diff --git a/dist/cli.d.ts b/dist/cli.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/cli.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/cli.js b/dist/cli.js new file mode 100644 index 0000000..40f399c --- /dev/null +++ b/dist/cli.js @@ -0,0 +1,204422 @@ +#!/usr/bin/env node + +'use strict'; + +var require$$0$1 = require('fs'); +var path$3 = require('path'); +var require$$0$2 = require('os'); +var require$$5 = require('crypto'); +var promises = require('fs/promises'); +var process$2 = require('process'); +var readline = require('readline'); +var require$$0$3 = require('events'); +var require$$1$1 = require('child_process'); +var require$$1$2 = require('util'); +var http$2 = require('http'); +var https$2 = require('https'); +var zlib$1 = require('zlib'); +var Stream = require('stream'); +var require$$0$4 = require('net'); +var require$$1$3 = require('tls'); +var Url = require('url'); +var require$$0$5 = require('punycode'); +var require$$0$6 = require('tty'); +var assert$6 = require('assert'); +var require$$0$7 = require('buffer'); +var require$$3$1 = require('dns'); +var VM = require('vm'); +var threads = require('worker_threads'); + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function getAugmentedNamespace(n) { + if (n.__esModule) return n; + var f = n.default; + if (typeof f == "function") { + var a = function a () { + if (this instanceof a) { + return Reflect.construct(f, arguments, this.constructor); + } + return f.apply(this, arguments); + }; + a.prototype = f.prototype; + } else a = {}; + Object.defineProperty(a, '__esModule', {value: true}); + Object.keys(n).forEach(function (k) { + var d = Object.getOwnPropertyDescriptor(n, k); + Object.defineProperty(a, k, d.get ? d : { + enumerable: true, + get: function () { + return n[k]; + } + }); + }); + return a; +} + +var figlet$2 = {exports: {}}; + +/* + FIGlet.js (a FIGDriver for FIGlet fonts) + Written by https://github.com/patorjk/figlet.js/graphs/contributors + Originally Written For: http://patorjk.com/software/taag/ + License: MIT (with this header staying intact) + + This JavaScript code aims to fully implement the FIGlet spec. + Full FIGlet spec: http://patorjk.com/software/taag/docs/figfont.txt + + FIGlet fonts are actually kind of complex, which is why you will see + a lot of code about parsing and interpreting rules. The actual generation + code is pretty simple and is done near the bottom of the code. +*/ + +(function (module) { + + const figlet = (() => { + // --------------------------------------------------------------------- + // Private static variables + + const FULL_WIDTH = 0, + FITTING = 1, + SMUSHING = 2, + CONTROLLED_SMUSHING = 3; + + // --------------------------------------------------------------------- + // Variable that will hold information about the fonts + + const figFonts = {}; // What stores all of the FIGlet font data + const figDefaults = { + font: "Standard", + fontPath: "./fonts", + }; + + // --------------------------------------------------------------------- + // Private static methods + + /* + This method takes in the oldLayout and newLayout data from the FIGfont header file and returns + the layout information. + */ + function getSmushingRules(oldLayout, newLayout) { + let rules = {}; + let val, index, len, code; + let codes = [ + [16384, "vLayout", SMUSHING], + [8192, "vLayout", FITTING], + [4096, "vRule5", true], + [2048, "vRule4", true], + [1024, "vRule3", true], + [512, "vRule2", true], + [256, "vRule1", true], + [128, "hLayout", SMUSHING], + [64, "hLayout", FITTING], + [32, "hRule6", true], + [16, "hRule5", true], + [8, "hRule4", true], + [4, "hRule3", true], + [2, "hRule2", true], + [1, "hRule1", true], + ]; + + val = newLayout !== null ? newLayout : oldLayout; + index = 0; + len = codes.length; + while (index < len) { + code = codes[index]; + if (val >= code[0]) { + val = val - code[0]; + rules[code[1]] = + typeof rules[code[1]] === "undefined" ? code[2] : rules[code[1]]; + } else if (code[1] !== "vLayout" && code[1] !== "hLayout") { + rules[code[1]] = false; + } + index++; + } + + if (typeof rules["hLayout"] === "undefined") { + if (oldLayout === 0) { + rules["hLayout"] = FITTING; + } else if (oldLayout === -1) { + rules["hLayout"] = FULL_WIDTH; + } else { + if ( + rules["hRule1"] || + rules["hRule2"] || + rules["hRule3"] || + rules["hRule4"] || + rules["hRule5"] || + rules["hRule6"] + ) { + rules["hLayout"] = CONTROLLED_SMUSHING; + } else { + rules["hLayout"] = SMUSHING; + } + } + } else if (rules["hLayout"] === SMUSHING) { + if ( + rules["hRule1"] || + rules["hRule2"] || + rules["hRule3"] || + rules["hRule4"] || + rules["hRule5"] || + rules["hRule6"] + ) { + rules["hLayout"] = CONTROLLED_SMUSHING; + } + } + + if (typeof rules["vLayout"] === "undefined") { + if ( + rules["vRule1"] || + rules["vRule2"] || + rules["vRule3"] || + rules["vRule4"] || + rules["vRule5"] + ) { + rules["vLayout"] = CONTROLLED_SMUSHING; + } else { + rules["vLayout"] = FULL_WIDTH; + } + } else if (rules["vLayout"] === SMUSHING) { + if ( + rules["vRule1"] || + rules["vRule2"] || + rules["vRule3"] || + rules["vRule4"] || + rules["vRule5"] + ) { + rules["vLayout"] = CONTROLLED_SMUSHING; + } + } + + return rules; + } + + /* The [vh]Rule[1-6]_Smush functions return the smushed character OR false if the two characters can't be smushed */ + + /* + Rule 1: EQUAL CHARACTER SMUSHING (code value 1) + + Two sub-characters are smushed into a single sub-character + if they are the same. This rule does not smush + hardblanks. (See rule 6 on hardblanks below) + */ + function hRule1_Smush(ch1, ch2, hardBlank) { + if (ch1 === ch2 && ch1 !== hardBlank) { + return ch1; + } + return false; + } + + /* + Rule 2: UNDERSCORE SMUSHING (code value 2) + + An underscore ("_") will be replaced by any of: "|", "/", + "\", "[", "]", "{", "}", "(", ")", "<" or ">". + */ + function hRule2_Smush(ch1, ch2) { + let rule2Str = "|/\\[]{}()<>"; + if (ch1 === "_") { + if (rule2Str.indexOf(ch2) !== -1) { + return ch2; + } + } else if (ch2 === "_") { + if (rule2Str.indexOf(ch1) !== -1) { + return ch1; + } + } + return false; + } + + /* + Rule 3: HIERARCHY SMUSHING (code value 4) + + A hierarchy of six classes is used: "|", "/\", "[]", "{}", + "()", and "<>". When two smushing sub-characters are + from different classes, the one from the latter class + will be used. + */ + function hRule3_Smush(ch1, ch2) { + let rule3Classes = "| /\\ [] {} () <>"; + let r3_pos1 = rule3Classes.indexOf(ch1); + let r3_pos2 = rule3Classes.indexOf(ch2); + if (r3_pos1 !== -1 && r3_pos2 !== -1) { + if (r3_pos1 !== r3_pos2 && Math.abs(r3_pos1 - r3_pos2) !== 1) { + const startPos = Math.max(r3_pos1, r3_pos2); + const endPos = startPos + 1; + return rule3Classes.substring(startPos, endPos); + } + } + return false; + } + + /* + Rule 4: OPPOSITE PAIR SMUSHING (code value 8) + + Smushes opposing brackets ("[]" or "]["), braces ("{}" or + "}{") and parentheses ("()" or ")(") together, replacing + any such pair with a vertical bar ("|"). + */ + function hRule4_Smush(ch1, ch2) { + let rule4Str = "[] {} ()"; + let r4_pos1 = rule4Str.indexOf(ch1); + let r4_pos2 = rule4Str.indexOf(ch2); + if (r4_pos1 !== -1 && r4_pos2 !== -1) { + if (Math.abs(r4_pos1 - r4_pos2) <= 1) { + return "|"; + } + } + return false; + } + + /* + Rule 5: BIG X SMUSHING (code value 16) + + Smushes "/\" into "|", "\/" into "Y", and "><" into "X". + Note that "<>" is not smushed in any way by this rule. + The name "BIG X" is historical; originally all three pairs + were smushed into "X". + */ + function hRule5_Smush(ch1, ch2) { + let rule5Str = "/\\ \\/ ><"; + let rule5Hash = { 0: "|", 3: "Y", 6: "X" }; + let r5_pos1 = rule5Str.indexOf(ch1); + let r5_pos2 = rule5Str.indexOf(ch2); + if (r5_pos1 !== -1 && r5_pos2 !== -1) { + if (r5_pos2 - r5_pos1 === 1) { + return rule5Hash[r5_pos1]; + } + } + return false; + } + + /* + Rule 6: HARDBLANK SMUSHING (code value 32) + + Smushes two hardblanks together, replacing them with a + single hardblank. (See "Hardblanks" below.) + */ + function hRule6_Smush(ch1, ch2, hardBlank) { + if (ch1 === hardBlank && ch2 === hardBlank) { + return hardBlank; + } + return false; + } + + /* + Rule 1: EQUAL CHARACTER SMUSHING (code value 256) + + Same as horizontal smushing rule 1. + */ + function vRule1_Smush(ch1, ch2) { + if (ch1 === ch2) { + return ch1; + } + return false; + } + + /* + Rule 2: UNDERSCORE SMUSHING (code value 512) + + Same as horizontal smushing rule 2. + */ + function vRule2_Smush(ch1, ch2) { + let rule2Str = "|/\\[]{}()<>"; + if (ch1 === "_") { + if (rule2Str.indexOf(ch2) !== -1) { + return ch2; + } + } else if (ch2 === "_") { + if (rule2Str.indexOf(ch1) !== -1) { + return ch1; + } + } + return false; + } + + /* + Rule 3: HIERARCHY SMUSHING (code value 1024) + + Same as horizontal smushing rule 3. + */ + function vRule3_Smush(ch1, ch2) { + let rule3Classes = "| /\\ [] {} () <>"; + let r3_pos1 = rule3Classes.indexOf(ch1); + let r3_pos2 = rule3Classes.indexOf(ch2); + if (r3_pos1 !== -1 && r3_pos2 !== -1) { + if (r3_pos1 !== r3_pos2 && Math.abs(r3_pos1 - r3_pos2) !== 1) { + const startPos = Math.max(r3_pos1, r3_pos2); + const endPos = startPos + 1; + return rule3Classes.substring(startPos, endPos); + } + } + return false; + } + + /* + Rule 4: HORIZONTAL LINE SMUSHING (code value 2048) + + Smushes stacked pairs of "-" and "_", replacing them with + a single "=" sub-character. It does not matter which is + found above the other. Note that vertical smushing rule 1 + will smush IDENTICAL pairs of horizontal lines, while this + rule smushes horizontal lines consisting of DIFFERENT + sub-characters. + */ + function vRule4_Smush(ch1, ch2) { + if ((ch1 === "-" && ch2 === "_") || (ch1 === "_" && ch2 === "-")) { + return "="; + } + return false; + } + + /* + Rule 5: VERTICAL LINE SUPERSMUSHING (code value 4096) + + This one rule is different from all others, in that it + "supersmushes" vertical lines consisting of several + vertical bars ("|"). This creates the illusion that + FIGcharacters have slid vertically against each other. + Supersmushing continues until any sub-characters other + than "|" would have to be smushed. Supersmushing can + produce impressive results, but it is seldom possible, + since other sub-characters would usually have to be + considered for smushing as soon as any such stacked + vertical lines are encountered. + */ + function vRule5_Smush(ch1, ch2) { + if (ch1 === "|" && ch2 === "|") { + return "|"; + } + return false; + } + + /* + Universal smushing simply overrides the sub-character from the + earlier FIGcharacter with the sub-character from the later + FIGcharacter. This produces an "overlapping" effect with some + FIGfonts, wherin the latter FIGcharacter may appear to be "in + front". + */ + function uni_Smush(ch1, ch2, hardBlank) { + if (ch2 === " " || ch2 === "") { + return ch1; + } else if (ch2 === hardBlank && ch1 !== " ") { + return ch1; + } else { + return ch2; + } + } + + // -------------------------------------------------------------------------- + // main vertical smush routines (excluding rules) + + /* + txt1 - A line of text + txt2 - A line of text + opts - FIGlet options array + + About: Takes in two lines of text and returns one of the following: + "valid" - These lines can be smushed together given the current smushing rules + "end" - The lines can be smushed, but we're at a stopping point + "invalid" - The two lines cannot be smushed together + */ + function canVerticalSmush(txt1, txt2, opts) { + if (opts.fittingRules.vLayout === FULL_WIDTH) { + return "invalid"; + } + let ii, + len = Math.min(txt1.length, txt2.length), + ch1, + ch2, + endSmush = false, + validSmush; + if (len === 0) { + return "invalid"; + } + + for (ii = 0; ii < len; ii++) { + ch1 = txt1.substring(ii, ii + 1); + ch2 = txt2.substring(ii, ii + 1); + if (ch1 !== " " && ch2 !== " ") { + if (opts.fittingRules.vLayout === FITTING) { + return "invalid"; + } else if (opts.fittingRules.vLayout === SMUSHING) { + return "end"; + } else { + if (vRule5_Smush(ch1, ch2)) { + endSmush = endSmush || false; + continue; + } // rule 5 allow for "super" smushing, but only if we're not already ending this smush + validSmush = false; + validSmush = opts.fittingRules.vRule1 + ? vRule1_Smush(ch1, ch2) + : validSmush; + validSmush = + !validSmush && opts.fittingRules.vRule2 + ? vRule2_Smush(ch1, ch2) + : validSmush; + validSmush = + !validSmush && opts.fittingRules.vRule3 + ? vRule3_Smush(ch1, ch2) + : validSmush; + validSmush = + !validSmush && opts.fittingRules.vRule4 + ? vRule4_Smush(ch1, ch2) + : validSmush; + endSmush = true; + if (!validSmush) { + return "invalid"; + } + } + } + } + if (endSmush) { + return "end"; + } else { + return "valid"; + } + } + + function getVerticalSmushDist(lines1, lines2, opts) { + let maxDist = lines1.length; + let len1 = lines1.length; + lines2.length; + let subLines1, subLines2, slen; + let curDist = 1; + let ii, ret, result; + while (curDist <= maxDist) { + subLines1 = lines1.slice(Math.max(0, len1 - curDist), len1); + subLines2 = lines2.slice(0, Math.min(maxDist, curDist)); + + slen = subLines2.length; //TODO:check this + result = ""; + for (ii = 0; ii < slen; ii++) { + ret = canVerticalSmush(subLines1[ii], subLines2[ii], opts); + if (ret === "end") { + result = ret; + } else if (ret === "invalid") { + result = ret; + break; + } else { + if (result === "") { + result = "valid"; + } + } + } + + if (result === "invalid") { + curDist--; + break; + } + if (result === "end") { + break; + } + if (result === "valid") { + curDist++; + } + } + + return Math.min(maxDist, curDist); + } + + function verticallySmushLines(line1, line2, opts) { + let ii, + len = Math.min(line1.length, line2.length); + let ch1, + ch2, + result = "", + validSmush; + + for (ii = 0; ii < len; ii++) { + ch1 = line1.substring(ii, ii + 1); + ch2 = line2.substring(ii, ii + 1); + if (ch1 !== " " && ch2 !== " ") { + if (opts.fittingRules.vLayout === FITTING) { + result += uni_Smush(ch1, ch2); + } else if (opts.fittingRules.vLayout === SMUSHING) { + result += uni_Smush(ch1, ch2); + } else { + validSmush = false; + validSmush = opts.fittingRules.vRule5 + ? vRule5_Smush(ch1, ch2) + : validSmush; + validSmush = + !validSmush && opts.fittingRules.vRule1 + ? vRule1_Smush(ch1, ch2) + : validSmush; + validSmush = + !validSmush && opts.fittingRules.vRule2 + ? vRule2_Smush(ch1, ch2) + : validSmush; + validSmush = + !validSmush && opts.fittingRules.vRule3 + ? vRule3_Smush(ch1, ch2) + : validSmush; + validSmush = + !validSmush && opts.fittingRules.vRule4 + ? vRule4_Smush(ch1, ch2) + : validSmush; + result += validSmush; + } + } else { + result += uni_Smush(ch1, ch2); + } + } + return result; + } + + function verticalSmush(lines1, lines2, overlap, opts) { + let len1 = lines1.length; + let len2 = lines2.length; + let piece1 = lines1.slice(0, Math.max(0, len1 - overlap)); + let piece2_1 = lines1.slice(Math.max(0, len1 - overlap), len1); + let piece2_2 = lines2.slice(0, Math.min(overlap, len2)); + let ii, + len, + line, + piece2 = [], + piece3, + result = []; + + len = piece2_1.length; + for (ii = 0; ii < len; ii++) { + if (ii >= len2) { + line = piece2_1[ii]; + } else { + line = verticallySmushLines(piece2_1[ii], piece2_2[ii], opts); + } + piece2.push(line); + } + + piece3 = lines2.slice(Math.min(overlap, len2), len2); + + return result.concat(piece1, piece2, piece3); + } + + function padLines(lines, numSpaces) { + let ii, + len = lines.length, + padding = ""; + for (ii = 0; ii < numSpaces; ii++) { + padding += " "; + } + for (ii = 0; ii < len; ii++) { + lines[ii] += padding; + } + } + + function smushVerticalFigLines(output, lines, opts) { + let len1 = output[0].length; + let len2 = lines[0].length; + let overlap; + if (len1 > len2) { + padLines(lines, len1 - len2); + } else if (len2 > len1) { + padLines(output, len2 - len1); + } + overlap = getVerticalSmushDist(output, lines, opts); + return verticalSmush(output, lines, overlap, opts); + } + + // ------------------------------------------------------------------------- + // Main horizontal smush routines (excluding rules) + + function getHorizontalSmushLength(txt1, txt2, opts) { + if (opts.fittingRules.hLayout === FULL_WIDTH) { + return 0; + } + let ii, + len1 = txt1.length, + len2 = txt2.length; + let maxDist = len1; + let curDist = 1; + let breakAfter = false; + let validSmush = false; + let seg1, seg2, ch1, ch2; + if (len1 === 0) { + return 0; + } + + distCal: while (curDist <= maxDist) { + const seg1StartPos = len1 - curDist; + seg1 = txt1.substring(seg1StartPos, seg1StartPos + curDist); + seg2 = txt2.substring(0, Math.min(curDist, len2)); + for (ii = 0; ii < Math.min(curDist, len2); ii++) { + ch1 = seg1.substring(ii, ii + 1); + ch2 = seg2.substring(ii, ii + 1); + if (ch1 !== " " && ch2 !== " ") { + if (opts.fittingRules.hLayout === FITTING) { + curDist = curDist - 1; + break distCal; + } else if (opts.fittingRules.hLayout === SMUSHING) { + if (ch1 === opts.hardBlank || ch2 === opts.hardBlank) { + curDist = curDist - 1; // universal smushing does not smush hardblanks + } + break distCal; + } else { + breakAfter = true; // we know we need to break, but we need to check if our smushing rules will allow us to smush the overlapped characters + validSmush = false; // the below checks will let us know if we can smush these characters + + validSmush = opts.fittingRules.hRule1 + ? hRule1_Smush(ch1, ch2, opts.hardBlank) + : validSmush; + validSmush = + !validSmush && opts.fittingRules.hRule2 + ? hRule2_Smush(ch1, ch2, opts.hardBlank) + : validSmush; + validSmush = + !validSmush && opts.fittingRules.hRule3 + ? hRule3_Smush(ch1, ch2, opts.hardBlank) + : validSmush; + validSmush = + !validSmush && opts.fittingRules.hRule4 + ? hRule4_Smush(ch1, ch2, opts.hardBlank) + : validSmush; + validSmush = + !validSmush && opts.fittingRules.hRule5 + ? hRule5_Smush(ch1, ch2, opts.hardBlank) + : validSmush; + validSmush = + !validSmush && opts.fittingRules.hRule6 + ? hRule6_Smush(ch1, ch2, opts.hardBlank) + : validSmush; + + if (!validSmush) { + curDist = curDist - 1; + break distCal; + } + } + } + } + if (breakAfter) { + break; + } + curDist++; + } + return Math.min(maxDist, curDist); + } + + function horizontalSmush(textBlock1, textBlock2, overlap, opts) { + let ii, + jj, + outputFig = [], + overlapStart, + piece1, + piece2, + piece3, + len1, + len2, + txt1, + txt2; + + for (ii = 0; ii < opts.height; ii++) { + txt1 = textBlock1[ii]; + txt2 = textBlock2[ii]; + len1 = txt1.length; + len2 = txt2.length; + overlapStart = len1 - overlap; + piece1 = txt1.substr(0, Math.max(0, overlapStart)); + piece2 = ""; + + // determine overlap piece + const seg1StartPos = Math.max(0, len1 - overlap); + var seg1 = txt1.substring(seg1StartPos, seg1StartPos + overlap); + var seg2 = txt2.substring(0, Math.min(overlap, len2)); + + for (jj = 0; jj < overlap; jj++) { + var ch1 = jj < len1 ? seg1.substring(jj, jj + 1) : " "; + var ch2 = jj < len2 ? seg2.substring(jj, jj + 1) : " "; + + if (ch1 !== " " && ch2 !== " ") { + if (opts.fittingRules.hLayout === FITTING) { + piece2 += uni_Smush(ch1, ch2, opts.hardBlank); + } else if (opts.fittingRules.hLayout === SMUSHING) { + piece2 += uni_Smush(ch1, ch2, opts.hardBlank); + } else { + // Controlled Smushing + var nextCh = ""; + nextCh = + !nextCh && opts.fittingRules.hRule1 + ? hRule1_Smush(ch1, ch2, opts.hardBlank) + : nextCh; + nextCh = + !nextCh && opts.fittingRules.hRule2 + ? hRule2_Smush(ch1, ch2, opts.hardBlank) + : nextCh; + nextCh = + !nextCh && opts.fittingRules.hRule3 + ? hRule3_Smush(ch1, ch2, opts.hardBlank) + : nextCh; + nextCh = + !nextCh && opts.fittingRules.hRule4 + ? hRule4_Smush(ch1, ch2, opts.hardBlank) + : nextCh; + nextCh = + !nextCh && opts.fittingRules.hRule5 + ? hRule5_Smush(ch1, ch2, opts.hardBlank) + : nextCh; + nextCh = + !nextCh && opts.fittingRules.hRule6 + ? hRule6_Smush(ch1, ch2, opts.hardBlank) + : nextCh; + nextCh = nextCh || uni_Smush(ch1, ch2, opts.hardBlank); + piece2 += nextCh; + } + } else { + piece2 += uni_Smush(ch1, ch2, opts.hardBlank); + } + } + + if (overlap >= len2) { + piece3 = ""; + } else { + piece3 = txt2.substring(overlap, overlap + Math.max(0, len2 - overlap)); + } + outputFig[ii] = piece1 + piece2 + piece3; + } + return outputFig; + } + + /* + Creates new empty ASCII placeholder of give len + - len - number + */ + function newFigChar(len) { + let outputFigText = [], + row; + for (row = 0; row < len; row++) { + outputFigText[row] = ""; + } + return outputFigText; + } + + /* + Return max line of the ASCII Art + - text is array of lines for text + - char is next character + */ + const figLinesWidth = function (textLines) { + return Math.max.apply( + Math, + textLines.map(function (line, i) { + return line.length; + }) + ); + }; + + /* + join words or single characaters into single Fig line + - array - array of ASCII words or single characters: {fig: array, overlap: number} + - len - height of the Characters (number of rows) + - opt - options object + */ + function joinFigArray(array, len, opts) { + return array.reduce(function (acc, data) { + return horizontalSmush(acc, data.fig, data.overlap, opts); + }, newFigChar(len)); + } + + /* + break long word return leftover characters and line before the break + - figChars - list of single ASCII characters in form {fig, overlap} + - len - number of rows + - opt - options object + */ + function breakWord(figChars, len, opts) { + const result = {}; + for (let i = figChars.length; --i; ) { + let w = joinFigArray(figChars.slice(0, i), len, opts); + if (figLinesWidth(w) <= opts.width) { + result.outputFigText = w; + if (i < figChars.length) { + result.chars = figChars.slice(i); + } else { + result.chars = []; + } + break; + } + } + return result; + } + + function generateFigTextLines(txt, figChars, opts) { + let charIndex, + figChar, + overlap = 0, + row, + outputFigText, + len, + height = opts.height, + outputFigLines = [], + maxWidth, + nextFigChars, + figWords = [], + char, + isSpace, + textFigWord, + textFigLine, + tmpBreak; + + outputFigText = newFigChar(height); + if (opts.width > 0 && opts.whitespaceBreak) { + // list of characters is used to break in the middle of the word when word is logner + // chars is array of characters with {fig, overlap} and overlap is for whole word + nextFigChars = { + chars: [], + overlap: overlap, + }; + } + if (opts.printDirection === 1) { + txt = txt.split("").reverse().join(""); + } + len = txt.length; + for (charIndex = 0; charIndex < len; charIndex++) { + char = txt.substring(charIndex, charIndex + 1); + isSpace = char.match(/\s/); + figChar = figChars[char.charCodeAt(0)]; + textFigLine = null; + if (figChar) { + if (opts.fittingRules.hLayout !== FULL_WIDTH) { + overlap = 10000; // a value too high to be the overlap + for (row = 0; row < opts.height; row++) { + overlap = Math.min( + overlap, + getHorizontalSmushLength(outputFigText[row], figChar[row], opts) + ); + } + overlap = overlap === 10000 ? 0 : overlap; + } + if (opts.width > 0) { + if (opts.whitespaceBreak) { + // next character in last word (figChars have same data as words) + textFigWord = joinFigArray( + nextFigChars.chars.concat([ + { + fig: figChar, + overlap: overlap, + }, + ]), + height, + opts + ); + textFigLine = joinFigArray( + figWords.concat([ + { + fig: textFigWord, + overlap: nextFigChars.overlap, + }, + ]), + height, + opts + ); + maxWidth = figLinesWidth(textFigLine); + } else { + textFigLine = horizontalSmush( + outputFigText, + figChar, + overlap, + opts + ); + maxWidth = figLinesWidth(textFigLine); + } + if (maxWidth >= opts.width && charIndex > 0) { + if (opts.whitespaceBreak) { + outputFigText = joinFigArray(figWords.slice(0, -1), height, opts); + if (figWords.length > 1) { + outputFigLines.push(outputFigText); + outputFigText = newFigChar(height); + } + figWords = []; + } else { + outputFigLines.push(outputFigText); + outputFigText = newFigChar(height); + } + } + } + if (opts.width > 0 && opts.whitespaceBreak) { + if (!isSpace || charIndex === len - 1) { + nextFigChars.chars.push({ fig: figChar, overlap: overlap }); + } + if (isSpace || charIndex === len - 1) { + // break long words + tmpBreak = null; + while (true) { + textFigLine = joinFigArray(nextFigChars.chars, height, opts); + maxWidth = figLinesWidth(textFigLine); + if (maxWidth >= opts.width) { + tmpBreak = breakWord(nextFigChars.chars, height, opts); + nextFigChars = { chars: tmpBreak.chars }; + outputFigLines.push(tmpBreak.outputFigText); + } else { + break; + } + } + // any leftovers + if (maxWidth > 0) { + if (tmpBreak) { + figWords.push({ fig: textFigLine, overlap: 1 }); + } else { + figWords.push({ + fig: textFigLine, + overlap: nextFigChars.overlap, + }); + } + } + // save space character and current overlap for smush in joinFigWords + if (isSpace) { + figWords.push({ fig: figChar, overlap: overlap }); + outputFigText = newFigChar(height); + } + if (charIndex === len - 1) { + // last line + outputFigText = joinFigArray(figWords, height, opts); + } + nextFigChars = { + chars: [], + overlap: overlap, + }; + continue; + } + } + outputFigText = horizontalSmush(outputFigText, figChar, overlap, opts); + } + } + // special case when last line would be empty + // this may happen if text fit exactly opt.width + if (figLinesWidth(outputFigText) > 0) { + outputFigLines.push(outputFigText); + } + // remove hardblanks + if (opts.showHardBlanks !== true) { + outputFigLines.forEach(function (outputFigText) { + len = outputFigText.length; + for (row = 0; row < len; row++) { + outputFigText[row] = outputFigText[row].replace( + new RegExp("\\" + opts.hardBlank, "g"), + " " + ); + } + }); + } + return outputFigLines; + } + + // ------------------------------------------------------------------------- + // Parsing and Generation methods + + const getHorizontalFittingRules = function (layout, options) { + let props = [ + "hLayout", + "hRule1", + "hRule2", + "hRule3", + "hRule4", + "hRule5", + "hRule6", + ], + params = {}, + ii; + if (layout === "default") { + for (ii = 0; ii < props.length; ii++) { + params[props[ii]] = options.fittingRules[props[ii]]; + } + } else if (layout === "full") { + params = { + hLayout: FULL_WIDTH, + hRule1: false, + hRule2: false, + hRule3: false, + hRule4: false, + hRule5: false, + hRule6: false, + }; + } else if (layout === "fitted") { + params = { + hLayout: FITTING, + hRule1: false, + hRule2: false, + hRule3: false, + hRule4: false, + hRule5: false, + hRule6: false, + }; + } else if (layout === "controlled smushing") { + params = { + hLayout: CONTROLLED_SMUSHING, + hRule1: true, + hRule2: true, + hRule3: true, + hRule4: true, + hRule5: true, + hRule6: true, + }; + } else if (layout === "universal smushing") { + params = { + hLayout: SMUSHING, + hRule1: false, + hRule2: false, + hRule3: false, + hRule4: false, + hRule5: false, + hRule6: false, + }; + } else { + return; + } + return params; + }; + + const getVerticalFittingRules = function (layout, options) { + let props = ["vLayout", "vRule1", "vRule2", "vRule3", "vRule4", "vRule5"], + params = {}, + ii; + if (layout === "default") { + for (ii = 0; ii < props.length; ii++) { + params[props[ii]] = options.fittingRules[props[ii]]; + } + } else if (layout === "full") { + params = { + vLayout: FULL_WIDTH, + vRule1: false, + vRule2: false, + vRule3: false, + vRule4: false, + vRule5: false, + }; + } else if (layout === "fitted") { + params = { + vLayout: FITTING, + vRule1: false, + vRule2: false, + vRule3: false, + vRule4: false, + vRule5: false, + }; + } else if (layout === "controlled smushing") { + params = { + vLayout: CONTROLLED_SMUSHING, + vRule1: true, + vRule2: true, + vRule3: true, + vRule4: true, + vRule5: true, + }; + } else if (layout === "universal smushing") { + params = { + vLayout: SMUSHING, + vRule1: false, + vRule2: false, + vRule3: false, + vRule4: false, + vRule5: false, + }; + } else { + return; + } + return params; + }; + + /* + Generates the ASCII Art + - fontName: Font to use + - option: Options to override the defaults + - txt: The text to make into ASCII Art + */ + const generateText = function (fontName, options, txt) { + txt = txt.replace(/\r\n/g, "\n").replace(/\r/g, "\n"); + let lines = txt.split("\n"); + let figLines = []; + let ii, len, output; + len = lines.length; + for (ii = 0; ii < len; ii++) { + figLines = figLines.concat( + generateFigTextLines(lines[ii], figFonts[fontName], options) + ); + } + len = figLines.length; + output = figLines[0]; + for (ii = 1; ii < len; ii++) { + output = smushVerticalFigLines(output, figLines[ii], options); + } + + return output ? output.join("\n") : ""; + }; + + /* + takes assigned options and merges them with the default options from the choosen font + */ + function _reworkFontOpts(fontOpts, options) { + let myOpts = JSON.parse(JSON.stringify(fontOpts)), // make a copy because we may edit this (see below) + params, + prop; + + /* + If the user is chosing to use a specific type of layout (e.g., 'full', 'fitted', etc etc) + Then we need to override the default font options. + */ + if (typeof options.horizontalLayout !== "undefined") { + params = getHorizontalFittingRules(options.horizontalLayout, fontOpts); + for (prop in params) { + if (params.hasOwnProperty(prop)) { + myOpts.fittingRules[prop] = params[prop]; + } + } + } + if (typeof options.verticalLayout !== "undefined") { + params = getVerticalFittingRules(options.verticalLayout, fontOpts); + for (prop in params) { + if (params.hasOwnProperty(prop)) { + myOpts.fittingRules[prop] = params[prop]; + } + } + } + myOpts.printDirection = + typeof options.printDirection !== "undefined" + ? options.printDirection + : fontOpts.printDirection; + myOpts.showHardBlanks = options.showHardBlanks || false; + myOpts.width = options.width || -1; + myOpts.whitespaceBreak = options.whitespaceBreak || false; + + return myOpts; + } + + // ------------------------------------------------------------------------- + // Public methods + + /* + A short-cut for the figlet.text method + + Parameters: + - txt (string): The text to make into ASCII Art + - options (object/string - optional): Options that will override the current font's default options. + If a string is provided instead of an object, it is assumed to be the font name. + + * font + * horizontalLayout + * verticalLayout + * showHardBlanks - Wont remove hardblank characters + + - next (function): A callback function, it will contained the outputted ASCII Art. + */ + const me = function (txt, options, next) { + return me.text(txt, options, next); + }; + me.text = async function (txt, options, next) { + let fontName = ""; + + // Validate inputs + txt = txt + ""; + + if (typeof arguments[1] === "function") { + next = options; + options = {}; + options.font = figDefaults.font; // default font + } + + if (typeof options === "string") { + fontName = options; + options = {}; + } else { + options = options || {}; + fontName = options.font || figDefaults.font; + } + + return await new Promise((resolve, reject) => { + /* + Load the font. If it loads, it's data will be contained in the figFonts object. + The callback will recieve a fontsOpts object, which contains the default + options of the font (its fitting rules, etc etc). + */ + me.loadFont(fontName, function (err, fontOpts) { + if (err) { + reject(err); + if (next) next(err); + return; + } + + const generatedTxt = generateText( + fontName, + _reworkFontOpts(fontOpts, options), + txt + ); + + resolve(generatedTxt); + if (next) next(null, generatedTxt); + }); + }); + }; + + /* + Synchronous version of figlet.text. + Accepts the same parameters. + */ + me.textSync = function (txt, options) { + let fontName = ""; + + // Validate inputs + txt = txt + ""; + + if (typeof options === "string") { + fontName = options; + options = {}; + } else { + options = options || {}; + fontName = options.font || figDefaults.font; + } + + var fontOpts = _reworkFontOpts(me.loadFontSync(fontName), options); + return generateText(fontName, fontOpts, txt); + }; + + /* + Returns metadata about a specfic FIGlet font. + + Returns: + next(err, options, headerComment) + - err: The error if an error occurred, otherwise null/falsey. + - options (object): The options defined for the font. + - headerComment (string): The font's header comment. + */ + me.metadata = function (fontName, next) { + fontName = fontName + ""; + + /* + Load the font. If it loads, it's data will be contained in the figFonts object. + The callback will recieve a fontsOpts object, which contains the default + options of the font (its fitting rules, etc etc). + */ + me.loadFont(fontName, function (err, fontOpts) { + if (err) { + next(err); + return; + } + + next(null, fontOpts, figFonts[fontName].comment); + }); + }; + + /* + Allows you to override defaults. See the definition of the figDefaults object up above + to see what properties can be overridden. + Returns the options for the font. + */ + me.defaults = function (opts) { + if (typeof opts === "object" && opts !== null) { + for (var prop in opts) { + if (opts.hasOwnProperty(prop)) { + figDefaults[prop] = opts[prop]; + } + } + } + return JSON.parse(JSON.stringify(figDefaults)); + }; + + /* + Parses data from a FIGlet font file and places it into the figFonts object. + */ + me.parseFont = function (fontName, data) { + data = data.replace(/\r\n/g, "\n").replace(/\r/g, "\n"); + figFonts[fontName] = {}; + + var lines = data.split("\n"); + var headerData = lines.splice(0, 1)[0].split(" "); + var figFont = figFonts[fontName]; + var opts = {}; + + opts.hardBlank = headerData[0].substr(5, 1); + opts.height = parseInt(headerData[1], 10); + opts.baseline = parseInt(headerData[2], 10); + opts.maxLength = parseInt(headerData[3], 10); + opts.oldLayout = parseInt(headerData[4], 10); + opts.numCommentLines = parseInt(headerData[5], 10); + opts.printDirection = + headerData.length >= 6 ? parseInt(headerData[6], 10) : 0; + opts.fullLayout = + headerData.length >= 7 ? parseInt(headerData[7], 10) : null; + opts.codeTagCount = + headerData.length >= 8 ? parseInt(headerData[8], 10) : null; + opts.fittingRules = getSmushingRules(opts.oldLayout, opts.fullLayout); + + figFont.options = opts; + + // error check + if ( + opts.hardBlank.length !== 1 || + isNaN(opts.height) || + isNaN(opts.baseline) || + isNaN(opts.maxLength) || + isNaN(opts.oldLayout) || + isNaN(opts.numCommentLines) + ) { + throw new Error("FIGlet header contains invalid values."); + } + + /* + All FIGlet fonts must contain chars 32-126, 196, 214, 220, 228, 246, 252, 223 + */ + + let charNums = [], + ii; + for (ii = 32; ii <= 126; ii++) { + charNums.push(ii); + } + charNums = charNums.concat(196, 214, 220, 228, 246, 252, 223); + + // error check - validate that there are enough lines in the file + if (lines.length < opts.numCommentLines + opts.height * charNums.length) { + throw new Error("FIGlet file is missing data."); + } + + /* + Parse out the context of the file and put it into our figFont object + */ + + let cNum, + endCharRegEx, + parseError = false; + + figFont.comment = lines.splice(0, opts.numCommentLines).join("\n"); + figFont.numChars = 0; + + while (lines.length > 0 && figFont.numChars < charNums.length) { + cNum = charNums[figFont.numChars]; + figFont[cNum] = lines.splice(0, opts.height); + // remove end sub-chars + for (ii = 0; ii < opts.height; ii++) { + if (typeof figFont[cNum][ii] === "undefined") { + figFont[cNum][ii] = ""; + } else { + endCharRegEx = new RegExp( + "\\" + + figFont[cNum][ii].substr(figFont[cNum][ii].length - 1, 1) + + "+$" + ); + figFont[cNum][ii] = figFont[cNum][ii].replace(endCharRegEx, ""); + } + } + figFont.numChars++; + } + + /* + Now we check to see if any additional characters are present + */ + + while (lines.length > 0) { + cNum = lines.splice(0, 1)[0].split(" ")[0]; + if (/^0[xX][0-9a-fA-F]+$/.test(cNum)) { + cNum = parseInt(cNum, 16); + } else if (/^0[0-7]+$/.test(cNum)) { + cNum = parseInt(cNum, 8); + } else if (/^[0-9]+$/.test(cNum)) { + cNum = parseInt(cNum, 10); + } else if (/^-0[xX][0-9a-fA-F]+$/.test(cNum)) { + cNum = parseInt(cNum, 16); + } else { + if (cNum === "") { + break; + } + // something's wrong + console.log("Invalid data:" + cNum); + parseError = true; + break; + } + + figFont[cNum] = lines.splice(0, opts.height); + // remove end sub-chars + for (ii = 0; ii < opts.height; ii++) { + if (typeof figFont[cNum][ii] === "undefined") { + figFont[cNum][ii] = ""; + } else { + endCharRegEx = new RegExp( + "\\" + + figFont[cNum][ii].substr(figFont[cNum][ii].length - 1, 1) + + "+$" + ); + figFont[cNum][ii] = figFont[cNum][ii].replace(endCharRegEx, ""); + } + } + figFont.numChars++; + } + + // error check + if (parseError === true) { + throw new Error("Error parsing data."); + } + + return opts; + }; + + /* + Loads a font. + */ + me.loadFont = function (fontName, next) { + if (figFonts[fontName]) { + next(null, figFonts[fontName].options); + return; + } + + if (typeof fetch !== "function") { + console.error( + "figlet.js requires the fetch API or a fetch polyfill such as https://cdnjs.com/libraries/fetch" + ); + throw new Error("fetch is required for figlet.js to work."); + } + + fetch(figDefaults.fontPath + "/" + fontName + ".flf") + .then(function (response) { + if (response.ok) { + return response.text(); + } + + console.log("Unexpected response", response); + throw new Error("Network response was not ok."); + }) + .then(function (text) { + next(null, me.parseFont(fontName, text)); + }) + .catch(next); + }; + + /* + loads a font synchronously, not implemented for the browser + */ + me.loadFontSync = function (name) { + if (figFonts[name]) { + return figFonts[name].options; + } + throw new Error( + "synchronous font loading is not implemented for the browser" + ); + }; + + /* + preloads a list of fonts prior to using textSync + - fonts: an array of font names (i.e. ["Standard","Soft"]) + - next: callback function + */ + me.preloadFonts = function (fonts, next) { + let fontData = []; + + fonts + .reduce(function (promise, name) { + return promise.then(function () { + return fetch(figDefaults.fontPath + "/" + name + ".flf") + .then((response) => { + return response.text(); + }) + .then(function (data) { + fontData.push(data); + }); + }); + }, Promise.resolve()) + .then(function (res) { + for (var i in fonts) { + if (fonts.hasOwnProperty(i)) { + me.parseFont(fonts[i], fontData[i]); + } + } + + if (next) { + next(); + } + }); + }; + + me.figFonts = figFonts; + + return me; + })(); + + // for node.js + { + { + module.exports = figlet; + } + } +} (figlet$2)); + +var figletExports = figlet$2.exports; + +/* + Node plugin for figlet.js +*/ + +const figlet = figletExports, + fs$2 = require$$0$1, + path$2 = path$3, + fontDir = path$2.join(__dirname, "/../fonts/"); + +/* + Loads a font into the figlet object. + + Parameters: + - name (string): Name of the font to load. + - next (function): Callback function. +*/ +figlet.loadFont = function (name, next) { + if (figlet.figFonts[name]) { + next(null, figlet.figFonts[name].options); + return; + } + + fs$2.readFile( + path$2.join(fontDir, name + ".flf"), + { encoding: "utf-8" }, + function (err, fontData) { + if (err) { + return next(err); + } + + fontData = fontData + ""; + try { + next(null, figlet.parseFont(name, fontData)); + } catch (error) { + next(error); + } + } + ); +}; + +/* + Loads a font synchronously into the figlet object. + + Parameters: + - name (string): Name of the font to load. + */ +figlet.loadFontSync = function (name) { + if (figlet.figFonts[name]) { + return figlet.figFonts[name].options; + } + + var fontData = fs$2.readFileSync(path$2.join(fontDir, name + ".flf"), { + encoding: "utf-8", + }); + + fontData = fontData + ""; + return figlet.parseFont(name, fontData); +}; + +/* + Returns an array containing all of the font names +*/ +figlet.fonts = function (next) { + var fontList = []; + fs$2.readdir(fontDir, function (err, files) { + // '/' denotes the root folder + if (err) { + return next(err); + } + + files.forEach(function (file) { + if (/\.flf$/.test(file)) { + fontList.push(file.replace(/\.flf$/, "")); + } + }); + + next(null, fontList); + }); +}; + +figlet.fontsSync = function () { + var fontList = []; + fs$2.readdirSync(fontDir).forEach(function (file) { + if (/\.flf$/.test(file)) { + fontList.push(file.replace(/\.flf$/, "")); + } + }); + + return fontList; +}; + +var nodeFiglet = figlet; + +var figlet$1 = /*@__PURE__*/getDefaultExportFromCjs(nodeFiglet); + +const figletStandard = `flf2a$ 6 5 16 15 13 0 24463 229 +Standard by Glenn Chappell & Ian Chai 3/93 -- based on Frank's .sig +Includes ISO Latin-1 +figlet release 2.1 -- 12 Aug 1994 +Modified for figlet 2.2 by John Cowan + to add Latin-{2,3,4,5} support (Unicode U+0100-017F). +Permission is hereby given to modify this font, as long as the +modifier's name is placed on a comment line. + +Modified by Paul Burton 12/96 to include new parameter +supported by FIGlet and FIGWin. May also be slightly modified for better use +of new full-width/kern/smush alternatives, but default output is NOT changed. + +Font modified May 20, 2012 by patorjk to add the 0xCA0 character + $@ + $@ + $@ + $@ + $@ + $@@ + _ @ + | |@ + | |@ + |_|@ + (_)@ + @@ + _ _ @ + ( | )@ + V V @ + $ @ + $ @ + @@ + _ _ @ + _| || |_ @ + |_ .. _|@ + |_ _|@ + |_||_| @ + @@ + _ @ + | | @ + / __)@ + \\__ \\@ + ( /@ + |_| @@ + _ __@ + (_)/ /@ + / / @ + / /_ @ + /_/(_)@ + @@ + ___ @ + ( _ ) @ + / _ \\/\\@ + | (_> <@ + \\___/\\/@ + @@ + _ @ + ( )@ + |/ @ + $ @ + $ @ + @@ + __@ + / /@ + | | @ + | | @ + | | @ + \\_\\@@ + __ @ + \\ \\ @ + | |@ + | |@ + | |@ + /_/ @@ + @ + __/\\__@ + \\ /@ + /_ _\\@ + \\/ @ + @@ + @ + _ @ + _| |_ @ + |_ _|@ + |_| @ + @@ + @ + @ + @ + _ @ + ( )@ + |/ @@ + @ + @ + _____ @ + |_____|@ + $ @ + @@ + @ + @ + @ + _ @ + (_)@ + @@ + __@ + / /@ + / / @ + / / @ + /_/ @ + @@ + ___ @ + / _ \\ @ + | | | |@ + | |_| |@ + \\___/ @ + @@ + _ @ + / |@ + | |@ + | |@ + |_|@ + @@ + ____ @ + |___ \\ @ + __) |@ + / __/ @ + |_____|@ + @@ + _____ @ + |___ / @ + |_ \\ @ + ___) |@ + |____/ @ + @@ + _ _ @ + | || | @ + | || |_ @ + |__ _|@ + |_| @ + @@ + ____ @ + | ___| @ + |___ \\ @ + ___) |@ + |____/ @ + @@ + __ @ + / /_ @ + | '_ \\ @ + | (_) |@ + \\___/ @ + @@ + _____ @ + |___ |@ + / / @ + / / @ + /_/ @ + @@ + ___ @ + ( _ ) @ + / _ \\ @ + | (_) |@ + \\___/ @ + @@ + ___ @ + / _ \\ @ + | (_) |@ + \\__, |@ + /_/ @ + @@ + @ + _ @ + (_)@ + _ @ + (_)@ + @@ + @ + _ @ + (_)@ + _ @ + ( )@ + |/ @@ + __@ + / /@ + / / @ + \\ \\ @ + \\_\\@ + @@ + @ + _____ @ + |_____|@ + |_____|@ + $ @ + @@ + __ @ + \\ \\ @ + \\ \\@ + / /@ + /_/ @ + @@ + ___ @ + |__ \\@ + / /@ + |_| @ + (_) @ + @@ + ____ @ + / __ \\ @ + / / _\` |@ + | | (_| |@ + \\ \\__,_|@ + \\____/ @@ + _ @ + / \\ @ + / _ \\ @ + / ___ \\ @ + /_/ \\_\\@ + @@ + ____ @ + | __ ) @ + | _ \\ @ + | |_) |@ + |____/ @ + @@ + ____ @ + / ___|@ + | | @ + | |___ @ + \\____|@ + @@ + ____ @ + | _ \\ @ + | | | |@ + | |_| |@ + |____/ @ + @@ + _____ @ + | ____|@ + | _| @ + | |___ @ + |_____|@ + @@ + _____ @ + | ___|@ + | |_ @ + | _| @ + |_| @ + @@ + ____ @ + / ___|@ + | | _ @ + | |_| |@ + \\____|@ + @@ + _ _ @ + | | | |@ + | |_| |@ + | _ |@ + |_| |_|@ + @@ + ___ @ + |_ _|@ + | | @ + | | @ + |___|@ + @@ + _ @ + | |@ + _ | |@ + | |_| |@ + \\___/ @ + @@ + _ __@ + | |/ /@ + | ' / @ + | . \\ @ + |_|\\_\\@ + @@ + _ @ + | | @ + | | @ + | |___ @ + |_____|@ + @@ + __ __ @ + | \\/ |@ + | |\\/| |@ + | | | |@ + |_| |_|@ + @@ + _ _ @ + | \\ | |@ + | \\| |@ + | |\\ |@ + |_| \\_|@ + @@ + ___ @ + / _ \\ @ + | | | |@ + | |_| |@ + \\___/ @ + @@ + ____ @ + | _ \\ @ + | |_) |@ + | __/ @ + |_| @ + @@ + ___ @ + / _ \\ @ + | | | |@ + | |_| |@ + \\__\\_\\@ + @@ + ____ @ + | _ \\ @ + | |_) |@ + | _ < @ + |_| \\_\\@ + @@ + ____ @ + / ___| @ + \\___ \\ @ + ___) |@ + |____/ @ + @@ + _____ @ + |_ _|@ + | | @ + | | @ + |_| @ + @@ + _ _ @ + | | | |@ + | | | |@ + | |_| |@ + \\___/ @ + @@ + __ __@ + \\ \\ / /@ + \\ \\ / / @ + \\ V / @ + \\_/ @ + @@ + __ __@ + \\ \\ / /@ + \\ \\ /\\ / / @ + \\ V V / @ + \\_/\\_/ @ + @@ + __ __@ + \\ \\/ /@ + \\ / @ + / \\ @ + /_/\\_\\@ + @@ + __ __@ + \\ \\ / /@ + \\ V / @ + | | @ + |_| @ + @@ + _____@ + |__ /@ + / / @ + / /_ @ + /____|@ + @@ + __ @ + | _|@ + | | @ + | | @ + | | @ + |__|@@ + __ @ + \\ \\ @ + \\ \\ @ + \\ \\ @ + \\_\\@ + @@ + __ @ + |_ |@ + | |@ + | |@ + | |@ + |__|@@ + /\\ @ + |/\\|@ + $ @ + $ @ + $ @ + @@ + @ + @ + @ + @ + _____ @ + |_____|@@ + _ @ + ( )@ + \\|@ + $ @ + $ @ + @@ + @ + __ _ @ + / _\` |@ + | (_| |@ + \\__,_|@ + @@ + _ @ + | |__ @ + | '_ \\ @ + | |_) |@ + |_.__/ @ + @@ + @ + ___ @ + / __|@ + | (__ @ + \\___|@ + @@ + _ @ + __| |@ + / _\` |@ + | (_| |@ + \\__,_|@ + @@ + @ + ___ @ + / _ \\@ + | __/@ + \\___|@ + @@ + __ @ + / _|@ + | |_ @ + | _|@ + |_| @ + @@ + @ + __ _ @ + / _\` |@ + | (_| |@ + \\__, |@ + |___/ @@ + _ @ + | |__ @ + | '_ \\ @ + | | | |@ + |_| |_|@ + @@ + _ @ + (_)@ + | |@ + | |@ + |_|@ + @@ + _ @ + (_)@ + | |@ + | |@ + _/ |@ + |__/ @@ + _ @ + | | __@ + | |/ /@ + | < @ + |_|\\_\\@ + @@ + _ @ + | |@ + | |@ + | |@ + |_|@ + @@ + @ + _ __ ___ @ + | '_ \` _ \\ @ + | | | | | |@ + |_| |_| |_|@ + @@ + @ + _ __ @ + | '_ \\ @ + | | | |@ + |_| |_|@ + @@ + @ + ___ @ + / _ \\ @ + | (_) |@ + \\___/ @ + @@ + @ + _ __ @ + | '_ \\ @ + | |_) |@ + | .__/ @ + |_| @@ + @ + __ _ @ + / _\` |@ + | (_| |@ + \\__, |@ + |_|@@ + @ + _ __ @ + | '__|@ + | | @ + |_| @ + @@ + @ + ___ @ + / __|@ + \\__ \\@ + |___/@ + @@ + _ @ + | |_ @ + | __|@ + | |_ @ + \\__|@ + @@ + @ + _ _ @ + | | | |@ + | |_| |@ + \\__,_|@ + @@ + @ + __ __@ + \\ \\ / /@ + \\ V / @ + \\_/ @ + @@ + @ + __ __@ + \\ \\ /\\ / /@ + \\ V V / @ + \\_/\\_/ @ + @@ + @ + __ __@ + \\ \\/ /@ + > < @ + /_/\\_\\@ + @@ + @ + _ _ @ + | | | |@ + | |_| |@ + \\__, |@ + |___/ @@ + @ + ____@ + |_ /@ + / / @ + /___|@ + @@ + __@ + / /@ + | | @ + < < @ + | | @ + \\_\\@@ + _ @ + | |@ + | |@ + | |@ + | |@ + |_|@@ + __ @ + \\ \\ @ + | | @ + > >@ + | | @ + /_/ @@ + /\\/|@ + |/\\/ @ + $ @ + $ @ + $ @ + @@ + _ _ @ + (_)_(_)@ + /_\\ @ + / _ \\ @ + /_/ \\_\\@ + @@ + _ _ @ + (_)_(_)@ + / _ \\ @ + | |_| |@ + \\___/ @ + @@ + _ _ @ + (_) (_)@ + | | | |@ + | |_| |@ + \\___/ @ + @@ + _ _ @ + (_)_(_)@ + / _\` |@ + | (_| |@ + \\__,_|@ + @@ + _ _ @ + (_)_(_)@ + / _ \\ @ + | (_) |@ + \\___/ @ + @@ + _ _ @ + (_) (_)@ + | | | |@ + | |_| |@ + \\__,_|@ + @@ + ___ @ + / _ \\@ + | |/ /@ + | |\\ \\@ + | ||_/@ + |_| @@ +160 NO-BREAK SPACE + $@ + $@ + $@ + $@ + $@ + $@@ +161 INVERTED EXCLAMATION MARK + _ @ + (_)@ + | |@ + | |@ + |_|@ + @@ +162 CENT SIGN + _ @ + | | @ + / __)@ + | (__ @ + \\ )@ + |_| @@ +163 POUND SIGN + ___ @ + / ,_\\ @ + _| |_ @ + | |___ @ + (_,____|@ + @@ +164 CURRENCY SIGN + /\\___/\\@ + \\ _ /@ + | (_) |@ + / ___ \\@ + \\/ \\/@ + @@ +165 YEN SIGN + __ __ @ + \\ V / @ + |__ __|@ + |__ __|@ + |_| @ + @@ +166 BROKEN BAR + _ @ + | |@ + |_|@ + _ @ + | |@ + |_|@@ +167 SECTION SIGN + __ @ + _/ _)@ + / \\ \\ @ + \\ \\\\ \\@ + \\ \\_/@ + (__/ @@ +168 DIAERESIS + _ _ @ + (_) (_)@ + $ $ @ + $ $ @ + $ $ @ + @@ +169 COPYRIGHT SIGN + _____ @ + / ___ \\ @ + / / __| \\ @ + | | (__ |@ + \\ \\___| / @ + \\_____/ @@ +170 FEMININE ORDINAL INDICATOR + __ _ @ + / _\` |@ + \\__,_|@ + |____|@ + $ @ + @@ +171 LEFT-POINTING DOUBLE ANGLE QUOTATION MARK + ____@ + / / /@ + / / / @ + \\ \\ \\ @ + \\_\\_\\@ + @@ +172 NOT SIGN + @ + _____ @ + |___ |@ + |_|@ + $ @ + @@ +173 SOFT HYPHEN + @ + @ + ____ @ + |____|@ + $ @ + @@ +174 REGISTERED SIGN + _____ @ + / ___ \\ @ + / | _ \\ \\ @ + | | / |@ + \\ |_|_\\ / @ + \\_____/ @@ +175 MACRON + _____ @ + |_____|@ + $ @ + $ @ + $ @ + @@ +176 DEGREE SIGN + __ @ + / \\ @ + | () |@ + \\__/ @ + $ @ + @@ +177 PLUS-MINUS SIGN + _ @ + _| |_ @ + |_ _|@ + _|_|_ @ + |_____|@ + @@ +178 SUPERSCRIPT TWO + ___ @ + |_ )@ + / / @ + /___|@ + $ @ + @@ +179 SUPERSCRIPT THREE + ____@ + |__ /@ + |_ \\@ + |___/@ + $ @ + @@ +180 ACUTE ACCENT + __@ + /_/@ + $ @ + $ @ + $ @ + @@ +181 MICRO SIGN + @ + _ _ @ + | | | |@ + | |_| |@ + | ._,_|@ + |_| @@ +182 PILCROW SIGN + _____ @ + / |@ + | (| | |@ + \\__ | |@ + |_|_|@ + @@ +183 MIDDLE DOT + @ + _ @ + (_)@ + $ @ + $ @ + @@ +184 CEDILLA + @ + @ + @ + @ + _ @ + )_)@@ +185 SUPERSCRIPT ONE + _ @ + / |@ + | |@ + |_|@ + $ @ + @@ +186 MASCULINE ORDINAL INDICATOR + ___ @ + / _ \\@ + \\___/@ + |___|@ + $ @ + @@ +187 RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK + ____ @ + \\ \\ \\ @ + \\ \\ \\@ + / / /@ + /_/_/ @ + @@ +188 VULGAR FRACTION ONE QUARTER + _ __ @ + / | / / _ @ + | |/ / | | @ + |_/ /|_ _|@ + /_/ |_| @ + @@ +189 VULGAR FRACTION ONE HALF + _ __ @ + / | / /__ @ + | |/ /_ )@ + |_/ / / / @ + /_/ /___|@ + @@ +190 VULGAR FRACTION THREE QUARTERS + ____ __ @ + |__ / / / _ @ + |_ \\/ / | | @ + |___/ /|_ _|@ + /_/ |_| @ + @@ +191 INVERTED QUESTION MARK + _ @ + (_) @ + | | @ + / /_ @ + \\___|@ + @@ +192 LATIN CAPITAL LETTER A WITH GRAVE + __ @ + \\_\\ @ + /_\\ @ + / _ \\ @ + /_/ \\_\\@ + @@ +193 LATIN CAPITAL LETTER A WITH ACUTE + __ @ + /_/ @ + /_\\ @ + / _ \\ @ + /_/ \\_\\@ + @@ +194 LATIN CAPITAL LETTER A WITH CIRCUMFLEX + //\\ @ + |/_\\| @ + /_\\ @ + / _ \\ @ + /_/ \\_\\@ + @@ +195 LATIN CAPITAL LETTER A WITH TILDE + /\\/| @ + |/\\/ @ + /_\\ @ + / _ \\ @ + /_/ \\_\\@ + @@ +196 LATIN CAPITAL LETTER A WITH DIAERESIS + _ _ @ + (_)_(_)@ + /_\\ @ + / _ \\ @ + /_/ \\_\\@ + @@ +197 LATIN CAPITAL LETTER A WITH RING ABOVE + _ @ + (o) @ + /_\\ @ + / _ \\ @ + /_/ \\_\\@ + @@ +198 LATIN CAPITAL LETTER AE + ______ @ + / ____|@ + / _ _| @ + / __ |___ @ + /_/ |_____|@ + @@ +199 LATIN CAPITAL LETTER C WITH CEDILLA + ____ @ + / ___|@ + | | @ + | |___ @ + \\____|@ + )_) @@ +200 LATIN CAPITAL LETTER E WITH GRAVE + __ @ + _\\_\\_ @ + | ____|@ + | _|_ @ + |_____|@ + @@ +201 LATIN CAPITAL LETTER E WITH ACUTE + __ @ + _/_/_ @ + | ____|@ + | _|_ @ + |_____|@ + @@ +202 LATIN CAPITAL LETTER E WITH CIRCUMFLEX + //\\ @ + |/_\\| @ + | ____|@ + | _|_ @ + |_____|@ + @@ +203 LATIN CAPITAL LETTER E WITH DIAERESIS + _ _ @ + (_)_(_)@ + | ____|@ + | _|_ @ + |_____|@ + @@ +204 LATIN CAPITAL LETTER I WITH GRAVE + __ @ + \\_\\ @ + |_ _|@ + | | @ + |___|@ + @@ +205 LATIN CAPITAL LETTER I WITH ACUTE + __ @ + /_/ @ + |_ _|@ + | | @ + |___|@ + @@ +206 LATIN CAPITAL LETTER I WITH CIRCUMFLEX + //\\ @ + |/_\\|@ + |_ _|@ + | | @ + |___|@ + @@ +207 LATIN CAPITAL LETTER I WITH DIAERESIS + _ _ @ + (_)_(_)@ + |_ _| @ + | | @ + |___| @ + @@ +208 LATIN CAPITAL LETTER ETH + ____ @ + | _ \\ @ + _| |_| |@ + |__ __| |@ + |____/ @ + @@ +209 LATIN CAPITAL LETTER N WITH TILDE + /\\/|@ + |/\\/ @ + | \\| |@ + | .\` |@ + |_|\\_|@ + @@ +210 LATIN CAPITAL LETTER O WITH GRAVE + __ @ + \\_\\ @ + / _ \\ @ + | |_| |@ + \\___/ @ + @@ +211 LATIN CAPITAL LETTER O WITH ACUTE + __ @ + /_/ @ + / _ \\ @ + | |_| |@ + \\___/ @ + @@ +212 LATIN CAPITAL LETTER O WITH CIRCUMFLEX + //\\ @ + |/_\\| @ + / _ \\ @ + | |_| |@ + \\___/ @ + @@ +213 LATIN CAPITAL LETTER O WITH TILDE + /\\/| @ + |/\\/ @ + / _ \\ @ + | |_| |@ + \\___/ @ + @@ +214 LATIN CAPITAL LETTER O WITH DIAERESIS + _ _ @ + (_)_(_)@ + / _ \\ @ + | |_| |@ + \\___/ @ + @@ +215 MULTIPLICATION SIGN + @ + @ + /\\/\\@ + > <@ + \\/\\/@ + @@ +216 LATIN CAPITAL LETTER O WITH STROKE + ____ @ + / _// @ + | |// |@ + | //| |@ + //__/ @ + @@ +217 LATIN CAPITAL LETTER U WITH GRAVE + __ @ + _\\_\\_ @ + | | | |@ + | |_| |@ + \\___/ @ + @@ +218 LATIN CAPITAL LETTER U WITH ACUTE + __ @ + _/_/_ @ + | | | |@ + | |_| |@ + \\___/ @ + @@ +219 LATIN CAPITAL LETTER U WITH CIRCUMFLEX + //\\ @ + |/ \\| @ + | | | |@ + | |_| |@ + \\___/ @ + @@ +220 LATIN CAPITAL LETTER U WITH DIAERESIS + _ _ @ + (_) (_)@ + | | | |@ + | |_| |@ + \\___/ @ + @@ +221 LATIN CAPITAL LETTER Y WITH ACUTE + __ @ + __/_/__@ + \\ \\ / /@ + \\ V / @ + |_| @ + @@ +222 LATIN CAPITAL LETTER THORN + _ @ + | |___ @ + | __ \\@ + | ___/@ + |_| @ + @@ +223 LATIN SMALL LETTER SHARP S + ___ @ + / _ \\@ + | |/ /@ + | |\\ \\@ + | ||_/@ + |_| @@ +224 LATIN SMALL LETTER A WITH GRAVE + __ @ + \\_\\_ @ + / _\` |@ + | (_| |@ + \\__,_|@ + @@ +225 LATIN SMALL LETTER A WITH ACUTE + __ @ + /_/_ @ + / _\` |@ + | (_| |@ + \\__,_|@ + @@ +226 LATIN SMALL LETTER A WITH CIRCUMFLEX + //\\ @ + |/_\\| @ + / _\` |@ + | (_| |@ + \\__,_|@ + @@ +227 LATIN SMALL LETTER A WITH TILDE + /\\/| @ + |/\\/_ @ + / _\` |@ + | (_| |@ + \\__,_|@ + @@ +228 LATIN SMALL LETTER A WITH DIAERESIS + _ _ @ + (_)_(_)@ + / _\` |@ + | (_| |@ + \\__,_|@ + @@ +229 LATIN SMALL LETTER A WITH RING ABOVE + __ @ + (()) @ + / _ '|@ + | (_| |@ + \\__,_|@ + @@ +230 LATIN SMALL LETTER AE + @ + __ ____ @ + / _\` _ \\@ + | (_| __/@ + \\__,____|@ + @@ +231 LATIN SMALL LETTER C WITH CEDILLA + @ + ___ @ + / __|@ + | (__ @ + \\___|@ + )_) @@ +232 LATIN SMALL LETTER E WITH GRAVE + __ @ + \\_\\ @ + / _ \\@ + | __/@ + \\___|@ + @@ +233 LATIN SMALL LETTER E WITH ACUTE + __ @ + /_/ @ + / _ \\@ + | __/@ + \\___|@ + @@ +234 LATIN SMALL LETTER E WITH CIRCUMFLEX + //\\ @ + |/_\\|@ + / _ \\@ + | __/@ + \\___|@ + @@ +235 LATIN SMALL LETTER E WITH DIAERESIS + _ _ @ + (_)_(_)@ + / _ \\ @ + | __/ @ + \\___| @ + @@ +236 LATIN SMALL LETTER I WITH GRAVE + __ @ + \\_\\@ + | |@ + | |@ + |_|@ + @@ +237 LATIN SMALL LETTER I WITH ACUTE + __@ + /_/@ + | |@ + | |@ + |_|@ + @@ +238 LATIN SMALL LETTER I WITH CIRCUMFLEX + //\\ @ + |/_\\|@ + | | @ + | | @ + |_| @ + @@ +239 LATIN SMALL LETTER I WITH DIAERESIS + _ _ @ + (_)_(_)@ + | | @ + | | @ + |_| @ + @@ +240 LATIN SMALL LETTER ETH + /\\/\\ @ + > < @ + _\\/\\ |@ + / __\` |@ + \\____/ @ + @@ +241 LATIN SMALL LETTER N WITH TILDE + /\\/| @ + |/\\/ @ + | '_ \\ @ + | | | |@ + |_| |_|@ + @@ +242 LATIN SMALL LETTER O WITH GRAVE + __ @ + \\_\\ @ + / _ \\ @ + | (_) |@ + \\___/ @ + @@ +243 LATIN SMALL LETTER O WITH ACUTE + __ @ + /_/ @ + / _ \\ @ + | (_) |@ + \\___/ @ + @@ +244 LATIN SMALL LETTER O WITH CIRCUMFLEX + //\\ @ + |/_\\| @ + / _ \\ @ + | (_) |@ + \\___/ @ + @@ +245 LATIN SMALL LETTER O WITH TILDE + /\\/| @ + |/\\/ @ + / _ \\ @ + | (_) |@ + \\___/ @ + @@ +246 LATIN SMALL LETTER O WITH DIAERESIS + _ _ @ + (_)_(_)@ + / _ \\ @ + | (_) |@ + \\___/ @ + @@ +247 DIVISION SIGN + @ + _ @ + _(_)_ @ + |_____|@ + (_) @ + @@ +248 LATIN SMALL LETTER O WITH STROKE + @ + ____ @ + / _//\\ @ + | (//) |@ + \\//__/ @ + @@ +249 LATIN SMALL LETTER U WITH GRAVE + __ @ + _\\_\\_ @ + | | | |@ + | |_| |@ + \\__,_|@ + @@ +250 LATIN SMALL LETTER U WITH ACUTE + __ @ + _/_/_ @ + | | | |@ + | |_| |@ + \\__,_|@ + @@ +251 LATIN SMALL LETTER U WITH CIRCUMFLEX + //\\ @ + |/ \\| @ + | | | |@ + | |_| |@ + \\__,_|@ + @@ +252 LATIN SMALL LETTER U WITH DIAERESIS + _ _ @ + (_) (_)@ + | | | |@ + | |_| |@ + \\__,_|@ + @@ +253 LATIN SMALL LETTER Y WITH ACUTE + __ @ + _/_/_ @ + | | | |@ + | |_| |@ + \\__, |@ + |___/ @@ +254 LATIN SMALL LETTER THORN + _ @ + | |__ @ + | '_ \\ @ + | |_) |@ + | .__/ @ + |_| @@ +255 LATIN SMALL LETTER Y WITH DIAERESIS + _ _ @ + (_) (_)@ + | | | |@ + | |_| |@ + \\__, |@ + |___/ @@ +0x0100 LATIN CAPITAL LETTER A WITH MACRON + ____ @ + /___/ @ + /_\\ @ + / _ \\ @ + /_/ \\_\\@ + @@ +0x0101 LATIN SMALL LETTER A WITH MACRON + ___ @ + /_ _/@ + / _\` |@ + | (_| |@ + \\__,_|@ + @@ +0x0102 LATIN CAPITAL LETTER A WITH BREVE + _ _ @ + \\\\_// @ + /_\\ @ + / _ \\ @ + /_/ \\_\\@ + @@ +0x0103 LATIN SMALL LETTER A WITH BREVE + \\_/ @ + ___ @ + / _\` |@ + | (_| |@ + \\__,_|@ + @@ +0x0104 LATIN CAPITAL LETTER A WITH OGONEK + @ + _ @ + /_\\ @ + / _ \\ @ + /_/ \\_\\@ + (_(@@ +0x0105 LATIN SMALL LETTER A WITH OGONEK + @ + __ _ @ + / _\` |@ + | (_| |@ + \\__,_|@ + (_(@@ +0x0106 LATIN CAPITAL LETTER C WITH ACUTE + __ @ + _/_/ @ + / ___|@ + | |___ @ + \\____|@ + @@ +0x0107 LATIN SMALL LETTER C WITH ACUTE + __ @ + /__/@ + / __|@ + | (__ @ + \\___|@ + @@ +0x0108 LATIN CAPITAL LETTER C WITH CIRCUMFLEX + /\\ @ + _//\\\\@ + / ___|@ + | |___ @ + \\____|@ + @@ +0x0109 LATIN SMALL LETTER C WITH CIRCUMFLEX + /\\ @ + /_\\ @ + / __|@ + | (__ @ + \\___|@ + @@ +0x010A LATIN CAPITAL LETTER C WITH DOT ABOVE + [] @ + ____ @ + / ___|@ + | |___ @ + \\____|@ + @@ +0x010B LATIN SMALL LETTER C WITH DOT ABOVE + [] @ + ___ @ + / __|@ + | (__ @ + \\___|@ + @@ +0x010C LATIN CAPITAL LETTER C WITH CARON + \\\\// @ + _\\/_ @ + / ___|@ + | |___ @ + \\____|@ + @@ +0x010D LATIN SMALL LETTER C WITH CARON + \\\\//@ + _\\/ @ + / __|@ + | (__ @ + \\___|@ + @@ +0x010E LATIN CAPITAL LETTER D WITH CARON + \\\\// @ + __\\/ @ + | _ \\ @ + | |_| |@ + |____/ @ + @@ +0x010F LATIN SMALL LETTER D WITH CARON + \\/ _ @ + __| |@ + / _\` |@ + | (_| |@ + \\__,_|@ + @@ +0x0110 LATIN CAPITAL LETTER D WITH STROKE + ____ @ + |_ __ \\ @ + /| |/ | |@ + /|_|/_| |@ + |_____/ @ + @@ +0x0111 LATIN SMALL LETTER D WITH STROKE + ---|@ + __| |@ + / _\` |@ + | (_| |@ + \\__,_|@ + @@ +0x0112 LATIN CAPITAL LETTER E WITH MACRON + ____ @ + /___/ @ + | ____|@ + | _|_ @ + |_____|@ + @@ +0x0113 LATIN SMALL LETTER E WITH MACRON + ____@ + /_ _/@ + / _ \\ @ + | __/ @ + \\___| @ + @@ +0x0114 LATIN CAPITAL LETTER E WITH BREVE + _ _ @ + \\\\_// @ + | ____|@ + | _|_ @ + |_____|@ + @@ +0x0115 LATIN SMALL LETTER E WITH BREVE + \\\\ //@ + -- @ + / _ \\ @ + | __/ @ + \\___| @ + @@ +0x0116 LATIN CAPITAL LETTER E WITH DOT ABOVE + [] @ + _____ @ + | ____|@ + | _|_ @ + |_____|@ + @@ +0x0117 LATIN SMALL LETTER E WITH DOT ABOVE + [] @ + __ @ + / _ \\@ + | __/@ + \\___|@ + @@ +0x0118 LATIN CAPITAL LETTER E WITH OGONEK + @ + _____ @ + | ____|@ + | _|_ @ + |_____|@ + (__(@@ +0x0119 LATIN SMALL LETTER E WITH OGONEK + @ + ___ @ + / _ \\@ + | __/@ + \\___|@ + (_(@@ +0x011A LATIN CAPITAL LETTER E WITH CARON + \\\\// @ + __\\/_ @ + | ____|@ + | _|_ @ + |_____|@ + @@ +0x011B LATIN SMALL LETTER E WITH CARON + \\\\//@ + \\/ @ + / _ \\@ + | __/@ + \\___|@ + @@ +0x011C LATIN CAPITAL LETTER G WITH CIRCUMFLEX + _/\\_ @ + / ___|@ + | | _ @ + | |_| |@ + \\____|@ + @@ +0x011D LATIN SMALL LETTER G WITH CIRCUMFLEX + /\\ @ + _/_ \\@ + / _\` |@ + | (_| |@ + \\__, |@ + |___/ @@ +0x011E LATIN CAPITAL LETTER G WITH BREVE + _\\/_ @ + / ___|@ + | | _ @ + | |_| |@ + \\____|@ + @@ +0x011F LATIN SMALL LETTER G WITH BREVE + \\___/ @ + __ _ @ + / _\` |@ + | (_| |@ + \\__, |@ + |___/ @@ +0x0120 LATIN CAPITAL LETTER G WITH DOT ABOVE + _[]_ @ + / ___|@ + | | _ @ + | |_| |@ + \\____|@ + @@ +0x0121 LATIN SMALL LETTER G WITH DOT ABOVE + [] @ + __ _ @ + / _\` |@ + | (_| |@ + \\__, |@ + |___/ @@ +0x0122 LATIN CAPITAL LETTER G WITH CEDILLA + ____ @ + / ___|@ + | | _ @ + | |_| |@ + \\____|@ + )__) @@ +0x0123 LATIN SMALL LETTER G WITH CEDILLA + @ + __ _ @ + / _\` |@ + | (_| |@ + \\__, |@ + |_))))@@ +0x0124 LATIN CAPITAL LETTER H WITH CIRCUMFLEX + _/ \\_ @ + | / \\ |@ + | |_| |@ + | _ |@ + |_| |_|@ + @@ +0x0125 LATIN SMALL LETTER H WITH CIRCUMFLEX + _ /\\ @ + | |//\\ @ + | '_ \\ @ + | | | |@ + |_| |_|@ + @@ +0x0126 LATIN CAPITAL LETTER H WITH STROKE + _ _ @ + | |=| |@ + | |_| |@ + | _ |@ + |_| |_|@ + @@ +0x0127 LATIN SMALL LETTER H WITH STROKE + _ @ + |=|__ @ + | '_ \\ @ + | | | |@ + |_| |_|@ + @@ +0x0128 LATIN CAPITAL LETTER I WITH TILDE + /\\//@ + |_ _|@ + | | @ + | | @ + |___|@ + @@ +0x0129 LATIN SMALL LETTER I WITH TILDE + @ + /\\/@ + | |@ + | |@ + |_|@ + @@ +0x012A LATIN CAPITAL LETTER I WITH MACRON + /___/@ + |_ _|@ + | | @ + | | @ + |___|@ + @@ +0x012B LATIN SMALL LETTER I WITH MACRON + ____@ + /___/@ + | | @ + | | @ + |_| @ + @@ +0x012C LATIN CAPITAL LETTER I WITH BREVE + \\__/@ + |_ _|@ + | | @ + | | @ + |___|@ + @@ +0x012D LATIN SMALL LETTER I WITH BREVE + @ + \\_/@ + | |@ + | |@ + |_|@ + @@ +0x012E LATIN CAPITAL LETTER I WITH OGONEK + ___ @ + |_ _|@ + | | @ + | | @ + |___|@ + (__(@@ +0x012F LATIN SMALL LETTER I WITH OGONEK + _ @ + (_) @ + | | @ + | | @ + |_|_@ + (_(@@ +0x0130 LATIN CAPITAL LETTER I WITH DOT ABOVE + _[] @ + |_ _|@ + | | @ + | | @ + |___|@ + @@ +0x0131 LATIN SMALL LETTER DOTLESS I + @ + _ @ + | |@ + | |@ + |_|@ + @@ +0x0132 LATIN CAPITAL LIGATURE IJ + ___ _ @ + |_ _|| |@ + | | | |@ + | |_| |@ + |__|__/ @ + @@ +0x0133 LATIN SMALL LIGATURE IJ + _ _ @ + (_) (_)@ + | | | |@ + | | | |@ + |_|_/ |@ + |__/ @@ +0x0134 LATIN CAPITAL LETTER J WITH CIRCUMFLEX + /\\ @ + /_\\|@ + _ | | @ + | |_| | @ + \\___/ @ + @@ +0x0135 LATIN SMALL LETTER J WITH CIRCUMFLEX + /\\@ + /_\\@ + | |@ + | |@ + _/ |@ + |__/ @@ +0x0136 LATIN CAPITAL LETTER K WITH CEDILLA + _ _ @ + | |/ / @ + | ' / @ + | . \\ @ + |_|\\_\\ @ + )__)@@ +0x0137 LATIN SMALL LETTER K WITH CEDILLA + _ @ + | | __@ + | |/ /@ + | < @ + |_|\\_\\@ + )_)@@ +0x0138 LATIN SMALL LETTER KRA + @ + _ __ @ + | |/ \\@ + | < @ + |_|\\_\\@ + @@ +0x0139 LATIN CAPITAL LETTER L WITH ACUTE + _ //@ + | | // @ + | | @ + | |___ @ + |_____|@ + @@ +0x013A LATIN SMALL LETTER L WITH ACUTE + //@ + | |@ + | |@ + | |@ + |_|@ + @@ +0x013B LATIN CAPITAL LETTER L WITH CEDILLA + _ @ + | | @ + | | @ + | |___ @ + |_____|@ + )__)@@ +0x013C LATIN SMALL LETTER L WITH CEDILLA + _ @ + | | @ + | | @ + | | @ + |_| @ + )_)@@ +0x013D LATIN CAPITAL LETTER L WITH CARON + _ \\\\//@ + | | \\/ @ + | | @ + | |___ @ + |_____|@ + @@ +0x013E LATIN SMALL LETTER L WITH CARON + _ \\\\//@ + | | \\/ @ + | | @ + | | @ + |_| @ + @@ +0x013F LATIN CAPITAL LETTER L WITH MIDDLE DOT + _ @ + | | @ + | | [] @ + | |___ @ + |_____|@ + @@ +0x0140 LATIN SMALL LETTER L WITH MIDDLE DOT + _ @ + | | @ + | | []@ + | | @ + |_| @ + @@ +0x0141 LATIN CAPITAL LETTER L WITH STROKE + __ @ + | // @ + |//| @ + // |__ @ + |_____|@ + @@ +0x0142 LATIN SMALL LETTER L WITH STROKE + _ @ + | |@ + |//@ + //|@ + |_|@ + @@ +0x0143 LATIN CAPITAL LETTER N WITH ACUTE + _/ /_ @ + | \\ | |@ + | \\| |@ + | |\\ |@ + |_| \\_|@ + @@ +0x0144 LATIN SMALL LETTER N WITH ACUTE + _ @ + _ /_/ @ + | '_ \\ @ + | | | |@ + |_| |_|@ + @@ +0x0145 LATIN CAPITAL LETTER N WITH CEDILLA + _ _ @ + | \\ | |@ + | \\| |@ + | |\\ |@ + |_| \\_|@ + )_) @@ +0x0146 LATIN SMALL LETTER N WITH CEDILLA + @ + _ __ @ + | '_ \\ @ + | | | |@ + |_| |_|@ + )_) @@ +0x0147 LATIN CAPITAL LETTER N WITH CARON + _\\/ _ @ + | \\ | |@ + | \\| |@ + | |\\ |@ + |_| \\_|@ + @@ +0x0148 LATIN SMALL LETTER N WITH CARON + \\\\// @ + _\\/_ @ + | '_ \\ @ + | | | |@ + |_| |_|@ + @@ +0x0149 LATIN SMALL LETTER N PRECEDED BY APOSTROPHE + @ + _ __ @ + ( )| '_\\ @ + |/| | | |@ + |_| |_|@ + @@ +0x014A LATIN CAPITAL LETTER ENG + _ _ @ + | \\ | |@ + | \\| |@ + | |\\ |@ + |_| \\ |@ + )_)@@ +0x014B LATIN SMALL LETTER ENG + _ __ @ + | '_ \\ @ + | | | |@ + |_| | |@ + | |@ + |__ @@ +0x014C LATIN CAPITAL LETTER O WITH MACRON + ____ @ + /_ _/ @ + / _ \\ @ + | (_) |@ + \\___/ @ + @@ +0x014D LATIN SMALL LETTER O WITH MACRON + ____ @ + /_ _/ @ + / _ \\ @ + | (_) |@ + \\___/ @ + @@ +0x014E LATIN CAPITAL LETTER O WITH BREVE + \\ / @ + _-_ @ + / _ \\ @ + | |_| |@ + \\___/ @ + @@ +0x014F LATIN SMALL LETTER O WITH BREVE + \\ / @ + _-_ @ + / _ \\ @ + | |_| |@ + \\___/ @ + @@ +0x0150 LATIN CAPITAL LETTER O WITH DOUBLE ACUTE + ___ @ + /_/_/@ + / _ \\ @ + | |_| |@ + \\___/ @ + @@ +0x0151 LATIN SMALL LETTER O WITH DOUBLE ACUTE + ___ @ + /_/_/@ + / _ \\ @ + | |_| |@ + \\___/ @ + @@ +0x0152 LATIN CAPITAL LIGATURE OE + ___ ___ @ + / _ \\| __|@ + | | | | | @ + | |_| | |__@ + \\___/|____@ + @@ +0x0153 LATIN SMALL LIGATURE OE + @ + ___ ___ @ + / _ \\ / _ \\@ + | (_) | __/@ + \\___/ \\___|@ + @@ +0x0154 LATIN CAPITAL LETTER R WITH ACUTE + _/_/ @ + | _ \\ @ + | |_) |@ + | _ < @ + |_| \\_\\@ + @@ +0x0155 LATIN SMALL LETTER R WITH ACUTE + __@ + _ /_/@ + | '__|@ + | | @ + |_| @ + @@ +0x0156 LATIN CAPITAL LETTER R WITH CEDILLA + ____ @ + | _ \\ @ + | |_) |@ + | _ < @ + |_| \\_\\@ + )_) @@ +0x0157 LATIN SMALL LETTER R WITH CEDILLA + @ + _ __ @ + | '__|@ + | | @ + |_| @ + )_) @@ +0x0158 LATIN CAPITAL LETTER R WITH CARON + _\\_/ @ + | _ \\ @ + | |_) |@ + | _ < @ + |_| \\_\\@ + @@ +0x0159 LATIN SMALL LETTER R WITH CARON + \\\\// @ + _\\/_ @ + | '__|@ + | | @ + |_| @ + @@ +0x015A LATIN CAPITAL LETTER S WITH ACUTE + _/_/ @ + / ___| @ + \\___ \\ @ + ___) |@ + |____/ @ + @@ +0x015B LATIN SMALL LETTER S WITH ACUTE + __@ + _/_/@ + / __|@ + \\__ \\@ + |___/@ + @@ +0x015C LATIN CAPITAL LETTER S WITH CIRCUMFLEX + _/\\_ @ + / ___| @ + \\___ \\ @ + ___) |@ + |____/ @ + @@ +0x015D LATIN SMALL LETTER S WITH CIRCUMFLEX + @ + /_\\_@ + / __|@ + \\__ \\@ + |___/@ + @@ +0x015E LATIN CAPITAL LETTER S WITH CEDILLA + ____ @ + / ___| @ + \\___ \\ @ + ___) |@ + |____/ @ + )__)@@ +0x015F LATIN SMALL LETTER S WITH CEDILLA + @ + ___ @ + / __|@ + \\__ \\@ + |___/@ + )_)@@ +0x0160 LATIN CAPITAL LETTER S WITH CARON + _\\_/ @ + / ___| @ + \\___ \\ @ + ___) |@ + |____/ @ + @@ +0x0161 LATIN SMALL LETTER S WITH CARON + \\\\//@ + _\\/ @ + / __|@ + \\__ \\@ + |___/@ + @@ +0x0162 LATIN CAPITAL LETTER T WITH CEDILLA + _____ @ + |_ _|@ + | | @ + | | @ + |_| @ + )__)@@ +0x0163 LATIN SMALL LETTER T WITH CEDILLA + _ @ + | |_ @ + | __|@ + | |_ @ + \\__|@ + )_)@@ +0x0164 LATIN CAPITAL LETTER T WITH CARON + _____ @ + |_ _|@ + | | @ + | | @ + |_| @ + @@ +0x0165 LATIN SMALL LETTER T WITH CARON + \\/ @ + | |_ @ + | __|@ + | |_ @ + \\__|@ + @@ +0x0166 LATIN CAPITAL LETTER T WITH STROKE + _____ @ + |_ _|@ + | | @ + -|-|- @ + |_| @ + @@ +0x0167 LATIN SMALL LETTER T WITH STROKE + _ @ + | |_ @ + | __|@ + |-|_ @ + \\__|@ + @@ +0x0168 LATIN CAPITAL LETTER U WITH TILDE + @ + _/\\/_ @ + | | | |@ + | |_| |@ + \\___/ @ + @@ +0x0169 LATIN SMALL LETTER U WITH TILDE + @ + _/\\/_ @ + | | | |@ + | |_| |@ + \\__,_|@ + @@ +0x016A LATIN CAPITAL LETTER U WITH MACRON + ____ @ + /__ _/@ + | | | |@ + | |_| |@ + \\___/ @ + @@ +0x016B LATIN SMALL LETTER U WITH MACRON + ____ @ + / _ /@ + | | | |@ + | |_| |@ + \\__,_|@ + @@ +0x016C LATIN CAPITAL LETTER U WITH BREVE + @ + \\_/_ @ + | | | |@ + | |_| |@ + \\____|@ + @@ +0x016D LATIN SMALL LETTER U WITH BREVE + @ + \\_/_ @ + | | | |@ + | |_| |@ + \\__,_|@ + @@ +0x016E LATIN CAPITAL LETTER U WITH RING ABOVE + O @ + __ _ @ + | | | |@ + | |_| |@ + \\___/ @ + @@ +0x016F LATIN SMALL LETTER U WITH RING ABOVE + O @ + __ __ @ + | | | |@ + | |_| |@ + \\__,_|@ + @@ +0x0170 LATIN CAPITAL LETTER U WITH DOUBLE ACUTE + -- --@ + /_//_/@ + | | | |@ + | |_| |@ + \\___/ @ + @@ +0x0171 LATIN SMALL LETTER U WITH DOUBLE ACUTE + ____@ + _/_/_/@ + | | | |@ + | |_| |@ + \\__,_|@ + @@ +0x0172 LATIN CAPITAL LETTER U WITH OGONEK + _ _ @ + | | | |@ + | | | |@ + | |_| |@ + \\___/ @ + (__(@@ +0x0173 LATIN SMALL LETTER U WITH OGONEK + @ + _ _ @ + | | | |@ + | |_| |@ + \\__,_|@ + (_(@@ +0x0174 LATIN CAPITAL LETTER W WITH CIRCUMFLEX + __ /\\ __@ + \\ \\ //\\\\/ /@ + \\ \\ /\\ / / @ + \\ V V / @ + \\_/\\_/ @ + @@ +0x0175 LATIN SMALL LETTER W WITH CIRCUMFLEX + /\\ @ + __ //\\\\__@ + \\ \\ /\\ / /@ + \\ V V / @ + \\_/\\_/ @ + @@ +0x0176 LATIN CAPITAL LETTER Y WITH CIRCUMFLEX + /\\ @ + __//\\\\ @ + \\ \\ / /@ + \\ V / @ + |_| @ + @@ +0x0177 LATIN SMALL LETTER Y WITH CIRCUMFLEX + /\\ @ + //\\\\ @ + | | | |@ + | |_| |@ + \\__, |@ + |___/ @@ +0x0178 LATIN CAPITAL LETTER Y WITH DIAERESIS + [] []@ + __ _@ + \\ \\ / /@ + \\ V / @ + |_| @ + @@ +0x0179 LATIN CAPITAL LETTER Z WITH ACUTE + __/_/@ + |__ /@ + / / @ + / /_ @ + /____|@ + @@ +0x017A LATIN SMALL LETTER Z WITH ACUTE + _ @ + _/_/@ + |_ /@ + / / @ + /___|@ + @@ +0x017B LATIN CAPITAL LETTER Z WITH DOT ABOVE + __[]_@ + |__ /@ + / / @ + / /_ @ + /____|@ + @@ +0x017C LATIN SMALL LETTER Z WITH DOT ABOVE + [] @ + ____@ + |_ /@ + / / @ + /___|@ + @@ +0x017D LATIN CAPITAL LETTER Z WITH CARON + _\\_/_@ + |__ /@ + / / @ + / /_ @ + /____|@ + @@ +0x017E LATIN SMALL LETTER Z WITH CARON + \\\\//@ + _\\/_@ + |_ /@ + / / @ + /___|@ + @@ +0x017F LATIN SMALL LETTER LONG S + __ @ + / _|@ + |-| | @ + |-| | @ + |_| @ + @@ +0x02C7 CARON + \\\\//@ + \\/ @ + $@ + $@ + $@ + $@@ +0x02D8 BREVE + \\\\_//@ + \\_/ @ + $@ + $@ + $@ + $@@ +0x02D9 DOT ABOVE + []@ + $@ + $@ + $@ + $@ + $@@ +0x02DB OGONEK + $@ + $@ + $@ + $@ + $@ + )_) @@ +0x02DD DOUBLE ACUTE ACCENT + _ _ @ + /_/_/@ + $@ + $@ + $@ + $@@ +0xCA0 KANNADA LETTER TTHA + _____)@ + /_ ___/@ + / _ \\ @ + | (_) | @ + $\\___/$ @ + @@ +`; + +var main$2 = {exports: {}}; + +var name$1 = "dotenv"; +var version$6 = "16.4.5"; +var description$2 = "Loads environment variables from .env file"; +var main$1 = "lib/main.js"; +var types$2 = "lib/main.d.ts"; +var exports$1 = { + ".": { + types: "./lib/main.d.ts", + require: "./lib/main.js", + "default": "./lib/main.js" + }, + "./config": "./config.js", + "./config.js": "./config.js", + "./lib/env-options": "./lib/env-options.js", + "./lib/env-options.js": "./lib/env-options.js", + "./lib/cli-options": "./lib/cli-options.js", + "./lib/cli-options.js": "./lib/cli-options.js", + "./package.json": "./package.json" +}; +var scripts$1 = { + "dts-check": "tsc --project tests/types/tsconfig.json", + lint: "standard", + "lint-readme": "standard-markdown", + pretest: "npm run lint && npm run dts-check", + test: "tap tests/*.js --100 -Rspec", + "test:coverage": "tap --coverage-report=lcov", + prerelease: "npm test", + release: "standard-version" +}; +var repository = { + type: "git", + url: "git://github.com/motdotla/dotenv.git" +}; +var funding = "https://dotenvx.com"; +var keywords = [ + "dotenv", + "env", + ".env", + "environment", + "variables", + "config", + "settings" +]; +var readmeFilename = "README.md"; +var license$1 = "BSD-2-Clause"; +var devDependencies$1 = { + "@definitelytyped/dtslint": "^0.0.133", + "@types/node": "^18.11.3", + decache: "^4.6.1", + sinon: "^14.0.1", + standard: "^17.0.0", + "standard-markdown": "^7.1.0", + "standard-version": "^9.5.0", + tap: "^16.3.0", + tar: "^6.1.11", + typescript: "^4.8.4" +}; +var engines = { + node: ">=12" +}; +var browser$1 = { + fs: false +}; +var require$$4 = { + name: name$1, + version: version$6, + description: description$2, + main: main$1, + types: types$2, + exports: exports$1, + scripts: scripts$1, + repository: repository, + funding: funding, + keywords: keywords, + readmeFilename: readmeFilename, + license: license$1, + devDependencies: devDependencies$1, + engines: engines, + browser: browser$1 +}; + +const fs$1 = require$$0$1; +const path$1 = path$3; +const os$1 = require$$0$2; +const crypto$2 = require$$5; +const packageJson$1 = require$$4; + +const version$5 = packageJson$1.version; + +const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg; + +// Parse src into an Object +function parse$2 (src) { + const obj = {}; + + // Convert buffer to string + let lines = src.toString(); + + // Convert line breaks to same format + lines = lines.replace(/\r\n?/mg, '\n'); + + let match; + while ((match = LINE.exec(lines)) != null) { + const key = match[1]; + + // Default undefined or null to empty string + let value = (match[2] || ''); + + // Remove whitespace + value = value.trim(); + + // Check if double quoted + const maybeQuote = value[0]; + + // Remove surrounding quotes + value = value.replace(/^(['"`])([\s\S]*)\1$/mg, '$2'); + + // Expand newlines if double quoted + if (maybeQuote === '"') { + value = value.replace(/\\n/g, '\n'); + value = value.replace(/\\r/g, '\r'); + } + + // Add to object + obj[key] = value; + } + + return obj +} + +function _parseVault (options) { + const vaultPath = _vaultPath(options); + + // Parse .env.vault + const result = DotenvModule.configDotenv({ path: vaultPath }); + if (!result.parsed) { + const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`); + err.code = 'MISSING_DATA'; + throw err + } + + // handle scenario for comma separated keys - for use with key rotation + // example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod" + const keys = _dotenvKey(options).split(','); + const length = keys.length; + + let decrypted; + for (let i = 0; i < length; i++) { + try { + // Get full key + const key = keys[i].trim(); + + // Get instructions for decrypt + const attrs = _instructions(result, key); + + // Decrypt + decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key); + + break + } catch (error) { + // last key + if (i + 1 >= length) { + throw error + } + // try next key + } + } + + // Parse decrypted .env string + return DotenvModule.parse(decrypted) +} + +function _log (message) { + console.log(`[dotenv@${version$5}][INFO] ${message}`); +} + +function _warn (message) { + console.log(`[dotenv@${version$5}][WARN] ${message}`); +} + +function _debug (message) { + console.log(`[dotenv@${version$5}][DEBUG] ${message}`); +} + +function _dotenvKey (options) { + // prioritize developer directly setting options.DOTENV_KEY + if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) { + return options.DOTENV_KEY + } + + // secondary infra already contains a DOTENV_KEY environment variable + if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) { + return process.env.DOTENV_KEY + } + + // fallback to empty string + return '' +} + +function _instructions (result, dotenvKey) { + // Parse DOTENV_KEY. Format is a URI + let uri; + try { + uri = new URL(dotenvKey); + } catch (error) { + if (error.code === 'ERR_INVALID_URL') { + const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development'); + err.code = 'INVALID_DOTENV_KEY'; + throw err + } + + throw error + } + + // Get decrypt key + const key = uri.password; + if (!key) { + const err = new Error('INVALID_DOTENV_KEY: Missing key part'); + err.code = 'INVALID_DOTENV_KEY'; + throw err + } + + // Get environment + const environment = uri.searchParams.get('environment'); + if (!environment) { + const err = new Error('INVALID_DOTENV_KEY: Missing environment part'); + err.code = 'INVALID_DOTENV_KEY'; + throw err + } + + // Get ciphertext payload + const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`; + const ciphertext = result.parsed[environmentKey]; // DOTENV_VAULT_PRODUCTION + if (!ciphertext) { + const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`); + err.code = 'NOT_FOUND_DOTENV_ENVIRONMENT'; + throw err + } + + return { ciphertext, key } +} + +function _vaultPath (options) { + let possibleVaultPath = null; + + if (options && options.path && options.path.length > 0) { + if (Array.isArray(options.path)) { + for (const filepath of options.path) { + if (fs$1.existsSync(filepath)) { + possibleVaultPath = filepath.endsWith('.vault') ? filepath : `${filepath}.vault`; + } + } + } else { + possibleVaultPath = options.path.endsWith('.vault') ? options.path : `${options.path}.vault`; + } + } else { + possibleVaultPath = path$1.resolve(process.cwd(), '.env.vault'); + } + + if (fs$1.existsSync(possibleVaultPath)) { + return possibleVaultPath + } + + return null +} + +function _resolveHome (envPath) { + return envPath[0] === '~' ? path$1.join(os$1.homedir(), envPath.slice(1)) : envPath +} + +function _configVault (options) { + _log('Loading env from encrypted .env.vault'); + + const parsed = DotenvModule._parseVault(options); + + let processEnv = process.env; + if (options && options.processEnv != null) { + processEnv = options.processEnv; + } + + DotenvModule.populate(processEnv, parsed, options); + + return { parsed } +} + +function configDotenv (options) { + const dotenvPath = path$1.resolve(process.cwd(), '.env'); + let encoding = 'utf8'; + const debug = Boolean(options && options.debug); + + if (options && options.encoding) { + encoding = options.encoding; + } else { + if (debug) { + _debug('No encoding is specified. UTF-8 is used by default'); + } + } + + let optionPaths = [dotenvPath]; // default, look for .env + if (options && options.path) { + if (!Array.isArray(options.path)) { + optionPaths = [_resolveHome(options.path)]; + } else { + optionPaths = []; // reset default + for (const filepath of options.path) { + optionPaths.push(_resolveHome(filepath)); + } + } + } + + // Build the parsed data in a temporary object (because we need to return it). Once we have the final + // parsed data, we will combine it with process.env (or options.processEnv if provided). + let lastError; + const parsedAll = {}; + for (const path of optionPaths) { + try { + // Specifying an encoding returns a string instead of a buffer + const parsed = DotenvModule.parse(fs$1.readFileSync(path, { encoding })); + + DotenvModule.populate(parsedAll, parsed, options); + } catch (e) { + if (debug) { + _debug(`Failed to load ${path} ${e.message}`); + } + lastError = e; + } + } + + let processEnv = process.env; + if (options && options.processEnv != null) { + processEnv = options.processEnv; + } + + DotenvModule.populate(processEnv, parsedAll, options); + + if (lastError) { + return { parsed: parsedAll, error: lastError } + } else { + return { parsed: parsedAll } + } +} + +// Populates process.env from .env file +function config (options) { + // fallback to original dotenv if DOTENV_KEY is not set + if (_dotenvKey(options).length === 0) { + return DotenvModule.configDotenv(options) + } + + const vaultPath = _vaultPath(options); + + // dotenvKey exists but .env.vault file does not exist + if (!vaultPath) { + _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`); + + return DotenvModule.configDotenv(options) + } + + return DotenvModule._configVault(options) +} + +function decrypt$1 (encrypted, keyStr) { + const key = Buffer.from(keyStr.slice(-64), 'hex'); + let ciphertext = Buffer.from(encrypted, 'base64'); + + const nonce = ciphertext.subarray(0, 12); + const authTag = ciphertext.subarray(-16); + ciphertext = ciphertext.subarray(12, -16); + + try { + const aesgcm = crypto$2.createDecipheriv('aes-256-gcm', key, nonce); + aesgcm.setAuthTag(authTag); + return `${aesgcm.update(ciphertext)}${aesgcm.final()}` + } catch (error) { + const isRange = error instanceof RangeError; + const invalidKeyLength = error.message === 'Invalid key length'; + const decryptionFailed = error.message === 'Unsupported state or unable to authenticate data'; + + if (isRange || invalidKeyLength) { + const err = new Error('INVALID_DOTENV_KEY: It must be 64 characters long (or more)'); + err.code = 'INVALID_DOTENV_KEY'; + throw err + } else if (decryptionFailed) { + const err = new Error('DECRYPTION_FAILED: Please check your DOTENV_KEY'); + err.code = 'DECRYPTION_FAILED'; + throw err + } else { + throw error + } + } +} + +// Populate process.env with parsed values +function populate$1 (processEnv, parsed, options = {}) { + const debug = Boolean(options && options.debug); + const override = Boolean(options && options.override); + + if (typeof parsed !== 'object') { + const err = new Error('OBJECT_REQUIRED: Please check the processEnv argument being passed to populate'); + err.code = 'OBJECT_REQUIRED'; + throw err + } + + // Set process.env + for (const key of Object.keys(parsed)) { + if (Object.prototype.hasOwnProperty.call(processEnv, key)) { + if (override === true) { + processEnv[key] = parsed[key]; + } + + if (debug) { + if (override === true) { + _debug(`"${key}" is already defined and WAS overwritten`); + } else { + _debug(`"${key}" is already defined and was NOT overwritten`); + } + } + } else { + processEnv[key] = parsed[key]; + } + } +} + +const DotenvModule = { + configDotenv, + _configVault, + _parseVault, + config, + decrypt: decrypt$1, + parse: parse$2, + populate: populate$1 +}; + +main$2.exports.configDotenv = DotenvModule.configDotenv; +main$2.exports._configVault = DotenvModule._configVault; +main$2.exports._parseVault = DotenvModule._parseVault; +main$2.exports.config = DotenvModule.config; +main$2.exports.decrypt = DotenvModule.decrypt; +main$2.exports.parse = DotenvModule.parse; +main$2.exports.populate = DotenvModule.populate; + +main$2.exports = DotenvModule; + +var mainExports = main$2.exports; + +// ../config.js accepts options via environment variables +const options = {}; + +if (process.env.DOTENV_CONFIG_ENCODING != null) { + options.encoding = process.env.DOTENV_CONFIG_ENCODING; +} + +if (process.env.DOTENV_CONFIG_PATH != null) { + options.path = process.env.DOTENV_CONFIG_PATH; +} + +if (process.env.DOTENV_CONFIG_DEBUG != null) { + options.debug = process.env.DOTENV_CONFIG_DEBUG; +} + +if (process.env.DOTENV_CONFIG_OVERRIDE != null) { + options.override = process.env.DOTENV_CONFIG_OVERRIDE; +} + +if (process.env.DOTENV_CONFIG_DOTENV_KEY != null) { + options.DOTENV_KEY = process.env.DOTENV_CONFIG_DOTENV_KEY; +} + +var envOptions = options; + +const re = /^dotenv_config_(encoding|path|debug|override|DOTENV_KEY)=(.+)$/; + +var cliOptions = function optionMatcher (args) { + return args.reduce(function (acc, cur) { + const matches = cur.match(re); + if (matches) { + acc[matches[1]] = matches[2]; + } + return acc + }, {}) +}; + +(function () { + mainExports.config( + Object.assign( + {}, + envOptions, + cliOptions(process.argv) + ) + ); +})(); + +var commander = {}; + +var argument = {}; + +var error$k = {}; + +/** + * CommanderError class + * @class + */ + +let CommanderError$3 = class CommanderError extends Error { + /** + * Constructs the CommanderError class + * @param {number} exitCode suggested exit code which could be used with process.exit + * @param {string} code an id string representing the error + * @param {string} message human-readable description of the error + * @constructor + */ + constructor(exitCode, code, message) { + super(message); + // properly capture stack trace in Node.js + Error.captureStackTrace(this, this.constructor); + this.name = this.constructor.name; + this.code = code; + this.exitCode = exitCode; + this.nestedError = undefined; + } +}; + +/** + * InvalidArgumentError class + * @class + */ +let InvalidArgumentError$4 = class InvalidArgumentError extends CommanderError$3 { + /** + * Constructs the InvalidArgumentError class + * @param {string} [message] explanation of why argument is invalid + * @constructor + */ + constructor(message) { + super(1, 'commander.invalidArgument', message); + // properly capture stack trace in Node.js + Error.captureStackTrace(this, this.constructor); + this.name = this.constructor.name; + } +}; + +error$k.CommanderError = CommanderError$3; +error$k.InvalidArgumentError = InvalidArgumentError$4; + +const { InvalidArgumentError: InvalidArgumentError$3 } = error$k; + +let Argument$3 = class Argument { + /** + * Initialize a new command argument with the given name and description. + * The default is that the argument is required, and you can explicitly + * indicate this with <> around the name. Put [] around the name for an optional argument. + * + * @param {string} name + * @param {string} [description] + */ + + constructor(name, description) { + this.description = description || ''; + this.variadic = false; + this.parseArg = undefined; + this.defaultValue = undefined; + this.defaultValueDescription = undefined; + this.argChoices = undefined; + + switch (name[0]) { + case '<': // e.g. + this.required = true; + this._name = name.slice(1, -1); + break; + case '[': // e.g. [optional] + this.required = false; + this._name = name.slice(1, -1); + break; + default: + this.required = true; + this._name = name; + break; + } + + if (this._name.length > 3 && this._name.slice(-3) === '...') { + this.variadic = true; + this._name = this._name.slice(0, -3); + } + } + + /** + * Return argument name. + * + * @return {string} + */ + + name() { + return this._name; + } + + /** + * @package internal use only + */ + + _concatValue(value, previous) { + if (previous === this.defaultValue || !Array.isArray(previous)) { + return [value]; + } + + return previous.concat(value); + } + + /** + * Set the default value, and optionally supply the description to be displayed in the help. + * + * @param {*} value + * @param {string} [description] + * @return {Argument} + */ + + default(value, description) { + this.defaultValue = value; + this.defaultValueDescription = description; + return this; + } + + /** + * Set the custom handler for processing CLI command arguments into argument values. + * + * @param {Function} [fn] + * @return {Argument} + */ + + argParser(fn) { + this.parseArg = fn; + return this; + } + + /** + * Only allow argument value to be one of choices. + * + * @param {string[]} values + * @return {Argument} + */ + + choices(values) { + this.argChoices = values.slice(); + this.parseArg = (arg, previous) => { + if (!this.argChoices.includes(arg)) { + throw new InvalidArgumentError$3(`Allowed choices are ${this.argChoices.join(', ')}.`); + } + if (this.variadic) { + return this._concatValue(arg, previous); + } + return arg; + }; + return this; + } + + /** + * Make argument required. + */ + argRequired() { + this.required = true; + return this; + } + + /** + * Make argument optional. + */ + argOptional() { + this.required = false; + return this; + } +}; + +/** + * Takes an argument and returns its human readable equivalent for help usage. + * + * @param {Argument} arg + * @return {string} + * @private + */ + +function humanReadableArgName$2(arg) { + const nameOutput = arg.name() + (arg.variadic === true ? '...' : ''); + + return arg.required + ? '<' + nameOutput + '>' + : '[' + nameOutput + ']'; +} + +argument.Argument = Argument$3; +argument.humanReadableArgName = humanReadableArgName$2; + +var command = {}; + +var help = {}; + +const { humanReadableArgName: humanReadableArgName$1 } = argument; + +/** + * TypeScript import types for JSDoc, used by Visual Studio Code IntelliSense and `npm run typescript-checkJS` + * https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#import-types + * @typedef { import("./argument.js").Argument } Argument + * @typedef { import("./command.js").Command } Command + * @typedef { import("./option.js").Option } Option + */ + +// Although this is a class, methods are static in style to allow override using subclass or just functions. +let Help$3 = class Help { + constructor() { + this.helpWidth = undefined; + this.sortSubcommands = false; + this.sortOptions = false; + this.showGlobalOptions = false; + } + + /** + * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one. + * + * @param {Command} cmd + * @returns {Command[]} + */ + + visibleCommands(cmd) { + const visibleCommands = cmd.commands.filter(cmd => !cmd._hidden); + const helpCommand = cmd._getHelpCommand(); + if (helpCommand && !helpCommand._hidden) { + visibleCommands.push(helpCommand); + } + if (this.sortSubcommands) { + visibleCommands.sort((a, b) => { + // @ts-ignore: overloaded return type + return a.name().localeCompare(b.name()); + }); + } + return visibleCommands; + } + + /** + * Compare options for sort. + * + * @param {Option} a + * @param {Option} b + * @returns number + */ + compareOptions(a, b) { + const getSortKey = (option) => { + // WYSIWYG for order displayed in help. Short used for comparison if present. No special handling for negated. + return option.short ? option.short.replace(/^-/, '') : option.long.replace(/^--/, ''); + }; + return getSortKey(a).localeCompare(getSortKey(b)); + } + + /** + * Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one. + * + * @param {Command} cmd + * @returns {Option[]} + */ + + visibleOptions(cmd) { + const visibleOptions = cmd.options.filter((option) => !option.hidden); + // Built-in help option. + const helpOption = cmd._getHelpOption(); + if (helpOption && !helpOption.hidden) { + // Automatically hide conflicting flags. Bit dubious but a historical behaviour that is convenient for single-command programs. + const removeShort = helpOption.short && cmd._findOption(helpOption.short); + const removeLong = helpOption.long && cmd._findOption(helpOption.long); + if (!removeShort && !removeLong) { + visibleOptions.push(helpOption); // no changes needed + } else if (helpOption.long && !removeLong) { + visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description)); + } else if (helpOption.short && !removeShort) { + visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description)); + } + } + if (this.sortOptions) { + visibleOptions.sort(this.compareOptions); + } + return visibleOptions; + } + + /** + * Get an array of the visible global options. (Not including help.) + * + * @param {Command} cmd + * @returns {Option[]} + */ + + visibleGlobalOptions(cmd) { + if (!this.showGlobalOptions) return []; + + const globalOptions = []; + for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) { + const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden); + globalOptions.push(...visibleOptions); + } + if (this.sortOptions) { + globalOptions.sort(this.compareOptions); + } + return globalOptions; + } + + /** + * Get an array of the arguments if any have a description. + * + * @param {Command} cmd + * @returns {Argument[]} + */ + + visibleArguments(cmd) { + // Side effect! Apply the legacy descriptions before the arguments are displayed. + if (cmd._argsDescription) { + cmd.registeredArguments.forEach(argument => { + argument.description = argument.description || cmd._argsDescription[argument.name()] || ''; + }); + } + + // If there are any arguments with a description then return all the arguments. + if (cmd.registeredArguments.find(argument => argument.description)) { + return cmd.registeredArguments; + } + return []; + } + + /** + * Get the command term to show in the list of subcommands. + * + * @param {Command} cmd + * @returns {string} + */ + + subcommandTerm(cmd) { + // Legacy. Ignores custom usage string, and nested commands. + const args = cmd.registeredArguments.map(arg => humanReadableArgName$1(arg)).join(' '); + return cmd._name + + (cmd._aliases[0] ? '|' + cmd._aliases[0] : '') + + (cmd.options.length ? ' [options]' : '') + // simplistic check for non-help option + (args ? ' ' + args : ''); + } + + /** + * Get the option term to show in the list of options. + * + * @param {Option} option + * @returns {string} + */ + + optionTerm(option) { + return option.flags; + } + + /** + * Get the argument term to show in the list of arguments. + * + * @param {Argument} argument + * @returns {string} + */ + + argumentTerm(argument) { + return argument.name(); + } + + /** + * Get the longest command term length. + * + * @param {Command} cmd + * @param {Help} helper + * @returns {number} + */ + + longestSubcommandTermLength(cmd, helper) { + return helper.visibleCommands(cmd).reduce((max, command) => { + return Math.max(max, helper.subcommandTerm(command).length); + }, 0); + } + + /** + * Get the longest option term length. + * + * @param {Command} cmd + * @param {Help} helper + * @returns {number} + */ + + longestOptionTermLength(cmd, helper) { + return helper.visibleOptions(cmd).reduce((max, option) => { + return Math.max(max, helper.optionTerm(option).length); + }, 0); + } + + /** + * Get the longest global option term length. + * + * @param {Command} cmd + * @param {Help} helper + * @returns {number} + */ + + longestGlobalOptionTermLength(cmd, helper) { + return helper.visibleGlobalOptions(cmd).reduce((max, option) => { + return Math.max(max, helper.optionTerm(option).length); + }, 0); + } + + /** + * Get the longest argument term length. + * + * @param {Command} cmd + * @param {Help} helper + * @returns {number} + */ + + longestArgumentTermLength(cmd, helper) { + return helper.visibleArguments(cmd).reduce((max, argument) => { + return Math.max(max, helper.argumentTerm(argument).length); + }, 0); + } + + /** + * Get the command usage to be displayed at the top of the built-in help. + * + * @param {Command} cmd + * @returns {string} + */ + + commandUsage(cmd) { + // Usage + let cmdName = cmd._name; + if (cmd._aliases[0]) { + cmdName = cmdName + '|' + cmd._aliases[0]; + } + let ancestorCmdNames = ''; + for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) { + ancestorCmdNames = ancestorCmd.name() + ' ' + ancestorCmdNames; + } + return ancestorCmdNames + cmdName + ' ' + cmd.usage(); + } + + /** + * Get the description for the command. + * + * @param {Command} cmd + * @returns {string} + */ + + commandDescription(cmd) { + // @ts-ignore: overloaded return type + return cmd.description(); + } + + /** + * Get the subcommand summary to show in the list of subcommands. + * (Fallback to description for backwards compatibility.) + * + * @param {Command} cmd + * @returns {string} + */ + + subcommandDescription(cmd) { + // @ts-ignore: overloaded return type + return cmd.summary() || cmd.description(); + } + + /** + * Get the option description to show in the list of options. + * + * @param {Option} option + * @return {string} + */ + + optionDescription(option) { + const extraInfo = []; + + if (option.argChoices) { + extraInfo.push( + // use stringify to match the display of the default value + `choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`); + } + if (option.defaultValue !== undefined) { + // default for boolean and negated more for programmer than end user, + // but show true/false for boolean option as may be for hand-rolled env or config processing. + const showDefault = option.required || option.optional || + (option.isBoolean() && typeof option.defaultValue === 'boolean'); + if (showDefault) { + extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`); + } + } + // preset for boolean and negated are more for programmer than end user + if (option.presetArg !== undefined && option.optional) { + extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`); + } + if (option.envVar !== undefined) { + extraInfo.push(`env: ${option.envVar}`); + } + if (extraInfo.length > 0) { + return `${option.description} (${extraInfo.join(', ')})`; + } + + return option.description; + } + + /** + * Get the argument description to show in the list of arguments. + * + * @param {Argument} argument + * @return {string} + */ + + argumentDescription(argument) { + const extraInfo = []; + if (argument.argChoices) { + extraInfo.push( + // use stringify to match the display of the default value + `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`); + } + if (argument.defaultValue !== undefined) { + extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`); + } + if (extraInfo.length > 0) { + const extraDescripton = `(${extraInfo.join(', ')})`; + if (argument.description) { + return `${argument.description} ${extraDescripton}`; + } + return extraDescripton; + } + return argument.description; + } + + /** + * Generate the built-in help text. + * + * @param {Command} cmd + * @param {Help} helper + * @returns {string} + */ + + formatHelp(cmd, helper) { + const termWidth = helper.padWidth(cmd, helper); + const helpWidth = helper.helpWidth || 80; + const itemIndentWidth = 2; + const itemSeparatorWidth = 2; // between term and description + function formatItem(term, description) { + if (description) { + const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`; + return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth); + } + return term; + } + function formatList(textArray) { + return textArray.join('\n').replace(/^/gm, ' '.repeat(itemIndentWidth)); + } + + // Usage + let output = [`Usage: ${helper.commandUsage(cmd)}`, '']; + + // Description + const commandDescription = helper.commandDescription(cmd); + if (commandDescription.length > 0) { + output = output.concat([helper.wrap(commandDescription, helpWidth, 0), '']); + } + + // Arguments + const argumentList = helper.visibleArguments(cmd).map((argument) => { + return formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument)); + }); + if (argumentList.length > 0) { + output = output.concat(['Arguments:', formatList(argumentList), '']); + } + + // Options + const optionList = helper.visibleOptions(cmd).map((option) => { + return formatItem(helper.optionTerm(option), helper.optionDescription(option)); + }); + if (optionList.length > 0) { + output = output.concat(['Options:', formatList(optionList), '']); + } + + if (this.showGlobalOptions) { + const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => { + return formatItem(helper.optionTerm(option), helper.optionDescription(option)); + }); + if (globalOptionList.length > 0) { + output = output.concat(['Global Options:', formatList(globalOptionList), '']); + } + } + + // Commands + const commandList = helper.visibleCommands(cmd).map((cmd) => { + return formatItem(helper.subcommandTerm(cmd), helper.subcommandDescription(cmd)); + }); + if (commandList.length > 0) { + output = output.concat(['Commands:', formatList(commandList), '']); + } + + return output.join('\n'); + } + + /** + * Calculate the pad width from the maximum term length. + * + * @param {Command} cmd + * @param {Help} helper + * @returns {number} + */ + + padWidth(cmd, helper) { + return Math.max( + helper.longestOptionTermLength(cmd, helper), + helper.longestGlobalOptionTermLength(cmd, helper), + helper.longestSubcommandTermLength(cmd, helper), + helper.longestArgumentTermLength(cmd, helper) + ); + } + + /** + * Wrap the given string to width characters per line, with lines after the first indented. + * Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted. + * + * @param {string} str + * @param {number} width + * @param {number} indent + * @param {number} [minColumnWidth=40] + * @return {string} + * + */ + + wrap(str, width, indent, minColumnWidth = 40) { + // Full \s characters, minus the linefeeds. + const indents = ' \\f\\t\\v\u00a0\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff'; + // Detect manually wrapped and indented strings by searching for line break followed by spaces. + const manualIndent = new RegExp(`[\\n][${indents}]+`); + if (str.match(manualIndent)) return str; + // Do not wrap if not enough room for a wrapped column of text (as could end up with a word per line). + const columnWidth = width - indent; + if (columnWidth < minColumnWidth) return str; + + const leadingStr = str.slice(0, indent); + const columnText = str.slice(indent).replace('\r\n', '\n'); + const indentString = ' '.repeat(indent); + const zeroWidthSpace = '\u200B'; + const breaks = `\\s${zeroWidthSpace}`; + // Match line end (so empty lines don't collapse), + // or as much text as will fit in column, or excess text up to first break. + const regex = new RegExp(`\n|.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`, 'g'); + const lines = columnText.match(regex) || []; + return leadingStr + lines.map((line, i) => { + if (line === '\n') return ''; // preserve empty lines + return ((i > 0) ? indentString : '') + line.trimEnd(); + }).join('\n'); + } +}; + +help.Help = Help$3; + +var option = {}; + +const { InvalidArgumentError: InvalidArgumentError$2 } = error$k; + +let Option$3 = class Option { + /** + * Initialize a new `Option` with the given `flags` and `description`. + * + * @param {string} flags + * @param {string} [description] + */ + + constructor(flags, description) { + this.flags = flags; + this.description = description || ''; + + this.required = flags.includes('<'); // A value must be supplied when the option is specified. + this.optional = flags.includes('['); // A value is optional when the option is specified. + // variadic test ignores et al which might be used to describe custom splitting of single argument + this.variadic = /\w\.\.\.[>\]]$/.test(flags); // The option can take multiple values. + this.mandatory = false; // The option must have a value after parsing, which usually means it must be specified on command line. + const optionFlags = splitOptionFlags(flags); + this.short = optionFlags.shortFlag; + this.long = optionFlags.longFlag; + this.negate = false; + if (this.long) { + this.negate = this.long.startsWith('--no-'); + } + this.defaultValue = undefined; + this.defaultValueDescription = undefined; + this.presetArg = undefined; + this.envVar = undefined; + this.parseArg = undefined; + this.hidden = false; + this.argChoices = undefined; + this.conflictsWith = []; + this.implied = undefined; + } + + /** + * Set the default value, and optionally supply the description to be displayed in the help. + * + * @param {*} value + * @param {string} [description] + * @return {Option} + */ + + default(value, description) { + this.defaultValue = value; + this.defaultValueDescription = description; + return this; + } + + /** + * Preset to use when option used without option-argument, especially optional but also boolean and negated. + * The custom processing (parseArg) is called. + * + * @example + * new Option('--color').default('GREYSCALE').preset('RGB'); + * new Option('--donate [amount]').preset('20').argParser(parseFloat); + * + * @param {*} arg + * @return {Option} + */ + + preset(arg) { + this.presetArg = arg; + return this; + } + + /** + * Add option name(s) that conflict with this option. + * An error will be displayed if conflicting options are found during parsing. + * + * @example + * new Option('--rgb').conflicts('cmyk'); + * new Option('--js').conflicts(['ts', 'jsx']); + * + * @param {(string | string[])} names + * @return {Option} + */ + + conflicts(names) { + this.conflictsWith = this.conflictsWith.concat(names); + return this; + } + + /** + * Specify implied option values for when this option is set and the implied options are not. + * + * The custom processing (parseArg) is not called on the implied values. + * + * @example + * program + * .addOption(new Option('--log', 'write logging information to file')) + * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' })); + * + * @param {Object} impliedOptionValues + * @return {Option} + */ + implies(impliedOptionValues) { + let newImplied = impliedOptionValues; + if (typeof impliedOptionValues === 'string') { + // string is not documented, but easy mistake and we can do what user probably intended. + newImplied = { [impliedOptionValues]: true }; + } + this.implied = Object.assign(this.implied || {}, newImplied); + return this; + } + + /** + * Set environment variable to check for option value. + * + * An environment variable is only used if when processed the current option value is + * undefined, or the source of the current value is 'default' or 'config' or 'env'. + * + * @param {string} name + * @return {Option} + */ + + env(name) { + this.envVar = name; + return this; + } + + /** + * Set the custom handler for processing CLI option arguments into option values. + * + * @param {Function} [fn] + * @return {Option} + */ + + argParser(fn) { + this.parseArg = fn; + return this; + } + + /** + * Whether the option is mandatory and must have a value after parsing. + * + * @param {boolean} [mandatory=true] + * @return {Option} + */ + + makeOptionMandatory(mandatory = true) { + this.mandatory = !!mandatory; + return this; + } + + /** + * Hide option in help. + * + * @param {boolean} [hide=true] + * @return {Option} + */ + + hideHelp(hide = true) { + this.hidden = !!hide; + return this; + } + + /** + * @package internal use only + */ + + _concatValue(value, previous) { + if (previous === this.defaultValue || !Array.isArray(previous)) { + return [value]; + } + + return previous.concat(value); + } + + /** + * Only allow option value to be one of choices. + * + * @param {string[]} values + * @return {Option} + */ + + choices(values) { + this.argChoices = values.slice(); + this.parseArg = (arg, previous) => { + if (!this.argChoices.includes(arg)) { + throw new InvalidArgumentError$2(`Allowed choices are ${this.argChoices.join(', ')}.`); + } + if (this.variadic) { + return this._concatValue(arg, previous); + } + return arg; + }; + return this; + } + + /** + * Return option name. + * + * @return {string} + */ + + name() { + if (this.long) { + return this.long.replace(/^--/, ''); + } + return this.short.replace(/^-/, ''); + } + + /** + * Return option name, in a camelcase format that can be used + * as a object attribute key. + * + * @return {string} + */ + + attributeName() { + return camelcase(this.name().replace(/^no-/, '')); + } + + /** + * Check if `arg` matches the short or long flag. + * + * @param {string} arg + * @return {boolean} + * @package internal use only + */ + + is(arg) { + return this.short === arg || this.long === arg; + } + + /** + * Return whether a boolean option. + * + * Options are one of boolean, negated, required argument, or optional argument. + * + * @return {boolean} + * @package internal use only + */ + + isBoolean() { + return !this.required && !this.optional && !this.negate; + } +}; + +/** + * This class is to make it easier to work with dual options, without changing the existing + * implementation. We support separate dual options for separate positive and negative options, + * like `--build` and `--no-build`, which share a single option value. This works nicely for some + * use cases, but is tricky for others where we want separate behaviours despite + * the single shared option value. + */ +let DualOptions$1 = class DualOptions { + /** + * @param {Option[]} options + */ + constructor(options) { + this.positiveOptions = new Map(); + this.negativeOptions = new Map(); + this.dualOptions = new Set(); + options.forEach(option => { + if (option.negate) { + this.negativeOptions.set(option.attributeName(), option); + } else { + this.positiveOptions.set(option.attributeName(), option); + } + }); + this.negativeOptions.forEach((value, key) => { + if (this.positiveOptions.has(key)) { + this.dualOptions.add(key); + } + }); + } + + /** + * Did the value come from the option, and not from possible matching dual option? + * + * @param {*} value + * @param {Option} option + * @returns {boolean} + */ + valueFromOption(value, option) { + const optionKey = option.attributeName(); + if (!this.dualOptions.has(optionKey)) return true; + + // Use the value to deduce if (probably) came from the option. + const preset = this.negativeOptions.get(optionKey).presetArg; + const negativeValue = (preset !== undefined) ? preset : false; + return option.negate === (negativeValue === value); + } +}; + +/** + * Convert string from kebab-case to camelCase. + * + * @param {string} str + * @return {string} + * @private + */ + +function camelcase(str) { + return str.split('-').reduce((str, word) => { + return str + word[0].toUpperCase() + word.slice(1); + }); +} + +/** + * Split the short and long flag out of something like '-m,--mixed ' + * + * @private + */ + +function splitOptionFlags(flags) { + let shortFlag; + let longFlag; + // Use original very loose parsing to maintain backwards compatibility for now, + // which allowed for example unintended `-sw, --short-word` [sic]. + const flagParts = flags.split(/[ |,]+/); + if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1])) shortFlag = flagParts.shift(); + longFlag = flagParts.shift(); + // Add support for lone short flag without significantly changing parsing! + if (!shortFlag && /^-[^-]$/.test(longFlag)) { + shortFlag = longFlag; + longFlag = undefined; + } + return { shortFlag, longFlag }; +} + +option.Option = Option$3; +option.DualOptions = DualOptions$1; + +var suggestSimilar$2 = {}; + +const maxDistance = 3; + +function editDistance(a, b) { + // https://en.wikipedia.org/wiki/Damerau–Levenshtein_distance + // Calculating optimal string alignment distance, no substring is edited more than once. + // (Simple implementation.) + + // Quick early exit, return worst case. + if (Math.abs(a.length - b.length) > maxDistance) return Math.max(a.length, b.length); + + // distance between prefix substrings of a and b + const d = []; + + // pure deletions turn a into empty string + for (let i = 0; i <= a.length; i++) { + d[i] = [i]; + } + // pure insertions turn empty string into b + for (let j = 0; j <= b.length; j++) { + d[0][j] = j; + } + + // fill matrix + for (let j = 1; j <= b.length; j++) { + for (let i = 1; i <= a.length; i++) { + let cost = 1; + if (a[i - 1] === b[j - 1]) { + cost = 0; + } else { + cost = 1; + } + d[i][j] = Math.min( + d[i - 1][j] + 1, // deletion + d[i][j - 1] + 1, // insertion + d[i - 1][j - 1] + cost // substitution + ); + // transposition + if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) { + d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1); + } + } + } + + return d[a.length][b.length]; +} + +/** + * Find close matches, restricted to same number of edits. + * + * @param {string} word + * @param {string[]} candidates + * @returns {string} + */ + +function suggestSimilar$1(word, candidates) { + if (!candidates || candidates.length === 0) return ''; + // remove possible duplicates + candidates = Array.from(new Set(candidates)); + + const searchingOptions = word.startsWith('--'); + if (searchingOptions) { + word = word.slice(2); + candidates = candidates.map(candidate => candidate.slice(2)); + } + + let similar = []; + let bestDistance = maxDistance; + const minSimilarity = 0.4; + candidates.forEach((candidate) => { + if (candidate.length <= 1) return; // no one character guesses + + const distance = editDistance(word, candidate); + const length = Math.max(word.length, candidate.length); + const similarity = (length - distance) / length; + if (similarity > minSimilarity) { + if (distance < bestDistance) { + // better edit distance, throw away previous worse matches + bestDistance = distance; + similar = [candidate]; + } else if (distance === bestDistance) { + similar.push(candidate); + } + } + }); + + similar.sort((a, b) => a.localeCompare(b)); + if (searchingOptions) { + similar = similar.map(candidate => `--${candidate}`); + } + + if (similar.length > 1) { + return `\n(Did you mean one of ${similar.join(', ')}?)`; + } + if (similar.length === 1) { + return `\n(Did you mean ${similar[0]}?)`; + } + return ''; +} + +suggestSimilar$2.suggestSimilar = suggestSimilar$1; + +const EventEmitter$1 = require$$0$3.EventEmitter; +const childProcess = require$$1$1; +const path = path$3; +const fs = require$$0$1; +const process$1 = process$2; + +const { Argument: Argument$2, humanReadableArgName } = argument; +const { CommanderError: CommanderError$2 } = error$k; +const { Help: Help$2 } = help; +const { Option: Option$2, DualOptions } = option; +const { suggestSimilar } = suggestSimilar$2; + +let Command$2 = class Command extends EventEmitter$1 { + /** + * Initialize a new `Command`. + * + * @param {string} [name] + */ + + constructor(name) { + super(); + /** @type {Command[]} */ + this.commands = []; + /** @type {Option[]} */ + this.options = []; + this.parent = null; + this._allowUnknownOption = false; + this._allowExcessArguments = true; + /** @type {Argument[]} */ + this.registeredArguments = []; + this._args = this.registeredArguments; // deprecated old name + /** @type {string[]} */ + this.args = []; // cli args with options removed + this.rawArgs = []; + this.processedArgs = []; // like .args but after custom processing and collecting variadic + this._scriptPath = null; + this._name = name || ''; + this._optionValues = {}; + this._optionValueSources = {}; // default, env, cli etc + this._storeOptionsAsProperties = false; + this._actionHandler = null; + this._executableHandler = false; + this._executableFile = null; // custom name for executable + this._executableDir = null; // custom search directory for subcommands + this._defaultCommandName = null; + this._exitCallback = null; + this._aliases = []; + this._combineFlagAndOptionalValue = true; + this._description = ''; + this._summary = ''; + this._argsDescription = undefined; // legacy + this._enablePositionalOptions = false; + this._passThroughOptions = false; + this._lifeCycleHooks = {}; // a hash of arrays + /** @type {(boolean | string)} */ + this._showHelpAfterError = false; + this._showSuggestionAfterError = true; + + // see .configureOutput() for docs + this._outputConfiguration = { + writeOut: (str) => process$1.stdout.write(str), + writeErr: (str) => process$1.stderr.write(str), + getOutHelpWidth: () => process$1.stdout.isTTY ? process$1.stdout.columns : undefined, + getErrHelpWidth: () => process$1.stderr.isTTY ? process$1.stderr.columns : undefined, + outputError: (str, write) => write(str) + }; + + this._hidden = false; + /** @type {(Option | null | undefined)} */ + this._helpOption = undefined; // Lazy created on demand. May be null if help option is disabled. + this._addImplicitHelpCommand = undefined; // undecided whether true or false yet, not inherited + /** @type {Command} */ + this._helpCommand = undefined; // lazy initialised, inherited + this._helpConfiguration = {}; + } + + /** + * Copy settings that are useful to have in common across root command and subcommands. + * + * (Used internally when adding a command using `.command()` so subcommands inherit parent settings.) + * + * @param {Command} sourceCommand + * @return {Command} `this` command for chaining + */ + copyInheritedSettings(sourceCommand) { + this._outputConfiguration = sourceCommand._outputConfiguration; + this._helpOption = sourceCommand._helpOption; + this._helpCommand = sourceCommand._helpCommand; + this._helpConfiguration = sourceCommand._helpConfiguration; + this._exitCallback = sourceCommand._exitCallback; + this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties; + this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue; + this._allowExcessArguments = sourceCommand._allowExcessArguments; + this._enablePositionalOptions = sourceCommand._enablePositionalOptions; + this._showHelpAfterError = sourceCommand._showHelpAfterError; + this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError; + + return this; + } + + /** + * @returns {Command[]} + * @private + */ + + _getCommandAndAncestors() { + const result = []; + for (let command = this; command; command = command.parent) { + result.push(command); + } + return result; + } + + /** + * Define a command. + * + * There are two styles of command: pay attention to where to put the description. + * + * @example + * // Command implemented using action handler (description is supplied separately to `.command`) + * program + * .command('clone [destination]') + * .description('clone a repository into a newly created directory') + * .action((source, destination) => { + * console.log('clone command called'); + * }); + * + * // Command implemented using separate executable file (description is second parameter to `.command`) + * program + * .command('start ', 'start named service') + * .command('stop [service]', 'stop named service, or all if no name supplied'); + * + * @param {string} nameAndArgs - command name and arguments, args are `` or `[optional]` and last may also be `variadic...` + * @param {(Object|string)} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable) + * @param {Object} [execOpts] - configuration options (for executable) + * @return {Command} returns new command for action handler, or `this` for executable command + */ + + command(nameAndArgs, actionOptsOrExecDesc, execOpts) { + let desc = actionOptsOrExecDesc; + let opts = execOpts; + if (typeof desc === 'object' && desc !== null) { + opts = desc; + desc = null; + } + opts = opts || {}; + const [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/); + + const cmd = this.createCommand(name); + if (desc) { + cmd.description(desc); + cmd._executableHandler = true; + } + if (opts.isDefault) this._defaultCommandName = cmd._name; + cmd._hidden = !!(opts.noHelp || opts.hidden); // noHelp is deprecated old name for hidden + cmd._executableFile = opts.executableFile || null; // Custom name for executable file, set missing to null to match constructor + if (args) cmd.arguments(args); + this._registerCommand(cmd); + cmd.parent = this; + cmd.copyInheritedSettings(this); + + if (desc) return this; + return cmd; + } + + /** + * Factory routine to create a new unattached command. + * + * See .command() for creating an attached subcommand, which uses this routine to + * create the command. You can override createCommand to customise subcommands. + * + * @param {string} [name] + * @return {Command} new command + */ + + createCommand(name) { + return new Command(name); + } + + /** + * You can customise the help with a subclass of Help by overriding createHelp, + * or by overriding Help properties using configureHelp(). + * + * @return {Help} + */ + + createHelp() { + return Object.assign(new Help$2(), this.configureHelp()); + } + + /** + * You can customise the help by overriding Help properties using configureHelp(), + * or with a subclass of Help by overriding createHelp(). + * + * @param {Object} [configuration] - configuration options + * @return {(Command|Object)} `this` command for chaining, or stored configuration + */ + + configureHelp(configuration) { + if (configuration === undefined) return this._helpConfiguration; + + this._helpConfiguration = configuration; + return this; + } + + /** + * The default output goes to stdout and stderr. You can customise this for special + * applications. You can also customise the display of errors by overriding outputError. + * + * The configuration properties are all functions: + * + * // functions to change where being written, stdout and stderr + * writeOut(str) + * writeErr(str) + * // matching functions to specify width for wrapping help + * getOutHelpWidth() + * getErrHelpWidth() + * // functions based on what is being written out + * outputError(str, write) // used for displaying errors, and not used for displaying help + * + * @param {Object} [configuration] - configuration options + * @return {(Command|Object)} `this` command for chaining, or stored configuration + */ + + configureOutput(configuration) { + if (configuration === undefined) return this._outputConfiguration; + + Object.assign(this._outputConfiguration, configuration); + return this; + } + + /** + * Display the help or a custom message after an error occurs. + * + * @param {(boolean|string)} [displayHelp] + * @return {Command} `this` command for chaining + */ + showHelpAfterError(displayHelp = true) { + if (typeof displayHelp !== 'string') displayHelp = !!displayHelp; + this._showHelpAfterError = displayHelp; + return this; + } + + /** + * Display suggestion of similar commands for unknown commands, or options for unknown options. + * + * @param {boolean} [displaySuggestion] + * @return {Command} `this` command for chaining + */ + showSuggestionAfterError(displaySuggestion = true) { + this._showSuggestionAfterError = !!displaySuggestion; + return this; + } + + /** + * Add a prepared subcommand. + * + * See .command() for creating an attached subcommand which inherits settings from its parent. + * + * @param {Command} cmd - new subcommand + * @param {Object} [opts] - configuration options + * @return {Command} `this` command for chaining + */ + + addCommand(cmd, opts) { + if (!cmd._name) { + throw new Error(`Command passed to .addCommand() must have a name +- specify the name in Command constructor or using .name()`); + } + + opts = opts || {}; + if (opts.isDefault) this._defaultCommandName = cmd._name; + if (opts.noHelp || opts.hidden) cmd._hidden = true; // modifying passed command due to existing implementation + + this._registerCommand(cmd); + cmd.parent = this; + cmd._checkForBrokenPassThrough(); + + return this; + } + + /** + * Factory routine to create a new unattached argument. + * + * See .argument() for creating an attached argument, which uses this routine to + * create the argument. You can override createArgument to return a custom argument. + * + * @param {string} name + * @param {string} [description] + * @return {Argument} new argument + */ + + createArgument(name, description) { + return new Argument$2(name, description); + } + + /** + * Define argument syntax for command. + * + * The default is that the argument is required, and you can explicitly + * indicate this with <> around the name. Put [] around the name for an optional argument. + * + * @example + * program.argument(''); + * program.argument('[output-file]'); + * + * @param {string} name + * @param {string} [description] + * @param {(Function|*)} [fn] - custom argument processing function + * @param {*} [defaultValue] + * @return {Command} `this` command for chaining + */ + argument(name, description, fn, defaultValue) { + const argument = this.createArgument(name, description); + if (typeof fn === 'function') { + argument.default(defaultValue).argParser(fn); + } else { + argument.default(fn); + } + this.addArgument(argument); + return this; + } + + /** + * Define argument syntax for command, adding multiple at once (without descriptions). + * + * See also .argument(). + * + * @example + * program.arguments(' [env]'); + * + * @param {string} names + * @return {Command} `this` command for chaining + */ + + arguments(names) { + names.trim().split(/ +/).forEach((detail) => { + this.argument(detail); + }); + return this; + } + + /** + * Define argument syntax for command, adding a prepared argument. + * + * @param {Argument} argument + * @return {Command} `this` command for chaining + */ + addArgument(argument) { + const previousArgument = this.registeredArguments.slice(-1)[0]; + if (previousArgument && previousArgument.variadic) { + throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`); + } + if (argument.required && argument.defaultValue !== undefined && argument.parseArg === undefined) { + throw new Error(`a default value for a required argument is never used: '${argument.name()}'`); + } + this.registeredArguments.push(argument); + return this; + } + + /** + * Customise or override default help command. By default a help command is automatically added if your command has subcommands. + * + * program.helpCommand('help [cmd]'); + * program.helpCommand('help [cmd]', 'show help'); + * program.helpCommand(false); // suppress default help command + * program.helpCommand(true); // add help command even if no subcommands + * + * @param {string|boolean} enableOrNameAndArgs - enable with custom name and/or arguments, or boolean to override whether added + * @param {string} [description] - custom description + * @return {Command} `this` command for chaining + */ + + helpCommand(enableOrNameAndArgs, description) { + if (typeof enableOrNameAndArgs === 'boolean') { + this._addImplicitHelpCommand = enableOrNameAndArgs; + return this; + } + + enableOrNameAndArgs = enableOrNameAndArgs ?? 'help [command]'; + const [, helpName, helpArgs] = enableOrNameAndArgs.match(/([^ ]+) *(.*)/); + const helpDescription = description ?? 'display help for command'; + + const helpCommand = this.createCommand(helpName); + helpCommand.helpOption(false); + if (helpArgs) helpCommand.arguments(helpArgs); + if (helpDescription) helpCommand.description(helpDescription); + + this._addImplicitHelpCommand = true; + this._helpCommand = helpCommand; + + return this; + } + + /** + * Add prepared custom help command. + * + * @param {(Command|string|boolean)} helpCommand - custom help command, or deprecated enableOrNameAndArgs as for `.helpCommand()` + * @param {string} [deprecatedDescription] - deprecated custom description used with custom name only + * @return {Command} `this` command for chaining + */ + addHelpCommand(helpCommand, deprecatedDescription) { + // If not passed an object, call through to helpCommand for backwards compatibility, + // as addHelpCommand was originally used like helpCommand is now. + if (typeof helpCommand !== 'object') { + this.helpCommand(helpCommand, deprecatedDescription); + return this; + } + + this._addImplicitHelpCommand = true; + this._helpCommand = helpCommand; + return this; + } + + /** + * Lazy create help command. + * + * @return {(Command|null)} + * @package + */ + _getHelpCommand() { + const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? + (this.commands.length && !this._actionHandler && !this._findCommand('help')); + + if (hasImplicitHelpCommand) { + if (this._helpCommand === undefined) { + this.helpCommand(undefined, undefined); // use default name and description + } + return this._helpCommand; + } + return null; + } + + /** + * Add hook for life cycle event. + * + * @param {string} event + * @param {Function} listener + * @return {Command} `this` command for chaining + */ + + hook(event, listener) { + const allowedValues = ['preSubcommand', 'preAction', 'postAction']; + if (!allowedValues.includes(event)) { + throw new Error(`Unexpected value for event passed to hook : '${event}'. +Expecting one of '${allowedValues.join("', '")}'`); + } + if (this._lifeCycleHooks[event]) { + this._lifeCycleHooks[event].push(listener); + } else { + this._lifeCycleHooks[event] = [listener]; + } + return this; + } + + /** + * Register callback to use as replacement for calling process.exit. + * + * @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing + * @return {Command} `this` command for chaining + */ + + exitOverride(fn) { + if (fn) { + this._exitCallback = fn; + } else { + this._exitCallback = (err) => { + if (err.code !== 'commander.executeSubCommandAsync') { + throw err; + } + }; + } + return this; + } + + /** + * Call process.exit, and _exitCallback if defined. + * + * @param {number} exitCode exit code for using with process.exit + * @param {string} code an id string representing the error + * @param {string} message human-readable description of the error + * @return never + * @private + */ + + _exit(exitCode, code, message) { + if (this._exitCallback) { + this._exitCallback(new CommanderError$2(exitCode, code, message)); + // Expecting this line is not reached. + } + process$1.exit(exitCode); + } + + /** + * Register callback `fn` for the command. + * + * @example + * program + * .command('serve') + * .description('start service') + * .action(function() { + * // do work here + * }); + * + * @param {Function} fn + * @return {Command} `this` command for chaining + */ + + action(fn) { + const listener = (args) => { + // The .action callback takes an extra parameter which is the command or options. + const expectedArgsCount = this.registeredArguments.length; + const actionArgs = args.slice(0, expectedArgsCount); + if (this._storeOptionsAsProperties) { + actionArgs[expectedArgsCount] = this; // backwards compatible "options" + } else { + actionArgs[expectedArgsCount] = this.opts(); + } + actionArgs.push(this); + + return fn.apply(this, actionArgs); + }; + this._actionHandler = listener; + return this; + } + + /** + * Factory routine to create a new unattached option. + * + * See .option() for creating an attached option, which uses this routine to + * create the option. You can override createOption to return a custom option. + * + * @param {string} flags + * @param {string} [description] + * @return {Option} new option + */ + + createOption(flags, description) { + return new Option$2(flags, description); + } + + /** + * Wrap parseArgs to catch 'commander.invalidArgument'. + * + * @param {(Option | Argument)} target + * @param {string} value + * @param {*} previous + * @param {string} invalidArgumentMessage + * @private + */ + + _callParseArg(target, value, previous, invalidArgumentMessage) { + try { + return target.parseArg(value, previous); + } catch (err) { + if (err.code === 'commander.invalidArgument') { + const message = `${invalidArgumentMessage} ${err.message}`; + this.error(message, { exitCode: err.exitCode, code: err.code }); + } + throw err; + } + } + + /** + * Check for option flag conflicts. + * Register option if no conflicts found, or throw on conflict. + * + * @param {Option} option + * @api private + */ + + _registerOption(option) { + const matchingOption = (option.short && this._findOption(option.short)) || + (option.long && this._findOption(option.long)); + if (matchingOption) { + const matchingFlag = (option.long && this._findOption(option.long)) ? option.long : option.short; + throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}' +- already used by option '${matchingOption.flags}'`); + } + + this.options.push(option); + } + + /** + * Check for command name and alias conflicts with existing commands. + * Register command if no conflicts found, or throw on conflict. + * + * @param {Command} command + * @api private + */ + + _registerCommand(command) { + const knownBy = (cmd) => { + return [cmd.name()].concat(cmd.aliases()); + }; + + const alreadyUsed = knownBy(command).find((name) => this._findCommand(name)); + if (alreadyUsed) { + const existingCmd = knownBy(this._findCommand(alreadyUsed)).join('|'); + const newCmd = knownBy(command).join('|'); + throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`); + } + + this.commands.push(command); + } + + /** + * Add an option. + * + * @param {Option} option + * @return {Command} `this` command for chaining + */ + addOption(option) { + this._registerOption(option); + + const oname = option.name(); + const name = option.attributeName(); + + // store default value + if (option.negate) { + // --no-foo is special and defaults foo to true, unless a --foo option is already defined + const positiveLongFlag = option.long.replace(/^--no-/, '--'); + if (!this._findOption(positiveLongFlag)) { + this.setOptionValueWithSource(name, option.defaultValue === undefined ? true : option.defaultValue, 'default'); + } + } else if (option.defaultValue !== undefined) { + this.setOptionValueWithSource(name, option.defaultValue, 'default'); + } + + // handler for cli and env supplied values + const handleOptionValue = (val, invalidValueMessage, valueSource) => { + // val is null for optional option used without an optional-argument. + // val is undefined for boolean and negated option. + if (val == null && option.presetArg !== undefined) { + val = option.presetArg; + } + + // custom processing + const oldValue = this.getOptionValue(name); + if (val !== null && option.parseArg) { + val = this._callParseArg(option, val, oldValue, invalidValueMessage); + } else if (val !== null && option.variadic) { + val = option._concatValue(val, oldValue); + } + + // Fill-in appropriate missing values. Long winded but easy to follow. + if (val == null) { + if (option.negate) { + val = false; + } else if (option.isBoolean() || option.optional) { + val = true; + } else { + val = ''; // not normal, parseArg might have failed or be a mock function for testing + } + } + this.setOptionValueWithSource(name, val, valueSource); + }; + + this.on('option:' + oname, (val) => { + const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`; + handleOptionValue(val, invalidValueMessage, 'cli'); + }); + + if (option.envVar) { + this.on('optionEnv:' + oname, (val) => { + const invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`; + handleOptionValue(val, invalidValueMessage, 'env'); + }); + } + + return this; + } + + /** + * Internal implementation shared by .option() and .requiredOption() + * + * @private + */ + _optionEx(config, flags, description, fn, defaultValue) { + if (typeof flags === 'object' && flags instanceof Option$2) { + throw new Error('To add an Option object use addOption() instead of option() or requiredOption()'); + } + const option = this.createOption(flags, description); + option.makeOptionMandatory(!!config.mandatory); + if (typeof fn === 'function') { + option.default(defaultValue).argParser(fn); + } else if (fn instanceof RegExp) { + // deprecated + const regex = fn; + fn = (val, def) => { + const m = regex.exec(val); + return m ? m[0] : def; + }; + option.default(defaultValue).argParser(fn); + } else { + option.default(fn); + } + + return this.addOption(option); + } + + /** + * Define option with `flags`, `description`, and optional argument parsing function or `defaultValue` or both. + * + * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space. A required + * option-argument is indicated by `<>` and an optional option-argument by `[]`. + * + * See the README for more details, and see also addOption() and requiredOption(). + * + * @example + * program + * .option('-p, --pepper', 'add pepper') + * .option('-p, --pizza-type ', 'type of pizza') // required option-argument + * .option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default + * .option('-t, --tip ', 'add tip to purchase cost', parseFloat) // custom parse function + * + * @param {string} flags + * @param {string} [description] + * @param {(Function|*)} [parseArg] - custom option processing function or default value + * @param {*} [defaultValue] + * @return {Command} `this` command for chaining + */ + + option(flags, description, parseArg, defaultValue) { + return this._optionEx({}, flags, description, parseArg, defaultValue); + } + + /** + * Add a required option which must have a value after parsing. This usually means + * the option must be specified on the command line. (Otherwise the same as .option().) + * + * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space. + * + * @param {string} flags + * @param {string} [description] + * @param {(Function|*)} [parseArg] - custom option processing function or default value + * @param {*} [defaultValue] + * @return {Command} `this` command for chaining + */ + + requiredOption(flags, description, parseArg, defaultValue) { + return this._optionEx({ mandatory: true }, flags, description, parseArg, defaultValue); + } + + /** + * Alter parsing of short flags with optional values. + * + * @example + * // for `.option('-f,--flag [value]'): + * program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour + * program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b` + * + * @param {boolean} [combine=true] - if `true` or omitted, an optional value can be specified directly after the flag. + */ + combineFlagAndOptionalValue(combine = true) { + this._combineFlagAndOptionalValue = !!combine; + return this; + } + + /** + * Allow unknown options on the command line. + * + * @param {boolean} [allowUnknown=true] - if `true` or omitted, no error will be thrown + * for unknown options. + */ + allowUnknownOption(allowUnknown = true) { + this._allowUnknownOption = !!allowUnknown; + return this; + } + + /** + * Allow excess command-arguments on the command line. Pass false to make excess arguments an error. + * + * @param {boolean} [allowExcess=true] - if `true` or omitted, no error will be thrown + * for excess arguments. + */ + allowExcessArguments(allowExcess = true) { + this._allowExcessArguments = !!allowExcess; + return this; + } + + /** + * Enable positional options. Positional means global options are specified before subcommands which lets + * subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions. + * The default behaviour is non-positional and global options may appear anywhere on the command line. + * + * @param {boolean} [positional=true] + */ + enablePositionalOptions(positional = true) { + this._enablePositionalOptions = !!positional; + return this; + } + + /** + * Pass through options that come after command-arguments rather than treat them as command-options, + * so actual command-options come before command-arguments. Turning this on for a subcommand requires + * positional options to have been enabled on the program (parent commands). + * The default behaviour is non-positional and options may appear before or after command-arguments. + * + * @param {boolean} [passThrough=true] + * for unknown options. + */ + passThroughOptions(passThrough = true) { + this._passThroughOptions = !!passThrough; + this._checkForBrokenPassThrough(); + return this; + } + + /** + * @private + */ + + _checkForBrokenPassThrough() { + if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) { + throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`); + } + } + + /** + * Whether to store option values as properties on command object, + * or store separately (specify false). In both cases the option values can be accessed using .opts(). + * + * @param {boolean} [storeAsProperties=true] + * @return {Command} `this` command for chaining + */ + + storeOptionsAsProperties(storeAsProperties = true) { + if (this.options.length) { + throw new Error('call .storeOptionsAsProperties() before adding options'); + } + if (Object.keys(this._optionValues).length) { + throw new Error('call .storeOptionsAsProperties() before setting option values'); + } + this._storeOptionsAsProperties = !!storeAsProperties; + return this; + } + + /** + * Retrieve option value. + * + * @param {string} key + * @return {Object} value + */ + + getOptionValue(key) { + if (this._storeOptionsAsProperties) { + return this[key]; + } + return this._optionValues[key]; + } + + /** + * Store option value. + * + * @param {string} key + * @param {Object} value + * @return {Command} `this` command for chaining + */ + + setOptionValue(key, value) { + return this.setOptionValueWithSource(key, value, undefined); + } + + /** + * Store option value and where the value came from. + * + * @param {string} key + * @param {Object} value + * @param {string} source - expected values are default/config/env/cli/implied + * @return {Command} `this` command for chaining + */ + + setOptionValueWithSource(key, value, source) { + if (this._storeOptionsAsProperties) { + this[key] = value; + } else { + this._optionValues[key] = value; + } + this._optionValueSources[key] = source; + return this; + } + + /** + * Get source of option value. + * Expected values are default | config | env | cli | implied + * + * @param {string} key + * @return {string} + */ + + getOptionValueSource(key) { + return this._optionValueSources[key]; + } + + /** + * Get source of option value. See also .optsWithGlobals(). + * Expected values are default | config | env | cli | implied + * + * @param {string} key + * @return {string} + */ + + getOptionValueSourceWithGlobals(key) { + // global overwrites local, like optsWithGlobals + let source; + this._getCommandAndAncestors().forEach((cmd) => { + if (cmd.getOptionValueSource(key) !== undefined) { + source = cmd.getOptionValueSource(key); + } + }); + return source; + } + + /** + * Get user arguments from implied or explicit arguments. + * Side-effects: set _scriptPath if args included script. Used for default program name, and subcommand searches. + * + * @private + */ + + _prepareUserArgs(argv, parseOptions) { + if (argv !== undefined && !Array.isArray(argv)) { + throw new Error('first parameter to parse must be array or undefined'); + } + parseOptions = parseOptions || {}; + + // Default to using process.argv + if (argv === undefined) { + argv = process$1.argv; + // @ts-ignore: unknown property + if (process$1.versions && process$1.versions.electron) { + parseOptions.from = 'electron'; + } + } + this.rawArgs = argv.slice(); + + // make it a little easier for callers by supporting various argv conventions + let userArgs; + switch (parseOptions.from) { + case undefined: + case 'node': + this._scriptPath = argv[1]; + userArgs = argv.slice(2); + break; + case 'electron': + // @ts-ignore: unknown property + if (process$1.defaultApp) { + this._scriptPath = argv[1]; + userArgs = argv.slice(2); + } else { + userArgs = argv.slice(1); + } + break; + case 'user': + userArgs = argv.slice(0); + break; + default: + throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`); + } + + // Find default name for program from arguments. + if (!this._name && this._scriptPath) this.nameFromFilename(this._scriptPath); + this._name = this._name || 'program'; + + return userArgs; + } + + /** + * Parse `argv`, setting options and invoking commands when defined. + * + * The default expectation is that the arguments are from node and have the application as argv[0] + * and the script being run in argv[1], with user parameters after that. + * + * @example + * program.parse(process.argv); + * program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions + * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0] + * + * @param {string[]} [argv] - optional, defaults to process.argv + * @param {Object} [parseOptions] - optionally specify style of options with from: node/user/electron + * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron' + * @return {Command} `this` command for chaining + */ + + parse(argv, parseOptions) { + const userArgs = this._prepareUserArgs(argv, parseOptions); + this._parseCommand([], userArgs); + + return this; + } + + /** + * Parse `argv`, setting options and invoking commands when defined. + * + * Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise. + * + * The default expectation is that the arguments are from node and have the application as argv[0] + * and the script being run in argv[1], with user parameters after that. + * + * @example + * await program.parseAsync(process.argv); + * await program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions + * await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0] + * + * @param {string[]} [argv] + * @param {Object} [parseOptions] + * @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron' + * @return {Promise} + */ + + async parseAsync(argv, parseOptions) { + const userArgs = this._prepareUserArgs(argv, parseOptions); + await this._parseCommand([], userArgs); + + return this; + } + + /** + * Execute a sub-command executable. + * + * @private + */ + + _executeSubCommand(subcommand, args) { + args = args.slice(); + let launchWithNode = false; // Use node for source targets so do not need to get permissions correct, and on Windows. + const sourceExt = ['.js', '.ts', '.tsx', '.mjs', '.cjs']; + + function findFile(baseDir, baseName) { + // Look for specified file + const localBin = path.resolve(baseDir, baseName); + if (fs.existsSync(localBin)) return localBin; + + // Stop looking if candidate already has an expected extension. + if (sourceExt.includes(path.extname(baseName))) return undefined; + + // Try all the extensions. + const foundExt = sourceExt.find(ext => fs.existsSync(`${localBin}${ext}`)); + if (foundExt) return `${localBin}${foundExt}`; + + return undefined; + } + + // Not checking for help first. Unlikely to have mandatory and executable, and can't robustly test for help flags in external command. + this._checkForMissingMandatoryOptions(); + this._checkForConflictingOptions(); + + // executableFile and executableDir might be full path, or just a name + let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`; + let executableDir = this._executableDir || ''; + if (this._scriptPath) { + let resolvedScriptPath; // resolve possible symlink for installed npm binary + try { + resolvedScriptPath = fs.realpathSync(this._scriptPath); + } catch (err) { + resolvedScriptPath = this._scriptPath; + } + executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir); + } + + // Look for a local file in preference to a command in PATH. + if (executableDir) { + let localFile = findFile(executableDir, executableFile); + + // Legacy search using prefix of script name instead of command name + if (!localFile && !subcommand._executableFile && this._scriptPath) { + const legacyName = path.basename(this._scriptPath, path.extname(this._scriptPath)); + if (legacyName !== this._name) { + localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`); + } + } + executableFile = localFile || executableFile; + } + + launchWithNode = sourceExt.includes(path.extname(executableFile)); + + let proc; + if (process$1.platform !== 'win32') { + if (launchWithNode) { + args.unshift(executableFile); + // add executable arguments to spawn + args = incrementNodeInspectorPort(process$1.execArgv).concat(args); + + proc = childProcess.spawn(process$1.argv[0], args, { stdio: 'inherit' }); + } else { + proc = childProcess.spawn(executableFile, args, { stdio: 'inherit' }); + } + } else { + args.unshift(executableFile); + // add executable arguments to spawn + args = incrementNodeInspectorPort(process$1.execArgv).concat(args); + proc = childProcess.spawn(process$1.execPath, args, { stdio: 'inherit' }); + } + + if (!proc.killed) { // testing mainly to avoid leak warnings during unit tests with mocked spawn + const signals = ['SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGINT', 'SIGHUP']; + signals.forEach((signal) => { + // @ts-ignore + process$1.on(signal, () => { + if (proc.killed === false && proc.exitCode === null) { + proc.kill(signal); + } + }); + }); + } + + // By default terminate process when spawned process terminates. + const exitCallback = this._exitCallback; + proc.on('close', (code, _signal) => { + code = code ?? 1; // code is null if spawned process terminated due to a signal + if (!exitCallback) { + process$1.exit(code); + } else { + exitCallback(new CommanderError$2(code, 'commander.executeSubCommandAsync', '(close)')); + } + }); + proc.on('error', (err) => { + // @ts-ignore + if (err.code === 'ENOENT') { + const executableDirMessage = executableDir + ? `searched for local subcommand relative to directory '${executableDir}'` + : 'no directory for search for local subcommand, use .executableDir() to supply a custom directory'; + const executableMissing = `'${executableFile}' does not exist + - if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead + - if the default executable name is not suitable, use the executableFile option to supply a custom name or path + - ${executableDirMessage}`; + throw new Error(executableMissing); + // @ts-ignore + } else if (err.code === 'EACCES') { + throw new Error(`'${executableFile}' not executable`); + } + if (!exitCallback) { + process$1.exit(1); + } else { + const wrappedError = new CommanderError$2(1, 'commander.executeSubCommandAsync', '(error)'); + wrappedError.nestedError = err; + exitCallback(wrappedError); + } + }); + + // Store the reference to the child process + this.runningCommand = proc; + } + + /** + * @private + */ + + _dispatchSubcommand(commandName, operands, unknown) { + const subCommand = this._findCommand(commandName); + if (!subCommand) this.help({ error: true }); + + let promiseChain; + promiseChain = this._chainOrCallSubCommandHook(promiseChain, subCommand, 'preSubcommand'); + promiseChain = this._chainOrCall(promiseChain, () => { + if (subCommand._executableHandler) { + this._executeSubCommand(subCommand, operands.concat(unknown)); + } else { + return subCommand._parseCommand(operands, unknown); + } + }); + return promiseChain; + } + + /** + * Invoke help directly if possible, or dispatch if necessary. + * e.g. help foo + * + * @private + */ + + _dispatchHelpCommand(subcommandName) { + if (!subcommandName) { + this.help(); + } + const subCommand = this._findCommand(subcommandName); + if (subCommand && !subCommand._executableHandler) { + subCommand.help(); + } + + // Fallback to parsing the help flag to invoke the help. + return this._dispatchSubcommand(subcommandName, [], [ + this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? '--help' + ]); + } + + /** + * Check this.args against expected this.registeredArguments. + * + * @private + */ + + _checkNumberOfArguments() { + // too few + this.registeredArguments.forEach((arg, i) => { + if (arg.required && this.args[i] == null) { + this.missingArgument(arg.name()); + } + }); + // too many + if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) { + return; + } + if (this.args.length > this.registeredArguments.length) { + this._excessArguments(this.args); + } + } + + /** + * Process this.args using this.registeredArguments and save as this.processedArgs! + * + * @private + */ + + _processArguments() { + const myParseArg = (argument, value, previous) => { + // Extra processing for nice error message on parsing failure. + let parsedValue = value; + if (value !== null && argument.parseArg) { + const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`; + parsedValue = this._callParseArg(argument, value, previous, invalidValueMessage); + } + return parsedValue; + }; + + this._checkNumberOfArguments(); + + const processedArgs = []; + this.registeredArguments.forEach((declaredArg, index) => { + let value = declaredArg.defaultValue; + if (declaredArg.variadic) { + // Collect together remaining arguments for passing together as an array. + if (index < this.args.length) { + value = this.args.slice(index); + if (declaredArg.parseArg) { + value = value.reduce((processed, v) => { + return myParseArg(declaredArg, v, processed); + }, declaredArg.defaultValue); + } + } else if (value === undefined) { + value = []; + } + } else if (index < this.args.length) { + value = this.args[index]; + if (declaredArg.parseArg) { + value = myParseArg(declaredArg, value, declaredArg.defaultValue); + } + } + processedArgs[index] = value; + }); + this.processedArgs = processedArgs; + } + + /** + * Once we have a promise we chain, but call synchronously until then. + * + * @param {(Promise|undefined)} promise + * @param {Function} fn + * @return {(Promise|undefined)} + * @private + */ + + _chainOrCall(promise, fn) { + // thenable + if (promise && promise.then && typeof promise.then === 'function') { + // already have a promise, chain callback + return promise.then(() => fn()); + } + // callback might return a promise + return fn(); + } + + /** + * + * @param {(Promise|undefined)} promise + * @param {string} event + * @return {(Promise|undefined)} + * @private + */ + + _chainOrCallHooks(promise, event) { + let result = promise; + const hooks = []; + this._getCommandAndAncestors() + .reverse() + .filter(cmd => cmd._lifeCycleHooks[event] !== undefined) + .forEach(hookedCommand => { + hookedCommand._lifeCycleHooks[event].forEach((callback) => { + hooks.push({ hookedCommand, callback }); + }); + }); + if (event === 'postAction') { + hooks.reverse(); + } + + hooks.forEach((hookDetail) => { + result = this._chainOrCall(result, () => { + return hookDetail.callback(hookDetail.hookedCommand, this); + }); + }); + return result; + } + + /** + * + * @param {(Promise|undefined)} promise + * @param {Command} subCommand + * @param {string} event + * @return {(Promise|undefined)} + * @private + */ + + _chainOrCallSubCommandHook(promise, subCommand, event) { + let result = promise; + if (this._lifeCycleHooks[event] !== undefined) { + this._lifeCycleHooks[event].forEach((hook) => { + result = this._chainOrCall(result, () => { + return hook(this, subCommand); + }); + }); + } + return result; + } + + /** + * Process arguments in context of this command. + * Returns action result, in case it is a promise. + * + * @private + */ + + _parseCommand(operands, unknown) { + const parsed = this.parseOptions(unknown); + this._parseOptionsEnv(); // after cli, so parseArg not called on both cli and env + this._parseOptionsImplied(); + operands = operands.concat(parsed.operands); + unknown = parsed.unknown; + this.args = operands.concat(unknown); + + if (operands && this._findCommand(operands[0])) { + return this._dispatchSubcommand(operands[0], operands.slice(1), unknown); + } + if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) { + return this._dispatchHelpCommand(operands[1]); + } + if (this._defaultCommandName) { + this._outputHelpIfRequested(unknown); // Run the help for default command from parent rather than passing to default command + return this._dispatchSubcommand(this._defaultCommandName, operands, unknown); + } + if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) { + // probably missing subcommand and no handler, user needs help (and exit) + this.help({ error: true }); + } + + this._outputHelpIfRequested(parsed.unknown); + this._checkForMissingMandatoryOptions(); + this._checkForConflictingOptions(); + + // We do not always call this check to avoid masking a "better" error, like unknown command. + const checkForUnknownOptions = () => { + if (parsed.unknown.length > 0) { + this.unknownOption(parsed.unknown[0]); + } + }; + + const commandEvent = `command:${this.name()}`; + if (this._actionHandler) { + checkForUnknownOptions(); + this._processArguments(); + + let promiseChain; + promiseChain = this._chainOrCallHooks(promiseChain, 'preAction'); + promiseChain = this._chainOrCall(promiseChain, () => this._actionHandler(this.processedArgs)); + if (this.parent) { + promiseChain = this._chainOrCall(promiseChain, () => { + this.parent.emit(commandEvent, operands, unknown); // legacy + }); + } + promiseChain = this._chainOrCallHooks(promiseChain, 'postAction'); + return promiseChain; + } + if (this.parent && this.parent.listenerCount(commandEvent)) { + checkForUnknownOptions(); + this._processArguments(); + this.parent.emit(commandEvent, operands, unknown); // legacy + } else if (operands.length) { + if (this._findCommand('*')) { // legacy default command + return this._dispatchSubcommand('*', operands, unknown); + } + if (this.listenerCount('command:*')) { + // skip option check, emit event for possible misspelling suggestion + this.emit('command:*', operands, unknown); + } else if (this.commands.length) { + this.unknownCommand(); + } else { + checkForUnknownOptions(); + this._processArguments(); + } + } else if (this.commands.length) { + checkForUnknownOptions(); + // This command has subcommands and nothing hooked up at this level, so display help (and exit). + this.help({ error: true }); + } else { + checkForUnknownOptions(); + this._processArguments(); + // fall through for caller to handle after calling .parse() + } + } + + /** + * Find matching command. + * + * @private + */ + _findCommand(name) { + if (!name) return undefined; + return this.commands.find(cmd => cmd._name === name || cmd._aliases.includes(name)); + } + + /** + * Return an option matching `arg` if any. + * + * @param {string} arg + * @return {Option} + * @package internal use only + */ + + _findOption(arg) { + return this.options.find(option => option.is(arg)); + } + + /** + * Display an error message if a mandatory option does not have a value. + * Called after checking for help flags in leaf subcommand. + * + * @private + */ + + _checkForMissingMandatoryOptions() { + // Walk up hierarchy so can call in subcommand after checking for displaying help. + this._getCommandAndAncestors().forEach((cmd) => { + cmd.options.forEach((anOption) => { + if (anOption.mandatory && (cmd.getOptionValue(anOption.attributeName()) === undefined)) { + cmd.missingMandatoryOptionValue(anOption); + } + }); + }); + } + + /** + * Display an error message if conflicting options are used together in this. + * + * @private + */ + _checkForConflictingLocalOptions() { + const definedNonDefaultOptions = this.options.filter( + (option) => { + const optionKey = option.attributeName(); + if (this.getOptionValue(optionKey) === undefined) { + return false; + } + return this.getOptionValueSource(optionKey) !== 'default'; + } + ); + + const optionsWithConflicting = definedNonDefaultOptions.filter( + (option) => option.conflictsWith.length > 0 + ); + + optionsWithConflicting.forEach((option) => { + const conflictingAndDefined = definedNonDefaultOptions.find((defined) => + option.conflictsWith.includes(defined.attributeName()) + ); + if (conflictingAndDefined) { + this._conflictingOption(option, conflictingAndDefined); + } + }); + } + + /** + * Display an error message if conflicting options are used together. + * Called after checking for help flags in leaf subcommand. + * + * @private + */ + _checkForConflictingOptions() { + // Walk up hierarchy so can call in subcommand after checking for displaying help. + this._getCommandAndAncestors().forEach((cmd) => { + cmd._checkForConflictingLocalOptions(); + }); + } + + /** + * Parse options from `argv` removing known options, + * and return argv split into operands and unknown arguments. + * + * Examples: + * + * argv => operands, unknown + * --known kkk op => [op], [] + * op --known kkk => [op], [] + * sub --unknown uuu op => [sub], [--unknown uuu op] + * sub -- --unknown uuu op => [sub --unknown uuu op], [] + * + * @param {string[]} argv + * @return {{operands: string[], unknown: string[]}} + */ + + parseOptions(argv) { + const operands = []; // operands, not options or values + const unknown = []; // first unknown option and remaining unknown args + let dest = operands; + const args = argv.slice(); + + function maybeOption(arg) { + return arg.length > 1 && arg[0] === '-'; + } + + // parse options + let activeVariadicOption = null; + while (args.length) { + const arg = args.shift(); + + // literal + if (arg === '--') { + if (dest === unknown) dest.push(arg); + dest.push(...args); + break; + } + + if (activeVariadicOption && !maybeOption(arg)) { + this.emit(`option:${activeVariadicOption.name()}`, arg); + continue; + } + activeVariadicOption = null; + + if (maybeOption(arg)) { + const option = this._findOption(arg); + // recognised option, call listener to assign value with possible custom processing + if (option) { + if (option.required) { + const value = args.shift(); + if (value === undefined) this.optionMissingArgument(option); + this.emit(`option:${option.name()}`, value); + } else if (option.optional) { + let value = null; + // historical behaviour is optional value is following arg unless an option + if (args.length > 0 && !maybeOption(args[0])) { + value = args.shift(); + } + this.emit(`option:${option.name()}`, value); + } else { // boolean flag + this.emit(`option:${option.name()}`); + } + activeVariadicOption = option.variadic ? option : null; + continue; + } + } + + // Look for combo options following single dash, eat first one if known. + if (arg.length > 2 && arg[0] === '-' && arg[1] !== '-') { + const option = this._findOption(`-${arg[1]}`); + if (option) { + if (option.required || (option.optional && this._combineFlagAndOptionalValue)) { + // option with value following in same argument + this.emit(`option:${option.name()}`, arg.slice(2)); + } else { + // boolean option, emit and put back remainder of arg for further processing + this.emit(`option:${option.name()}`); + args.unshift(`-${arg.slice(2)}`); + } + continue; + } + } + + // Look for known long flag with value, like --foo=bar + if (/^--[^=]+=/.test(arg)) { + const index = arg.indexOf('='); + const option = this._findOption(arg.slice(0, index)); + if (option && (option.required || option.optional)) { + this.emit(`option:${option.name()}`, arg.slice(index + 1)); + continue; + } + } + + // Not a recognised option by this command. + // Might be a command-argument, or subcommand option, or unknown option, or help command or option. + + // An unknown option means further arguments also classified as unknown so can be reprocessed by subcommands. + if (maybeOption(arg)) { + dest = unknown; + } + + // If using positionalOptions, stop processing our options at subcommand. + if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) { + if (this._findCommand(arg)) { + operands.push(arg); + if (args.length > 0) unknown.push(...args); + break; + } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) { + operands.push(arg); + if (args.length > 0) operands.push(...args); + break; + } else if (this._defaultCommandName) { + unknown.push(arg); + if (args.length > 0) unknown.push(...args); + break; + } + } + + // If using passThroughOptions, stop processing options at first command-argument. + if (this._passThroughOptions) { + dest.push(arg); + if (args.length > 0) dest.push(...args); + break; + } + + // add arg + dest.push(arg); + } + + return { operands, unknown }; + } + + /** + * Return an object containing local option values as key-value pairs. + * + * @return {Object} + */ + opts() { + if (this._storeOptionsAsProperties) { + // Preserve original behaviour so backwards compatible when still using properties + const result = {}; + const len = this.options.length; + + for (let i = 0; i < len; i++) { + const key = this.options[i].attributeName(); + result[key] = key === this._versionOptionName ? this._version : this[key]; + } + return result; + } + + return this._optionValues; + } + + /** + * Return an object containing merged local and global option values as key-value pairs. + * + * @return {Object} + */ + optsWithGlobals() { + // globals overwrite locals + return this._getCommandAndAncestors().reduce( + (combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()), + {} + ); + } + + /** + * Display error message and exit (or call exitOverride). + * + * @param {string} message + * @param {Object} [errorOptions] + * @param {string} [errorOptions.code] - an id string representing the error + * @param {number} [errorOptions.exitCode] - used with process.exit + */ + error(message, errorOptions) { + // output handling + this._outputConfiguration.outputError(`${message}\n`, this._outputConfiguration.writeErr); + if (typeof this._showHelpAfterError === 'string') { + this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`); + } else if (this._showHelpAfterError) { + this._outputConfiguration.writeErr('\n'); + this.outputHelp({ error: true }); + } + + // exit handling + const config = errorOptions || {}; + const exitCode = config.exitCode || 1; + const code = config.code || 'commander.error'; + this._exit(exitCode, code, message); + } + + /** + * Apply any option related environment variables, if option does + * not have a value from cli or client code. + * + * @private + */ + _parseOptionsEnv() { + this.options.forEach((option) => { + if (option.envVar && option.envVar in process$1.env) { + const optionKey = option.attributeName(); + // Priority check. Do not overwrite cli or options from unknown source (client-code). + if (this.getOptionValue(optionKey) === undefined || ['default', 'config', 'env'].includes(this.getOptionValueSource(optionKey))) { + if (option.required || option.optional) { // option can take a value + // keep very simple, optional always takes value + this.emit(`optionEnv:${option.name()}`, process$1.env[option.envVar]); + } else { // boolean + // keep very simple, only care that envVar defined and not the value + this.emit(`optionEnv:${option.name()}`); + } + } + } + }); + } + + /** + * Apply any implied option values, if option is undefined or default value. + * + * @private + */ + _parseOptionsImplied() { + const dualHelper = new DualOptions(this.options); + const hasCustomOptionValue = (optionKey) => { + return this.getOptionValue(optionKey) !== undefined && !['default', 'implied'].includes(this.getOptionValueSource(optionKey)); + }; + this.options + .filter(option => (option.implied !== undefined) && + hasCustomOptionValue(option.attributeName()) && + dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option)) + .forEach((option) => { + Object.keys(option.implied) + .filter(impliedKey => !hasCustomOptionValue(impliedKey)) + .forEach(impliedKey => { + this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], 'implied'); + }); + }); + } + + /** + * Argument `name` is missing. + * + * @param {string} name + * @private + */ + + missingArgument(name) { + const message = `error: missing required argument '${name}'`; + this.error(message, { code: 'commander.missingArgument' }); + } + + /** + * `Option` is missing an argument. + * + * @param {Option} option + * @private + */ + + optionMissingArgument(option) { + const message = `error: option '${option.flags}' argument missing`; + this.error(message, { code: 'commander.optionMissingArgument' }); + } + + /** + * `Option` does not have a value, and is a mandatory option. + * + * @param {Option} option + * @private + */ + + missingMandatoryOptionValue(option) { + const message = `error: required option '${option.flags}' not specified`; + this.error(message, { code: 'commander.missingMandatoryOptionValue' }); + } + + /** + * `Option` conflicts with another option. + * + * @param {Option} option + * @param {Option} conflictingOption + * @private + */ + _conflictingOption(option, conflictingOption) { + // The calling code does not know whether a negated option is the source of the + // value, so do some work to take an educated guess. + const findBestOptionFromValue = (option) => { + const optionKey = option.attributeName(); + const optionValue = this.getOptionValue(optionKey); + const negativeOption = this.options.find(target => target.negate && optionKey === target.attributeName()); + const positiveOption = this.options.find(target => !target.negate && optionKey === target.attributeName()); + if (negativeOption && ( + (negativeOption.presetArg === undefined && optionValue === false) || + (negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg) + )) { + return negativeOption; + } + return positiveOption || option; + }; + + const getErrorMessage = (option) => { + const bestOption = findBestOptionFromValue(option); + const optionKey = bestOption.attributeName(); + const source = this.getOptionValueSource(optionKey); + if (source === 'env') { + return `environment variable '${bestOption.envVar}'`; + } + return `option '${bestOption.flags}'`; + }; + + const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`; + this.error(message, { code: 'commander.conflictingOption' }); + } + + /** + * Unknown option `flag`. + * + * @param {string} flag + * @private + */ + + unknownOption(flag) { + if (this._allowUnknownOption) return; + let suggestion = ''; + + if (flag.startsWith('--') && this._showSuggestionAfterError) { + // Looping to pick up the global options too + let candidateFlags = []; + let command = this; + do { + const moreFlags = command.createHelp().visibleOptions(command) + .filter(option => option.long) + .map(option => option.long); + candidateFlags = candidateFlags.concat(moreFlags); + command = command.parent; + } while (command && !command._enablePositionalOptions); + suggestion = suggestSimilar(flag, candidateFlags); + } + + const message = `error: unknown option '${flag}'${suggestion}`; + this.error(message, { code: 'commander.unknownOption' }); + } + + /** + * Excess arguments, more than expected. + * + * @param {string[]} receivedArgs + * @private + */ + + _excessArguments(receivedArgs) { + if (this._allowExcessArguments) return; + + const expected = this.registeredArguments.length; + const s = (expected === 1) ? '' : 's'; + const forSubcommand = this.parent ? ` for '${this.name()}'` : ''; + const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`; + this.error(message, { code: 'commander.excessArguments' }); + } + + /** + * Unknown command. + * + * @private + */ + + unknownCommand() { + const unknownName = this.args[0]; + let suggestion = ''; + + if (this._showSuggestionAfterError) { + const candidateNames = []; + this.createHelp().visibleCommands(this).forEach((command) => { + candidateNames.push(command.name()); + // just visible alias + if (command.alias()) candidateNames.push(command.alias()); + }); + suggestion = suggestSimilar(unknownName, candidateNames); + } + + const message = `error: unknown command '${unknownName}'${suggestion}`; + this.error(message, { code: 'commander.unknownCommand' }); + } + + /** + * Get or set the program version. + * + * This method auto-registers the "-V, --version" option which will print the version number. + * + * You can optionally supply the flags and description to override the defaults. + * + * @param {string} [str] + * @param {string} [flags] + * @param {string} [description] + * @return {(this | string | undefined)} `this` command for chaining, or version string if no arguments + */ + + version(str, flags, description) { + if (str === undefined) return this._version; + this._version = str; + flags = flags || '-V, --version'; + description = description || 'output the version number'; + const versionOption = this.createOption(flags, description); + this._versionOptionName = versionOption.attributeName(); + this._registerOption(versionOption); + + this.on('option:' + versionOption.name(), () => { + this._outputConfiguration.writeOut(`${str}\n`); + this._exit(0, 'commander.version', str); + }); + return this; + } + + /** + * Set the description. + * + * @param {string} [str] + * @param {Object} [argsDescription] + * @return {(string|Command)} + */ + description(str, argsDescription) { + if (str === undefined && argsDescription === undefined) return this._description; + this._description = str; + if (argsDescription) { + this._argsDescription = argsDescription; + } + return this; + } + + /** + * Set the summary. Used when listed as subcommand of parent. + * + * @param {string} [str] + * @return {(string|Command)} + */ + summary(str) { + if (str === undefined) return this._summary; + this._summary = str; + return this; + } + + /** + * Set an alias for the command. + * + * You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help. + * + * @param {string} [alias] + * @return {(string|Command)} + */ + + alias(alias) { + if (alias === undefined) return this._aliases[0]; // just return first, for backwards compatibility + + /** @type {Command} */ + let command = this; + if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) { + // assume adding alias for last added executable subcommand, rather than this + command = this.commands[this.commands.length - 1]; + } + + if (alias === command._name) throw new Error('Command alias can\'t be the same as its name'); + const matchingCommand = this.parent?._findCommand(alias); + if (matchingCommand) { + // c.f. _registerCommand + const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join('|'); + throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`); + } + + command._aliases.push(alias); + return this; + } + + /** + * Set aliases for the command. + * + * Only the first alias is shown in the auto-generated help. + * + * @param {string[]} [aliases] + * @return {(string[]|Command)} + */ + + aliases(aliases) { + // Getter for the array of aliases is the main reason for having aliases() in addition to alias(). + if (aliases === undefined) return this._aliases; + + aliases.forEach((alias) => this.alias(alias)); + return this; + } + + /** + * Set / get the command usage `str`. + * + * @param {string} [str] + * @return {(string|Command)} + */ + + usage(str) { + if (str === undefined) { + if (this._usage) return this._usage; + + const args = this.registeredArguments.map((arg) => { + return humanReadableArgName(arg); + }); + return [].concat( + (this.options.length || (this._helpOption !== null) ? '[options]' : []), + (this.commands.length ? '[command]' : []), + (this.registeredArguments.length ? args : []) + ).join(' '); + } + + this._usage = str; + return this; + } + + /** + * Get or set the name of the command. + * + * @param {string} [str] + * @return {(string|Command)} + */ + + name(str) { + if (str === undefined) return this._name; + this._name = str; + return this; + } + + /** + * Set the name of the command from script filename, such as process.argv[1], + * or require.main.filename, or __filename. + * + * (Used internally and public although not documented in README.) + * + * @example + * program.nameFromFilename(require.main.filename); + * + * @param {string} filename + * @return {Command} + */ + + nameFromFilename(filename) { + this._name = path.basename(filename, path.extname(filename)); + + return this; + } + + /** + * Get or set the directory for searching for executable subcommands of this command. + * + * @example + * program.executableDir(__dirname); + * // or + * program.executableDir('subcommands'); + * + * @param {string} [path] + * @return {(string|null|Command)} + */ + + executableDir(path) { + if (path === undefined) return this._executableDir; + this._executableDir = path; + return this; + } + + /** + * Return program help documentation. + * + * @param {{ error: boolean }} [contextOptions] - pass {error:true} to wrap for stderr instead of stdout + * @return {string} + */ + + helpInformation(contextOptions) { + const helper = this.createHelp(); + if (helper.helpWidth === undefined) { + helper.helpWidth = (contextOptions && contextOptions.error) ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth(); + } + return helper.formatHelp(this, helper); + } + + /** + * @private + */ + + _getHelpContext(contextOptions) { + contextOptions = contextOptions || {}; + const context = { error: !!contextOptions.error }; + let write; + if (context.error) { + write = (arg) => this._outputConfiguration.writeErr(arg); + } else { + write = (arg) => this._outputConfiguration.writeOut(arg); + } + context.write = contextOptions.write || write; + context.command = this; + return context; + } + + /** + * Output help information for this command. + * + * Outputs built-in help, and custom text added using `.addHelpText()`. + * + * @param {{ error: boolean } | Function} [contextOptions] - pass {error:true} to write to stderr instead of stdout + */ + + outputHelp(contextOptions) { + let deprecatedCallback; + if (typeof contextOptions === 'function') { + deprecatedCallback = contextOptions; + contextOptions = undefined; + } + const context = this._getHelpContext(contextOptions); + + this._getCommandAndAncestors().reverse().forEach(command => command.emit('beforeAllHelp', context)); + this.emit('beforeHelp', context); + + let helpInformation = this.helpInformation(context); + if (deprecatedCallback) { + helpInformation = deprecatedCallback(helpInformation); + if (typeof helpInformation !== 'string' && !Buffer.isBuffer(helpInformation)) { + throw new Error('outputHelp callback must return a string or a Buffer'); + } + } + context.write(helpInformation); + + if (this._getHelpOption()?.long) { + this.emit(this._getHelpOption().long); // deprecated + } + this.emit('afterHelp', context); + this._getCommandAndAncestors().forEach(command => command.emit('afterAllHelp', context)); + } + + /** + * You can pass in flags and a description to customise the built-in help option. + * Pass in false to disable the built-in help option. + * + * @example + * program.helpOption('-?, --help' 'show help'); // customise + * program.helpOption(false); // disable + * + * @param {(string | boolean)} flags + * @param {string} [description] + * @return {Command} `this` command for chaining + */ + + helpOption(flags, description) { + // Support disabling built-in help option. + if (typeof flags === 'boolean') { + if (flags) { + this._helpOption = this._helpOption ?? undefined; // preserve existing option + } else { + this._helpOption = null; // disable + } + return this; + } + + // Customise flags and description. + flags = flags ?? '-h, --help'; + description = description ?? 'display help for command'; + this._helpOption = this.createOption(flags, description); + + return this; + } + + /** + * Lazy create help option. + * Returns null if has been disabled with .helpOption(false). + * + * @returns {(Option | null)} the help option + * @package internal use only + */ + _getHelpOption() { + // Lazy create help option on demand. + if (this._helpOption === undefined) { + this.helpOption(undefined, undefined); + } + return this._helpOption; + } + + /** + * Supply your own option to use for the built-in help option. + * This is an alternative to using helpOption() to customise the flags and description etc. + * + * @param {Option} option + * @return {Command} `this` command for chaining + */ + addHelpOption(option) { + this._helpOption = option; + return this; + } + + /** + * Output help information and exit. + * + * Outputs built-in help, and custom text added using `.addHelpText()`. + * + * @param {{ error: boolean }} [contextOptions] - pass {error:true} to write to stderr instead of stdout + */ + + help(contextOptions) { + this.outputHelp(contextOptions); + let exitCode = process$1.exitCode || 0; + if (exitCode === 0 && contextOptions && typeof contextOptions !== 'function' && contextOptions.error) { + exitCode = 1; + } + // message: do not have all displayed text available so only passing placeholder. + this._exit(exitCode, 'commander.help', '(outputHelp)'); + } + + /** + * Add additional text to be displayed with the built-in help. + * + * Position is 'before' or 'after' to affect just this command, + * and 'beforeAll' or 'afterAll' to affect this command and all its subcommands. + * + * @param {string} position - before or after built-in help + * @param {(string | Function)} text - string to add, or a function returning a string + * @return {Command} `this` command for chaining + */ + addHelpText(position, text) { + const allowedValues = ['beforeAll', 'before', 'after', 'afterAll']; + if (!allowedValues.includes(position)) { + throw new Error(`Unexpected value for position to addHelpText. +Expecting one of '${allowedValues.join("', '")}'`); + } + const helpEvent = `${position}Help`; + this.on(helpEvent, (context) => { + let helpStr; + if (typeof text === 'function') { + helpStr = text({ error: context.error, command: context.command }); + } else { + helpStr = text; + } + // Ignore falsy value when nothing to output. + if (helpStr) { + context.write(`${helpStr}\n`); + } + }); + return this; + } + + /** + * Output help information if help flags specified + * + * @param {Array} args - array of options to search for help flags + * @private + */ + + _outputHelpIfRequested(args) { + const helpOption = this._getHelpOption(); + const helpRequested = helpOption && args.find(arg => helpOption.is(arg)); + if (helpRequested) { + this.outputHelp(); + // (Do not have all displayed text available so only passing placeholder.) + this._exit(0, 'commander.helpDisplayed', '(outputHelp)'); + } + } +}; + +/** + * Scan arguments and increment port number for inspect calls (to avoid conflicts when spawning new command). + * + * @param {string[]} args - array of arguments from node.execArgv + * @returns {string[]} + * @private + */ + +function incrementNodeInspectorPort(args) { + // Testing for these options: + // --inspect[=[host:]port] + // --inspect-brk[=[host:]port] + // --inspect-port=[host:]port + return args.map((arg) => { + if (!arg.startsWith('--inspect')) { + return arg; + } + let debugOption; + let debugHost = '127.0.0.1'; + let debugPort = '9229'; + let match; + if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) { + // e.g. --inspect + debugOption = match[1]; + } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) { + debugOption = match[1]; + if (/^\d+$/.test(match[3])) { + // e.g. --inspect=1234 + debugPort = match[3]; + } else { + // e.g. --inspect=localhost + debugHost = match[3]; + } + } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) { + // e.g. --inspect=localhost:1234 + debugOption = match[1]; + debugHost = match[3]; + debugPort = match[4]; + } + + if (debugOption && debugPort !== '0') { + return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`; + } + return arg; + }); +} + +command.Command = Command$2; + +const { Argument: Argument$1 } = argument; +const { Command: Command$1 } = command; +const { CommanderError: CommanderError$1, InvalidArgumentError: InvalidArgumentError$1 } = error$k; +const { Help: Help$1 } = help; +const { Option: Option$1 } = option; + +commander.program = new Command$1(); + +commander.createCommand = (name) => new Command$1(name); +commander.createOption = (flags, description) => new Option$1(flags, description); +commander.createArgument = (name, description) => new Argument$1(name, description); + +/** + * Expose classes + */ + +commander.Command = Command$1; +commander.Option = Option$1; +commander.Argument = Argument$1; +commander.Help = Help$1; + +commander.CommanderError = CommanderError$1; +commander.InvalidArgumentError = InvalidArgumentError$1; +commander.InvalidOptionArgumentError = InvalidArgumentError$1; // Deprecated + +// wrapper to provide named exports for ESM. +const { + program, + createCommand, + createArgument, + createOption, + CommanderError, + InvalidArgumentError, + InvalidOptionArgumentError, // deprecated old name + Command, + Argument, + Option, + Help +} = commander; + +let messages = []; +let level = 0; + +const debug$7 = (msg, min) => { + if (level >= min) { + messages.push(msg); + } +}; + +debug$7.WARN = 1; +debug$7.INFO = 2; +debug$7.DEBUG = 3; + +debug$7.reset = () => { + messages = []; +}; + +debug$7.setDebugLevel = (v) => { + level = v; +}; + +debug$7.warn = (msg) => debug$7(msg, debug$7.WARN); +debug$7.info = (msg) => debug$7(msg, debug$7.INFO); +debug$7.debug = (msg) => debug$7(msg, debug$7.DEBUG); + +debug$7.debugMessages = () => messages; + +var debug_1$4 = debug$7; + +var stringWidth$2 = {exports: {}}; + +var ansiRegex$1 = ({onlyFirst = false} = {}) => { + const pattern = [ + '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', + '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))' + ].join('|'); + + return new RegExp(pattern, onlyFirst ? undefined : 'g'); +}; + +const ansiRegex = ansiRegex$1; + +var stripAnsi$1 = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string; + +var isFullwidthCodePoint$2 = {exports: {}}; + +/* eslint-disable yoda */ + +const isFullwidthCodePoint$1 = codePoint => { + if (Number.isNaN(codePoint)) { + return false; + } + + // Code points are derived from: + // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt + if ( + codePoint >= 0x1100 && ( + codePoint <= 0x115F || // Hangul Jamo + codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET + codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET + // CJK Radicals Supplement .. Enclosed CJK Letters and Months + (0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F) || + // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A + (0x3250 <= codePoint && codePoint <= 0x4DBF) || + // CJK Unified Ideographs .. Yi Radicals + (0x4E00 <= codePoint && codePoint <= 0xA4C6) || + // Hangul Jamo Extended-A + (0xA960 <= codePoint && codePoint <= 0xA97C) || + // Hangul Syllables + (0xAC00 <= codePoint && codePoint <= 0xD7A3) || + // CJK Compatibility Ideographs + (0xF900 <= codePoint && codePoint <= 0xFAFF) || + // Vertical Forms + (0xFE10 <= codePoint && codePoint <= 0xFE19) || + // CJK Compatibility Forms .. Small Form Variants + (0xFE30 <= codePoint && codePoint <= 0xFE6B) || + // Halfwidth and Fullwidth Forms + (0xFF01 <= codePoint && codePoint <= 0xFF60) || + (0xFFE0 <= codePoint && codePoint <= 0xFFE6) || + // Kana Supplement + (0x1B000 <= codePoint && codePoint <= 0x1B001) || + // Enclosed Ideographic Supplement + (0x1F200 <= codePoint && codePoint <= 0x1F251) || + // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane + (0x20000 <= codePoint && codePoint <= 0x3FFFD) + ) + ) { + return true; + } + + return false; +}; + +isFullwidthCodePoint$2.exports = isFullwidthCodePoint$1; +isFullwidthCodePoint$2.exports.default = isFullwidthCodePoint$1; + +var isFullwidthCodePointExports = isFullwidthCodePoint$2.exports; + +var emojiRegex$1 = function () { + // https://mths.be/emoji + return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g; +}; + +const stripAnsi = stripAnsi$1; +const isFullwidthCodePoint = isFullwidthCodePointExports; +const emojiRegex = emojiRegex$1; + +const stringWidth$1 = string => { + if (typeof string !== 'string' || string.length === 0) { + return 0; + } + + string = stripAnsi(string); + + if (string.length === 0) { + return 0; + } + + string = string.replace(emojiRegex(), ' '); + + let width = 0; + + for (let i = 0; i < string.length; i++) { + const code = string.codePointAt(i); + + // Ignore control characters + if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) { + continue; + } + + // Ignore combining characters + if (code >= 0x300 && code <= 0x36F) { + continue; + } + + // Surrogates + if (code > 0xFFFF) { + i++; + } + + width += isFullwidthCodePoint(code) ? 2 : 1; + } + + return width; +}; + +stringWidth$2.exports = stringWidth$1; +// TODO: remove this in the next major version +stringWidth$2.exports.default = stringWidth$1; + +var stringWidthExports = stringWidth$2.exports; + +const stringWidth = stringWidthExports; + +function codeRegex(capture) { + return capture ? /\u001b\[((?:\d*;){0,5}\d*)m/g : /\u001b\[(?:\d*;){0,5}\d*m/g; +} + +function strlen(str) { + let code = codeRegex(); + let stripped = ('' + str).replace(code, ''); + let split = stripped.split('\n'); + return split.reduce(function (memo, s) { + return stringWidth(s) > memo ? stringWidth(s) : memo; + }, 0); +} + +function repeat(str, times) { + return Array(times + 1).join(str); +} + +function pad(str, len, pad, dir) { + let length = strlen(str); + if (len + 1 >= length) { + let padlen = len - length; + switch (dir) { + case 'right': { + str = repeat(pad, padlen) + str; + break; + } + case 'center': { + let right = Math.ceil(padlen / 2); + let left = padlen - right; + str = repeat(pad, left) + str + repeat(pad, right); + break; + } + default: { + str = str + repeat(pad, padlen); + break; + } + } + } + return str; +} + +let codeCache = {}; + +function addToCodeCache(name, on, off) { + on = '\u001b[' + on + 'm'; + off = '\u001b[' + off + 'm'; + codeCache[on] = { set: name, to: true }; + codeCache[off] = { set: name, to: false }; + codeCache[name] = { on: on, off: off }; +} + +//https://github.com/Marak/colors.js/blob/master/lib/styles.js +addToCodeCache('bold', 1, 22); +addToCodeCache('italics', 3, 23); +addToCodeCache('underline', 4, 24); +addToCodeCache('inverse', 7, 27); +addToCodeCache('strikethrough', 9, 29); + +function updateState(state, controlChars) { + let controlCode = controlChars[1] ? parseInt(controlChars[1].split(';')[0]) : 0; + if ((controlCode >= 30 && controlCode <= 39) || (controlCode >= 90 && controlCode <= 97)) { + state.lastForegroundAdded = controlChars[0]; + return; + } + if ((controlCode >= 40 && controlCode <= 49) || (controlCode >= 100 && controlCode <= 107)) { + state.lastBackgroundAdded = controlChars[0]; + return; + } + if (controlCode === 0) { + for (let i in state) { + /* istanbul ignore else */ + if (Object.prototype.hasOwnProperty.call(state, i)) { + delete state[i]; + } + } + return; + } + let info = codeCache[controlChars[0]]; + if (info) { + state[info.set] = info.to; + } +} + +function readState(line) { + let code = codeRegex(true); + let controlChars = code.exec(line); + let state = {}; + while (controlChars !== null) { + updateState(state, controlChars); + controlChars = code.exec(line); + } + return state; +} + +function unwindState(state, ret) { + let lastBackgroundAdded = state.lastBackgroundAdded; + let lastForegroundAdded = state.lastForegroundAdded; + + delete state.lastBackgroundAdded; + delete state.lastForegroundAdded; + + Object.keys(state).forEach(function (key) { + if (state[key]) { + ret += codeCache[key].off; + } + }); + + if (lastBackgroundAdded && lastBackgroundAdded != '\u001b[49m') { + ret += '\u001b[49m'; + } + if (lastForegroundAdded && lastForegroundAdded != '\u001b[39m') { + ret += '\u001b[39m'; + } + + return ret; +} + +function rewindState(state, ret) { + let lastBackgroundAdded = state.lastBackgroundAdded; + let lastForegroundAdded = state.lastForegroundAdded; + + delete state.lastBackgroundAdded; + delete state.lastForegroundAdded; + + Object.keys(state).forEach(function (key) { + if (state[key]) { + ret = codeCache[key].on + ret; + } + }); + + if (lastBackgroundAdded && lastBackgroundAdded != '\u001b[49m') { + ret = lastBackgroundAdded + ret; + } + if (lastForegroundAdded && lastForegroundAdded != '\u001b[39m') { + ret = lastForegroundAdded + ret; + } + + return ret; +} + +function truncateWidth(str, desiredLength) { + if (str.length === strlen(str)) { + return str.substr(0, desiredLength); + } + + while (strlen(str) > desiredLength) { + str = str.slice(0, -1); + } + + return str; +} + +function truncateWidthWithAnsi(str, desiredLength) { + let code = codeRegex(true); + let split = str.split(codeRegex()); + let splitIndex = 0; + let retLen = 0; + let ret = ''; + let myArray; + let state = {}; + + while (retLen < desiredLength) { + myArray = code.exec(str); + let toAdd = split[splitIndex]; + splitIndex++; + if (retLen + strlen(toAdd) > desiredLength) { + toAdd = truncateWidth(toAdd, desiredLength - retLen); + } + ret += toAdd; + retLen += strlen(toAdd); + + if (retLen < desiredLength) { + if (!myArray) { + break; + } // full-width chars may cause a whitespace which cannot be filled + ret += myArray[0]; + updateState(state, myArray); + } + } + + return unwindState(state, ret); +} + +function truncate(str, desiredLength, truncateChar) { + truncateChar = truncateChar || '…'; + let lengthOfStr = strlen(str); + if (lengthOfStr <= desiredLength) { + return str; + } + desiredLength -= strlen(truncateChar); + + let ret = truncateWidthWithAnsi(str, desiredLength); + + return ret + truncateChar; +} + +function defaultOptions$2() { + return { + chars: { + top: '─', + 'top-mid': '┬', + 'top-left': '┌', + 'top-right': '┐', + bottom: '─', + 'bottom-mid': '┴', + 'bottom-left': '└', + 'bottom-right': '┘', + left: '│', + 'left-mid': '├', + mid: '─', + 'mid-mid': '┼', + right: '│', + 'right-mid': '┤', + middle: '│', + }, + truncate: '…', + colWidths: [], + rowHeights: [], + colAligns: [], + rowAligns: [], + style: { + 'padding-left': 1, + 'padding-right': 1, + head: ['red'], + border: ['grey'], + compact: false, + }, + head: [], + }; +} + +function mergeOptions(options, defaults) { + options = options || {}; + defaults = defaults || defaultOptions$2(); + let ret = Object.assign({}, defaults, options); + ret.chars = Object.assign({}, defaults.chars, options.chars); + ret.style = Object.assign({}, defaults.style, options.style); + return ret; +} + +// Wrap on word boundary +function wordWrap(maxLength, input) { + let lines = []; + let split = input.split(/(\s+)/g); + let line = []; + let lineLength = 0; + let whitespace; + for (let i = 0; i < split.length; i += 2) { + let word = split[i]; + let newLength = lineLength + strlen(word); + if (lineLength > 0 && whitespace) { + newLength += whitespace.length; + } + if (newLength > maxLength) { + if (lineLength !== 0) { + lines.push(line.join('')); + } + line = [word]; + lineLength = strlen(word); + } else { + line.push(whitespace || '', word); + lineLength = newLength; + } + whitespace = split[i + 1]; + } + if (lineLength) { + lines.push(line.join('')); + } + return lines; +} + +// Wrap text (ignoring word boundaries) +function textWrap(maxLength, input) { + let lines = []; + let line = ''; + function pushLine(str, ws) { + if (line.length && ws) line += ws; + line += str; + while (line.length > maxLength) { + lines.push(line.slice(0, maxLength)); + line = line.slice(maxLength); + } + } + let split = input.split(/(\s+)/g); + for (let i = 0; i < split.length; i += 2) { + pushLine(split[i], i && split[i - 1]); + } + if (line.length) lines.push(line); + return lines; +} + +function multiLineWordWrap(maxLength, input, wrapOnWordBoundary = true) { + let output = []; + input = input.split('\n'); + const handler = wrapOnWordBoundary ? wordWrap : textWrap; + for (let i = 0; i < input.length; i++) { + output.push.apply(output, handler(maxLength, input[i])); + } + return output; +} + +function colorizeLines(input) { + let state = {}; + let output = []; + for (let i = 0; i < input.length; i++) { + let line = rewindState(state, input[i]); + state = readState(line); + let temp = Object.assign({}, state); + output.push(unwindState(temp, line)); + } + return output; +} + +/** + * Credit: Matheus Sampaio https://github.com/matheussampaio + */ +function hyperlink(url, text) { + const OSC = '\u001B]'; + const BEL = '\u0007'; + const SEP = ';'; + + return [OSC, '8', SEP, SEP, url || text, BEL, text, OSC, '8', SEP, SEP, BEL].join(''); +} + +var utils$i = { + strlen: strlen, + repeat: repeat, + pad: pad, + truncate: truncate, + mergeOptions: mergeOptions, + wordWrap: multiLineWordWrap, + colorizeLines: colorizeLines, + hyperlink, +}; + +var layoutManager = {exports: {}}; + +var cell = {exports: {}}; + +var safe = {exports: {}}; + +var colors$1 = {exports: {}}; + +var styles = {exports: {}}; + +/* +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +*/ + +(function (module) { + var styles = {}; + module['exports'] = styles; + + var codes = { + reset: [0, 0], + + bold: [1, 22], + dim: [2, 22], + italic: [3, 23], + underline: [4, 24], + inverse: [7, 27], + hidden: [8, 28], + strikethrough: [9, 29], + + black: [30, 39], + red: [31, 39], + green: [32, 39], + yellow: [33, 39], + blue: [34, 39], + magenta: [35, 39], + cyan: [36, 39], + white: [37, 39], + gray: [90, 39], + grey: [90, 39], + + brightRed: [91, 39], + brightGreen: [92, 39], + brightYellow: [93, 39], + brightBlue: [94, 39], + brightMagenta: [95, 39], + brightCyan: [96, 39], + brightWhite: [97, 39], + + bgBlack: [40, 49], + bgRed: [41, 49], + bgGreen: [42, 49], + bgYellow: [43, 49], + bgBlue: [44, 49], + bgMagenta: [45, 49], + bgCyan: [46, 49], + bgWhite: [47, 49], + bgGray: [100, 49], + bgGrey: [100, 49], + + bgBrightRed: [101, 49], + bgBrightGreen: [102, 49], + bgBrightYellow: [103, 49], + bgBrightBlue: [104, 49], + bgBrightMagenta: [105, 49], + bgBrightCyan: [106, 49], + bgBrightWhite: [107, 49], + + // legacy styles for colors pre v1.0.0 + blackBG: [40, 49], + redBG: [41, 49], + greenBG: [42, 49], + yellowBG: [43, 49], + blueBG: [44, 49], + magentaBG: [45, 49], + cyanBG: [46, 49], + whiteBG: [47, 49], + + }; + + Object.keys(codes).forEach(function(key) { + var val = codes[key]; + var style = styles[key] = []; + style.open = '\u001b[' + val[0] + 'm'; + style.close = '\u001b[' + val[1] + 'm'; + }); +} (styles)); + +var stylesExports = styles.exports; + +/* +MIT License + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +var hasFlag$2 = function(flag, argv) { + argv = argv || process.argv; + + var terminatorPos = argv.indexOf('--'); + var prefix = /^-{1,2}/.test(flag) ? '' : '--'; + var pos = argv.indexOf(prefix + flag); + + return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos); +}; + +/* +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +*/ + +var os = require$$0$2; +var hasFlag$1 = hasFlag$2; + +var env = process.env; + +var forceColor = void 0; +if (hasFlag$1('no-color') || hasFlag$1('no-colors') || hasFlag$1('color=false')) { + forceColor = false; +} else if (hasFlag$1('color') || hasFlag$1('colors') || hasFlag$1('color=true') + || hasFlag$1('color=always')) { + forceColor = true; +} +if ('FORCE_COLOR' in env) { + forceColor = env.FORCE_COLOR.length === 0 + || parseInt(env.FORCE_COLOR, 10) !== 0; +} + +function translateLevel(level) { + if (level === 0) { + return false; + } + + return { + level: level, + hasBasic: true, + has256: level >= 2, + has16m: level >= 3, + }; +} + +function supportsColor(stream) { + if (forceColor === false) { + return 0; + } + + if (hasFlag$1('color=16m') || hasFlag$1('color=full') + || hasFlag$1('color=truecolor')) { + return 3; + } + + if (hasFlag$1('color=256')) { + return 2; + } + + if (stream && !stream.isTTY && forceColor !== true) { + return 0; + } + + var min = forceColor ? 1 : 0; + + if (process.platform === 'win32') { + // Node.js 7.5.0 is the first version of Node.js to include a patch to + // libuv that enables 256 color output on Windows. Anything earlier and it + // won't work. However, here we target Node.js 8 at minimum as it is an LTS + // release, and Node.js 7 is not. Windows 10 build 10586 is the first + // Windows release that supports 256 colors. Windows 10 build 14931 is the + // first release that supports 16m/TrueColor. + var osRelease = os.release().split('.'); + if (Number(process.versions.node.split('.')[0]) >= 8 + && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) { + return Number(osRelease[2]) >= 14931 ? 3 : 2; + } + + return 1; + } + + if ('CI' in env) { + if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function(sign) { + return sign in env; + }) || env.CI_NAME === 'codeship') { + return 1; + } + + return min; + } + + if ('TEAMCITY_VERSION' in env) { + return (/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0 + ); + } + + if ('TERM_PROGRAM' in env) { + var version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); + + switch (env.TERM_PROGRAM) { + case 'iTerm.app': + return version >= 3 ? 3 : 2; + case 'Hyper': + return 3; + case 'Apple_Terminal': + return 2; + // No default + } + } + + if (/-256(color)?$/i.test(env.TERM)) { + return 2; + } + + if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { + return 1; + } + + if ('COLORTERM' in env) { + return 1; + } + + if (env.TERM === 'dumb') { + return min; + } + + return min; +} + +function getSupportLevel(stream) { + var level = supportsColor(stream); + return translateLevel(level); +} + +var supportsColors = { + supportsColor: getSupportLevel, + stdout: getSupportLevel(process.stdout), + stderr: getSupportLevel(process.stderr), +}; + +var trap = {exports: {}}; + +var hasRequiredTrap; + +function requireTrap () { + if (hasRequiredTrap) return trap.exports; + hasRequiredTrap = 1; + (function (module) { + module['exports'] = function runTheTrap(text, options) { + var result = ''; + text = text || 'Run the trap, drop the bass'; + text = text.split(''); + var trap = { + a: ['\u0040', '\u0104', '\u023a', '\u0245', '\u0394', '\u039b', '\u0414'], + b: ['\u00df', '\u0181', '\u0243', '\u026e', '\u03b2', '\u0e3f'], + c: ['\u00a9', '\u023b', '\u03fe'], + d: ['\u00d0', '\u018a', '\u0500', '\u0501', '\u0502', '\u0503'], + e: ['\u00cb', '\u0115', '\u018e', '\u0258', '\u03a3', '\u03be', '\u04bc', + '\u0a6c'], + f: ['\u04fa'], + g: ['\u0262'], + h: ['\u0126', '\u0195', '\u04a2', '\u04ba', '\u04c7', '\u050a'], + i: ['\u0f0f'], + j: ['\u0134'], + k: ['\u0138', '\u04a0', '\u04c3', '\u051e'], + l: ['\u0139'], + m: ['\u028d', '\u04cd', '\u04ce', '\u0520', '\u0521', '\u0d69'], + n: ['\u00d1', '\u014b', '\u019d', '\u0376', '\u03a0', '\u048a'], + o: ['\u00d8', '\u00f5', '\u00f8', '\u01fe', '\u0298', '\u047a', '\u05dd', + '\u06dd', '\u0e4f'], + p: ['\u01f7', '\u048e'], + q: ['\u09cd'], + r: ['\u00ae', '\u01a6', '\u0210', '\u024c', '\u0280', '\u042f'], + s: ['\u00a7', '\u03de', '\u03df', '\u03e8'], + t: ['\u0141', '\u0166', '\u0373'], + u: ['\u01b1', '\u054d'], + v: ['\u05d8'], + w: ['\u0428', '\u0460', '\u047c', '\u0d70'], + x: ['\u04b2', '\u04fe', '\u04fc', '\u04fd'], + y: ['\u00a5', '\u04b0', '\u04cb'], + z: ['\u01b5', '\u0240'], + }; + text.forEach(function(c) { + c = c.toLowerCase(); + var chars = trap[c] || [' ']; + var rand = Math.floor(Math.random() * chars.length); + if (typeof trap[c] !== 'undefined') { + result += trap[c][rand]; + } else { + result += c; + } + }); + return result; + }; + } (trap)); + return trap.exports; +} + +var zalgo = {exports: {}}; + +var hasRequiredZalgo; + +function requireZalgo () { + if (hasRequiredZalgo) return zalgo.exports; + hasRequiredZalgo = 1; + (function (module) { + // please no + module['exports'] = function zalgo(text, options) { + text = text || ' he is here '; + var soul = { + 'up': [ + '̍', '̎', '̄', '̅', + '̿', '̑', '̆', '̐', + '͒', '͗', '͑', '̇', + '̈', '̊', '͂', '̓', + '̈', '͊', '͋', '͌', + '̃', '̂', '̌', '͐', + '̀', '́', '̋', '̏', + '̒', '̓', '̔', '̽', + '̉', 'ͣ', 'ͤ', 'ͥ', + 'ͦ', 'ͧ', 'ͨ', 'ͩ', + 'ͪ', 'ͫ', 'ͬ', 'ͭ', + 'ͮ', 'ͯ', '̾', '͛', + '͆', '̚', + ], + 'down': [ + '̖', '̗', '̘', '̙', + '̜', '̝', '̞', '̟', + '̠', '̤', '̥', '̦', + '̩', '̪', '̫', '̬', + '̭', '̮', '̯', '̰', + '̱', '̲', '̳', '̹', + '̺', '̻', '̼', 'ͅ', + '͇', '͈', '͉', '͍', + '͎', '͓', '͔', '͕', + '͖', '͙', '͚', '̣', + ], + 'mid': [ + '̕', '̛', '̀', '́', + '͘', '̡', '̢', '̧', + '̨', '̴', '̵', '̶', + '͜', '͝', '͞', + '͟', '͠', '͢', '̸', + '̷', '͡', ' ҉', + ], + }; + var all = [].concat(soul.up, soul.down, soul.mid); + + function randomNumber(range) { + var r = Math.floor(Math.random() * range); + return r; + } + + function isChar(character) { + var bool = false; + all.filter(function(i) { + bool = (i === character); + }); + return bool; + } + + + function heComes(text, options) { + var result = ''; + var counts; + var l; + options = options || {}; + options['up'] = + typeof options['up'] !== 'undefined' ? options['up'] : true; + options['mid'] = + typeof options['mid'] !== 'undefined' ? options['mid'] : true; + options['down'] = + typeof options['down'] !== 'undefined' ? options['down'] : true; + options['size'] = + typeof options['size'] !== 'undefined' ? options['size'] : 'maxi'; + text = text.split(''); + for (l in text) { + if (isChar(l)) { + continue; + } + result = result + text[l]; + counts = {'up': 0, 'down': 0, 'mid': 0}; + switch (options.size) { + case 'mini': + counts.up = randomNumber(8); + counts.mid = randomNumber(2); + counts.down = randomNumber(8); + break; + case 'maxi': + counts.up = randomNumber(16) + 3; + counts.mid = randomNumber(4) + 1; + counts.down = randomNumber(64) + 3; + break; + default: + counts.up = randomNumber(8) + 1; + counts.mid = randomNumber(6) / 2; + counts.down = randomNumber(8) + 1; + break; + } + + var arr = ['up', 'mid', 'down']; + for (var d in arr) { + var index = arr[d]; + for (var i = 0; i <= counts[index]; i++) { + if (options[index]) { + result = result + soul[index][randomNumber(soul[index].length)]; + } + } + } + } + return result; + } + // don't summon him + return heComes(text, options); + }; + } (zalgo)); + return zalgo.exports; +} + +var america = {exports: {}}; + +var hasRequiredAmerica; + +function requireAmerica () { + if (hasRequiredAmerica) return america.exports; + hasRequiredAmerica = 1; + (function (module) { + module['exports'] = function(colors) { + return function(letter, i, exploded) { + if (letter === ' ') return letter; + switch (i%3) { + case 0: return colors.red(letter); + case 1: return colors.white(letter); + case 2: return colors.blue(letter); + } + }; + }; + } (america)); + return america.exports; +} + +var zebra = {exports: {}}; + +var hasRequiredZebra; + +function requireZebra () { + if (hasRequiredZebra) return zebra.exports; + hasRequiredZebra = 1; + (function (module) { + module['exports'] = function(colors) { + return function(letter, i, exploded) { + return i % 2 === 0 ? letter : colors.inverse(letter); + }; + }; + } (zebra)); + return zebra.exports; +} + +var rainbow = {exports: {}}; + +var hasRequiredRainbow; + +function requireRainbow () { + if (hasRequiredRainbow) return rainbow.exports; + hasRequiredRainbow = 1; + (function (module) { + module['exports'] = function(colors) { + // RoY G BiV + var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta']; + return function(letter, i, exploded) { + if (letter === ' ') { + return letter; + } else { + return colors[rainbowColors[i++ % rainbowColors.length]](letter); + } + }; + }; + } (rainbow)); + return rainbow.exports; +} + +var random = {exports: {}}; + +var hasRequiredRandom; + +function requireRandom () { + if (hasRequiredRandom) return random.exports; + hasRequiredRandom = 1; + (function (module) { + module['exports'] = function(colors) { + var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green', + 'blue', 'white', 'cyan', 'magenta', 'brightYellow', 'brightRed', + 'brightGreen', 'brightBlue', 'brightWhite', 'brightCyan', 'brightMagenta']; + return function(letter, i, exploded) { + return letter === ' ' ? letter : + colors[ + available[Math.round(Math.random() * (available.length - 2))] + ](letter); + }; + }; + } (random)); + return random.exports; +} + +/* + +The MIT License (MIT) + +Original Library + - Copyright (c) Marak Squires + +Additional functionality + - Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +*/ + +(function (module) { + var colors = {}; + module['exports'] = colors; + + colors.themes = {}; + + var util = require$$1$2; + var ansiStyles = colors.styles = stylesExports; + var defineProps = Object.defineProperties; + var newLineRegex = new RegExp(/[\r\n]+/g); + + colors.supportsColor = supportsColors.supportsColor; + + if (typeof colors.enabled === 'undefined') { + colors.enabled = colors.supportsColor() !== false; + } + + colors.enable = function() { + colors.enabled = true; + }; + + colors.disable = function() { + colors.enabled = false; + }; + + colors.stripColors = colors.strip = function(str) { + return ('' + str).replace(/\x1B\[\d+m/g, ''); + }; + + // eslint-disable-next-line no-unused-vars + colors.stylize = function stylize(str, style) { + if (!colors.enabled) { + return str+''; + } + + var styleMap = ansiStyles[style]; + + // Stylize should work for non-ANSI styles, too + if (!styleMap && style in colors) { + // Style maps like trap operate as functions on strings; + // they don't have properties like open or close. + return colors[style](str); + } + + return styleMap.open + str + styleMap.close; + }; + + var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; + var escapeStringRegexp = function(str) { + if (typeof str !== 'string') { + throw new TypeError('Expected a string'); + } + return str.replace(matchOperatorsRe, '\\$&'); + }; + + function build(_styles) { + var builder = function builder() { + return applyStyle.apply(builder, arguments); + }; + builder._styles = _styles; + // __proto__ is used because we must return a function, but there is + // no way to create a function with a different prototype. + builder.__proto__ = proto; + return builder; + } + + var styles = (function() { + var ret = {}; + ansiStyles.grey = ansiStyles.gray; + Object.keys(ansiStyles).forEach(function(key) { + ansiStyles[key].closeRe = + new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g'); + ret[key] = { + get: function() { + return build(this._styles.concat(key)); + }, + }; + }); + return ret; + })(); + + var proto = defineProps(function colors() {}, styles); + + function applyStyle() { + var args = Array.prototype.slice.call(arguments); + + var str = args.map(function(arg) { + // Use weak equality check so we can colorize null/undefined in safe mode + if (arg != null && arg.constructor === String) { + return arg; + } else { + return util.inspect(arg); + } + }).join(' '); + + if (!colors.enabled || !str) { + return str; + } + + var newLinesPresent = str.indexOf('\n') != -1; + + var nestedStyles = this._styles; + + var i = nestedStyles.length; + while (i--) { + var code = ansiStyles[nestedStyles[i]]; + str = code.open + str.replace(code.closeRe, code.open) + code.close; + if (newLinesPresent) { + str = str.replace(newLineRegex, function(match) { + return code.close + match + code.open; + }); + } + } + + return str; + } + + colors.setTheme = function(theme) { + if (typeof theme === 'string') { + console.log('colors.setTheme now only accepts an object, not a string. ' + + 'If you are trying to set a theme from a file, it is now your (the ' + + 'caller\'s) responsibility to require the file. The old syntax ' + + 'looked like colors.setTheme(__dirname + ' + + '\'/../themes/generic-logging.js\'); The new syntax looks like '+ + 'colors.setTheme(require(__dirname + ' + + '\'/../themes/generic-logging.js\'));'); + return; + } + for (var style in theme) { + (function(style) { + colors[style] = function(str) { + if (typeof theme[style] === 'object') { + var out = str; + for (var i in theme[style]) { + out = colors[theme[style][i]](out); + } + return out; + } + return colors[theme[style]](str); + }; + })(style); + } + }; + + function init() { + var ret = {}; + Object.keys(styles).forEach(function(name) { + ret[name] = { + get: function() { + return build([name]); + }, + }; + }); + return ret; + } + + var sequencer = function sequencer(map, str) { + var exploded = str.split(''); + exploded = exploded.map(map); + return exploded.join(''); + }; + + // custom formatter methods + colors.trap = requireTrap(); + colors.zalgo = requireZalgo(); + + // maps + colors.maps = {}; + colors.maps.america = requireAmerica()(colors); + colors.maps.zebra = requireZebra()(colors); + colors.maps.rainbow = requireRainbow()(colors); + colors.maps.random = requireRandom()(colors); + + for (var map in colors.maps) { + (function(map) { + colors[map] = function(str) { + return sequencer(colors.maps[map], str); + }; + })(map); + } + + defineProps(colors, init()); +} (colors$1)); + +var colorsExports = colors$1.exports; + +var hasRequiredSafe; + +function requireSafe () { + if (hasRequiredSafe) return safe.exports; + hasRequiredSafe = 1; + (function (module) { + // + // Remark: Requiring this file will use the "safe" colors API, + // which will not touch String.prototype. + // + // var colors = require('colors/safe'); + // colors.red("foo") + // + // + var colors = colorsExports; + module['exports'] = colors; + } (safe)); + return safe.exports; +} + +const { info, debug: debug$6 } = debug_1$4; +const utils$h = utils$i; + +let Cell$1 = class Cell { + /** + * A representation of a cell within the table. + * Implementations must have `init` and `draw` methods, + * as well as `colSpan`, `rowSpan`, `desiredHeight` and `desiredWidth` properties. + * @param options + * @constructor + */ + constructor(options) { + this.setOptions(options); + + /** + * Each cell will have it's `x` and `y` values set by the `layout-manager` prior to + * `init` being called; + * @type {Number} + */ + this.x = null; + this.y = null; + } + + setOptions(options) { + if (['boolean', 'number', 'string'].indexOf(typeof options) !== -1) { + options = { content: '' + options }; + } + options = options || {}; + this.options = options; + let content = options.content; + if (['boolean', 'number', 'string'].indexOf(typeof content) !== -1) { + this.content = String(content); + } else if (!content) { + this.content = this.options.href || ''; + } else { + throw new Error('Content needs to be a primitive, got: ' + typeof content); + } + this.colSpan = options.colSpan || 1; + this.rowSpan = options.rowSpan || 1; + if (this.options.href) { + Object.defineProperty(this, 'href', { + get() { + return this.options.href; + }, + }); + } + } + + mergeTableOptions(tableOptions, cells) { + this.cells = cells; + + let optionsChars = this.options.chars || {}; + let tableChars = tableOptions.chars; + let chars = (this.chars = {}); + CHAR_NAMES.forEach(function (name) { + setOption(optionsChars, tableChars, name, chars); + }); + + this.truncate = this.options.truncate || tableOptions.truncate; + + let style = (this.options.style = this.options.style || {}); + let tableStyle = tableOptions.style; + setOption(style, tableStyle, 'padding-left', this); + setOption(style, tableStyle, 'padding-right', this); + this.head = style.head || tableStyle.head; + this.border = style.border || tableStyle.border; + + this.fixedWidth = tableOptions.colWidths[this.x]; + this.lines = this.computeLines(tableOptions); + + this.desiredWidth = utils$h.strlen(this.content) + this.paddingLeft + this.paddingRight; + this.desiredHeight = this.lines.length; + } + + computeLines(tableOptions) { + const tableWordWrap = tableOptions.wordWrap || tableOptions.textWrap; + const { wordWrap = tableWordWrap } = this.options; + if (this.fixedWidth && wordWrap) { + this.fixedWidth -= this.paddingLeft + this.paddingRight; + if (this.colSpan) { + let i = 1; + while (i < this.colSpan) { + this.fixedWidth += tableOptions.colWidths[this.x + i]; + i++; + } + } + const { wrapOnWordBoundary: tableWrapOnWordBoundary = true } = tableOptions; + const { wrapOnWordBoundary = tableWrapOnWordBoundary } = this.options; + return this.wrapLines(utils$h.wordWrap(this.fixedWidth, this.content, wrapOnWordBoundary)); + } + return this.wrapLines(this.content.split('\n')); + } + + wrapLines(computedLines) { + const lines = utils$h.colorizeLines(computedLines); + if (this.href) { + return lines.map((line) => utils$h.hyperlink(this.href, line)); + } + return lines; + } + + /** + * Initializes the Cells data structure. + * + * @param tableOptions - A fully populated set of tableOptions. + * In addition to the standard default values, tableOptions must have fully populated the + * `colWidths` and `rowWidths` arrays. Those arrays must have lengths equal to the number + * of columns or rows (respectively) in this table, and each array item must be a Number. + * + */ + init(tableOptions) { + let x = this.x; + let y = this.y; + this.widths = tableOptions.colWidths.slice(x, x + this.colSpan); + this.heights = tableOptions.rowHeights.slice(y, y + this.rowSpan); + this.width = this.widths.reduce(sumPlusOne, -1); + this.height = this.heights.reduce(sumPlusOne, -1); + + this.hAlign = this.options.hAlign || tableOptions.colAligns[x]; + this.vAlign = this.options.vAlign || tableOptions.rowAligns[y]; + + this.drawRight = x + this.colSpan == tableOptions.colWidths.length; + } + + /** + * Draws the given line of the cell. + * This default implementation defers to methods `drawTop`, `drawBottom`, `drawLine` and `drawEmpty`. + * @param lineNum - can be `top`, `bottom` or a numerical line number. + * @param spanningCell - will be a number if being called from a RowSpanCell, and will represent how + * many rows below it's being called from. Otherwise it's undefined. + * @returns {String} The representation of this line. + */ + draw(lineNum, spanningCell) { + if (lineNum == 'top') return this.drawTop(this.drawRight); + if (lineNum == 'bottom') return this.drawBottom(this.drawRight); + let content = utils$h.truncate(this.content, 10, this.truncate); + if (!lineNum) { + info(`${this.y}-${this.x}: ${this.rowSpan - lineNum}x${this.colSpan} Cell ${content}`); + } + let padLen = Math.max(this.height - this.lines.length, 0); + let padTop; + switch (this.vAlign) { + case 'center': + padTop = Math.ceil(padLen / 2); + break; + case 'bottom': + padTop = padLen; + break; + default: + padTop = 0; + } + if (lineNum < padTop || lineNum >= padTop + this.lines.length) { + return this.drawEmpty(this.drawRight, spanningCell); + } + let forceTruncation = this.lines.length > this.height && lineNum + 1 >= this.height; + return this.drawLine(lineNum - padTop, this.drawRight, forceTruncation, spanningCell); + } + + /** + * Renders the top line of the cell. + * @param drawRight - true if this method should render the right edge of the cell. + * @returns {String} + */ + drawTop(drawRight) { + let content = []; + if (this.cells) { + //TODO: cells should always exist - some tests don't fill it in though + this.widths.forEach(function (width, index) { + content.push(this._topLeftChar(index)); + content.push(utils$h.repeat(this.chars[this.y == 0 ? 'top' : 'mid'], width)); + }, this); + } else { + content.push(this._topLeftChar(0)); + content.push(utils$h.repeat(this.chars[this.y == 0 ? 'top' : 'mid'], this.width)); + } + if (drawRight) { + content.push(this.chars[this.y == 0 ? 'topRight' : 'rightMid']); + } + return this.wrapWithStyleColors('border', content.join('')); + } + + _topLeftChar(offset) { + let x = this.x + offset; + let leftChar; + if (this.y == 0) { + leftChar = x == 0 ? 'topLeft' : offset == 0 ? 'topMid' : 'top'; + } else { + if (x == 0) { + leftChar = 'leftMid'; + } else { + leftChar = offset == 0 ? 'midMid' : 'bottomMid'; + if (this.cells) { + //TODO: cells should always exist - some tests don't fill it in though + let spanAbove = this.cells[this.y - 1][x] instanceof Cell.ColSpanCell; + if (spanAbove) { + leftChar = offset == 0 ? 'topMid' : 'mid'; + } + if (offset == 0) { + let i = 1; + while (this.cells[this.y][x - i] instanceof Cell.ColSpanCell) { + i++; + } + if (this.cells[this.y][x - i] instanceof Cell.RowSpanCell) { + leftChar = 'leftMid'; + } + } + } + } + } + return this.chars[leftChar]; + } + + wrapWithStyleColors(styleProperty, content) { + if (this[styleProperty] && this[styleProperty].length) { + try { + let colors = requireSafe(); + for (let i = this[styleProperty].length - 1; i >= 0; i--) { + colors = colors[this[styleProperty][i]]; + } + return colors(content); + } catch (e) { + return content; + } + } else { + return content; + } + } + + /** + * Renders a line of text. + * @param lineNum - Which line of text to render. This is not necessarily the line within the cell. + * There may be top-padding above the first line of text. + * @param drawRight - true if this method should render the right edge of the cell. + * @param forceTruncationSymbol - `true` if the rendered text should end with the truncation symbol even + * if the text fits. This is used when the cell is vertically truncated. If `false` the text should + * only include the truncation symbol if the text will not fit horizontally within the cell width. + * @param spanningCell - a number of if being called from a RowSpanCell. (how many rows below). otherwise undefined. + * @returns {String} + */ + drawLine(lineNum, drawRight, forceTruncationSymbol, spanningCell) { + let left = this.chars[this.x == 0 ? 'left' : 'middle']; + if (this.x && spanningCell && this.cells) { + let cellLeft = this.cells[this.y + spanningCell][this.x - 1]; + while (cellLeft instanceof ColSpanCell$1) { + cellLeft = this.cells[cellLeft.y][cellLeft.x - 1]; + } + if (!(cellLeft instanceof RowSpanCell$1)) { + left = this.chars['rightMid']; + } + } + let leftPadding = utils$h.repeat(' ', this.paddingLeft); + let right = drawRight ? this.chars['right'] : ''; + let rightPadding = utils$h.repeat(' ', this.paddingRight); + let line = this.lines[lineNum]; + let len = this.width - (this.paddingLeft + this.paddingRight); + if (forceTruncationSymbol) line += this.truncate || '…'; + let content = utils$h.truncate(line, len, this.truncate); + content = utils$h.pad(content, len, ' ', this.hAlign); + content = leftPadding + content + rightPadding; + return this.stylizeLine(left, content, right); + } + + stylizeLine(left, content, right) { + left = this.wrapWithStyleColors('border', left); + right = this.wrapWithStyleColors('border', right); + if (this.y === 0) { + content = this.wrapWithStyleColors('head', content); + } + return left + content + right; + } + + /** + * Renders the bottom line of the cell. + * @param drawRight - true if this method should render the right edge of the cell. + * @returns {String} + */ + drawBottom(drawRight) { + let left = this.chars[this.x == 0 ? 'bottomLeft' : 'bottomMid']; + let content = utils$h.repeat(this.chars.bottom, this.width); + let right = drawRight ? this.chars['bottomRight'] : ''; + return this.wrapWithStyleColors('border', left + content + right); + } + + /** + * Renders a blank line of text within the cell. Used for top and/or bottom padding. + * @param drawRight - true if this method should render the right edge of the cell. + * @param spanningCell - a number of if being called from a RowSpanCell. (how many rows below). otherwise undefined. + * @returns {String} + */ + drawEmpty(drawRight, spanningCell) { + let left = this.chars[this.x == 0 ? 'left' : 'middle']; + if (this.x && spanningCell && this.cells) { + let cellLeft = this.cells[this.y + spanningCell][this.x - 1]; + while (cellLeft instanceof ColSpanCell$1) { + cellLeft = this.cells[cellLeft.y][cellLeft.x - 1]; + } + if (!(cellLeft instanceof RowSpanCell$1)) { + left = this.chars['rightMid']; + } + } + let right = drawRight ? this.chars['right'] : ''; + let content = utils$h.repeat(' ', this.width); + return this.stylizeLine(left, content, right); + } +}; + +let ColSpanCell$1 = class ColSpanCell { + /** + * A Cell that doesn't do anything. It just draws empty lines. + * Used as a placeholder in column spanning. + * @constructor + */ + constructor() {} + + draw(lineNum) { + if (typeof lineNum === 'number') { + debug$6(`${this.y}-${this.x}: 1x1 ColSpanCell`); + } + return ''; + } + + init() {} + + mergeTableOptions() {} +}; + +let RowSpanCell$1 = class RowSpanCell { + /** + * A placeholder Cell for a Cell that spans multiple rows. + * It delegates rendering to the original cell, but adds the appropriate offset. + * @param originalCell + * @constructor + */ + constructor(originalCell) { + this.originalCell = originalCell; + } + + init(tableOptions) { + let y = this.y; + let originalY = this.originalCell.y; + this.cellOffset = y - originalY; + this.offset = findDimension(tableOptions.rowHeights, originalY, this.cellOffset); + } + + draw(lineNum) { + if (lineNum == 'top') { + return this.originalCell.draw(this.offset, this.cellOffset); + } + if (lineNum == 'bottom') { + return this.originalCell.draw('bottom'); + } + debug$6(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`); + return this.originalCell.draw(this.offset + 1 + lineNum); + } + + mergeTableOptions() {} +}; + +function firstDefined(...args) { + return args.filter((v) => v !== undefined && v !== null).shift(); +} + +// HELPER FUNCTIONS +function setOption(objA, objB, nameB, targetObj) { + let nameA = nameB.split('-'); + if (nameA.length > 1) { + nameA[1] = nameA[1].charAt(0).toUpperCase() + nameA[1].substr(1); + nameA = nameA.join(''); + targetObj[nameA] = firstDefined(objA[nameA], objA[nameB], objB[nameA], objB[nameB]); + } else { + targetObj[nameB] = firstDefined(objA[nameB], objB[nameB]); + } +} + +function findDimension(dimensionTable, startingIndex, span) { + let ret = dimensionTable[startingIndex]; + for (let i = 1; i < span; i++) { + ret += 1 + dimensionTable[startingIndex + i]; + } + return ret; +} + +function sumPlusOne(a, b) { + return a + b + 1; +} + +let CHAR_NAMES = [ + 'top', + 'top-mid', + 'top-left', + 'top-right', + 'bottom', + 'bottom-mid', + 'bottom-left', + 'bottom-right', + 'left', + 'left-mid', + 'mid', + 'mid-mid', + 'right', + 'right-mid', + 'middle', +]; + +cell.exports = Cell$1; +cell.exports.ColSpanCell = ColSpanCell$1; +cell.exports.RowSpanCell = RowSpanCell$1; + +var cellExports = cell.exports; + +const { warn, debug: debug$5 } = debug_1$4; +const Cell = cellExports; +const { ColSpanCell, RowSpanCell } = Cell; + +(function () { + function next(alloc, col) { + if (alloc[col] > 0) { + return next(alloc, col + 1); + } + return col; + } + + function layoutTable(table) { + let alloc = {}; + table.forEach(function (row, rowIndex) { + let col = 0; + row.forEach(function (cell) { + cell.y = rowIndex; + // Avoid erroneous call to next() on first row + cell.x = rowIndex ? next(alloc, col) : col; + const rowSpan = cell.rowSpan || 1; + const colSpan = cell.colSpan || 1; + if (rowSpan > 1) { + for (let cs = 0; cs < colSpan; cs++) { + alloc[cell.x + cs] = rowSpan; + } + } + col = cell.x + colSpan; + }); + Object.keys(alloc).forEach((idx) => { + alloc[idx]--; + if (alloc[idx] < 1) delete alloc[idx]; + }); + }); + } + + function maxWidth(table) { + let mw = 0; + table.forEach(function (row) { + row.forEach(function (cell) { + mw = Math.max(mw, cell.x + (cell.colSpan || 1)); + }); + }); + return mw; + } + + function maxHeight(table) { + return table.length; + } + + function cellsConflict(cell1, cell2) { + let yMin1 = cell1.y; + let yMax1 = cell1.y - 1 + (cell1.rowSpan || 1); + let yMin2 = cell2.y; + let yMax2 = cell2.y - 1 + (cell2.rowSpan || 1); + let yConflict = !(yMin1 > yMax2 || yMin2 > yMax1); + + let xMin1 = cell1.x; + let xMax1 = cell1.x - 1 + (cell1.colSpan || 1); + let xMin2 = cell2.x; + let xMax2 = cell2.x - 1 + (cell2.colSpan || 1); + let xConflict = !(xMin1 > xMax2 || xMin2 > xMax1); + + return yConflict && xConflict; + } + + function conflictExists(rows, x, y) { + let i_max = Math.min(rows.length - 1, y); + let cell = { x: x, y: y }; + for (let i = 0; i <= i_max; i++) { + let row = rows[i]; + for (let j = 0; j < row.length; j++) { + if (cellsConflict(cell, row[j])) { + return true; + } + } + } + return false; + } + + function allBlank(rows, y, xMin, xMax) { + for (let x = xMin; x < xMax; x++) { + if (conflictExists(rows, x, y)) { + return false; + } + } + return true; + } + + function addRowSpanCells(table) { + table.forEach(function (row, rowIndex) { + row.forEach(function (cell) { + for (let i = 1; i < cell.rowSpan; i++) { + let rowSpanCell = new RowSpanCell(cell); + rowSpanCell.x = cell.x; + rowSpanCell.y = cell.y + i; + rowSpanCell.colSpan = cell.colSpan; + insertCell(rowSpanCell, table[rowIndex + i]); + } + }); + }); + } + + function addColSpanCells(cellRows) { + for (let rowIndex = cellRows.length - 1; rowIndex >= 0; rowIndex--) { + let cellColumns = cellRows[rowIndex]; + for (let columnIndex = 0; columnIndex < cellColumns.length; columnIndex++) { + let cell = cellColumns[columnIndex]; + for (let k = 1; k < cell.colSpan; k++) { + let colSpanCell = new ColSpanCell(); + colSpanCell.x = cell.x + k; + colSpanCell.y = cell.y; + cellColumns.splice(columnIndex + 1, 0, colSpanCell); + } + } + } + } + + function insertCell(cell, row) { + let x = 0; + while (x < row.length && row[x].x < cell.x) { + x++; + } + row.splice(x, 0, cell); + } + + function fillInTable(table) { + let h_max = maxHeight(table); + let w_max = maxWidth(table); + debug$5(`Max rows: ${h_max}; Max cols: ${w_max}`); + for (let y = 0; y < h_max; y++) { + for (let x = 0; x < w_max; x++) { + if (!conflictExists(table, x, y)) { + let opts = { x: x, y: y, colSpan: 1, rowSpan: 1 }; + x++; + while (x < w_max && !conflictExists(table, x, y)) { + opts.colSpan++; + x++; + } + let y2 = y + 1; + while (y2 < h_max && allBlank(table, y2, opts.x, opts.x + opts.colSpan)) { + opts.rowSpan++; + y2++; + } + let cell = new Cell(opts); + cell.x = opts.x; + cell.y = opts.y; + warn(`Missing cell at ${cell.y}-${cell.x}.`); + insertCell(cell, table[y]); + } + } + } + } + + function generateCells(rows) { + return rows.map(function (row) { + if (!Array.isArray(row)) { + let key = Object.keys(row)[0]; + row = row[key]; + if (Array.isArray(row)) { + row = row.slice(); + row.unshift(key); + } else { + row = [key, row]; + } + } + return row.map(function (cell) { + return new Cell(cell); + }); + }); + } + + function makeTableLayout(rows) { + let cellRows = generateCells(rows); + layoutTable(cellRows); + fillInTable(cellRows); + addRowSpanCells(cellRows); + addColSpanCells(cellRows); + return cellRows; + } + + layoutManager.exports = { + makeTableLayout: makeTableLayout, + layoutTable: layoutTable, + addRowSpanCells: addRowSpanCells, + maxWidth: maxWidth, + fillInTable: fillInTable, + computeWidths: makeComputeWidths('colSpan', 'desiredWidth', 'x', 1), + computeHeights: makeComputeWidths('rowSpan', 'desiredHeight', 'y', 1), + }; +})(); + +function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) { + return function (vals, table) { + let result = []; + let spanners = []; + let auto = {}; + table.forEach(function (row) { + row.forEach(function (cell) { + if ((cell[colSpan] || 1) > 1) { + spanners.push(cell); + } else { + result[cell[x]] = Math.max(result[cell[x]] || 0, cell[desiredWidth] || 0, forcedMin); + } + }); + }); + + vals.forEach(function (val, index) { + if (typeof val === 'number') { + result[index] = val; + } + }); + + //spanners.forEach(function(cell){ + for (let k = spanners.length - 1; k >= 0; k--) { + let cell = spanners[k]; + let span = cell[colSpan]; + let col = cell[x]; + let existingWidth = result[col]; + let editableCols = typeof vals[col] === 'number' ? 0 : 1; + if (typeof existingWidth === 'number') { + for (let i = 1; i < span; i++) { + existingWidth += 1 + result[col + i]; + if (typeof vals[col + i] !== 'number') { + editableCols++; + } + } + } else { + existingWidth = desiredWidth === 'desiredWidth' ? cell.desiredWidth - 1 : 1; + if (!auto[col] || auto[col] < existingWidth) { + auto[col] = existingWidth; + } + } + + if (cell[desiredWidth] > existingWidth) { + let i = 0; + while (editableCols > 0 && cell[desiredWidth] > existingWidth) { + if (typeof vals[col + i] !== 'number') { + let dif = Math.round((cell[desiredWidth] - existingWidth) / editableCols); + existingWidth += dif; + result[col + i] += dif; + editableCols--; + } + i++; + } + } + } + + Object.assign(vals, result, auto); + for (let j = 0; j < vals.length; j++) { + vals[j] = Math.max(forcedMin, vals[j] || 0); + } + }; +} + +var layoutManagerExports = layoutManager.exports; + +const debug$4 = debug_1$4; +const utils$g = utils$i; +const tableLayout = layoutManagerExports; + +let Table$1 = class Table extends Array { + constructor(opts) { + super(); + + const options = utils$g.mergeOptions(opts); + Object.defineProperty(this, 'options', { + value: options, + enumerable: options.debug, + }); + + if (options.debug) { + switch (typeof options.debug) { + case 'boolean': + debug$4.setDebugLevel(debug$4.WARN); + break; + case 'number': + debug$4.setDebugLevel(options.debug); + break; + case 'string': + debug$4.setDebugLevel(parseInt(options.debug, 10)); + break; + default: + debug$4.setDebugLevel(debug$4.WARN); + debug$4.warn(`Debug option is expected to be boolean, number, or string. Received a ${typeof options.debug}`); + } + Object.defineProperty(this, 'messages', { + get() { + return debug$4.debugMessages(); + }, + }); + } + } + + toString() { + let array = this; + let headersPresent = this.options.head && this.options.head.length; + if (headersPresent) { + array = [this.options.head]; + if (this.length) { + array.push.apply(array, this); + } + } else { + this.options.style.head = []; + } + + let cells = tableLayout.makeTableLayout(array); + + cells.forEach(function (row) { + row.forEach(function (cell) { + cell.mergeTableOptions(this.options, cells); + }, this); + }, this); + + tableLayout.computeWidths(this.options.colWidths, cells); + tableLayout.computeHeights(this.options.rowHeights, cells); + + cells.forEach(function (row) { + row.forEach(function (cell) { + cell.init(this.options); + }, this); + }, this); + + let result = []; + + for (let rowIndex = 0; rowIndex < cells.length; rowIndex++) { + let row = cells[rowIndex]; + let heightOfRow = this.options.rowHeights[rowIndex]; + + if (rowIndex === 0 || !this.options.style.compact || (rowIndex == 1 && headersPresent)) { + doDraw(row, 'top', result); + } + + for (let lineNum = 0; lineNum < heightOfRow; lineNum++) { + doDraw(row, lineNum, result); + } + + if (rowIndex + 1 == cells.length) { + doDraw(row, 'bottom', result); + } + } + + return result.join('\n'); + } + + get width() { + let str = this.toString().split('\n'); + return str[0].length; + } +}; + +Table$1.reset = () => debug$4.reset(); + +function doDraw(row, lineNum, result) { + let line = []; + row.forEach(function (cell) { + line.push(cell.draw(lineNum)); + }); + let str = line.join(''); + if (str.length) result.push(str); +} + +var table = Table$1; + +var cliTable3 = table; + +var Table = /*@__PURE__*/getDefaultExportFromCjs(cliTable3); + +var lib$4 = {exports: {}}; + +var extendStringPrototype = {exports: {}}; + +(function (module) { + var colors = colorsExports; + + module['exports'] = function() { + // + // Extends prototype of native string object to allow for "foo".red syntax + // + var addProperty = function(color, func) { + String.prototype.__defineGetter__(color, func); + }; + + addProperty('strip', function() { + return colors.strip(this); + }); + + addProperty('stripColors', function() { + return colors.strip(this); + }); + + addProperty('trap', function() { + return colors.trap(this); + }); + + addProperty('zalgo', function() { + return colors.zalgo(this); + }); + + addProperty('zebra', function() { + return colors.zebra(this); + }); + + addProperty('rainbow', function() { + return colors.rainbow(this); + }); + + addProperty('random', function() { + return colors.random(this); + }); + + addProperty('america', function() { + return colors.america(this); + }); + + // + // Iterate through all default styles and colors + // + var x = Object.keys(colors.styles); + x.forEach(function(style) { + addProperty(style, function() { + return colors.stylize(this, style); + }); + }); + + function applyTheme(theme) { + // + // Remark: This is a list of methods that exist + // on String that you should not overwrite. + // + var stringPrototypeBlacklist = [ + '__defineGetter__', '__defineSetter__', '__lookupGetter__', + '__lookupSetter__', 'charAt', 'constructor', 'hasOwnProperty', + 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', + 'valueOf', 'charCodeAt', 'indexOf', 'lastIndexOf', 'length', + 'localeCompare', 'match', 'repeat', 'replace', 'search', 'slice', + 'split', 'substring', 'toLocaleLowerCase', 'toLocaleUpperCase', + 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight', + ]; + + Object.keys(theme).forEach(function(prop) { + if (stringPrototypeBlacklist.indexOf(prop) !== -1) { + console.log('warn: '.red + ('String.prototype' + prop).magenta + + ' is probably something you don\'t want to override. ' + + 'Ignoring style name'); + } else { + if (typeof(theme[prop]) === 'string') { + colors[prop] = colors[theme[prop]]; + addProperty(prop, function() { + return colors[prop](this); + }); + } else { + var themePropApplicator = function(str) { + var ret = str || this; + for (var t = 0; t < theme[prop].length; t++) { + ret = colors[theme[prop][t]](ret); + } + return ret; + }; + addProperty(prop, themePropApplicator); + colors[prop] = function(str) { + return themePropApplicator(str); + }; + } + } + }); + } + + colors.setTheme = function(theme) { + if (typeof theme === 'string') { + console.log('colors.setTheme now only accepts an object, not a string. ' + + 'If you are trying to set a theme from a file, it is now your (the ' + + 'caller\'s) responsibility to require the file. The old syntax ' + + 'looked like colors.setTheme(__dirname + ' + + '\'/../themes/generic-logging.js\'); The new syntax looks like '+ + 'colors.setTheme(require(__dirname + ' + + '\'/../themes/generic-logging.js\'));'); + return; + } else { + applyTheme(theme); + } + }; + }; +} (extendStringPrototype)); + +var extendStringPrototypeExports = extendStringPrototype.exports; + +(function (module) { + var colors = colorsExports; + module['exports'] = colors; + + // Remark: By default, colors will add style properties to String.prototype. + // + // If you don't wish to extend String.prototype, you can do this instead and + // native String will not be touched: + // + // var colors = require('colors/safe); + // colors.red("foo") + // + // + extendStringPrototypeExports(); +} (lib$4)); + +var libExports = lib$4.exports; +var colors = /*@__PURE__*/getDefaultExportFromCjs(libExports); + +function commonjsRequire(path) { + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); +} + +var moment$1 = {exports: {}}; + +(function (module, exports) { +(function (global, factory) { + module.exports = factory() ; + }(commonjsGlobal, (function () { + var hookCallback; + + function hooks() { + return hookCallback.apply(null, arguments); + } + + // This is done to register the method called with moment() + // without creating circular dependencies. + function setHookCallback(callback) { + hookCallback = callback; + } + + function isArray(input) { + return ( + input instanceof Array || + Object.prototype.toString.call(input) === '[object Array]' + ); + } + + function isObject(input) { + // IE8 will treat undefined and null as object if it wasn't for + // input != null + return ( + input != null && + Object.prototype.toString.call(input) === '[object Object]' + ); + } + + function hasOwnProp(a, b) { + return Object.prototype.hasOwnProperty.call(a, b); + } + + function isObjectEmpty(obj) { + if (Object.getOwnPropertyNames) { + return Object.getOwnPropertyNames(obj).length === 0; + } else { + var k; + for (k in obj) { + if (hasOwnProp(obj, k)) { + return false; + } + } + return true; + } + } + + function isUndefined(input) { + return input === void 0; + } + + function isNumber(input) { + return ( + typeof input === 'number' || + Object.prototype.toString.call(input) === '[object Number]' + ); + } + + function isDate(input) { + return ( + input instanceof Date || + Object.prototype.toString.call(input) === '[object Date]' + ); + } + + function map(arr, fn) { + var res = [], + i, + arrLen = arr.length; + for (i = 0; i < arrLen; ++i) { + res.push(fn(arr[i], i)); + } + return res; + } + + function extend(a, b) { + for (var i in b) { + if (hasOwnProp(b, i)) { + a[i] = b[i]; + } + } + + if (hasOwnProp(b, 'toString')) { + a.toString = b.toString; + } + + if (hasOwnProp(b, 'valueOf')) { + a.valueOf = b.valueOf; + } + + return a; + } + + function createUTC(input, format, locale, strict) { + return createLocalOrUTC(input, format, locale, strict, true).utc(); + } + + function defaultParsingFlags() { + // We need to deep clone this object. + return { + empty: false, + unusedTokens: [], + unusedInput: [], + overflow: -2, + charsLeftOver: 0, + nullInput: false, + invalidEra: null, + invalidMonth: null, + invalidFormat: false, + userInvalidated: false, + iso: false, + parsedDateParts: [], + era: null, + meridiem: null, + rfc2822: false, + weekdayMismatch: false, + }; + } + + function getParsingFlags(m) { + if (m._pf == null) { + m._pf = defaultParsingFlags(); + } + return m._pf; + } + + var some; + if (Array.prototype.some) { + some = Array.prototype.some; + } else { + some = function (fun) { + var t = Object(this), + len = t.length >>> 0, + i; + + for (i = 0; i < len; i++) { + if (i in t && fun.call(this, t[i], i, t)) { + return true; + } + } + + return false; + }; + } + + function isValid(m) { + var flags = null, + parsedParts = false, + isNowValid = m._d && !isNaN(m._d.getTime()); + if (isNowValid) { + flags = getParsingFlags(m); + parsedParts = some.call(flags.parsedDateParts, function (i) { + return i != null; + }); + isNowValid = + flags.overflow < 0 && + !flags.empty && + !flags.invalidEra && + !flags.invalidMonth && + !flags.invalidWeekday && + !flags.weekdayMismatch && + !flags.nullInput && + !flags.invalidFormat && + !flags.userInvalidated && + (!flags.meridiem || (flags.meridiem && parsedParts)); + if (m._strict) { + isNowValid = + isNowValid && + flags.charsLeftOver === 0 && + flags.unusedTokens.length === 0 && + flags.bigHour === undefined; + } + } + if (Object.isFrozen == null || !Object.isFrozen(m)) { + m._isValid = isNowValid; + } else { + return isNowValid; + } + return m._isValid; + } + + function createInvalid(flags) { + var m = createUTC(NaN); + if (flags != null) { + extend(getParsingFlags(m), flags); + } else { + getParsingFlags(m).userInvalidated = true; + } + + return m; + } + + // Plugins that add properties should also add the key here (null value), + // so we can properly clone ourselves. + var momentProperties = (hooks.momentProperties = []), + updateInProgress = false; + + function copyConfig(to, from) { + var i, + prop, + val, + momentPropertiesLen = momentProperties.length; + + if (!isUndefined(from._isAMomentObject)) { + to._isAMomentObject = from._isAMomentObject; + } + if (!isUndefined(from._i)) { + to._i = from._i; + } + if (!isUndefined(from._f)) { + to._f = from._f; + } + if (!isUndefined(from._l)) { + to._l = from._l; + } + if (!isUndefined(from._strict)) { + to._strict = from._strict; + } + if (!isUndefined(from._tzm)) { + to._tzm = from._tzm; + } + if (!isUndefined(from._isUTC)) { + to._isUTC = from._isUTC; + } + if (!isUndefined(from._offset)) { + to._offset = from._offset; + } + if (!isUndefined(from._pf)) { + to._pf = getParsingFlags(from); + } + if (!isUndefined(from._locale)) { + to._locale = from._locale; + } + + if (momentPropertiesLen > 0) { + for (i = 0; i < momentPropertiesLen; i++) { + prop = momentProperties[i]; + val = from[prop]; + if (!isUndefined(val)) { + to[prop] = val; + } + } + } + + return to; + } + + // Moment prototype object + function Moment(config) { + copyConfig(this, config); + this._d = new Date(config._d != null ? config._d.getTime() : NaN); + if (!this.isValid()) { + this._d = new Date(NaN); + } + // Prevent infinite loop in case updateOffset creates new moment + // objects. + if (updateInProgress === false) { + updateInProgress = true; + hooks.updateOffset(this); + updateInProgress = false; + } + } + + function isMoment(obj) { + return ( + obj instanceof Moment || (obj != null && obj._isAMomentObject != null) + ); + } + + function warn(msg) { + if ( + hooks.suppressDeprecationWarnings === false && + typeof console !== 'undefined' && + console.warn + ) { + console.warn('Deprecation warning: ' + msg); + } + } + + function deprecate(msg, fn) { + var firstTime = true; + + return extend(function () { + if (hooks.deprecationHandler != null) { + hooks.deprecationHandler(null, msg); + } + if (firstTime) { + var args = [], + arg, + i, + key, + argLen = arguments.length; + for (i = 0; i < argLen; i++) { + arg = ''; + if (typeof arguments[i] === 'object') { + arg += '\n[' + i + '] '; + for (key in arguments[0]) { + if (hasOwnProp(arguments[0], key)) { + arg += key + ': ' + arguments[0][key] + ', '; + } + } + arg = arg.slice(0, -2); // Remove trailing comma and space + } else { + arg = arguments[i]; + } + args.push(arg); + } + warn( + msg + + '\nArguments: ' + + Array.prototype.slice.call(args).join('') + + '\n' + + new Error().stack + ); + firstTime = false; + } + return fn.apply(this, arguments); + }, fn); + } + + var deprecations = {}; + + function deprecateSimple(name, msg) { + if (hooks.deprecationHandler != null) { + hooks.deprecationHandler(name, msg); + } + if (!deprecations[name]) { + warn(msg); + deprecations[name] = true; + } + } + + hooks.suppressDeprecationWarnings = false; + hooks.deprecationHandler = null; + + function isFunction(input) { + return ( + (typeof Function !== 'undefined' && input instanceof Function) || + Object.prototype.toString.call(input) === '[object Function]' + ); + } + + function set(config) { + var prop, i; + for (i in config) { + if (hasOwnProp(config, i)) { + prop = config[i]; + if (isFunction(prop)) { + this[i] = prop; + } else { + this['_' + i] = prop; + } + } + } + this._config = config; + // Lenient ordinal parsing accepts just a number in addition to + // number + (possibly) stuff coming from _dayOfMonthOrdinalParse. + // TODO: Remove "ordinalParse" fallback in next major release. + this._dayOfMonthOrdinalParseLenient = new RegExp( + (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + + '|' + + /\d{1,2}/.source + ); + } + + function mergeConfigs(parentConfig, childConfig) { + var res = extend({}, parentConfig), + prop; + for (prop in childConfig) { + if (hasOwnProp(childConfig, prop)) { + if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) { + res[prop] = {}; + extend(res[prop], parentConfig[prop]); + extend(res[prop], childConfig[prop]); + } else if (childConfig[prop] != null) { + res[prop] = childConfig[prop]; + } else { + delete res[prop]; + } + } + } + for (prop in parentConfig) { + if ( + hasOwnProp(parentConfig, prop) && + !hasOwnProp(childConfig, prop) && + isObject(parentConfig[prop]) + ) { + // make sure changes to properties don't modify parent config + res[prop] = extend({}, res[prop]); + } + } + return res; + } + + function Locale(config) { + if (config != null) { + this.set(config); + } + } + + var keys; + + if (Object.keys) { + keys = Object.keys; + } else { + keys = function (obj) { + var i, + res = []; + for (i in obj) { + if (hasOwnProp(obj, i)) { + res.push(i); + } + } + return res; + }; + } + + var defaultCalendar = { + sameDay: '[Today at] LT', + nextDay: '[Tomorrow at] LT', + nextWeek: 'dddd [at] LT', + lastDay: '[Yesterday at] LT', + lastWeek: '[Last] dddd [at] LT', + sameElse: 'L', + }; + + function calendar(key, mom, now) { + var output = this._calendar[key] || this._calendar['sameElse']; + return isFunction(output) ? output.call(mom, now) : output; + } + + function zeroFill(number, targetLength, forceSign) { + var absNumber = '' + Math.abs(number), + zerosToFill = targetLength - absNumber.length, + sign = number >= 0; + return ( + (sign ? (forceSign ? '+' : '') : '-') + + Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + + absNumber + ); + } + + var formattingTokens = + /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g, + localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, + formatFunctions = {}, + formatTokenFunctions = {}; + + // token: 'M' + // padded: ['MM', 2] + // ordinal: 'Mo' + // callback: function () { this.month() + 1 } + function addFormatToken(token, padded, ordinal, callback) { + var func = callback; + if (typeof callback === 'string') { + func = function () { + return this[callback](); + }; + } + if (token) { + formatTokenFunctions[token] = func; + } + if (padded) { + formatTokenFunctions[padded[0]] = function () { + return zeroFill(func.apply(this, arguments), padded[1], padded[2]); + }; + } + if (ordinal) { + formatTokenFunctions[ordinal] = function () { + return this.localeData().ordinal( + func.apply(this, arguments), + token + ); + }; + } + } + + function removeFormattingTokens(input) { + if (input.match(/\[[\s\S]/)) { + return input.replace(/^\[|\]$/g, ''); + } + return input.replace(/\\/g, ''); + } + + function makeFormatFunction(format) { + var array = format.match(formattingTokens), + i, + length; + + for (i = 0, length = array.length; i < length; i++) { + if (formatTokenFunctions[array[i]]) { + array[i] = formatTokenFunctions[array[i]]; + } else { + array[i] = removeFormattingTokens(array[i]); + } + } + + return function (mom) { + var output = '', + i; + for (i = 0; i < length; i++) { + output += isFunction(array[i]) + ? array[i].call(mom, format) + : array[i]; + } + return output; + }; + } + + // format date using native date object + function formatMoment(m, format) { + if (!m.isValid()) { + return m.localeData().invalidDate(); + } + + format = expandFormat(format, m.localeData()); + formatFunctions[format] = + formatFunctions[format] || makeFormatFunction(format); + + return formatFunctions[format](m); + } + + function expandFormat(format, locale) { + var i = 5; + + function replaceLongDateFormatTokens(input) { + return locale.longDateFormat(input) || input; + } + + localFormattingTokens.lastIndex = 0; + while (i >= 0 && localFormattingTokens.test(format)) { + format = format.replace( + localFormattingTokens, + replaceLongDateFormatTokens + ); + localFormattingTokens.lastIndex = 0; + i -= 1; + } + + return format; + } + + var defaultLongDateFormat = { + LTS: 'h:mm:ss A', + LT: 'h:mm A', + L: 'MM/DD/YYYY', + LL: 'MMMM D, YYYY', + LLL: 'MMMM D, YYYY h:mm A', + LLLL: 'dddd, MMMM D, YYYY h:mm A', + }; + + function longDateFormat(key) { + var format = this._longDateFormat[key], + formatUpper = this._longDateFormat[key.toUpperCase()]; + + if (format || !formatUpper) { + return format; + } + + this._longDateFormat[key] = formatUpper + .match(formattingTokens) + .map(function (tok) { + if ( + tok === 'MMMM' || + tok === 'MM' || + tok === 'DD' || + tok === 'dddd' + ) { + return tok.slice(1); + } + return tok; + }) + .join(''); + + return this._longDateFormat[key]; + } + + var defaultInvalidDate = 'Invalid date'; + + function invalidDate() { + return this._invalidDate; + } + + var defaultOrdinal = '%d', + defaultDayOfMonthOrdinalParse = /\d{1,2}/; + + function ordinal(number) { + return this._ordinal.replace('%d', number); + } + + var defaultRelativeTime = { + future: 'in %s', + past: '%s ago', + s: 'a few seconds', + ss: '%d seconds', + m: 'a minute', + mm: '%d minutes', + h: 'an hour', + hh: '%d hours', + d: 'a day', + dd: '%d days', + w: 'a week', + ww: '%d weeks', + M: 'a month', + MM: '%d months', + y: 'a year', + yy: '%d years', + }; + + function relativeTime(number, withoutSuffix, string, isFuture) { + var output = this._relativeTime[string]; + return isFunction(output) + ? output(number, withoutSuffix, string, isFuture) + : output.replace(/%d/i, number); + } + + function pastFuture(diff, output) { + var format = this._relativeTime[diff > 0 ? 'future' : 'past']; + return isFunction(format) ? format(output) : format.replace(/%s/i, output); + } + + var aliases = { + D: 'date', + dates: 'date', + date: 'date', + d: 'day', + days: 'day', + day: 'day', + e: 'weekday', + weekdays: 'weekday', + weekday: 'weekday', + E: 'isoWeekday', + isoweekdays: 'isoWeekday', + isoweekday: 'isoWeekday', + DDD: 'dayOfYear', + dayofyears: 'dayOfYear', + dayofyear: 'dayOfYear', + h: 'hour', + hours: 'hour', + hour: 'hour', + ms: 'millisecond', + milliseconds: 'millisecond', + millisecond: 'millisecond', + m: 'minute', + minutes: 'minute', + minute: 'minute', + M: 'month', + months: 'month', + month: 'month', + Q: 'quarter', + quarters: 'quarter', + quarter: 'quarter', + s: 'second', + seconds: 'second', + second: 'second', + gg: 'weekYear', + weekyears: 'weekYear', + weekyear: 'weekYear', + GG: 'isoWeekYear', + isoweekyears: 'isoWeekYear', + isoweekyear: 'isoWeekYear', + w: 'week', + weeks: 'week', + week: 'week', + W: 'isoWeek', + isoweeks: 'isoWeek', + isoweek: 'isoWeek', + y: 'year', + years: 'year', + year: 'year', + }; + + function normalizeUnits(units) { + return typeof units === 'string' + ? aliases[units] || aliases[units.toLowerCase()] + : undefined; + } + + function normalizeObjectUnits(inputObject) { + var normalizedInput = {}, + normalizedProp, + prop; + + for (prop in inputObject) { + if (hasOwnProp(inputObject, prop)) { + normalizedProp = normalizeUnits(prop); + if (normalizedProp) { + normalizedInput[normalizedProp] = inputObject[prop]; + } + } + } + + return normalizedInput; + } + + var priorities = { + date: 9, + day: 11, + weekday: 11, + isoWeekday: 11, + dayOfYear: 4, + hour: 13, + millisecond: 16, + minute: 14, + month: 8, + quarter: 7, + second: 15, + weekYear: 1, + isoWeekYear: 1, + week: 5, + isoWeek: 5, + year: 1, + }; + + function getPrioritizedUnits(unitsObj) { + var units = [], + u; + for (u in unitsObj) { + if (hasOwnProp(unitsObj, u)) { + units.push({ unit: u, priority: priorities[u] }); + } + } + units.sort(function (a, b) { + return a.priority - b.priority; + }); + return units; + } + + var match1 = /\d/, // 0 - 9 + match2 = /\d\d/, // 00 - 99 + match3 = /\d{3}/, // 000 - 999 + match4 = /\d{4}/, // 0000 - 9999 + match6 = /[+-]?\d{6}/, // -999999 - 999999 + match1to2 = /\d\d?/, // 0 - 99 + match3to4 = /\d\d\d\d?/, // 999 - 9999 + match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999 + match1to3 = /\d{1,3}/, // 0 - 999 + match1to4 = /\d{1,4}/, // 0 - 9999 + match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999 + matchUnsigned = /\d+/, // 0 - inf + matchSigned = /[+-]?\d+/, // -inf - inf + matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z + matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z + matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123 + // any word (or two) characters or numbers including two/three word month in arabic. + // includes scottish gaelic two word and hyphenated months + matchWord = + /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i, + match1to2NoLeadingZero = /^[1-9]\d?/, // 1-99 + match1to2HasZero = /^([1-9]\d|\d)/, // 0-99 + regexes; + + regexes = {}; + + function addRegexToken(token, regex, strictRegex) { + regexes[token] = isFunction(regex) + ? regex + : function (isStrict, localeData) { + return isStrict && strictRegex ? strictRegex : regex; + }; + } + + function getParseRegexForToken(token, config) { + if (!hasOwnProp(regexes, token)) { + return new RegExp(unescapeFormat(token)); + } + + return regexes[token](config._strict, config._locale); + } + + // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript + function unescapeFormat(s) { + return regexEscape( + s + .replace('\\', '') + .replace( + /\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, + function (matched, p1, p2, p3, p4) { + return p1 || p2 || p3 || p4; + } + ) + ); + } + + function regexEscape(s) { + return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); + } + + function absFloor(number) { + if (number < 0) { + // -0 -> 0 + return Math.ceil(number) || 0; + } else { + return Math.floor(number); + } + } + + function toInt(argumentForCoercion) { + var coercedNumber = +argumentForCoercion, + value = 0; + + if (coercedNumber !== 0 && isFinite(coercedNumber)) { + value = absFloor(coercedNumber); + } + + return value; + } + + var tokens = {}; + + function addParseToken(token, callback) { + var i, + func = callback, + tokenLen; + if (typeof token === 'string') { + token = [token]; + } + if (isNumber(callback)) { + func = function (input, array) { + array[callback] = toInt(input); + }; + } + tokenLen = token.length; + for (i = 0; i < tokenLen; i++) { + tokens[token[i]] = func; + } + } + + function addWeekParseToken(token, callback) { + addParseToken(token, function (input, array, config, token) { + config._w = config._w || {}; + callback(input, config._w, config, token); + }); + } + + function addTimeToArrayFromToken(token, input, config) { + if (input != null && hasOwnProp(tokens, token)) { + tokens[token](input, config._a, config, token); + } + } + + function isLeapYear(year) { + return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; + } + + var YEAR = 0, + MONTH = 1, + DATE = 2, + HOUR = 3, + MINUTE = 4, + SECOND = 5, + MILLISECOND = 6, + WEEK = 7, + WEEKDAY = 8; + + // FORMATTING + + addFormatToken('Y', 0, 0, function () { + var y = this.year(); + return y <= 9999 ? zeroFill(y, 4) : '+' + y; + }); + + addFormatToken(0, ['YY', 2], 0, function () { + return this.year() % 100; + }); + + addFormatToken(0, ['YYYY', 4], 0, 'year'); + addFormatToken(0, ['YYYYY', 5], 0, 'year'); + addFormatToken(0, ['YYYYYY', 6, true], 0, 'year'); + + // PARSING + + addRegexToken('Y', matchSigned); + addRegexToken('YY', match1to2, match2); + addRegexToken('YYYY', match1to4, match4); + addRegexToken('YYYYY', match1to6, match6); + addRegexToken('YYYYYY', match1to6, match6); + + addParseToken(['YYYYY', 'YYYYYY'], YEAR); + addParseToken('YYYY', function (input, array) { + array[YEAR] = + input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input); + }); + addParseToken('YY', function (input, array) { + array[YEAR] = hooks.parseTwoDigitYear(input); + }); + addParseToken('Y', function (input, array) { + array[YEAR] = parseInt(input, 10); + }); + + // HELPERS + + function daysInYear(year) { + return isLeapYear(year) ? 366 : 365; + } + + // HOOKS + + hooks.parseTwoDigitYear = function (input) { + return toInt(input) + (toInt(input) > 68 ? 1900 : 2000); + }; + + // MOMENTS + + var getSetYear = makeGetSet('FullYear', true); + + function getIsLeapYear() { + return isLeapYear(this.year()); + } + + function makeGetSet(unit, keepTime) { + return function (value) { + if (value != null) { + set$1(this, unit, value); + hooks.updateOffset(this, keepTime); + return this; + } else { + return get(this, unit); + } + }; + } + + function get(mom, unit) { + if (!mom.isValid()) { + return NaN; + } + + var d = mom._d, + isUTC = mom._isUTC; + + switch (unit) { + case 'Milliseconds': + return isUTC ? d.getUTCMilliseconds() : d.getMilliseconds(); + case 'Seconds': + return isUTC ? d.getUTCSeconds() : d.getSeconds(); + case 'Minutes': + return isUTC ? d.getUTCMinutes() : d.getMinutes(); + case 'Hours': + return isUTC ? d.getUTCHours() : d.getHours(); + case 'Date': + return isUTC ? d.getUTCDate() : d.getDate(); + case 'Day': + return isUTC ? d.getUTCDay() : d.getDay(); + case 'Month': + return isUTC ? d.getUTCMonth() : d.getMonth(); + case 'FullYear': + return isUTC ? d.getUTCFullYear() : d.getFullYear(); + default: + return NaN; // Just in case + } + } + + function set$1(mom, unit, value) { + var d, isUTC, year, month, date; + + if (!mom.isValid() || isNaN(value)) { + return; + } + + d = mom._d; + isUTC = mom._isUTC; + + switch (unit) { + case 'Milliseconds': + return void (isUTC + ? d.setUTCMilliseconds(value) + : d.setMilliseconds(value)); + case 'Seconds': + return void (isUTC ? d.setUTCSeconds(value) : d.setSeconds(value)); + case 'Minutes': + return void (isUTC ? d.setUTCMinutes(value) : d.setMinutes(value)); + case 'Hours': + return void (isUTC ? d.setUTCHours(value) : d.setHours(value)); + case 'Date': + return void (isUTC ? d.setUTCDate(value) : d.setDate(value)); + // case 'Day': // Not real + // return void (isUTC ? d.setUTCDay(value) : d.setDay(value)); + // case 'Month': // Not used because we need to pass two variables + // return void (isUTC ? d.setUTCMonth(value) : d.setMonth(value)); + case 'FullYear': + break; // See below ... + default: + return; // Just in case + } + + year = value; + month = mom.month(); + date = mom.date(); + date = date === 29 && month === 1 && !isLeapYear(year) ? 28 : date; + void (isUTC + ? d.setUTCFullYear(year, month, date) + : d.setFullYear(year, month, date)); + } + + // MOMENTS + + function stringGet(units) { + units = normalizeUnits(units); + if (isFunction(this[units])) { + return this[units](); + } + return this; + } + + function stringSet(units, value) { + if (typeof units === 'object') { + units = normalizeObjectUnits(units); + var prioritized = getPrioritizedUnits(units), + i, + prioritizedLen = prioritized.length; + for (i = 0; i < prioritizedLen; i++) { + this[prioritized[i].unit](units[prioritized[i].unit]); + } + } else { + units = normalizeUnits(units); + if (isFunction(this[units])) { + return this[units](value); + } + } + return this; + } + + function mod(n, x) { + return ((n % x) + x) % x; + } + + var indexOf; + + if (Array.prototype.indexOf) { + indexOf = Array.prototype.indexOf; + } else { + indexOf = function (o) { + // I know + var i; + for (i = 0; i < this.length; ++i) { + if (this[i] === o) { + return i; + } + } + return -1; + }; + } + + function daysInMonth(year, month) { + if (isNaN(year) || isNaN(month)) { + return NaN; + } + var modMonth = mod(month, 12); + year += (month - modMonth) / 12; + return modMonth === 1 + ? isLeapYear(year) + ? 29 + : 28 + : 31 - ((modMonth % 7) % 2); + } + + // FORMATTING + + addFormatToken('M', ['MM', 2], 'Mo', function () { + return this.month() + 1; + }); + + addFormatToken('MMM', 0, 0, function (format) { + return this.localeData().monthsShort(this, format); + }); + + addFormatToken('MMMM', 0, 0, function (format) { + return this.localeData().months(this, format); + }); + + // PARSING + + addRegexToken('M', match1to2, match1to2NoLeadingZero); + addRegexToken('MM', match1to2, match2); + addRegexToken('MMM', function (isStrict, locale) { + return locale.monthsShortRegex(isStrict); + }); + addRegexToken('MMMM', function (isStrict, locale) { + return locale.monthsRegex(isStrict); + }); + + addParseToken(['M', 'MM'], function (input, array) { + array[MONTH] = toInt(input) - 1; + }); + + addParseToken(['MMM', 'MMMM'], function (input, array, config, token) { + var month = config._locale.monthsParse(input, token, config._strict); + // if we didn't find a month name, mark the date as invalid. + if (month != null) { + array[MONTH] = month; + } else { + getParsingFlags(config).invalidMonth = input; + } + }); + + // LOCALES + + var defaultLocaleMonths = + 'January_February_March_April_May_June_July_August_September_October_November_December'.split( + '_' + ), + defaultLocaleMonthsShort = + 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), + MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/, + defaultMonthsShortRegex = matchWord, + defaultMonthsRegex = matchWord; + + function localeMonths(m, format) { + if (!m) { + return isArray(this._months) + ? this._months + : this._months['standalone']; + } + return isArray(this._months) + ? this._months[m.month()] + : this._months[ + (this._months.isFormat || MONTHS_IN_FORMAT).test(format) + ? 'format' + : 'standalone' + ][m.month()]; + } + + function localeMonthsShort(m, format) { + if (!m) { + return isArray(this._monthsShort) + ? this._monthsShort + : this._monthsShort['standalone']; + } + return isArray(this._monthsShort) + ? this._monthsShort[m.month()] + : this._monthsShort[ + MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone' + ][m.month()]; + } + + function handleStrictParse(monthName, format, strict) { + var i, + ii, + mom, + llc = monthName.toLocaleLowerCase(); + if (!this._monthsParse) { + // this is not used + this._monthsParse = []; + this._longMonthsParse = []; + this._shortMonthsParse = []; + for (i = 0; i < 12; ++i) { + mom = createUTC([2000, i]); + this._shortMonthsParse[i] = this.monthsShort( + mom, + '' + ).toLocaleLowerCase(); + this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase(); + } + } + + if (strict) { + if (format === 'MMM') { + ii = indexOf.call(this._shortMonthsParse, llc); + return ii !== -1 ? ii : null; + } else { + ii = indexOf.call(this._longMonthsParse, llc); + return ii !== -1 ? ii : null; + } + } else { + if (format === 'MMM') { + ii = indexOf.call(this._shortMonthsParse, llc); + if (ii !== -1) { + return ii; + } + ii = indexOf.call(this._longMonthsParse, llc); + return ii !== -1 ? ii : null; + } else { + ii = indexOf.call(this._longMonthsParse, llc); + if (ii !== -1) { + return ii; + } + ii = indexOf.call(this._shortMonthsParse, llc); + return ii !== -1 ? ii : null; + } + } + } + + function localeMonthsParse(monthName, format, strict) { + var i, mom, regex; + + if (this._monthsParseExact) { + return handleStrictParse.call(this, monthName, format, strict); + } + + if (!this._monthsParse) { + this._monthsParse = []; + this._longMonthsParse = []; + this._shortMonthsParse = []; + } + + // TODO: add sorting + // Sorting makes sure if one month (or abbr) is a prefix of another + // see sorting in computeMonthsParse + for (i = 0; i < 12; i++) { + // make the regex if we don't have it already + mom = createUTC([2000, i]); + if (strict && !this._longMonthsParse[i]) { + this._longMonthsParse[i] = new RegExp( + '^' + this.months(mom, '').replace('.', '') + '$', + 'i' + ); + this._shortMonthsParse[i] = new RegExp( + '^' + this.monthsShort(mom, '').replace('.', '') + '$', + 'i' + ); + } + if (!strict && !this._monthsParse[i]) { + regex = + '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, ''); + this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i'); + } + // test the regex + if ( + strict && + format === 'MMMM' && + this._longMonthsParse[i].test(monthName) + ) { + return i; + } else if ( + strict && + format === 'MMM' && + this._shortMonthsParse[i].test(monthName) + ) { + return i; + } else if (!strict && this._monthsParse[i].test(monthName)) { + return i; + } + } + } + + // MOMENTS + + function setMonth(mom, value) { + if (!mom.isValid()) { + // No op + return mom; + } + + if (typeof value === 'string') { + if (/^\d+$/.test(value)) { + value = toInt(value); + } else { + value = mom.localeData().monthsParse(value); + // TODO: Another silent failure? + if (!isNumber(value)) { + return mom; + } + } + } + + var month = value, + date = mom.date(); + + date = date < 29 ? date : Math.min(date, daysInMonth(mom.year(), month)); + void (mom._isUTC + ? mom._d.setUTCMonth(month, date) + : mom._d.setMonth(month, date)); + return mom; + } + + function getSetMonth(value) { + if (value != null) { + setMonth(this, value); + hooks.updateOffset(this, true); + return this; + } else { + return get(this, 'Month'); + } + } + + function getDaysInMonth() { + return daysInMonth(this.year(), this.month()); + } + + function monthsShortRegex(isStrict) { + if (this._monthsParseExact) { + if (!hasOwnProp(this, '_monthsRegex')) { + computeMonthsParse.call(this); + } + if (isStrict) { + return this._monthsShortStrictRegex; + } else { + return this._monthsShortRegex; + } + } else { + if (!hasOwnProp(this, '_monthsShortRegex')) { + this._monthsShortRegex = defaultMonthsShortRegex; + } + return this._monthsShortStrictRegex && isStrict + ? this._monthsShortStrictRegex + : this._monthsShortRegex; + } + } + + function monthsRegex(isStrict) { + if (this._monthsParseExact) { + if (!hasOwnProp(this, '_monthsRegex')) { + computeMonthsParse.call(this); + } + if (isStrict) { + return this._monthsStrictRegex; + } else { + return this._monthsRegex; + } + } else { + if (!hasOwnProp(this, '_monthsRegex')) { + this._monthsRegex = defaultMonthsRegex; + } + return this._monthsStrictRegex && isStrict + ? this._monthsStrictRegex + : this._monthsRegex; + } + } + + function computeMonthsParse() { + function cmpLenRev(a, b) { + return b.length - a.length; + } + + var shortPieces = [], + longPieces = [], + mixedPieces = [], + i, + mom, + shortP, + longP; + for (i = 0; i < 12; i++) { + // make the regex if we don't have it already + mom = createUTC([2000, i]); + shortP = regexEscape(this.monthsShort(mom, '')); + longP = regexEscape(this.months(mom, '')); + shortPieces.push(shortP); + longPieces.push(longP); + mixedPieces.push(longP); + mixedPieces.push(shortP); + } + // Sorting makes sure if one month (or abbr) is a prefix of another it + // will match the longer piece. + shortPieces.sort(cmpLenRev); + longPieces.sort(cmpLenRev); + mixedPieces.sort(cmpLenRev); + + this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); + this._monthsShortRegex = this._monthsRegex; + this._monthsStrictRegex = new RegExp( + '^(' + longPieces.join('|') + ')', + 'i' + ); + this._monthsShortStrictRegex = new RegExp( + '^(' + shortPieces.join('|') + ')', + 'i' + ); + } + + function createDate(y, m, d, h, M, s, ms) { + // can't just apply() to create a date: + // https://stackoverflow.com/q/181348 + var date; + // the date constructor remaps years 0-99 to 1900-1999 + if (y < 100 && y >= 0) { + // preserve leap years using a full 400 year cycle, then reset + date = new Date(y + 400, m, d, h, M, s, ms); + if (isFinite(date.getFullYear())) { + date.setFullYear(y); + } + } else { + date = new Date(y, m, d, h, M, s, ms); + } + + return date; + } + + function createUTCDate(y) { + var date, args; + // the Date.UTC function remaps years 0-99 to 1900-1999 + if (y < 100 && y >= 0) { + args = Array.prototype.slice.call(arguments); + // preserve leap years using a full 400 year cycle, then reset + args[0] = y + 400; + date = new Date(Date.UTC.apply(null, args)); + if (isFinite(date.getUTCFullYear())) { + date.setUTCFullYear(y); + } + } else { + date = new Date(Date.UTC.apply(null, arguments)); + } + + return date; + } + + // start-of-first-week - start-of-year + function firstWeekOffset(year, dow, doy) { + var // first-week day -- which january is always in the first week (4 for iso, 1 for other) + fwd = 7 + dow - doy, + // first-week day local weekday -- which local weekday is fwd + fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7; + + return -fwdlw + fwd - 1; + } + + // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday + function dayOfYearFromWeeks(year, week, weekday, dow, doy) { + var localWeekday = (7 + weekday - dow) % 7, + weekOffset = firstWeekOffset(year, dow, doy), + dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset, + resYear, + resDayOfYear; + + if (dayOfYear <= 0) { + resYear = year - 1; + resDayOfYear = daysInYear(resYear) + dayOfYear; + } else if (dayOfYear > daysInYear(year)) { + resYear = year + 1; + resDayOfYear = dayOfYear - daysInYear(year); + } else { + resYear = year; + resDayOfYear = dayOfYear; + } + + return { + year: resYear, + dayOfYear: resDayOfYear, + }; + } + + function weekOfYear(mom, dow, doy) { + var weekOffset = firstWeekOffset(mom.year(), dow, doy), + week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1, + resWeek, + resYear; + + if (week < 1) { + resYear = mom.year() - 1; + resWeek = week + weeksInYear(resYear, dow, doy); + } else if (week > weeksInYear(mom.year(), dow, doy)) { + resWeek = week - weeksInYear(mom.year(), dow, doy); + resYear = mom.year() + 1; + } else { + resYear = mom.year(); + resWeek = week; + } + + return { + week: resWeek, + year: resYear, + }; + } + + function weeksInYear(year, dow, doy) { + var weekOffset = firstWeekOffset(year, dow, doy), + weekOffsetNext = firstWeekOffset(year + 1, dow, doy); + return (daysInYear(year) - weekOffset + weekOffsetNext) / 7; + } + + // FORMATTING + + addFormatToken('w', ['ww', 2], 'wo', 'week'); + addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek'); + + // PARSING + + addRegexToken('w', match1to2, match1to2NoLeadingZero); + addRegexToken('ww', match1to2, match2); + addRegexToken('W', match1to2, match1to2NoLeadingZero); + addRegexToken('WW', match1to2, match2); + + addWeekParseToken( + ['w', 'ww', 'W', 'WW'], + function (input, week, config, token) { + week[token.substr(0, 1)] = toInt(input); + } + ); + + // HELPERS + + // LOCALES + + function localeWeek(mom) { + return weekOfYear(mom, this._week.dow, this._week.doy).week; + } + + var defaultLocaleWeek = { + dow: 0, // Sunday is the first day of the week. + doy: 6, // The week that contains Jan 6th is the first week of the year. + }; + + function localeFirstDayOfWeek() { + return this._week.dow; + } + + function localeFirstDayOfYear() { + return this._week.doy; + } + + // MOMENTS + + function getSetWeek(input) { + var week = this.localeData().week(this); + return input == null ? week : this.add((input - week) * 7, 'd'); + } + + function getSetISOWeek(input) { + var week = weekOfYear(this, 1, 4).week; + return input == null ? week : this.add((input - week) * 7, 'd'); + } + + // FORMATTING + + addFormatToken('d', 0, 'do', 'day'); + + addFormatToken('dd', 0, 0, function (format) { + return this.localeData().weekdaysMin(this, format); + }); + + addFormatToken('ddd', 0, 0, function (format) { + return this.localeData().weekdaysShort(this, format); + }); + + addFormatToken('dddd', 0, 0, function (format) { + return this.localeData().weekdays(this, format); + }); + + addFormatToken('e', 0, 0, 'weekday'); + addFormatToken('E', 0, 0, 'isoWeekday'); + + // PARSING + + addRegexToken('d', match1to2); + addRegexToken('e', match1to2); + addRegexToken('E', match1to2); + addRegexToken('dd', function (isStrict, locale) { + return locale.weekdaysMinRegex(isStrict); + }); + addRegexToken('ddd', function (isStrict, locale) { + return locale.weekdaysShortRegex(isStrict); + }); + addRegexToken('dddd', function (isStrict, locale) { + return locale.weekdaysRegex(isStrict); + }); + + addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) { + var weekday = config._locale.weekdaysParse(input, token, config._strict); + // if we didn't get a weekday name, mark the date as invalid + if (weekday != null) { + week.d = weekday; + } else { + getParsingFlags(config).invalidWeekday = input; + } + }); + + addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) { + week[token] = toInt(input); + }); + + // HELPERS + + function parseWeekday(input, locale) { + if (typeof input !== 'string') { + return input; + } + + if (!isNaN(input)) { + return parseInt(input, 10); + } + + input = locale.weekdaysParse(input); + if (typeof input === 'number') { + return input; + } + + return null; + } + + function parseIsoWeekday(input, locale) { + if (typeof input === 'string') { + return locale.weekdaysParse(input) % 7 || 7; + } + return isNaN(input) ? null : input; + } + + // LOCALES + function shiftWeekdays(ws, n) { + return ws.slice(n, 7).concat(ws.slice(0, n)); + } + + var defaultLocaleWeekdays = + 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), + defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), + defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), + defaultWeekdaysRegex = matchWord, + defaultWeekdaysShortRegex = matchWord, + defaultWeekdaysMinRegex = matchWord; + + function localeWeekdays(m, format) { + var weekdays = isArray(this._weekdays) + ? this._weekdays + : this._weekdays[ + m && m !== true && this._weekdays.isFormat.test(format) + ? 'format' + : 'standalone' + ]; + return m === true + ? shiftWeekdays(weekdays, this._week.dow) + : m + ? weekdays[m.day()] + : weekdays; + } + + function localeWeekdaysShort(m) { + return m === true + ? shiftWeekdays(this._weekdaysShort, this._week.dow) + : m + ? this._weekdaysShort[m.day()] + : this._weekdaysShort; + } + + function localeWeekdaysMin(m) { + return m === true + ? shiftWeekdays(this._weekdaysMin, this._week.dow) + : m + ? this._weekdaysMin[m.day()] + : this._weekdaysMin; + } + + function handleStrictParse$1(weekdayName, format, strict) { + var i, + ii, + mom, + llc = weekdayName.toLocaleLowerCase(); + if (!this._weekdaysParse) { + this._weekdaysParse = []; + this._shortWeekdaysParse = []; + this._minWeekdaysParse = []; + + for (i = 0; i < 7; ++i) { + mom = createUTC([2000, 1]).day(i); + this._minWeekdaysParse[i] = this.weekdaysMin( + mom, + '' + ).toLocaleLowerCase(); + this._shortWeekdaysParse[i] = this.weekdaysShort( + mom, + '' + ).toLocaleLowerCase(); + this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase(); + } + } + + if (strict) { + if (format === 'dddd') { + ii = indexOf.call(this._weekdaysParse, llc); + return ii !== -1 ? ii : null; + } else if (format === 'ddd') { + ii = indexOf.call(this._shortWeekdaysParse, llc); + return ii !== -1 ? ii : null; + } else { + ii = indexOf.call(this._minWeekdaysParse, llc); + return ii !== -1 ? ii : null; + } + } else { + if (format === 'dddd') { + ii = indexOf.call(this._weekdaysParse, llc); + if (ii !== -1) { + return ii; + } + ii = indexOf.call(this._shortWeekdaysParse, llc); + if (ii !== -1) { + return ii; + } + ii = indexOf.call(this._minWeekdaysParse, llc); + return ii !== -1 ? ii : null; + } else if (format === 'ddd') { + ii = indexOf.call(this._shortWeekdaysParse, llc); + if (ii !== -1) { + return ii; + } + ii = indexOf.call(this._weekdaysParse, llc); + if (ii !== -1) { + return ii; + } + ii = indexOf.call(this._minWeekdaysParse, llc); + return ii !== -1 ? ii : null; + } else { + ii = indexOf.call(this._minWeekdaysParse, llc); + if (ii !== -1) { + return ii; + } + ii = indexOf.call(this._weekdaysParse, llc); + if (ii !== -1) { + return ii; + } + ii = indexOf.call(this._shortWeekdaysParse, llc); + return ii !== -1 ? ii : null; + } + } + } + + function localeWeekdaysParse(weekdayName, format, strict) { + var i, mom, regex; + + if (this._weekdaysParseExact) { + return handleStrictParse$1.call(this, weekdayName, format, strict); + } + + if (!this._weekdaysParse) { + this._weekdaysParse = []; + this._minWeekdaysParse = []; + this._shortWeekdaysParse = []; + this._fullWeekdaysParse = []; + } + + for (i = 0; i < 7; i++) { + // make the regex if we don't have it already + + mom = createUTC([2000, 1]).day(i); + if (strict && !this._fullWeekdaysParse[i]) { + this._fullWeekdaysParse[i] = new RegExp( + '^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', + 'i' + ); + this._shortWeekdaysParse[i] = new RegExp( + '^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', + 'i' + ); + this._minWeekdaysParse[i] = new RegExp( + '^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', + 'i' + ); + } + if (!this._weekdaysParse[i]) { + regex = + '^' + + this.weekdays(mom, '') + + '|^' + + this.weekdaysShort(mom, '') + + '|^' + + this.weekdaysMin(mom, ''); + this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i'); + } + // test the regex + if ( + strict && + format === 'dddd' && + this._fullWeekdaysParse[i].test(weekdayName) + ) { + return i; + } else if ( + strict && + format === 'ddd' && + this._shortWeekdaysParse[i].test(weekdayName) + ) { + return i; + } else if ( + strict && + format === 'dd' && + this._minWeekdaysParse[i].test(weekdayName) + ) { + return i; + } else if (!strict && this._weekdaysParse[i].test(weekdayName)) { + return i; + } + } + } + + // MOMENTS + + function getSetDayOfWeek(input) { + if (!this.isValid()) { + return input != null ? this : NaN; + } + + var day = get(this, 'Day'); + if (input != null) { + input = parseWeekday(input, this.localeData()); + return this.add(input - day, 'd'); + } else { + return day; + } + } + + function getSetLocaleDayOfWeek(input) { + if (!this.isValid()) { + return input != null ? this : NaN; + } + var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7; + return input == null ? weekday : this.add(input - weekday, 'd'); + } + + function getSetISODayOfWeek(input) { + if (!this.isValid()) { + return input != null ? this : NaN; + } + + // behaves the same as moment#day except + // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6) + // as a setter, sunday should belong to the previous week. + + if (input != null) { + var weekday = parseIsoWeekday(input, this.localeData()); + return this.day(this.day() % 7 ? weekday : weekday - 7); + } else { + return this.day() || 7; + } + } + + function weekdaysRegex(isStrict) { + if (this._weekdaysParseExact) { + if (!hasOwnProp(this, '_weekdaysRegex')) { + computeWeekdaysParse.call(this); + } + if (isStrict) { + return this._weekdaysStrictRegex; + } else { + return this._weekdaysRegex; + } + } else { + if (!hasOwnProp(this, '_weekdaysRegex')) { + this._weekdaysRegex = defaultWeekdaysRegex; + } + return this._weekdaysStrictRegex && isStrict + ? this._weekdaysStrictRegex + : this._weekdaysRegex; + } + } + + function weekdaysShortRegex(isStrict) { + if (this._weekdaysParseExact) { + if (!hasOwnProp(this, '_weekdaysRegex')) { + computeWeekdaysParse.call(this); + } + if (isStrict) { + return this._weekdaysShortStrictRegex; + } else { + return this._weekdaysShortRegex; + } + } else { + if (!hasOwnProp(this, '_weekdaysShortRegex')) { + this._weekdaysShortRegex = defaultWeekdaysShortRegex; + } + return this._weekdaysShortStrictRegex && isStrict + ? this._weekdaysShortStrictRegex + : this._weekdaysShortRegex; + } + } + + function weekdaysMinRegex(isStrict) { + if (this._weekdaysParseExact) { + if (!hasOwnProp(this, '_weekdaysRegex')) { + computeWeekdaysParse.call(this); + } + if (isStrict) { + return this._weekdaysMinStrictRegex; + } else { + return this._weekdaysMinRegex; + } + } else { + if (!hasOwnProp(this, '_weekdaysMinRegex')) { + this._weekdaysMinRegex = defaultWeekdaysMinRegex; + } + return this._weekdaysMinStrictRegex && isStrict + ? this._weekdaysMinStrictRegex + : this._weekdaysMinRegex; + } + } + + function computeWeekdaysParse() { + function cmpLenRev(a, b) { + return b.length - a.length; + } + + var minPieces = [], + shortPieces = [], + longPieces = [], + mixedPieces = [], + i, + mom, + minp, + shortp, + longp; + for (i = 0; i < 7; i++) { + // make the regex if we don't have it already + mom = createUTC([2000, 1]).day(i); + minp = regexEscape(this.weekdaysMin(mom, '')); + shortp = regexEscape(this.weekdaysShort(mom, '')); + longp = regexEscape(this.weekdays(mom, '')); + minPieces.push(minp); + shortPieces.push(shortp); + longPieces.push(longp); + mixedPieces.push(minp); + mixedPieces.push(shortp); + mixedPieces.push(longp); + } + // Sorting makes sure if one weekday (or abbr) is a prefix of another it + // will match the longer piece. + minPieces.sort(cmpLenRev); + shortPieces.sort(cmpLenRev); + longPieces.sort(cmpLenRev); + mixedPieces.sort(cmpLenRev); + + this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); + this._weekdaysShortRegex = this._weekdaysRegex; + this._weekdaysMinRegex = this._weekdaysRegex; + + this._weekdaysStrictRegex = new RegExp( + '^(' + longPieces.join('|') + ')', + 'i' + ); + this._weekdaysShortStrictRegex = new RegExp( + '^(' + shortPieces.join('|') + ')', + 'i' + ); + this._weekdaysMinStrictRegex = new RegExp( + '^(' + minPieces.join('|') + ')', + 'i' + ); + } + + // FORMATTING + + function hFormat() { + return this.hours() % 12 || 12; + } + + function kFormat() { + return this.hours() || 24; + } + + addFormatToken('H', ['HH', 2], 0, 'hour'); + addFormatToken('h', ['hh', 2], 0, hFormat); + addFormatToken('k', ['kk', 2], 0, kFormat); + + addFormatToken('hmm', 0, 0, function () { + return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2); + }); + + addFormatToken('hmmss', 0, 0, function () { + return ( + '' + + hFormat.apply(this) + + zeroFill(this.minutes(), 2) + + zeroFill(this.seconds(), 2) + ); + }); + + addFormatToken('Hmm', 0, 0, function () { + return '' + this.hours() + zeroFill(this.minutes(), 2); + }); + + addFormatToken('Hmmss', 0, 0, function () { + return ( + '' + + this.hours() + + zeroFill(this.minutes(), 2) + + zeroFill(this.seconds(), 2) + ); + }); + + function meridiem(token, lowercase) { + addFormatToken(token, 0, 0, function () { + return this.localeData().meridiem( + this.hours(), + this.minutes(), + lowercase + ); + }); + } + + meridiem('a', true); + meridiem('A', false); + + // PARSING + + function matchMeridiem(isStrict, locale) { + return locale._meridiemParse; + } + + addRegexToken('a', matchMeridiem); + addRegexToken('A', matchMeridiem); + addRegexToken('H', match1to2, match1to2HasZero); + addRegexToken('h', match1to2, match1to2NoLeadingZero); + addRegexToken('k', match1to2, match1to2NoLeadingZero); + addRegexToken('HH', match1to2, match2); + addRegexToken('hh', match1to2, match2); + addRegexToken('kk', match1to2, match2); + + addRegexToken('hmm', match3to4); + addRegexToken('hmmss', match5to6); + addRegexToken('Hmm', match3to4); + addRegexToken('Hmmss', match5to6); + + addParseToken(['H', 'HH'], HOUR); + addParseToken(['k', 'kk'], function (input, array, config) { + var kInput = toInt(input); + array[HOUR] = kInput === 24 ? 0 : kInput; + }); + addParseToken(['a', 'A'], function (input, array, config) { + config._isPm = config._locale.isPM(input); + config._meridiem = input; + }); + addParseToken(['h', 'hh'], function (input, array, config) { + array[HOUR] = toInt(input); + getParsingFlags(config).bigHour = true; + }); + addParseToken('hmm', function (input, array, config) { + var pos = input.length - 2; + array[HOUR] = toInt(input.substr(0, pos)); + array[MINUTE] = toInt(input.substr(pos)); + getParsingFlags(config).bigHour = true; + }); + addParseToken('hmmss', function (input, array, config) { + var pos1 = input.length - 4, + pos2 = input.length - 2; + array[HOUR] = toInt(input.substr(0, pos1)); + array[MINUTE] = toInt(input.substr(pos1, 2)); + array[SECOND] = toInt(input.substr(pos2)); + getParsingFlags(config).bigHour = true; + }); + addParseToken('Hmm', function (input, array, config) { + var pos = input.length - 2; + array[HOUR] = toInt(input.substr(0, pos)); + array[MINUTE] = toInt(input.substr(pos)); + }); + addParseToken('Hmmss', function (input, array, config) { + var pos1 = input.length - 4, + pos2 = input.length - 2; + array[HOUR] = toInt(input.substr(0, pos1)); + array[MINUTE] = toInt(input.substr(pos1, 2)); + array[SECOND] = toInt(input.substr(pos2)); + }); + + // LOCALES + + function localeIsPM(input) { + // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays + // Using charAt should be more compatible. + return (input + '').toLowerCase().charAt(0) === 'p'; + } + + var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i, + // Setting the hour should keep the time, because the user explicitly + // specified which hour they want. So trying to maintain the same hour (in + // a new timezone) makes sense. Adding/subtracting hours does not follow + // this rule. + getSetHour = makeGetSet('Hours', true); + + function localeMeridiem(hours, minutes, isLower) { + if (hours > 11) { + return isLower ? 'pm' : 'PM'; + } else { + return isLower ? 'am' : 'AM'; + } + } + + var baseConfig = { + calendar: defaultCalendar, + longDateFormat: defaultLongDateFormat, + invalidDate: defaultInvalidDate, + ordinal: defaultOrdinal, + dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse, + relativeTime: defaultRelativeTime, + + months: defaultLocaleMonths, + monthsShort: defaultLocaleMonthsShort, + + week: defaultLocaleWeek, + + weekdays: defaultLocaleWeekdays, + weekdaysMin: defaultLocaleWeekdaysMin, + weekdaysShort: defaultLocaleWeekdaysShort, + + meridiemParse: defaultLocaleMeridiemParse, + }; + + // internal storage for locale config files + var locales = {}, + localeFamilies = {}, + globalLocale; + + function commonPrefix(arr1, arr2) { + var i, + minl = Math.min(arr1.length, arr2.length); + for (i = 0; i < minl; i += 1) { + if (arr1[i] !== arr2[i]) { + return i; + } + } + return minl; + } + + function normalizeLocale(key) { + return key ? key.toLowerCase().replace('_', '-') : key; + } + + // pick the locale from the array + // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each + // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root + function chooseLocale(names) { + var i = 0, + j, + next, + locale, + split; + + while (i < names.length) { + split = normalizeLocale(names[i]).split('-'); + j = split.length; + next = normalizeLocale(names[i + 1]); + next = next ? next.split('-') : null; + while (j > 0) { + locale = loadLocale(split.slice(0, j).join('-')); + if (locale) { + return locale; + } + if ( + next && + next.length >= j && + commonPrefix(split, next) >= j - 1 + ) { + //the next array item is better than a shallower substring of this one + break; + } + j--; + } + i++; + } + return globalLocale; + } + + function isLocaleNameSane(name) { + // Prevent names that look like filesystem paths, i.e contain '/' or '\' + // Ensure name is available and function returns boolean + return !!(name && name.match('^[^/\\\\]*$')); + } + + function loadLocale(name) { + var oldLocale = null, + aliasedRequire; + // TODO: Find a better way to register and load all the locales in Node + if ( + locales[name] === undefined && + 'object' !== 'undefined' && + module && + module.exports && + isLocaleNameSane(name) + ) { + try { + oldLocale = globalLocale._abbr; + aliasedRequire = commonjsRequire; + aliasedRequire('./locale/' + name); + getSetGlobalLocale(oldLocale); + } catch (e) { + // mark as not found to avoid repeating expensive file require call causing high CPU + // when trying to find en-US, en_US, en-us for every format call + locales[name] = null; // null means not found + } + } + return locales[name]; + } + + // This function will load locale and then set the global locale. If + // no arguments are passed in, it will simply return the current global + // locale key. + function getSetGlobalLocale(key, values) { + var data; + if (key) { + if (isUndefined(values)) { + data = getLocale(key); + } else { + data = defineLocale(key, values); + } + + if (data) { + // moment.duration._locale = moment._locale = data; + globalLocale = data; + } else { + if (typeof console !== 'undefined' && console.warn) { + //warn user if arguments are passed but the locale could not be set + console.warn( + 'Locale ' + key + ' not found. Did you forget to load it?' + ); + } + } + } + + return globalLocale._abbr; + } + + function defineLocale(name, config) { + if (config !== null) { + var locale, + parentConfig = baseConfig; + config.abbr = name; + if (locales[name] != null) { + deprecateSimple( + 'defineLocaleOverride', + 'use moment.updateLocale(localeName, config) to change ' + + 'an existing locale. moment.defineLocale(localeName, ' + + 'config) should only be used for creating a new locale ' + + 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.' + ); + parentConfig = locales[name]._config; + } else if (config.parentLocale != null) { + if (locales[config.parentLocale] != null) { + parentConfig = locales[config.parentLocale]._config; + } else { + locale = loadLocale(config.parentLocale); + if (locale != null) { + parentConfig = locale._config; + } else { + if (!localeFamilies[config.parentLocale]) { + localeFamilies[config.parentLocale] = []; + } + localeFamilies[config.parentLocale].push({ + name: name, + config: config, + }); + return null; + } + } + } + locales[name] = new Locale(mergeConfigs(parentConfig, config)); + + if (localeFamilies[name]) { + localeFamilies[name].forEach(function (x) { + defineLocale(x.name, x.config); + }); + } + + // backwards compat for now: also set the locale + // make sure we set the locale AFTER all child locales have been + // created, so we won't end up with the child locale set. + getSetGlobalLocale(name); + + return locales[name]; + } else { + // useful for testing + delete locales[name]; + return null; + } + } + + function updateLocale(name, config) { + if (config != null) { + var locale, + tmpLocale, + parentConfig = baseConfig; + + if (locales[name] != null && locales[name].parentLocale != null) { + // Update existing child locale in-place to avoid memory-leaks + locales[name].set(mergeConfigs(locales[name]._config, config)); + } else { + // MERGE + tmpLocale = loadLocale(name); + if (tmpLocale != null) { + parentConfig = tmpLocale._config; + } + config = mergeConfigs(parentConfig, config); + if (tmpLocale == null) { + // updateLocale is called for creating a new locale + // Set abbr so it will have a name (getters return + // undefined otherwise). + config.abbr = name; + } + locale = new Locale(config); + locale.parentLocale = locales[name]; + locales[name] = locale; + } + + // backwards compat for now: also set the locale + getSetGlobalLocale(name); + } else { + // pass null for config to unupdate, useful for tests + if (locales[name] != null) { + if (locales[name].parentLocale != null) { + locales[name] = locales[name].parentLocale; + if (name === getSetGlobalLocale()) { + getSetGlobalLocale(name); + } + } else if (locales[name] != null) { + delete locales[name]; + } + } + } + return locales[name]; + } + + // returns locale data + function getLocale(key) { + var locale; + + if (key && key._locale && key._locale._abbr) { + key = key._locale._abbr; + } + + if (!key) { + return globalLocale; + } + + if (!isArray(key)) { + //short-circuit everything else + locale = loadLocale(key); + if (locale) { + return locale; + } + key = [key]; + } + + return chooseLocale(key); + } + + function listLocales() { + return keys(locales); + } + + function checkOverflow(m) { + var overflow, + a = m._a; + + if (a && getParsingFlags(m).overflow === -2) { + overflow = + a[MONTH] < 0 || a[MONTH] > 11 + ? MONTH + : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) + ? DATE + : a[HOUR] < 0 || + a[HOUR] > 24 || + (a[HOUR] === 24 && + (a[MINUTE] !== 0 || + a[SECOND] !== 0 || + a[MILLISECOND] !== 0)) + ? HOUR + : a[MINUTE] < 0 || a[MINUTE] > 59 + ? MINUTE + : a[SECOND] < 0 || a[SECOND] > 59 + ? SECOND + : a[MILLISECOND] < 0 || a[MILLISECOND] > 999 + ? MILLISECOND + : -1; + + if ( + getParsingFlags(m)._overflowDayOfYear && + (overflow < YEAR || overflow > DATE) + ) { + overflow = DATE; + } + if (getParsingFlags(m)._overflowWeeks && overflow === -1) { + overflow = WEEK; + } + if (getParsingFlags(m)._overflowWeekday && overflow === -1) { + overflow = WEEKDAY; + } + + getParsingFlags(m).overflow = overflow; + } + + return m; + } + + // iso 8601 regex + // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00) + var extendedIsoRegex = + /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/, + basicIsoRegex = + /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/, + tzRegex = /Z|[+-]\d\d(?::?\d\d)?/, + isoDates = [ + ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/], + ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/], + ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/], + ['GGGG-[W]WW', /\d{4}-W\d\d/, false], + ['YYYY-DDD', /\d{4}-\d{3}/], + ['YYYY-MM', /\d{4}-\d\d/, false], + ['YYYYYYMMDD', /[+-]\d{10}/], + ['YYYYMMDD', /\d{8}/], + ['GGGG[W]WWE', /\d{4}W\d{3}/], + ['GGGG[W]WW', /\d{4}W\d{2}/, false], + ['YYYYDDD', /\d{7}/], + ['YYYYMM', /\d{6}/, false], + ['YYYY', /\d{4}/, false], + ], + // iso time formats and regexes + isoTimes = [ + ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], + ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/], + ['HH:mm:ss', /\d\d:\d\d:\d\d/], + ['HH:mm', /\d\d:\d\d/], + ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/], + ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/], + ['HHmmss', /\d\d\d\d\d\d/], + ['HHmm', /\d\d\d\d/], + ['HH', /\d\d/], + ], + aspNetJsonRegex = /^\/?Date\((-?\d+)/i, + // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3 + rfc2822 = + /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/, + obsOffsets = { + UT: 0, + GMT: 0, + EDT: -4 * 60, + EST: -5 * 60, + CDT: -5 * 60, + CST: -6 * 60, + MDT: -6 * 60, + MST: -7 * 60, + PDT: -7 * 60, + PST: -8 * 60, + }; + + // date from iso format + function configFromISO(config) { + var i, + l, + string = config._i, + match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string), + allowTime, + dateFormat, + timeFormat, + tzFormat, + isoDatesLen = isoDates.length, + isoTimesLen = isoTimes.length; + + if (match) { + getParsingFlags(config).iso = true; + for (i = 0, l = isoDatesLen; i < l; i++) { + if (isoDates[i][1].exec(match[1])) { + dateFormat = isoDates[i][0]; + allowTime = isoDates[i][2] !== false; + break; + } + } + if (dateFormat == null) { + config._isValid = false; + return; + } + if (match[3]) { + for (i = 0, l = isoTimesLen; i < l; i++) { + if (isoTimes[i][1].exec(match[3])) { + // match[2] should be 'T' or space + timeFormat = (match[2] || ' ') + isoTimes[i][0]; + break; + } + } + if (timeFormat == null) { + config._isValid = false; + return; + } + } + if (!allowTime && timeFormat != null) { + config._isValid = false; + return; + } + if (match[4]) { + if (tzRegex.exec(match[4])) { + tzFormat = 'Z'; + } else { + config._isValid = false; + return; + } + } + config._f = dateFormat + (timeFormat || '') + (tzFormat || ''); + configFromStringAndFormat(config); + } else { + config._isValid = false; + } + } + + function extractFromRFC2822Strings( + yearStr, + monthStr, + dayStr, + hourStr, + minuteStr, + secondStr + ) { + var result = [ + untruncateYear(yearStr), + defaultLocaleMonthsShort.indexOf(monthStr), + parseInt(dayStr, 10), + parseInt(hourStr, 10), + parseInt(minuteStr, 10), + ]; + + if (secondStr) { + result.push(parseInt(secondStr, 10)); + } + + return result; + } + + function untruncateYear(yearStr) { + var year = parseInt(yearStr, 10); + if (year <= 49) { + return 2000 + year; + } else if (year <= 999) { + return 1900 + year; + } + return year; + } + + function preprocessRFC2822(s) { + // Remove comments and folding whitespace and replace multiple-spaces with a single space + return s + .replace(/\([^()]*\)|[\n\t]/g, ' ') + .replace(/(\s\s+)/g, ' ') + .replace(/^\s\s*/, '') + .replace(/\s\s*$/, ''); + } + + function checkWeekday(weekdayStr, parsedInput, config) { + if (weekdayStr) { + // TODO: Replace the vanilla JS Date object with an independent day-of-week check. + var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr), + weekdayActual = new Date( + parsedInput[0], + parsedInput[1], + parsedInput[2] + ).getDay(); + if (weekdayProvided !== weekdayActual) { + getParsingFlags(config).weekdayMismatch = true; + config._isValid = false; + return false; + } + } + return true; + } + + function calculateOffset(obsOffset, militaryOffset, numOffset) { + if (obsOffset) { + return obsOffsets[obsOffset]; + } else if (militaryOffset) { + // the only allowed military tz is Z + return 0; + } else { + var hm = parseInt(numOffset, 10), + m = hm % 100, + h = (hm - m) / 100; + return h * 60 + m; + } + } + + // date and time from ref 2822 format + function configFromRFC2822(config) { + var match = rfc2822.exec(preprocessRFC2822(config._i)), + parsedArray; + if (match) { + parsedArray = extractFromRFC2822Strings( + match[4], + match[3], + match[2], + match[5], + match[6], + match[7] + ); + if (!checkWeekday(match[1], parsedArray, config)) { + return; + } + + config._a = parsedArray; + config._tzm = calculateOffset(match[8], match[9], match[10]); + + config._d = createUTCDate.apply(null, config._a); + config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm); + + getParsingFlags(config).rfc2822 = true; + } else { + config._isValid = false; + } + } + + // date from 1) ASP.NET, 2) ISO, 3) RFC 2822 formats, or 4) optional fallback if parsing isn't strict + function configFromString(config) { + var matched = aspNetJsonRegex.exec(config._i); + if (matched !== null) { + config._d = new Date(+matched[1]); + return; + } + + configFromISO(config); + if (config._isValid === false) { + delete config._isValid; + } else { + return; + } + + configFromRFC2822(config); + if (config._isValid === false) { + delete config._isValid; + } else { + return; + } + + if (config._strict) { + config._isValid = false; + } else { + // Final attempt, use Input Fallback + hooks.createFromInputFallback(config); + } + } + + hooks.createFromInputFallback = deprecate( + 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' + + 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' + + 'discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.', + function (config) { + config._d = new Date(config._i + (config._useUTC ? ' UTC' : '')); + } + ); + + // Pick the first defined of two or three arguments. + function defaults(a, b, c) { + if (a != null) { + return a; + } + if (b != null) { + return b; + } + return c; + } + + function currentDateArray(config) { + // hooks is actually the exported moment object + var nowValue = new Date(hooks.now()); + if (config._useUTC) { + return [ + nowValue.getUTCFullYear(), + nowValue.getUTCMonth(), + nowValue.getUTCDate(), + ]; + } + return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()]; + } + + // convert an array to a date. + // the array should mirror the parameters below + // note: all values past the year are optional and will default to the lowest possible value. + // [year, month, day , hour, minute, second, millisecond] + function configFromArray(config) { + var i, + date, + input = [], + currentDate, + expectedWeekday, + yearToUse; + + if (config._d) { + return; + } + + currentDate = currentDateArray(config); + + //compute day of the year from weeks and weekdays + if (config._w && config._a[DATE] == null && config._a[MONTH] == null) { + dayOfYearFromWeekInfo(config); + } + + //if the day of the year is set, figure out what it is + if (config._dayOfYear != null) { + yearToUse = defaults(config._a[YEAR], currentDate[YEAR]); + + if ( + config._dayOfYear > daysInYear(yearToUse) || + config._dayOfYear === 0 + ) { + getParsingFlags(config)._overflowDayOfYear = true; + } + + date = createUTCDate(yearToUse, 0, config._dayOfYear); + config._a[MONTH] = date.getUTCMonth(); + config._a[DATE] = date.getUTCDate(); + } + + // Default to current date. + // * if no year, month, day of month are given, default to today + // * if day of month is given, default month and year + // * if month is given, default only year + // * if year is given, don't default anything + for (i = 0; i < 3 && config._a[i] == null; ++i) { + config._a[i] = input[i] = currentDate[i]; + } + + // Zero out whatever was not defaulted, including time + for (; i < 7; i++) { + config._a[i] = input[i] = + config._a[i] == null ? (i === 2 ? 1 : 0) : config._a[i]; + } + + // Check for 24:00:00.000 + if ( + config._a[HOUR] === 24 && + config._a[MINUTE] === 0 && + config._a[SECOND] === 0 && + config._a[MILLISECOND] === 0 + ) { + config._nextDay = true; + config._a[HOUR] = 0; + } + + config._d = (config._useUTC ? createUTCDate : createDate).apply( + null, + input + ); + expectedWeekday = config._useUTC + ? config._d.getUTCDay() + : config._d.getDay(); + + // Apply timezone offset from input. The actual utcOffset can be changed + // with parseZone. + if (config._tzm != null) { + config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm); + } + + if (config._nextDay) { + config._a[HOUR] = 24; + } + + // check for mismatching day of week + if ( + config._w && + typeof config._w.d !== 'undefined' && + config._w.d !== expectedWeekday + ) { + getParsingFlags(config).weekdayMismatch = true; + } + } + + function dayOfYearFromWeekInfo(config) { + var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek; + + w = config._w; + if (w.GG != null || w.W != null || w.E != null) { + dow = 1; + doy = 4; + + // TODO: We need to take the current isoWeekYear, but that depends on + // how we interpret now (local, utc, fixed offset). So create + // a now version of current config (take local/utc/offset flags, and + // create now). + weekYear = defaults( + w.GG, + config._a[YEAR], + weekOfYear(createLocal(), 1, 4).year + ); + week = defaults(w.W, 1); + weekday = defaults(w.E, 1); + if (weekday < 1 || weekday > 7) { + weekdayOverflow = true; + } + } else { + dow = config._locale._week.dow; + doy = config._locale._week.doy; + + curWeek = weekOfYear(createLocal(), dow, doy); + + weekYear = defaults(w.gg, config._a[YEAR], curWeek.year); + + // Default to current week. + week = defaults(w.w, curWeek.week); + + if (w.d != null) { + // weekday -- low day numbers are considered next week + weekday = w.d; + if (weekday < 0 || weekday > 6) { + weekdayOverflow = true; + } + } else if (w.e != null) { + // local weekday -- counting starts from beginning of week + weekday = w.e + dow; + if (w.e < 0 || w.e > 6) { + weekdayOverflow = true; + } + } else { + // default to beginning of week + weekday = dow; + } + } + if (week < 1 || week > weeksInYear(weekYear, dow, doy)) { + getParsingFlags(config)._overflowWeeks = true; + } else if (weekdayOverflow != null) { + getParsingFlags(config)._overflowWeekday = true; + } else { + temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy); + config._a[YEAR] = temp.year; + config._dayOfYear = temp.dayOfYear; + } + } + + // constant that refers to the ISO standard + hooks.ISO_8601 = function () {}; + + // constant that refers to the RFC 2822 form + hooks.RFC_2822 = function () {}; + + // date from string and format string + function configFromStringAndFormat(config) { + // TODO: Move this to another part of the creation flow to prevent circular deps + if (config._f === hooks.ISO_8601) { + configFromISO(config); + return; + } + if (config._f === hooks.RFC_2822) { + configFromRFC2822(config); + return; + } + config._a = []; + getParsingFlags(config).empty = true; + + // This array is used to make a Date, either with `new Date` or `Date.UTC` + var string = '' + config._i, + i, + parsedInput, + tokens, + token, + skipped, + stringLength = string.length, + totalParsedInputLength = 0, + era, + tokenLen; + + tokens = + expandFormat(config._f, config._locale).match(formattingTokens) || []; + tokenLen = tokens.length; + for (i = 0; i < tokenLen; i++) { + token = tokens[i]; + parsedInput = (string.match(getParseRegexForToken(token, config)) || + [])[0]; + if (parsedInput) { + skipped = string.substr(0, string.indexOf(parsedInput)); + if (skipped.length > 0) { + getParsingFlags(config).unusedInput.push(skipped); + } + string = string.slice( + string.indexOf(parsedInput) + parsedInput.length + ); + totalParsedInputLength += parsedInput.length; + } + // don't parse if it's not a known token + if (formatTokenFunctions[token]) { + if (parsedInput) { + getParsingFlags(config).empty = false; + } else { + getParsingFlags(config).unusedTokens.push(token); + } + addTimeToArrayFromToken(token, parsedInput, config); + } else if (config._strict && !parsedInput) { + getParsingFlags(config).unusedTokens.push(token); + } + } + + // add remaining unparsed input length to the string + getParsingFlags(config).charsLeftOver = + stringLength - totalParsedInputLength; + if (string.length > 0) { + getParsingFlags(config).unusedInput.push(string); + } + + // clear _12h flag if hour is <= 12 + if ( + config._a[HOUR] <= 12 && + getParsingFlags(config).bigHour === true && + config._a[HOUR] > 0 + ) { + getParsingFlags(config).bigHour = undefined; + } + + getParsingFlags(config).parsedDateParts = config._a.slice(0); + getParsingFlags(config).meridiem = config._meridiem; + // handle meridiem + config._a[HOUR] = meridiemFixWrap( + config._locale, + config._a[HOUR], + config._meridiem + ); + + // handle era + era = getParsingFlags(config).era; + if (era !== null) { + config._a[YEAR] = config._locale.erasConvertYear(era, config._a[YEAR]); + } + + configFromArray(config); + checkOverflow(config); + } + + function meridiemFixWrap(locale, hour, meridiem) { + var isPm; + + if (meridiem == null) { + // nothing to do + return hour; + } + if (locale.meridiemHour != null) { + return locale.meridiemHour(hour, meridiem); + } else if (locale.isPM != null) { + // Fallback + isPm = locale.isPM(meridiem); + if (isPm && hour < 12) { + hour += 12; + } + if (!isPm && hour === 12) { + hour = 0; + } + return hour; + } else { + // this is not supposed to happen + return hour; + } + } + + // date from string and array of format strings + function configFromStringAndArray(config) { + var tempConfig, + bestMoment, + scoreToBeat, + i, + currentScore, + validFormatFound, + bestFormatIsValid = false, + configfLen = config._f.length; + + if (configfLen === 0) { + getParsingFlags(config).invalidFormat = true; + config._d = new Date(NaN); + return; + } + + for (i = 0; i < configfLen; i++) { + currentScore = 0; + validFormatFound = false; + tempConfig = copyConfig({}, config); + if (config._useUTC != null) { + tempConfig._useUTC = config._useUTC; + } + tempConfig._f = config._f[i]; + configFromStringAndFormat(tempConfig); + + if (isValid(tempConfig)) { + validFormatFound = true; + } + + // if there is any input that was not parsed add a penalty for that format + currentScore += getParsingFlags(tempConfig).charsLeftOver; + + //or tokens + currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10; + + getParsingFlags(tempConfig).score = currentScore; + + if (!bestFormatIsValid) { + if ( + scoreToBeat == null || + currentScore < scoreToBeat || + validFormatFound + ) { + scoreToBeat = currentScore; + bestMoment = tempConfig; + if (validFormatFound) { + bestFormatIsValid = true; + } + } + } else { + if (currentScore < scoreToBeat) { + scoreToBeat = currentScore; + bestMoment = tempConfig; + } + } + } + + extend(config, bestMoment || tempConfig); + } + + function configFromObject(config) { + if (config._d) { + return; + } + + var i = normalizeObjectUnits(config._i), + dayOrDate = i.day === undefined ? i.date : i.day; + config._a = map( + [i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond], + function (obj) { + return obj && parseInt(obj, 10); + } + ); + + configFromArray(config); + } + + function createFromConfig(config) { + var res = new Moment(checkOverflow(prepareConfig(config))); + if (res._nextDay) { + // Adding is smart enough around DST + res.add(1, 'd'); + res._nextDay = undefined; + } + + return res; + } + + function prepareConfig(config) { + var input = config._i, + format = config._f; + + config._locale = config._locale || getLocale(config._l); + + if (input === null || (format === undefined && input === '')) { + return createInvalid({ nullInput: true }); + } + + if (typeof input === 'string') { + config._i = input = config._locale.preparse(input); + } + + if (isMoment(input)) { + return new Moment(checkOverflow(input)); + } else if (isDate(input)) { + config._d = input; + } else if (isArray(format)) { + configFromStringAndArray(config); + } else if (format) { + configFromStringAndFormat(config); + } else { + configFromInput(config); + } + + if (!isValid(config)) { + config._d = null; + } + + return config; + } + + function configFromInput(config) { + var input = config._i; + if (isUndefined(input)) { + config._d = new Date(hooks.now()); + } else if (isDate(input)) { + config._d = new Date(input.valueOf()); + } else if (typeof input === 'string') { + configFromString(config); + } else if (isArray(input)) { + config._a = map(input.slice(0), function (obj) { + return parseInt(obj, 10); + }); + configFromArray(config); + } else if (isObject(input)) { + configFromObject(config); + } else if (isNumber(input)) { + // from milliseconds + config._d = new Date(input); + } else { + hooks.createFromInputFallback(config); + } + } + + function createLocalOrUTC(input, format, locale, strict, isUTC) { + var c = {}; + + if (format === true || format === false) { + strict = format; + format = undefined; + } + + if (locale === true || locale === false) { + strict = locale; + locale = undefined; + } + + if ( + (isObject(input) && isObjectEmpty(input)) || + (isArray(input) && input.length === 0) + ) { + input = undefined; + } + // object construction must be done this way. + // https://github.com/moment/moment/issues/1423 + c._isAMomentObject = true; + c._useUTC = c._isUTC = isUTC; + c._l = locale; + c._i = input; + c._f = format; + c._strict = strict; + + return createFromConfig(c); + } + + function createLocal(input, format, locale, strict) { + return createLocalOrUTC(input, format, locale, strict, false); + } + + var prototypeMin = deprecate( + 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/', + function () { + var other = createLocal.apply(null, arguments); + if (this.isValid() && other.isValid()) { + return other < this ? this : other; + } else { + return createInvalid(); + } + } + ), + prototypeMax = deprecate( + 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/', + function () { + var other = createLocal.apply(null, arguments); + if (this.isValid() && other.isValid()) { + return other > this ? this : other; + } else { + return createInvalid(); + } + } + ); + + // Pick a moment m from moments so that m[fn](other) is true for all + // other. This relies on the function fn to be transitive. + // + // moments should either be an array of moment objects or an array, whose + // first element is an array of moment objects. + function pickBy(fn, moments) { + var res, i; + if (moments.length === 1 && isArray(moments[0])) { + moments = moments[0]; + } + if (!moments.length) { + return createLocal(); + } + res = moments[0]; + for (i = 1; i < moments.length; ++i) { + if (!moments[i].isValid() || moments[i][fn](res)) { + res = moments[i]; + } + } + return res; + } + + // TODO: Use [].sort instead? + function min() { + var args = [].slice.call(arguments, 0); + + return pickBy('isBefore', args); + } + + function max() { + var args = [].slice.call(arguments, 0); + + return pickBy('isAfter', args); + } + + var now = function () { + return Date.now ? Date.now() : +new Date(); + }; + + var ordering = [ + 'year', + 'quarter', + 'month', + 'week', + 'day', + 'hour', + 'minute', + 'second', + 'millisecond', + ]; + + function isDurationValid(m) { + var key, + unitHasDecimal = false, + i, + orderLen = ordering.length; + for (key in m) { + if ( + hasOwnProp(m, key) && + !( + indexOf.call(ordering, key) !== -1 && + (m[key] == null || !isNaN(m[key])) + ) + ) { + return false; + } + } + + for (i = 0; i < orderLen; ++i) { + if (m[ordering[i]]) { + if (unitHasDecimal) { + return false; // only allow non-integers for smallest unit + } + if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) { + unitHasDecimal = true; + } + } + } + + return true; + } + + function isValid$1() { + return this._isValid; + } + + function createInvalid$1() { + return createDuration(NaN); + } + + function Duration(duration) { + var normalizedInput = normalizeObjectUnits(duration), + years = normalizedInput.year || 0, + quarters = normalizedInput.quarter || 0, + months = normalizedInput.month || 0, + weeks = normalizedInput.week || normalizedInput.isoWeek || 0, + days = normalizedInput.day || 0, + hours = normalizedInput.hour || 0, + minutes = normalizedInput.minute || 0, + seconds = normalizedInput.second || 0, + milliseconds = normalizedInput.millisecond || 0; + + this._isValid = isDurationValid(normalizedInput); + + // representation for dateAddRemove + this._milliseconds = + +milliseconds + + seconds * 1e3 + // 1000 + minutes * 6e4 + // 1000 * 60 + hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978 + // Because of dateAddRemove treats 24 hours as different from a + // day when working around DST, we need to store them separately + this._days = +days + weeks * 7; + // It is impossible to translate months into days without knowing + // which months you are are talking about, so we have to store + // it separately. + this._months = +months + quarters * 3 + years * 12; + + this._data = {}; + + this._locale = getLocale(); + + this._bubble(); + } + + function isDuration(obj) { + return obj instanceof Duration; + } + + function absRound(number) { + if (number < 0) { + return Math.round(-1 * number) * -1; + } else { + return Math.round(number); + } + } + + // compare two arrays, return the number of differences + function compareArrays(array1, array2, dontConvert) { + var len = Math.min(array1.length, array2.length), + lengthDiff = Math.abs(array1.length - array2.length), + diffs = 0, + i; + for (i = 0; i < len; i++) { + if ( + (dontConvert && array1[i] !== array2[i]) || + (!dontConvert && toInt(array1[i]) !== toInt(array2[i])) + ) { + diffs++; + } + } + return diffs + lengthDiff; + } + + // FORMATTING + + function offset(token, separator) { + addFormatToken(token, 0, 0, function () { + var offset = this.utcOffset(), + sign = '+'; + if (offset < 0) { + offset = -offset; + sign = '-'; + } + return ( + sign + + zeroFill(~~(offset / 60), 2) + + separator + + zeroFill(~~offset % 60, 2) + ); + }); + } + + offset('Z', ':'); + offset('ZZ', ''); + + // PARSING + + addRegexToken('Z', matchShortOffset); + addRegexToken('ZZ', matchShortOffset); + addParseToken(['Z', 'ZZ'], function (input, array, config) { + config._useUTC = true; + config._tzm = offsetFromString(matchShortOffset, input); + }); + + // HELPERS + + // timezone chunker + // '+10:00' > ['10', '00'] + // '-1530' > ['-15', '30'] + var chunkOffset = /([\+\-]|\d\d)/gi; + + function offsetFromString(matcher, string) { + var matches = (string || '').match(matcher), + chunk, + parts, + minutes; + + if (matches === null) { + return null; + } + + chunk = matches[matches.length - 1] || []; + parts = (chunk + '').match(chunkOffset) || ['-', 0, 0]; + minutes = +(parts[1] * 60) + toInt(parts[2]); + + return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes; + } + + // Return a moment from input, that is local/utc/zone equivalent to model. + function cloneWithOffset(input, model) { + var res, diff; + if (model._isUTC) { + res = model.clone(); + diff = + (isMoment(input) || isDate(input) + ? input.valueOf() + : createLocal(input).valueOf()) - res.valueOf(); + // Use low-level api, because this fn is low-level api. + res._d.setTime(res._d.valueOf() + diff); + hooks.updateOffset(res, false); + return res; + } else { + return createLocal(input).local(); + } + } + + function getDateOffset(m) { + // On Firefox.24 Date#getTimezoneOffset returns a floating point. + // https://github.com/moment/moment/pull/1871 + return -Math.round(m._d.getTimezoneOffset()); + } + + // HOOKS + + // This function will be called whenever a moment is mutated. + // It is intended to keep the offset in sync with the timezone. + hooks.updateOffset = function () {}; + + // MOMENTS + + // keepLocalTime = true means only change the timezone, without + // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]--> + // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset + // +0200, so we adjust the time as needed, to be valid. + // + // Keeping the time actually adds/subtracts (one hour) + // from the actual represented time. That is why we call updateOffset + // a second time. In case it wants us to change the offset again + // _changeInProgress == true case, then we have to adjust, because + // there is no such time in the given timezone. + function getSetOffset(input, keepLocalTime, keepMinutes) { + var offset = this._offset || 0, + localAdjust; + if (!this.isValid()) { + return input != null ? this : NaN; + } + if (input != null) { + if (typeof input === 'string') { + input = offsetFromString(matchShortOffset, input); + if (input === null) { + return this; + } + } else if (Math.abs(input) < 16 && !keepMinutes) { + input = input * 60; + } + if (!this._isUTC && keepLocalTime) { + localAdjust = getDateOffset(this); + } + this._offset = input; + this._isUTC = true; + if (localAdjust != null) { + this.add(localAdjust, 'm'); + } + if (offset !== input) { + if (!keepLocalTime || this._changeInProgress) { + addSubtract( + this, + createDuration(input - offset, 'm'), + 1, + false + ); + } else if (!this._changeInProgress) { + this._changeInProgress = true; + hooks.updateOffset(this, true); + this._changeInProgress = null; + } + } + return this; + } else { + return this._isUTC ? offset : getDateOffset(this); + } + } + + function getSetZone(input, keepLocalTime) { + if (input != null) { + if (typeof input !== 'string') { + input = -input; + } + + this.utcOffset(input, keepLocalTime); + + return this; + } else { + return -this.utcOffset(); + } + } + + function setOffsetToUTC(keepLocalTime) { + return this.utcOffset(0, keepLocalTime); + } + + function setOffsetToLocal(keepLocalTime) { + if (this._isUTC) { + this.utcOffset(0, keepLocalTime); + this._isUTC = false; + + if (keepLocalTime) { + this.subtract(getDateOffset(this), 'm'); + } + } + return this; + } + + function setOffsetToParsedOffset() { + if (this._tzm != null) { + this.utcOffset(this._tzm, false, true); + } else if (typeof this._i === 'string') { + var tZone = offsetFromString(matchOffset, this._i); + if (tZone != null) { + this.utcOffset(tZone); + } else { + this.utcOffset(0, true); + } + } + return this; + } + + function hasAlignedHourOffset(input) { + if (!this.isValid()) { + return false; + } + input = input ? createLocal(input).utcOffset() : 0; + + return (this.utcOffset() - input) % 60 === 0; + } + + function isDaylightSavingTime() { + return ( + this.utcOffset() > this.clone().month(0).utcOffset() || + this.utcOffset() > this.clone().month(5).utcOffset() + ); + } + + function isDaylightSavingTimeShifted() { + if (!isUndefined(this._isDSTShifted)) { + return this._isDSTShifted; + } + + var c = {}, + other; + + copyConfig(c, this); + c = prepareConfig(c); + + if (c._a) { + other = c._isUTC ? createUTC(c._a) : createLocal(c._a); + this._isDSTShifted = + this.isValid() && compareArrays(c._a, other.toArray()) > 0; + } else { + this._isDSTShifted = false; + } + + return this._isDSTShifted; + } + + function isLocal() { + return this.isValid() ? !this._isUTC : false; + } + + function isUtcOffset() { + return this.isValid() ? this._isUTC : false; + } + + function isUtc() { + return this.isValid() ? this._isUTC && this._offset === 0 : false; + } + + // ASP.NET json date format regex + var aspNetRegex = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/, + // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html + // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere + // and further modified to allow for strings containing both week and day + isoRegex = + /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/; + + function createDuration(input, key) { + var duration = input, + // matching against regexp is expensive, do it on demand + match = null, + sign, + ret, + diffRes; + + if (isDuration(input)) { + duration = { + ms: input._milliseconds, + d: input._days, + M: input._months, + }; + } else if (isNumber(input) || !isNaN(+input)) { + duration = {}; + if (key) { + duration[key] = +input; + } else { + duration.milliseconds = +input; + } + } else if ((match = aspNetRegex.exec(input))) { + sign = match[1] === '-' ? -1 : 1; + duration = { + y: 0, + d: toInt(match[DATE]) * sign, + h: toInt(match[HOUR]) * sign, + m: toInt(match[MINUTE]) * sign, + s: toInt(match[SECOND]) * sign, + ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign, // the millisecond decimal point is included in the match + }; + } else if ((match = isoRegex.exec(input))) { + sign = match[1] === '-' ? -1 : 1; + duration = { + y: parseIso(match[2], sign), + M: parseIso(match[3], sign), + w: parseIso(match[4], sign), + d: parseIso(match[5], sign), + h: parseIso(match[6], sign), + m: parseIso(match[7], sign), + s: parseIso(match[8], sign), + }; + } else if (duration == null) { + // checks for null or undefined + duration = {}; + } else if ( + typeof duration === 'object' && + ('from' in duration || 'to' in duration) + ) { + diffRes = momentsDifference( + createLocal(duration.from), + createLocal(duration.to) + ); + + duration = {}; + duration.ms = diffRes.milliseconds; + duration.M = diffRes.months; + } + + ret = new Duration(duration); + + if (isDuration(input) && hasOwnProp(input, '_locale')) { + ret._locale = input._locale; + } + + if (isDuration(input) && hasOwnProp(input, '_isValid')) { + ret._isValid = input._isValid; + } + + return ret; + } + + createDuration.fn = Duration.prototype; + createDuration.invalid = createInvalid$1; + + function parseIso(inp, sign) { + // We'd normally use ~~inp for this, but unfortunately it also + // converts floats to ints. + // inp may be undefined, so careful calling replace on it. + var res = inp && parseFloat(inp.replace(',', '.')); + // apply sign while we're at it + return (isNaN(res) ? 0 : res) * sign; + } + + function positiveMomentsDifference(base, other) { + var res = {}; + + res.months = + other.month() - base.month() + (other.year() - base.year()) * 12; + if (base.clone().add(res.months, 'M').isAfter(other)) { + --res.months; + } + + res.milliseconds = +other - +base.clone().add(res.months, 'M'); + + return res; + } + + function momentsDifference(base, other) { + var res; + if (!(base.isValid() && other.isValid())) { + return { milliseconds: 0, months: 0 }; + } + + other = cloneWithOffset(other, base); + if (base.isBefore(other)) { + res = positiveMomentsDifference(base, other); + } else { + res = positiveMomentsDifference(other, base); + res.milliseconds = -res.milliseconds; + res.months = -res.months; + } + + return res; + } + + // TODO: remove 'name' arg after deprecation is removed + function createAdder(direction, name) { + return function (val, period) { + var dur, tmp; + //invert the arguments, but complain about it + if (period !== null && !isNaN(+period)) { + deprecateSimple( + name, + 'moment().' + + name + + '(period, number) is deprecated. Please use moment().' + + name + + '(number, period). ' + + 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.' + ); + tmp = val; + val = period; + period = tmp; + } + + dur = createDuration(val, period); + addSubtract(this, dur, direction); + return this; + }; + } + + function addSubtract(mom, duration, isAdding, updateOffset) { + var milliseconds = duration._milliseconds, + days = absRound(duration._days), + months = absRound(duration._months); + + if (!mom.isValid()) { + // No op + return; + } + + updateOffset = updateOffset == null ? true : updateOffset; + + if (months) { + setMonth(mom, get(mom, 'Month') + months * isAdding); + } + if (days) { + set$1(mom, 'Date', get(mom, 'Date') + days * isAdding); + } + if (milliseconds) { + mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding); + } + if (updateOffset) { + hooks.updateOffset(mom, days || months); + } + } + + var add = createAdder(1, 'add'), + subtract = createAdder(-1, 'subtract'); + + function isString(input) { + return typeof input === 'string' || input instanceof String; + } + + // type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | void; // null | undefined + function isMomentInput(input) { + return ( + isMoment(input) || + isDate(input) || + isString(input) || + isNumber(input) || + isNumberOrStringArray(input) || + isMomentInputObject(input) || + input === null || + input === undefined + ); + } + + function isMomentInputObject(input) { + var objectTest = isObject(input) && !isObjectEmpty(input), + propertyTest = false, + properties = [ + 'years', + 'year', + 'y', + 'months', + 'month', + 'M', + 'days', + 'day', + 'd', + 'dates', + 'date', + 'D', + 'hours', + 'hour', + 'h', + 'minutes', + 'minute', + 'm', + 'seconds', + 'second', + 's', + 'milliseconds', + 'millisecond', + 'ms', + ], + i, + property, + propertyLen = properties.length; + + for (i = 0; i < propertyLen; i += 1) { + property = properties[i]; + propertyTest = propertyTest || hasOwnProp(input, property); + } + + return objectTest && propertyTest; + } + + function isNumberOrStringArray(input) { + var arrayTest = isArray(input), + dataTypeTest = false; + if (arrayTest) { + dataTypeTest = + input.filter(function (item) { + return !isNumber(item) && isString(input); + }).length === 0; + } + return arrayTest && dataTypeTest; + } + + function isCalendarSpec(input) { + var objectTest = isObject(input) && !isObjectEmpty(input), + propertyTest = false, + properties = [ + 'sameDay', + 'nextDay', + 'lastDay', + 'nextWeek', + 'lastWeek', + 'sameElse', + ], + i, + property; + + for (i = 0; i < properties.length; i += 1) { + property = properties[i]; + propertyTest = propertyTest || hasOwnProp(input, property); + } + + return objectTest && propertyTest; + } + + function getCalendarFormat(myMoment, now) { + var diff = myMoment.diff(now, 'days', true); + return diff < -6 + ? 'sameElse' + : diff < -1 + ? 'lastWeek' + : diff < 0 + ? 'lastDay' + : diff < 1 + ? 'sameDay' + : diff < 2 + ? 'nextDay' + : diff < 7 + ? 'nextWeek' + : 'sameElse'; + } + + function calendar$1(time, formats) { + // Support for single parameter, formats only overload to the calendar function + if (arguments.length === 1) { + if (!arguments[0]) { + time = undefined; + formats = undefined; + } else if (isMomentInput(arguments[0])) { + time = arguments[0]; + formats = undefined; + } else if (isCalendarSpec(arguments[0])) { + formats = arguments[0]; + time = undefined; + } + } + // We want to compare the start of today, vs this. + // Getting start-of-today depends on whether we're local/utc/offset or not. + var now = time || createLocal(), + sod = cloneWithOffset(now, this).startOf('day'), + format = hooks.calendarFormat(this, sod) || 'sameElse', + output = + formats && + (isFunction(formats[format]) + ? formats[format].call(this, now) + : formats[format]); + + return this.format( + output || this.localeData().calendar(format, this, createLocal(now)) + ); + } + + function clone() { + return new Moment(this); + } + + function isAfter(input, units) { + var localInput = isMoment(input) ? input : createLocal(input); + if (!(this.isValid() && localInput.isValid())) { + return false; + } + units = normalizeUnits(units) || 'millisecond'; + if (units === 'millisecond') { + return this.valueOf() > localInput.valueOf(); + } else { + return localInput.valueOf() < this.clone().startOf(units).valueOf(); + } + } + + function isBefore(input, units) { + var localInput = isMoment(input) ? input : createLocal(input); + if (!(this.isValid() && localInput.isValid())) { + return false; + } + units = normalizeUnits(units) || 'millisecond'; + if (units === 'millisecond') { + return this.valueOf() < localInput.valueOf(); + } else { + return this.clone().endOf(units).valueOf() < localInput.valueOf(); + } + } + + function isBetween(from, to, units, inclusivity) { + var localFrom = isMoment(from) ? from : createLocal(from), + localTo = isMoment(to) ? to : createLocal(to); + if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) { + return false; + } + inclusivity = inclusivity || '()'; + return ( + (inclusivity[0] === '(' + ? this.isAfter(localFrom, units) + : !this.isBefore(localFrom, units)) && + (inclusivity[1] === ')' + ? this.isBefore(localTo, units) + : !this.isAfter(localTo, units)) + ); + } + + function isSame(input, units) { + var localInput = isMoment(input) ? input : createLocal(input), + inputMs; + if (!(this.isValid() && localInput.isValid())) { + return false; + } + units = normalizeUnits(units) || 'millisecond'; + if (units === 'millisecond') { + return this.valueOf() === localInput.valueOf(); + } else { + inputMs = localInput.valueOf(); + return ( + this.clone().startOf(units).valueOf() <= inputMs && + inputMs <= this.clone().endOf(units).valueOf() + ); + } + } + + function isSameOrAfter(input, units) { + return this.isSame(input, units) || this.isAfter(input, units); + } + + function isSameOrBefore(input, units) { + return this.isSame(input, units) || this.isBefore(input, units); + } + + function diff(input, units, asFloat) { + var that, zoneDelta, output; + + if (!this.isValid()) { + return NaN; + } + + that = cloneWithOffset(input, this); + + if (!that.isValid()) { + return NaN; + } + + zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4; + + units = normalizeUnits(units); + + switch (units) { + case 'year': + output = monthDiff(this, that) / 12; + break; + case 'month': + output = monthDiff(this, that); + break; + case 'quarter': + output = monthDiff(this, that) / 3; + break; + case 'second': + output = (this - that) / 1e3; + break; // 1000 + case 'minute': + output = (this - that) / 6e4; + break; // 1000 * 60 + case 'hour': + output = (this - that) / 36e5; + break; // 1000 * 60 * 60 + case 'day': + output = (this - that - zoneDelta) / 864e5; + break; // 1000 * 60 * 60 * 24, negate dst + case 'week': + output = (this - that - zoneDelta) / 6048e5; + break; // 1000 * 60 * 60 * 24 * 7, negate dst + default: + output = this - that; + } + + return asFloat ? output : absFloor(output); + } + + function monthDiff(a, b) { + if (a.date() < b.date()) { + // end-of-month calculations work correct when the start month has more + // days than the end month. + return -monthDiff(b, a); + } + // difference in months + var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()), + // b is in (anchor - 1 month, anchor + 1 month) + anchor = a.clone().add(wholeMonthDiff, 'months'), + anchor2, + adjust; + + if (b - anchor < 0) { + anchor2 = a.clone().add(wholeMonthDiff - 1, 'months'); + // linear across the month + adjust = (b - anchor) / (anchor - anchor2); + } else { + anchor2 = a.clone().add(wholeMonthDiff + 1, 'months'); + // linear across the month + adjust = (b - anchor) / (anchor2 - anchor); + } + + //check for negative zero, return zero if negative zero + return -(wholeMonthDiff + adjust) || 0; + } + + hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ'; + hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]'; + + function toString() { + return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ'); + } + + function toISOString(keepOffset) { + if (!this.isValid()) { + return null; + } + var utc = keepOffset !== true, + m = utc ? this.clone().utc() : this; + if (m.year() < 0 || m.year() > 9999) { + return formatMoment( + m, + utc + ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' + : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ' + ); + } + if (isFunction(Date.prototype.toISOString)) { + // native implementation is ~50x faster, use it when we can + if (utc) { + return this.toDate().toISOString(); + } else { + return new Date(this.valueOf() + this.utcOffset() * 60 * 1000) + .toISOString() + .replace('Z', formatMoment(m, 'Z')); + } + } + return formatMoment( + m, + utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ' + ); + } + + /** + * Return a human readable representation of a moment that can + * also be evaluated to get a new moment which is the same + * + * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects + */ + function inspect() { + if (!this.isValid()) { + return 'moment.invalid(/* ' + this._i + ' */)'; + } + var func = 'moment', + zone = '', + prefix, + year, + datetime, + suffix; + if (!this.isLocal()) { + func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone'; + zone = 'Z'; + } + prefix = '[' + func + '("]'; + year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY'; + datetime = '-MM-DD[T]HH:mm:ss.SSS'; + suffix = zone + '[")]'; + + return this.format(prefix + year + datetime + suffix); + } + + function format(inputString) { + if (!inputString) { + inputString = this.isUtc() + ? hooks.defaultFormatUtc + : hooks.defaultFormat; + } + var output = formatMoment(this, inputString); + return this.localeData().postformat(output); + } + + function from(time, withoutSuffix) { + if ( + this.isValid() && + ((isMoment(time) && time.isValid()) || createLocal(time).isValid()) + ) { + return createDuration({ to: this, from: time }) + .locale(this.locale()) + .humanize(!withoutSuffix); + } else { + return this.localeData().invalidDate(); + } + } + + function fromNow(withoutSuffix) { + return this.from(createLocal(), withoutSuffix); + } + + function to(time, withoutSuffix) { + if ( + this.isValid() && + ((isMoment(time) && time.isValid()) || createLocal(time).isValid()) + ) { + return createDuration({ from: this, to: time }) + .locale(this.locale()) + .humanize(!withoutSuffix); + } else { + return this.localeData().invalidDate(); + } + } + + function toNow(withoutSuffix) { + return this.to(createLocal(), withoutSuffix); + } + + // If passed a locale key, it will set the locale for this + // instance. Otherwise, it will return the locale configuration + // variables for this instance. + function locale(key) { + var newLocaleData; + + if (key === undefined) { + return this._locale._abbr; + } else { + newLocaleData = getLocale(key); + if (newLocaleData != null) { + this._locale = newLocaleData; + } + return this; + } + } + + var lang = deprecate( + 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.', + function (key) { + if (key === undefined) { + return this.localeData(); + } else { + return this.locale(key); + } + } + ); + + function localeData() { + return this._locale; + } + + var MS_PER_SECOND = 1000, + MS_PER_MINUTE = 60 * MS_PER_SECOND, + MS_PER_HOUR = 60 * MS_PER_MINUTE, + MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR; + + // actual modulo - handles negative numbers (for dates before 1970): + function mod$1(dividend, divisor) { + return ((dividend % divisor) + divisor) % divisor; + } + + function localStartOfDate(y, m, d) { + // the date constructor remaps years 0-99 to 1900-1999 + if (y < 100 && y >= 0) { + // preserve leap years using a full 400 year cycle, then reset + return new Date(y + 400, m, d) - MS_PER_400_YEARS; + } else { + return new Date(y, m, d).valueOf(); + } + } + + function utcStartOfDate(y, m, d) { + // Date.UTC remaps years 0-99 to 1900-1999 + if (y < 100 && y >= 0) { + // preserve leap years using a full 400 year cycle, then reset + return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS; + } else { + return Date.UTC(y, m, d); + } + } + + function startOf(units) { + var time, startOfDate; + units = normalizeUnits(units); + if (units === undefined || units === 'millisecond' || !this.isValid()) { + return this; + } + + startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate; + + switch (units) { + case 'year': + time = startOfDate(this.year(), 0, 1); + break; + case 'quarter': + time = startOfDate( + this.year(), + this.month() - (this.month() % 3), + 1 + ); + break; + case 'month': + time = startOfDate(this.year(), this.month(), 1); + break; + case 'week': + time = startOfDate( + this.year(), + this.month(), + this.date() - this.weekday() + ); + break; + case 'isoWeek': + time = startOfDate( + this.year(), + this.month(), + this.date() - (this.isoWeekday() - 1) + ); + break; + case 'day': + case 'date': + time = startOfDate(this.year(), this.month(), this.date()); + break; + case 'hour': + time = this._d.valueOf(); + time -= mod$1( + time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), + MS_PER_HOUR + ); + break; + case 'minute': + time = this._d.valueOf(); + time -= mod$1(time, MS_PER_MINUTE); + break; + case 'second': + time = this._d.valueOf(); + time -= mod$1(time, MS_PER_SECOND); + break; + } + + this._d.setTime(time); + hooks.updateOffset(this, true); + return this; + } + + function endOf(units) { + var time, startOfDate; + units = normalizeUnits(units); + if (units === undefined || units === 'millisecond' || !this.isValid()) { + return this; + } + + startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate; + + switch (units) { + case 'year': + time = startOfDate(this.year() + 1, 0, 1) - 1; + break; + case 'quarter': + time = + startOfDate( + this.year(), + this.month() - (this.month() % 3) + 3, + 1 + ) - 1; + break; + case 'month': + time = startOfDate(this.year(), this.month() + 1, 1) - 1; + break; + case 'week': + time = + startOfDate( + this.year(), + this.month(), + this.date() - this.weekday() + 7 + ) - 1; + break; + case 'isoWeek': + time = + startOfDate( + this.year(), + this.month(), + this.date() - (this.isoWeekday() - 1) + 7 + ) - 1; + break; + case 'day': + case 'date': + time = startOfDate(this.year(), this.month(), this.date() + 1) - 1; + break; + case 'hour': + time = this._d.valueOf(); + time += + MS_PER_HOUR - + mod$1( + time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), + MS_PER_HOUR + ) - + 1; + break; + case 'minute': + time = this._d.valueOf(); + time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1; + break; + case 'second': + time = this._d.valueOf(); + time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1; + break; + } + + this._d.setTime(time); + hooks.updateOffset(this, true); + return this; + } + + function valueOf() { + return this._d.valueOf() - (this._offset || 0) * 60000; + } + + function unix() { + return Math.floor(this.valueOf() / 1000); + } + + function toDate() { + return new Date(this.valueOf()); + } + + function toArray() { + var m = this; + return [ + m.year(), + m.month(), + m.date(), + m.hour(), + m.minute(), + m.second(), + m.millisecond(), + ]; + } + + function toObject() { + var m = this; + return { + years: m.year(), + months: m.month(), + date: m.date(), + hours: m.hours(), + minutes: m.minutes(), + seconds: m.seconds(), + milliseconds: m.milliseconds(), + }; + } + + function toJSON() { + // new Date(NaN).toJSON() === null + return this.isValid() ? this.toISOString() : null; + } + + function isValid$2() { + return isValid(this); + } + + function parsingFlags() { + return extend({}, getParsingFlags(this)); + } + + function invalidAt() { + return getParsingFlags(this).overflow; + } + + function creationData() { + return { + input: this._i, + format: this._f, + locale: this._locale, + isUTC: this._isUTC, + strict: this._strict, + }; + } + + addFormatToken('N', 0, 0, 'eraAbbr'); + addFormatToken('NN', 0, 0, 'eraAbbr'); + addFormatToken('NNN', 0, 0, 'eraAbbr'); + addFormatToken('NNNN', 0, 0, 'eraName'); + addFormatToken('NNNNN', 0, 0, 'eraNarrow'); + + addFormatToken('y', ['y', 1], 'yo', 'eraYear'); + addFormatToken('y', ['yy', 2], 0, 'eraYear'); + addFormatToken('y', ['yyy', 3], 0, 'eraYear'); + addFormatToken('y', ['yyyy', 4], 0, 'eraYear'); + + addRegexToken('N', matchEraAbbr); + addRegexToken('NN', matchEraAbbr); + addRegexToken('NNN', matchEraAbbr); + addRegexToken('NNNN', matchEraName); + addRegexToken('NNNNN', matchEraNarrow); + + addParseToken( + ['N', 'NN', 'NNN', 'NNNN', 'NNNNN'], + function (input, array, config, token) { + var era = config._locale.erasParse(input, token, config._strict); + if (era) { + getParsingFlags(config).era = era; + } else { + getParsingFlags(config).invalidEra = input; + } + } + ); + + addRegexToken('y', matchUnsigned); + addRegexToken('yy', matchUnsigned); + addRegexToken('yyy', matchUnsigned); + addRegexToken('yyyy', matchUnsigned); + addRegexToken('yo', matchEraYearOrdinal); + + addParseToken(['y', 'yy', 'yyy', 'yyyy'], YEAR); + addParseToken(['yo'], function (input, array, config, token) { + var match; + if (config._locale._eraYearOrdinalRegex) { + match = input.match(config._locale._eraYearOrdinalRegex); + } + + if (config._locale.eraYearOrdinalParse) { + array[YEAR] = config._locale.eraYearOrdinalParse(input, match); + } else { + array[YEAR] = parseInt(input, 10); + } + }); + + function localeEras(m, format) { + var i, + l, + date, + eras = this._eras || getLocale('en')._eras; + for (i = 0, l = eras.length; i < l; ++i) { + switch (typeof eras[i].since) { + case 'string': + // truncate time + date = hooks(eras[i].since).startOf('day'); + eras[i].since = date.valueOf(); + break; + } + + switch (typeof eras[i].until) { + case 'undefined': + eras[i].until = +Infinity; + break; + case 'string': + // truncate time + date = hooks(eras[i].until).startOf('day').valueOf(); + eras[i].until = date.valueOf(); + break; + } + } + return eras; + } + + function localeErasParse(eraName, format, strict) { + var i, + l, + eras = this.eras(), + name, + abbr, + narrow; + eraName = eraName.toUpperCase(); + + for (i = 0, l = eras.length; i < l; ++i) { + name = eras[i].name.toUpperCase(); + abbr = eras[i].abbr.toUpperCase(); + narrow = eras[i].narrow.toUpperCase(); + + if (strict) { + switch (format) { + case 'N': + case 'NN': + case 'NNN': + if (abbr === eraName) { + return eras[i]; + } + break; + + case 'NNNN': + if (name === eraName) { + return eras[i]; + } + break; + + case 'NNNNN': + if (narrow === eraName) { + return eras[i]; + } + break; + } + } else if ([name, abbr, narrow].indexOf(eraName) >= 0) { + return eras[i]; + } + } + } + + function localeErasConvertYear(era, year) { + var dir = era.since <= era.until ? +1 : -1; + if (year === undefined) { + return hooks(era.since).year(); + } else { + return hooks(era.since).year() + (year - era.offset) * dir; + } + } + + function getEraName() { + var i, + l, + val, + eras = this.localeData().eras(); + for (i = 0, l = eras.length; i < l; ++i) { + // truncate time + val = this.clone().startOf('day').valueOf(); + + if (eras[i].since <= val && val <= eras[i].until) { + return eras[i].name; + } + if (eras[i].until <= val && val <= eras[i].since) { + return eras[i].name; + } + } + + return ''; + } + + function getEraNarrow() { + var i, + l, + val, + eras = this.localeData().eras(); + for (i = 0, l = eras.length; i < l; ++i) { + // truncate time + val = this.clone().startOf('day').valueOf(); + + if (eras[i].since <= val && val <= eras[i].until) { + return eras[i].narrow; + } + if (eras[i].until <= val && val <= eras[i].since) { + return eras[i].narrow; + } + } + + return ''; + } + + function getEraAbbr() { + var i, + l, + val, + eras = this.localeData().eras(); + for (i = 0, l = eras.length; i < l; ++i) { + // truncate time + val = this.clone().startOf('day').valueOf(); + + if (eras[i].since <= val && val <= eras[i].until) { + return eras[i].abbr; + } + if (eras[i].until <= val && val <= eras[i].since) { + return eras[i].abbr; + } + } + + return ''; + } + + function getEraYear() { + var i, + l, + dir, + val, + eras = this.localeData().eras(); + for (i = 0, l = eras.length; i < l; ++i) { + dir = eras[i].since <= eras[i].until ? +1 : -1; + + // truncate time + val = this.clone().startOf('day').valueOf(); + + if ( + (eras[i].since <= val && val <= eras[i].until) || + (eras[i].until <= val && val <= eras[i].since) + ) { + return ( + (this.year() - hooks(eras[i].since).year()) * dir + + eras[i].offset + ); + } + } + + return this.year(); + } + + function erasNameRegex(isStrict) { + if (!hasOwnProp(this, '_erasNameRegex')) { + computeErasParse.call(this); + } + return isStrict ? this._erasNameRegex : this._erasRegex; + } + + function erasAbbrRegex(isStrict) { + if (!hasOwnProp(this, '_erasAbbrRegex')) { + computeErasParse.call(this); + } + return isStrict ? this._erasAbbrRegex : this._erasRegex; + } + + function erasNarrowRegex(isStrict) { + if (!hasOwnProp(this, '_erasNarrowRegex')) { + computeErasParse.call(this); + } + return isStrict ? this._erasNarrowRegex : this._erasRegex; + } + + function matchEraAbbr(isStrict, locale) { + return locale.erasAbbrRegex(isStrict); + } + + function matchEraName(isStrict, locale) { + return locale.erasNameRegex(isStrict); + } + + function matchEraNarrow(isStrict, locale) { + return locale.erasNarrowRegex(isStrict); + } + + function matchEraYearOrdinal(isStrict, locale) { + return locale._eraYearOrdinalRegex || matchUnsigned; + } + + function computeErasParse() { + var abbrPieces = [], + namePieces = [], + narrowPieces = [], + mixedPieces = [], + i, + l, + erasName, + erasAbbr, + erasNarrow, + eras = this.eras(); + + for (i = 0, l = eras.length; i < l; ++i) { + erasName = regexEscape(eras[i].name); + erasAbbr = regexEscape(eras[i].abbr); + erasNarrow = regexEscape(eras[i].narrow); + + namePieces.push(erasName); + abbrPieces.push(erasAbbr); + narrowPieces.push(erasNarrow); + mixedPieces.push(erasName); + mixedPieces.push(erasAbbr); + mixedPieces.push(erasNarrow); + } + + this._erasRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); + this._erasNameRegex = new RegExp('^(' + namePieces.join('|') + ')', 'i'); + this._erasAbbrRegex = new RegExp('^(' + abbrPieces.join('|') + ')', 'i'); + this._erasNarrowRegex = new RegExp( + '^(' + narrowPieces.join('|') + ')', + 'i' + ); + } + + // FORMATTING + + addFormatToken(0, ['gg', 2], 0, function () { + return this.weekYear() % 100; + }); + + addFormatToken(0, ['GG', 2], 0, function () { + return this.isoWeekYear() % 100; + }); + + function addWeekYearFormatToken(token, getter) { + addFormatToken(0, [token, token.length], 0, getter); + } + + addWeekYearFormatToken('gggg', 'weekYear'); + addWeekYearFormatToken('ggggg', 'weekYear'); + addWeekYearFormatToken('GGGG', 'isoWeekYear'); + addWeekYearFormatToken('GGGGG', 'isoWeekYear'); + + // ALIASES + + // PARSING + + addRegexToken('G', matchSigned); + addRegexToken('g', matchSigned); + addRegexToken('GG', match1to2, match2); + addRegexToken('gg', match1to2, match2); + addRegexToken('GGGG', match1to4, match4); + addRegexToken('gggg', match1to4, match4); + addRegexToken('GGGGG', match1to6, match6); + addRegexToken('ggggg', match1to6, match6); + + addWeekParseToken( + ['gggg', 'ggggg', 'GGGG', 'GGGGG'], + function (input, week, config, token) { + week[token.substr(0, 2)] = toInt(input); + } + ); + + addWeekParseToken(['gg', 'GG'], function (input, week, config, token) { + week[token] = hooks.parseTwoDigitYear(input); + }); + + // MOMENTS + + function getSetWeekYear(input) { + return getSetWeekYearHelper.call( + this, + input, + this.week(), + this.weekday() + this.localeData()._week.dow, + this.localeData()._week.dow, + this.localeData()._week.doy + ); + } + + function getSetISOWeekYear(input) { + return getSetWeekYearHelper.call( + this, + input, + this.isoWeek(), + this.isoWeekday(), + 1, + 4 + ); + } + + function getISOWeeksInYear() { + return weeksInYear(this.year(), 1, 4); + } + + function getISOWeeksInISOWeekYear() { + return weeksInYear(this.isoWeekYear(), 1, 4); + } + + function getWeeksInYear() { + var weekInfo = this.localeData()._week; + return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy); + } + + function getWeeksInWeekYear() { + var weekInfo = this.localeData()._week; + return weeksInYear(this.weekYear(), weekInfo.dow, weekInfo.doy); + } + + function getSetWeekYearHelper(input, week, weekday, dow, doy) { + var weeksTarget; + if (input == null) { + return weekOfYear(this, dow, doy).year; + } else { + weeksTarget = weeksInYear(input, dow, doy); + if (week > weeksTarget) { + week = weeksTarget; + } + return setWeekAll.call(this, input, week, weekday, dow, doy); + } + } + + function setWeekAll(weekYear, week, weekday, dow, doy) { + var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy), + date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear); + + this.year(date.getUTCFullYear()); + this.month(date.getUTCMonth()); + this.date(date.getUTCDate()); + return this; + } + + // FORMATTING + + addFormatToken('Q', 0, 'Qo', 'quarter'); + + // PARSING + + addRegexToken('Q', match1); + addParseToken('Q', function (input, array) { + array[MONTH] = (toInt(input) - 1) * 3; + }); + + // MOMENTS + + function getSetQuarter(input) { + return input == null + ? Math.ceil((this.month() + 1) / 3) + : this.month((input - 1) * 3 + (this.month() % 3)); + } + + // FORMATTING + + addFormatToken('D', ['DD', 2], 'Do', 'date'); + + // PARSING + + addRegexToken('D', match1to2, match1to2NoLeadingZero); + addRegexToken('DD', match1to2, match2); + addRegexToken('Do', function (isStrict, locale) { + // TODO: Remove "ordinalParse" fallback in next major release. + return isStrict + ? locale._dayOfMonthOrdinalParse || locale._ordinalParse + : locale._dayOfMonthOrdinalParseLenient; + }); + + addParseToken(['D', 'DD'], DATE); + addParseToken('Do', function (input, array) { + array[DATE] = toInt(input.match(match1to2)[0]); + }); + + // MOMENTS + + var getSetDayOfMonth = makeGetSet('Date', true); + + // FORMATTING + + addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear'); + + // PARSING + + addRegexToken('DDD', match1to3); + addRegexToken('DDDD', match3); + addParseToken(['DDD', 'DDDD'], function (input, array, config) { + config._dayOfYear = toInt(input); + }); + + // HELPERS + + // MOMENTS + + function getSetDayOfYear(input) { + var dayOfYear = + Math.round( + (this.clone().startOf('day') - this.clone().startOf('year')) / 864e5 + ) + 1; + return input == null ? dayOfYear : this.add(input - dayOfYear, 'd'); + } + + // FORMATTING + + addFormatToken('m', ['mm', 2], 0, 'minute'); + + // PARSING + + addRegexToken('m', match1to2, match1to2HasZero); + addRegexToken('mm', match1to2, match2); + addParseToken(['m', 'mm'], MINUTE); + + // MOMENTS + + var getSetMinute = makeGetSet('Minutes', false); + + // FORMATTING + + addFormatToken('s', ['ss', 2], 0, 'second'); + + // PARSING + + addRegexToken('s', match1to2, match1to2HasZero); + addRegexToken('ss', match1to2, match2); + addParseToken(['s', 'ss'], SECOND); + + // MOMENTS + + var getSetSecond = makeGetSet('Seconds', false); + + // FORMATTING + + addFormatToken('S', 0, 0, function () { + return ~~(this.millisecond() / 100); + }); + + addFormatToken(0, ['SS', 2], 0, function () { + return ~~(this.millisecond() / 10); + }); + + addFormatToken(0, ['SSS', 3], 0, 'millisecond'); + addFormatToken(0, ['SSSS', 4], 0, function () { + return this.millisecond() * 10; + }); + addFormatToken(0, ['SSSSS', 5], 0, function () { + return this.millisecond() * 100; + }); + addFormatToken(0, ['SSSSSS', 6], 0, function () { + return this.millisecond() * 1000; + }); + addFormatToken(0, ['SSSSSSS', 7], 0, function () { + return this.millisecond() * 10000; + }); + addFormatToken(0, ['SSSSSSSS', 8], 0, function () { + return this.millisecond() * 100000; + }); + addFormatToken(0, ['SSSSSSSSS', 9], 0, function () { + return this.millisecond() * 1000000; + }); + + // PARSING + + addRegexToken('S', match1to3, match1); + addRegexToken('SS', match1to3, match2); + addRegexToken('SSS', match1to3, match3); + + var token, getSetMillisecond; + for (token = 'SSSS'; token.length <= 9; token += 'S') { + addRegexToken(token, matchUnsigned); + } + + function parseMs(input, array) { + array[MILLISECOND] = toInt(('0.' + input) * 1000); + } + + for (token = 'S'; token.length <= 9; token += 'S') { + addParseToken(token, parseMs); + } + + getSetMillisecond = makeGetSet('Milliseconds', false); + + // FORMATTING + + addFormatToken('z', 0, 0, 'zoneAbbr'); + addFormatToken('zz', 0, 0, 'zoneName'); + + // MOMENTS + + function getZoneAbbr() { + return this._isUTC ? 'UTC' : ''; + } + + function getZoneName() { + return this._isUTC ? 'Coordinated Universal Time' : ''; + } + + var proto = Moment.prototype; + + proto.add = add; + proto.calendar = calendar$1; + proto.clone = clone; + proto.diff = diff; + proto.endOf = endOf; + proto.format = format; + proto.from = from; + proto.fromNow = fromNow; + proto.to = to; + proto.toNow = toNow; + proto.get = stringGet; + proto.invalidAt = invalidAt; + proto.isAfter = isAfter; + proto.isBefore = isBefore; + proto.isBetween = isBetween; + proto.isSame = isSame; + proto.isSameOrAfter = isSameOrAfter; + proto.isSameOrBefore = isSameOrBefore; + proto.isValid = isValid$2; + proto.lang = lang; + proto.locale = locale; + proto.localeData = localeData; + proto.max = prototypeMax; + proto.min = prototypeMin; + proto.parsingFlags = parsingFlags; + proto.set = stringSet; + proto.startOf = startOf; + proto.subtract = subtract; + proto.toArray = toArray; + proto.toObject = toObject; + proto.toDate = toDate; + proto.toISOString = toISOString; + proto.inspect = inspect; + if (typeof Symbol !== 'undefined' && Symbol.for != null) { + proto[Symbol.for('nodejs.util.inspect.custom')] = function () { + return 'Moment<' + this.format() + '>'; + }; + } + proto.toJSON = toJSON; + proto.toString = toString; + proto.unix = unix; + proto.valueOf = valueOf; + proto.creationData = creationData; + proto.eraName = getEraName; + proto.eraNarrow = getEraNarrow; + proto.eraAbbr = getEraAbbr; + proto.eraYear = getEraYear; + proto.year = getSetYear; + proto.isLeapYear = getIsLeapYear; + proto.weekYear = getSetWeekYear; + proto.isoWeekYear = getSetISOWeekYear; + proto.quarter = proto.quarters = getSetQuarter; + proto.month = getSetMonth; + proto.daysInMonth = getDaysInMonth; + proto.week = proto.weeks = getSetWeek; + proto.isoWeek = proto.isoWeeks = getSetISOWeek; + proto.weeksInYear = getWeeksInYear; + proto.weeksInWeekYear = getWeeksInWeekYear; + proto.isoWeeksInYear = getISOWeeksInYear; + proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear; + proto.date = getSetDayOfMonth; + proto.day = proto.days = getSetDayOfWeek; + proto.weekday = getSetLocaleDayOfWeek; + proto.isoWeekday = getSetISODayOfWeek; + proto.dayOfYear = getSetDayOfYear; + proto.hour = proto.hours = getSetHour; + proto.minute = proto.minutes = getSetMinute; + proto.second = proto.seconds = getSetSecond; + proto.millisecond = proto.milliseconds = getSetMillisecond; + proto.utcOffset = getSetOffset; + proto.utc = setOffsetToUTC; + proto.local = setOffsetToLocal; + proto.parseZone = setOffsetToParsedOffset; + proto.hasAlignedHourOffset = hasAlignedHourOffset; + proto.isDST = isDaylightSavingTime; + proto.isLocal = isLocal; + proto.isUtcOffset = isUtcOffset; + proto.isUtc = isUtc; + proto.isUTC = isUtc; + proto.zoneAbbr = getZoneAbbr; + proto.zoneName = getZoneName; + proto.dates = deprecate( + 'dates accessor is deprecated. Use date instead.', + getSetDayOfMonth + ); + proto.months = deprecate( + 'months accessor is deprecated. Use month instead', + getSetMonth + ); + proto.years = deprecate( + 'years accessor is deprecated. Use year instead', + getSetYear + ); + proto.zone = deprecate( + 'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', + getSetZone + ); + proto.isDSTShifted = deprecate( + 'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', + isDaylightSavingTimeShifted + ); + + function createUnix(input) { + return createLocal(input * 1000); + } + + function createInZone() { + return createLocal.apply(null, arguments).parseZone(); + } + + function preParsePostFormat(string) { + return string; + } + + var proto$1 = Locale.prototype; + + proto$1.calendar = calendar; + proto$1.longDateFormat = longDateFormat; + proto$1.invalidDate = invalidDate; + proto$1.ordinal = ordinal; + proto$1.preparse = preParsePostFormat; + proto$1.postformat = preParsePostFormat; + proto$1.relativeTime = relativeTime; + proto$1.pastFuture = pastFuture; + proto$1.set = set; + proto$1.eras = localeEras; + proto$1.erasParse = localeErasParse; + proto$1.erasConvertYear = localeErasConvertYear; + proto$1.erasAbbrRegex = erasAbbrRegex; + proto$1.erasNameRegex = erasNameRegex; + proto$1.erasNarrowRegex = erasNarrowRegex; + + proto$1.months = localeMonths; + proto$1.monthsShort = localeMonthsShort; + proto$1.monthsParse = localeMonthsParse; + proto$1.monthsRegex = monthsRegex; + proto$1.monthsShortRegex = monthsShortRegex; + proto$1.week = localeWeek; + proto$1.firstDayOfYear = localeFirstDayOfYear; + proto$1.firstDayOfWeek = localeFirstDayOfWeek; + + proto$1.weekdays = localeWeekdays; + proto$1.weekdaysMin = localeWeekdaysMin; + proto$1.weekdaysShort = localeWeekdaysShort; + proto$1.weekdaysParse = localeWeekdaysParse; + + proto$1.weekdaysRegex = weekdaysRegex; + proto$1.weekdaysShortRegex = weekdaysShortRegex; + proto$1.weekdaysMinRegex = weekdaysMinRegex; + + proto$1.isPM = localeIsPM; + proto$1.meridiem = localeMeridiem; + + function get$1(format, index, field, setter) { + var locale = getLocale(), + utc = createUTC().set(setter, index); + return locale[field](utc, format); + } + + function listMonthsImpl(format, index, field) { + if (isNumber(format)) { + index = format; + format = undefined; + } + + format = format || ''; + + if (index != null) { + return get$1(format, index, field, 'month'); + } + + var i, + out = []; + for (i = 0; i < 12; i++) { + out[i] = get$1(format, i, field, 'month'); + } + return out; + } + + // () + // (5) + // (fmt, 5) + // (fmt) + // (true) + // (true, 5) + // (true, fmt, 5) + // (true, fmt) + function listWeekdaysImpl(localeSorted, format, index, field) { + if (typeof localeSorted === 'boolean') { + if (isNumber(format)) { + index = format; + format = undefined; + } + + format = format || ''; + } else { + format = localeSorted; + index = format; + localeSorted = false; + + if (isNumber(format)) { + index = format; + format = undefined; + } + + format = format || ''; + } + + var locale = getLocale(), + shift = localeSorted ? locale._week.dow : 0, + i, + out = []; + + if (index != null) { + return get$1(format, (index + shift) % 7, field, 'day'); + } + + for (i = 0; i < 7; i++) { + out[i] = get$1(format, (i + shift) % 7, field, 'day'); + } + return out; + } + + function listMonths(format, index) { + return listMonthsImpl(format, index, 'months'); + } + + function listMonthsShort(format, index) { + return listMonthsImpl(format, index, 'monthsShort'); + } + + function listWeekdays(localeSorted, format, index) { + return listWeekdaysImpl(localeSorted, format, index, 'weekdays'); + } + + function listWeekdaysShort(localeSorted, format, index) { + return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort'); + } + + function listWeekdaysMin(localeSorted, format, index) { + return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin'); + } + + getSetGlobalLocale('en', { + eras: [ + { + since: '0001-01-01', + until: +Infinity, + offset: 1, + name: 'Anno Domini', + narrow: 'AD', + abbr: 'AD', + }, + { + since: '0000-12-31', + until: -Infinity, + offset: 1, + name: 'Before Christ', + narrow: 'BC', + abbr: 'BC', + }, + ], + dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/, + ordinal: function (number) { + var b = number % 10, + output = + toInt((number % 100) / 10) === 1 + ? 'th' + : b === 1 + ? 'st' + : b === 2 + ? 'nd' + : b === 3 + ? 'rd' + : 'th'; + return number + output; + }, + }); + + // Side effect imports + + hooks.lang = deprecate( + 'moment.lang is deprecated. Use moment.locale instead.', + getSetGlobalLocale + ); + hooks.langData = deprecate( + 'moment.langData is deprecated. Use moment.localeData instead.', + getLocale + ); + + var mathAbs = Math.abs; + + function abs() { + var data = this._data; + + this._milliseconds = mathAbs(this._milliseconds); + this._days = mathAbs(this._days); + this._months = mathAbs(this._months); + + data.milliseconds = mathAbs(data.milliseconds); + data.seconds = mathAbs(data.seconds); + data.minutes = mathAbs(data.minutes); + data.hours = mathAbs(data.hours); + data.months = mathAbs(data.months); + data.years = mathAbs(data.years); + + return this; + } + + function addSubtract$1(duration, input, value, direction) { + var other = createDuration(input, value); + + duration._milliseconds += direction * other._milliseconds; + duration._days += direction * other._days; + duration._months += direction * other._months; + + return duration._bubble(); + } + + // supports only 2.0-style add(1, 's') or add(duration) + function add$1(input, value) { + return addSubtract$1(this, input, value, 1); + } + + // supports only 2.0-style subtract(1, 's') or subtract(duration) + function subtract$1(input, value) { + return addSubtract$1(this, input, value, -1); + } + + function absCeil(number) { + if (number < 0) { + return Math.floor(number); + } else { + return Math.ceil(number); + } + } + + function bubble() { + var milliseconds = this._milliseconds, + days = this._days, + months = this._months, + data = this._data, + seconds, + minutes, + hours, + years, + monthsFromDays; + + // if we have a mix of positive and negative values, bubble down first + // check: https://github.com/moment/moment/issues/2166 + if ( + !( + (milliseconds >= 0 && days >= 0 && months >= 0) || + (milliseconds <= 0 && days <= 0 && months <= 0) + ) + ) { + milliseconds += absCeil(monthsToDays(months) + days) * 864e5; + days = 0; + months = 0; + } + + // The following code bubbles up values, see the tests for + // examples of what that means. + data.milliseconds = milliseconds % 1000; + + seconds = absFloor(milliseconds / 1000); + data.seconds = seconds % 60; + + minutes = absFloor(seconds / 60); + data.minutes = minutes % 60; + + hours = absFloor(minutes / 60); + data.hours = hours % 24; + + days += absFloor(hours / 24); + + // convert days to months + monthsFromDays = absFloor(daysToMonths(days)); + months += monthsFromDays; + days -= absCeil(monthsToDays(monthsFromDays)); + + // 12 months -> 1 year + years = absFloor(months / 12); + months %= 12; + + data.days = days; + data.months = months; + data.years = years; + + return this; + } + + function daysToMonths(days) { + // 400 years have 146097 days (taking into account leap year rules) + // 400 years have 12 months === 4800 + return (days * 4800) / 146097; + } + + function monthsToDays(months) { + // the reverse of daysToMonths + return (months * 146097) / 4800; + } + + function as(units) { + if (!this.isValid()) { + return NaN; + } + var days, + months, + milliseconds = this._milliseconds; + + units = normalizeUnits(units); + + if (units === 'month' || units === 'quarter' || units === 'year') { + days = this._days + milliseconds / 864e5; + months = this._months + daysToMonths(days); + switch (units) { + case 'month': + return months; + case 'quarter': + return months / 3; + case 'year': + return months / 12; + } + } else { + // handle milliseconds separately because of floating point math errors (issue #1867) + days = this._days + Math.round(monthsToDays(this._months)); + switch (units) { + case 'week': + return days / 7 + milliseconds / 6048e5; + case 'day': + return days + milliseconds / 864e5; + case 'hour': + return days * 24 + milliseconds / 36e5; + case 'minute': + return days * 1440 + milliseconds / 6e4; + case 'second': + return days * 86400 + milliseconds / 1000; + // Math.floor prevents floating point math errors here + case 'millisecond': + return Math.floor(days * 864e5) + milliseconds; + default: + throw new Error('Unknown unit ' + units); + } + } + } + + function makeAs(alias) { + return function () { + return this.as(alias); + }; + } + + var asMilliseconds = makeAs('ms'), + asSeconds = makeAs('s'), + asMinutes = makeAs('m'), + asHours = makeAs('h'), + asDays = makeAs('d'), + asWeeks = makeAs('w'), + asMonths = makeAs('M'), + asQuarters = makeAs('Q'), + asYears = makeAs('y'), + valueOf$1 = asMilliseconds; + + function clone$1() { + return createDuration(this); + } + + function get$2(units) { + units = normalizeUnits(units); + return this.isValid() ? this[units + 's']() : NaN; + } + + function makeGetter(name) { + return function () { + return this.isValid() ? this._data[name] : NaN; + }; + } + + var milliseconds = makeGetter('milliseconds'), + seconds = makeGetter('seconds'), + minutes = makeGetter('minutes'), + hours = makeGetter('hours'), + days = makeGetter('days'), + months = makeGetter('months'), + years = makeGetter('years'); + + function weeks() { + return absFloor(this.days() / 7); + } + + var round = Math.round, + thresholds = { + ss: 44, // a few seconds to seconds + s: 45, // seconds to minute + m: 45, // minutes to hour + h: 22, // hours to day + d: 26, // days to month/week + w: null, // weeks to month + M: 11, // months to year + }; + + // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize + function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) { + return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture); + } + + function relativeTime$1(posNegDuration, withoutSuffix, thresholds, locale) { + var duration = createDuration(posNegDuration).abs(), + seconds = round(duration.as('s')), + minutes = round(duration.as('m')), + hours = round(duration.as('h')), + days = round(duration.as('d')), + months = round(duration.as('M')), + weeks = round(duration.as('w')), + years = round(duration.as('y')), + a = + (seconds <= thresholds.ss && ['s', seconds]) || + (seconds < thresholds.s && ['ss', seconds]) || + (minutes <= 1 && ['m']) || + (minutes < thresholds.m && ['mm', minutes]) || + (hours <= 1 && ['h']) || + (hours < thresholds.h && ['hh', hours]) || + (days <= 1 && ['d']) || + (days < thresholds.d && ['dd', days]); + + if (thresholds.w != null) { + a = + a || + (weeks <= 1 && ['w']) || + (weeks < thresholds.w && ['ww', weeks]); + } + a = a || + (months <= 1 && ['M']) || + (months < thresholds.M && ['MM', months]) || + (years <= 1 && ['y']) || ['yy', years]; + + a[2] = withoutSuffix; + a[3] = +posNegDuration > 0; + a[4] = locale; + return substituteTimeAgo.apply(null, a); + } + + // This function allows you to set the rounding function for relative time strings + function getSetRelativeTimeRounding(roundingFunction) { + if (roundingFunction === undefined) { + return round; + } + if (typeof roundingFunction === 'function') { + round = roundingFunction; + return true; + } + return false; + } + + // This function allows you to set a threshold for relative time strings + function getSetRelativeTimeThreshold(threshold, limit) { + if (thresholds[threshold] === undefined) { + return false; + } + if (limit === undefined) { + return thresholds[threshold]; + } + thresholds[threshold] = limit; + if (threshold === 's') { + thresholds.ss = limit - 1; + } + return true; + } + + function humanize(argWithSuffix, argThresholds) { + if (!this.isValid()) { + return this.localeData().invalidDate(); + } + + var withSuffix = false, + th = thresholds, + locale, + output; + + if (typeof argWithSuffix === 'object') { + argThresholds = argWithSuffix; + argWithSuffix = false; + } + if (typeof argWithSuffix === 'boolean') { + withSuffix = argWithSuffix; + } + if (typeof argThresholds === 'object') { + th = Object.assign({}, thresholds, argThresholds); + if (argThresholds.s != null && argThresholds.ss == null) { + th.ss = argThresholds.s - 1; + } + } + + locale = this.localeData(); + output = relativeTime$1(this, !withSuffix, th, locale); + + if (withSuffix) { + output = locale.pastFuture(+this, output); + } + + return locale.postformat(output); + } + + var abs$1 = Math.abs; + + function sign(x) { + return (x > 0) - (x < 0) || +x; + } + + function toISOString$1() { + // for ISO strings we do not use the normal bubbling rules: + // * milliseconds bubble up until they become hours + // * days do not bubble at all + // * months bubble up until they become years + // This is because there is no context-free conversion between hours and days + // (think of clock changes) + // and also not between days and months (28-31 days per month) + if (!this.isValid()) { + return this.localeData().invalidDate(); + } + + var seconds = abs$1(this._milliseconds) / 1000, + days = abs$1(this._days), + months = abs$1(this._months), + minutes, + hours, + years, + s, + total = this.asSeconds(), + totalSign, + ymSign, + daysSign, + hmsSign; + + if (!total) { + // this is the same as C#'s (Noda) and python (isodate)... + // but not other JS (goog.date) + return 'P0D'; + } + + // 3600 seconds -> 60 minutes -> 1 hour + minutes = absFloor(seconds / 60); + hours = absFloor(minutes / 60); + seconds %= 60; + minutes %= 60; + + // 12 months -> 1 year + years = absFloor(months / 12); + months %= 12; + + // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js + s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : ''; + + totalSign = total < 0 ? '-' : ''; + ymSign = sign(this._months) !== sign(total) ? '-' : ''; + daysSign = sign(this._days) !== sign(total) ? '-' : ''; + hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : ''; + + return ( + totalSign + + 'P' + + (years ? ymSign + years + 'Y' : '') + + (months ? ymSign + months + 'M' : '') + + (days ? daysSign + days + 'D' : '') + + (hours || minutes || seconds ? 'T' : '') + + (hours ? hmsSign + hours + 'H' : '') + + (minutes ? hmsSign + minutes + 'M' : '') + + (seconds ? hmsSign + s + 'S' : '') + ); + } + + var proto$2 = Duration.prototype; + + proto$2.isValid = isValid$1; + proto$2.abs = abs; + proto$2.add = add$1; + proto$2.subtract = subtract$1; + proto$2.as = as; + proto$2.asMilliseconds = asMilliseconds; + proto$2.asSeconds = asSeconds; + proto$2.asMinutes = asMinutes; + proto$2.asHours = asHours; + proto$2.asDays = asDays; + proto$2.asWeeks = asWeeks; + proto$2.asMonths = asMonths; + proto$2.asQuarters = asQuarters; + proto$2.asYears = asYears; + proto$2.valueOf = valueOf$1; + proto$2._bubble = bubble; + proto$2.clone = clone$1; + proto$2.get = get$2; + proto$2.milliseconds = milliseconds; + proto$2.seconds = seconds; + proto$2.minutes = minutes; + proto$2.hours = hours; + proto$2.days = days; + proto$2.weeks = weeks; + proto$2.months = months; + proto$2.years = years; + proto$2.humanize = humanize; + proto$2.toISOString = toISOString$1; + proto$2.toString = toISOString$1; + proto$2.toJSON = toISOString$1; + proto$2.locale = locale; + proto$2.localeData = localeData; + + proto$2.toIsoString = deprecate( + 'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', + toISOString$1 + ); + proto$2.lang = lang; + + // FORMATTING + + addFormatToken('X', 0, 0, 'unix'); + addFormatToken('x', 0, 0, 'valueOf'); + + // PARSING + + addRegexToken('x', matchSigned); + addRegexToken('X', matchTimestamp); + addParseToken('X', function (input, array, config) { + config._d = new Date(parseFloat(input) * 1000); + }); + addParseToken('x', function (input, array, config) { + config._d = new Date(toInt(input)); + }); + + //! moment.js + + hooks.version = '2.30.1'; + + setHookCallback(createLocal); + + hooks.fn = proto; + hooks.min = min; + hooks.max = max; + hooks.now = now; + hooks.utc = createUTC; + hooks.unix = createUnix; + hooks.months = listMonths; + hooks.isDate = isDate; + hooks.locale = getSetGlobalLocale; + hooks.invalid = createInvalid; + hooks.duration = createDuration; + hooks.isMoment = isMoment; + hooks.weekdays = listWeekdays; + hooks.parseZone = createInZone; + hooks.localeData = getLocale; + hooks.isDuration = isDuration; + hooks.monthsShort = listMonthsShort; + hooks.weekdaysMin = listWeekdaysMin; + hooks.defineLocale = defineLocale; + hooks.updateLocale = updateLocale; + hooks.locales = listLocales; + hooks.weekdaysShort = listWeekdaysShort; + hooks.normalizeUnits = normalizeUnits; + hooks.relativeTimeRounding = getSetRelativeTimeRounding; + hooks.relativeTimeThreshold = getSetRelativeTimeThreshold; + hooks.calendarFormat = getCalendarFormat; + hooks.prototype = proto; + + // currently HTML5 input type only supports 24-hour formats + hooks.HTML5_FMT = { + DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // + DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // + DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // + DATE: 'YYYY-MM-DD', // + TIME: 'HH:mm', // + TIME_SECONDS: 'HH:mm:ss', // + TIME_MS: 'HH:mm:ss.SSS', // + WEEK: 'GGGG-[W]WW', // + MONTH: 'YYYY-MM', // + }; + + return hooks; + + }))); +} (moment$1)); + +var momentExports = moment$1.exports; +var moment = /*@__PURE__*/getDefaultExportFromCjs(momentExports); + +/* Do NOT modify this file; see /src.ts/_admin/update-version.ts */ +/** + * The current version of Ethers. + */ +const version$4 = "6.12.0"; + +/** + * Property helper functions. + * + * @_subsection api/utils:Properties [about-properties] + */ +function checkType(value, type, name) { + const types = type.split("|").map(t => t.trim()); + for (let i = 0; i < types.length; i++) { + switch (type) { + case "any": + return; + case "bigint": + case "boolean": + case "number": + case "string": + if (typeof (value) === type) { + return; + } + } + } + const error = new Error(`invalid value for type ${type}`); + error.code = "INVALID_ARGUMENT"; + error.argument = `value.${name}`; + error.value = value; + throw error; +} +/** + * Resolves to a new object that is a copy of %%value%%, but with all + * values resolved. + */ +async function resolveProperties(value) { + const keys = Object.keys(value); + const results = await Promise.all(keys.map((k) => Promise.resolve(value[k]))); + return results.reduce((accum, v, index) => { + accum[keys[index]] = v; + return accum; + }, {}); +} +/** + * Assigns the %%values%% to %%target%% as read-only values. + * + * It %%types%% is specified, the values are checked. + */ +function defineProperties(target, values, types) { + for (let key in values) { + let value = values[key]; + const type = (types ? types[key] : null); + if (type) { + checkType(value, type, key); + } + Object.defineProperty(target, key, { enumerable: true, value, writable: false }); + } +} + +/** + * All errors in ethers include properties to ensure they are both + * human-readable (i.e. ``.message``) and machine-readable (i.e. ``.code``). + * + * The [[isError]] function can be used to check the error ``code`` and + * provide a type guard for the properties present on that error interface. + * + * @_section: api/utils/errors:Errors [about-errors] + */ +function stringify(value) { + if (value == null) { + return "null"; + } + if (Array.isArray(value)) { + return "[ " + (value.map(stringify)).join(", ") + " ]"; + } + if (value instanceof Uint8Array) { + const HEX = "0123456789abcdef"; + let result = "0x"; + for (let i = 0; i < value.length; i++) { + result += HEX[value[i] >> 4]; + result += HEX[value[i] & 0xf]; + } + return result; + } + if (typeof (value) === "object" && typeof (value.toJSON) === "function") { + return stringify(value.toJSON()); + } + switch (typeof (value)) { + case "boolean": + case "symbol": + return value.toString(); + case "bigint": + return BigInt(value).toString(); + case "number": + return (value).toString(); + case "string": + return JSON.stringify(value); + case "object": { + const keys = Object.keys(value); + keys.sort(); + return "{ " + keys.map((k) => `${stringify(k)}: ${stringify(value[k])}`).join(", ") + " }"; + } + } + return `[ COULD NOT SERIALIZE ]`; +} +/** + * Returns true if the %%error%% matches an error thrown by ethers + * that matches the error %%code%%. + * + * In TypeScript environments, this can be used to check that %%error%% + * matches an EthersError type, which means the expected properties will + * be set. + * + * @See [ErrorCodes](api:ErrorCode) + * @example + * try { + * // code.... + * } catch (e) { + * if (isError(e, "CALL_EXCEPTION")) { + * // The Type Guard has validated this object + * console.log(e.data); + * } + * } + */ +function isError(error, code) { + return (error && error.code === code); +} +/** + * Returns true if %%error%% is a [[CallExceptionError]. + */ +function isCallException(error) { + return isError(error, "CALL_EXCEPTION"); +} +/** + * Returns a new Error configured to the format ethers emits errors, with + * the %%message%%, [[api:ErrorCode]] %%code%% and additional properties + * for the corresponding EthersError. + * + * Each error in ethers includes the version of ethers, a + * machine-readable [[ErrorCode]], and depending on %%code%%, additional + * required properties. The error message will also include the %%message%%, + * ethers version, %%code%% and all additional properties, serialized. + */ +function makeError(message, code, info) { + let shortMessage = message; + { + const details = []; + if (info) { + if ("message" in info || "code" in info || "name" in info) { + throw new Error(`value will overwrite populated values: ${stringify(info)}`); + } + for (const key in info) { + if (key === "shortMessage") { + continue; + } + const value = (info[key]); + // try { + details.push(key + "=" + stringify(value)); + // } catch (error: any) { + // console.log("MMM", error.message); + // details.push(key + "=[could not serialize object]"); + // } + } + } + details.push(`code=${code}`); + details.push(`version=${version$4}`); + if (details.length) { + message += " (" + details.join(", ") + ")"; + } + } + let error; + switch (code) { + case "INVALID_ARGUMENT": + error = new TypeError(message); + break; + case "NUMERIC_FAULT": + case "BUFFER_OVERRUN": + error = new RangeError(message); + break; + default: + error = new Error(message); + } + defineProperties(error, { code }); + if (info) { + Object.assign(error, info); + } + if (error.shortMessage == null) { + defineProperties(error, { shortMessage }); + } + return error; +} +/** + * Throws an EthersError with %%message%%, %%code%% and additional error + * %%info%% when %%check%% is falsish.. + * + * @see [[api:makeError]] + */ +function assert$5(check, message, code, info) { + if (!check) { + throw makeError(message, code, info); + } +} +/** + * A simple helper to simply ensuring provided arguments match expected + * constraints, throwing if not. + * + * In TypeScript environments, the %%check%% has been asserted true, so + * any further code does not need additional compile-time checks. + */ +function assertArgument(check, message, name, value) { + assert$5(check, message, "INVALID_ARGUMENT", { argument: name, value: value }); +} +function assertArgumentCount(count, expectedCount, message) { + if (message == null) { + message = ""; + } + if (message) { + message = ": " + message; + } + assert$5(count >= expectedCount, "missing arguemnt" + message, "MISSING_ARGUMENT", { + count: count, + expectedCount: expectedCount + }); + assert$5(count <= expectedCount, "too many arguments" + message, "UNEXPECTED_ARGUMENT", { + count: count, + expectedCount: expectedCount + }); +} +const _normalizeForms = ["NFD", "NFC", "NFKD", "NFKC"].reduce((accum, form) => { + try { + // General test for normalize + /* c8 ignore start */ + if ("test".normalize(form) !== "test") { + throw new Error("bad"); + } + ; + /* c8 ignore stop */ + if (form === "NFD") { + const check = String.fromCharCode(0xe9).normalize("NFD"); + const expected = String.fromCharCode(0x65, 0x0301); + /* c8 ignore start */ + if (check !== expected) { + throw new Error("broken"); + } + /* c8 ignore stop */ + } + accum.push(form); + } + catch (error) { } + return accum; +}, []); +/** + * Throws if the normalization %%form%% is not supported. + */ +function assertNormalize(form) { + assert$5(_normalizeForms.indexOf(form) >= 0, "platform missing String.prototype.normalize", "UNSUPPORTED_OPERATION", { + operation: "String.prototype.normalize", info: { form } + }); +} +/** + * Many classes use file-scoped values to guard the constructor, + * making it effectively private. This facilitates that pattern + * by ensuring the %%givenGaurd%% matches the file-scoped %%guard%%, + * throwing if not, indicating the %%className%% if provided. + */ +function assertPrivate(givenGuard, guard, className) { + if (className == null) { + className = ""; + } + if (givenGuard !== guard) { + let method = className, operation = "new"; + if (className) { + method += "."; + operation += " " + className; + } + assert$5(false, `private constructor; use ${method}from* methods`, "UNSUPPORTED_OPERATION", { + operation + }); + } +} + +/** + * Some data helpers. + * + * + * @_subsection api/utils:Data Helpers [about-data] + */ +function _getBytes(value, name, copy) { + if (value instanceof Uint8Array) { + if (copy) { + return new Uint8Array(value); + } + return value; + } + if (typeof (value) === "string" && value.match(/^0x([0-9a-f][0-9a-f])*$/i)) { + const result = new Uint8Array((value.length - 2) / 2); + let offset = 2; + for (let i = 0; i < result.length; i++) { + result[i] = parseInt(value.substring(offset, offset + 2), 16); + offset += 2; + } + return result; + } + assertArgument(false, "invalid BytesLike value", name || "value", value); +} +/** + * Get a typed Uint8Array for %%value%%. If already a Uint8Array + * the original %%value%% is returned; if a copy is required use + * [[getBytesCopy]]. + * + * @see: getBytesCopy + */ +function getBytes(value, name) { + return _getBytes(value, name, false); +} +/** + * Get a typed Uint8Array for %%value%%, creating a copy if necessary + * to prevent any modifications of the returned value from being + * reflected elsewhere. + * + * @see: getBytes + */ +function getBytesCopy(value, name) { + return _getBytes(value, name, true); +} +/** + * Returns true if %%value%% is a valid [[HexString]]. + * + * If %%length%% is ``true`` or a //number//, it also checks that + * %%value%% is a valid [[DataHexString]] of %%length%% (if a //number//) + * bytes of data (e.g. ``0x1234`` is 2 bytes). + */ +function isHexString$1(value, length) { + if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) { + return false; + } + if (typeof (length) === "number" && value.length !== 2 + 2 * length) { + return false; + } + if (length === true && (value.length % 2) !== 0) { + return false; + } + return true; +} +/** + * Returns true if %%value%% is a valid representation of arbitrary + * data (i.e. a valid [[DataHexString]] or a Uint8Array). + */ +function isBytesLike(value) { + return (isHexString$1(value, true) || (value instanceof Uint8Array)); +} +const HexCharacters = "0123456789abcdef"; +/** + * Returns a [[DataHexString]] representation of %%data%%. + */ +function hexlify(data) { + const bytes = getBytes(data); + let result = "0x"; + for (let i = 0; i < bytes.length; i++) { + const v = bytes[i]; + result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f]; + } + return result; +} +/** + * Returns a [[DataHexString]] by concatenating all values + * within %%data%%. + */ +function concat$3(datas) { + return "0x" + datas.map((d) => hexlify(d).substring(2)).join(""); +} +/** + * Returns the length of %%data%%, in bytes. + */ +function dataLength(data) { + if (isHexString$1(data, true)) { + return (data.length - 2) / 2; + } + return getBytes(data).length; +} +/** + * Returns a [[DataHexString]] by slicing %%data%% from the %%start%% + * offset to the %%end%% offset. + * + * By default %%start%% is 0 and %%end%% is the length of %%data%%. + */ +function dataSlice(data, start, end) { + const bytes = getBytes(data); + if (end != null && end > bytes.length) { + assert$5(false, "cannot slice beyond data bounds", "BUFFER_OVERRUN", { + buffer: bytes, length: bytes.length, offset: end + }); + } + return hexlify(bytes.slice((start == null) ? 0 : start, (end == null) ? bytes.length : end)); +} +function zeroPad(data, length, left) { + const bytes = getBytes(data); + assert$5(length >= bytes.length, "padding exceeds data length", "BUFFER_OVERRUN", { + buffer: new Uint8Array(bytes), + length: length, + offset: length + 1 + }); + const result = new Uint8Array(length); + result.fill(0); + if (left) { + result.set(bytes, length - bytes.length); + } + else { + result.set(bytes, 0); + } + return hexlify(result); +} +/** + * Return the [[DataHexString]] of %%data%% padded on the **left** + * to %%length%% bytes. + * + * If %%data%% already exceeds %%length%%, a [[BufferOverrunError]] is + * thrown. + * + * This pads data the same as **values** are in Solidity + * (e.g. ``uint128``). + */ +function zeroPadValue(data, length) { + return zeroPad(data, length, true); +} +/** + * Return the [[DataHexString]] of %%data%% padded on the **right** + * to %%length%% bytes. + * + * If %%data%% already exceeds %%length%%, a [[BufferOverrunError]] is + * thrown. + * + * This pads data the same as **bytes** are in Solidity + * (e.g. ``bytes16``). + */ +function zeroPadBytes(data, length) { + return zeroPad(data, length, false); +} + +/** + * Some mathematic operations. + * + * @_subsection: api/utils:Math Helpers [about-maths] + */ +const BN_0$a = BigInt(0); +const BN_1$4 = BigInt(1); +//const BN_Max256 = (BN_1 << BigInt(256)) - BN_1; +// IEEE 754 support 53-bits of mantissa +const maxValue = 0x1fffffffffffff; +/** + * Convert %%value%% from a twos-compliment representation of %%width%% + * bits to its value. + * + * If the highest bit is ``1``, the result will be negative. + */ +function fromTwos(_value, _width) { + const value = getUint(_value, "value"); + const width = BigInt(getNumber(_width, "width")); + assert$5((value >> width) === BN_0$a, "overflow", "NUMERIC_FAULT", { + operation: "fromTwos", fault: "overflow", value: _value + }); + // Top bit set; treat as a negative value + if (value >> (width - BN_1$4)) { + const mask = (BN_1$4 << width) - BN_1$4; + return -(((~value) & mask) + BN_1$4); + } + return value; +} +/** + * Convert %%value%% to a twos-compliment representation of + * %%width%% bits. + * + * The result will always be positive. + */ +function toTwos(_value, _width) { + let value = getBigInt(_value, "value"); + const width = BigInt(getNumber(_width, "width")); + const limit = (BN_1$4 << (width - BN_1$4)); + if (value < BN_0$a) { + value = -value; + assert$5(value <= limit, "too low", "NUMERIC_FAULT", { + operation: "toTwos", fault: "overflow", value: _value + }); + const mask = (BN_1$4 << width) - BN_1$4; + return ((~value) & mask) + BN_1$4; + } + else { + assert$5(value < limit, "too high", "NUMERIC_FAULT", { + operation: "toTwos", fault: "overflow", value: _value + }); + } + return value; +} +/** + * Mask %%value%% with a bitmask of %%bits%% ones. + */ +function mask(_value, _bits) { + const value = getUint(_value, "value"); + const bits = BigInt(getNumber(_bits, "bits")); + return value & ((BN_1$4 << bits) - BN_1$4); +} +/** + * Gets a BigInt from %%value%%. If it is an invalid value for + * a BigInt, then an ArgumentError will be thrown for %%name%%. + */ +function getBigInt(value, name) { + switch (typeof (value)) { + case "bigint": return value; + case "number": + assertArgument(Number.isInteger(value), "underflow", name || "value", value); + assertArgument(value >= -maxValue && value <= maxValue, "overflow", name || "value", value); + return BigInt(value); + case "string": + try { + if (value === "") { + throw new Error("empty string"); + } + if (value[0] === "-" && value[1] !== "-") { + return -BigInt(value.substring(1)); + } + return BigInt(value); + } + catch (e) { + assertArgument(false, `invalid BigNumberish string: ${e.message}`, name || "value", value); + } + } + assertArgument(false, "invalid BigNumberish value", name || "value", value); +} +/** + * Returns %%value%% as a bigint, validating it is valid as a bigint + * value and that it is positive. + */ +function getUint(value, name) { + const result = getBigInt(value, name); + assert$5(result >= BN_0$a, "unsigned value cannot be negative", "NUMERIC_FAULT", { + fault: "overflow", operation: "getUint", value + }); + return result; +} +const Nibbles$1 = "0123456789abcdef"; +/* + * Converts %%value%% to a BigInt. If %%value%% is a Uint8Array, it + * is treated as Big Endian data. + */ +function toBigInt(value) { + if (value instanceof Uint8Array) { + let result = "0x0"; + for (const v of value) { + result += Nibbles$1[v >> 4]; + result += Nibbles$1[v & 0x0f]; + } + return BigInt(result); + } + return getBigInt(value); +} +/** + * Gets a //number// from %%value%%. If it is an invalid value for + * a //number//, then an ArgumentError will be thrown for %%name%%. + */ +function getNumber(value, name) { + switch (typeof (value)) { + case "bigint": + assertArgument(value >= -maxValue && value <= maxValue, "overflow", name || "value", value); + return Number(value); + case "number": + assertArgument(Number.isInteger(value), "underflow", name || "value", value); + assertArgument(value >= -maxValue && value <= maxValue, "overflow", name || "value", value); + return value; + case "string": + try { + if (value === "") { + throw new Error("empty string"); + } + return getNumber(BigInt(value), name); + } + catch (e) { + assertArgument(false, `invalid numeric string: ${e.message}`, name || "value", value); + } + } + assertArgument(false, "invalid numeric value", name || "value", value); +} +/** + * Converts %%value%% to a number. If %%value%% is a Uint8Array, it + * is treated as Big Endian data. Throws if the value is not safe. + */ +function toNumber$4(value) { + return getNumber(toBigInt(value)); +} +/** + * Converts %%value%% to a Big Endian hexstring, optionally padded to + * %%width%% bytes. + */ +function toBeHex(_value, _width) { + const value = getUint(_value, "value"); + let result = value.toString(16); + if (_width == null) { + // Ensure the value is of even length + if (result.length % 2) { + result = "0" + result; + } + } + else { + const width = getNumber(_width, "width"); + assert$5(width * 2 >= result.length, `value exceeds width (${width} bytes)`, "NUMERIC_FAULT", { + operation: "toBeHex", + fault: "overflow", + value: _value + }); + // Pad the value to the required width + while (result.length < (width * 2)) { + result = "0" + result; + } + } + return "0x" + result; +} +/** + * Converts %%value%% to a Big Endian Uint8Array. + */ +function toBeArray(_value) { + const value = getUint(_value, "value"); + if (value === BN_0$a) { + return new Uint8Array([]); + } + let hex = value.toString(16); + if (hex.length % 2) { + hex = "0" + hex; + } + const result = new Uint8Array(hex.length / 2); + for (let i = 0; i < result.length; i++) { + const offset = i * 2; + result[i] = parseInt(hex.substring(offset, offset + 2), 16); + } + return result; +} +/** + * Returns a [[HexString]] for %%value%% safe to use as a //Quantity//. + * + * A //Quantity// does not have and leading 0 values unless the value is + * the literal value `0x0`. This is most commonly used for JSSON-RPC + * numeric values. + */ +function toQuantity(value) { + let result = hexlify(isBytesLike(value) ? value : toBeArray(value)).substring(2); + while (result.startsWith("0")) { + result = result.substring(1); + } + if (result === "") { + result = "0"; + } + return "0x" + result; +} + +/** + * The [Base58 Encoding](link-base58) scheme allows a **numeric** value + * to be encoded as a compact string using a radix of 58 using only + * alpha-numeric characters. Confusingly similar characters are omitted + * (i.e. ``"l0O"``). + * + * Note that Base58 encodes a **numeric** value, not arbitrary bytes, + * since any zero-bytes on the left would get removed. To mitigate this + * issue most schemes that use Base58 choose specific high-order values + * to ensure non-zero prefixes. + * + * @_subsection: api/utils:Base58 Encoding [about-base58] + */ +const Alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; +let Lookup = null; +function getAlpha(letter) { + if (Lookup == null) { + Lookup = {}; + for (let i = 0; i < Alphabet.length; i++) { + Lookup[Alphabet[i]] = BigInt(i); + } + } + const result = Lookup[letter]; + assertArgument(result != null, `invalid base58 value`, "letter", letter); + return result; +} +const BN_0$9 = BigInt(0); +const BN_58 = BigInt(58); +/** + * Encode %%value%% as a Base58-encoded string. + */ +function encodeBase58(_value) { + const bytes = getBytes(_value); + let value = toBigInt(bytes); + let result = ""; + while (value) { + result = Alphabet[Number(value % BN_58)] + result; + value /= BN_58; + } + // Account for leading padding zeros + for (let i = 0; i < bytes.length; i++) { + if (bytes[i]) { + break; + } + result = Alphabet[0] + result; + } + return result; +} +/** + * Decode the Base58-encoded %%value%%. + */ +function decodeBase58(value) { + let result = BN_0$9; + for (let i = 0; i < value.length; i++) { + result *= BN_58; + result += getAlpha(value[i]); + } + return result; +} + +/** + * [Base64 encoding](link-wiki-base64) using 6-bit words to encode + * arbitrary bytes into a string using 65 printable symbols, the + * upper-case and lower-case alphabet, the digits ``0`` through ``9``, + * ``"+"`` and ``"/"`` with the ``"="`` used for padding. + * + * @_subsection: api/utils:Base64 Encoding [about-base64] + */ +/** + * Decodes the base-64 encoded %%value%%. + * + * @example: + * // The decoded value is always binary data... + * result = decodeBase64("SGVsbG8gV29ybGQhIQ==") + * //_result: + * + * // ...use toUtf8String to convert it to a string. + * toUtf8String(result) + * //_result: + * + * // Decoding binary data + * decodeBase64("EjQ=") + * //_result: + */ +function decodeBase64(value) { + return getBytesCopy(Buffer.from(value, "base64")); +} +/** + * Encodes %%data%% as a base-64 encoded string. + * + * @example: + * // Encoding binary data as a hexstring + * encodeBase64("0x1234") + * //_result: + * + * // Encoding binary data as a Uint8Array + * encodeBase64(new Uint8Array([ 0x12, 0x34 ])) + * //_result: + * + * // The input MUST be data... + * encodeBase64("Hello World!!") + * //_error: + * + * // ...use toUtf8Bytes for this. + * encodeBase64(toUtf8Bytes("Hello World!!")) + * //_result: + */ +function encodeBase64(data) { + return Buffer.from(getBytes(data)).toString("base64"); +} + +/** + * Events allow for applications to use the observer pattern, which + * allows subscribing and publishing events, outside the normal + * execution paths. + * + * @_section api/utils/events:Events [about-events] + */ +/** + * When an [[EventEmitterable]] triggers a [[Listener]], the + * callback always ahas one additional argument passed, which is + * an **EventPayload**. + */ +class EventPayload { + /** + * The event filter. + */ + filter; + /** + * The **EventEmitterable**. + */ + emitter; + #listener; + /** + * Create a new **EventPayload** for %%emitter%% with + * the %%listener%% and for %%filter%%. + */ + constructor(emitter, listener, filter) { + this.#listener = listener; + defineProperties(this, { emitter, filter }); + } + /** + * Unregister the triggered listener for future events. + */ + async removeListener() { + if (this.#listener == null) { + return; + } + await this.emitter.off(this.filter, this.#listener); + } +} + +/** + * Using strings in Ethereum (or any security-basd system) requires + * additional care. These utilities attempt to mitigate some of the + * safety issues as well as provide the ability to recover and analyse + * strings. + * + * @_subsection api/utils:Strings and UTF-8 [about-strings] + */ +function errorFunc(reason, offset, bytes, output, badCodepoint) { + assertArgument(false, `invalid codepoint at offset ${offset}; ${reason}`, "bytes", bytes); +} +function ignoreFunc(reason, offset, bytes, output, badCodepoint) { + // If there is an invalid prefix (including stray continuation), skip any additional continuation bytes + if (reason === "BAD_PREFIX" || reason === "UNEXPECTED_CONTINUE") { + let i = 0; + for (let o = offset + 1; o < bytes.length; o++) { + if (bytes[o] >> 6 !== 0x02) { + break; + } + i++; + } + return i; + } + // This byte runs us past the end of the string, so just jump to the end + // (but the first byte was read already read and therefore skipped) + if (reason === "OVERRUN") { + return bytes.length - offset - 1; + } + // Nothing to skip + return 0; +} +function replaceFunc(reason, offset, bytes, output, badCodepoint) { + // Overlong representations are otherwise "valid" code points; just non-deistingtished + if (reason === "OVERLONG") { + assertArgument(typeof (badCodepoint) === "number", "invalid bad code point for replacement", "badCodepoint", badCodepoint); + output.push(badCodepoint); + return 0; + } + // Put the replacement character into the output + output.push(0xfffd); + // Otherwise, process as if ignoring errors + return ignoreFunc(reason, offset, bytes); +} +/** + * A handful of popular, built-in UTF-8 error handling strategies. + * + * **``"error"``** - throws on ANY illegal UTF-8 sequence or + * non-canonical (overlong) codepoints (this is the default) + * + * **``"ignore"``** - silently drops any illegal UTF-8 sequence + * and accepts non-canonical (overlong) codepoints + * + * **``"replace"``** - replace any illegal UTF-8 sequence with the + * UTF-8 replacement character (i.e. ``"\\ufffd"``) and accepts + * non-canonical (overlong) codepoints + * + * @returns: Record<"error" | "ignore" | "replace", Utf8ErrorFunc> + */ +const Utf8ErrorFuncs = Object.freeze({ + error: errorFunc, + ignore: ignoreFunc, + replace: replaceFunc +}); +// http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499 +function getUtf8CodePoints(_bytes, onError) { + if (onError == null) { + onError = Utf8ErrorFuncs.error; + } + const bytes = getBytes(_bytes, "bytes"); + const result = []; + let i = 0; + // Invalid bytes are ignored + while (i < bytes.length) { + const c = bytes[i++]; + // 0xxx xxxx + if (c >> 7 === 0) { + result.push(c); + continue; + } + // Multibyte; how many bytes left for this character? + let extraLength = null; + let overlongMask = null; + // 110x xxxx 10xx xxxx + if ((c & 0xe0) === 0xc0) { + extraLength = 1; + overlongMask = 0x7f; + // 1110 xxxx 10xx xxxx 10xx xxxx + } + else if ((c & 0xf0) === 0xe0) { + extraLength = 2; + overlongMask = 0x7ff; + // 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx + } + else if ((c & 0xf8) === 0xf0) { + extraLength = 3; + overlongMask = 0xffff; + } + else { + if ((c & 0xc0) === 0x80) { + i += onError("UNEXPECTED_CONTINUE", i - 1, bytes, result); + } + else { + i += onError("BAD_PREFIX", i - 1, bytes, result); + } + continue; + } + // Do we have enough bytes in our data? + if (i - 1 + extraLength >= bytes.length) { + i += onError("OVERRUN", i - 1, bytes, result); + continue; + } + // Remove the length prefix from the char + let res = c & ((1 << (8 - extraLength - 1)) - 1); + for (let j = 0; j < extraLength; j++) { + let nextChar = bytes[i]; + // Invalid continuation byte + if ((nextChar & 0xc0) != 0x80) { + i += onError("MISSING_CONTINUE", i, bytes, result); + res = null; + break; + } + res = (res << 6) | (nextChar & 0x3f); + i++; + } + // See above loop for invalid continuation byte + if (res === null) { + continue; + } + // Maximum code point + if (res > 0x10ffff) { + i += onError("OUT_OF_RANGE", i - 1 - extraLength, bytes, result, res); + continue; + } + // Reserved for UTF-16 surrogate halves + if (res >= 0xd800 && res <= 0xdfff) { + i += onError("UTF16_SURROGATE", i - 1 - extraLength, bytes, result, res); + continue; + } + // Check for overlong sequences (more bytes than needed) + if (res <= overlongMask) { + i += onError("OVERLONG", i - 1 - extraLength, bytes, result, res); + continue; + } + result.push(res); + } + return result; +} +// http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array +/** + * Returns the UTF-8 byte representation of %%str%%. + * + * If %%form%% is specified, the string is normalized. + */ +function toUtf8Bytes$1(str, form) { + assertArgument(typeof (str) === "string", "invalid string value", "str", str); + if (form != null) { + assertNormalize(form); + str = str.normalize(form); + } + let result = []; + for (let i = 0; i < str.length; i++) { + const c = str.charCodeAt(i); + if (c < 0x80) { + result.push(c); + } + else if (c < 0x800) { + result.push((c >> 6) | 0xc0); + result.push((c & 0x3f) | 0x80); + } + else if ((c & 0xfc00) == 0xd800) { + i++; + const c2 = str.charCodeAt(i); + assertArgument(i < str.length && ((c2 & 0xfc00) === 0xdc00), "invalid surrogate pair", "str", str); + // Surrogate Pair + const pair = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff); + result.push((pair >> 18) | 0xf0); + result.push(((pair >> 12) & 0x3f) | 0x80); + result.push(((pair >> 6) & 0x3f) | 0x80); + result.push((pair & 0x3f) | 0x80); + } + else { + result.push((c >> 12) | 0xe0); + result.push(((c >> 6) & 0x3f) | 0x80); + result.push((c & 0x3f) | 0x80); + } + } + return new Uint8Array(result); +} +//export +function _toUtf8String(codePoints) { + return codePoints.map((codePoint) => { + if (codePoint <= 0xffff) { + return String.fromCharCode(codePoint); + } + codePoint -= 0x10000; + return String.fromCharCode((((codePoint >> 10) & 0x3ff) + 0xd800), ((codePoint & 0x3ff) + 0xdc00)); + }).join(""); +} +/** + * Returns the string represented by the UTF-8 data %%bytes%%. + * + * When %%onError%% function is specified, it is called on UTF-8 + * errors allowing recovery using the [[Utf8ErrorFunc]] API. + * (default: [error](Utf8ErrorFuncs)) + */ +function toUtf8String(bytes, onError) { + return _toUtf8String(getUtf8CodePoints(bytes, onError)); +} + +/** + * @_ignore: + */ +function createGetUrl(options) { + async function getUrl(req, signal) { + const protocol = req.url.split(":")[0].toLowerCase(); + assert$5(protocol === "http" || protocol === "https", `unsupported protocol ${protocol}`, "UNSUPPORTED_OPERATION", { + info: { protocol }, + operation: "request" + }); + assert$5(protocol === "https" || !req.credentials || req.allowInsecureAuthentication, "insecure authorized connections unsupported", "UNSUPPORTED_OPERATION", { + operation: "request" + }); + const method = req.method; + const headers = Object.assign({}, req.headers); + const reqOptions = { method, headers }; + if (options) { + if (options.agent) { + reqOptions.agent = options.agent; + } + } + const request = ((protocol === "http") ? http$2 : https$2).request(req.url, reqOptions); + request.setTimeout(req.timeout); + const body = req.body; + if (body) { + request.write(Buffer.from(body)); + } + request.end(); + return new Promise((resolve, reject) => { + // @TODO: Node 15 added AbortSignal; once we drop support for + // Node14, we can add that in here too + request.once("response", (resp) => { + const statusCode = resp.statusCode || 0; + const statusMessage = resp.statusMessage || ""; + const headers = Object.keys(resp.headers || {}).reduce((accum, name) => { + let value = resp.headers[name] || ""; + if (Array.isArray(value)) { + value = value.join(", "); + } + accum[name] = value; + return accum; + }, {}); + let body = null; + //resp.setEncoding("utf8"); + resp.on("data", (chunk) => { + if (signal) { + try { + signal.checkSignal(); + } + catch (error) { + return reject(error); + } + } + if (body == null) { + body = chunk; + } + else { + const newBody = new Uint8Array(body.length + chunk.length); + newBody.set(body, 0); + newBody.set(chunk, body.length); + body = newBody; + } + }); + resp.on("end", () => { + if (headers["content-encoding"] === "gzip" && body) { + body = getBytes(zlib$1.gunzipSync(body)); + } + resolve({ statusCode, statusMessage, headers, body }); + }); + resp.on("error", (error) => { + //@TODO: Should this just return nornal response with a server error? + error.response = { statusCode, statusMessage, headers, body }; + reject(error); + }); + }); + request.on("error", (error) => { reject(error); }); + }); + } + return getUrl; +} + +/** + * Fetching content from the web is environment-specific, so Ethers + * provides an abstraction that each environment can implement to provide + * this service. + * + * On [Node.js](link-node), the ``http`` and ``https`` libs are used to + * create a request object, register event listeners and process data + * and populate the [[FetchResponse]]. + * + * In a browser, the [DOM fetch](link-js-fetch) is used, and the resulting + * ``Promise`` is waited on to retrieve the payload. + * + * The [[FetchRequest]] is responsible for handling many common situations, + * such as redirects, server throttling, authentication, etc. + * + * It also handles common gateways, such as IPFS and data URIs. + * + * @_section api/utils/fetching:Fetching Web Content [about-fetch] + */ +const MAX_ATTEMPTS = 12; +const SLOT_INTERVAL = 250; +// The global FetchGetUrlFunc implementation. +let defaultGetUrlFunc = createGetUrl(); +const reData = new RegExp("^data:([^;:]*)?(;base64)?,(.*)$", "i"); +const reIpfs = new RegExp("^ipfs:/\/(ipfs/)?(.*)$", "i"); +// If locked, new Gateways cannot be added +let locked$5 = false; +// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs +async function dataGatewayFunc(url, signal) { + try { + const match = url.match(reData); + if (!match) { + throw new Error("invalid data"); + } + return new FetchResponse(200, "OK", { + "content-type": (match[1] || "text/plain"), + }, (match[2] ? decodeBase64(match[3]) : unpercent(match[3]))); + } + catch (error) { + return new FetchResponse(599, "BAD REQUEST (invalid data: URI)", {}, null, new FetchRequest(url)); + } +} +/** + * Returns a [[FetchGatewayFunc]] for fetching content from a standard + * IPFS gateway hosted at %%baseUrl%%. + */ +function getIpfsGatewayFunc(baseUrl) { + async function gatewayIpfs(url, signal) { + try { + const match = url.match(reIpfs); + if (!match) { + throw new Error("invalid link"); + } + return new FetchRequest(`${baseUrl}${match[2]}`); + } + catch (error) { + return new FetchResponse(599, "BAD REQUEST (invalid IPFS URI)", {}, null, new FetchRequest(url)); + } + } + return gatewayIpfs; +} +const Gateways = { + "data": dataGatewayFunc, + "ipfs": getIpfsGatewayFunc("https:/\/gateway.ipfs.io/ipfs/") +}; +const fetchSignals = new WeakMap(); +/** + * @_ignore + */ +class FetchCancelSignal { + #listeners; + #cancelled; + constructor(request) { + this.#listeners = []; + this.#cancelled = false; + fetchSignals.set(request, () => { + if (this.#cancelled) { + return; + } + this.#cancelled = true; + for (const listener of this.#listeners) { + setTimeout(() => { listener(); }, 0); + } + this.#listeners = []; + }); + } + addListener(listener) { + assert$5(!this.#cancelled, "singal already cancelled", "UNSUPPORTED_OPERATION", { + operation: "fetchCancelSignal.addCancelListener" + }); + this.#listeners.push(listener); + } + get cancelled() { return this.#cancelled; } + checkSignal() { + assert$5(!this.cancelled, "cancelled", "CANCELLED", {}); + } +} +// Check the signal, throwing if it is cancelled +function checkSignal(signal) { + if (signal == null) { + throw new Error("missing signal; should not happen"); + } + signal.checkSignal(); + return signal; +} +/** + * Represents a request for a resource using a URI. + * + * By default, the supported schemes are ``HTTP``, ``HTTPS``, ``data:``, + * and ``IPFS:``. + * + * Additional schemes can be added globally using [[registerGateway]]. + * + * @example: + * req = new FetchRequest("https://www.ricmoo.com") + * resp = await req.send() + * resp.body.length + * //_result: + */ +class FetchRequest { + #allowInsecure; + #gzip; + #headers; + #method; + #timeout; + #url; + #body; + #bodyType; + #creds; + // Hooks + #preflight; + #process; + #retry; + #signal; + #throttle; + #getUrlFunc; + /** + * The fetch URL to request. + */ + get url() { return this.#url; } + set url(url) { + this.#url = String(url); + } + /** + * The fetch body, if any, to send as the request body. //(default: null)// + * + * When setting a body, the intrinsic ``Content-Type`` is automatically + * set and will be used if **not overridden** by setting a custom + * header. + * + * If %%body%% is null, the body is cleared (along with the + * intrinsic ``Content-Type``). + * + * If %%body%% is a string, the intrinsic ``Content-Type`` is set to + * ``text/plain``. + * + * If %%body%% is a Uint8Array, the intrinsic ``Content-Type`` is set to + * ``application/octet-stream``. + * + * If %%body%% is any other object, the intrinsic ``Content-Type`` is + * set to ``application/json``. + */ + get body() { + if (this.#body == null) { + return null; + } + return new Uint8Array(this.#body); + } + set body(body) { + if (body == null) { + this.#body = undefined; + this.#bodyType = undefined; + } + else if (typeof (body) === "string") { + this.#body = toUtf8Bytes$1(body); + this.#bodyType = "text/plain"; + } + else if (body instanceof Uint8Array) { + this.#body = body; + this.#bodyType = "application/octet-stream"; + } + else if (typeof (body) === "object") { + this.#body = toUtf8Bytes$1(JSON.stringify(body)); + this.#bodyType = "application/json"; + } + else { + throw new Error("invalid body"); + } + } + /** + * Returns true if the request has a body. + */ + hasBody() { + return (this.#body != null); + } + /** + * The HTTP method to use when requesting the URI. If no method + * has been explicitly set, then ``GET`` is used if the body is + * null and ``POST`` otherwise. + */ + get method() { + if (this.#method) { + return this.#method; + } + if (this.hasBody()) { + return "POST"; + } + return "GET"; + } + set method(method) { + if (method == null) { + method = ""; + } + this.#method = String(method).toUpperCase(); + } + /** + * The headers that will be used when requesting the URI. All + * keys are lower-case. + * + * This object is a copy, so any changes will **NOT** be reflected + * in the ``FetchRequest``. + * + * To set a header entry, use the ``setHeader`` method. + */ + get headers() { + const headers = Object.assign({}, this.#headers); + if (this.#creds) { + headers["authorization"] = `Basic ${encodeBase64(toUtf8Bytes$1(this.#creds))}`; + } + if (this.allowGzip) { + headers["accept-encoding"] = "gzip"; + } + if (headers["content-type"] == null && this.#bodyType) { + headers["content-type"] = this.#bodyType; + } + if (this.body) { + headers["content-length"] = String(this.body.length); + } + return headers; + } + /** + * Get the header for %%key%%, ignoring case. + */ + getHeader(key) { + return this.headers[key.toLowerCase()]; + } + /** + * Set the header for %%key%% to %%value%%. All values are coerced + * to a string. + */ + setHeader(key, value) { + this.#headers[String(key).toLowerCase()] = String(value); + } + /** + * Clear all headers, resetting all intrinsic headers. + */ + clearHeaders() { + this.#headers = {}; + } + [Symbol.iterator]() { + const headers = this.headers; + const keys = Object.keys(headers); + let index = 0; + return { + next: () => { + if (index < keys.length) { + const key = keys[index++]; + return { + value: [key, headers[key]], done: false + }; + } + return { value: undefined, done: true }; + } + }; + } + /** + * The value that will be sent for the ``Authorization`` header. + * + * To set the credentials, use the ``setCredentials`` method. + */ + get credentials() { + return this.#creds || null; + } + /** + * Sets an ``Authorization`` for %%username%% with %%password%%. + */ + setCredentials(username, password) { + assertArgument(!username.match(/:/), "invalid basic authentication username", "username", "[REDACTED]"); + this.#creds = `${username}:${password}`; + } + /** + * Enable and request gzip-encoded responses. The response will + * automatically be decompressed. //(default: true)// + */ + get allowGzip() { + return this.#gzip; + } + set allowGzip(value) { + this.#gzip = !!value; + } + /** + * Allow ``Authentication`` credentials to be sent over insecure + * channels. //(default: false)// + */ + get allowInsecureAuthentication() { + return !!this.#allowInsecure; + } + set allowInsecureAuthentication(value) { + this.#allowInsecure = !!value; + } + /** + * The timeout (in milliseconds) to wait for a complete response. + * //(default: 5 minutes)// + */ + get timeout() { return this.#timeout; } + set timeout(timeout) { + assertArgument(timeout >= 0, "timeout must be non-zero", "timeout", timeout); + this.#timeout = timeout; + } + /** + * This function is called prior to each request, for example + * during a redirection or retry in case of server throttling. + * + * This offers an opportunity to populate headers or update + * content before sending a request. + */ + get preflightFunc() { + return this.#preflight || null; + } + set preflightFunc(preflight) { + this.#preflight = preflight; + } + /** + * This function is called after each response, offering an + * opportunity to provide client-level throttling or updating + * response data. + * + * Any error thrown in this causes the ``send()`` to throw. + * + * To schedule a retry attempt (assuming the maximum retry limit + * has not been reached), use [[response.throwThrottleError]]. + */ + get processFunc() { + return this.#process || null; + } + set processFunc(process) { + this.#process = process; + } + /** + * This function is called on each retry attempt. + */ + get retryFunc() { + return this.#retry || null; + } + set retryFunc(retry) { + this.#retry = retry; + } + /** + * This function is called to fetch content from HTTP and + * HTTPS URLs and is platform specific (e.g. nodejs vs + * browsers). + * + * This is by default the currently registered global getUrl + * function, which can be changed using [[registerGetUrl]]. + * If this has been set, setting is to ``null`` will cause + * this FetchRequest (and any future clones) to revert back to + * using the currently registered global getUrl function. + * + * Setting this is generally not necessary, but may be useful + * for developers that wish to intercept requests or to + * configurege a proxy or other agent. + */ + get getUrlFunc() { + return this.#getUrlFunc || defaultGetUrlFunc; + } + set getUrlFunc(value) { + this.#getUrlFunc = value; + } + /** + * Create a new FetchRequest instance with default values. + * + * Once created, each property may be set before issuing a + * ``.send()`` to make the request. + */ + constructor(url) { + this.#url = String(url); + this.#allowInsecure = false; + this.#gzip = true; + this.#headers = {}; + this.#method = ""; + this.#timeout = 300000; + this.#throttle = { + slotInterval: SLOT_INTERVAL, + maxAttempts: MAX_ATTEMPTS + }; + this.#getUrlFunc = null; + } + toString() { + return ``; + } + /** + * Update the throttle parameters used to determine maximum + * attempts and exponential-backoff properties. + */ + setThrottleParams(params) { + if (params.slotInterval != null) { + this.#throttle.slotInterval = params.slotInterval; + } + if (params.maxAttempts != null) { + this.#throttle.maxAttempts = params.maxAttempts; + } + } + async #send(attempt, expires, delay, _request, _response) { + if (attempt >= this.#throttle.maxAttempts) { + return _response.makeServerError("exceeded maximum retry limit"); + } + assert$5(getTime$1() <= expires, "timeout", "TIMEOUT", { + operation: "request.send", reason: "timeout", request: _request + }); + if (delay > 0) { + await wait(delay); + } + let req = this.clone(); + const scheme = (req.url.split(":")[0] || "").toLowerCase(); + // Process any Gateways + if (scheme in Gateways) { + const result = await Gateways[scheme](req.url, checkSignal(_request.#signal)); + if (result instanceof FetchResponse) { + let response = result; + if (this.processFunc) { + checkSignal(_request.#signal); + try { + response = await this.processFunc(req, response); + } + catch (error) { + // Something went wrong during processing; throw a 5xx server error + if (error.throttle == null || typeof (error.stall) !== "number") { + response.makeServerError("error in post-processing function", error).assertOk(); + } + // Ignore throttling + } + } + return response; + } + req = result; + } + // We have a preflight function; update the request + if (this.preflightFunc) { + req = await this.preflightFunc(req); + } + const resp = await this.getUrlFunc(req, checkSignal(_request.#signal)); + let response = new FetchResponse(resp.statusCode, resp.statusMessage, resp.headers, resp.body, _request); + if (response.statusCode === 301 || response.statusCode === 302) { + // Redirect + try { + const location = response.headers.location || ""; + return req.redirect(location).#send(attempt + 1, expires, 0, _request, response); + } + catch (error) { } + // Things won't get any better on another attempt; abort + return response; + } + else if (response.statusCode === 429) { + // Throttle + if (this.retryFunc == null || (await this.retryFunc(req, response, attempt))) { + const retryAfter = response.headers["retry-after"]; + let delay = this.#throttle.slotInterval * Math.trunc(Math.random() * Math.pow(2, attempt)); + if (typeof (retryAfter) === "string" && retryAfter.match(/^[1-9][0-9]*$/)) { + delay = parseInt(retryAfter); + } + return req.clone().#send(attempt + 1, expires, delay, _request, response); + } + } + if (this.processFunc) { + checkSignal(_request.#signal); + try { + response = await this.processFunc(req, response); + } + catch (error) { + // Something went wrong during processing; throw a 5xx server error + if (error.throttle == null || typeof (error.stall) !== "number") { + response.makeServerError("error in post-processing function", error).assertOk(); + } + // Throttle + let delay = this.#throttle.slotInterval * Math.trunc(Math.random() * Math.pow(2, attempt)); + if (error.stall >= 0) { + delay = error.stall; + } + return req.clone().#send(attempt + 1, expires, delay, _request, response); + } + } + return response; + } + /** + * Resolves to the response by sending the request. + */ + send() { + assert$5(this.#signal == null, "request already sent", "UNSUPPORTED_OPERATION", { operation: "fetchRequest.send" }); + this.#signal = new FetchCancelSignal(this); + return this.#send(0, getTime$1() + this.timeout, 0, this, new FetchResponse(0, "", {}, null, this)); + } + /** + * Cancels the inflight response, causing a ``CANCELLED`` + * error to be rejected from the [[send]]. + */ + cancel() { + assert$5(this.#signal != null, "request has not been sent", "UNSUPPORTED_OPERATION", { operation: "fetchRequest.cancel" }); + const signal = fetchSignals.get(this); + if (!signal) { + throw new Error("missing signal; should not happen"); + } + signal(); + } + /** + * Returns a new [[FetchRequest]] that represents the redirection + * to %%location%%. + */ + redirect(location) { + // Redirection; for now we only support absolute locations + const current = this.url.split(":")[0].toLowerCase(); + const target = location.split(":")[0].toLowerCase(); + // Don't allow redirecting: + // - non-GET requests + // - downgrading the security (e.g. https => http) + // - to non-HTTP (or non-HTTPS) protocols [this could be relaxed?] + assert$5(this.method === "GET" && (current !== "https" || target !== "http") && location.match(/^https?:/), `unsupported redirect`, "UNSUPPORTED_OPERATION", { + operation: `redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(location)})` + }); + // Create a copy of this request, with a new URL + const req = new FetchRequest(location); + req.method = "GET"; + req.allowGzip = this.allowGzip; + req.timeout = this.timeout; + req.#headers = Object.assign({}, this.#headers); + if (this.#body) { + req.#body = new Uint8Array(this.#body); + } + req.#bodyType = this.#bodyType; + // Do not forward credentials unless on the same domain; only absolute + //req.allowInsecure = false; + // paths are currently supported; may want a way to specify to forward? + //setStore(req.#props, "creds", getStore(this.#pros, "creds")); + return req; + } + /** + * Create a new copy of this request. + */ + clone() { + const clone = new FetchRequest(this.url); + // Preserve "default method" (i.e. null) + clone.#method = this.#method; + // Preserve "default body" with type, copying the Uint8Array is present + if (this.#body) { + clone.#body = this.#body; + } + clone.#bodyType = this.#bodyType; + // Preserve "default headers" + clone.#headers = Object.assign({}, this.#headers); + // Credentials is readonly, so we copy internally + clone.#creds = this.#creds; + if (this.allowGzip) { + clone.allowGzip = true; + } + clone.timeout = this.timeout; + if (this.allowInsecureAuthentication) { + clone.allowInsecureAuthentication = true; + } + clone.#preflight = this.#preflight; + clone.#process = this.#process; + clone.#retry = this.#retry; + clone.#throttle = Object.assign({}, this.#throttle); + clone.#getUrlFunc = this.#getUrlFunc; + return clone; + } + /** + * Locks all static configuration for gateways and FetchGetUrlFunc + * registration. + */ + static lockConfig() { + locked$5 = true; + } + /** + * Get the current Gateway function for %%scheme%%. + */ + static getGateway(scheme) { + return Gateways[scheme.toLowerCase()] || null; + } + /** + * Use the %%func%% when fetching URIs using %%scheme%%. + * + * This method affects all requests globally. + * + * If [[lockConfig]] has been called, no change is made and this + * throws. + */ + static registerGateway(scheme, func) { + scheme = scheme.toLowerCase(); + if (scheme === "http" || scheme === "https") { + throw new Error(`cannot intercept ${scheme}; use registerGetUrl`); + } + if (locked$5) { + throw new Error("gateways locked"); + } + Gateways[scheme] = func; + } + /** + * Use %%getUrl%% when fetching URIs over HTTP and HTTPS requests. + * + * This method affects all requests globally. + * + * If [[lockConfig]] has been called, no change is made and this + * throws. + */ + static registerGetUrl(getUrl) { + if (locked$5) { + throw new Error("gateways locked"); + } + defaultGetUrlFunc = getUrl; + } + /** + * Creates a getUrl function that fetches content from HTTP and + * HTTPS URLs. + * + * The available %%options%% are dependent on the platform + * implementation of the default getUrl function. + * + * This is not generally something that is needed, but is useful + * when trying to customize simple behaviour when fetching HTTP + * content. + */ + static createGetUrlFunc(options) { + return createGetUrl(options); + } + /** + * Creates a function that can "fetch" data URIs. + * + * Note that this is automatically done internally to support + * data URIs, so it is not necessary to register it. + * + * This is not generally something that is needed, but may + * be useful in a wrapper to perfom custom data URI functionality. + */ + static createDataGateway() { + return dataGatewayFunc; + } + /** + * Creates a function that will fetch IPFS (unvalidated) from + * a custom gateway baseUrl. + * + * The default IPFS gateway used internally is + * ``"https:/\/gateway.ipfs.io/ipfs/"``. + */ + static createIpfsGatewayFunc(baseUrl) { + return getIpfsGatewayFunc(baseUrl); + } +} +/** + * The response for a FetchRequest. + */ +class FetchResponse { + #statusCode; + #statusMessage; + #headers; + #body; + #request; + #error; + toString() { + return ``; + } + /** + * The response status code. + */ + get statusCode() { return this.#statusCode; } + /** + * The response status message. + */ + get statusMessage() { return this.#statusMessage; } + /** + * The response headers. All keys are lower-case. + */ + get headers() { return Object.assign({}, this.#headers); } + /** + * The response body, or ``null`` if there was no body. + */ + get body() { + return (this.#body == null) ? null : new Uint8Array(this.#body); + } + /** + * The response body as a UTF-8 encoded string, or the empty + * string (i.e. ``""``) if there was no body. + * + * An error is thrown if the body is invalid UTF-8 data. + */ + get bodyText() { + try { + return (this.#body == null) ? "" : toUtf8String(this.#body); + } + catch (error) { + assert$5(false, "response body is not valid UTF-8 data", "UNSUPPORTED_OPERATION", { + operation: "bodyText", info: { response: this } + }); + } + } + /** + * The response body, decoded as JSON. + * + * An error is thrown if the body is invalid JSON-encoded data + * or if there was no body. + */ + get bodyJson() { + try { + return JSON.parse(this.bodyText); + } + catch (error) { + assert$5(false, "response body is not valid JSON", "UNSUPPORTED_OPERATION", { + operation: "bodyJson", info: { response: this } + }); + } + } + [Symbol.iterator]() { + const headers = this.headers; + const keys = Object.keys(headers); + let index = 0; + return { + next: () => { + if (index < keys.length) { + const key = keys[index++]; + return { + value: [key, headers[key]], done: false + }; + } + return { value: undefined, done: true }; + } + }; + } + constructor(statusCode, statusMessage, headers, body, request) { + this.#statusCode = statusCode; + this.#statusMessage = statusMessage; + this.#headers = Object.keys(headers).reduce((accum, k) => { + accum[k.toLowerCase()] = String(headers[k]); + return accum; + }, {}); + this.#body = ((body == null) ? null : new Uint8Array(body)); + this.#request = (request || null); + this.#error = { message: "" }; + } + /** + * Return a Response with matching headers and body, but with + * an error status code (i.e. 599) and %%message%% with an + * optional %%error%%. + */ + makeServerError(message, error) { + let statusMessage; + if (!message) { + message = `${this.statusCode} ${this.statusMessage}`; + statusMessage = `CLIENT ESCALATED SERVER ERROR (${message})`; + } + else { + statusMessage = `CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${message})`; + } + const response = new FetchResponse(599, statusMessage, this.headers, this.body, this.#request || undefined); + response.#error = { message, error }; + return response; + } + /** + * If called within a [request.processFunc](FetchRequest-processFunc) + * call, causes the request to retry as if throttled for %%stall%% + * milliseconds. + */ + throwThrottleError(message, stall) { + if (stall == null) { + stall = -1; + } + else { + assertArgument(Number.isInteger(stall) && stall >= 0, "invalid stall timeout", "stall", stall); + } + const error = new Error(message || "throttling requests"); + defineProperties(error, { stall, throttle: true }); + throw error; + } + /** + * Get the header value for %%key%%, ignoring case. + */ + getHeader(key) { + return this.headers[key.toLowerCase()]; + } + /** + * Returns true if the response has a body. + */ + hasBody() { + return (this.#body != null); + } + /** + * The request made for this response. + */ + get request() { return this.#request; } + /** + * Returns true if this response was a success statusCode. + */ + ok() { + return (this.#error.message === "" && this.statusCode >= 200 && this.statusCode < 300); + } + /** + * Throws a ``SERVER_ERROR`` if this response is not ok. + */ + assertOk() { + if (this.ok()) { + return; + } + let { message, error } = this.#error; + if (message === "") { + message = `server response ${this.statusCode} ${this.statusMessage}`; + } + let requestUrl = null; + if (this.request) { + requestUrl = this.request.url; + } + let responseBody = null; + try { + if (this.#body) { + responseBody = toUtf8String(this.#body); + } + } + catch (e) { } + assert$5(false, message, "SERVER_ERROR", { + request: (this.request || "unknown request"), response: this, error, + info: { + requestUrl, responseBody, + responseStatus: `${this.statusCode} ${this.statusMessage}` + } + }); + } +} +function getTime$1() { return (new Date()).getTime(); } +function unpercent(value) { + return toUtf8Bytes$1(value.replace(/%([0-9a-f][0-9a-f])/gi, (all, code) => { + return String.fromCharCode(parseInt(code, 16)); + })); +} +function wait(delay) { + return new Promise((resolve) => setTimeout(resolve, delay)); +} + +/** + * The **FixedNumber** class permits using values with decimal places, + * using fixed-pont math. + * + * Fixed-point math is still based on integers under-the-hood, but uses an + * internal offset to store fractional components below, and each operation + * corrects for this after each operation. + * + * @_section: api/utils/fixed-point-math:Fixed-Point Maths [about-fixed-point-math] + */ +const BN_N1 = BigInt(-1); +const BN_0$8 = BigInt(0); +const BN_1$3 = BigInt(1); +const BN_5 = BigInt(5); +const _guard$5 = {}; +// Constant to pull zeros from for multipliers +let Zeros$1 = "0000"; +while (Zeros$1.length < 80) { + Zeros$1 += Zeros$1; +} +// Returns a string "1" followed by decimal "0"s +function getTens(decimals) { + let result = Zeros$1; + while (result.length < decimals) { + result += result; + } + return BigInt("1" + result.substring(0, decimals)); +} +function checkValue(val, format, safeOp) { + const width = BigInt(format.width); + if (format.signed) { + const limit = (BN_1$3 << (width - BN_1$3)); + assert$5(safeOp == null || (val >= -limit && val < limit), "overflow", "NUMERIC_FAULT", { + operation: safeOp, fault: "overflow", value: val + }); + if (val > BN_0$8) { + val = fromTwos(mask(val, width), width); + } + else { + val = -fromTwos(mask(-val, width), width); + } + } + else { + const limit = (BN_1$3 << width); + assert$5(safeOp == null || (val >= 0 && val < limit), "overflow", "NUMERIC_FAULT", { + operation: safeOp, fault: "overflow", value: val + }); + val = (((val % limit) + limit) % limit) & (limit - BN_1$3); + } + return val; +} +function getFormat(value) { + if (typeof (value) === "number") { + value = `fixed128x${value}`; + } + let signed = true; + let width = 128; + let decimals = 18; + if (typeof (value) === "string") { + // Parse the format string + if (value === "fixed") ; + else if (value === "ufixed") { + signed = false; + } + else { + const match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + assertArgument(match, "invalid fixed format", "format", value); + signed = (match[1] !== "u"); + width = parseInt(match[2]); + decimals = parseInt(match[3]); + } + } + else if (value) { + // Extract the values from the object + const v = value; + const check = (key, type, defaultValue) => { + if (v[key] == null) { + return defaultValue; + } + assertArgument(typeof (v[key]) === type, "invalid fixed format (" + key + " not " + type + ")", "format." + key, v[key]); + return v[key]; + }; + signed = check("signed", "boolean", signed); + width = check("width", "number", width); + decimals = check("decimals", "number", decimals); + } + assertArgument((width % 8) === 0, "invalid FixedNumber width (not byte aligned)", "format.width", width); + assertArgument(decimals <= 80, "invalid FixedNumber decimals (too large)", "format.decimals", decimals); + const name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals); + return { signed, width, decimals, name }; +} +function toString$3(val, decimals) { + let negative = ""; + if (val < BN_0$8) { + negative = "-"; + val *= BN_N1; + } + let str = val.toString(); + // No decimal point for whole values + if (decimals === 0) { + return (negative + str); + } + // Pad out to the whole component (including a whole digit) + while (str.length <= decimals) { + str = Zeros$1 + str; + } + // Insert the decimal point + const index = str.length - decimals; + str = str.substring(0, index) + "." + str.substring(index); + // Trim the whole component (leaving at least one 0) + while (str[0] === "0" && str[1] !== ".") { + str = str.substring(1); + } + // Trim the decimal component (leaving at least one 0) + while (str[str.length - 1] === "0" && str[str.length - 2] !== ".") { + str = str.substring(0, str.length - 1); + } + return (negative + str); +} +/** + * A FixedNumber represents a value over its [[FixedFormat]] + * arithmetic field. + * + * A FixedNumber can be used to perform math, losslessly, on + * values which have decmial places. + * + * A FixedNumber has a fixed bit-width to store values in, and stores all + * values internally by multiplying the value by 10 raised to the power of + * %%decimals%%. + * + * If operations are performed that cause a value to grow too high (close to + * positive infinity) or too low (close to negative infinity), the value + * is said to //overflow//. + * + * For example, an 8-bit signed value, with 0 decimals may only be within + * the range ``-128`` to ``127``; so ``-128 - 1`` will overflow and become + * ``127``. Likewise, ``127 + 1`` will overflow and become ``-127``. + * + * Many operation have a normal and //unsafe// variant. The normal variant + * will throw a [[NumericFaultError]] on any overflow, while the //unsafe// + * variant will silently allow overflow, corrupting its value value. + * + * If operations are performed that cause a value to become too small + * (close to zero), the value loses precison and is said to //underflow//. + * + * For example, an value with 1 decimal place may store a number as small + * as ``0.1``, but the value of ``0.1 / 2`` is ``0.05``, which cannot fit + * into 1 decimal place, so underflow occurs which means precision is lost + * and the value becomes ``0``. + * + * Some operations have a normal and //signalling// variant. The normal + * variant will silently ignore underflow, while the //signalling// variant + * will thow a [[NumericFaultError]] on underflow. + */ +class FixedNumber { + /** + * The specific fixed-point arithmetic field for this value. + */ + format; + #format; + // The actual value (accounting for decimals) + #val; + // A base-10 value to multiple values by to maintain the magnitude + #tens; + /** + * This is a property so console.log shows a human-meaningful value. + * + * @private + */ + _value; + // Use this when changing this file to get some typing info, + // but then switch to any to mask the internal type + //constructor(guard: any, value: bigint, format: _FixedFormat) { + /** + * @private + */ + constructor(guard, value, format) { + assertPrivate(guard, _guard$5, "FixedNumber"); + this.#val = value; + this.#format = format; + const _value = toString$3(value, format.decimals); + defineProperties(this, { format: format.name, _value }); + this.#tens = getTens(format.decimals); + } + /** + * If true, negative values are permitted, otherwise only + * positive values and zero are allowed. + */ + get signed() { return this.#format.signed; } + /** + * The number of bits available to store the value. + */ + get width() { return this.#format.width; } + /** + * The number of decimal places in the fixed-point arithment field. + */ + get decimals() { return this.#format.decimals; } + /** + * The value as an integer, based on the smallest unit the + * [[decimals]] allow. + */ + get value() { return this.#val; } + #checkFormat(other) { + assertArgument(this.format === other.format, "incompatible format; use fixedNumber.toFormat", "other", other); + } + #checkValue(val, safeOp) { + /* + const width = BigInt(this.width); + if (this.signed) { + const limit = (BN_1 << (width - BN_1)); + assert(safeOp == null || (val >= -limit && val < limit), "overflow", "NUMERIC_FAULT", { + operation: safeOp, fault: "overflow", value: val + }); + + if (val > BN_0) { + val = fromTwos(mask(val, width), width); + } else { + val = -fromTwos(mask(-val, width), width); + } + + } else { + const masked = mask(val, width); + assert(safeOp == null || (val >= 0 && val === masked), "overflow", "NUMERIC_FAULT", { + operation: safeOp, fault: "overflow", value: val + }); + val = masked; + } + */ + val = checkValue(val, this.#format, safeOp); + return new FixedNumber(_guard$5, val, this.#format); + } + #add(o, safeOp) { + this.#checkFormat(o); + return this.#checkValue(this.#val + o.#val, safeOp); + } + /** + * Returns a new [[FixedNumber]] with the result of %%this%% added + * to %%other%%, ignoring overflow. + */ + addUnsafe(other) { return this.#add(other); } + /** + * Returns a new [[FixedNumber]] with the result of %%this%% added + * to %%other%%. A [[NumericFaultError]] is thrown if overflow + * occurs. + */ + add(other) { return this.#add(other, "add"); } + #sub(o, safeOp) { + this.#checkFormat(o); + return this.#checkValue(this.#val - o.#val, safeOp); + } + /** + * Returns a new [[FixedNumber]] with the result of %%other%% subtracted + * from %%this%%, ignoring overflow. + */ + subUnsafe(other) { return this.#sub(other); } + /** + * Returns a new [[FixedNumber]] with the result of %%other%% subtracted + * from %%this%%. A [[NumericFaultError]] is thrown if overflow + * occurs. + */ + sub(other) { return this.#sub(other, "sub"); } + #mul(o, safeOp) { + this.#checkFormat(o); + return this.#checkValue((this.#val * o.#val) / this.#tens, safeOp); + } + /** + * Returns a new [[FixedNumber]] with the result of %%this%% multiplied + * by %%other%%, ignoring overflow and underflow (precision loss). + */ + mulUnsafe(other) { return this.#mul(other); } + /** + * Returns a new [[FixedNumber]] with the result of %%this%% multiplied + * by %%other%%. A [[NumericFaultError]] is thrown if overflow + * occurs. + */ + mul(other) { return this.#mul(other, "mul"); } + /** + * Returns a new [[FixedNumber]] with the result of %%this%% multiplied + * by %%other%%. A [[NumericFaultError]] is thrown if overflow + * occurs or if underflow (precision loss) occurs. + */ + mulSignal(other) { + this.#checkFormat(other); + const value = this.#val * other.#val; + assert$5((value % this.#tens) === BN_0$8, "precision lost during signalling mul", "NUMERIC_FAULT", { + operation: "mulSignal", fault: "underflow", value: this + }); + return this.#checkValue(value / this.#tens, "mulSignal"); + } + #div(o, safeOp) { + assert$5(o.#val !== BN_0$8, "division by zero", "NUMERIC_FAULT", { + operation: "div", fault: "divide-by-zero", value: this + }); + this.#checkFormat(o); + return this.#checkValue((this.#val * this.#tens) / o.#val, safeOp); + } + /** + * Returns a new [[FixedNumber]] with the result of %%this%% divided + * by %%other%%, ignoring underflow (precision loss). A + * [[NumericFaultError]] is thrown if overflow occurs. + */ + divUnsafe(other) { return this.#div(other); } + /** + * Returns a new [[FixedNumber]] with the result of %%this%% divided + * by %%other%%, ignoring underflow (precision loss). A + * [[NumericFaultError]] is thrown if overflow occurs. + */ + div(other) { return this.#div(other, "div"); } + /** + * Returns a new [[FixedNumber]] with the result of %%this%% divided + * by %%other%%. A [[NumericFaultError]] is thrown if underflow + * (precision loss) occurs. + */ + divSignal(other) { + assert$5(other.#val !== BN_0$8, "division by zero", "NUMERIC_FAULT", { + operation: "div", fault: "divide-by-zero", value: this + }); + this.#checkFormat(other); + const value = (this.#val * this.#tens); + assert$5((value % other.#val) === BN_0$8, "precision lost during signalling div", "NUMERIC_FAULT", { + operation: "divSignal", fault: "underflow", value: this + }); + return this.#checkValue(value / other.#val, "divSignal"); + } + /** + * Returns a comparison result between %%this%% and %%other%%. + * + * This is suitable for use in sorting, where ``-1`` implies %%this%% + * is smaller, ``1`` implies %%this%% is larger and ``0`` implies + * both are equal. + */ + cmp(other) { + let a = this.value, b = other.value; + // Coerce a and b to the same magnitude + const delta = this.decimals - other.decimals; + if (delta > 0) { + b *= getTens(delta); + } + else if (delta < 0) { + a *= getTens(-delta); + } + // Comnpare + if (a < b) { + return -1; + } + if (a > b) { + return 1; + } + return 0; + } + /** + * Returns true if %%other%% is equal to %%this%%. + */ + eq(other) { return this.cmp(other) === 0; } + /** + * Returns true if %%other%% is less than to %%this%%. + */ + lt(other) { return this.cmp(other) < 0; } + /** + * Returns true if %%other%% is less than or equal to %%this%%. + */ + lte(other) { return this.cmp(other) <= 0; } + /** + * Returns true if %%other%% is greater than to %%this%%. + */ + gt(other) { return this.cmp(other) > 0; } + /** + * Returns true if %%other%% is greater than or equal to %%this%%. + */ + gte(other) { return this.cmp(other) >= 0; } + /** + * Returns a new [[FixedNumber]] which is the largest **integer** + * that is less than or equal to %%this%%. + * + * The decimal component of the result will always be ``0``. + */ + floor() { + let val = this.#val; + if (this.#val < BN_0$8) { + val -= this.#tens - BN_1$3; + } + val = (this.#val / this.#tens) * this.#tens; + return this.#checkValue(val, "floor"); + } + /** + * Returns a new [[FixedNumber]] which is the smallest **integer** + * that is greater than or equal to %%this%%. + * + * The decimal component of the result will always be ``0``. + */ + ceiling() { + let val = this.#val; + if (this.#val > BN_0$8) { + val += this.#tens - BN_1$3; + } + val = (this.#val / this.#tens) * this.#tens; + return this.#checkValue(val, "ceiling"); + } + /** + * Returns a new [[FixedNumber]] with the decimal component + * rounded up on ties at %%decimals%% places. + */ + round(decimals) { + if (decimals == null) { + decimals = 0; + } + // Not enough precision to not already be rounded + if (decimals >= this.decimals) { + return this; + } + const delta = this.decimals - decimals; + const bump = BN_5 * getTens(delta - 1); + let value = this.value + bump; + const tens = getTens(delta); + value = (value / tens) * tens; + checkValue(value, this.#format, "round"); + return new FixedNumber(_guard$5, value, this.#format); + } + /** + * Returns true if %%this%% is equal to ``0``. + */ + isZero() { return (this.#val === BN_0$8); } + /** + * Returns true if %%this%% is less than ``0``. + */ + isNegative() { return (this.#val < BN_0$8); } + /** + * Returns the string representation of %%this%%. + */ + toString() { return this._value; } + /** + * Returns a float approximation. + * + * Due to IEEE 754 precission (or lack thereof), this function + * can only return an approximation and most values will contain + * rounding errors. + */ + toUnsafeFloat() { return parseFloat(this.toString()); } + /** + * Return a new [[FixedNumber]] with the same value but has had + * its field set to %%format%%. + * + * This will throw if the value cannot fit into %%format%%. + */ + toFormat(format) { + return FixedNumber.fromString(this.toString(), format); + } + /** + * Creates a new [[FixedNumber]] for %%value%% divided by + * %%decimal%% places with %%format%%. + * + * This will throw a [[NumericFaultError]] if %%value%% (once adjusted + * for %%decimals%%) cannot fit in %%format%%, either due to overflow + * or underflow (precision loss). + */ + static fromValue(_value, _decimals, _format) { + const decimals = (_decimals == null) ? 0 : getNumber(_decimals); + const format = getFormat(_format); + let value = getBigInt(_value, "value"); + const delta = decimals - format.decimals; + if (delta > 0) { + const tens = getTens(delta); + assert$5((value % tens) === BN_0$8, "value loses precision for format", "NUMERIC_FAULT", { + operation: "fromValue", fault: "underflow", value: _value + }); + value /= tens; + } + else if (delta < 0) { + value *= getTens(-delta); + } + checkValue(value, format, "fromValue"); + return new FixedNumber(_guard$5, value, format); + } + /** + * Creates a new [[FixedNumber]] for %%value%% with %%format%%. + * + * This will throw a [[NumericFaultError]] if %%value%% cannot fit + * in %%format%%, either due to overflow or underflow (precision loss). + */ + static fromString(_value, _format) { + const match = _value.match(/^(-?)([0-9]*)\.?([0-9]*)$/); + assertArgument(match && (match[2].length + match[3].length) > 0, "invalid FixedNumber string value", "value", _value); + const format = getFormat(_format); + let whole = (match[2] || "0"), decimal = (match[3] || ""); + // Pad out the decimals + while (decimal.length < format.decimals) { + decimal += Zeros$1; + } + // Check precision is safe + assert$5(decimal.substring(format.decimals).match(/^0*$/), "too many decimals for format", "NUMERIC_FAULT", { + operation: "fromString", fault: "underflow", value: _value + }); + // Remove extra padding + decimal = decimal.substring(0, format.decimals); + const value = BigInt(match[1] + whole + decimal); + checkValue(value, format, "fromString"); + return new FixedNumber(_guard$5, value, format); + } + /** + * Creates a new [[FixedNumber]] with the big-endian representation + * %%value%% with %%format%%. + * + * This will throw a [[NumericFaultError]] if %%value%% cannot fit + * in %%format%% due to overflow. + */ + static fromBytes(_value, _format) { + let value = toBigInt(getBytes(_value, "value")); + const format = getFormat(_format); + if (format.signed) { + value = fromTwos(value, format.width); + } + checkValue(value, format, "fromBytes"); + return new FixedNumber(_guard$5, value, format); + } +} +//const f1 = FixedNumber.fromString("12.56", "fixed16x2"); +//const f2 = FixedNumber.fromString("0.3", "fixed16x2"); +//console.log(f1.divSignal(f2)); +//const BUMP = FixedNumber.from("0.5"); + +//See: https://github.com/ethereum/wiki/wiki/RLP +function hexlifyByte(value) { + let result = value.toString(16); + while (result.length < 2) { + result = "0" + result; + } + return "0x" + result; +} +function unarrayifyInteger(data, offset, length) { + let result = 0; + for (let i = 0; i < length; i++) { + result = (result * 256) + data[offset + i]; + } + return result; +} +function _decodeChildren(data, offset, childOffset, length) { + const result = []; + while (childOffset < offset + 1 + length) { + const decoded = _decode(data, childOffset); + result.push(decoded.result); + childOffset += decoded.consumed; + assert$5(childOffset <= offset + 1 + length, "child data too short", "BUFFER_OVERRUN", { + buffer: data, length, offset + }); + } + return { consumed: (1 + length), result: result }; +} +// returns { consumed: number, result: Object } +function _decode(data, offset) { + assert$5(data.length !== 0, "data too short", "BUFFER_OVERRUN", { + buffer: data, length: 0, offset: 1 + }); + const checkOffset = (offset) => { + assert$5(offset <= data.length, "data short segment too short", "BUFFER_OVERRUN", { + buffer: data, length: data.length, offset + }); + }; + // Array with extra length prefix + if (data[offset] >= 0xf8) { + const lengthLength = data[offset] - 0xf7; + checkOffset(offset + 1 + lengthLength); + const length = unarrayifyInteger(data, offset + 1, lengthLength); + checkOffset(offset + 1 + lengthLength + length); + return _decodeChildren(data, offset, offset + 1 + lengthLength, lengthLength + length); + } + else if (data[offset] >= 0xc0) { + const length = data[offset] - 0xc0; + checkOffset(offset + 1 + length); + return _decodeChildren(data, offset, offset + 1, length); + } + else if (data[offset] >= 0xb8) { + const lengthLength = data[offset] - 0xb7; + checkOffset(offset + 1 + lengthLength); + const length = unarrayifyInteger(data, offset + 1, lengthLength); + checkOffset(offset + 1 + lengthLength + length); + const result = hexlify(data.slice(offset + 1 + lengthLength, offset + 1 + lengthLength + length)); + return { consumed: (1 + lengthLength + length), result: result }; + } + else if (data[offset] >= 0x80) { + const length = data[offset] - 0x80; + checkOffset(offset + 1 + length); + const result = hexlify(data.slice(offset + 1, offset + 1 + length)); + return { consumed: (1 + length), result: result }; + } + return { consumed: 1, result: hexlifyByte(data[offset]) }; +} +/** + * Decodes %%data%% into the structured data it represents. + */ +function decodeRlp(_data) { + const data = getBytes(_data, "data"); + const decoded = _decode(data, 0); + assertArgument(decoded.consumed === data.length, "unexpected junk after rlp payload", "data", _data); + return decoded.result; +} + +//See: https://github.com/ethereum/wiki/wiki/RLP +function arrayifyInteger(value) { + const result = []; + while (value) { + result.unshift(value & 0xff); + value >>= 8; + } + return result; +} +function _encode(object) { + if (Array.isArray(object)) { + let payload = []; + object.forEach(function (child) { + payload = payload.concat(_encode(child)); + }); + if (payload.length <= 55) { + payload.unshift(0xc0 + payload.length); + return payload; + } + const length = arrayifyInteger(payload.length); + length.unshift(0xf7 + length.length); + return length.concat(payload); + } + const data = Array.prototype.slice.call(getBytes(object, "object")); + if (data.length === 1 && data[0] <= 0x7f) { + return data; + } + else if (data.length <= 55) { + data.unshift(0x80 + data.length); + return data; + } + const length = arrayifyInteger(data.length); + length.unshift(0xb7 + length.length); + return length.concat(data); +} +const nibbles = "0123456789abcdef"; +/** + * Encodes %%object%% as an RLP-encoded [[DataHexString]]. + */ +function encodeRlp(object) { + let result = "0x"; + for (const v of _encode(object)) { + result += nibbles[v >> 4]; + result += nibbles[v & 0xf]; + } + return result; +} + +/** + * Most interactions with Ethereum requires integer values, which use + * the smallest magnitude unit. + * + * For example, imagine dealing with dollars and cents. Since dollars + * are divisible, non-integer values are possible, such as ``$10.77``. + * By using the smallest indivisible unit (i.e. cents), the value can + * be kept as the integer ``1077``. + * + * When receiving decimal input from the user (as a decimal string), + * the value should be converted to an integer and when showing a user + * a value, the integer value should be converted to a decimal string. + * + * This creates a clear distinction, between values to be used by code + * (integers) and values used for display logic to users (decimals). + * + * The native unit in Ethereum, //ether// is divisible to 18 decimal places, + * where each individual unit is called a //wei//. + * + * @_subsection api/utils:Unit Conversion [about-units] + */ +const names$2 = [ + "wei", + "kwei", + "mwei", + "gwei", + "szabo", + "finney", + "ether", +]; +/** + * Converts %%value%% into a //decimal string//, assuming %%unit%% decimal + * places. The %%unit%% may be the number of decimal places or the name of + * a unit (e.g. ``"gwei"`` for 9 decimal places). + * + */ +function formatUnits(value, unit) { + let decimals = 18; + if (typeof (unit) === "string") { + const index = names$2.indexOf(unit); + assertArgument(index >= 0, "invalid unit", "unit", unit); + decimals = 3 * index; + } + else if (unit != null) { + decimals = getNumber(unit, "unit"); + } + return FixedNumber.fromValue(value, decimals, { decimals, width: 512 }).toString(); +} +/** + * Converts the //decimal string// %%value%% to a BigInt, assuming + * %%unit%% decimal places. The %%unit%% may the number of decimal places + * or the name of a unit (e.g. ``"gwei"`` for 9 decimal places). + */ +function parseUnits$1(value, unit) { + assertArgument(typeof (value) === "string", "value must be a string", "value", value); + let decimals = 18; + if (typeof (unit) === "string") { + const index = names$2.indexOf(unit); + assertArgument(index >= 0, "invalid unit", "unit", unit); + decimals = 3 * index; + } + else if (unit != null) { + decimals = getNumber(unit, "unit"); + } + return FixedNumber.fromString(value, { decimals, width: 512 }).value; +} +/** + * Converts %%value%% into a //decimal string// using 18 decimal places. + */ +function formatEther(wei) { + return formatUnits(wei, 18); +} +/** + * Converts the //decimal string// %%ether%% to a BigInt, using 18 + * decimal places. + */ +function parseEther(ether) { + return parseUnits$1(ether, 18); +} + +/** + * Explain UUID and link to RFC here. + * + * @_subsection: api/utils:UUID [about-uuid] + */ +/** + * Returns the version 4 [[link-uuid]] for the %%randomBytes%%. + * + * @see: https://www.ietf.org/rfc/rfc4122.txt (Section 4.4) + */ +function uuidV4(randomBytes) { + const bytes = getBytes(randomBytes, "randomBytes"); + // Section: 4.1.3: + // - time_hi_and_version[12:16] = 0b0100 + bytes[6] = (bytes[6] & 0x0f) | 0x40; + // Section 4.4 + // - clock_seq_hi_and_reserved[6] = 0b0 + // - clock_seq_hi_and_reserved[7] = 0b1 + bytes[8] = (bytes[8] & 0x3f) | 0x80; + const value = hexlify(bytes); + return [ + value.substring(2, 10), + value.substring(10, 14), + value.substring(14, 18), + value.substring(18, 22), + value.substring(22, 34), + ].join("-"); +} + +/** + * @_ignore: + */ +const WordSize = 32; +const Padding = new Uint8Array(WordSize); +// Properties used to immediate pass through to the underlying object +// - `then` is used to detect if an object is a Promise for await +const passProperties$1 = ["then"]; +const _guard$4 = {}; +function throwError(name, error) { + const wrapped = new Error(`deferred error during ABI decoding triggered accessing ${name}`); + wrapped.error = error; + throw wrapped; +} +/** + * A [[Result]] is a sub-class of Array, which allows accessing any + * of its values either positionally by its index or, if keys are + * provided by its name. + * + * @_docloc: api/abi + */ +class Result extends Array { + #names; + /** + * @private + */ + constructor(...args) { + // To properly sub-class Array so the other built-in + // functions work, the constructor has to behave fairly + // well. So, in the event we are created via fromItems() + // we build the read-only Result object we want, but on + // any other input, we use the default constructor + // constructor(guard: any, items: Array, keys?: Array); + const guard = args[0]; + let items = args[1]; + let names = (args[2] || []).slice(); + let wrap = true; + if (guard !== _guard$4) { + items = args; + names = []; + wrap = false; + } + // Can't just pass in ...items since an array of length 1 + // is a special case in the super. + super(items.length); + items.forEach((item, index) => { this[index] = item; }); + // Find all unique keys + const nameCounts = names.reduce((accum, name) => { + if (typeof (name) === "string") { + accum.set(name, (accum.get(name) || 0) + 1); + } + return accum; + }, (new Map())); + // Remove any key thats not unique + this.#names = Object.freeze(items.map((item, index) => { + const name = names[index]; + if (name != null && nameCounts.get(name) === 1) { + return name; + } + return null; + })); + if (!wrap) { + return; + } + // A wrapped Result is immutable + Object.freeze(this); + // Proxy indices and names so we can trap deferred errors + return new Proxy(this, { + get: (target, prop, receiver) => { + if (typeof (prop) === "string") { + // Index accessor + if (prop.match(/^[0-9]+$/)) { + const index = getNumber(prop, "%index"); + if (index < 0 || index >= this.length) { + throw new RangeError("out of result range"); + } + const item = target[index]; + if (item instanceof Error) { + throwError(`index ${index}`, item); + } + return item; + } + // Pass important checks (like `then` for Promise) through + if (passProperties$1.indexOf(prop) >= 0) { + return Reflect.get(target, prop, receiver); + } + const value = target[prop]; + if (value instanceof Function) { + // Make sure functions work with private variables + // See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy#no_private_property_forwarding + return function (...args) { + return value.apply((this === receiver) ? target : this, args); + }; + } + else if (!(prop in target)) { + // Possible name accessor + return target.getValue.apply((this === receiver) ? target : this, [prop]); + } + } + return Reflect.get(target, prop, receiver); + } + }); + } + /** + * Returns the Result as a normal Array. If %%deep%%, any children + * which are Result objects are also converted to a normal Array. + * + * This will throw if there are any outstanding deferred + * errors. + */ + toArray(deep) { + const result = []; + this.forEach((item, index) => { + if (item instanceof Error) { + throwError(`index ${index}`, item); + } + if (deep && item instanceof Result) { + item = item.toArray(deep); + } + result.push(item); + }); + return result; + } + /** + * Returns the Result as an Object with each name-value pair. If + * %%deep%%, any children which are Result objects are also + * converted to an Object. + * + * This will throw if any value is unnamed, or if there are + * any outstanding deferred errors. + */ + toObject(deep) { + return this.#names.reduce((accum, name, index) => { + assert$5(name != null, "value at index ${ index } unnamed", "UNSUPPORTED_OPERATION", { + operation: "toObject()" + }); + // Add values for names that don't conflict + if (!(name in accum)) { + let child = this.getValue(name); + if (deep && child instanceof Result) { + child = child.toObject(deep); + } + accum[name] = child; + } + return accum; + }, {}); + } + /** + * @_ignore + */ + slice(start, end) { + if (start == null) { + start = 0; + } + if (start < 0) { + start += this.length; + if (start < 0) { + start = 0; + } + } + if (end == null) { + end = this.length; + } + if (end < 0) { + end += this.length; + if (end < 0) { + end = 0; + } + } + if (end > this.length) { + end = this.length; + } + const result = [], names = []; + for (let i = start; i < end; i++) { + result.push(this[i]); + names.push(this.#names[i]); + } + return new Result(_guard$4, result, names); + } + /** + * @_ignore + */ + filter(callback, thisArg) { + const result = [], names = []; + for (let i = 0; i < this.length; i++) { + const item = this[i]; + if (item instanceof Error) { + throwError(`index ${i}`, item); + } + if (callback.call(thisArg, item, i, this)) { + result.push(item); + names.push(this.#names[i]); + } + } + return new Result(_guard$4, result, names); + } + /** + * @_ignore + */ + map(callback, thisArg) { + const result = []; + for (let i = 0; i < this.length; i++) { + const item = this[i]; + if (item instanceof Error) { + throwError(`index ${i}`, item); + } + result.push(callback.call(thisArg, item, i, this)); + } + return result; + } + /** + * Returns the value for %%name%%. + * + * Since it is possible to have a key whose name conflicts with + * a method on a [[Result]] or its superclass Array, or any + * JavaScript keyword, this ensures all named values are still + * accessible by name. + */ + getValue(name) { + const index = this.#names.indexOf(name); + if (index === -1) { + return undefined; + } + const value = this[index]; + if (value instanceof Error) { + throwError(`property ${JSON.stringify(name)}`, value.error); + } + return value; + } + /** + * Creates a new [[Result]] for %%items%% with each entry + * also accessible by its corresponding name in %%keys%%. + */ + static fromItems(items, keys) { + return new Result(_guard$4, items, keys); + } +} +function getValue$1(value) { + let bytes = toBeArray(value); + assert$5(bytes.length <= WordSize, "value out-of-bounds", "BUFFER_OVERRUN", { buffer: bytes, length: WordSize, offset: bytes.length }); + if (bytes.length !== WordSize) { + bytes = getBytesCopy(concat$3([Padding.slice(bytes.length % WordSize), bytes])); + } + return bytes; +} +/** + * @_ignore + */ +class Coder { + // The coder name: + // - address, uint256, tuple, array, etc. + name; + // The fully expanded type, including composite types: + // - address, uint256, tuple(address,bytes), uint256[3][4][], etc. + type; + // The localName bound in the signature, in this example it is "baz": + // - tuple(address foo, uint bar) baz + localName; + // Whether this type is dynamic: + // - Dynamic: bytes, string, address[], tuple(boolean[]), etc. + // - Not Dynamic: address, uint256, boolean[3], tuple(address, uint8) + dynamic; + constructor(name, type, localName, dynamic) { + defineProperties(this, { name, type, localName, dynamic }, { + name: "string", type: "string", localName: "string", dynamic: "boolean" + }); + } + _throwError(message, value) { + assertArgument(false, message, this.localName, value); + } +} +/** + * @_ignore + */ +class Writer { + // An array of WordSize lengthed objects to concatenation + #data; + #dataLength; + constructor() { + this.#data = []; + this.#dataLength = 0; + } + get data() { + return concat$3(this.#data); + } + get length() { return this.#dataLength; } + #writeData(data) { + this.#data.push(data); + this.#dataLength += data.length; + return data.length; + } + appendWriter(writer) { + return this.#writeData(getBytesCopy(writer.data)); + } + // Arrayish item; pad on the right to *nearest* WordSize + writeBytes(value) { + let bytes = getBytesCopy(value); + const paddingOffset = bytes.length % WordSize; + if (paddingOffset) { + bytes = getBytesCopy(concat$3([bytes, Padding.slice(paddingOffset)])); + } + return this.#writeData(bytes); + } + // Numeric item; pad on the left *to* WordSize + writeValue(value) { + return this.#writeData(getValue$1(value)); + } + // Inserts a numeric place-holder, returning a callback that can + // be used to asjust the value later + writeUpdatableValue() { + const offset = this.#data.length; + this.#data.push(Padding); + this.#dataLength += WordSize; + return (value) => { + this.#data[offset] = getValue$1(value); + }; + } +} +/** + * @_ignore + */ +class Reader { + // Allows incomplete unpadded data to be read; otherwise an error + // is raised if attempting to overrun the buffer. This is required + // to deal with an old Solidity bug, in which event data for + // external (not public thoguh) was tightly packed. + allowLoose; + #data; + #offset; + #bytesRead; + #parent; + #maxInflation; + constructor(data, allowLoose, maxInflation) { + defineProperties(this, { allowLoose: !!allowLoose }); + this.#data = getBytesCopy(data); + this.#bytesRead = 0; + this.#parent = null; + this.#maxInflation = (maxInflation != null) ? maxInflation : 1024; + this.#offset = 0; + } + get data() { return hexlify(this.#data); } + get dataLength() { return this.#data.length; } + get consumed() { return this.#offset; } + get bytes() { return new Uint8Array(this.#data); } + #incrementBytesRead(count) { + if (this.#parent) { + return this.#parent.#incrementBytesRead(count); + } + this.#bytesRead += count; + // Check for excessive inflation (see: #4537) + assert$5(this.#maxInflation < 1 || this.#bytesRead <= this.#maxInflation * this.dataLength, `compressed ABI data exceeds inflation ratio of ${this.#maxInflation} ( see: https:/\/github.com/ethers-io/ethers.js/issues/4537 )`, "BUFFER_OVERRUN", { + buffer: getBytesCopy(this.#data), offset: this.#offset, + length: count, info: { + bytesRead: this.#bytesRead, + dataLength: this.dataLength + } + }); + } + #peekBytes(offset, length, loose) { + let alignedLength = Math.ceil(length / WordSize) * WordSize; + if (this.#offset + alignedLength > this.#data.length) { + if (this.allowLoose && loose && this.#offset + length <= this.#data.length) { + alignedLength = length; + } + else { + assert$5(false, "data out-of-bounds", "BUFFER_OVERRUN", { + buffer: getBytesCopy(this.#data), + length: this.#data.length, + offset: this.#offset + alignedLength + }); + } + } + return this.#data.slice(this.#offset, this.#offset + alignedLength); + } + // Create a sub-reader with the same underlying data, but offset + subReader(offset) { + const reader = new Reader(this.#data.slice(this.#offset + offset), this.allowLoose, this.#maxInflation); + reader.#parent = this; + return reader; + } + // Read bytes + readBytes(length, loose) { + let bytes = this.#peekBytes(0, length, !!loose); + this.#incrementBytesRead(length); + this.#offset += bytes.length; + // @TODO: Make sure the length..end bytes are all 0? + return bytes.slice(0, length); + } + // Read a numeric values + readValue() { + return toBigInt(this.readBytes(WordSize)); + } + readIndex() { + return toNumber$4(this.readBytes(WordSize)); + } +} + +/** + * An **HMAC** enables verification that a given key was used + * to authenticate a payload. + * + * See: [[link-wiki-hmac]] + * + * @_subsection: api/crypto:HMAC [about-hmac] + */ +let locked$4 = false; +const _computeHmac = function (algorithm, key, data) { + return require$$5.createHmac(algorithm, key).update(data).digest(); +}; +let __computeHmac = _computeHmac; +/** + * Return the HMAC for %%data%% using the %%key%% key with the underlying + * %%algo%% used for compression. + * + * @example: + * key = id("some-secret") + * + * // Compute the HMAC + * computeHmac("sha256", key, "0x1337") + * //_result: + * + * // To compute the HMAC of UTF-8 data, the data must be + * // converted to UTF-8 bytes + * computeHmac("sha256", key, toUtf8Bytes("Hello World")) + * //_result: + * + */ +function computeHmac(algorithm, _key, _data) { + const key = getBytes(_key, "key"); + const data = getBytes(_data, "data"); + return hexlify(__computeHmac(algorithm, key, data)); +} +computeHmac._ = _computeHmac; +computeHmac.lock = function () { locked$4 = true; }; +computeHmac.register = function (func) { + if (locked$4) { + throw new Error("computeHmac is locked"); + } + __computeHmac = func; +}; +Object.freeze(computeHmac); + +function number(n) { + if (!Number.isSafeInteger(n) || n < 0) + throw new Error(`Wrong positive integer: ${n}`); +} +function bytes(b, ...lengths) { + if (!(b instanceof Uint8Array)) + throw new Error('Expected Uint8Array'); + if (lengths.length > 0 && !lengths.includes(b.length)) + throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`); +} +function hash(hash) { + if (typeof hash !== 'function' || typeof hash.create !== 'function') + throw new Error('Hash should be wrapped by utils.wrapConstructor'); + number(hash.outputLen); + number(hash.blockLen); +} +function exists(instance, checkFinished = true) { + if (instance.destroyed) + throw new Error('Hash instance has been destroyed'); + if (checkFinished && instance.finished) + throw new Error('Hash#digest() has already been called'); +} +function output(out, instance) { + bytes(out); + const min = instance.outputLen; + if (out.length < min) { + throw new Error(`digestInto() expects output buffer of length at least ${min}`); + } +} + +const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1); +const _32n = /* @__PURE__ */ BigInt(32); +// We are not using BigUint64Array, because they are extremely slow as per 2022 +function fromBig(n, le = false) { + if (le) + return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) }; + return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 }; +} +function split$1(lst, le = false) { + let Ah = new Uint32Array(lst.length); + let Al = new Uint32Array(lst.length); + for (let i = 0; i < lst.length; i++) { + const { h, l } = fromBig(lst[i], le); + [Ah[i], Al[i]] = [h, l]; + } + return [Ah, Al]; +} +// Left rotate for Shift in [1, 32) +const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s)); +const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s)); +// Left rotate for Shift in (32, 64), NOTE: 32 is special case. +const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s)); +const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s)); + +const crypto$1 = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined; + +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+. +// node.js versions earlier than v19 don't declare it in global scope. +// For node.js, package.json#exports field mapping rewrites import +// from `crypto` to `cryptoNode`, which imports native module. +// Makes the utils un-importable in browsers without a bundler. +// Once node.js 18 is deprecated, we can just drop the import. +const u8a$1 = (a) => a instanceof Uint8Array; +const u32$1 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4)); +// Cast array to view +const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength); +// The rotate right (circular right shift) operation for uint32 +const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift); +// big-endian hardware is rare. Just in case someone still decides to run hashes: +// early-throw an error because we don't support BE yet. +const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44; +if (!isLE) + throw new Error('Non little-endian hardware is not supported'); +// There is no setImmediate in browser and setTimeout is slow. +// call of async fn will return Promise, which will be fullfiled only on +// next scheduler queue processing step and this is exactly what we need. +const nextTick = async () => { }; +// Returns control to thread each 'tick' ms to avoid blocking +async function asyncLoop(iters, tick, cb) { + let ts = Date.now(); + for (let i = 0; i < iters; i++) { + cb(i); + // Date.now() is not monotonic, so in case if clock goes backwards we return return control too + const diff = Date.now() - ts; + if (diff >= 0 && diff < tick) + continue; + await nextTick(); + ts += diff; + } +} +/** + * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) + */ +function utf8ToBytes$1(str) { + if (typeof str !== 'string') + throw new Error(`utf8ToBytes expected string, got ${typeof str}`); + return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 +} +/** + * Normalizes (non-hex) string or Uint8Array to Uint8Array. + * Warning: when Uint8Array is passed, it would NOT get copied. + * Keep in mind for future mutable operations. + */ +function toBytes(data) { + if (typeof data === 'string') + data = utf8ToBytes$1(data); + if (!u8a$1(data)) + throw new Error(`expected Uint8Array, got ${typeof data}`); + return data; +} +/** + * Copies several Uint8Arrays into one. + */ +function concatBytes$1(...arrays) { + const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0)); + let pad = 0; // walk through each item, ensure they have proper type + arrays.forEach((a) => { + if (!u8a$1(a)) + throw new Error('Uint8Array expected'); + r.set(a, pad); + pad += a.length; + }); + return r; +} +// For runtime check if class implements interface +class Hash { + // Safe version that clones internal state + clone() { + return this._cloneInto(); + } +} +const toStr = {}.toString; +function checkOpts(defaults, opts) { + if (opts !== undefined && toStr.call(opts) !== '[object Object]') + throw new Error('Options should be object or undefined'); + const merged = Object.assign(defaults, opts); + return merged; +} +function wrapConstructor(hashCons) { + const hashC = (msg) => hashCons().update(toBytes(msg)).digest(); + const tmp = hashCons(); + hashC.outputLen = tmp.outputLen; + hashC.blockLen = tmp.blockLen; + hashC.create = () => hashCons(); + return hashC; +} +/** + * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS. + */ +function randomBytes$2(bytesLength = 32) { + if (crypto$1 && typeof crypto$1.getRandomValues === 'function') { + return crypto$1.getRandomValues(new Uint8Array(bytesLength)); + } + throw new Error('crypto.getRandomValues must be defined'); +} + +// SHA3 (keccak) is based on a new design: basically, the internal state is bigger than output size. +// It's called a sponge function. +// Various per round constants calculations +const [SHA3_PI, SHA3_ROTL, _SHA3_IOTA] = [[], [], []]; +const _0n$4 = /* @__PURE__ */ BigInt(0); +const _1n$5 = /* @__PURE__ */ BigInt(1); +const _2n$3 = /* @__PURE__ */ BigInt(2); +const _7n = /* @__PURE__ */ BigInt(7); +const _256n = /* @__PURE__ */ BigInt(256); +const _0x71n = /* @__PURE__ */ BigInt(0x71); +for (let round = 0, R = _1n$5, x = 1, y = 0; round < 24; round++) { + // Pi + [x, y] = [y, (2 * x + 3 * y) % 5]; + SHA3_PI.push(2 * (5 * y + x)); + // Rotational + SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64); + // Iota + let t = _0n$4; + for (let j = 0; j < 7; j++) { + R = ((R << _1n$5) ^ ((R >> _7n) * _0x71n)) % _256n; + if (R & _2n$3) + t ^= _1n$5 << ((_1n$5 << /* @__PURE__ */ BigInt(j)) - _1n$5); + } + _SHA3_IOTA.push(t); +} +const [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ split$1(_SHA3_IOTA, true); +// Left rotation (without 0, 32, 64) +const rotlH = (h, l, s) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s)); +const rotlL = (h, l, s) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s)); +// Same as keccakf1600, but allows to skip some rounds +function keccakP(s, rounds = 24) { + const B = new Uint32Array(5 * 2); + // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js) + for (let round = 24 - rounds; round < 24; round++) { + // Theta θ + for (let x = 0; x < 10; x++) + B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40]; + for (let x = 0; x < 10; x += 2) { + const idx1 = (x + 8) % 10; + const idx0 = (x + 2) % 10; + const B0 = B[idx0]; + const B1 = B[idx0 + 1]; + const Th = rotlH(B0, B1, 1) ^ B[idx1]; + const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1]; + for (let y = 0; y < 50; y += 10) { + s[x + y] ^= Th; + s[x + y + 1] ^= Tl; + } + } + // Rho (ρ) and Pi (π) + let curH = s[2]; + let curL = s[3]; + for (let t = 0; t < 24; t++) { + const shift = SHA3_ROTL[t]; + const Th = rotlH(curH, curL, shift); + const Tl = rotlL(curH, curL, shift); + const PI = SHA3_PI[t]; + curH = s[PI]; + curL = s[PI + 1]; + s[PI] = Th; + s[PI + 1] = Tl; + } + // Chi (χ) + for (let y = 0; y < 50; y += 10) { + for (let x = 0; x < 10; x++) + B[x] = s[y + x]; + for (let x = 0; x < 10; x++) + s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10]; + } + // Iota (ι) + s[0] ^= SHA3_IOTA_H[round]; + s[1] ^= SHA3_IOTA_L[round]; + } + B.fill(0); +} +class Keccak extends Hash { + // NOTE: we accept arguments in bytes instead of bits here. + constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) { + super(); + this.blockLen = blockLen; + this.suffix = suffix; + this.outputLen = outputLen; + this.enableXOF = enableXOF; + this.rounds = rounds; + this.pos = 0; + this.posOut = 0; + this.finished = false; + this.destroyed = false; + // Can be passed from user as dkLen + number(outputLen); + // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes + if (0 >= this.blockLen || this.blockLen >= 200) + throw new Error('Sha3 supports only keccak-f1600 function'); + this.state = new Uint8Array(200); + this.state32 = u32$1(this.state); + } + keccak() { + keccakP(this.state32, this.rounds); + this.posOut = 0; + this.pos = 0; + } + update(data) { + exists(this); + const { blockLen, state } = this; + data = toBytes(data); + const len = data.length; + for (let pos = 0; pos < len;) { + const take = Math.min(blockLen - this.pos, len - pos); + for (let i = 0; i < take; i++) + state[this.pos++] ^= data[pos++]; + if (this.pos === blockLen) + this.keccak(); + } + return this; + } + finish() { + if (this.finished) + return; + this.finished = true; + const { state, suffix, pos, blockLen } = this; + // Do the padding + state[pos] ^= suffix; + if ((suffix & 0x80) !== 0 && pos === blockLen - 1) + this.keccak(); + state[blockLen - 1] ^= 0x80; + this.keccak(); + } + writeInto(out) { + exists(this, false); + bytes(out); + this.finish(); + const bufferOut = this.state; + const { blockLen } = this; + for (let pos = 0, len = out.length; pos < len;) { + if (this.posOut >= blockLen) + this.keccak(); + const take = Math.min(blockLen - this.posOut, len - pos); + out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos); + this.posOut += take; + pos += take; + } + return out; + } + xofInto(out) { + // Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF + if (!this.enableXOF) + throw new Error('XOF is not possible for this instance'); + return this.writeInto(out); + } + xof(bytes) { + number(bytes); + return this.xofInto(new Uint8Array(bytes)); + } + digestInto(out) { + output(out, this); + if (this.finished) + throw new Error('digest() was already called'); + this.writeInto(out); + this.destroy(); + return out; + } + digest() { + return this.digestInto(new Uint8Array(this.outputLen)); + } + destroy() { + this.destroyed = true; + this.state.fill(0); + } + _cloneInto(to) { + const { blockLen, suffix, outputLen, rounds, enableXOF } = this; + to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds)); + to.state32.set(this.state32); + to.pos = this.pos; + to.posOut = this.posOut; + to.finished = this.finished; + to.rounds = rounds; + // Suffix can change in cSHAKE + to.suffix = suffix; + to.outputLen = outputLen; + to.enableXOF = enableXOF; + to.destroyed = this.destroyed; + return to; + } +} +const gen = (suffix, blockLen, outputLen) => wrapConstructor(() => new Keccak(blockLen, suffix, outputLen)); +/** + * keccak-256 hash function. Different from SHA3-256. + * @param message - that would be hashed + */ +const keccak_256 = /* @__PURE__ */ gen(0x01, 136, 256 / 8); + +/** + * Cryptographic hashing functions + * + * @_subsection: api/crypto:Hash Functions [about-crypto-hashing] + */ +let locked$3 = false; +const _keccak256 = function (data) { + return keccak_256(data); +}; +let __keccak256 = _keccak256; +/** + * Compute the cryptographic KECCAK256 hash of %%data%%. + * + * The %%data%% **must** be a data representation, to compute the + * hash of UTF-8 data use the [[id]] function. + * + * @returns DataHexstring + * @example: + * keccak256("0x") + * //_result: + * + * keccak256("0x1337") + * //_result: + * + * keccak256(new Uint8Array([ 0x13, 0x37 ])) + * //_result: + * + * // Strings are assumed to be DataHexString, otherwise it will + * // throw. To hash UTF-8 data, see the note above. + * keccak256("Hello World") + * //_error: + */ +function keccak256$1(_data) { + const data = getBytes(_data, "data"); + return hexlify(__keccak256(data)); +} +keccak256$1._ = _keccak256; +keccak256$1.lock = function () { locked$3 = true; }; +keccak256$1.register = function (func) { + if (locked$3) { + throw new TypeError("keccak256 is locked"); + } + __keccak256 = func; +}; +Object.freeze(keccak256$1); + +// Polyfill for Safari 14 +function setBigUint64(view, byteOffset, value, isLE) { + if (typeof view.setBigUint64 === 'function') + return view.setBigUint64(byteOffset, value, isLE); + const _32n = BigInt(32); + const _u32_max = BigInt(0xffffffff); + const wh = Number((value >> _32n) & _u32_max); + const wl = Number(value & _u32_max); + const h = isLE ? 4 : 0; + const l = isLE ? 0 : 4; + view.setUint32(byteOffset + h, wh, isLE); + view.setUint32(byteOffset + l, wl, isLE); +} +// Base SHA2 class (RFC 6234) +class SHA2 extends Hash { + constructor(blockLen, outputLen, padOffset, isLE) { + super(); + this.blockLen = blockLen; + this.outputLen = outputLen; + this.padOffset = padOffset; + this.isLE = isLE; + this.finished = false; + this.length = 0; + this.pos = 0; + this.destroyed = false; + this.buffer = new Uint8Array(blockLen); + this.view = createView(this.buffer); + } + update(data) { + exists(this); + const { view, buffer, blockLen } = this; + data = toBytes(data); + const len = data.length; + for (let pos = 0; pos < len;) { + const take = Math.min(blockLen - this.pos, len - pos); + // Fast path: we have at least one block in input, cast it to view and process + if (take === blockLen) { + const dataView = createView(data); + for (; blockLen <= len - pos; pos += blockLen) + this.process(dataView, pos); + continue; + } + buffer.set(data.subarray(pos, pos + take), this.pos); + this.pos += take; + pos += take; + if (this.pos === blockLen) { + this.process(view, 0); + this.pos = 0; + } + } + this.length += data.length; + this.roundClean(); + return this; + } + digestInto(out) { + exists(this); + output(out, this); + this.finished = true; + // Padding + // We can avoid allocation of buffer for padding completely if it + // was previously not allocated here. But it won't change performance. + const { buffer, view, blockLen, isLE } = this; + let { pos } = this; + // append the bit '1' to the message + buffer[pos++] = 0b10000000; + this.buffer.subarray(pos).fill(0); + // we have less than padOffset left in buffer, so we cannot put length in current block, need process it and pad again + if (this.padOffset > blockLen - pos) { + this.process(view, 0); + pos = 0; + } + // Pad until full block byte with zeros + for (let i = pos; i < blockLen; i++) + buffer[i] = 0; + // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that + // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen. + // So we just write lowest 64 bits of that value. + setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE); + this.process(view, 0); + const oview = createView(out); + const len = this.outputLen; + // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT + if (len % 4) + throw new Error('_sha2: outputLen should be aligned to 32bit'); + const outLen = len / 4; + const state = this.get(); + if (outLen > state.length) + throw new Error('_sha2: outputLen bigger than state'); + for (let i = 0; i < outLen; i++) + oview.setUint32(4 * i, state[i], isLE); + } + digest() { + const { buffer, outputLen } = this; + this.digestInto(buffer); + const res = buffer.slice(0, outputLen); + this.destroy(); + return res; + } + _cloneInto(to) { + to || (to = new this.constructor()); + to.set(...this.get()); + const { blockLen, buffer, length, finished, destroyed, pos } = this; + to.length = length; + to.pos = pos; + to.finished = finished; + to.destroyed = destroyed; + if (length % blockLen) + to.buffer.set(buffer); + return to; + } +} + +// https://homes.esat.kuleuven.be/~bosselae/ripemd160.html +// https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf +const Rho = /* @__PURE__ */ new Uint8Array([7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8]); +const Id = /* @__PURE__ */ Uint8Array.from({ length: 16 }, (_, i) => i); +const Pi = /* @__PURE__ */ Id.map((i) => (9 * i + 5) % 16); +let idxL = [Id]; +let idxR = [Pi]; +for (let i = 0; i < 4; i++) + for (let j of [idxL, idxR]) + j.push(j[i].map((k) => Rho[k])); +const shifts = /* @__PURE__ */ [ + [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8], + [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7], + [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9], + [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6], + [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5], +].map((i) => new Uint8Array(i)); +const shiftsL = /* @__PURE__ */ idxL.map((idx, i) => idx.map((j) => shifts[i][j])); +const shiftsR = /* @__PURE__ */ idxR.map((idx, i) => idx.map((j) => shifts[i][j])); +const Kl = /* @__PURE__ */ new Uint32Array([ + 0x00000000, 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xa953fd4e, +]); +const Kr = /* @__PURE__ */ new Uint32Array([ + 0x50a28be6, 0x5c4dd124, 0x6d703ef3, 0x7a6d76e9, 0x00000000, +]); +// The rotate left (circular left shift) operation for uint32 +const rotl$1 = (word, shift) => (word << shift) | (word >>> (32 - shift)); +// It's called f() in spec. +function f(group, x, y, z) { + if (group === 0) + return x ^ y ^ z; + else if (group === 1) + return (x & y) | (~x & z); + else if (group === 2) + return (x | ~y) ^ z; + else if (group === 3) + return (x & z) | (y & ~z); + else + return x ^ (y | ~z); +} +// Temporary buffer, not used to store anything between runs +const BUF = /* @__PURE__ */ new Uint32Array(16); +class RIPEMD160 extends SHA2 { + constructor() { + super(64, 20, 8, true); + this.h0 = 0x67452301 | 0; + this.h1 = 0xefcdab89 | 0; + this.h2 = 0x98badcfe | 0; + this.h3 = 0x10325476 | 0; + this.h4 = 0xc3d2e1f0 | 0; + } + get() { + const { h0, h1, h2, h3, h4 } = this; + return [h0, h1, h2, h3, h4]; + } + set(h0, h1, h2, h3, h4) { + this.h0 = h0 | 0; + this.h1 = h1 | 0; + this.h2 = h2 | 0; + this.h3 = h3 | 0; + this.h4 = h4 | 0; + } + process(view, offset) { + for (let i = 0; i < 16; i++, offset += 4) + BUF[i] = view.getUint32(offset, true); + // prettier-ignore + let al = this.h0 | 0, ar = al, bl = this.h1 | 0, br = bl, cl = this.h2 | 0, cr = cl, dl = this.h3 | 0, dr = dl, el = this.h4 | 0, er = el; + // Instead of iterating 0 to 80, we split it into 5 groups + // And use the groups in constants, functions, etc. Much simpler + for (let group = 0; group < 5; group++) { + const rGroup = 4 - group; + const hbl = Kl[group], hbr = Kr[group]; // prettier-ignore + const rl = idxL[group], rr = idxR[group]; // prettier-ignore + const sl = shiftsL[group], sr = shiftsR[group]; // prettier-ignore + for (let i = 0; i < 16; i++) { + const tl = (rotl$1(al + f(group, bl, cl, dl) + BUF[rl[i]] + hbl, sl[i]) + el) | 0; + al = el, el = dl, dl = rotl$1(cl, 10) | 0, cl = bl, bl = tl; // prettier-ignore + } + // 2 loops are 10% faster + for (let i = 0; i < 16; i++) { + const tr = (rotl$1(ar + f(rGroup, br, cr, dr) + BUF[rr[i]] + hbr, sr[i]) + er) | 0; + ar = er, er = dr, dr = rotl$1(cr, 10) | 0, cr = br, br = tr; // prettier-ignore + } + } + // Add the compressed chunk to the current hash value + this.set((this.h1 + cl + dr) | 0, (this.h2 + dl + er) | 0, (this.h3 + el + ar) | 0, (this.h4 + al + br) | 0, (this.h0 + bl + cr) | 0); + } + roundClean() { + BUF.fill(0); + } + destroy() { + this.destroyed = true; + this.buffer.fill(0); + this.set(0, 0, 0, 0, 0); + } +} +/** + * RIPEMD-160 - a hash function from 1990s. + * @param message - msg that would be hashed + */ +const ripemd160$1 = /* @__PURE__ */ wrapConstructor(() => new RIPEMD160()); + +let locked$2 = false; +const _ripemd160 = function (data) { + return ripemd160$1(data); +}; +let __ripemd160 = _ripemd160; +/** + * Compute the cryptographic RIPEMD-160 hash of %%data%%. + * + * @_docloc: api/crypto:Hash Functions + * @returns DataHexstring + * + * @example: + * ripemd160("0x") + * //_result: + * + * ripemd160("0x1337") + * //_result: + * + * ripemd160(new Uint8Array([ 0x13, 0x37 ])) + * //_result: + * + */ +function ripemd160(_data) { + const data = getBytes(_data, "data"); + return hexlify(__ripemd160(data)); +} +ripemd160._ = _ripemd160; +ripemd160.lock = function () { locked$2 = true; }; +ripemd160.register = function (func) { + if (locked$2) { + throw new TypeError("ripemd160 is locked"); + } + __ripemd160 = func; +}; +Object.freeze(ripemd160); + +/** + * A **Password-Based Key-Derivation Function** is designed to create + * a sequence of bytes suitible as a **key** from a human-rememberable + * password. + * + * @_subsection: api/crypto:Passwords [about-pbkdf] + */ +let locked$1 = false; +const _pbkdf2 = function (password, salt, iterations, keylen, algo) { + return require$$5.pbkdf2Sync(password, salt, iterations, keylen, algo); +}; +let __pbkdf2 = _pbkdf2; +/** + * Return the [[link-pbkdf2]] for %%keylen%% bytes for %%password%% using + * the %%salt%% and using %%iterations%% of %%algo%%. + * + * This PBKDF is outdated and should not be used in new projects, but is + * required to decrypt older files. + * + * @example: + * // The password must be converted to bytes, and it is generally + * // best practices to ensure the string has been normalized. Many + * // formats explicitly indicate the normalization form to use. + * password = "hello" + * passwordBytes = toUtf8Bytes(password, "NFKC") + * + * salt = id("some-salt") + * + * // Compute the PBKDF2 + * pbkdf2(passwordBytes, salt, 1024, 16, "sha256") + * //_result: + */ +function pbkdf2$1(_password, _salt, iterations, keylen, algo) { + const password = getBytes(_password, "password"); + const salt = getBytes(_salt, "salt"); + return hexlify(__pbkdf2(password, salt, iterations, keylen, algo)); +} +pbkdf2$1._ = _pbkdf2; +pbkdf2$1.lock = function () { locked$1 = true; }; +pbkdf2$1.register = function (func) { + if (locked$1) { + throw new Error("pbkdf2 is locked"); + } + __pbkdf2 = func; +}; +Object.freeze(pbkdf2$1); + +/** + * A **Cryptographically Secure Random Value** is one that has been + * generated with additional care take to prevent side-channels + * from allowing others to detect it and prevent others from through + * coincidence generate the same values. + * + * @_subsection: api/crypto:Random Values [about-crypto-random] + */ +let locked = false; +const _randomBytes = function (length) { + return new Uint8Array(require$$5.randomBytes(length)); +}; +let __randomBytes = _randomBytes; +/** + * Return %%length%% bytes of cryptographically secure random data. + * + * @example: + * randomBytes(8) + * //_result: + */ +function randomBytes$1(length) { + return __randomBytes(length); +} +randomBytes$1._ = _randomBytes; +randomBytes$1.lock = function () { locked = true; }; +randomBytes$1.register = function (func) { + if (locked) { + throw new Error("randomBytes is locked"); + } + __randomBytes = func; +}; +Object.freeze(randomBytes$1); + +// SHA2-256 need to try 2^128 hashes to execute birthday attack. +// BTC network is doing 2^67 hashes/sec as per early 2023. +// Choice: a ? b : c +const Chi = (a, b, c) => (a & b) ^ (~a & c); +// Majority function, true if any two inpust is true +const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c); +// Round constants: +// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311) +// prettier-ignore +const SHA256_K = /* @__PURE__ */ new Uint32Array([ + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +]); +// Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19): +// prettier-ignore +const IV = /* @__PURE__ */ new Uint32Array([ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 +]); +// Temporary buffer, not used to store anything between runs +// Named this way because it matches specification. +const SHA256_W = /* @__PURE__ */ new Uint32Array(64); +class SHA256 extends SHA2 { + constructor() { + super(64, 32, 8, false); + // We cannot use array here since array allows indexing by variable + // which means optimizer/compiler cannot use registers. + this.A = IV[0] | 0; + this.B = IV[1] | 0; + this.C = IV[2] | 0; + this.D = IV[3] | 0; + this.E = IV[4] | 0; + this.F = IV[5] | 0; + this.G = IV[6] | 0; + this.H = IV[7] | 0; + } + get() { + const { A, B, C, D, E, F, G, H } = this; + return [A, B, C, D, E, F, G, H]; + } + // prettier-ignore + set(A, B, C, D, E, F, G, H) { + this.A = A | 0; + this.B = B | 0; + this.C = C | 0; + this.D = D | 0; + this.E = E | 0; + this.F = F | 0; + this.G = G | 0; + this.H = H | 0; + } + process(view, offset) { + // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array + for (let i = 0; i < 16; i++, offset += 4) + SHA256_W[i] = view.getUint32(offset, false); + for (let i = 16; i < 64; i++) { + const W15 = SHA256_W[i - 15]; + const W2 = SHA256_W[i - 2]; + const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3); + const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10); + SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0; + } + // Compression function main loop, 64 rounds + let { A, B, C, D, E, F, G, H } = this; + for (let i = 0; i < 64; i++) { + const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25); + const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0; + const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22); + const T2 = (sigma0 + Maj(A, B, C)) | 0; + H = G; + G = F; + F = E; + E = (D + T1) | 0; + D = C; + C = B; + B = A; + A = (T1 + T2) | 0; + } + // Add the compressed chunk to the current hash value + A = (A + this.A) | 0; + B = (B + this.B) | 0; + C = (C + this.C) | 0; + D = (D + this.D) | 0; + E = (E + this.E) | 0; + F = (F + this.F) | 0; + G = (G + this.G) | 0; + H = (H + this.H) | 0; + this.set(A, B, C, D, E, F, G, H); + } + roundClean() { + SHA256_W.fill(0); + } + destroy() { + this.set(0, 0, 0, 0, 0, 0, 0, 0); + this.buffer.fill(0); + } +} +/** + * SHA2-256 hash function + * @param message - data that would be hashed + */ +const sha256$1 = /* @__PURE__ */ wrapConstructor(() => new SHA256()); + +// HMAC (RFC 2104) +class HMAC extends Hash { + constructor(hash$1, _key) { + super(); + this.finished = false; + this.destroyed = false; + hash(hash$1); + const key = toBytes(_key); + this.iHash = hash$1.create(); + if (typeof this.iHash.update !== 'function') + throw new Error('Expected instance of class which extends utils.Hash'); + this.blockLen = this.iHash.blockLen; + this.outputLen = this.iHash.outputLen; + const blockLen = this.blockLen; + const pad = new Uint8Array(blockLen); + // blockLen can be bigger than outputLen + pad.set(key.length > blockLen ? hash$1.create().update(key).digest() : key); + for (let i = 0; i < pad.length; i++) + pad[i] ^= 0x36; + this.iHash.update(pad); + // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone + this.oHash = hash$1.create(); + // Undo internal XOR && apply outer XOR + for (let i = 0; i < pad.length; i++) + pad[i] ^= 0x36 ^ 0x5c; + this.oHash.update(pad); + pad.fill(0); + } + update(buf) { + exists(this); + this.iHash.update(buf); + return this; + } + digestInto(out) { + exists(this); + bytes(out, this.outputLen); + this.finished = true; + this.iHash.digestInto(out); + this.oHash.update(out); + this.oHash.digestInto(out); + this.destroy(); + } + digest() { + const out = new Uint8Array(this.oHash.outputLen); + this.digestInto(out); + return out; + } + _cloneInto(to) { + // Create new instance without calling constructor since key already in state and we don't know it. + to || (to = Object.create(Object.getPrototypeOf(this), {})); + const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this; + to = to; + to.finished = finished; + to.destroyed = destroyed; + to.blockLen = blockLen; + to.outputLen = outputLen; + to.oHash = oHash._cloneInto(to.oHash); + to.iHash = iHash._cloneInto(to.iHash); + return to; + } + destroy() { + this.destroyed = true; + this.oHash.destroy(); + this.iHash.destroy(); + } +} +/** + * HMAC: RFC2104 message authentication code. + * @param hash - function that would be used e.g. sha256 + * @param key - message key + * @param message - message data + */ +const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest(); +hmac.create = (hash, key) => new HMAC(hash, key); + +// Common prologue and epilogue for sync/async functions +function pbkdf2Init(hash$1, _password, _salt, _opts) { + hash(hash$1); + const opts = checkOpts({ dkLen: 32, asyncTick: 10 }, _opts); + const { c, dkLen, asyncTick } = opts; + number(c); + number(dkLen); + number(asyncTick); + if (c < 1) + throw new Error('PBKDF2: iterations (c) should be >= 1'); + const password = toBytes(_password); + const salt = toBytes(_salt); + // DK = PBKDF2(PRF, Password, Salt, c, dkLen); + const DK = new Uint8Array(dkLen); + // U1 = PRF(Password, Salt + INT_32_BE(i)) + const PRF = hmac.create(hash$1, password); + const PRFSalt = PRF._cloneInto().update(salt); + return { c, dkLen, asyncTick, DK, PRF, PRFSalt }; +} +function pbkdf2Output(PRF, PRFSalt, DK, prfW, u) { + PRF.destroy(); + PRFSalt.destroy(); + if (prfW) + prfW.destroy(); + u.fill(0); + return DK; +} +/** + * PBKDF2-HMAC: RFC 2898 key derivation function + * @param hash - hash function that would be used e.g. sha256 + * @param password - password from which a derived key is generated + * @param salt - cryptographic salt + * @param opts - {c, dkLen} where c is work factor and dkLen is output message size + */ +function pbkdf2(hash, password, salt, opts) { + const { c, dkLen, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts); + let prfW; // Working copy + const arr = new Uint8Array(4); + const view = createView(arr); + const u = new Uint8Array(PRF.outputLen); + // DK = T1 + T2 + ⋯ + Tdklen/hlen + for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) { + // Ti = F(Password, Salt, c, i) + const Ti = DK.subarray(pos, pos + PRF.outputLen); + view.setInt32(0, ti, false); + // F(Password, Salt, c, i) = U1 ^ U2 ^ ⋯ ^ Uc + // U1 = PRF(Password, Salt + INT_32_BE(i)) + (prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u); + Ti.set(u.subarray(0, Ti.length)); + for (let ui = 1; ui < c; ui++) { + // Uc = PRF(Password, Uc−1) + PRF._cloneInto(prfW).update(u).digestInto(u); + for (let i = 0; i < Ti.length; i++) + Ti[i] ^= u[i]; + } + } + return pbkdf2Output(PRF, PRFSalt, DK, prfW, u); +} + +// RFC 7914 Scrypt KDF +// Left rotate for uint32 +const rotl = (a, b) => (a << b) | (a >>> (32 - b)); +// The main Scrypt loop: uses Salsa extensively. +// Six versions of the function were tried, this is the fastest one. +// prettier-ignore +function XorAndSalsa(prev, pi, input, ii, out, oi) { + // Based on https://cr.yp.to/salsa20.html + // Xor blocks + let y00 = prev[pi++] ^ input[ii++], y01 = prev[pi++] ^ input[ii++]; + let y02 = prev[pi++] ^ input[ii++], y03 = prev[pi++] ^ input[ii++]; + let y04 = prev[pi++] ^ input[ii++], y05 = prev[pi++] ^ input[ii++]; + let y06 = prev[pi++] ^ input[ii++], y07 = prev[pi++] ^ input[ii++]; + let y08 = prev[pi++] ^ input[ii++], y09 = prev[pi++] ^ input[ii++]; + let y10 = prev[pi++] ^ input[ii++], y11 = prev[pi++] ^ input[ii++]; + let y12 = prev[pi++] ^ input[ii++], y13 = prev[pi++] ^ input[ii++]; + let y14 = prev[pi++] ^ input[ii++], y15 = prev[pi++] ^ input[ii++]; + // Save state to temporary variables (salsa) + let x00 = y00, x01 = y01, x02 = y02, x03 = y03, x04 = y04, x05 = y05, x06 = y06, x07 = y07, x08 = y08, x09 = y09, x10 = y10, x11 = y11, x12 = y12, x13 = y13, x14 = y14, x15 = y15; + // Main loop (salsa) + for (let i = 0; i < 8; i += 2) { + x04 ^= rotl(x00 + x12 | 0, 7); + x08 ^= rotl(x04 + x00 | 0, 9); + x12 ^= rotl(x08 + x04 | 0, 13); + x00 ^= rotl(x12 + x08 | 0, 18); + x09 ^= rotl(x05 + x01 | 0, 7); + x13 ^= rotl(x09 + x05 | 0, 9); + x01 ^= rotl(x13 + x09 | 0, 13); + x05 ^= rotl(x01 + x13 | 0, 18); + x14 ^= rotl(x10 + x06 | 0, 7); + x02 ^= rotl(x14 + x10 | 0, 9); + x06 ^= rotl(x02 + x14 | 0, 13); + x10 ^= rotl(x06 + x02 | 0, 18); + x03 ^= rotl(x15 + x11 | 0, 7); + x07 ^= rotl(x03 + x15 | 0, 9); + x11 ^= rotl(x07 + x03 | 0, 13); + x15 ^= rotl(x11 + x07 | 0, 18); + x01 ^= rotl(x00 + x03 | 0, 7); + x02 ^= rotl(x01 + x00 | 0, 9); + x03 ^= rotl(x02 + x01 | 0, 13); + x00 ^= rotl(x03 + x02 | 0, 18); + x06 ^= rotl(x05 + x04 | 0, 7); + x07 ^= rotl(x06 + x05 | 0, 9); + x04 ^= rotl(x07 + x06 | 0, 13); + x05 ^= rotl(x04 + x07 | 0, 18); + x11 ^= rotl(x10 + x09 | 0, 7); + x08 ^= rotl(x11 + x10 | 0, 9); + x09 ^= rotl(x08 + x11 | 0, 13); + x10 ^= rotl(x09 + x08 | 0, 18); + x12 ^= rotl(x15 + x14 | 0, 7); + x13 ^= rotl(x12 + x15 | 0, 9); + x14 ^= rotl(x13 + x12 | 0, 13); + x15 ^= rotl(x14 + x13 | 0, 18); + } + // Write output (salsa) + out[oi++] = (y00 + x00) | 0; + out[oi++] = (y01 + x01) | 0; + out[oi++] = (y02 + x02) | 0; + out[oi++] = (y03 + x03) | 0; + out[oi++] = (y04 + x04) | 0; + out[oi++] = (y05 + x05) | 0; + out[oi++] = (y06 + x06) | 0; + out[oi++] = (y07 + x07) | 0; + out[oi++] = (y08 + x08) | 0; + out[oi++] = (y09 + x09) | 0; + out[oi++] = (y10 + x10) | 0; + out[oi++] = (y11 + x11) | 0; + out[oi++] = (y12 + x12) | 0; + out[oi++] = (y13 + x13) | 0; + out[oi++] = (y14 + x14) | 0; + out[oi++] = (y15 + x15) | 0; +} +function BlockMix(input, ii, out, oi, r) { + // The block B is r 128-byte chunks (which is equivalent of 2r 64-byte chunks) + let head = oi + 0; + let tail = oi + 16 * r; + for (let i = 0; i < 16; i++) + out[tail + i] = input[ii + (2 * r - 1) * 16 + i]; // X ← B[2r−1] + for (let i = 0; i < r; i++, head += 16, ii += 16) { + // We write odd & even Yi at same time. Even: 0bXXXXX0 Odd: 0bXXXXX1 + XorAndSalsa(out, tail, input, ii, out, head); // head[i] = Salsa(blockIn[2*i] ^ tail[i-1]) + if (i > 0) + tail += 16; // First iteration overwrites tmp value in tail + XorAndSalsa(out, head, input, (ii += 16), out, tail); // tail[i] = Salsa(blockIn[2*i+1] ^ head[i]) + } +} +// Common prologue and epilogue for sync/async functions +function scryptInit(password, salt, _opts) { + // Maxmem - 1GB+1KB by default + const opts = checkOpts({ + dkLen: 32, + asyncTick: 10, + maxmem: 1024 ** 3 + 1024, + }, _opts); + const { N, r, p, dkLen, asyncTick, maxmem, onProgress } = opts; + number(N); + number(r); + number(p); + number(dkLen); + number(asyncTick); + number(maxmem); + if (onProgress !== undefined && typeof onProgress !== 'function') + throw new Error('progressCb should be function'); + const blockSize = 128 * r; + const blockSize32 = blockSize / 4; + if (N <= 1 || (N & (N - 1)) !== 0 || N >= 2 ** (blockSize / 8) || N > 2 ** 32) { + // NOTE: we limit N to be less than 2**32 because of 32 bit variant of Integrify function + // There is no JS engines that allows alocate more than 4GB per single Uint8Array for now, but can change in future. + throw new Error('Scrypt: N must be larger than 1, a power of 2, less than 2^(128 * r / 8) and less than 2^32'); + } + if (p < 0 || p > ((2 ** 32 - 1) * 32) / blockSize) { + throw new Error('Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)'); + } + if (dkLen < 0 || dkLen > (2 ** 32 - 1) * 32) { + throw new Error('Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32'); + } + const memUsed = blockSize * (N + p); + if (memUsed > maxmem) { + throw new Error(`Scrypt: parameters too large, ${memUsed} (128 * r * (N + p)) > ${maxmem} (maxmem)`); + } + // [B0...Bp−1] ← PBKDF2HMAC-SHA256(Passphrase, Salt, 1, blockSize*ParallelizationFactor) + // Since it has only one iteration there is no reason to use async variant + const B = pbkdf2(sha256$1, password, salt, { c: 1, dkLen: blockSize * p }); + const B32 = u32$1(B); + // Re-used between parallel iterations. Array(iterations) of B + const V = u32$1(new Uint8Array(blockSize * N)); + const tmp = u32$1(new Uint8Array(blockSize)); + let blockMixCb = () => { }; + if (onProgress) { + const totalBlockMix = 2 * N * p; + // Invoke callback if progress changes from 10.01 to 10.02 + // Allows to draw smooth progress bar on up to 8K screen + const callbackPer = Math.max(Math.floor(totalBlockMix / 10000), 1); + let blockMixCnt = 0; + blockMixCb = () => { + blockMixCnt++; + if (onProgress && (!(blockMixCnt % callbackPer) || blockMixCnt === totalBlockMix)) + onProgress(blockMixCnt / totalBlockMix); + }; + } + return { N, r, p, dkLen, blockSize32, V, B32, B, tmp, blockMixCb, asyncTick }; +} +function scryptOutput(password, dkLen, B, V, tmp) { + const res = pbkdf2(sha256$1, password, B, { c: 1, dkLen }); + B.fill(0); + V.fill(0); + tmp.fill(0); + return res; +} +/** + * Scrypt KDF from RFC 7914. + * @param password - pass + * @param salt - salt + * @param opts - parameters + * - `N` is cpu/mem work factor (power of 2 e.g. 2**18) + * - `r` is block size (8 is common), fine-tunes sequential memory read size and performance + * - `p` is parallelization factor (1 is common) + * - `dkLen` is output key length in bytes e.g. 32. + * - `asyncTick` - (default: 10) max time in ms for which async function can block execution + * - `maxmem` - (default: `1024 ** 3 + 1024` aka 1GB+1KB). A limit that the app could use for scrypt + * - `onProgress` - callback function that would be executed for progress report + * @returns Derived key + */ +function scrypt$1(password, salt, opts) { + const { N, r, p, dkLen, blockSize32, V, B32, B, tmp, blockMixCb } = scryptInit(password, salt, opts); + for (let pi = 0; pi < p; pi++) { + const Pi = blockSize32 * pi; + for (let i = 0; i < blockSize32; i++) + V[i] = B32[Pi + i]; // V[0] = B[i] + for (let i = 0, pos = 0; i < N - 1; i++) { + BlockMix(V, pos, V, (pos += blockSize32), r); // V[i] = BlockMix(V[i-1]); + blockMixCb(); + } + BlockMix(V, (N - 1) * blockSize32, B32, Pi, r); // Process last element + blockMixCb(); + for (let i = 0; i < N; i++) { + // First u32 of the last 64-byte block (u32 is LE) + const j = B32[Pi + blockSize32 - 16] % N; // j = Integrify(X) % iterations + for (let k = 0; k < blockSize32; k++) + tmp[k] = B32[Pi + k] ^ V[j * blockSize32 + k]; // tmp = B ^ V[j] + BlockMix(tmp, 0, B32, Pi, r); // B = BlockMix(B ^ V[j]) + blockMixCb(); + } + } + return scryptOutput(password, dkLen, B, V, tmp); +} +/** + * Scrypt KDF from RFC 7914. + */ +async function scryptAsync(password, salt, opts) { + const { N, r, p, dkLen, blockSize32, V, B32, B, tmp, blockMixCb, asyncTick } = scryptInit(password, salt, opts); + for (let pi = 0; pi < p; pi++) { + const Pi = blockSize32 * pi; + for (let i = 0; i < blockSize32; i++) + V[i] = B32[Pi + i]; // V[0] = B[i] + let pos = 0; + await asyncLoop(N - 1, asyncTick, () => { + BlockMix(V, pos, V, (pos += blockSize32), r); // V[i] = BlockMix(V[i-1]); + blockMixCb(); + }); + BlockMix(V, (N - 1) * blockSize32, B32, Pi, r); // Process last element + blockMixCb(); + await asyncLoop(N, asyncTick, () => { + // First u32 of the last 64-byte block (u32 is LE) + const j = B32[Pi + blockSize32 - 16] % N; // j = Integrify(X) % iterations + for (let k = 0; k < blockSize32; k++) + tmp[k] = B32[Pi + k] ^ V[j * blockSize32 + k]; // tmp = B ^ V[j] + BlockMix(tmp, 0, B32, Pi, r); // B = BlockMix(B ^ V[j]) + blockMixCb(); + }); + } + return scryptOutput(password, dkLen, B, V, tmp); +} + +let lockedSync = false, lockedAsync = false; +const _scryptAsync = async function (passwd, salt, N, r, p, dkLen, onProgress) { + return await scryptAsync(passwd, salt, { N, r, p, dkLen, onProgress }); +}; +const _scryptSync = function (passwd, salt, N, r, p, dkLen) { + return scrypt$1(passwd, salt, { N, r, p, dkLen }); +}; +let __scryptAsync = _scryptAsync; +let __scryptSync = _scryptSync; +/** + * The [[link-wiki-scrypt]] uses a memory and cpu hard method of + * derivation to increase the resource cost to brute-force a password + * for a given key. + * + * This means this algorithm is intentionally slow, and can be tuned to + * become slower. As computation and memory speed improve over time, + * increasing the difficulty maintains the cost of an attacker. + * + * For example, if a target time of 5 seconds is used, a legitimate user + * which knows their password requires only 5 seconds to unlock their + * account. A 6 character password has 68 billion possibilities, which + * would require an attacker to invest over 10,000 years of CPU time. This + * is of course a crude example (as password generally aren't random), + * but demonstrates to value of imposing large costs to decryption. + * + * For this reason, if building a UI which involved decrypting or + * encrypting datsa using scrypt, it is recommended to use a + * [[ProgressCallback]] (as event short periods can seem lik an eternity + * if the UI freezes). Including the phrase //"decrypting"// in the UI + * can also help, assuring the user their waiting is for a good reason. + * + * @_docloc: api/crypto:Passwords + * + * @example: + * // The password must be converted to bytes, and it is generally + * // best practices to ensure the string has been normalized. Many + * // formats explicitly indicate the normalization form to use. + * password = "hello" + * passwordBytes = toUtf8Bytes(password, "NFKC") + * + * salt = id("some-salt") + * + * // Compute the scrypt + * scrypt(passwordBytes, salt, 1024, 8, 1, 16) + * //_result: + */ +async function scrypt(_passwd, _salt, N, r, p, dkLen, progress) { + const passwd = getBytes(_passwd, "passwd"); + const salt = getBytes(_salt, "salt"); + return hexlify(await __scryptAsync(passwd, salt, N, r, p, dkLen, progress)); +} +scrypt._ = _scryptAsync; +scrypt.lock = function () { lockedAsync = true; }; +scrypt.register = function (func) { + if (lockedAsync) { + throw new Error("scrypt is locked"); + } + __scryptAsync = func; +}; +Object.freeze(scrypt); +/** + * Provides a synchronous variant of [[scrypt]]. + * + * This will completely lock up and freeze the UI in a browser and will + * prevent any event loop from progressing. For this reason, it is + * preferred to use the [async variant](scrypt). + * + * @_docloc: api/crypto:Passwords + * + * @example: + * // The password must be converted to bytes, and it is generally + * // best practices to ensure the string has been normalized. Many + * // formats explicitly indicate the normalization form to use. + * password = "hello" + * passwordBytes = toUtf8Bytes(password, "NFKC") + * + * salt = id("some-salt") + * + * // Compute the scrypt + * scryptSync(passwordBytes, salt, 1024, 8, 1, 16) + * //_result: + */ +function scryptSync(_passwd, _salt, N, r, p, dkLen) { + const passwd = getBytes(_passwd, "passwd"); + const salt = getBytes(_salt, "salt"); + return hexlify(__scryptSync(passwd, salt, N, r, p, dkLen)); +} +scryptSync._ = _scryptSync; +scryptSync.lock = function () { lockedSync = true; }; +scryptSync.register = function (func) { + if (lockedSync) { + throw new Error("scryptSync is locked"); + } + __scryptSync = func; +}; +Object.freeze(scryptSync); + +const _sha256 = function (data) { + return require$$5.createHash("sha256").update(data).digest(); +}; +let __sha256 = _sha256; +let locked256 = false; +/** + * Compute the cryptographic SHA2-256 hash of %%data%%. + * + * @_docloc: api/crypto:Hash Functions + * @returns DataHexstring + * + * @example: + * sha256("0x") + * //_result: + * + * sha256("0x1337") + * //_result: + * + * sha256(new Uint8Array([ 0x13, 0x37 ])) + * //_result: + * + */ +function sha256(_data) { + const data = getBytes(_data, "data"); + return hexlify(__sha256(data)); +} +sha256._ = _sha256; +sha256.lock = function () { locked256 = true; }; +sha256.register = function (func) { + if (locked256) { + throw new Error("sha256 is locked"); + } + __sha256 = func; +}; +Object.freeze(sha256); +Object.freeze(sha256); + +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +// 100 lines of code in the file are duplicated from noble-hashes (utils). +// This is OK: `abstract` directory does not use noble-hashes. +// User may opt-in into using different hashing library. This way, noble-hashes +// won't be included into their bundle. +const _0n$3 = BigInt(0); +const _1n$4 = BigInt(1); +const _2n$2 = BigInt(2); +const u8a = (a) => a instanceof Uint8Array; +const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0')); +/** + * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123' + */ +function bytesToHex$1(bytes) { + if (!u8a(bytes)) + throw new Error('Uint8Array expected'); + // pre-caching improves the speed 6x + let hex = ''; + for (let i = 0; i < bytes.length; i++) { + hex += hexes[bytes[i]]; + } + return hex; +} +function numberToHexUnpadded(num) { + const hex = num.toString(16); + return hex.length & 1 ? `0${hex}` : hex; +} +function hexToNumber(hex) { + if (typeof hex !== 'string') + throw new Error('hex string expected, got ' + typeof hex); + // Big Endian + return BigInt(hex === '' ? '0' : `0x${hex}`); +} +/** + * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23]) + */ +function hexToBytes(hex) { + if (typeof hex !== 'string') + throw new Error('hex string expected, got ' + typeof hex); + const len = hex.length; + if (len % 2) + throw new Error('padded hex string expected, got unpadded hex of length ' + len); + const array = new Uint8Array(len / 2); + for (let i = 0; i < array.length; i++) { + const j = i * 2; + const hexByte = hex.slice(j, j + 2); + const byte = Number.parseInt(hexByte, 16); + if (Number.isNaN(byte) || byte < 0) + throw new Error('Invalid byte sequence'); + array[i] = byte; + } + return array; +} +// BE: Big Endian, LE: Little Endian +function bytesToNumberBE(bytes) { + return hexToNumber(bytesToHex$1(bytes)); +} +function bytesToNumberLE(bytes) { + if (!u8a(bytes)) + throw new Error('Uint8Array expected'); + return hexToNumber(bytesToHex$1(Uint8Array.from(bytes).reverse())); +} +function numberToBytesBE(n, len) { + return hexToBytes(n.toString(16).padStart(len * 2, '0')); +} +function numberToBytesLE(n, len) { + return numberToBytesBE(n, len).reverse(); +} +// Unpadded, rarely used +function numberToVarBytesBE(n) { + return hexToBytes(numberToHexUnpadded(n)); +} +/** + * Takes hex string or Uint8Array, converts to Uint8Array. + * Validates output length. + * Will throw error for other types. + * @param title descriptive title for an error e.g. 'private key' + * @param hex hex string or Uint8Array + * @param expectedLength optional, will compare to result array's length + * @returns + */ +function ensureBytes(title, hex, expectedLength) { + let res; + if (typeof hex === 'string') { + try { + res = hexToBytes(hex); + } + catch (e) { + throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`); + } + } + else if (u8a(hex)) { + // Uint8Array.from() instead of hash.slice() because node.js Buffer + // is instance of Uint8Array, and its slice() creates **mutable** copy + res = Uint8Array.from(hex); + } + else { + throw new Error(`${title} must be hex string or Uint8Array`); + } + const len = res.length; + if (typeof expectedLength === 'number' && len !== expectedLength) + throw new Error(`${title} expected ${expectedLength} bytes, got ${len}`); + return res; +} +/** + * Copies several Uint8Arrays into one. + */ +function concatBytes(...arrays) { + const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0)); + let pad = 0; // walk through each item, ensure they have proper type + arrays.forEach((a) => { + if (!u8a(a)) + throw new Error('Uint8Array expected'); + r.set(a, pad); + pad += a.length; + }); + return r; +} +function equalBytes(b1, b2) { + // We don't care about timing attacks here + if (b1.length !== b2.length) + return false; + for (let i = 0; i < b1.length; i++) + if (b1[i] !== b2[i]) + return false; + return true; +} +/** + * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99]) + */ +function utf8ToBytes(str) { + if (typeof str !== 'string') + throw new Error(`utf8ToBytes expected string, got ${typeof str}`); + return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809 +} +// Bit operations +/** + * Calculates amount of bits in a bigint. + * Same as `n.toString(2).length` + */ +function bitLen(n) { + let len; + for (len = 0; n > _0n$3; n >>= _1n$4, len += 1) + ; + return len; +} +/** + * Gets single bit at position. + * NOTE: first bit position is 0 (same as arrays) + * Same as `!!+Array.from(n.toString(2)).reverse()[pos]` + */ +function bitGet(n, pos) { + return (n >> BigInt(pos)) & _1n$4; +} +/** + * Sets single bit at position. + */ +const bitSet = (n, pos, value) => { + return n | ((value ? _1n$4 : _0n$3) << BigInt(pos)); +}; +/** + * Calculate mask for N bits. Not using ** operator with bigints because of old engines. + * Same as BigInt(`0b${Array(i).fill('1').join('')}`) + */ +const bitMask = (n) => (_2n$2 << BigInt(n - 1)) - _1n$4; +// DRBG +const u8n = (data) => new Uint8Array(data); // creates Uint8Array +const u8fr = (arr) => Uint8Array.from(arr); // another shortcut +/** + * Minimal HMAC-DRBG from NIST 800-90 for RFC6979 sigs. + * @returns function that will call DRBG until 2nd arg returns something meaningful + * @example + * const drbg = createHmacDRBG(32, 32, hmac); + * drbg(seed, bytesToKey); // bytesToKey must return Key or undefined + */ +function createHmacDrbg(hashLen, qByteLen, hmacFn) { + if (typeof hashLen !== 'number' || hashLen < 2) + throw new Error('hashLen must be a number'); + if (typeof qByteLen !== 'number' || qByteLen < 2) + throw new Error('qByteLen must be a number'); + if (typeof hmacFn !== 'function') + throw new Error('hmacFn must be a function'); + // Step B, Step C: set hashLen to 8*ceil(hlen/8) + let v = u8n(hashLen); // Minimal non-full-spec HMAC-DRBG from NIST 800-90 for RFC6979 sigs. + let k = u8n(hashLen); // Steps B and C of RFC6979 3.2: set hashLen, in our case always same + let i = 0; // Iterations counter, will throw when over 1000 + const reset = () => { + v.fill(1); + k.fill(0); + i = 0; + }; + const h = (...b) => hmacFn(k, v, ...b); // hmac(k)(v, ...values) + const reseed = (seed = u8n()) => { + // HMAC-DRBG reseed() function. Steps D-G + k = h(u8fr([0x00]), seed); // k = hmac(k || v || 0x00 || seed) + v = h(); // v = hmac(k || v) + if (seed.length === 0) + return; + k = h(u8fr([0x01]), seed); // k = hmac(k || v || 0x01 || seed) + v = h(); // v = hmac(k || v) + }; + const gen = () => { + // HMAC-DRBG generate() function + if (i++ >= 1000) + throw new Error('drbg: tried 1000 values'); + let len = 0; + const out = []; + while (len < qByteLen) { + v = h(); + const sl = v.slice(); + out.push(sl); + len += v.length; + } + return concatBytes(...out); + }; + const genUntil = (seed, pred) => { + reset(); + reseed(seed); // Steps D-G + let res = undefined; // Step H: grind until k is in [1..n-1] + while (!(res = pred(gen()))) + reseed(); + reset(); + return res; + }; + return genUntil; +} +// Validating curves and fields +const validatorFns = { + bigint: (val) => typeof val === 'bigint', + function: (val) => typeof val === 'function', + boolean: (val) => typeof val === 'boolean', + string: (val) => typeof val === 'string', + stringOrUint8Array: (val) => typeof val === 'string' || val instanceof Uint8Array, + isSafeInteger: (val) => Number.isSafeInteger(val), + array: (val) => Array.isArray(val), + field: (val, object) => object.Fp.isValid(val), + hash: (val) => typeof val === 'function' && Number.isSafeInteger(val.outputLen), +}; +// type Record = { [P in K]: T; } +function validateObject(object, validators, optValidators = {}) { + const checkField = (fieldName, type, isOptional) => { + const checkVal = validatorFns[type]; + if (typeof checkVal !== 'function') + throw new Error(`Invalid validator "${type}", expected function`); + const val = object[fieldName]; + if (isOptional && val === undefined) + return; + if (!checkVal(val, object)) { + throw new Error(`Invalid param ${String(fieldName)}=${val} (${typeof val}), expected ${type}`); + } + }; + for (const [fieldName, type] of Object.entries(validators)) + checkField(fieldName, type, false); + for (const [fieldName, type] of Object.entries(optValidators)) + checkField(fieldName, type, true); + return object; +} +// validate type tests +// const o: { a: number; b: number; c: number } = { a: 1, b: 5, c: 6 }; +// const z0 = validateObject(o, { a: 'isSafeInteger' }, { c: 'bigint' }); // Ok! +// // Should fail type-check +// const z1 = validateObject(o, { a: 'tmp' }, { c: 'zz' }); +// const z2 = validateObject(o, { a: 'isSafeInteger' }, { c: 'zz' }); +// const z3 = validateObject(o, { test: 'boolean', z: 'bug' }); +// const z4 = validateObject(o, { a: 'boolean', z: 'bug' }); + +var ut = /*#__PURE__*/Object.freeze({ + __proto__: null, + bitGet: bitGet, + bitLen: bitLen, + bitMask: bitMask, + bitSet: bitSet, + bytesToHex: bytesToHex$1, + bytesToNumberBE: bytesToNumberBE, + bytesToNumberLE: bytesToNumberLE, + concatBytes: concatBytes, + createHmacDrbg: createHmacDrbg, + ensureBytes: ensureBytes, + equalBytes: equalBytes, + hexToBytes: hexToBytes, + hexToNumber: hexToNumber, + numberToBytesBE: numberToBytesBE, + numberToBytesLE: numberToBytesLE, + numberToHexUnpadded: numberToHexUnpadded, + numberToVarBytesBE: numberToVarBytesBE, + utf8ToBytes: utf8ToBytes, + validateObject: validateObject +}); + +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +// Utilities for modular arithmetics and finite fields +// prettier-ignore +const _0n$2 = BigInt(0), _1n$3 = BigInt(1), _2n$1 = BigInt(2), _3n$1 = BigInt(3); +// prettier-ignore +const _4n = BigInt(4), _5n = BigInt(5), _8n = BigInt(8); +// prettier-ignore +BigInt(9); BigInt(16); +// Calculates a modulo b +function mod$3(a, b) { + const result = a % b; + return result >= _0n$2 ? result : b + result; +} +/** + * Efficiently raise num to power and do modular division. + * Unsafe in some contexts: uses ladder, so can expose bigint bits. + * @example + * pow(2n, 6n, 11n) // 64n % 11n == 9n + */ +// TODO: use field version && remove +function pow$3(num, power, modulo) { + if (modulo <= _0n$2 || power < _0n$2) + throw new Error('Expected power/modulo > 0'); + if (modulo === _1n$3) + return _0n$2; + let res = _1n$3; + while (power > _0n$2) { + if (power & _1n$3) + res = (res * num) % modulo; + num = (num * num) % modulo; + power >>= _1n$3; + } + return res; +} +// Does x ^ (2 ^ power) mod p. pow2(30, 4) == 30 ^ (2 ^ 4) +function pow2(x, power, modulo) { + let res = x; + while (power-- > _0n$2) { + res *= res; + res %= modulo; + } + return res; +} +// Inverses number over modulo +function invert(number, modulo) { + if (number === _0n$2 || modulo <= _0n$2) { + throw new Error(`invert: expected positive integers, got n=${number} mod=${modulo}`); + } + // Euclidean GCD https://brilliant.org/wiki/extended-euclidean-algorithm/ + // Fermat's little theorem "CT-like" version inv(n) = n^(m-2) mod m is 30x slower. + let a = mod$3(number, modulo); + let b = modulo; + // prettier-ignore + let x = _0n$2, u = _1n$3; + while (a !== _0n$2) { + // JIT applies optimization if those two lines follow each other + const q = b / a; + const r = b % a; + const m = x - u * q; + // prettier-ignore + b = a, a = r, x = u, u = m; + } + const gcd = b; + if (gcd !== _1n$3) + throw new Error('invert: does not exist'); + return mod$3(x, modulo); +} +/** + * Tonelli-Shanks square root search algorithm. + * 1. https://eprint.iacr.org/2012/685.pdf (page 12) + * 2. Square Roots from 1; 24, 51, 10 to Dan Shanks + * Will start an infinite loop if field order P is not prime. + * @param P field order + * @returns function that takes field Fp (created from P) and number n + */ +function tonelliShanks(P) { + // Legendre constant: used to calculate Legendre symbol (a | p), + // which denotes the value of a^((p-1)/2) (mod p). + // (a | p) ≡ 1 if a is a square (mod p) + // (a | p) ≡ -1 if a is not a square (mod p) + // (a | p) ≡ 0 if a ≡ 0 (mod p) + const legendreC = (P - _1n$3) / _2n$1; + let Q, S, Z; + // Step 1: By factoring out powers of 2 from p - 1, + // find q and s such that p - 1 = q*(2^s) with q odd + for (Q = P - _1n$3, S = 0; Q % _2n$1 === _0n$2; Q /= _2n$1, S++) + ; + // Step 2: Select a non-square z such that (z | p) ≡ -1 and set c ≡ zq + for (Z = _2n$1; Z < P && pow$3(Z, legendreC, P) !== P - _1n$3; Z++) + ; + // Fast-path + if (S === 1) { + const p1div4 = (P + _1n$3) / _4n; + return function tonelliFast(Fp, n) { + const root = Fp.pow(n, p1div4); + if (!Fp.eql(Fp.sqr(root), n)) + throw new Error('Cannot find square root'); + return root; + }; + } + // Slow-path + const Q1div2 = (Q + _1n$3) / _2n$1; + return function tonelliSlow(Fp, n) { + // Step 0: Check that n is indeed a square: (n | p) should not be ≡ -1 + if (Fp.pow(n, legendreC) === Fp.neg(Fp.ONE)) + throw new Error('Cannot find square root'); + let r = S; + // TODO: will fail at Fp2/etc + let g = Fp.pow(Fp.mul(Fp.ONE, Z), Q); // will update both x and b + let x = Fp.pow(n, Q1div2); // first guess at the square root + let b = Fp.pow(n, Q); // first guess at the fudge factor + while (!Fp.eql(b, Fp.ONE)) { + if (Fp.eql(b, Fp.ZERO)) + return Fp.ZERO; // https://en.wikipedia.org/wiki/Tonelli%E2%80%93Shanks_algorithm (4. If t = 0, return r = 0) + // Find m such b^(2^m)==1 + let m = 1; + for (let t2 = Fp.sqr(b); m < r; m++) { + if (Fp.eql(t2, Fp.ONE)) + break; + t2 = Fp.sqr(t2); // t2 *= t2 + } + // NOTE: r-m-1 can be bigger than 32, need to convert to bigint before shift, otherwise there will be overflow + const ge = Fp.pow(g, _1n$3 << BigInt(r - m - 1)); // ge = 2^(r-m-1) + g = Fp.sqr(ge); // g = ge * ge + x = Fp.mul(x, ge); // x *= ge + b = Fp.mul(b, g); // b *= g + r = m; + } + return x; + }; +} +function FpSqrt(P) { + // NOTE: different algorithms can give different roots, it is up to user to decide which one they want. + // For example there is FpSqrtOdd/FpSqrtEven to choice root based on oddness (used for hash-to-curve). + // P ≡ 3 (mod 4) + // √n = n^((P+1)/4) + if (P % _4n === _3n$1) { + // Not all roots possible! + // const ORDER = + // 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn; + // const NUM = 72057594037927816n; + const p1div4 = (P + _1n$3) / _4n; + return function sqrt3mod4(Fp, n) { + const root = Fp.pow(n, p1div4); + // Throw if root**2 != n + if (!Fp.eql(Fp.sqr(root), n)) + throw new Error('Cannot find square root'); + return root; + }; + } + // Atkin algorithm for q ≡ 5 (mod 8), https://eprint.iacr.org/2012/685.pdf (page 10) + if (P % _8n === _5n) { + const c1 = (P - _5n) / _8n; + return function sqrt5mod8(Fp, n) { + const n2 = Fp.mul(n, _2n$1); + const v = Fp.pow(n2, c1); + const nv = Fp.mul(n, v); + const i = Fp.mul(Fp.mul(nv, _2n$1), v); + const root = Fp.mul(nv, Fp.sub(i, Fp.ONE)); + if (!Fp.eql(Fp.sqr(root), n)) + throw new Error('Cannot find square root'); + return root; + }; + } + // Other cases: Tonelli-Shanks algorithm + return tonelliShanks(P); +} +// prettier-ignore +const FIELD_FIELDS = [ + 'create', 'isValid', 'is0', 'neg', 'inv', 'sqrt', 'sqr', + 'eql', 'add', 'sub', 'mul', 'pow', 'div', + 'addN', 'subN', 'mulN', 'sqrN' +]; +function validateField(field) { + const initial = { + ORDER: 'bigint', + MASK: 'bigint', + BYTES: 'isSafeInteger', + BITS: 'isSafeInteger', + }; + const opts = FIELD_FIELDS.reduce((map, val) => { + map[val] = 'function'; + return map; + }, initial); + return validateObject(field, opts); +} +// Generic field functions +/** + * Same as `pow` but for Fp: non-constant-time. + * Unsafe in some contexts: uses ladder, so can expose bigint bits. + */ +function FpPow(f, num, power) { + // Should have same speed as pow for bigints + // TODO: benchmark! + if (power < _0n$2) + throw new Error('Expected power > 0'); + if (power === _0n$2) + return f.ONE; + if (power === _1n$3) + return num; + let p = f.ONE; + let d = num; + while (power > _0n$2) { + if (power & _1n$3) + p = f.mul(p, d); + d = f.sqr(d); + power >>= _1n$3; + } + return p; +} +/** + * Efficiently invert an array of Field elements. + * `inv(0)` will return `undefined` here: make sure to throw an error. + */ +function FpInvertBatch(f, nums) { + const tmp = new Array(nums.length); + // Walk from first to last, multiply them by each other MOD p + const lastMultiplied = nums.reduce((acc, num, i) => { + if (f.is0(num)) + return acc; + tmp[i] = acc; + return f.mul(acc, num); + }, f.ONE); + // Invert last element + const inverted = f.inv(lastMultiplied); + // Walk from last to first, multiply them by inverted each other MOD p + nums.reduceRight((acc, num, i) => { + if (f.is0(num)) + return acc; + tmp[i] = f.mul(acc, tmp[i]); + return f.mul(acc, num); + }, inverted); + return tmp; +} +// CURVE.n lengths +function nLength(n, nBitLength) { + // Bit size, byte size of CURVE.n + const _nBitLength = nBitLength !== undefined ? nBitLength : n.toString(2).length; + const nByteLength = Math.ceil(_nBitLength / 8); + return { nBitLength: _nBitLength, nByteLength }; +} +/** + * Initializes a finite field over prime. **Non-primes are not supported.** + * Do not init in loop: slow. Very fragile: always run a benchmark on a change. + * Major performance optimizations: + * * a) denormalized operations like mulN instead of mul + * * b) same object shape: never add or remove keys + * * c) Object.freeze + * @param ORDER prime positive bigint + * @param bitLen how many bits the field consumes + * @param isLE (def: false) if encoding / decoding should be in little-endian + * @param redef optional faster redefinitions of sqrt and other methods + */ +function Field(ORDER, bitLen, isLE = false, redef = {}) { + if (ORDER <= _0n$2) + throw new Error(`Expected Field ORDER > 0, got ${ORDER}`); + const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen); + if (BYTES > 2048) + throw new Error('Field lengths over 2048 bytes are not supported'); + const sqrtP = FpSqrt(ORDER); + const f = Object.freeze({ + ORDER, + BITS, + BYTES, + MASK: bitMask(BITS), + ZERO: _0n$2, + ONE: _1n$3, + create: (num) => mod$3(num, ORDER), + isValid: (num) => { + if (typeof num !== 'bigint') + throw new Error(`Invalid field element: expected bigint, got ${typeof num}`); + return _0n$2 <= num && num < ORDER; // 0 is valid element, but it's not invertible + }, + is0: (num) => num === _0n$2, + isOdd: (num) => (num & _1n$3) === _1n$3, + neg: (num) => mod$3(-num, ORDER), + eql: (lhs, rhs) => lhs === rhs, + sqr: (num) => mod$3(num * num, ORDER), + add: (lhs, rhs) => mod$3(lhs + rhs, ORDER), + sub: (lhs, rhs) => mod$3(lhs - rhs, ORDER), + mul: (lhs, rhs) => mod$3(lhs * rhs, ORDER), + pow: (num, power) => FpPow(f, num, power), + div: (lhs, rhs) => mod$3(lhs * invert(rhs, ORDER), ORDER), + // Same as above, but doesn't normalize + sqrN: (num) => num * num, + addN: (lhs, rhs) => lhs + rhs, + subN: (lhs, rhs) => lhs - rhs, + mulN: (lhs, rhs) => lhs * rhs, + inv: (num) => invert(num, ORDER), + sqrt: redef.sqrt || ((n) => sqrtP(f, n)), + invertBatch: (lst) => FpInvertBatch(f, lst), + // TODO: do we really need constant cmov? + // We don't have const-time bigints anyway, so probably will be not very useful + cmov: (a, b, c) => (c ? b : a), + toBytes: (num) => (isLE ? numberToBytesLE(num, BYTES) : numberToBytesBE(num, BYTES)), + fromBytes: (bytes) => { + if (bytes.length !== BYTES) + throw new Error(`Fp.fromBytes: expected ${BYTES}, got ${bytes.length}`); + return isLE ? bytesToNumberLE(bytes) : bytesToNumberBE(bytes); + }, + }); + return Object.freeze(f); +} +/** + * Returns total number of bytes consumed by the field element. + * For example, 32 bytes for usual 256-bit weierstrass curve. + * @param fieldOrder number of field elements, usually CURVE.n + * @returns byte length of field + */ +function getFieldBytesLength(fieldOrder) { + if (typeof fieldOrder !== 'bigint') + throw new Error('field order must be bigint'); + const bitLength = fieldOrder.toString(2).length; + return Math.ceil(bitLength / 8); +} +/** + * Returns minimal amount of bytes that can be safely reduced + * by field order. + * Should be 2^-128 for 128-bit curve such as P256. + * @param fieldOrder number of field elements, usually CURVE.n + * @returns byte length of target hash + */ +function getMinHashLength(fieldOrder) { + const length = getFieldBytesLength(fieldOrder); + return length + Math.ceil(length / 2); +} +/** + * "Constant-time" private key generation utility. + * Can take (n + n/2) or more bytes of uniform input e.g. from CSPRNG or KDF + * and convert them into private scalar, with the modulo bias being negligible. + * Needs at least 48 bytes of input for 32-byte private key. + * https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/ + * FIPS 186-5, A.2 https://csrc.nist.gov/publications/detail/fips/186/5/final + * RFC 9380, https://www.rfc-editor.org/rfc/rfc9380#section-5 + * @param hash hash output from SHA3 or a similar function + * @param groupOrder size of subgroup - (e.g. secp256k1.CURVE.n) + * @param isLE interpret hash bytes as LE num + * @returns valid private scalar + */ +function mapHashToField(key, fieldOrder, isLE = false) { + const len = key.length; + const fieldLen = getFieldBytesLength(fieldOrder); + const minLen = getMinHashLength(fieldOrder); + // No small numbers: need to understand bias story. No huge numbers: easier to detect JS timings. + if (len < 16 || len < minLen || len > 1024) + throw new Error(`expected ${minLen}-1024 bytes of input, got ${len}`); + const num = isLE ? bytesToNumberBE(key) : bytesToNumberLE(key); + // `mod(x, 11)` can sometimes produce 0. `mod(x, 10) + 1` is the same, but no 0 + const reduced = mod$3(num, fieldOrder - _1n$3) + _1n$3; + return isLE ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen); +} + +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +// Abelian group utilities +const _0n$1 = BigInt(0); +const _1n$2 = BigInt(1); +// Elliptic curve multiplication of Point by scalar. Fragile. +// Scalars should always be less than curve order: this should be checked inside of a curve itself. +// Creates precomputation tables for fast multiplication: +// - private scalar is split by fixed size windows of W bits +// - every window point is collected from window's table & added to accumulator +// - since windows are different, same point inside tables won't be accessed more than once per calc +// - each multiplication is 'Math.ceil(CURVE_ORDER / 𝑊) + 1' point additions (fixed for any scalar) +// - +1 window is neccessary for wNAF +// - wNAF reduces table size: 2x less memory + 2x faster generation, but 10% slower multiplication +// TODO: Research returning 2d JS array of windows, instead of a single window. This would allow +// windows to be in different memory locations +function wNAF(c, bits) { + const constTimeNegate = (condition, item) => { + const neg = item.negate(); + return condition ? neg : item; + }; + const opts = (W) => { + const windows = Math.ceil(bits / W) + 1; // +1, because + const windowSize = 2 ** (W - 1); // -1 because we skip zero + return { windows, windowSize }; + }; + return { + constTimeNegate, + // non-const time multiplication ladder + unsafeLadder(elm, n) { + let p = c.ZERO; + let d = elm; + while (n > _0n$1) { + if (n & _1n$2) + p = p.add(d); + d = d.double(); + n >>= _1n$2; + } + return p; + }, + /** + * Creates a wNAF precomputation window. Used for caching. + * Default window size is set by `utils.precompute()` and is equal to 8. + * Number of precomputed points depends on the curve size: + * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where: + * - 𝑊 is the window size + * - 𝑛 is the bitlength of the curve order. + * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224. + * @returns precomputed point tables flattened to a single array + */ + precomputeWindow(elm, W) { + const { windows, windowSize } = opts(W); + const points = []; + let p = elm; + let base = p; + for (let window = 0; window < windows; window++) { + base = p; + points.push(base); + // =1, because we skip zero + for (let i = 1; i < windowSize; i++) { + base = base.add(p); + points.push(base); + } + p = base.double(); + } + return points; + }, + /** + * Implements ec multiplication using precomputed tables and w-ary non-adjacent form. + * @param W window size + * @param precomputes precomputed tables + * @param n scalar (we don't check here, but should be less than curve order) + * @returns real and fake (for const-time) points + */ + wNAF(W, precomputes, n) { + // TODO: maybe check that scalar is less than group order? wNAF behavious is undefined otherwise + // But need to carefully remove other checks before wNAF. ORDER == bits here + const { windows, windowSize } = opts(W); + let p = c.ZERO; + let f = c.BASE; + const mask = BigInt(2 ** W - 1); // Create mask with W ones: 0b1111 for W=4 etc. + const maxNumber = 2 ** W; + const shiftBy = BigInt(W); + for (let window = 0; window < windows; window++) { + const offset = window * windowSize; + // Extract W bits. + let wbits = Number(n & mask); + // Shift number by W bits. + n >>= shiftBy; + // If the bits are bigger than max size, we'll split those. + // +224 => 256 - 32 + if (wbits > windowSize) { + wbits -= maxNumber; + n += _1n$2; + } + // This code was first written with assumption that 'f' and 'p' will never be infinity point: + // since each addition is multiplied by 2 ** W, it cannot cancel each other. However, + // there is negate now: it is possible that negated element from low value + // would be the same as high element, which will create carry into next window. + // It's not obvious how this can fail, but still worth investigating later. + // Check if we're onto Zero point. + // Add random point inside current window to f. + const offset1 = offset; + const offset2 = offset + Math.abs(wbits) - 1; // -1 because we skip zero + const cond1 = window % 2 !== 0; + const cond2 = wbits < 0; + if (wbits === 0) { + // The most important part for const-time getPublicKey + f = f.add(constTimeNegate(cond1, precomputes[offset1])); + } + else { + p = p.add(constTimeNegate(cond2, precomputes[offset2])); + } + } + // JIT-compiler should not eliminate f here, since it will later be used in normalizeZ() + // Even if the variable is still unused, there are some checks which will + // throw an exception, so compiler needs to prove they won't happen, which is hard. + // At this point there is a way to F be infinity-point even if p is not, + // which makes it less const-time: around 1 bigint multiply. + return { p, f }; + }, + wNAFCached(P, precomputesMap, n, transform) { + // @ts-ignore + const W = P._WINDOW_SIZE || 1; + // Calculate precomputes on a first run, reuse them after + let comp = precomputesMap.get(P); + if (!comp) { + comp = this.precomputeWindow(P, W); + if (W !== 1) { + precomputesMap.set(P, transform(comp)); + } + } + return this.wNAF(W, comp, n); + }, + }; +} +function validateBasic(curve) { + validateField(curve.Fp); + validateObject(curve, { + n: 'bigint', + h: 'bigint', + Gx: 'field', + Gy: 'field', + }, { + nBitLength: 'isSafeInteger', + nByteLength: 'isSafeInteger', + }); + // Set defaults + return Object.freeze({ + ...nLength(curve.n, curve.nBitLength), + ...curve, + ...{ p: curve.Fp.ORDER }, + }); +} + +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +// Short Weierstrass curve. The formula is: y² = x³ + ax + b +function validatePointOpts(curve) { + const opts = validateBasic(curve); + validateObject(opts, { + a: 'field', + b: 'field', + }, { + allowedPrivateKeyLengths: 'array', + wrapPrivateKey: 'boolean', + isTorsionFree: 'function', + clearCofactor: 'function', + allowInfinityPoint: 'boolean', + fromBytes: 'function', + toBytes: 'function', + }); + const { endo, Fp, a } = opts; + if (endo) { + if (!Fp.eql(a, Fp.ZERO)) { + throw new Error('Endomorphism can only be defined for Koblitz curves that have a=0'); + } + if (typeof endo !== 'object' || + typeof endo.beta !== 'bigint' || + typeof endo.splitScalar !== 'function') { + throw new Error('Expected endomorphism with beta: bigint and splitScalar: function'); + } + } + return Object.freeze({ ...opts }); +} +// ASN.1 DER encoding utilities +const { bytesToNumberBE: b2n, hexToBytes: h2b } = ut; +const DER = { + // asn.1 DER encoding utils + Err: class DERErr extends Error { + constructor(m = '') { + super(m); + } + }, + _parseInt(data) { + const { Err: E } = DER; + if (data.length < 2 || data[0] !== 0x02) + throw new E('Invalid signature integer tag'); + const len = data[1]; + const res = data.subarray(2, len + 2); + if (!len || res.length !== len) + throw new E('Invalid signature integer: wrong length'); + // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag, + // since we always use positive integers here. It must always be empty: + // - add zero byte if exists + // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding) + if (res[0] & 0b10000000) + throw new E('Invalid signature integer: negative'); + if (res[0] === 0x00 && !(res[1] & 0b10000000)) + throw new E('Invalid signature integer: unnecessary leading zero'); + return { d: b2n(res), l: data.subarray(len + 2) }; // d is data, l is left + }, + toSig(hex) { + // parse DER signature + const { Err: E } = DER; + const data = typeof hex === 'string' ? h2b(hex) : hex; + if (!(data instanceof Uint8Array)) + throw new Error('ui8a expected'); + let l = data.length; + if (l < 2 || data[0] != 0x30) + throw new E('Invalid signature tag'); + if (data[1] !== l - 2) + throw new E('Invalid signature: incorrect length'); + const { d: r, l: sBytes } = DER._parseInt(data.subarray(2)); + const { d: s, l: rBytesLeft } = DER._parseInt(sBytes); + if (rBytesLeft.length) + throw new E('Invalid signature: left bytes after parsing'); + return { r, s }; + }, + hexFromSig(sig) { + // Add leading zero if first byte has negative bit enabled. More details in '_parseInt' + const slice = (s) => (Number.parseInt(s[0], 16) & 0b1000 ? '00' + s : s); + const h = (num) => { + const hex = num.toString(16); + return hex.length & 1 ? `0${hex}` : hex; + }; + const s = slice(h(sig.s)); + const r = slice(h(sig.r)); + const shl = s.length / 2; + const rhl = r.length / 2; + const sl = h(shl); + const rl = h(rhl); + return `30${h(rhl + shl + 4)}02${rl}${r}02${sl}${s}`; + }, +}; +// Be friendly to bad ECMAScript parsers by not using bigint literals +// prettier-ignore +const _0n = BigInt(0), _1n$1 = BigInt(1); BigInt(2); const _3n = BigInt(3); BigInt(4); +function weierstrassPoints(opts) { + const CURVE = validatePointOpts(opts); + const { Fp } = CURVE; // All curves has same field / group length as for now, but they can differ + const toBytes = CURVE.toBytes || + ((_c, point, _isCompressed) => { + const a = point.toAffine(); + return concatBytes(Uint8Array.from([0x04]), Fp.toBytes(a.x), Fp.toBytes(a.y)); + }); + const fromBytes = CURVE.fromBytes || + ((bytes) => { + // const head = bytes[0]; + const tail = bytes.subarray(1); + // if (head !== 0x04) throw new Error('Only non-compressed encoding is supported'); + const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES)); + const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES)); + return { x, y }; + }); + /** + * y² = x³ + ax + b: Short weierstrass curve formula + * @returns y² + */ + function weierstrassEquation(x) { + const { a, b } = CURVE; + const x2 = Fp.sqr(x); // x * x + const x3 = Fp.mul(x2, x); // x2 * x + return Fp.add(Fp.add(x3, Fp.mul(x, a)), b); // x3 + a * x + b + } + // Validate whether the passed curve params are valid. + // We check if curve equation works for generator point. + // `assertValidity()` won't work: `isTorsionFree()` is not available at this point in bls12-381. + // ProjectivePoint class has not been initialized yet. + if (!Fp.eql(Fp.sqr(CURVE.Gy), weierstrassEquation(CURVE.Gx))) + throw new Error('bad generator point: equation left != right'); + // Valid group elements reside in range 1..n-1 + function isWithinCurveOrder(num) { + return typeof num === 'bigint' && _0n < num && num < CURVE.n; + } + function assertGE(num) { + if (!isWithinCurveOrder(num)) + throw new Error('Expected valid bigint: 0 < bigint < curve.n'); + } + // Validates if priv key is valid and converts it to bigint. + // Supports options allowedPrivateKeyLengths and wrapPrivateKey. + function normPrivateKeyToScalar(key) { + const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n } = CURVE; + if (lengths && typeof key !== 'bigint') { + if (key instanceof Uint8Array) + key = bytesToHex$1(key); + // Normalize to hex string, pad. E.g. P521 would norm 130-132 char hex to 132-char bytes + if (typeof key !== 'string' || !lengths.includes(key.length)) + throw new Error('Invalid key'); + key = key.padStart(nByteLength * 2, '0'); + } + let num; + try { + num = + typeof key === 'bigint' + ? key + : bytesToNumberBE(ensureBytes('private key', key, nByteLength)); + } + catch (error) { + throw new Error(`private key must be ${nByteLength} bytes, hex or bigint, not ${typeof key}`); + } + if (wrapPrivateKey) + num = mod$3(num, n); // disabled by default, enabled for BLS + assertGE(num); // num in range [1..N-1] + return num; + } + const pointPrecomputes = new Map(); + function assertPrjPoint(other) { + if (!(other instanceof Point)) + throw new Error('ProjectivePoint expected'); + } + /** + * Projective Point works in 3d / projective (homogeneous) coordinates: (x, y, z) ∋ (x=x/z, y=y/z) + * Default Point works in 2d / affine coordinates: (x, y) + * We're doing calculations in projective, because its operations don't require costly inversion. + */ + class Point { + constructor(px, py, pz) { + this.px = px; + this.py = py; + this.pz = pz; + if (px == null || !Fp.isValid(px)) + throw new Error('x required'); + if (py == null || !Fp.isValid(py)) + throw new Error('y required'); + if (pz == null || !Fp.isValid(pz)) + throw new Error('z required'); + } + // Does not validate if the point is on-curve. + // Use fromHex instead, or call assertValidity() later. + static fromAffine(p) { + const { x, y } = p || {}; + if (!p || !Fp.isValid(x) || !Fp.isValid(y)) + throw new Error('invalid affine point'); + if (p instanceof Point) + throw new Error('projective point not allowed'); + const is0 = (i) => Fp.eql(i, Fp.ZERO); + // fromAffine(x:0, y:0) would produce (x:0, y:0, z:1), but we need (x:0, y:1, z:0) + if (is0(x) && is0(y)) + return Point.ZERO; + return new Point(x, y, Fp.ONE); + } + get x() { + return this.toAffine().x; + } + get y() { + return this.toAffine().y; + } + /** + * Takes a bunch of Projective Points but executes only one + * inversion on all of them. Inversion is very slow operation, + * so this improves performance massively. + * Optimization: converts a list of projective points to a list of identical points with Z=1. + */ + static normalizeZ(points) { + const toInv = Fp.invertBatch(points.map((p) => p.pz)); + return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine); + } + /** + * Converts hash string or Uint8Array to Point. + * @param hex short/long ECDSA hex + */ + static fromHex(hex) { + const P = Point.fromAffine(fromBytes(ensureBytes('pointHex', hex))); + P.assertValidity(); + return P; + } + // Multiplies generator point by privateKey. + static fromPrivateKey(privateKey) { + return Point.BASE.multiply(normPrivateKeyToScalar(privateKey)); + } + // "Private method", don't use it directly + _setWindowSize(windowSize) { + this._WINDOW_SIZE = windowSize; + pointPrecomputes.delete(this); + } + // A point on curve is valid if it conforms to equation. + assertValidity() { + if (this.is0()) { + // (0, 1, 0) aka ZERO is invalid in most contexts. + // In BLS, ZERO can be serialized, so we allow it. + // (0, 0, 0) is wrong representation of ZERO and is always invalid. + if (CURVE.allowInfinityPoint && !Fp.is0(this.py)) + return; + throw new Error('bad point: ZERO'); + } + // Some 3rd-party test vectors require different wording between here & `fromCompressedHex` + const { x, y } = this.toAffine(); + // Check if x, y are valid field elements + if (!Fp.isValid(x) || !Fp.isValid(y)) + throw new Error('bad point: x or y not FE'); + const left = Fp.sqr(y); // y² + const right = weierstrassEquation(x); // x³ + ax + b + if (!Fp.eql(left, right)) + throw new Error('bad point: equation left != right'); + if (!this.isTorsionFree()) + throw new Error('bad point: not in prime-order subgroup'); + } + hasEvenY() { + const { y } = this.toAffine(); + if (Fp.isOdd) + return !Fp.isOdd(y); + throw new Error("Field doesn't support isOdd"); + } + /** + * Compare one point to another. + */ + equals(other) { + assertPrjPoint(other); + const { px: X1, py: Y1, pz: Z1 } = this; + const { px: X2, py: Y2, pz: Z2 } = other; + const U1 = Fp.eql(Fp.mul(X1, Z2), Fp.mul(X2, Z1)); + const U2 = Fp.eql(Fp.mul(Y1, Z2), Fp.mul(Y2, Z1)); + return U1 && U2; + } + /** + * Flips point to one corresponding to (x, -y) in Affine coordinates. + */ + negate() { + return new Point(this.px, Fp.neg(this.py), this.pz); + } + // Renes-Costello-Batina exception-free doubling formula. + // There is 30% faster Jacobian formula, but it is not complete. + // https://eprint.iacr.org/2015/1060, algorithm 3 + // Cost: 8M + 3S + 3*a + 2*b3 + 15add. + double() { + const { a, b } = CURVE; + const b3 = Fp.mul(b, _3n); + const { px: X1, py: Y1, pz: Z1 } = this; + let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO; // prettier-ignore + let t0 = Fp.mul(X1, X1); // step 1 + let t1 = Fp.mul(Y1, Y1); + let t2 = Fp.mul(Z1, Z1); + let t3 = Fp.mul(X1, Y1); + t3 = Fp.add(t3, t3); // step 5 + Z3 = Fp.mul(X1, Z1); + Z3 = Fp.add(Z3, Z3); + X3 = Fp.mul(a, Z3); + Y3 = Fp.mul(b3, t2); + Y3 = Fp.add(X3, Y3); // step 10 + X3 = Fp.sub(t1, Y3); + Y3 = Fp.add(t1, Y3); + Y3 = Fp.mul(X3, Y3); + X3 = Fp.mul(t3, X3); + Z3 = Fp.mul(b3, Z3); // step 15 + t2 = Fp.mul(a, t2); + t3 = Fp.sub(t0, t2); + t3 = Fp.mul(a, t3); + t3 = Fp.add(t3, Z3); + Z3 = Fp.add(t0, t0); // step 20 + t0 = Fp.add(Z3, t0); + t0 = Fp.add(t0, t2); + t0 = Fp.mul(t0, t3); + Y3 = Fp.add(Y3, t0); + t2 = Fp.mul(Y1, Z1); // step 25 + t2 = Fp.add(t2, t2); + t0 = Fp.mul(t2, t3); + X3 = Fp.sub(X3, t0); + Z3 = Fp.mul(t2, t1); + Z3 = Fp.add(Z3, Z3); // step 30 + Z3 = Fp.add(Z3, Z3); + return new Point(X3, Y3, Z3); + } + // Renes-Costello-Batina exception-free addition formula. + // There is 30% faster Jacobian formula, but it is not complete. + // https://eprint.iacr.org/2015/1060, algorithm 1 + // Cost: 12M + 0S + 3*a + 3*b3 + 23add. + add(other) { + assertPrjPoint(other); + const { px: X1, py: Y1, pz: Z1 } = this; + const { px: X2, py: Y2, pz: Z2 } = other; + let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO; // prettier-ignore + const a = CURVE.a; + const b3 = Fp.mul(CURVE.b, _3n); + let t0 = Fp.mul(X1, X2); // step 1 + let t1 = Fp.mul(Y1, Y2); + let t2 = Fp.mul(Z1, Z2); + let t3 = Fp.add(X1, Y1); + let t4 = Fp.add(X2, Y2); // step 5 + t3 = Fp.mul(t3, t4); + t4 = Fp.add(t0, t1); + t3 = Fp.sub(t3, t4); + t4 = Fp.add(X1, Z1); + let t5 = Fp.add(X2, Z2); // step 10 + t4 = Fp.mul(t4, t5); + t5 = Fp.add(t0, t2); + t4 = Fp.sub(t4, t5); + t5 = Fp.add(Y1, Z1); + X3 = Fp.add(Y2, Z2); // step 15 + t5 = Fp.mul(t5, X3); + X3 = Fp.add(t1, t2); + t5 = Fp.sub(t5, X3); + Z3 = Fp.mul(a, t4); + X3 = Fp.mul(b3, t2); // step 20 + Z3 = Fp.add(X3, Z3); + X3 = Fp.sub(t1, Z3); + Z3 = Fp.add(t1, Z3); + Y3 = Fp.mul(X3, Z3); + t1 = Fp.add(t0, t0); // step 25 + t1 = Fp.add(t1, t0); + t2 = Fp.mul(a, t2); + t4 = Fp.mul(b3, t4); + t1 = Fp.add(t1, t2); + t2 = Fp.sub(t0, t2); // step 30 + t2 = Fp.mul(a, t2); + t4 = Fp.add(t4, t2); + t0 = Fp.mul(t1, t4); + Y3 = Fp.add(Y3, t0); + t0 = Fp.mul(t5, t4); // step 35 + X3 = Fp.mul(t3, X3); + X3 = Fp.sub(X3, t0); + t0 = Fp.mul(t3, t1); + Z3 = Fp.mul(t5, Z3); + Z3 = Fp.add(Z3, t0); // step 40 + return new Point(X3, Y3, Z3); + } + subtract(other) { + return this.add(other.negate()); + } + is0() { + return this.equals(Point.ZERO); + } + wNAF(n) { + return wnaf.wNAFCached(this, pointPrecomputes, n, (comp) => { + const toInv = Fp.invertBatch(comp.map((p) => p.pz)); + return comp.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine); + }); + } + /** + * Non-constant-time multiplication. Uses double-and-add algorithm. + * It's faster, but should only be used when you don't care about + * an exposed private key e.g. sig verification, which works over *public* keys. + */ + multiplyUnsafe(n) { + const I = Point.ZERO; + if (n === _0n) + return I; + assertGE(n); // Will throw on 0 + if (n === _1n$1) + return this; + const { endo } = CURVE; + if (!endo) + return wnaf.unsafeLadder(this, n); + // Apply endomorphism + let { k1neg, k1, k2neg, k2 } = endo.splitScalar(n); + let k1p = I; + let k2p = I; + let d = this; + while (k1 > _0n || k2 > _0n) { + if (k1 & _1n$1) + k1p = k1p.add(d); + if (k2 & _1n$1) + k2p = k2p.add(d); + d = d.double(); + k1 >>= _1n$1; + k2 >>= _1n$1; + } + if (k1neg) + k1p = k1p.negate(); + if (k2neg) + k2p = k2p.negate(); + k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz); + return k1p.add(k2p); + } + /** + * Constant time multiplication. + * Uses wNAF method. Windowed method may be 10% faster, + * but takes 2x longer to generate and consumes 2x memory. + * Uses precomputes when available. + * Uses endomorphism for Koblitz curves. + * @param scalar by which the point would be multiplied + * @returns New point + */ + multiply(scalar) { + assertGE(scalar); + let n = scalar; + let point, fake; // Fake point is used to const-time mult + const { endo } = CURVE; + if (endo) { + const { k1neg, k1, k2neg, k2 } = endo.splitScalar(n); + let { p: k1p, f: f1p } = this.wNAF(k1); + let { p: k2p, f: f2p } = this.wNAF(k2); + k1p = wnaf.constTimeNegate(k1neg, k1p); + k2p = wnaf.constTimeNegate(k2neg, k2p); + k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz); + point = k1p.add(k2p); + fake = f1p.add(f2p); + } + else { + const { p, f } = this.wNAF(n); + point = p; + fake = f; + } + // Normalize `z` for both points, but return only real one + return Point.normalizeZ([point, fake])[0]; + } + /** + * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly. + * Not using Strauss-Shamir trick: precomputation tables are faster. + * The trick could be useful if both P and Q are not G (not in our case). + * @returns non-zero affine point + */ + multiplyAndAddUnsafe(Q, a, b) { + const G = Point.BASE; // No Strauss-Shamir trick: we have 10% faster G precomputes + const mul = (P, a // Select faster multiply() method + ) => (a === _0n || a === _1n$1 || !P.equals(G) ? P.multiplyUnsafe(a) : P.multiply(a)); + const sum = mul(this, a).add(mul(Q, b)); + return sum.is0() ? undefined : sum; + } + // Converts Projective point to affine (x, y) coordinates. + // Can accept precomputed Z^-1 - for example, from invertBatch. + // (x, y, z) ∋ (x=x/z, y=y/z) + toAffine(iz) { + const { px: x, py: y, pz: z } = this; + const is0 = this.is0(); + // If invZ was 0, we return zero point. However we still want to execute + // all operations, so we replace invZ with a random number, 1. + if (iz == null) + iz = is0 ? Fp.ONE : Fp.inv(z); + const ax = Fp.mul(x, iz); + const ay = Fp.mul(y, iz); + const zz = Fp.mul(z, iz); + if (is0) + return { x: Fp.ZERO, y: Fp.ZERO }; + if (!Fp.eql(zz, Fp.ONE)) + throw new Error('invZ was invalid'); + return { x: ax, y: ay }; + } + isTorsionFree() { + const { h: cofactor, isTorsionFree } = CURVE; + if (cofactor === _1n$1) + return true; // No subgroups, always torsion-free + if (isTorsionFree) + return isTorsionFree(Point, this); + throw new Error('isTorsionFree() has not been declared for the elliptic curve'); + } + clearCofactor() { + const { h: cofactor, clearCofactor } = CURVE; + if (cofactor === _1n$1) + return this; // Fast-path + if (clearCofactor) + return clearCofactor(Point, this); + return this.multiplyUnsafe(CURVE.h); + } + toRawBytes(isCompressed = true) { + this.assertValidity(); + return toBytes(Point, this, isCompressed); + } + toHex(isCompressed = true) { + return bytesToHex$1(this.toRawBytes(isCompressed)); + } + } + Point.BASE = new Point(CURVE.Gx, CURVE.Gy, Fp.ONE); + Point.ZERO = new Point(Fp.ZERO, Fp.ONE, Fp.ZERO); + const _bits = CURVE.nBitLength; + const wnaf = wNAF(Point, CURVE.endo ? Math.ceil(_bits / 2) : _bits); + // Validate if generator point is on curve + return { + CURVE, + ProjectivePoint: Point, + normPrivateKeyToScalar, + weierstrassEquation, + isWithinCurveOrder, + }; +} +function validateOpts(curve) { + const opts = validateBasic(curve); + validateObject(opts, { + hash: 'hash', + hmac: 'function', + randomBytes: 'function', + }, { + bits2int: 'function', + bits2int_modN: 'function', + lowS: 'boolean', + }); + return Object.freeze({ lowS: true, ...opts }); +} +function weierstrass(curveDef) { + const CURVE = validateOpts(curveDef); + const { Fp, n: CURVE_ORDER } = CURVE; + const compressedLen = Fp.BYTES + 1; // e.g. 33 for 32 + const uncompressedLen = 2 * Fp.BYTES + 1; // e.g. 65 for 32 + function isValidFieldElement(num) { + return _0n < num && num < Fp.ORDER; // 0 is banned since it's not invertible FE + } + function modN(a) { + return mod$3(a, CURVE_ORDER); + } + function invN(a) { + return invert(a, CURVE_ORDER); + } + const { ProjectivePoint: Point, normPrivateKeyToScalar, weierstrassEquation, isWithinCurveOrder, } = weierstrassPoints({ + ...CURVE, + toBytes(_c, point, isCompressed) { + const a = point.toAffine(); + const x = Fp.toBytes(a.x); + const cat = concatBytes; + if (isCompressed) { + return cat(Uint8Array.from([point.hasEvenY() ? 0x02 : 0x03]), x); + } + else { + return cat(Uint8Array.from([0x04]), x, Fp.toBytes(a.y)); + } + }, + fromBytes(bytes) { + const len = bytes.length; + const head = bytes[0]; + const tail = bytes.subarray(1); + // this.assertValidity() is done inside of fromHex + if (len === compressedLen && (head === 0x02 || head === 0x03)) { + const x = bytesToNumberBE(tail); + if (!isValidFieldElement(x)) + throw new Error('Point is not on curve'); + const y2 = weierstrassEquation(x); // y² = x³ + ax + b + let y = Fp.sqrt(y2); // y = y² ^ (p+1)/4 + const isYOdd = (y & _1n$1) === _1n$1; + // ECDSA + const isHeadOdd = (head & 1) === 1; + if (isHeadOdd !== isYOdd) + y = Fp.neg(y); + return { x, y }; + } + else if (len === uncompressedLen && head === 0x04) { + const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES)); + const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES)); + return { x, y }; + } + else { + throw new Error(`Point of length ${len} was invalid. Expected ${compressedLen} compressed bytes or ${uncompressedLen} uncompressed bytes`); + } + }, + }); + const numToNByteStr = (num) => bytesToHex$1(numberToBytesBE(num, CURVE.nByteLength)); + function isBiggerThanHalfOrder(number) { + const HALF = CURVE_ORDER >> _1n$1; + return number > HALF; + } + function normalizeS(s) { + return isBiggerThanHalfOrder(s) ? modN(-s) : s; + } + // slice bytes num + const slcNum = (b, from, to) => bytesToNumberBE(b.slice(from, to)); + /** + * ECDSA signature with its (r, s) properties. Supports DER & compact representations. + */ + class Signature { + constructor(r, s, recovery) { + this.r = r; + this.s = s; + this.recovery = recovery; + this.assertValidity(); + } + // pair (bytes of r, bytes of s) + static fromCompact(hex) { + const l = CURVE.nByteLength; + hex = ensureBytes('compactSignature', hex, l * 2); + return new Signature(slcNum(hex, 0, l), slcNum(hex, l, 2 * l)); + } + // DER encoded ECDSA signature + // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script + static fromDER(hex) { + const { r, s } = DER.toSig(ensureBytes('DER', hex)); + return new Signature(r, s); + } + assertValidity() { + // can use assertGE here + if (!isWithinCurveOrder(this.r)) + throw new Error('r must be 0 < r < CURVE.n'); + if (!isWithinCurveOrder(this.s)) + throw new Error('s must be 0 < s < CURVE.n'); + } + addRecoveryBit(recovery) { + return new Signature(this.r, this.s, recovery); + } + recoverPublicKey(msgHash) { + const { r, s, recovery: rec } = this; + const h = bits2int_modN(ensureBytes('msgHash', msgHash)); // Truncate hash + if (rec == null || ![0, 1, 2, 3].includes(rec)) + throw new Error('recovery id invalid'); + const radj = rec === 2 || rec === 3 ? r + CURVE.n : r; + if (radj >= Fp.ORDER) + throw new Error('recovery id 2 or 3 invalid'); + const prefix = (rec & 1) === 0 ? '02' : '03'; + const R = Point.fromHex(prefix + numToNByteStr(radj)); + const ir = invN(radj); // r^-1 + const u1 = modN(-h * ir); // -hr^-1 + const u2 = modN(s * ir); // sr^-1 + const Q = Point.BASE.multiplyAndAddUnsafe(R, u1, u2); // (sr^-1)R-(hr^-1)G = -(hr^-1)G + (sr^-1) + if (!Q) + throw new Error('point at infinify'); // unsafe is fine: no priv data leaked + Q.assertValidity(); + return Q; + } + // Signatures should be low-s, to prevent malleability. + hasHighS() { + return isBiggerThanHalfOrder(this.s); + } + normalizeS() { + return this.hasHighS() ? new Signature(this.r, modN(-this.s), this.recovery) : this; + } + // DER-encoded + toDERRawBytes() { + return hexToBytes(this.toDERHex()); + } + toDERHex() { + return DER.hexFromSig({ r: this.r, s: this.s }); + } + // padded bytes of r, then padded bytes of s + toCompactRawBytes() { + return hexToBytes(this.toCompactHex()); + } + toCompactHex() { + return numToNByteStr(this.r) + numToNByteStr(this.s); + } + } + const utils = { + isValidPrivateKey(privateKey) { + try { + normPrivateKeyToScalar(privateKey); + return true; + } + catch (error) { + return false; + } + }, + normPrivateKeyToScalar: normPrivateKeyToScalar, + /** + * Produces cryptographically secure private key from random of size + * (groupLen + ceil(groupLen / 2)) with modulo bias being negligible. + */ + randomPrivateKey: () => { + const length = getMinHashLength(CURVE.n); + return mapHashToField(CURVE.randomBytes(length), CURVE.n); + }, + /** + * Creates precompute table for an arbitrary EC point. Makes point "cached". + * Allows to massively speed-up `point.multiply(scalar)`. + * @returns cached point + * @example + * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey)); + * fast.multiply(privKey); // much faster ECDH now + */ + precompute(windowSize = 8, point = Point.BASE) { + point._setWindowSize(windowSize); + point.multiply(BigInt(3)); // 3 is arbitrary, just need any number here + return point; + }, + }; + /** + * Computes public key for a private key. Checks for validity of the private key. + * @param privateKey private key + * @param isCompressed whether to return compact (default), or full key + * @returns Public key, full when isCompressed=false; short when isCompressed=true + */ + function getPublicKey(privateKey, isCompressed = true) { + return Point.fromPrivateKey(privateKey).toRawBytes(isCompressed); + } + /** + * Quick and dirty check for item being public key. Does not validate hex, or being on-curve. + */ + function isProbPub(item) { + const arr = item instanceof Uint8Array; + const str = typeof item === 'string'; + const len = (arr || str) && item.length; + if (arr) + return len === compressedLen || len === uncompressedLen; + if (str) + return len === 2 * compressedLen || len === 2 * uncompressedLen; + if (item instanceof Point) + return true; + return false; + } + /** + * ECDH (Elliptic Curve Diffie Hellman). + * Computes shared public key from private key and public key. + * Checks: 1) private key validity 2) shared key is on-curve. + * Does NOT hash the result. + * @param privateA private key + * @param publicB different public key + * @param isCompressed whether to return compact (default), or full key + * @returns shared public key + */ + function getSharedSecret(privateA, publicB, isCompressed = true) { + if (isProbPub(privateA)) + throw new Error('first arg must be private key'); + if (!isProbPub(publicB)) + throw new Error('second arg must be public key'); + const b = Point.fromHex(publicB); // check for being on-curve + return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed); + } + // RFC6979: ensure ECDSA msg is X bytes and < N. RFC suggests optional truncating via bits2octets. + // FIPS 186-4 4.6 suggests the leftmost min(nBitLen, outLen) bits, which matches bits2int. + // bits2int can produce res>N, we can do mod(res, N) since the bitLen is the same. + // int2octets can't be used; pads small msgs with 0: unacceptatble for trunc as per RFC vectors + const bits2int = CURVE.bits2int || + function (bytes) { + // For curves with nBitLength % 8 !== 0: bits2octets(bits2octets(m)) !== bits2octets(m) + // for some cases, since bytes.length * 8 is not actual bitLength. + const num = bytesToNumberBE(bytes); // check for == u8 done here + const delta = bytes.length * 8 - CURVE.nBitLength; // truncate to nBitLength leftmost bits + return delta > 0 ? num >> BigInt(delta) : num; + }; + const bits2int_modN = CURVE.bits2int_modN || + function (bytes) { + return modN(bits2int(bytes)); // can't use bytesToNumberBE here + }; + // NOTE: pads output with zero as per spec + const ORDER_MASK = bitMask(CURVE.nBitLength); + /** + * Converts to bytes. Checks if num in `[0..ORDER_MASK-1]` e.g.: `[0..2^256-1]`. + */ + function int2octets(num) { + if (typeof num !== 'bigint') + throw new Error('bigint expected'); + if (!(_0n <= num && num < ORDER_MASK)) + throw new Error(`bigint expected < 2^${CURVE.nBitLength}`); + // works with order, can have different size than numToField! + return numberToBytesBE(num, CURVE.nByteLength); + } + // Steps A, D of RFC6979 3.2 + // Creates RFC6979 seed; converts msg/privKey to numbers. + // Used only in sign, not in verify. + // NOTE: we cannot assume here that msgHash has same amount of bytes as curve order, this will be wrong at least for P521. + // Also it can be bigger for P224 + SHA256 + function prepSig(msgHash, privateKey, opts = defaultSigOpts) { + if (['recovered', 'canonical'].some((k) => k in opts)) + throw new Error('sign() legacy options not supported'); + const { hash, randomBytes } = CURVE; + let { lowS, prehash, extraEntropy: ent } = opts; // generates low-s sigs by default + if (lowS == null) + lowS = true; // RFC6979 3.2: we skip step A, because we already provide hash + msgHash = ensureBytes('msgHash', msgHash); + if (prehash) + msgHash = ensureBytes('prehashed msgHash', hash(msgHash)); + // We can't later call bits2octets, since nested bits2int is broken for curves + // with nBitLength % 8 !== 0. Because of that, we unwrap it here as int2octets call. + // const bits2octets = (bits) => int2octets(bits2int_modN(bits)) + const h1int = bits2int_modN(msgHash); + const d = normPrivateKeyToScalar(privateKey); // validate private key, convert to bigint + const seedArgs = [int2octets(d), int2octets(h1int)]; + // extraEntropy. RFC6979 3.6: additional k' (optional). + if (ent != null) { + // K = HMAC_K(V || 0x00 || int2octets(x) || bits2octets(h1) || k') + const e = ent === true ? randomBytes(Fp.BYTES) : ent; // generate random bytes OR pass as-is + seedArgs.push(ensureBytes('extraEntropy', e)); // check for being bytes + } + const seed = concatBytes(...seedArgs); // Step D of RFC6979 3.2 + const m = h1int; // NOTE: no need to call bits2int second time here, it is inside truncateHash! + // Converts signature params into point w r/s, checks result for validity. + function k2sig(kBytes) { + // RFC 6979 Section 3.2, step 3: k = bits2int(T) + const k = bits2int(kBytes); // Cannot use fields methods, since it is group element + if (!isWithinCurveOrder(k)) + return; // Important: all mod() calls here must be done over N + const ik = invN(k); // k^-1 mod n + const q = Point.BASE.multiply(k).toAffine(); // q = Gk + const r = modN(q.x); // r = q.x mod n + if (r === _0n) + return; + // Can use scalar blinding b^-1(bm + bdr) where b ∈ [1,q−1] according to + // https://tches.iacr.org/index.php/TCHES/article/view/7337/6509. We've decided against it: + // a) dependency on CSPRNG b) 15% slowdown c) doesn't really help since bigints are not CT + const s = modN(ik * modN(m + r * d)); // Not using blinding here + if (s === _0n) + return; + let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n$1); // recovery bit (2 or 3, when q.x > n) + let normS = s; + if (lowS && isBiggerThanHalfOrder(s)) { + normS = normalizeS(s); // if lowS was passed, ensure s is always + recovery ^= 1; // // in the bottom half of N + } + return new Signature(r, normS, recovery); // use normS, not s + } + return { seed, k2sig }; + } + const defaultSigOpts = { lowS: CURVE.lowS, prehash: false }; + const defaultVerOpts = { lowS: CURVE.lowS, prehash: false }; + /** + * Signs message hash with a private key. + * ``` + * sign(m, d, k) where + * (x, y) = G × k + * r = x mod n + * s = (m + dr)/k mod n + * ``` + * @param msgHash NOT message. msg needs to be hashed to `msgHash`, or use `prehash`. + * @param privKey private key + * @param opts lowS for non-malleable sigs. extraEntropy for mixing randomness into k. prehash will hash first arg. + * @returns signature with recovery param + */ + function sign(msgHash, privKey, opts = defaultSigOpts) { + const { seed, k2sig } = prepSig(msgHash, privKey, opts); // Steps A, D of RFC6979 3.2. + const C = CURVE; + const drbg = createHmacDrbg(C.hash.outputLen, C.nByteLength, C.hmac); + return drbg(seed, k2sig); // Steps B, C, D, E, F, G + } + // Enable precomputes. Slows down first publicKey computation by 20ms. + Point.BASE._setWindowSize(8); + // utils.precompute(8, ProjectivePoint.BASE) + /** + * Verifies a signature against message hash and public key. + * Rejects lowS signatures by default: to override, + * specify option `{lowS: false}`. Implements section 4.1.4 from https://www.secg.org/sec1-v2.pdf: + * + * ``` + * verify(r, s, h, P) where + * U1 = hs^-1 mod n + * U2 = rs^-1 mod n + * R = U1⋅G - U2⋅P + * mod(R.x, n) == r + * ``` + */ + function verify(signature, msgHash, publicKey, opts = defaultVerOpts) { + const sg = signature; + msgHash = ensureBytes('msgHash', msgHash); + publicKey = ensureBytes('publicKey', publicKey); + if ('strict' in opts) + throw new Error('options.strict was renamed to lowS'); + const { lowS, prehash } = opts; + let _sig = undefined; + let P; + try { + if (typeof sg === 'string' || sg instanceof Uint8Array) { + // Signature can be represented in 2 ways: compact (2*nByteLength) & DER (variable-length). + // Since DER can also be 2*nByteLength bytes, we check for it first. + try { + _sig = Signature.fromDER(sg); + } + catch (derError) { + if (!(derError instanceof DER.Err)) + throw derError; + _sig = Signature.fromCompact(sg); + } + } + else if (typeof sg === 'object' && typeof sg.r === 'bigint' && typeof sg.s === 'bigint') { + const { r, s } = sg; + _sig = new Signature(r, s); + } + else { + throw new Error('PARSE'); + } + P = Point.fromHex(publicKey); + } + catch (error) { + if (error.message === 'PARSE') + throw new Error(`signature must be Signature instance, Uint8Array or hex string`); + return false; + } + if (lowS && _sig.hasHighS()) + return false; + if (prehash) + msgHash = CURVE.hash(msgHash); + const { r, s } = _sig; + const h = bits2int_modN(msgHash); // Cannot use fields methods, since it is group element + const is = invN(s); // s^-1 + const u1 = modN(h * is); // u1 = hs^-1 mod n + const u2 = modN(r * is); // u2 = rs^-1 mod n + const R = Point.BASE.multiplyAndAddUnsafe(P, u1, u2)?.toAffine(); // R = u1⋅G + u2⋅P + if (!R) + return false; + const v = modN(R.x); + return v === r; + } + return { + CURVE, + getPublicKey, + getSharedSecret, + sign, + verify, + ProjectivePoint: Point, + Signature, + utils, + }; +} + +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +// connects noble-curves to noble-hashes +function getHash(hash) { + return { + hash, + hmac: (key, ...msgs) => hmac(hash, key, concatBytes$1(...msgs)), + randomBytes: randomBytes$2, + }; +} +function createCurve(curveDef, defHash) { + const create = (hash) => weierstrass({ ...curveDef, ...getHash(hash) }); + return Object.freeze({ ...create(defHash), create }); +} + +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +const secp256k1P = BigInt('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f'); +const secp256k1N = BigInt('0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141'); +const _1n = BigInt(1); +const _2n = BigInt(2); +const divNearest = (a, b) => (a + b / _2n) / b; +/** + * √n = n^((p+1)/4) for fields p = 3 mod 4. We unwrap the loop and multiply bit-by-bit. + * (P+1n/4n).toString(2) would produce bits [223x 1, 0, 22x 1, 4x 0, 11, 00] + */ +function sqrtMod(y) { + const P = secp256k1P; + // prettier-ignore + const _3n = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22); + // prettier-ignore + const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88); + const b2 = (y * y * y) % P; // x^3, 11 + const b3 = (b2 * b2 * y) % P; // x^7 + const b6 = (pow2(b3, _3n, P) * b3) % P; + const b9 = (pow2(b6, _3n, P) * b3) % P; + const b11 = (pow2(b9, _2n, P) * b2) % P; + const b22 = (pow2(b11, _11n, P) * b11) % P; + const b44 = (pow2(b22, _22n, P) * b22) % P; + const b88 = (pow2(b44, _44n, P) * b44) % P; + const b176 = (pow2(b88, _88n, P) * b88) % P; + const b220 = (pow2(b176, _44n, P) * b44) % P; + const b223 = (pow2(b220, _3n, P) * b3) % P; + const t1 = (pow2(b223, _23n, P) * b22) % P; + const t2 = (pow2(t1, _6n, P) * b2) % P; + const root = pow2(t2, _2n, P); + if (!Fp.eql(Fp.sqr(root), y)) + throw new Error('Cannot find square root'); + return root; +} +const Fp = Field(secp256k1P, undefined, undefined, { sqrt: sqrtMod }); +const secp256k1 = createCurve({ + a: BigInt(0), + b: BigInt(7), + Fp, + n: secp256k1N, + // Base point (x, y) aka generator point + Gx: BigInt('55066263022277343669578718895168534326250603453777594175500187360389116729240'), + Gy: BigInt('32670510020758816978083085130507043184471273380659243275938904335757337482424'), + h: BigInt(1), + lowS: true, + /** + * secp256k1 belongs to Koblitz curves: it has efficiently computable endomorphism. + * Endomorphism uses 2x less RAM, speeds up precomputation by 2x and ECDH / key recovery by 20%. + * For precomputed wNAF it trades off 1/2 init time & 1/3 ram for 20% perf hit. + * Explanation: https://gist.github.com/paulmillr/eb670806793e84df628a7c434a873066 + */ + endo: { + beta: BigInt('0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee'), + splitScalar: (k) => { + const n = secp256k1N; + const a1 = BigInt('0x3086d221a7d46bcde86c90e49284eb15'); + const b1 = -_1n * BigInt('0xe4437ed6010e88286f547fa90abfe4c3'); + const a2 = BigInt('0x114ca50f7a8e2f3f657c1108d9d44cfd8'); + const b2 = a1; + const POW_2_128 = BigInt('0x100000000000000000000000000000000'); // (2n**128n).toString(16) + const c1 = divNearest(b2 * k, n); + const c2 = divNearest(-b1 * k, n); + let k1 = mod$3(k - c1 * a1 - c2 * a2, n); + let k2 = mod$3(-c1 * b1 - c2 * b2, n); + const k1neg = k1 > POW_2_128; + const k2neg = k2 > POW_2_128; + if (k1neg) + k1 = n - k1; + if (k2neg) + k2 = n - k2; + if (k1 > POW_2_128 || k2 > POW_2_128) { + throw new Error('splitScalar: Endomorphism failed, k=' + k); + } + return { k1neg, k1, k2neg, k2 }; + }, + }, +}, sha256$1); +// Schnorr signatures are superior to ECDSA from above. Below is Schnorr-specific BIP0340 code. +// https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki +BigInt(0); +secp256k1.ProjectivePoint; + +/** + * A constant for the zero address. + * + * (**i.e.** ``"0x0000000000000000000000000000000000000000"``) + */ +const ZeroAddress = "0x0000000000000000000000000000000000000000"; + +/** + * A constant for the zero hash. + * + * (**i.e.** ``"0x0000000000000000000000000000000000000000000000000000000000000000"``) + */ +const ZeroHash = "0x0000000000000000000000000000000000000000000000000000000000000000"; + +/** + * A constant for the order N for the secp256k1 curve. + * + * (**i.e.** ``0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n``) + */ +BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"); +/** + * A constant for the number of wei in a single ether. + * + * (**i.e.** ``1000000000000000000n``) + */ +BigInt("1000000000000000000"); +/** + * A constant for the maximum value for a ``uint256``. + * + * (**i.e.** ``0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn``) + */ +const MaxUint256 = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); +/** + * A constant for the minimum value for an ``int256``. + * + * (**i.e.** ``-8000000000000000000000000000000000000000000000000000000000000000n``) + */ +BigInt("0x8000000000000000000000000000000000000000000000000000000000000000") * BigInt(-1); +/** + * A constant for the maximum value for an ``int256``. + * + * (**i.e.** ``0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffn``) + */ +BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); + +// NFKC (composed) // (decomposed) +/** + * A constant for the ether symbol (normalized using NFKC). + * + * (**i.e.** ``"\\u039e"``) + */ +/** + * A constant for the [[link-eip-191]] personal message prefix. + * + * (**i.e.** ``"\\x19Ethereum Signed Message:\\n"``) + */ +const MessagePrefix = "\x19Ethereum Signed Message:\n"; + +// Constants +const BN_0$7 = BigInt(0); +const BN_1$2 = BigInt(1); +const BN_2$2 = BigInt(2); +const BN_27$1 = BigInt(27); +const BN_28$1 = BigInt(28); +const BN_35$1 = BigInt(35); +const _guard$3 = {}; +function toUint256(value) { + return zeroPadValue(toBeArray(value), 32); +} +/** + * A Signature @TODO + * + * + * @_docloc: api/crypto:Signing + */ +class Signature { + #r; + #s; + #v; + #networkV; + /** + * The ``r`` value for a signautre. + * + * This represents the ``x`` coordinate of a "reference" or + * challenge point, from which the ``y`` can be computed. + */ + get r() { return this.#r; } + set r(value) { + assertArgument(dataLength(value) === 32, "invalid r", "value", value); + this.#r = hexlify(value); + } + /** + * The ``s`` value for a signature. + */ + get s() { return this.#s; } + set s(_value) { + assertArgument(dataLength(_value) === 32, "invalid s", "value", _value); + const value = hexlify(_value); + assertArgument(parseInt(value.substring(0, 3)) < 8, "non-canonical s", "value", value); + this.#s = value; + } + /** + * The ``v`` value for a signature. + * + * Since a given ``x`` value for ``r`` has two possible values for + * its correspondin ``y``, the ``v`` indicates which of the two ``y`` + * values to use. + * + * It is normalized to the values ``27`` or ``28`` for legacy + * purposes. + */ + get v() { return this.#v; } + set v(value) { + const v = getNumber(value, "value"); + assertArgument(v === 27 || v === 28, "invalid v", "v", value); + this.#v = v; + } + /** + * The EIP-155 ``v`` for legacy transactions. For non-legacy + * transactions, this value is ``null``. + */ + get networkV() { return this.#networkV; } + /** + * The chain ID for EIP-155 legacy transactions. For non-legacy + * transactions, this value is ``null``. + */ + get legacyChainId() { + const v = this.networkV; + if (v == null) { + return null; + } + return Signature.getChainId(v); + } + /** + * The ``yParity`` for the signature. + * + * See ``v`` for more details on how this value is used. + */ + get yParity() { + return (this.v === 27) ? 0 : 1; + } + /** + * The [[link-eip-2098]] compact representation of the ``yParity`` + * and ``s`` compacted into a single ``bytes32``. + */ + get yParityAndS() { + // The EIP-2098 compact representation + const yParityAndS = getBytes(this.s); + if (this.yParity) { + yParityAndS[0] |= 0x80; + } + return hexlify(yParityAndS); + } + /** + * The [[link-eip-2098]] compact representation. + */ + get compactSerialized() { + return concat$3([this.r, this.yParityAndS]); + } + /** + * The serialized representation. + */ + get serialized() { + return concat$3([this.r, this.s, (this.yParity ? "0x1c" : "0x1b")]); + } + /** + * @private + */ + constructor(guard, r, s, v) { + assertPrivate(guard, _guard$3, "Signature"); + this.#r = r; + this.#s = s; + this.#v = v; + this.#networkV = null; + } + [Symbol.for('nodejs.util.inspect.custom')]() { + return `Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`; + } + /** + * Returns a new identical [[Signature]]. + */ + clone() { + const clone = new Signature(_guard$3, this.r, this.s, this.v); + if (this.networkV) { + clone.#networkV = this.networkV; + } + return clone; + } + /** + * Returns a representation that is compatible with ``JSON.stringify``. + */ + toJSON() { + const networkV = this.networkV; + return { + _type: "signature", + networkV: ((networkV != null) ? networkV.toString() : null), + r: this.r, s: this.s, v: this.v, + }; + } + /** + * Compute the chain ID from the ``v`` in a legacy EIP-155 transactions. + * + * @example: + * Signature.getChainId(45) + * //_result: + * + * Signature.getChainId(46) + * //_result: + */ + static getChainId(v) { + const bv = getBigInt(v, "v"); + // The v is not an EIP-155 v, so it is the unspecified chain ID + if ((bv == BN_27$1) || (bv == BN_28$1)) { + return BN_0$7; + } + // Bad value for an EIP-155 v + assertArgument(bv >= BN_35$1, "invalid EIP-155 v", "v", v); + return (bv - BN_35$1) / BN_2$2; + } + /** + * Compute the ``v`` for a chain ID for a legacy EIP-155 transactions. + * + * Legacy transactions which use [[link-eip-155]] hijack the ``v`` + * property to include the chain ID. + * + * @example: + * Signature.getChainIdV(5, 27) + * //_result: + * + * Signature.getChainIdV(5, 28) + * //_result: + * + */ + static getChainIdV(chainId, v) { + return (getBigInt(chainId) * BN_2$2) + BigInt(35 + v - 27); + } + /** + * Compute the normalized legacy transaction ``v`` from a ``yParirty``, + * a legacy transaction ``v`` or a legacy [[link-eip-155]] transaction. + * + * @example: + * // The values 0 and 1 imply v is actually yParity + * Signature.getNormalizedV(0) + * //_result: + * + * // Legacy non-EIP-1559 transaction (i.e. 27 or 28) + * Signature.getNormalizedV(27) + * //_result: + * + * // Legacy EIP-155 transaction (i.e. >= 35) + * Signature.getNormalizedV(46) + * //_result: + * + * // Invalid values throw + * Signature.getNormalizedV(5) + * //_error: + */ + static getNormalizedV(v) { + const bv = getBigInt(v); + if (bv === BN_0$7 || bv === BN_27$1) { + return 27; + } + if (bv === BN_1$2 || bv === BN_28$1) { + return 28; + } + assertArgument(bv >= BN_35$1, "invalid v", "v", v); + // Otherwise, EIP-155 v means odd is 27 and even is 28 + return (bv & BN_1$2) ? 27 : 28; + } + /** + * Creates a new [[Signature]]. + * + * If no %%sig%% is provided, a new [[Signature]] is created + * with default values. + * + * If %%sig%% is a string, it is parsed. + */ + static from(sig) { + function assertError(check, message) { + assertArgument(check, message, "signature", sig); + } + if (sig == null) { + return new Signature(_guard$3, ZeroHash, ZeroHash, 27); + } + if (typeof (sig) === "string") { + const bytes = getBytes(sig, "signature"); + if (bytes.length === 64) { + const r = hexlify(bytes.slice(0, 32)); + const s = bytes.slice(32, 64); + const v = (s[0] & 0x80) ? 28 : 27; + s[0] &= 0x7f; + return new Signature(_guard$3, r, hexlify(s), v); + } + if (bytes.length === 65) { + const r = hexlify(bytes.slice(0, 32)); + const s = bytes.slice(32, 64); + assertError((s[0] & 0x80) === 0, "non-canonical s"); + const v = Signature.getNormalizedV(bytes[64]); + return new Signature(_guard$3, r, hexlify(s), v); + } + assertError(false, "invalid raw signature length"); + } + if (sig instanceof Signature) { + return sig.clone(); + } + // Get r + const _r = sig.r; + assertError(_r != null, "missing r"); + const r = toUint256(_r); + // Get s; by any means necessary (we check consistency below) + const s = (function (s, yParityAndS) { + if (s != null) { + return toUint256(s); + } + if (yParityAndS != null) { + assertError(isHexString$1(yParityAndS, 32), "invalid yParityAndS"); + const bytes = getBytes(yParityAndS); + bytes[0] &= 0x7f; + return hexlify(bytes); + } + assertError(false, "missing s"); + })(sig.s, sig.yParityAndS); + assertError((getBytes(s)[0] & 0x80) == 0, "non-canonical s"); + // Get v; by any means necessary (we check consistency below) + const { networkV, v } = (function (_v, yParityAndS, yParity) { + if (_v != null) { + const v = getBigInt(_v); + return { + networkV: ((v >= BN_35$1) ? v : undefined), + v: Signature.getNormalizedV(v) + }; + } + if (yParityAndS != null) { + assertError(isHexString$1(yParityAndS, 32), "invalid yParityAndS"); + return { v: ((getBytes(yParityAndS)[0] & 0x80) ? 28 : 27) }; + } + if (yParity != null) { + switch (getNumber(yParity, "sig.yParity")) { + case 0: return { v: 27 }; + case 1: return { v: 28 }; + } + assertError(false, "invalid yParity"); + } + assertError(false, "missing v"); + })(sig.v, sig.yParityAndS, sig.yParity); + const result = new Signature(_guard$3, r, s, v); + if (networkV) { + result.#networkV = networkV; + } + // If multiple of v, yParity, yParityAndS we given, check they match + assertError(sig.yParity == null || getNumber(sig.yParity, "sig.yParity") === result.yParity, "yParity mismatch"); + assertError(sig.yParityAndS == null || sig.yParityAndS === result.yParityAndS, "yParityAndS mismatch"); + return result; + } +} + +/** + * Add details about signing here. + * + * @_subsection: api/crypto:Signing [about-signing] + */ +/** + * A **SigningKey** provides high-level access to the elliptic curve + * cryptography (ECC) operations and key management. + */ +class SigningKey { + #privateKey; + /** + * Creates a new **SigningKey** for %%privateKey%%. + */ + constructor(privateKey) { + assertArgument(dataLength(privateKey) === 32, "invalid private key", "privateKey", "[REDACTED]"); + this.#privateKey = hexlify(privateKey); + } + /** + * The private key. + */ + get privateKey() { return this.#privateKey; } + /** + * The uncompressed public key. + * + * This will always begin with the prefix ``0x04`` and be 132 + * characters long (the ``0x`` prefix and 130 hexadecimal nibbles). + */ + get publicKey() { return SigningKey.computePublicKey(this.#privateKey); } + /** + * The compressed public key. + * + * This will always begin with either the prefix ``0x02`` or ``0x03`` + * and be 68 characters long (the ``0x`` prefix and 33 hexadecimal + * nibbles) + */ + get compressedPublicKey() { return SigningKey.computePublicKey(this.#privateKey, true); } + /** + * Return the signature of the signed %%digest%%. + */ + sign(digest) { + assertArgument(dataLength(digest) === 32, "invalid digest length", "digest", digest); + const sig = secp256k1.sign(getBytesCopy(digest), getBytesCopy(this.#privateKey), { + lowS: true + }); + return Signature.from({ + r: toBeHex(sig.r, 32), + s: toBeHex(sig.s, 32), + v: (sig.recovery ? 0x1c : 0x1b) + }); + } + /** + * Returns the [[link-wiki-ecdh]] shared secret between this + * private key and the %%other%% key. + * + * The %%other%% key may be any type of key, a raw public key, + * a compressed/uncompressed pubic key or aprivate key. + * + * Best practice is usually to use a cryptographic hash on the + * returned value before using it as a symetric secret. + * + * @example: + * sign1 = new SigningKey(id("some-secret-1")) + * sign2 = new SigningKey(id("some-secret-2")) + * + * // Notice that privA.computeSharedSecret(pubB)... + * sign1.computeSharedSecret(sign2.publicKey) + * //_result: + * + * // ...is equal to privB.computeSharedSecret(pubA). + * sign2.computeSharedSecret(sign1.publicKey) + * //_result: + */ + computeSharedSecret(other) { + const pubKey = SigningKey.computePublicKey(other); + return hexlify(secp256k1.getSharedSecret(getBytesCopy(this.#privateKey), getBytes(pubKey), false)); + } + /** + * Compute the public key for %%key%%, optionally %%compressed%%. + * + * The %%key%% may be any type of key, a raw public key, a + * compressed/uncompressed public key or private key. + * + * @example: + * sign = new SigningKey(id("some-secret")); + * + * // Compute the uncompressed public key for a private key + * SigningKey.computePublicKey(sign.privateKey) + * //_result: + * + * // Compute the compressed public key for a private key + * SigningKey.computePublicKey(sign.privateKey, true) + * //_result: + * + * // Compute the uncompressed public key + * SigningKey.computePublicKey(sign.publicKey, false); + * //_result: + * + * // Compute the Compressed a public key + * SigningKey.computePublicKey(sign.publicKey, true); + * //_result: + */ + static computePublicKey(key, compressed) { + let bytes = getBytes(key, "key"); + // private key + if (bytes.length === 32) { + const pubKey = secp256k1.getPublicKey(bytes, !!compressed); + return hexlify(pubKey); + } + // raw public key; use uncompressed key with 0x04 prefix + if (bytes.length === 64) { + const pub = new Uint8Array(65); + pub[0] = 0x04; + pub.set(bytes, 1); + bytes = pub; + } + const point = secp256k1.ProjectivePoint.fromHex(bytes); + return hexlify(point.toRawBytes(compressed)); + } + /** + * Returns the public key for the private key which produced the + * %%signature%% for the given %%digest%%. + * + * @example: + * key = new SigningKey(id("some-secret")) + * digest = id("hello world") + * sig = key.sign(digest) + * + * // Notice the signer public key... + * key.publicKey + * //_result: + * + * // ...is equal to the recovered public key + * SigningKey.recoverPublicKey(digest, sig) + * //_result: + * + */ + static recoverPublicKey(digest, signature) { + assertArgument(dataLength(digest) === 32, "invalid digest length", "digest", digest); + const sig = Signature.from(signature); + let secpSig = secp256k1.Signature.fromCompact(getBytesCopy(concat$3([sig.r, sig.s]))); + secpSig = secpSig.addRecoveryBit(sig.yParity); + const pubKey = secpSig.recoverPublicKey(getBytesCopy(digest)); + assertArgument(pubKey != null, "invalid signautre for digest", "signature", signature); + return "0x" + pubKey.toHex(false); + } + /** + * Returns the point resulting from adding the ellipic curve points + * %%p0%% and %%p1%%. + * + * This is not a common function most developers should require, but + * can be useful for certain privacy-specific techniques. + * + * For example, it is used by [[HDNodeWallet]] to compute child + * addresses from parent public keys and chain codes. + */ + static addPoints(p0, p1, compressed) { + const pub0 = secp256k1.ProjectivePoint.fromHex(SigningKey.computePublicKey(p0).substring(2)); + const pub1 = secp256k1.ProjectivePoint.fromHex(SigningKey.computePublicKey(p1).substring(2)); + return "0x" + pub0.add(pub1).toHex(!!compressed); + } +} + +const BN_0$6 = BigInt(0); +const BN_36 = BigInt(36); +function getChecksumAddress(address) { + // if (!isHexString(address, 20)) { + // logger.throwArgumentError("invalid address", "address", address); + // } + address = address.toLowerCase(); + const chars = address.substring(2).split(""); + const expanded = new Uint8Array(40); + for (let i = 0; i < 40; i++) { + expanded[i] = chars[i].charCodeAt(0); + } + const hashed = getBytes(keccak256$1(expanded)); + for (let i = 0; i < 40; i += 2) { + if ((hashed[i >> 1] >> 4) >= 8) { + chars[i] = chars[i].toUpperCase(); + } + if ((hashed[i >> 1] & 0x0f) >= 8) { + chars[i + 1] = chars[i + 1].toUpperCase(); + } + } + return "0x" + chars.join(""); +} +// See: https://en.wikipedia.org/wiki/International_Bank_Account_Number +// Create lookup table +const ibanLookup = {}; +for (let i = 0; i < 10; i++) { + ibanLookup[String(i)] = String(i); +} +for (let i = 0; i < 26; i++) { + ibanLookup[String.fromCharCode(65 + i)] = String(10 + i); +} +// How many decimal digits can we process? (for 64-bit float, this is 15) +// i.e. Math.floor(Math.log10(Number.MAX_SAFE_INTEGER)); +const safeDigits = 15; +function ibanChecksum(address) { + address = address.toUpperCase(); + address = address.substring(4) + address.substring(0, 2) + "00"; + let expanded = address.split("").map((c) => { return ibanLookup[c]; }).join(""); + // Javascript can handle integers safely up to 15 (decimal) digits + while (expanded.length >= safeDigits) { + let block = expanded.substring(0, safeDigits); + expanded = parseInt(block, 10) % 97 + expanded.substring(block.length); + } + let checksum = String(98 - (parseInt(expanded, 10) % 97)); + while (checksum.length < 2) { + checksum = "0" + checksum; + } + return checksum; +} +const Base36 = (function () { + const result = {}; + for (let i = 0; i < 36; i++) { + const key = "0123456789abcdefghijklmnopqrstuvwxyz"[i]; + result[key] = BigInt(i); + } + return result; +})(); +function fromBase36(value) { + value = value.toLowerCase(); + let result = BN_0$6; + for (let i = 0; i < value.length; i++) { + result = result * BN_36 + Base36[value[i]]; + } + return result; +} +/** + * Returns a normalized and checksumed address for %%address%%. + * This accepts non-checksum addresses, checksum addresses and + * [[getIcapAddress]] formats. + * + * The checksum in Ethereum uses the capitalization (upper-case + * vs lower-case) of the characters within an address to encode + * its checksum, which offers, on average, a checksum of 15-bits. + * + * If %%address%% contains both upper-case and lower-case, it is + * assumed to already be a checksum address and its checksum is + * validated, and if the address fails its expected checksum an + * error is thrown. + * + * If you wish the checksum of %%address%% to be ignore, it should + * be converted to lower-case (i.e. ``.toLowercase()``) before + * being passed in. This should be a very rare situation though, + * that you wish to bypass the safegaurds in place to protect + * against an address that has been incorrectly copied from another + * source. + * + * @example: + * // Adds the checksum (via upper-casing specific letters) + * getAddress("0x8ba1f109551bd432803012645ac136ddd64dba72") + * //_result: + * + * // Converts ICAP address and adds checksum + * getAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36"); + * //_result: + * + * // Throws an error if an address contains mixed case, + * // but the checksum fails + * getAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72") + * //_error: + */ +function getAddress(address) { + assertArgument(typeof (address) === "string", "invalid address", "address", address); + if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) { + // Missing the 0x prefix + if (!address.startsWith("0x")) { + address = "0x" + address; + } + const result = getChecksumAddress(address); + // It is a checksummed address with a bad checksum + assertArgument(!address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || result === address, "bad address checksum", "address", address); + return result; + } + // Maybe ICAP? (we only support direct mode) + if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { + // It is an ICAP address with a bad checksum + assertArgument(address.substring(2, 4) === ibanChecksum(address), "bad icap checksum", "address", address); + let result = fromBase36(address.substring(4)).toString(16); + while (result.length < 40) { + result = "0" + result; + } + return getChecksumAddress("0x" + result); + } + assertArgument(false, "invalid address", "address", address); +} + +// http://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed +/** + * Returns the address that would result from a ``CREATE`` for %%tx%%. + * + * This can be used to compute the address a contract will be + * deployed to by an EOA when sending a deployment transaction (i.e. + * when the ``to`` address is ``null``). + * + * This can also be used to compute the address a contract will be + * deployed to by a contract, by using the contract's address as the + * ``to`` and the contract's nonce. + * + * @example + * from = "0x8ba1f109551bD432803012645Ac136ddd64DBA72"; + * nonce = 5; + * + * getCreateAddress({ from, nonce }); + * //_result: + */ +function getCreateAddress(tx) { + const from = getAddress(tx.from); + const nonce = getBigInt(tx.nonce, "tx.nonce"); + let nonceHex = nonce.toString(16); + if (nonceHex === "0") { + nonceHex = "0x"; + } + else if (nonceHex.length % 2) { + nonceHex = "0x0" + nonceHex; + } + else { + nonceHex = "0x" + nonceHex; + } + return getAddress(dataSlice(keccak256$1(encodeRlp([from, nonceHex])), 12)); +} + +/** + * Returns true if %%value%% is an object which implements the + * [[Addressable]] interface. + * + * @example: + * // Wallets and AbstractSigner sub-classes + * isAddressable(Wallet.createRandom()) + * //_result: + * + * // Contracts + * contract = new Contract("dai.tokens.ethers.eth", [ ], provider) + * isAddressable(contract) + * //_result: + */ +function isAddressable(value) { + return (value && typeof (value.getAddress) === "function"); +} +async function checkAddress(target, promise) { + const result = await promise; + if (result == null || result === "0x0000000000000000000000000000000000000000") { + assert$5(typeof (target) !== "string", "unconfigured name", "UNCONFIGURED_NAME", { value: target }); + assertArgument(false, "invalid AddressLike value; did not resolve to a value address", "target", target); + } + return getAddress(result); +} +/** + * Resolves to an address for the %%target%%, which may be any + * supported address type, an [[Addressable]] or a Promise which + * resolves to an address. + * + * If an ENS name is provided, but that name has not been correctly + * configured a [[UnconfiguredNameError]] is thrown. + * + * @example: + * addr = "0x6B175474E89094C44Da98b954EedeAC495271d0F" + * + * // Addresses are return synchronously + * resolveAddress(addr, provider) + * //_result: + * + * // Address promises are resolved asynchronously + * resolveAddress(Promise.resolve(addr)) + * //_result: + * + * // ENS names are resolved asynchronously + * resolveAddress("dai.tokens.ethers.eth", provider) + * //_result: + * + * // Addressable objects are resolved asynchronously + * contract = new Contract(addr, [ ]) + * resolveAddress(contract, provider) + * //_result: + * + * // Unconfigured ENS names reject + * resolveAddress("nothing-here.ricmoo.eth", provider) + * //_error: + * + * // ENS names require a NameResolver object passed in + * // (notice the provider was omitted) + * resolveAddress("nothing-here.ricmoo.eth") + * //_error: + */ +function resolveAddress(target, resolver) { + if (typeof (target) === "string") { + if (target.match(/^0x[0-9a-f]{40}$/i)) { + return getAddress(target); + } + assert$5(resolver != null, "ENS resolution requires a provider", "UNSUPPORTED_OPERATION", { operation: "resolveName" }); + return checkAddress(target, resolver.resolveName(target)); + } + else if (isAddressable(target)) { + return checkAddress(target, target.getAddress()); + } + else if (target && typeof (target.then) === "function") { + return checkAddress(target, target); + } + assertArgument(false, "unsupported addressable value", "target", target); +} + +/** + * A Typed object allows a value to have its type explicitly + * specified. + * + * For example, in Solidity, the value ``45`` could represent a + * ``uint8`` or a ``uint256``. The value ``0x1234`` could represent + * a ``bytes2`` or ``bytes``. + * + * Since JavaScript has no meaningful way to explicitly inform any + * APIs which what the type is, this allows transparent interoperation + * with Soldity. + * + * @_subsection: api/abi:Typed Values + */ +const _gaurd = {}; +function n(value, width) { + let signed = false; + if (width < 0) { + signed = true; + width *= -1; + } + // @TODO: Check range is valid for value + return new Typed(_gaurd, `${signed ? "" : "u"}int${width}`, value, { signed, width }); +} +function b(value, size) { + // @TODO: Check range is valid for value + return new Typed(_gaurd, `bytes${(size) ? size : ""}`, value, { size }); +} +const _typedSymbol = Symbol.for("_ethers_typed"); +/** + * The **Typed** class to wrap values providing explicit type information. + */ +class Typed { + /** + * The type, as a Solidity-compatible type. + */ + type; + /** + * The actual value. + */ + value; + #options; + /** + * @_ignore: + */ + _typedSymbol; + /** + * @_ignore: + */ + constructor(gaurd, type, value, options) { + if (options == null) { + options = null; + } + assertPrivate(_gaurd, gaurd, "Typed"); + defineProperties(this, { _typedSymbol, type, value }); + this.#options = options; + // Check the value is valid + this.format(); + } + /** + * Format the type as a Human-Readable type. + */ + format() { + if (this.type === "array") { + throw new Error(""); + } + else if (this.type === "dynamicArray") { + throw new Error(""); + } + else if (this.type === "tuple") { + return `tuple(${this.value.map((v) => v.format()).join(",")})`; + } + return this.type; + } + /** + * The default value returned by this type. + */ + defaultValue() { + return 0; + } + /** + * The minimum value for numeric types. + */ + minValue() { + return 0; + } + /** + * The maximum value for numeric types. + */ + maxValue() { + return 0; + } + /** + * Returns ``true`` and provides a type guard is this is a [[TypedBigInt]]. + */ + isBigInt() { + return !!(this.type.match(/^u?int[0-9]+$/)); + } + /** + * Returns ``true`` and provides a type guard is this is a [[TypedData]]. + */ + isData() { + return this.type.startsWith("bytes"); + } + /** + * Returns ``true`` and provides a type guard is this is a [[TypedString]]. + */ + isString() { + return (this.type === "string"); + } + /** + * Returns the tuple name, if this is a tuple. Throws otherwise. + */ + get tupleName() { + if (this.type !== "tuple") { + throw TypeError("not a tuple"); + } + return this.#options; + } + // Returns the length of this type as an array + // - `null` indicates the length is unforced, it could be dynamic + // - `-1` indicates the length is dynamic + // - any other value indicates it is a static array and is its length + /** + * Returns the length of the array type or ``-1`` if it is dynamic. + * + * Throws if the type is not an array. + */ + get arrayLength() { + if (this.type !== "array") { + throw TypeError("not an array"); + } + if (this.#options === true) { + return -1; + } + if (this.#options === false) { + return (this.value).length; + } + return null; + } + /** + * Returns a new **Typed** of %%type%% with the %%value%%. + */ + static from(type, value) { + return new Typed(_gaurd, type, value); + } + /** + * Return a new ``uint8`` type for %%v%%. + */ + static uint8(v) { return n(v, 8); } + /** + * Return a new ``uint16`` type for %%v%%. + */ + static uint16(v) { return n(v, 16); } + /** + * Return a new ``uint24`` type for %%v%%. + */ + static uint24(v) { return n(v, 24); } + /** + * Return a new ``uint32`` type for %%v%%. + */ + static uint32(v) { return n(v, 32); } + /** + * Return a new ``uint40`` type for %%v%%. + */ + static uint40(v) { return n(v, 40); } + /** + * Return a new ``uint48`` type for %%v%%. + */ + static uint48(v) { return n(v, 48); } + /** + * Return a new ``uint56`` type for %%v%%. + */ + static uint56(v) { return n(v, 56); } + /** + * Return a new ``uint64`` type for %%v%%. + */ + static uint64(v) { return n(v, 64); } + /** + * Return a new ``uint72`` type for %%v%%. + */ + static uint72(v) { return n(v, 72); } + /** + * Return a new ``uint80`` type for %%v%%. + */ + static uint80(v) { return n(v, 80); } + /** + * Return a new ``uint88`` type for %%v%%. + */ + static uint88(v) { return n(v, 88); } + /** + * Return a new ``uint96`` type for %%v%%. + */ + static uint96(v) { return n(v, 96); } + /** + * Return a new ``uint104`` type for %%v%%. + */ + static uint104(v) { return n(v, 104); } + /** + * Return a new ``uint112`` type for %%v%%. + */ + static uint112(v) { return n(v, 112); } + /** + * Return a new ``uint120`` type for %%v%%. + */ + static uint120(v) { return n(v, 120); } + /** + * Return a new ``uint128`` type for %%v%%. + */ + static uint128(v) { return n(v, 128); } + /** + * Return a new ``uint136`` type for %%v%%. + */ + static uint136(v) { return n(v, 136); } + /** + * Return a new ``uint144`` type for %%v%%. + */ + static uint144(v) { return n(v, 144); } + /** + * Return a new ``uint152`` type for %%v%%. + */ + static uint152(v) { return n(v, 152); } + /** + * Return a new ``uint160`` type for %%v%%. + */ + static uint160(v) { return n(v, 160); } + /** + * Return a new ``uint168`` type for %%v%%. + */ + static uint168(v) { return n(v, 168); } + /** + * Return a new ``uint176`` type for %%v%%. + */ + static uint176(v) { return n(v, 176); } + /** + * Return a new ``uint184`` type for %%v%%. + */ + static uint184(v) { return n(v, 184); } + /** + * Return a new ``uint192`` type for %%v%%. + */ + static uint192(v) { return n(v, 192); } + /** + * Return a new ``uint200`` type for %%v%%. + */ + static uint200(v) { return n(v, 200); } + /** + * Return a new ``uint208`` type for %%v%%. + */ + static uint208(v) { return n(v, 208); } + /** + * Return a new ``uint216`` type for %%v%%. + */ + static uint216(v) { return n(v, 216); } + /** + * Return a new ``uint224`` type for %%v%%. + */ + static uint224(v) { return n(v, 224); } + /** + * Return a new ``uint232`` type for %%v%%. + */ + static uint232(v) { return n(v, 232); } + /** + * Return a new ``uint240`` type for %%v%%. + */ + static uint240(v) { return n(v, 240); } + /** + * Return a new ``uint248`` type for %%v%%. + */ + static uint248(v) { return n(v, 248); } + /** + * Return a new ``uint256`` type for %%v%%. + */ + static uint256(v) { return n(v, 256); } + /** + * Return a new ``uint256`` type for %%v%%. + */ + static uint(v) { return n(v, 256); } + /** + * Return a new ``int8`` type for %%v%%. + */ + static int8(v) { return n(v, -8); } + /** + * Return a new ``int16`` type for %%v%%. + */ + static int16(v) { return n(v, -16); } + /** + * Return a new ``int24`` type for %%v%%. + */ + static int24(v) { return n(v, -24); } + /** + * Return a new ``int32`` type for %%v%%. + */ + static int32(v) { return n(v, -32); } + /** + * Return a new ``int40`` type for %%v%%. + */ + static int40(v) { return n(v, -40); } + /** + * Return a new ``int48`` type for %%v%%. + */ + static int48(v) { return n(v, -48); } + /** + * Return a new ``int56`` type for %%v%%. + */ + static int56(v) { return n(v, -56); } + /** + * Return a new ``int64`` type for %%v%%. + */ + static int64(v) { return n(v, -64); } + /** + * Return a new ``int72`` type for %%v%%. + */ + static int72(v) { return n(v, -72); } + /** + * Return a new ``int80`` type for %%v%%. + */ + static int80(v) { return n(v, -80); } + /** + * Return a new ``int88`` type for %%v%%. + */ + static int88(v) { return n(v, -88); } + /** + * Return a new ``int96`` type for %%v%%. + */ + static int96(v) { return n(v, -96); } + /** + * Return a new ``int104`` type for %%v%%. + */ + static int104(v) { return n(v, -104); } + /** + * Return a new ``int112`` type for %%v%%. + */ + static int112(v) { return n(v, -112); } + /** + * Return a new ``int120`` type for %%v%%. + */ + static int120(v) { return n(v, -120); } + /** + * Return a new ``int128`` type for %%v%%. + */ + static int128(v) { return n(v, -128); } + /** + * Return a new ``int136`` type for %%v%%. + */ + static int136(v) { return n(v, -136); } + /** + * Return a new ``int144`` type for %%v%%. + */ + static int144(v) { return n(v, -144); } + /** + * Return a new ``int52`` type for %%v%%. + */ + static int152(v) { return n(v, -152); } + /** + * Return a new ``int160`` type for %%v%%. + */ + static int160(v) { return n(v, -160); } + /** + * Return a new ``int168`` type for %%v%%. + */ + static int168(v) { return n(v, -168); } + /** + * Return a new ``int176`` type for %%v%%. + */ + static int176(v) { return n(v, -176); } + /** + * Return a new ``int184`` type for %%v%%. + */ + static int184(v) { return n(v, -184); } + /** + * Return a new ``int92`` type for %%v%%. + */ + static int192(v) { return n(v, -192); } + /** + * Return a new ``int200`` type for %%v%%. + */ + static int200(v) { return n(v, -200); } + /** + * Return a new ``int208`` type for %%v%%. + */ + static int208(v) { return n(v, -208); } + /** + * Return a new ``int216`` type for %%v%%. + */ + static int216(v) { return n(v, -216); } + /** + * Return a new ``int224`` type for %%v%%. + */ + static int224(v) { return n(v, -224); } + /** + * Return a new ``int232`` type for %%v%%. + */ + static int232(v) { return n(v, -232); } + /** + * Return a new ``int240`` type for %%v%%. + */ + static int240(v) { return n(v, -240); } + /** + * Return a new ``int248`` type for %%v%%. + */ + static int248(v) { return n(v, -248); } + /** + * Return a new ``int256`` type for %%v%%. + */ + static int256(v) { return n(v, -256); } + /** + * Return a new ``int256`` type for %%v%%. + */ + static int(v) { return n(v, -256); } + /** + * Return a new ``bytes1`` type for %%v%%. + */ + static bytes1(v) { return b(v, 1); } + /** + * Return a new ``bytes2`` type for %%v%%. + */ + static bytes2(v) { return b(v, 2); } + /** + * Return a new ``bytes3`` type for %%v%%. + */ + static bytes3(v) { return b(v, 3); } + /** + * Return a new ``bytes4`` type for %%v%%. + */ + static bytes4(v) { return b(v, 4); } + /** + * Return a new ``bytes5`` type for %%v%%. + */ + static bytes5(v) { return b(v, 5); } + /** + * Return a new ``bytes6`` type for %%v%%. + */ + static bytes6(v) { return b(v, 6); } + /** + * Return a new ``bytes7`` type for %%v%%. + */ + static bytes7(v) { return b(v, 7); } + /** + * Return a new ``bytes8`` type for %%v%%. + */ + static bytes8(v) { return b(v, 8); } + /** + * Return a new ``bytes9`` type for %%v%%. + */ + static bytes9(v) { return b(v, 9); } + /** + * Return a new ``bytes10`` type for %%v%%. + */ + static bytes10(v) { return b(v, 10); } + /** + * Return a new ``bytes11`` type for %%v%%. + */ + static bytes11(v) { return b(v, 11); } + /** + * Return a new ``bytes12`` type for %%v%%. + */ + static bytes12(v) { return b(v, 12); } + /** + * Return a new ``bytes13`` type for %%v%%. + */ + static bytes13(v) { return b(v, 13); } + /** + * Return a new ``bytes14`` type for %%v%%. + */ + static bytes14(v) { return b(v, 14); } + /** + * Return a new ``bytes15`` type for %%v%%. + */ + static bytes15(v) { return b(v, 15); } + /** + * Return a new ``bytes16`` type for %%v%%. + */ + static bytes16(v) { return b(v, 16); } + /** + * Return a new ``bytes17`` type for %%v%%. + */ + static bytes17(v) { return b(v, 17); } + /** + * Return a new ``bytes18`` type for %%v%%. + */ + static bytes18(v) { return b(v, 18); } + /** + * Return a new ``bytes19`` type for %%v%%. + */ + static bytes19(v) { return b(v, 19); } + /** + * Return a new ``bytes20`` type for %%v%%. + */ + static bytes20(v) { return b(v, 20); } + /** + * Return a new ``bytes21`` type for %%v%%. + */ + static bytes21(v) { return b(v, 21); } + /** + * Return a new ``bytes22`` type for %%v%%. + */ + static bytes22(v) { return b(v, 22); } + /** + * Return a new ``bytes23`` type for %%v%%. + */ + static bytes23(v) { return b(v, 23); } + /** + * Return a new ``bytes24`` type for %%v%%. + */ + static bytes24(v) { return b(v, 24); } + /** + * Return a new ``bytes25`` type for %%v%%. + */ + static bytes25(v) { return b(v, 25); } + /** + * Return a new ``bytes26`` type for %%v%%. + */ + static bytes26(v) { return b(v, 26); } + /** + * Return a new ``bytes27`` type for %%v%%. + */ + static bytes27(v) { return b(v, 27); } + /** + * Return a new ``bytes28`` type for %%v%%. + */ + static bytes28(v) { return b(v, 28); } + /** + * Return a new ``bytes29`` type for %%v%%. + */ + static bytes29(v) { return b(v, 29); } + /** + * Return a new ``bytes30`` type for %%v%%. + */ + static bytes30(v) { return b(v, 30); } + /** + * Return a new ``bytes31`` type for %%v%%. + */ + static bytes31(v) { return b(v, 31); } + /** + * Return a new ``bytes32`` type for %%v%%. + */ + static bytes32(v) { return b(v, 32); } + /** + * Return a new ``address`` type for %%v%%. + */ + static address(v) { return new Typed(_gaurd, "address", v); } + /** + * Return a new ``bool`` type for %%v%%. + */ + static bool(v) { return new Typed(_gaurd, "bool", !!v); } + /** + * Return a new ``bytes`` type for %%v%%. + */ + static bytes(v) { return new Typed(_gaurd, "bytes", v); } + /** + * Return a new ``string`` type for %%v%%. + */ + static string(v) { return new Typed(_gaurd, "string", v); } + /** + * Return a new ``array`` type for %%v%%, allowing %%dynamic%% length. + */ + static array(v, dynamic) { + throw new Error("not implemented yet"); + } + /** + * Return a new ``tuple`` type for %%v%%, with the optional %%name%%. + */ + static tuple(v, name) { + throw new Error("not implemented yet"); + } + /** + * Return a new ``uint8`` type for %%v%%. + */ + static overrides(v) { + return new Typed(_gaurd, "overrides", Object.assign({}, v)); + } + /** + * Returns true only if %%value%% is a [[Typed]] instance. + */ + static isTyped(value) { + return (value + && typeof (value) === "object" + && "_typedSymbol" in value + && value._typedSymbol === _typedSymbol); + } + /** + * If the value is a [[Typed]] instance, validates the underlying value + * and returns it, otherwise returns value directly. + * + * This is useful for functions that with to accept either a [[Typed]] + * object or values. + */ + static dereference(value, type) { + if (Typed.isTyped(value)) { + if (value.type !== type) { + throw new Error(`invalid type: expecetd ${type}, got ${value.type}`); + } + return value.value; + } + return value; + } +} + +/** + * @_ignore + */ +class AddressCoder extends Coder { + constructor(localName) { + super("address", "address", localName, false); + } + defaultValue() { + return "0x0000000000000000000000000000000000000000"; + } + encode(writer, _value) { + let value = Typed.dereference(_value, "string"); + try { + value = getAddress(value); + } + catch (error) { + return this._throwError(error.message, _value); + } + return writer.writeValue(value); + } + decode(reader) { + return getAddress(toBeHex(reader.readValue(), 20)); + } +} + +/** + * Clones the functionality of an existing Coder, but without a localName + * + * @_ignore + */ +class AnonymousCoder extends Coder { + coder; + constructor(coder) { + super(coder.name, coder.type, "_", coder.dynamic); + this.coder = coder; + } + defaultValue() { + return this.coder.defaultValue(); + } + encode(writer, value) { + return this.coder.encode(writer, value); + } + decode(reader) { + return this.coder.decode(reader); + } +} + +/** + * @_ignore + */ +function pack(writer, coders, values) { + let arrayValues = []; + if (Array.isArray(values)) { + arrayValues = values; + } + else if (values && typeof (values) === "object") { + let unique = {}; + arrayValues = coders.map((coder) => { + const name = coder.localName; + assert$5(name, "cannot encode object for signature with missing names", "INVALID_ARGUMENT", { argument: "values", info: { coder }, value: values }); + assert$5(!unique[name], "cannot encode object for signature with duplicate names", "INVALID_ARGUMENT", { argument: "values", info: { coder }, value: values }); + unique[name] = true; + return values[name]; + }); + } + else { + assertArgument(false, "invalid tuple value", "tuple", values); + } + assertArgument(coders.length === arrayValues.length, "types/value length mismatch", "tuple", values); + let staticWriter = new Writer(); + let dynamicWriter = new Writer(); + let updateFuncs = []; + coders.forEach((coder, index) => { + let value = arrayValues[index]; + if (coder.dynamic) { + // Get current dynamic offset (for the future pointer) + let dynamicOffset = dynamicWriter.length; + // Encode the dynamic value into the dynamicWriter + coder.encode(dynamicWriter, value); + // Prepare to populate the correct offset once we are done + let updateFunc = staticWriter.writeUpdatableValue(); + updateFuncs.push((baseOffset) => { + updateFunc(baseOffset + dynamicOffset); + }); + } + else { + coder.encode(staticWriter, value); + } + }); + // Backfill all the dynamic offsets, now that we know the static length + updateFuncs.forEach((func) => { func(staticWriter.length); }); + let length = writer.appendWriter(staticWriter); + length += writer.appendWriter(dynamicWriter); + return length; +} +/** + * @_ignore + */ +function unpack(reader, coders) { + let values = []; + let keys = []; + // A reader anchored to this base + let baseReader = reader.subReader(0); + coders.forEach((coder) => { + let value = null; + if (coder.dynamic) { + let offset = reader.readIndex(); + let offsetReader = baseReader.subReader(offset); + try { + value = coder.decode(offsetReader); + } + catch (error) { + // Cannot recover from this + if (isError(error, "BUFFER_OVERRUN")) { + throw error; + } + value = error; + value.baseType = coder.name; + value.name = coder.localName; + value.type = coder.type; + } + } + else { + try { + value = coder.decode(reader); + } + catch (error) { + // Cannot recover from this + if (isError(error, "BUFFER_OVERRUN")) { + throw error; + } + value = error; + value.baseType = coder.name; + value.name = coder.localName; + value.type = coder.type; + } + } + if (value == undefined) { + throw new Error("investigate"); + } + values.push(value); + keys.push(coder.localName || null); + }); + return Result.fromItems(values, keys); +} +/** + * @_ignore + */ +class ArrayCoder extends Coder { + coder; + length; + constructor(coder, length, localName) { + const type = (coder.type + "[" + (length >= 0 ? length : "") + "]"); + const dynamic = (length === -1 || coder.dynamic); + super("array", type, localName, dynamic); + defineProperties(this, { coder, length }); + } + defaultValue() { + // Verifies the child coder is valid (even if the array is dynamic or 0-length) + const defaultChild = this.coder.defaultValue(); + const result = []; + for (let i = 0; i < this.length; i++) { + result.push(defaultChild); + } + return result; + } + encode(writer, _value) { + const value = Typed.dereference(_value, "array"); + if (!Array.isArray(value)) { + this._throwError("expected array value", value); + } + let count = this.length; + if (count === -1) { + count = value.length; + writer.writeValue(value.length); + } + assertArgumentCount(value.length, count, "coder array" + (this.localName ? (" " + this.localName) : "")); + let coders = []; + for (let i = 0; i < value.length; i++) { + coders.push(this.coder); + } + return pack(writer, coders, value); + } + decode(reader) { + let count = this.length; + if (count === -1) { + count = reader.readIndex(); + // Check that there is *roughly* enough data to ensure + // stray random data is not being read as a length. Each + // slot requires at least 32 bytes for their value (or 32 + // bytes as a link to the data). This could use a much + // tighter bound, but we are erroring on the side of safety. + assert$5(count * WordSize <= reader.dataLength, "insufficient data length", "BUFFER_OVERRUN", { buffer: reader.bytes, offset: count * WordSize, length: reader.dataLength }); + } + let coders = []; + for (let i = 0; i < count; i++) { + coders.push(new AnonymousCoder(this.coder)); + } + return unpack(reader, coders); + } +} + +/** + * @_ignore + */ +class BooleanCoder extends Coder { + constructor(localName) { + super("bool", "bool", localName, false); + } + defaultValue() { + return false; + } + encode(writer, _value) { + const value = Typed.dereference(_value, "bool"); + return writer.writeValue(value ? 1 : 0); + } + decode(reader) { + return !!reader.readValue(); + } +} + +/** + * @_ignore + */ +class DynamicBytesCoder extends Coder { + constructor(type, localName) { + super(type, type, localName, true); + } + defaultValue() { + return "0x"; + } + encode(writer, value) { + value = getBytesCopy(value); + let length = writer.writeValue(value.length); + length += writer.writeBytes(value); + return length; + } + decode(reader) { + return reader.readBytes(reader.readIndex(), true); + } +} +/** + * @_ignore + */ +class BytesCoder extends DynamicBytesCoder { + constructor(localName) { + super("bytes", localName); + } + decode(reader) { + return hexlify(super.decode(reader)); + } +} + +/** + * @_ignore + */ +class FixedBytesCoder extends Coder { + size; + constructor(size, localName) { + let name = "bytes" + String(size); + super(name, name, localName, false); + defineProperties(this, { size }, { size: "number" }); + } + defaultValue() { + return ("0x0000000000000000000000000000000000000000000000000000000000000000").substring(0, 2 + this.size * 2); + } + encode(writer, _value) { + let data = getBytesCopy(Typed.dereference(_value, this.type)); + if (data.length !== this.size) { + this._throwError("incorrect data length", _value); + } + return writer.writeBytes(data); + } + decode(reader) { + return hexlify(reader.readBytes(this.size)); + } +} + +const Empty = new Uint8Array([]); +/** + * @_ignore + */ +class NullCoder extends Coder { + constructor(localName) { + super("null", "", localName, false); + } + defaultValue() { + return null; + } + encode(writer, value) { + if (value != null) { + this._throwError("not null", value); + } + return writer.writeBytes(Empty); + } + decode(reader) { + reader.readBytes(0); + return null; + } +} + +const BN_0$5 = BigInt(0); +const BN_1$1 = BigInt(1); +const BN_MAX_UINT256$1 = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); +/** + * @_ignore + */ +class NumberCoder extends Coder { + size; + signed; + constructor(size, signed, localName) { + const name = ((signed ? "int" : "uint") + (size * 8)); + super(name, name, localName, false); + defineProperties(this, { size, signed }, { size: "number", signed: "boolean" }); + } + defaultValue() { + return 0; + } + encode(writer, _value) { + let value = getBigInt(Typed.dereference(_value, this.type)); + // Check bounds are safe for encoding + let maxUintValue = mask(BN_MAX_UINT256$1, WordSize * 8); + if (this.signed) { + let bounds = mask(maxUintValue, (this.size * 8) - 1); + if (value > bounds || value < -(bounds + BN_1$1)) { + this._throwError("value out-of-bounds", _value); + } + value = toTwos(value, 8 * WordSize); + } + else if (value < BN_0$5 || value > mask(maxUintValue, this.size * 8)) { + this._throwError("value out-of-bounds", _value); + } + return writer.writeValue(value); + } + decode(reader) { + let value = mask(reader.readValue(), this.size * 8); + if (this.signed) { + value = fromTwos(value, this.size * 8); + } + return value; + } +} + +/** + * @_ignore + */ +class StringCoder extends DynamicBytesCoder { + constructor(localName) { + super("string", localName); + } + defaultValue() { + return ""; + } + encode(writer, _value) { + return super.encode(writer, toUtf8Bytes$1(Typed.dereference(_value, "string"))); + } + decode(reader) { + return toUtf8String(super.decode(reader)); + } +} + +/** + * @_ignore + */ +class TupleCoder extends Coder { + coders; + constructor(coders, localName) { + let dynamic = false; + const types = []; + coders.forEach((coder) => { + if (coder.dynamic) { + dynamic = true; + } + types.push(coder.type); + }); + const type = ("tuple(" + types.join(",") + ")"); + super("tuple", type, localName, dynamic); + defineProperties(this, { coders: Object.freeze(coders.slice()) }); + } + defaultValue() { + const values = []; + this.coders.forEach((coder) => { + values.push(coder.defaultValue()); + }); + // We only output named properties for uniquely named coders + const uniqueNames = this.coders.reduce((accum, coder) => { + const name = coder.localName; + if (name) { + if (!accum[name]) { + accum[name] = 0; + } + accum[name]++; + } + return accum; + }, {}); + // Add named values + this.coders.forEach((coder, index) => { + let name = coder.localName; + if (!name || uniqueNames[name] !== 1) { + return; + } + if (name === "length") { + name = "_length"; + } + if (values[name] != null) { + return; + } + values[name] = values[index]; + }); + return Object.freeze(values); + } + encode(writer, _value) { + const value = Typed.dereference(_value, "tuple"); + return pack(writer, this.coders, value); + } + decode(reader) { + return unpack(reader, this.coders); + } +} + +/** + * A simple hashing function which operates on UTF-8 strings to + * compute an 32-byte identifier. + * + * This simply computes the [UTF-8 bytes](toUtf8Bytes) and computes + * the [[keccak256]]. + * + * @example: + * id("hello world") + * //_result: + */ +function id$1(value) { + return keccak256$1(toUtf8Bytes$1(value)); +} + +// created 2023-09-25T01:01:55.148Z +// compressed base64-encoded blob for include-ens data +// source: https://github.com/adraffy/ens-normalize.js/blob/main/src/make.js +// see: https://github.com/adraffy/ens-normalize.js#security +// SHA-256: 0565ed049b9cf1614bb9e11ba7d8ac6a6fb96c893253d890f7e2b2884b9ded32 +var COMPRESSED$1 = 'AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5HAW8ArQkDzQCuhzc3NzcBP68NEfMABQdHBuw5BV8FYAA9MzkI9r4ZBg7QyQAWA9CeOwLNCjcCjqkChuA/lm+RAsXTAoP6ASfnEQDytQFJAjWVCkeXAOsA6godAB/cwdAUE0WlBCN/AQUCQRjFD/MRBjHxDQSJbw0jBzUAswBxme+tnIcAYwabAysG8QAjAEMMmxcDqgPKQyDXCMMxA7kUQwD3NXOrAKmFIAAfBC0D3x4BJQDBGdUFAhEgVD8JnwmQJiNWYUzrg0oAGwAUAB0AFnNcACkAFgBP9h3gPfsDOWDKneY2ChglX1UDYD30ABsAFAAdABZzIGRAnwDD8wAjAEEMzRbDqgMB2sAFYwXqAtCnAsS4AwpUJKRtFHsadUz9AMMVbwLpABM1NJEX0ZkCgYMBEyMAxRVvAukAEzUBUFAtmUwSAy4DBTER33EftQHfSwB5MxJ/AjkWKQLzL8E/cwBB6QH9LQDPDtO9ASNriQC5DQANAwCK21EFI91zHwCoL9kBqQcHBwcHKzUDowBvAQohPvU3fAQgHwCyAc8CKQMA5zMSezr7ULgFmDp/LzVQBgEGAi8FYQVgt8AFcTtlQhpCWEmfe5tmZ6IAExsDzQ8t+X8rBKtTAltbAn0jsy8Bl6utPWMDTR8Ei2kRANkDBrNHNysDBzECQWUAcwFpJ3kAiyUhAJ0BUb8AL3EfAbfNAz81KUsFWwF3YQZtAm0A+VEfAzEJDQBRSQCzAQBlAHsAM70GD/v3IZWHBwARKQAxALsjTwHZAeMPEzmXgIHwABIAGQA8AEUAQDt3gdvIEGcQZAkGTRFMdEIVEwK0D64L7REdDNkq09PgADSxB/MDWwfzA1sDWwfzB/MDWwfzA1sDWwNbA1scEvAi28gQZw9QBHUFlgWTBN4IiyZREYkHMAjaVBV0JhxPA00BBCMtSSQ7mzMTJUpMFE0LCAQ2SmyvfUADTzGzVP2QqgPTMlc5dAkGHnkSqAAyD3skNb1OhnpPcagKU0+2tYdJak5vAsY6sEAACikJm2/Dd1YGRRAfJ6kQ+ww3AbkBPw3xS9wE9QY/BM0fgRkdD9GVoAipLeEM8SbnLqWAXiP5KocF8Uv4POELUVFsD10LaQnnOmeBUgMlAREijwrhDT0IcRD3Cs1vDekRSQc9A9lJngCpBwULFR05FbkmFGKwCw05ewb/GvoLkyazEy17AAXXGiUGUQEtGwMA0y7rhbRaNVwgT2MGBwspI8sUrFAkDSlAu3hMGh8HGSWtApVDdEqLUToelyH6PEENai4XUYAH+TwJGVMLhTyiRq9FEhHWPpE9TCJNTDAEOYMsMyePCdMPiQy9fHYBXQklCbUMdRM1ERs3yQg9Bx0xlygnGQglRplgngT7owP3E9UDDwVDCUUHFwO5HDETMhUtBRGBKNsC9zbZLrcCk1aEARsFzw8pH+MQVEfkDu0InwJpA4cl7wAxFSUAGyKfCEdnAGOP3FMJLs8Iy2pwI3gDaxTrZRF3B5UOWwerHDcVwxzlcMxeD4YMKKezCV8BeQmdAWME5wgNNV+MpCBFZ1eLXBifIGVBQ14AAjUMaRWjRMGHfAKPD28SHwE5AXcHPQ0FAnsR8RFvEJkI74YINbkz/DopBFMhhyAVCisDU2zSCysm/Qz8bQGnEmYDEDRBd/Jnr2C6KBgBBx0yyUFkIfULlk/RDKAaxRhGVDIZ6AfDA/ca9yfuQVsGAwOnBxc6UTPyBMELbQiPCUMATQ6nGwfbGG4KdYzUATWPAbudA1uVhwJzkwY7Bw8Aaw+LBX3pACECqwinAAkA0wNbAD0CsQehAB0AiUUBQQMrMwEl6QKTA5cINc8BmTMB9y0EH8cMGQD7O25OAsO1AoBuZqYF4VwCkgJNOQFRKQQJUktVA7N15QDfAE8GF+NLARmvTs8e50cB43MvAMsA/wAJOQcJRQHRAfdxALsBYws1Caa3uQFR7S0AhwAZbwHbAo0A4QA5AIP1AVcAUQVd/QXXAlNNARU1HC9bZQG/AyMBNwERAH0Gz5GpzQsjBHEH1wIQHxXlAu8yB7kFAyLjE9FCyQK94lkAMhoKPAqrCqpgX2Q3CjV2PVQAEh+sPss/UgVVO1c7XDtXO1w7VztcO1c7XDtXO1wDm8Pmw+YKcF9JYe8Mqg3YRMw6TRPfYFVgNhPMLbsUxRXSJVoZQRrAJwkl6FUNDwgt12Y0CDA0eRfAAEMpbINFY4oeNApPHOtTlVT8LR8AtUumM7MNsBsZREQFS3XxYi4WEgomAmSFAmJGX1GzAV83JAKh+wJonAJmDQKfiDgfDwJmPwJmKgRyBIMDfxcDfpY5Cjl7GzmGOicnAmwhAjI6OA4CbcsCbbLzjgM3a0kvAWsA4gDlAE4JB5wMkQECD8YAEbkCdzMCdqZDAnlPRwJ4viFg30WyRvcCfEMCeswCfQ0CfPRIBEiBZygALxlJXEpfGRtK0ALRBQLQ0EsrA4hTA4fqRMmRNgLypV0HAwOyS9JMMSkH001QTbMCi0MCitzFHwshR2sJuwKOOwKOYESbhQKO3QKOYHxRuFM5AQ5S2FSJApP/ApMQAO0AIFUiVbNV1AosHymZijLleGpFPz0Cl6MC77ZYJawAXSkClpMCloCgAK1ZsFoNhVEAPwKWuQKWUlxIXNUCmc8CmWhczl0LHQKcnznGOqECnBoCn58CnryOACETNS4TAp31Ap6WALlBYThh8wKe1wKgcgGtAp6jIwKeUqljzGQrKS8CJ7MCJoICoP8CoFDbAqYzAqXSAqgDAIECp/ZogGi1AAdNaiBq1QKs5wKssgKtawKtBgJXIQJV4AKx5dsDH1JsmwKywRECsuwbbORtZ21MYwMl0QK2YD9DbpQDKUkCuGICuUsZArkue3A6cOUCvR0DLbYDMhUCvoxyBgMzdQK+HnMmc1MCw88CwwhzhnRPOUl05AM8qwEDPJ4DPcMCxYACxksCxhSNAshtVQLISALJUwLJMgJkoQLd1nh9ZXiyeSlL1AMYp2cGAmH4GfeVKHsPXpZevxUCz28Cz3AzT1fW9xejAMqxAs93AS3uA04Wfk8JAtwrAtuOAtJTA1JgA1NjAQUDVZCAjUMEzxrxZEl5A4LSg5EC2ssC2eKEFIRNp0ADhqkAMwNkEoZ1Xf0AWQLfaQLevHd7AuIz7RgB8zQrAfSfAfLWiwLr9wLpdH0DAur9AuroAP1LAb0C7o0C66CWrpcHAu5DA4XkmH1w5HGlAvMHAG0DjhqZlwL3FwORcgOSiwL3nAL53QL4apogmq+/O5siA52HAv7+AR8APZ8gAZ+3AwWRA6ZuA6bdANXJAwZuoYyiCQ0DDE0BEwEjB3EGZb1rCQC/BG/DFY8etxEAG3k9ACcDNxJRA42DAWcrJQCM8wAlAOanC6OVCLsGI6fJBgCvBRnDBvElRUYFFoAFcD9GSDNCKUK8X3kZX8QAls0FOgCQVCGbwTsuYDoZutcONxjOGJHJ/gVfBWAFXwVgBWsFYAVfBWAFXwVgBV8FYAVfBWBOHQjfjW8KCgoKbF7xMwTRA7kGN8PDAMMEr8MA70gxFroFTj5xPnhCR0K+X30/X/AAWBkzswCNBsxzzASm70aCRS4rDDMeLz49fnXfcsH5GcoscQFz13Y4HwVnBXLJycnACNdRYwgICAqEXoWTxgA7P4kACxbZBu21Kw0AjMsTAwkVAOVtJUUsJ1JCuULESUArXy9gPi9AKwnJRQYKTD9LPoA+iT54PnkCkULEUUpDX9NWV3JVEjQAc1w3A3IBE3YnX+g7QiMJb6MKaiszRCUuQrNCxDPMCcwEX9EWJzYREBEEBwIHKn6l33JCNVIfybPJtAltydPUCmhBZw/tEKsZAJOVJU1CLRuxbUHOQAo7P0s+eEJHHA8SJVRPdGM0NVrpvBoKhfUlM0JHHGUQUhEWO1xLSj8MO0ucNAqJIzVCRxv9EFsqKyA4OQgNj2nwZgp5ZNFgE2A1K3YHS2AhQQojJmC7DgpzGG1WYFUZCQYHZO9gHWCdYIVgu2BTYJlwFh8GvRbcXbG8YgtDHrMBwzPVyQonHQgkCyYBgQJ0Ajc4nVqIAwGSCsBPIgDsK3SWEtIVBa5N8gGjAo+kVwVIZwD/AEUSCDweX4ITrRQsJ8K3TwBXFDwEAB0TvzVcAtoTS20RIwDgVgZ9BBImYgA5AL4Coi8LFnezOkCnIQFjAY4KBAPh9RcGsgZSBsEAJctdsWIRu2kTkQstRw7DAcMBKgpPBGIGMDAwKCYnKTQaLg4AKRSVAFwCdl+YUZ0JdicFD3lPAdt1F9ZZKCGxuE3yBxkFVGcA/wBFEgiCBwAOLHQSjxOtQDg1z7deFRMAZ8QTAGtKb1ApIiPHADkAvgKiLy1DFtYCmBiDAlDDWNB0eo7fpaMO/aEVRRv0ATEQZBIODyMEAc8JQhCbDRgzFD4TAEMAu9YBCgCsAOkAm5I3ABwAYxvONnR+MhXJAxgKQyxL2+kkJhMbhQKDBMkSsvF0AD9BNQ6uQC7WqSQHwxEAEEIu1hkhAH2z4iQPwyJPHNWpdyYBRSpnJALzoBAEVPPsH20MxA0CCEQKRgAFyAtFAlMNwwjEDUQJRArELtapMg7DDZgJIw+TGukEIwvDFkMAqAtDEMMMBhioe+QAO3MMRAACrgnEBSPY9Q0FDnbSBoMAB8MSYxkSxAEJAPIJAAB8FWMOFtMc/HcXwxhDAC7DAvOowwAewwJdKDKHAAHDAALrFUQVwwAbwyvzpWMWv8wA/ABpAy++bcYDUKPD0KhDCwKmJ1MAAmMA5+UZwxAagwipBRL/eADfw6fDGOMCGsOjk3l6BwOpo4sAEsMOGxMAA5sAbcMOAAvDp0MJGkMDwgipnNIPAwfIqUMGAOGDAAPzABXDAAcDAAnDAGmTABrDAA7DChjDjnEWAwABYwAOcwAuUyYABsMAF8MIKQANUgC6wy4AA8MADqMq8wCyYgAcIwAB8wqpAAXOCx0V4wAHowBCwwEKAGnDAAuDAB3DAAjDCakABdIAbqcZ3QCZCCkABdIAAAFDAAfjAB2jCCkABqIACYMAGzMAbSMA5sOIAAhjAAhDABTDBAkpAAbSAOOTAAlDC6kOzPtnAAdDAG6kQFAATwAKwwwAA0MACbUDPwAHIwAZgwACE6cDAAojAApDAAoDp/MGwwAJIwADEwAQQwgAFEMAEXMAD5MADfMADcMAGRMOFiMAFUMAbqMWuwHDAMIAE0MLAGkzEgDhUwACQwAEWgAXgwUjAAbYABjDBSYBgzBaAEFNALcQBxUMegAwMngBrA0IZgJ0KxQHBREPd1N0ZzKRJwaIHAZqNT4DqQq8BwngAB4DAwt2AX56T1ocKQNXAh1GATQGC3tOxYNagkgAMQA5CQADAQEAWxLjAIOYNAEzAH7tFRk6TglSAF8NAAlYAQ+S1ACAQwQorQBiAN4dAJ1wPyeTANVzuQDX3AIeEMp9eyMgXiUAEdkBkJizKltbVVAaRMqRAAEAhyQ/SDEz6BmfVwB6ATEsOClKIRcDOF0E/832AFNt5AByAnkCRxGCOs94NjXdAwINGBonDBwPALW2AwICAgAAAAAAAAYDBQMDARrUAwAtAAAAAgEGBgYGBgYFBQUFBQUEBQYHCAkEBQUFBQQAAAICAAAAIgCNAJAAlT0A6gC7ANwApEQAwgCyAK0AqADuAKYA2gCjAOcBCAEDAMcAgQBiANIA1AEDAN4A8gCQAKkBMQDqAN8A3AsBCQ8yO9ra2tq8xuLT1tRJOB0BUgFcNU0BWgFpAWgBWwFMUUlLbhMBUxsNEAs6PhMOACcUKy0vMj5AQENDQ0RFFEYGJFdXV1dZWVhZL1pbXVxcI2NnZ2ZoZypsbnZ1eHh4eHh4enp6enp6enp6enp8fH18e2IARPIASQCaAHgAMgBm+ACOAFcAVwA3AnbvAIsABfj4AGQAk/IAnwBPAGIAZP//sACFAIUAaQBWALEAJAC2AIMCQAJDAPwA5wD+AP4A6AD/AOkA6QDoAOYALwJ7AVEBQAE+AVQBPgE+AT4BOQE4ATgBOAEcAVgXADEQCAEAUx8SHgsdHhYAjgCWAKYAUQBqIAIxAHYAbwCXAxUDJzIDIUlGTzEAkQJPAMcCVwKkAMAClgKWApYClgKWApYCiwKWApYClgKWApYClgKVApUCmAKgApcClgKWApQClAKUApQCkgKVAnUB1AKXAp8ClgKWApUeAIETBQD+DQOfAmECOh8BVBg9AuIZEjMbAU4/G1WZAXusRAFpYQEFA0FPAQYAmTEeIJdyADFoAHEANgCRA5zMk/C2jGINwjMWygIZCaXdfDILBCs5dAE7YnQBugDlhoiHhoiGiYqKhouOjIaNkI6Ij4qQipGGkoaThpSSlYaWhpeKmIaZhpqGm4aci52QnoqfhuIC4XTpAt90AIp0LHSoAIsAdHQEQwRABEIERQRDBEkERgRBBEcESQRIBEQERgRJAJ5udACrA490ALxuAQ10ANFZdHQA13QCFHQA/mJ0AP4BIQD+APwA/AD9APwDhGZ03ASMK23HAP4A/AD8AP0A/CR0dACRYnQA/gCRASEA/gCRAvQA/gCRA4RmdNwEjCttxyR0AP9idAEhAP4A/gD8APwA/QD8AP8A/AD8AP0A/AOEZnTcBIwrbcckdHQAkWJ0ASEA/gCRAP4AkQL0AP4AkQOEZnTcBIwrbcckdAJLAT50AlIBQXQCU8l0dAJfdHQDpgL0A6YDpgOnA6cDpwOnA4RmdNwEjCttxyR0dACRYnQBIQOmAJEDpgCRAvQDpgCRA4RmdNwEjCttxyR0BDh0AJEEOQCRDpU5dSgCADR03gV2CwArdAEFAM5iCnR0AF1iAAYcOgp0dACRCnQAXAEIwWZ0CnRmdHQAkWZ0CnRmdEXgAFF03gp0dEY0tlT2u3SOAQTwscwhjZZKrhYcBSfFp9XNbKiVDOD2b+cpe4/Z17mQnbtzzhaeQtE2GGj0IDNTjRUSyTxxw/RPHW/+vS7d1NfRt9z9QPZg4X7QFfhCnkvgNPIItOsC2eV6hPannZNHlZ9xrwZXIMOlu3jSoQSq78WEjwLjw1ELSlF1aBvfzwk5ZX7AUvQzjPQKbDuQ+sm4wNOp4A6AdVuRS0t1y/DZpg4R6m7FNjM9HgvW7Bi88zaMjOo6lM8wtBBdj8LP4ylv3zCXPhebMKJc066o9sF71oFW/8JXu86HJbwDID5lzw5GWLR/LhT0Qqnp2JQxNZNfcbLIzPy+YypqRm/lBmGmex+82+PisxUumSeJkALIT6rJezxMH+CTJmQtt5uwTVbL3ptmjDUQzlSIvWi8Tl7ng1NpuRn1Ng4n14Qc+3Iil7OwkvNWogLSPkn3pihIFytyIGmMhOe3n1tWsuMy9BdKyqF4Z3v2SgggTL9KVvMXPnCbRe+oOuFFP3HejBG/w9gvmfNYvg6JuWia2lcSSN1uIjBktzoIazOHPJZ7kKHPz8mRWVdW3lA8WGF9dQF6Bm673boov3BUWDU2JNcahR23GtfHKLOz/viZ+rYnZFaIznXO67CYEJ1fXuTRpZhYZkKe54xeoagkNGLs+NTZHE0rX45/XvQ2RGADX6vcAvdxIUBV27wxGm2zjZo4X3ILgAlrOFheuZ6wtsvaIj4yLY7qqawlliaIcrz2G+c3vscAnCkCuMzMmZvMfu9lLwTvfX+3cVSyPdN9ZwgDZhfjRgNJcLiJ67b9xx8JHswprbiE3v9UphotAPIgnXVIN5KmMc0piXhc6cChPnN+MRhG9adtdttQTTwSIpl8I4/j//d3sz1326qTBTpPRM/Hgh3kzqEXs8ZAk4ErQhNO8hzrQ0DLkWMA/N+91tn2MdOJnWC2FCZehkQrwzwbKOjhvZsbM95QoeL9skYyMf4srVPVJSgg7pOLUtr/n9eT99oe9nLtFRpjA9okV2Kj8h9k5HaC0oivRD8VyXkJ81tcd4fHNXPCfloIQasxsuO18/46dR2jgul/UIet2G0kRvnyONMKhHs6J26FEoqSqd+rfYjeEGwHWVDpX1fh1jBBcKGMqRepju9Y00mDVHC+Xdij/j44rKfvfjGinNs1jO/0F3jB83XCDINN/HB84axlP+3E/klktRo+vl3U/aiyMJbIodE1XSsDn6UAzIoMtUObY2+k/4gY/l+AkZJ5Sj2vQrkyLm3FoxjhDX+31UXBFf9XrAH31fFqoBmDEZvhvvpnZ87N+oZEu7U9O/nnk+QWj3x8uyoRbEnf+O5UMr9i0nHP38IF5AvzrBW8YWBUR0mIAzIvndQq9N3v/Jto3aPjPXUPl8ASdPPyAp7jENf8bk7VMM9ol9XGmlBmeDMuGqt+WzuL6CXAxXjIhCPM5vACchgMJ/8XBGLO/D1isVvGhwwHHr1DLaI5mn2Jr/b1pUD90uciDaS8cXNDzCWvNmT/PhQe5e8nTnnnkt8Ds/SIjibcum/fqDhKopxAY8AkSrPn+IGDEKOO+U3XOP6djFs2H5N9+orhOahiQk5KnEUWa+CzkVzhp8bMHRbg81qhjjXuIKbHjSLSIBKWqockGtKinY+z4/RdBUF6pcc3JmnlxVcNgrI4SEzKUZSwcD2QCyxzKve+gAmg6ZuSRkpPFa6mfThu7LJNu3H5K42uCpNvPAsoedolKV/LHe/eJ+BbaG5MG0NaSGVPRUmNFMFFSSpXEcXwbVh7UETOZZtoVNRGOIbbkig3McEtR68cG0RZAoJevWYo7Dg/lZ1CQzblWeUvVHmr8fY4Nqd9JJiH/zEX24mJviH60fAyFr0A3c4bC1j3yZU60VgJxXn8JgJXLUIsiBnmKmMYz+7yBQFBvqb2eYnuW59joZBf56/wXvWIR4R8wTmV80i1mZy+S4+BUES+hzjk0uXpC///z/IlqHZ1monzlXp8aCfhGKMti73FI1KbL1q6IKO4fuBuZ59gagjn5xU79muMpHXg6S+e+gDM/U9BKLHbl9l6o8czQKl4RUkJJiqftQG2i3BMg/TQlUYFkJDYBOOvAugYuzYSDnZbDDd/aSd9x0Oe6F+bJcHfl9+gp6L5/TgA+BdFFovbfCrQ40s5vMPw8866pNX8zyFGeFWdxIpPVp9Rg1UPOVFbFZrvaFq/YAzHQgqMWpahMYfqHpmwXfHL1/kpYmGuHFwT55mQu0dylfNuq2Oq0hTMCPwqfxnuBIPLXfci4Y1ANy+1CUipQxld/izVh16WyG2Q0CQQ9NqtAnx1HCHwDj7sYxOSB0wopZSnOzxQOcExmxrVTF2BkOthVpGfuhaGECfCJpJKpjnihY+xOT2QJxN61+9K6QSqtv2Shr82I3jgJrqBg0wELFZPjvHpvzTtaJnLK6Vb97Yn933koO/saN7fsjwNKzp4l2lJVx2orjCGzC/4ZL4zCver6aQYtC5sdoychuFE6ufOiog+VWi5UDkbmvmtah/3aArEBIi39s5ILUnlFLgilcGuz9CQshEY7fw2ouoILAYPVT/gyAIq3TFAIwVsl+ktkRz/qGfnCDGrm5gsl/l9QdvCWGsjPz3dU7XuqKfdUrr/6XIgjp4rey6AJBmCmUJMjITHVdFb5m1p+dLMCL8t55zD42cmftmLEJC0Da04YiRCVUBLLa8D071/N5UBNBXDh0LFsmhV/5B5ExOB4j3WVG/S3lfK5o+V6ELHvy6RR9n4ac+VsK4VE4yphPvV+kG9FegTBH4ZRXL2HytUHCduJazB/KykjfetYxOXTLws267aGOd+I+JhKP//+VnXmS90OD/jvLcVu0asyqcuYN1mSb6XTlCkqv1vigZPIYwNF/zpWcT1GR/6aEIRjkh0yhg4LXJfaGobYJTY4JI58KiAKgmmgAKWdl5nYCeLqavRJGQNuYuZtZFGx+IkI4w4NS2xwbetNMunOjBu/hmKCI/w7tfiiyUd//4rbTeWt4izBY8YvGIN6vyKYmP/8X8wHKCeN+WRcKM70+tXKNGyevU9H2Dg5BsljnTf8YbsJ1TmMs74Ce2XlHisleguhyeg44rQOHZuw/6HTkhnnurK2d62q6yS7210SsAIaR+jXMQA+svkrLpsUY+F30Uw89uOdGAR6vo4FIME0EfVVeHTu6eKicfhSqOeXJhbftcd08sWEnNUL1C9fnprTgd83IMut8onVUF0hvqzZfHduPjbjwEXIcoYmy+P6tcJZHmeOv6VrvEdkHDJecjHuHeWANe79VG662qTjA/HCvumVv3qL+LrOcpqGps2ZGwQdFJ7PU4iuyRlBrwfO+xnPyr47s2cXVbWzAyznDiBGjCM3ksxjjqM62GE9C8f5U38kB3VjtabKp/nRdvMESPGDG90bWRLAt1Qk5DyLuazRR1YzdC1c+hZXvAWV8xA72S4A8B67vjVhbba3MMop293FeEXpe7zItMWrJG/LOH9ByOXmYnNJfjmfuX9KbrpgLOba4nZ+fl8Gbdv/ihv+6wFGKHCYrVwmhFC0J3V2bn2tIB1wCc1CST3d3X2OyxhguXcs4sm679UngzofuSeBewMFJboIQHbUh/m2JhW2hG9DIvG2t7yZIzKBTz9wBtnNC+2pCRYhSIuQ1j8xsz5VvqnyUIthvuoyyu7fNIrg/KQUVmGQaqkqZk/Vx5b33/gsEs8yX7SC1J+NV4icz6bvIE7C5G6McBaI8rVg56q5QBJWxn/87Q1sPK4+sQa8fLU5gXo4paaq4cOcQ4wR0VBHPGjKh+UlPCbA1nLXyEUX45qZ8J7/Ln4FPJE2TdzD0Z8MLSNQiykMMmSyOCiFfy84Rq60emYB2vD09KjYwsoIpeDcBDTElBbXxND72yhd9pC/1CMid/5HUMvAL27OtcIJDzNKpRPNqPOpyt2aPGz9QWIs9hQ9LiX5s8m9hjTUu/f7MyIatjjd+tSfQ3ufZxPpmJhTaBtZtKLUcfOCUqADuO+QoH8B9v6U+P0HV1GLQmtoNFTb3s74ivZgjES0qfK+8RdGgBbcCMSy8eBvh98+et1KIFqSe1KQPyXULBMTsIYnysIwiZBJYdI20vseV+wuJkcqGemehKjaAb9L57xZm3g2zX0bZ2xk/fU+bCo7TlnbW7JuF1YdURo/2Gw7VclDG1W7LOtas2LX4upifZ/23rzpsnY/ALfRgrcWP5hYmV9VxVOQA1fZvp9F2UNU+7d7xRyVm5wiLp3/0dlV7vdw1PMiZrbDAYzIVqEjRY2YU03sJhPnlwIPcZUG5ltL6S8XCxU1eYS5cjr34veBmXAvy7yN4ZjArIG0dfD/5UpBNlX1ZPoxJOwyqRi3wQWtOzd4oNKh0LkoTm8cwqgIfKhqqGOhwo71I+zXnMemTv2B2AUzABWyFztGgGULjDDzWYwJUVBTjKCn5K2QGMK1CQT7SzziOjo+BhAmqBjzuc3xYym2eedGeOIRJVyTwDw37iCMe4g5Vbnsb5ZBdxOAnMT7HU4DHpxWGuQ7GeiY30Cpbvzss55+5Km1YsbD5ea3NI9QNYIXol5apgSu9dZ8f8xS5dtHpido5BclDuLWY4lhik0tbJa07yJhH0BOyEut/GRbYTS6RfiTYWGMCkNpfSHi7HvdiTglEVHKZXaVhezH4kkXiIvKopYAlPusftpE4a5IZwvw1x/eLvoDIh/zpo9FiQInsTb2SAkKHV42XYBjpJDg4374XiVb3ws4qM0s9eSQ5HzsMU4OZJKuopFjBM+dAZEl8RUMx5uU2N486Kr141tVsGQfGjORYMCJAMsxELeNT4RmWjRcpdTGBwcx6XN9drWqPmJzcrGrH4+DRc7+n1w3kPZwu0BkNr6hQrqgo7JTB9A5kdJ/H7P4cWBMwsmuixAzJB3yrQpnGIq90lxAXLzDCdn1LPibsRt7rHNjgQBklRgPZ8vTbjXdgXrTWQsK5MdrXXQVPp0Rinq3frzZKJ0qD6Qhc40VzAraUXlob1gvkhK3vpmHgI6FRlQZNx6eRqkp0zy4AQlX813fAPtL3jMRaitGFFjo0zmErloC+h+YYdVQ6k4F/epxAoF0BmqEoKNTt6j4vQZNQ2BoqF9Vj53TOIoNmDiu9Xp15RkIgQIGcoLpfoIbenzpGUAtqFJp5W+LLnx38jHeECTJ/navKY1NWfN0sY1T8/pB8kIH3DU3DX+u6W3YwpypBMYOhbSxGjq84RZ84fWJow8pyHqn4S/9J15EcCMsXqrfwyd9mhiu3+rEo9pPpoJkdZqHjra4NvzFwuThNKy6hao/SlLw3ZADUcUp3w3SRVfW2rhl80zOgTYnKE0Hs2qp1J6H3xqPqIkvUDRMFDYyRbsFI3M9MEyovPk8rlw7/0a81cDVLmBsR2ze2pBuKb23fbeZC0uXoIvDppfTwIDxk1Oq2dGesGc+oJXWJLGkOha3CX+DUnzgAp9HGH9RsPZN63Hn4RMA5eSVhPHO+9RcRb/IOgtW31V1Q5IPGtoxPjC+MEJbVlIMYADd9aHYWUIQKopuPOHmoqSkubnAKnzgKHqgIOfW5RdAgotN6BN+O2ZYHkuemLnvQ8U9THVrS1RtLmKbcC7PeeDsYznvqzeg6VCNwmr0Yyx1wnLjyT84BZz3EJyCptD3yeueAyDWIs0L2qs/VQ3HUyqfrja0V1LdDzqAikeWuV4sc7RLIB69jEIBjCkyZedoUHqCrOvShVzyd73OdrJW0hPOuQv2qOoHDc9xVb6Yu6uq3Xqp2ZaH46A7lzevbxQEmfrzvAYSJuZ4WDk1Hz3QX1LVdiUK0EvlAGAYlG3Md30r7dcPN63yqBCIj25prpvZP0nI4+EgWoFG95V596CurXpKRBGRjQlHCvy5Ib/iW8nZJWwrET3mgd6mEhfP4KCuaLjopWs7h+MdXFdIv8dHQJgg1xi1eYqB0uDYjxwVmri0Sv5XKut/onqapC+FQiC2C1lvYJ9MVco6yDYsS3AANUfMtvtbYI2hfwZatiSsnoUeMZd34GVjkMMKA+XnjJpXgRW2SHTZplVowPmJsvXy6w3cfO1AK2dvtZEKTkC/TY9LFiKHCG0DnrMQdGm2lzlBHM9iEYynH2UcVMhUEjsc0oDBTgo2ZSQ1gzkAHeWeBXYFjYLuuf8yzTCy7/RFR81WDjXMbq2BOH5dURnxo6oivmxL3cKzKInlZkD31nvpHB9Kk7GfcfE1t+1V64b9LtgeJGlpRFxQCAqWJ5DoY77ski8gsOEOr2uywZaoO/NGa0X0y1pNQHBi3b2SUGNpcZxDT7rLbBf1FSnQ8guxGW3W+36BW0gBje4DOz6Ba6SVk0xiKgt+q2JOFyr4SYfnu+Ic1QZYIuwHBrgzr6UvOcSCzPTOo7D6IC4ISeS7zkl4h+2VoeHpnG/uWR3+ysNgPcOIXQbv0n4mr3BwQcdKJxgPSeyuP/z1Jjg4e9nUvoXegqQVIE30EHx5GHv+FAVUNTowYDJgyFhf5IvlYmEqRif6+WN1MkEJmDcQITx9FX23a4mxy1AQRsOHO/+eImX9l8EMJI3oPWzVXxSOeHU1dUWYr2uAA7AMb+vAEZSbU3qob9ibCyXeypEMpZ6863o6QPqlqGHZkuWABSTVNd4cOh9hv3qEpSx2Zy/DJMP6cItEmiBJ5PFqQnDEIt3NrA3COlOSgz43D7gpNFNJ5MBh4oFzhDPiglC2ypsNU4ISywY2erkyb1NC3Qh/IfWj0eDgZI4/ln8WPfBsT3meTjq1Uqt1E7Zl/qftqkx6aM9KueMCekSnMrcHj1CqTWWzEzPsZGcDe3Ue4Ws+XFYVxNbOFF8ezkvQGR6ZOtOLU2lQEnMBStx47vE6Pb7AYMBRj2OOfZXfisjJnpTfSNjo6sZ6qSvNxZNmDeS7Gk3yYyCk1HtKN2UnhMIjOXUzAqDv90lx9O/q/AT1ZMnit5XQe9wmQxnE/WSH0CqZ9/2Hy+Sfmpeg8RwsHI5Z8kC8H293m/LHVVM/BA7HaTJYg5Enk7M/xWpq0192ACfBai2LA/qrCjCr6Dh1BIMzMXINBmX96MJ5Hn2nxln/RXPFhwHxUmSV0EV2V0jm86/dxxuYSU1W7sVkEbN9EzkG0QFwPhyHKyb3t+Fj5WoUUTErcazE/N6EW6Lvp0d//SDPj7EV9UdJN+Amnf3Wwk3A0SlJ9Z00yvXZ7n3z70G47Hfsow8Wq1JXcfwnA+Yxa5mFsgV464KKP4T31wqIgzFPd3eCe3j5ory5fBF2hgCFyVFrLzI9eetNXvM7oQqyFgDo4CTp/hDV9NMX9JDHQ/nyHTLvZLNLF6ftn2OxjGm8+PqOwhxnPHWipkE/8wbtyri80Sr7pMNkQGMfo4ZYK9OcCC4ESVFFbLMIvlxSoRqWie0wxqnLfcLSXMSpMMQEJYDVObYsXIQNv4TGNwjq1kvT1UOkicTrG3IaBZ3XdScS3u8sgeZPVpOLkbiF940FjbCeNRINNvDbd01EPBrTCPpm12m43ze1bBB59Ia6Ovhnur/Nvx3IxwSWol+3H2qfCJR8df6aQf4v6WiONxkK+IqT4pKQrZK/LplgDI/PJZbOep8dtbV7oCr6CgfpWa8NczOkPx81iSHbsNhVSJBOtrLIMrL31LK9TqHqAbAHe0RLmmV806kRLDLNEhUEJfm9u0sxpkL93Zgd6rw+tqBfTMi59xqXHLXSHwSbSBl0EK0+loECOPtrl+/nsaFe197di4yUgoe4jKoAJDXc6DGDjrQOoFDWZJ9HXwt8xDrQP+7aRwWKWI1GF8s8O4KzxWBBcwnl3vnl1Oez3oh6Ea1vjR7/z7DDTrFtqU2W/KAEzAuXDNZ7MY73MF216dzdSbWmUp4lcm7keJfWaMHgut9x5C9mj66Z0lJ+yhsjVvyiWrfk1lzPOTdhG15Y7gQlXtacvI7qv/XNSscDwqkgwHT/gUsD5yB7LdRRvJxQGYINn9hTpodKFVSTPrtGvyQw+HlRFXIkodErAGu9Iy1YpfSPc3jkFh5CX3lPxv7aqjE/JAfTIpEjGb/H7MO0e2vsViSW1qa/Lmi4/n4DEI3g7lYrcanspDfEpKkdV1OjSLOy0BCUqVoECaB55vs06rXl4jqmLsPsFM/7vYJ0vrBhDCm/00A/H81l1uekJ/6Lml3Hb9+NKiLqATJmDpyzfYZFHumEjC662L0Bwkxi7E9U4cQA0XMVDuMYAIeLMPgQaMVOd8fmt5SflFIfuBoszeAw7ow5gXPE2Y/yBc/7jExARUf/BxIHQBF5Sn3i61w4z5xJdCyO1F1X3+3ax+JSvMeZ7S6QSKp1Fp/sjYz6Z+VgCZzibGeEoujryfMulH7Rai5kAft9ebcW50DyJr2uo2z97mTWIu45YsSnNSMrrNUuG1XsYBtD9TDYzQffKB87vWbkM4EbPAFgoBV4GQS+vtFDUqOFAoi1nTtmIOvg38N4hT2Sn8r8clmBCXspBlMBYTnrqFJGBT3wZOzAyJDre9dHH7+x7qaaKDOB4UQALD5ecS0DE4obubQEiuJZ0EpBVpLuYcce8Aa4PYd/V4DLDAJBYKQPCWTcrEaZ5HYbJi11Gd6hjGom1ii18VHYnG28NKpkz2UKVPxlhYSp8uZr367iOmoy7zsxehW9wzcy2zG0a80PBMCRQMb32hnaHeOR8fnNDzZhaNYhkOdDsBUZ3loDMa1YP0uS0cjUP3b/6DBlqmZOeNABDsLl5BI5QJups8uxAuWJdkUB/pO6Zax6tsg7fN5mjjDgMGngO+DPcKqiHIDbFIGudxtPTIyDi9SFMKBDcfdGQRv41q1AqmxgkVfJMnP8w/Bc7N9/TR6C7mGObFqFkIEom8sKi2xYqJLTCHK7cxzaZvqODo22c3wisBCP4HeAgcRbNPAsBkNRhSmD48dHupdBRw4mIvtS5oeF6zeT1KMCyhMnmhpkFAGWnGscoNkwvQ8ZM5lE/vgTHFYL99OuNxdFBxTEDd5v2qLR8y9WkXsWgG6kZNndFG+pO/UAkOCipqIhL3hq7cRSdrCq7YhUsTocEcnaFa6nVkhnSeRYUA1YO0z5itF9Sly3VlxYDw239TJJH6f3EUfYO5lb7bcFcz8Bp7Oo8QmnsUHOz/fagVUBtKEw1iT88j+aKkv8cscKNkMxjYr8344D1kFoZ7/td1W6LCNYN594301tUGRmFjAzeRg5vyoM1F6+bJZ/Q54jN/k8SFd3DxPTYaAUsivsBfgTn7Mx8H2SpPt4GOdYRnEJOH6jHM2p6SgB0gzIRq6fHxGMmSmqaPCmlfwxiuloaVIitLGN8wie2CDWhkzLoCJcODh7KIOAqbHEvXdUxaS4TTTs07Clzj/6GmVs9kiZDerMxEnhUB6QQPlcfqkG9882RqHoLiHGBoHfQuXIsAG8GTAtao2KVwRnvvam8jo1e312GQAKWEa4sUVEAMG4G6ckcONDwRcg1e2D3+ohXgY4UAWF8wHKQMrSnzCgfFpsxh+aHXMGtPQroQasRY4U6UdG0rz1Vjbka0MekOGRZQEvqQFlxseFor8zWFgHek3v29+WqN6gaK5gZOTOMZzpQIC1201LkMCXild3vWXSc5UX9xcFYfbRPzGFa1FDcPfPB/jUEq/FeGt419CI3YmBlVoHsa4KdcwQP5ZSwHHhFJ7/Ph/Rap/4vmG91eDwPP0lDfCDRCLszTqfzM71xpmiKi2HwS4WlqvGNwtvwF5Dqpn6KTq8ax00UMPkxDcZrEEEsIvHiUXXEphdb4GB4FymlPwBz4Gperqq5pW7TQ6/yNRhW8VT5NhuP0udlxo4gILq5ZxAZk8ZGh3g4CqxJlPKY7AQxupfUcVpWT5VItp1+30UqoyP4wWsRo3olRRgkWZZ2ZN6VC3OZFeXB8NbnUrSdikNptD1QiGuKkr8EmSR/AK9Rw+FF3s5uwuPbvHGiPeFOViltMK7AUaOsq9+x9cndk3iJEE5LKZRlWJbKOZweROzmPNVPkjE3K/TyA57Rs68TkZ3MR8akKpm7cFjnjPd/DdkWjgYoKHSr5Wu5ssoBYU4acRs5g2DHxUmdq8VXOXRbunD8QN0LhgkssgahcdoYsNvuXGUK/KXD/7oFb+VGdhqIn02veuM5bLudJOc2Ky0GMaG4W/xWBxIJcL7yliJOXOpx0AkBqUgzlDczmLT4iILXDxxtRR1oZa2JWFgiAb43obrJnG/TZC2KSK2wqOzRZTXavZZFMb1f3bXvVaNaK828w9TO610gk8JNf3gMfETzXXsbcvRGCG9JWQZ6+cDPqc4466Yo2RcKH+PILeKOqtnlbInR3MmBeGG3FH10yzkybuqEC2HSQwpA0An7d9+73BkDUTm30bZmoP/RGbgFN+GrCOfADgqr0WbI1a1okpFms8iHYw9hm0zUvlEMivBRxModrbJJ+9/p3jUdQQ9BCtQdxnOGrT5dzRUmw0593/mbRSdBg0nRvRZM5/E16m7ZHmDEtWhwvfdZCZ8J8M12W0yRMszXamWfQTwIZ4ayYktrnscQuWr8idp3PjT2eF/jmtdhIfcpMnb+IfZY2FebW6UY/AK3jP4u3Tu4zE4qlnQgLFbM19EBIsNf7KhjdbqQ/D6yiDb+NlEi2SKD+ivXVUK8ib0oBo366gXkR8ZxGjpJIDcEgZPa9TcYe0TIbiPl/rPUQDu3XBJ9X/GNq3FAUsKsll57DzaGMrjcT+gctp+9MLYXCq+sqP81eVQ0r9lt+gcQfZbACRbEjvlMskztZG8gbC8Qn9tt26Q7y7nDrbZq/LEz7kR6Jc6pg3N9rVX8Y5MJrGlML9p9lU4jbTkKqCveeZUJjHB03m2KRKR2TytoFkTXOLg7keU1s1lrPMQJpoOKLuAAC+y1HlJucU6ysB5hsXhvSPPLq5J7JtnqHKZ4vYjC4Vy8153QY+6780xDuGARsGbOs1WqzH0QS765rnSKEbbKlkO8oI/VDwUd0is13tKpqILu1mDJFNy/iJAWcvDgjxvusIT+PGz3ST/J9r9Mtfd0jpaGeiLYIqXc7DiHSS8TcjFVksi66PEkxW1z6ujbLLUGNNYnzOWpH8BZGK4bCK7iR+MbIv8ncDAz1u4StN3vTTzewr9IQjk9wxFxn+6N1ddKs0vffJiS08N3a4G1SVrlZ97Q/M+8G9fe5AP6d9/Qq4WRnORVhofPIKEdCr3llspUfE0oKIIYoByBRPh+bX1HLS3JWGJRhIvE1aW4NTd8ePi4Z+kXb+Z8snYfSNcqijhAgVsx4RCM54cXUiYkjeBmmC4ajOHrChoELscJJC7+9jjMjw5BagZKlgRMiSNYz7h7vvZIoQqbtQmspc0cUk1G/73iXtSpROl5wtLgQi0mW2Ex8i3WULhcggx6E1LMVHUsdc9GHI1PH3U2Ko0PyGdn9KdVOLm7FPBui0i9a0HpA60MsewVE4z8CAt5d401Gv6zXlIT5Ybit1VIA0FCs7wtvYreru1fUyW3oLAZ/+aTnZrOcYRNVA8spoRtlRoWflsRClFcgzkqiHOrf0/SVw+EpVaFlJ0g4Kxq1MMOmiQdpMNpte8lMMQqm6cIFXlnGbfJllysKDi+0JJMotkqgIxOSQgU9dn/lWkeVf8nUm3iwX2Nl3WDw9i6AUK3vBAbZZrcJpDQ/N64AVwjT07Jef30GSSmtNu2WlW7YoyW2FlWfZFQUwk867EdLYKk9VG6JgEnBiBxkY7LMo4YLQJJlAo9l/oTvJkSARDF/XtyAzM8O2t3eT/iXa6wDN3WewNmQHdPfsxChU/KtLG2Mn8i4ZqKdSlIaBZadxJmRzVS/o4yA65RTSViq60oa395Lqw0pzY4SipwE0SXXsKV+GZraGSkr/RW08wPRvqvSUkYBMA9lPx4m24az+IHmCbXA+0faxTRE9wuGeO06DIXa6QlKJ3puIyiuAVfPr736vzo2pBirS+Vxel3TMm3JKhz9o2ZoRvaFVpIkykb0Hcm4oHFBMcNSNj7/4GJt43ogonY2Vg4nsDQIWxAcorpXACzgBqQPjYsE/VUpXpwNManEru4NwMCFPkXvMoqvoeLN3qyu/N1eWEHttMD65v19l/0kH2mR35iv/FI+yjoHJ9gPMz67af3Mq/BoWXqu3rphiWMXVkmnPSEkpGpUI2h1MThideGFEOK6YZHPwYzMBvpNC7+ZHxPb7epfefGyIB4JzO9DTNEYnDLVVHdQyvOEVefrk6Uv5kTQYVYWWdqrdcIl7yljwwIWdfQ/y+2QB3eR/qxYObuYyB4gTbo2in4PzarU1sO9nETkmj9/AoxDA+JM3GMqQtJR4jtduHtnoCLxd1gQUscHRB/MoRYIEsP2pDZ9KvHgtlk1iTbWWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI'; +const FENCED = new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]); +const NSM_MAX = 4; + +function decode_arithmetic(bytes) { + let pos = 0; + function u16() { return (bytes[pos++] << 8) | bytes[pos++]; } + + // decode the frequency table + let symbol_count = u16(); + let total = 1; + let acc = [0, 1]; // first symbol has frequency 1 + for (let i = 1; i < symbol_count; i++) { + acc.push(total += u16()); + } + + // skip the sized-payload that the last 3 symbols index into + let skip = u16(); + let pos_payload = pos; + pos += skip; + + let read_width = 0; + let read_buffer = 0; + function read_bit() { + if (read_width == 0) { + // this will read beyond end of buffer + // but (undefined|0) => zero pad + read_buffer = (read_buffer << 8) | bytes[pos++]; + read_width = 8; + } + return (read_buffer >> --read_width) & 1; + } + + const N = 31; + const FULL = 2**N; + const HALF = FULL >>> 1; + const QRTR = HALF >> 1; + const MASK = FULL - 1; + + // fill register + let register = 0; + for (let i = 0; i < N; i++) register = (register << 1) | read_bit(); + + let symbols = []; + let low = 0; + let range = FULL; // treat like a float + while (true) { + let value = Math.floor((((register - low + 1) * total) - 1) / range); + let start = 0; + let end = symbol_count; + while (end - start > 1) { // binary search + let mid = (start + end) >>> 1; + if (value < acc[mid]) { + end = mid; + } else { + start = mid; + } + } + if (start == 0) break; // first symbol is end mark + symbols.push(start); + let a = low + Math.floor(range * acc[start] / total); + let b = low + Math.floor(range * acc[start+1] / total) - 1; + while (((a ^ b) & HALF) == 0) { + register = (register << 1) & MASK | read_bit(); + a = (a << 1) & MASK; + b = (b << 1) & MASK | 1; + } + while (a & ~b & QRTR) { + register = (register & HALF) | ((register << 1) & (MASK >>> 1)) | read_bit(); + a = (a << 1) ^ HALF; + b = ((b ^ HALF) << 1) | HALF | 1; + } + low = a; + range = 1 + b - a; + } + let offset = symbol_count - 4; + return symbols.map(x => { // index into payload + switch (x - offset) { + case 3: return offset + 0x10100 + ((bytes[pos_payload++] << 16) | (bytes[pos_payload++] << 8) | bytes[pos_payload++]); + case 2: return offset + 0x100 + ((bytes[pos_payload++] << 8) | bytes[pos_payload++]); + case 1: return offset + bytes[pos_payload++]; + default: return x - 1; + } + }); +} + +// returns an iterator which returns the next symbol +function read_payload(v) { + let pos = 0; + return () => v[pos++]; +} +function read_compressed_payload(s) { + return read_payload(decode_arithmetic(unsafe_atob(s))); +} + +// unsafe in the sense: +// expected well-formed Base64 w/o padding +// 20220922: added for https://github.com/adraffy/ens-normalize.js/issues/4 +function unsafe_atob(s) { + let lookup = []; + [...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'].forEach((c, i) => lookup[c.charCodeAt(0)] = i); + let n = s.length; + let ret = new Uint8Array((6 * n) >> 3); + for (let i = 0, pos = 0, width = 0, carry = 0; i < n; i++) { + carry = (carry << 6) | lookup[s.charCodeAt(i)]; + width += 6; + if (width >= 8) { + ret[pos++] = (carry >> (width -= 8)); + } + } + return ret; +} + +// eg. [0,1,2,3...] => [0,-1,1,-2,...] +function signed(i) { + return (i & 1) ? (~i >> 1) : (i >> 1); +} + +function read_deltas(n, next) { + let v = Array(n); + for (let i = 0, x = 0; i < n; i++) v[i] = x += signed(next()); + return v; +} + +// [123][5] => [0 3] [1 1] [0 0] +function read_sorted(next, prev = 0) { + let ret = []; + while (true) { + let x = next(); + let n = next(); + if (!n) break; + prev += x; + for (let i = 0; i < n; i++) { + ret.push(prev + i); + } + prev += n + 1; + } + return ret; +} + +function read_sorted_arrays(next) { + return read_array_while(() => { + let v = read_sorted(next); + if (v.length) return v; + }); +} + +// returns map of x => ys +function read_mapped(next) { + let ret = []; + while (true) { + let w = next(); + if (w == 0) break; + ret.push(read_linear_table(w, next)); + } + while (true) { + let w = next() - 1; + if (w < 0) break; + ret.push(read_replacement_table(w, next)); + } + return ret.flat(); +} + +// read until next is falsy +// return array of read values +function read_array_while(next) { + let v = []; + while (true) { + let x = next(v.length); + if (!x) break; + v.push(x); + } + return v; +} + +// read w columns of length n +// return as n rows of length w +function read_transposed(n, w, next) { + let m = Array(n).fill().map(() => []); + for (let i = 0; i < w; i++) { + read_deltas(n, next).forEach((x, j) => m[j].push(x)); + } + return m; +} + +// returns [[x, ys], [x+dx, ys+dy], [x+2*dx, ys+2*dy], ...] +// where dx/dy = steps, n = run size, w = length of y +function read_linear_table(w, next) { + let dx = 1 + next(); + let dy = next(); + let vN = read_array_while(next); + let m = read_transposed(vN.length, 1+w, next); + return m.flatMap((v, i) => { + let [x, ...ys] = v; + return Array(vN[i]).fill().map((_, j) => { + let j_dy = j * dy; + return [x + j * dx, ys.map(y => y + j_dy)]; + }); + }); +} + +// return [[x, ys...], ...] +// where w = length of y +function read_replacement_table(w, next) { + let n = 1 + next(); + let m = read_transposed(n, 1+w, next); + return m.map(v => [v[0], v.slice(1)]); +} + + +function read_trie(next) { + let ret = []; + let sorted = read_sorted(next); + expand(decode([]), []); + return ret; // not sorted + function decode(Q) { // characters that lead into this node + let S = next(); // state: valid, save, check + let B = read_array_while(() => { // buckets leading to new nodes + let cps = read_sorted(next).map(i => sorted[i]); + if (cps.length) return decode(cps); + }); + return {S, B, Q}; + } + function expand({S, B}, cps, saved) { + if (S & 4 && saved === cps[cps.length-1]) return; + if (S & 2) saved = cps[cps.length-1]; + if (S & 1) ret.push(cps); + for (let br of B) { + for (let cp of br.Q) { + expand(br, [...cps, cp], saved); + } + } + } +} + +function hex_cp(cp) { + return cp.toString(16).toUpperCase().padStart(2, '0'); +} + +function quote_cp(cp) { + return `{${hex_cp(cp)}}`; // raffy convention: like "\u{X}" w/o the "\u" +} + +/* +export function explode_cp(s) { + return [...s].map(c => c.codePointAt(0)); +} +*/ +function explode_cp(s) { // this is about 2x faster + let cps = []; + for (let pos = 0, len = s.length; pos < len; ) { + let cp = s.codePointAt(pos); + pos += cp < 0x10000 ? 1 : 2; + cps.push(cp); + } + return cps; +} + +function str_from_cps(cps) { + const chunk = 4096; + let len = cps.length; + if (len < chunk) return String.fromCodePoint(...cps); + let buf = []; + for (let i = 0; i < len; ) { + buf.push(String.fromCodePoint(...cps.slice(i, i += chunk))); + } + return buf.join(''); +} + +function compare_arrays(a, b) { + let n = a.length; + let c = n - b.length; + for (let i = 0; c == 0 && i < n; i++) c = a[i] - b[i]; + return c; +} + +// created 2023-09-25T01:01:55.148Z +// compressed base64-encoded blob for include-nf data +// source: https://github.com/adraffy/ens-normalize.js/blob/main/src/make.js +// see: https://github.com/adraffy/ens-normalize.js#security +// SHA-256: a974b6f8541fc29d919bc85118af0a44015851fab5343f8679cb31be2bdb209e +var COMPRESSED = 'AEUDTAHBCFQATQDRADAAcgAgADQAFAAsABQAHwAOACQADQARAAoAFwAHABIACAAPAAUACwAFAAwABAAQAAMABwAEAAoABQAIAAIACgABAAQAFAALAAIACwABAAIAAQAHAAMAAwAEAAsADAAMAAwACgANAA0AAwAKAAkABAAdAAYAZwDSAdsDJgC0CkMB8xhZAqfoC190UGcThgBurwf7PT09Pb09AjgJum8OjDllxHYUKXAPxzq6tABAxgK8ysUvWAgMPT09PT09PSs6LT2HcgWXWwFLoSMEEEl5RFVMKvO0XQ8ExDdJMnIgsj26PTQyy8FfEQ8AY8IPAGcEbwRwBHEEcgRzBHQEdQR2BHcEeAR6BHsEfAR+BIAEgfndBQoBYgULAWIFDAFiBNcE2ATZBRAFEQUvBdALFAsVDPcNBw13DYcOMA4xDjMB4BllHI0B2grbAMDpHLkQ7QHVAPRNQQFnGRUEg0yEB2uaJF8AJpIBpob5AERSMAKNoAXqaQLUBMCzEiACnwRZEkkVsS7tANAsBG0RuAQLEPABv9HICTUBXigPZwRBApMDOwAamhtaABqEAY8KvKx3LQ4ArAB8UhwEBAVSagD8AEFZADkBIadVj2UMUgx5Il4ANQC9AxIB1BlbEPMAs30CGxlXAhwZKQIECBc6EbsCoxngzv7UzRQA8M0BawL6ZwkN7wABAD33OQRcsgLJCjMCjqUChtw/km+NAsXPAoP2BT84PwURAK0RAvptb6cApQS/OMMey5HJS84UdxpxTPkCogVFITaTOwERAK5pAvkNBOVyA7q3BKlOJSALAgUIBRcEdASpBXqzABXFSWZOawLCOqw//AolCZdvv3dSBkEQGyelEPcMMwG1ATsN7UvYBPEGOwTJH30ZGQ/NlZwIpS3dDO0m4y6hgFoj9SqDBe1L9DzdC01RaA9ZC2UJ4zpjgU4DIQENIosK3Q05CG0Q8wrJaw3lEUUHOQPVSZoApQcBCxEdNRW1JhBirAsJOXcG+xr2C48mrxMpevwF0xohBk0BKRr/AM8u54WwWjFcHE9fBgMLJSPHFKhQIA0lQLd4SBobBxUlqQKRQ3BKh1E2HpMh9jw9DWYuE1F8B/U8BRlPC4E8nkarRQ4R0j6NPUgiSUwsBDV/LC8niwnPD4UMuXxyAVkJIQmxDHETMREXN8UIOQcZLZckJxUIIUaVYJoE958D8xPRAwsFPwlBBxMDtRwtEy4VKQUNgSTXAvM21S6zAo9WgAEXBcsPJR/fEFBH4A7pCJsCZQODJesALRUhABcimwhDYwBfj9hTBS7LCMdqbCN0A2cU52ERcweRDlcHpxwzFb8c4XDIXguGCCijrwlbAXUJmQFfBOMICTVbjKAgQWdTi1gYmyBhQT9d/AIxDGUVn0S9h3gCiw9rEhsBNQFzBzkNAQJ3Ee0RaxCVCOuGBDW1M/g6JQRPIYMgEQonA09szgsnJvkM+GkBoxJiAww0PXfuZ6tgtiQX/QcZMsVBYCHxC5JPzQycGsEYQlQuGeQHvwPzGvMn6kFXBf8DowMTOk0z7gS9C2kIiwk/AEkOoxcH1xhqCnGM0AExiwG3mQNXkYMCb48GNwcLAGcLhwV55QAdAqcIowAFAM8DVwA5Aq0HnQAZAIVBAT0DJy8BIeUCjwOTCDHLAZUvAfMpBBvDDBUA9zduSgLDsQKAamaiBd1YAo4CSTUBTSUEBU5HUQOvceEA2wBLBhPfRwEVq0rLGuNDAd9vKwDHAPsABTUHBUEBzQHzbQC3AV8LMQmis7UBTekpAIMAFWsB1wKJAN0ANQB/8QFTAE0FWfkF0wJPSQERMRgrV2EBuwMfATMBDQB5BsuNpckHHwRtB9MCEBsV4QLvLge1AQMi3xPNQsUCvd5VoWACZIECYkJbTa9bNyACofcCaJgCZgkCn4Q4GwsCZjsCZiYEbgR/A38TA36SOQY5dxc5gjojIwJsHQIyNjgKAm3HAm2u74ozZ0UrAWcA3gDhAEoFB5gMjQD+C8IADbUCdy8CdqI/AnlLQwJ4uh1c20WuRtcCfD8CesgCfQkCfPAFWQUgSABIfWMkAoFtAoAAAoAFAn+uSVhKWxUXSswC0QEC0MxLJwOITwOH5kTFkTIC8qFdAwMDrkvOTC0lA89NTE2vAos/AorYwRsHHUNnBbcCjjcCjlxAl4ECjtkCjlx4UbRTNQpS1FSFApP7ApMMAOkAHFUeVa9V0AYsGymVhjLheGZFOzkCl58C77JYIagAWSUClo8ClnycAKlZrFoJgU0AOwKWtQKWTlxEXNECmcsCmWRcyl0HGQKcmznCOp0CnBYCn5sCnriKAB0PMSoPAp3xAp6SALU9YTRh7wKe0wKgbgGpAp6fHwKeTqVjyGQnJSsCJ68CJn4CoPsCoEwCot0CocQCpi8Cpc4Cp/8AfQKn8mh8aLEAA0lqHGrRAqzjAqyuAq1nAq0CAlcdAlXcArHh1wMfTmyXArK9DQKy6Bds4G1jbUhfAyXNArZcOz9ukAMpRQK4XgK5RxUCuSp3cDZw4QK9GQK72nCWAzIRAr6IcgIDM3ECvhpzInNPAsPLAsMEc4J0SzVFdOADPKcDPJoDPb8CxXwCxkcCxhCJAshpUQLIRALJTwLJLgJknQLd0nh5YXiueSVL0AMYo2cCAmH0GfOVJHsLXpJeuxECz2sCz2wvS1PS8xOfAMatAs9zASnqA04SfksFAtwnAtuKAtJPA1JcA1NfAQEDVYyAiT8AyxbtYEWCHILTgs6DjQLaxwLZ3oQQhEmnPAOGpQAvA2QOhnFZ+QBVAt9lAt64c3cC4i/tFAHzMCcB9JsB8tKHAuvzAulweQLq+QLq5AD5RwG5Au6JAuuclqqXAwLuPwOF4Jh5cOBxoQLzAwBpA44WmZMC9xMDkW4DkocC95gC+dkC+GaaHJqruzebHgOdgwL++gEbADmfHJ+zAwWNA6ZqA6bZANHFAwZqoYiiBQkDDEkCwAA/AwDhQRdTARHzA2sHl2cFAJMtK7evvdsBiZkUfxEEOQH7KQUhDp0JnwCS/SlXxQL3AZ0AtwW5AG8LbUEuFCaNLgFDAYD8AbUmAHUDDgRtACwCFgyhAAAKAj0CagPdA34EkQEgRQUhfAoABQBEABMANhICdwEABdUDa+8KxQIA9wqfJ7+xt+UBkSFBQgHpFH8RNMCJAAQAGwBaAkUChIsABjpTOpSNbQC4Oo860ACNOME63AClAOgAywE6gTo7Ofw5+Tt2iTpbO56JOm85GAFWATMBbAUvNV01njWtNWY1dTW2NcU1gjWRNdI14TWeNa017jX9NbI1wTYCNhE1xjXVNhY2JzXeNe02LjY9Ni41LSE2OjY9Njw2yTcIBJA8VzY4Nt03IDcPNsogN4k3MAoEsDxnNiQ3GTdsOo03IULUQwdC4EMLHA8PCZsobShRVQYA6X8A6bABFCnXAukBowC9BbcAbwNzBL8MDAMMAQgDAAkKCwsLCQoGBAVVBI/DvwDz9b29kaUCb0QtsRTNLt4eGBcSHAMZFhYZEhYEARAEBUEcQRxBHEEcQRxBHEEaQRxBHEFCSTxBPElISUhBNkM2QTYbNklISVmBVIgBFLWZAu0BhQCjBcEAbykBvwGJAaQcEZ0ePCklMAAhMvAIMAL54gC7Bm8EescjzQMpARQpKgDUABavAj626xQAJP0A3etzuf4NNRA7efy2Z9NQrCnC0OSyANz5BBIbJ5IFDR6miIavYS6tprjjmuKebxm5C74Q225X1pkaYYPb6f1DK4k3xMEBb9S2WMjEibTNWhsRJIA+vwNVEiXTE5iXs/wezV66oFLfp9NZGYW+Gk19J2+bCT6Ye2w6LDYdgzKMUabk595eLBCXANz9HUpWbATq9vqXVx9XDg+Pc9Xp4+bsS005SVM/BJBM4687WUuf+Uj9dEi8aDNaPxtpbDxcG1THTImUMZq4UCaaNYpsVqraNyKLJXDYsFZ/5jl7bLRtO88t7P3xZaAxhb5OdPMXqsSkp1WCieG8jXm1U99+blvLlXzPCS+M93VnJCiK+09LfaSaBAVBomyDgJua8dfUzR7ga34IvR2Nvj+A9heJ6lsl1KG4NkI1032Cnff1m1wof2B9oHJK4bi6JkEdSqeNeiuo6QoZZincoc73/TH9SXF8sCE7XyuYyW8WSgbGFCjPV0ihLKhdPs08Tx82fYAkLLc4I2wdl4apY7GU5lHRFzRWJep7Ww3wbeA3qmd59/86P4xuNaqDpygXt6M85glSBHOCGgJDnt+pN9bK7HApMguX6+06RZNjzVmcZJ+wcUrJ9//bpRNxNuKpNl9uFds+S9tdx7LaM5ZkIrPj6nIU9mnbFtVbs9s/uLgl8MVczAwet+iOEzzBlYW7RCMgE6gyNLeq6+1tIx4dpgZnd0DksJS5f+JNDpwwcPNXaaVspq1fbQajOrJgK0ofKtJ1Ne90L6VO4MOl5S886p7u6xo7OLjG8TGL+HU1JXGJgppg4nNbNJ5nlzSpuPYy21JUEcUA94PoFiZfjZue+QnyQ80ekOuZVkxx4g+cvhJfHgNl4hy1/a6+RKcKlar/J29y//EztlbVPHVUeQ1zX86eQVAjR/M3dA9w4W8LfaXp4EgM85wOWasli837PzVMOnsLzR+k3o75/lRPAJSE1xAKQzEi5v10ke+VBvRt1cwQRMd+U5mLCTGVd6XiZtgBG5cDi0w22GKcVNvHiu5LQbZEDVtz0onn7k5+heuKXVsZtSzilkLRAUmjMXEMB3J9YC50XBxPiz53SC+EhnPl9WsKCv92SM/OFFIMJZYfl0WW8tIO3UxYcwdMAj7FSmgrsZ2aAZO03BOhP1bNNZItyXYQFTpC3SG1VuPDqH9GkiCDmE+JwxyIVSO5siDErAOpEXFgjy6PQtOVDj+s6e1r8heWVvmZnTciuf4EiNZzCAd7SOMhXERIOlsHIMG399i9aLTy3m2hRLZjJVDNLS53iGIK11dPqQt0zBDyg6qc7YqkDm2M5Ve6dCWCaCbTXX2rToaIgz6+zh4lYUi/+6nqcFMAkQJKHYLK0wYk5N9szV6xihDbDDFr45lN1K4aCXBq/FitPSud9gLt5ZVn+ZqGX7cwm2z5EGMgfFpIFyhGGuDPmso6TItTMwny+7uPnLCf4W6goFQFV0oQSsc9VfMmVLcLr6ZetDZbaSFTLqnSO/bIPjA3/zAUoqgGFAEQS4IhuMzEp2I3jJzbzkk/IEmyax+rhZTwd6f+CGtwPixu8IvzACquPWPREu9ZvGkUzpRwvRRuaNN6cr0W1wWits9ICdYJ7ltbgMiSL3sTPeufgNcVqMVWFkCPDH4jG2jA0XcVgQj62Cb29v9f/z/+2KbYvIv/zzjpQAPkliaVDzNrW57TZ/ZOyZD0nlfMmAIBIAGAI0D3k/mdN4xr9v85ZbZbbqfH2jGd5hUqNZWwl5SPfoGmfElmazUIeNL1j/mkF7VNAzTq4jNt8JoQ11NQOcmhprXoxSxfRGJ9LDEOAQ+dmxAQH90iti9e2u/MoeuaGcDTHoC+xsmEeWmxEKefQuIzHbpw5Tc5cEocboAD09oipWQhtTO1wivf/O+DRe2rpl/E9wlrzBorjJsOeG1B/XPW4EaJEFdNlECEZga5ZoGRHXgYouGRuVkm8tDESiEyFNo+3s5M5puSdTyUL2llnINVHEt91XUNW4ewdMgJ4boJfEyt/iY5WXqbA+A2Fkt5Z0lutiWhe9nZIyIUjyXDC3UsaG1t+eNx6z4W/OYoTB7A6x+dNSTOi9AInctbESqm5gvOLww7OWXPrmHwVZasrl4eD113pm+JtT7JVOvnCXqdzzdTRHgJ0PiGTFYW5Gvt9R9LD6Lzfs0v/TZZHSmyVNq7viIHE6DBK7Qp07Iz55EM8SYtQvZf/obBniTWi5C2/ovHfw4VndkE5XYdjOhCMRjDeOEfXeN/CwfGduiUIfsoFeUxXeQXba7c7972XNv8w+dTjjUM0QeNAReW+J014dKAD/McQYXT7c0GQPIkn3Ll6R7gGjuiQoZD0TEeEqQpKoZ15g/0OPQI17QiSv9AUROa/V/TQN3dvLArec3RrsYlvBm1b8LWzltdugsC50lNKYLEp2a+ZZYqPejULRlOJh5zj/LVMyTDvwKhMxxwuDkxJ1QpoNI0OTWLom4Z71SNzI9TV1iXJrIu9Wcnd+MCaAw8o1jSXd94YU/1gnkrC9BUEOtQvEIQ7g0i6h+KL2JKk8Ydl7HruvgWMSAmNe+LshGhV4qnWHhO9/RIPQzY1tHRj2VqOyNsDpK0cww+56AdDC4gsWwY0XxoucIWIqs/GcwnWqlaT0KPr8mbK5U94/301i1WLt4YINTVvCFBrFZbIbY8eycOdeJ2teD5IfPLCRg7jjcFTwlMFNl9zdh/o3E/hHPwj7BWg0MU09pPrBLbrCgm54A6H+I6v27+jL5gkjWg/iYdks9jbfVP5y/n0dlgWEMlKasl7JvFZd56LfybW1eeaVO0gxTfXZwD8G4SI116yx7UKVRgui6Ya1YpixqXeNLc8IxtAwCU5IhwQgn+NqHnRaDv61CxKhOq4pOX7M6pkA+Pmpd4j1vn6ACUALoLLc4vpXci8VidLxzm7qFBe7s+quuJs6ETYmnpgS3LwSZxPIltgBDXz8M1k/W2ySNv2f9/NPhxLGK2D21dkHeSGmenRT3Yqcdl0m/h3OYr8V+lXNYGf8aCCpd4bWjE4QIPj7vUKN4Nrfs7ML6Y2OyS830JCnofg/k7lpFpt4SqZc5HGg1HCOrHvOdC8bP6FGDbE/VV0mX4IakzbdS/op+Kt3G24/8QbBV7y86sGSQ/vZzU8FXs7u6jIvwchsEP2BpIhW3G8uWNwa3HmjfH/ZjhhCWvluAcF+nMf14ClKg5hGgtPLJ98ueNAkc5Hs2WZlk2QHvfreCK1CCGO6nMZVSb99VM/ajr8WHTte9JSmkXq/i/U943HEbdzW6Re/S88dKgg8pGOLlAeNiqrcLkUR3/aClFpMXcOUP3rmETcWSfMXZE3TUOi8i+fqRnTYLflVx/Vb/6GJ7eIRZUA6k3RYR3iFSK9c4iDdNwJuZL2FKz/IK5VimcNWEqdXjSoxSgmF0UPlDoUlNrPcM7ftmA8Y9gKiqKEHuWN+AZRIwtVSxye2Kf8rM3lhJ5XcBXU9n4v0Oy1RU2M+4qM8AQPVwse8ErNSob5oFPWxuqZnVzo1qB/IBxkM3EVUKFUUlO3e51259GgNcJbCmlvrdjtoTW7rChm1wyCKzpCTwozUUEOIcWLneRLgMXh+SjGSFkAllzbGS5HK7LlfCMRNRDSvbQPjcXaenNYxCvu2Qyznz6StuxVj66SgI0T8B6/sfHAJYZaZ78thjOSIFumNWLQbeZixDCCC+v0YBtkxiBB3jefHqZ/dFHU+crbj6OvS1x/JDD7vlm7zOVPwpUC01nhxZuY/63E7g'; + +// https://unicode.org/reports/tr15/ +// for reference implementation +// see: /derive/nf.js + + +// algorithmic hangul +// https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf (page 144) +const S0 = 0xAC00; +const L0 = 0x1100; +const V0 = 0x1161; +const T0 = 0x11A7; +const L_COUNT = 19; +const V_COUNT = 21; +const T_COUNT = 28; +const N_COUNT = V_COUNT * T_COUNT; +const S_COUNT = L_COUNT * N_COUNT; +const S1 = S0 + S_COUNT; +const L1 = L0 + L_COUNT; +const V1 = V0 + V_COUNT; +const T1$1 = T0 + T_COUNT; + +function unpack_cc(packed) { + return (packed >> 24) & 0xFF; +} +function unpack_cp(packed) { + return packed & 0xFFFFFF; +} + +let SHIFTED_RANK, EXCLUSIONS, DECOMP, RECOMP; + +function init$1() { + //console.time('nf'); + let r = read_compressed_payload(COMPRESSED); + SHIFTED_RANK = new Map(read_sorted_arrays(r).flatMap((v, i) => v.map(x => [x, (i+1) << 24]))); // pre-shifted + EXCLUSIONS = new Set(read_sorted(r)); + DECOMP = new Map(); + RECOMP = new Map(); + for (let [cp, cps] of read_mapped(r)) { + if (!EXCLUSIONS.has(cp) && cps.length == 2) { + let [a, b] = cps; + let bucket = RECOMP.get(a); + if (!bucket) { + bucket = new Map(); + RECOMP.set(a, bucket); + } + bucket.set(b, cp); + } + DECOMP.set(cp, cps.reverse()); // stored reversed + } + //console.timeEnd('nf'); + // 20230905: 11ms +} + +function is_hangul(cp) { + return cp >= S0 && cp < S1; +} + +function compose_pair(a, b) { + if (a >= L0 && a < L1 && b >= V0 && b < V1) { + return S0 + (a - L0) * N_COUNT + (b - V0) * T_COUNT; + } else if (is_hangul(a) && b > T0 && b < T1$1 && (a - S0) % T_COUNT == 0) { + return a + (b - T0); + } else { + let recomp = RECOMP.get(a); + if (recomp) { + recomp = recomp.get(b); + if (recomp) { + return recomp; + } + } + return -1; + } +} + +function decomposed(cps) { + if (!SHIFTED_RANK) init$1(); + let ret = []; + let buf = []; + let check_order = false; + function add(cp) { + let cc = SHIFTED_RANK.get(cp); + if (cc) { + check_order = true; + cp |= cc; + } + ret.push(cp); + } + for (let cp of cps) { + while (true) { + if (cp < 0x80) { + ret.push(cp); + } else if (is_hangul(cp)) { + let s_index = cp - S0; + let l_index = s_index / N_COUNT | 0; + let v_index = (s_index % N_COUNT) / T_COUNT | 0; + let t_index = s_index % T_COUNT; + add(L0 + l_index); + add(V0 + v_index); + if (t_index > 0) add(T0 + t_index); + } else { + let mapped = DECOMP.get(cp); + if (mapped) { + buf.push(...mapped); + } else { + add(cp); + } + } + if (!buf.length) break; + cp = buf.pop(); + } + } + if (check_order && ret.length > 1) { + let prev_cc = unpack_cc(ret[0]); + for (let i = 1; i < ret.length; i++) { + let cc = unpack_cc(ret[i]); + if (cc == 0 || prev_cc <= cc) { + prev_cc = cc; + continue; + } + let j = i-1; + while (true) { + let tmp = ret[j+1]; + ret[j+1] = ret[j]; + ret[j] = tmp; + if (!j) break; + prev_cc = unpack_cc(ret[--j]); + if (prev_cc <= cc) break; + } + prev_cc = unpack_cc(ret[i]); + } + } + return ret; +} + +function composed_from_decomposed(v) { + let ret = []; + let stack = []; + let prev_cp = -1; + let prev_cc = 0; + for (let packed of v) { + let cc = unpack_cc(packed); + let cp = unpack_cp(packed); + if (prev_cp == -1) { + if (cc == 0) { + prev_cp = cp; + } else { + ret.push(cp); + } + } else if (prev_cc > 0 && prev_cc >= cc) { + if (cc == 0) { + ret.push(prev_cp, ...stack); + stack.length = 0; + prev_cp = cp; + } else { + stack.push(cp); + } + prev_cc = cc; + } else { + let composed = compose_pair(prev_cp, cp); + if (composed >= 0) { + prev_cp = composed; + } else if (prev_cc == 0 && cc == 0) { + ret.push(prev_cp); + prev_cp = cp; + } else { + stack.push(cp); + prev_cc = cc; + } + } + } + if (prev_cp >= 0) { + ret.push(prev_cp, ...stack); + } + return ret; +} + +// note: cps can be iterable +function nfd(cps) { + return decomposed(cps).map(unpack_cp); +} +function nfc(cps) { + return composed_from_decomposed(decomposed(cps)); +} + +const HYPHEN = 0x2D; +const STOP_CH = '.'; +const FE0F = 0xFE0F; +const UNIQUE_PH = 1; + +// 20230913: replace [...v] with Array_from(v) to avoid large spreads +const Array_from = x => Array.from(x); // Array.from.bind(Array); + +function group_has_cp(g, cp) { + // 20230913: keep primary and secondary distinct instead of creating valid union + return g.P.has(cp) || g.Q.has(cp); +} + +class Emoji extends Array { + get is_emoji() { return true; } // free tagging system +} + +let MAPPED, IGNORED, CM, NSM, ESCAPE, GROUPS, WHOLE_VALID, WHOLE_MAP, VALID, EMOJI_LIST, EMOJI_ROOT; + +function init() { + if (MAPPED) return; + + let r = read_compressed_payload(COMPRESSED$1); + const read_sorted_array = () => read_sorted(r); + const read_sorted_set = () => new Set(read_sorted_array()); + const set_add_many = (set, v) => v.forEach(x => set.add(x)); + + MAPPED = new Map(read_mapped(r)); + IGNORED = read_sorted_set(); // ignored characters are not valid, so just read raw codepoints + + /* + // direct include from payload is smaller than the decompression code + const FENCED = new Map(read_array_while(() => { + let cp = r(); + if (cp) return [cp, read_str(r())]; + })); + */ + // 20230217: we still need all CM for proper error formatting + // but norm only needs NSM subset that are potentially-valid + CM = read_sorted_array(); + NSM = new Set(read_sorted_array().map(i => CM[i])); + CM = new Set(CM); + + ESCAPE = read_sorted_set(); // characters that should not be printed + read_sorted_set(); // only needed to illustrate ens_tokenize() transformations + + let chunks = read_sorted_arrays(r); + let unrestricted = r(); + //const read_chunked = () => new Set(read_sorted_array().flatMap(i => chunks[i]).concat(read_sorted_array())); + const read_chunked = () => { + // 20230921: build set in parts, 2x faster + let set = new Set(); + read_sorted_array().forEach(i => set_add_many(set, chunks[i])); + set_add_many(set, read_sorted_array()); + return set; + }; + GROUPS = read_array_while(i => { + // minifier property mangling seems unsafe + // so these are manually renamed to single chars + let N = read_array_while(r).map(x => x+0x60); + if (N.length) { + let R = i >= unrestricted; // unrestricted then restricted + N[0] -= 32; // capitalize + N = str_from_cps(N); + if (R) N=`Restricted[${N}]`; + let P = read_chunked(); // primary + let Q = read_chunked(); // secondary + let M = !r(); // not-whitelisted, check for NSM + // *** this code currently isn't needed *** + /* + let V = [...P, ...Q].sort((a, b) => a-b); // derive: sorted valid + let M = r()-1; // number of combining mark + if (M < 0) { // whitelisted + M = new Map(read_array_while(() => { + let i = r(); + if (i) return [V[i-1], read_array_while(() => { + let v = read_array_while(r); + if (v.length) return v.map(x => x-1); + })]; + })); + }*/ + return {N, P, Q, M, R}; + } + }); + + // decode compressed wholes + WHOLE_VALID = read_sorted_set(); + WHOLE_MAP = new Map(); + let wholes = read_sorted_array().concat(Array_from(WHOLE_VALID)).sort((a, b) => a-b); // must be sorted + wholes.forEach((cp, i) => { + let d = r(); + let w = wholes[i] = d ? wholes[i-d] : {V: [], M: new Map()}; + w.V.push(cp); // add to member set + if (!WHOLE_VALID.has(cp)) { + WHOLE_MAP.set(cp, w); // register with whole map + } + }); + + // compute confusable-extent complements + // usage: WHOLE_MAP.get(cp).M.get(cp) = complement set + for (let {V, M} of new Set(WHOLE_MAP.values())) { + // connect all groups that have each whole character + let recs = []; + for (let cp of V) { + let gs = GROUPS.filter(g => group_has_cp(g, cp)); + let rec = recs.find(({G}) => gs.some(g => G.has(g))); + if (!rec) { + rec = {G: new Set(), V: []}; + recs.push(rec); + } + rec.V.push(cp); + set_add_many(rec.G, gs); + } + // per character cache groups which are not a member of the extent + let union = recs.flatMap(x => Array_from(x.G)); // all of the groups used by this whole + for (let {G, V} of recs) { + let complement = new Set(union.filter(g => !G.has(g))); // groups not covered by the extent + for (let cp of V) { + M.set(cp, complement); // this is the same reference + } + } + } + + // compute valid set + // 20230924: VALID was union but can be re-used + VALID = new Set(); // exists in 1+ groups + let multi = new Set(); // exists in 2+ groups + const add_to_union = cp => VALID.has(cp) ? multi.add(cp) : VALID.add(cp); + for (let g of GROUPS) { + for (let cp of g.P) add_to_union(cp); + for (let cp of g.Q) add_to_union(cp); + } + // dual purpose WHOLE_MAP: return placeholder if unique non-confusable + for (let cp of VALID) { + if (!WHOLE_MAP.has(cp) && !multi.has(cp)) { + WHOLE_MAP.set(cp, UNIQUE_PH); + } + } + // add all decomposed parts + // see derive: "Valid is Closed (via Brute-force)" + set_add_many(VALID, nfd(VALID)); + + // decode emoji + // 20230719: emoji are now fully-expanded to avoid quirk logic + EMOJI_LIST = read_trie(r).map(v => Emoji.from(v)).sort(compare_arrays); + EMOJI_ROOT = new Map(); // this has approx 7K nodes (2+ per emoji) + for (let cps of EMOJI_LIST) { + // 20230719: change to *slightly* stricter algorithm which disallows + // insertion of misplaced FE0F in emoji sequences (matching ENSIP-15) + // example: beautified [A B] (eg. flag emoji) + // before: allow: [A FE0F B], error: [A FE0F FE0F B] + // after: error: both + // note: this code now matches ENSNormalize.{cs,java} logic + let prev = [EMOJI_ROOT]; + for (let cp of cps) { + let next = prev.map(node => { + let child = node.get(cp); + if (!child) { + // should this be object? + // (most have 1-2 items, few have many) + // 20230719: no, v8 default map is 4? + child = new Map(); + node.set(cp, child); + } + return child; + }); + if (cp === FE0F) { + prev.push(...next); // less than 20 elements + } else { + prev = next; + } + } + for (let x of prev) { + x.V = cps; + } + } +} + +// if escaped: {HEX} +// else: "x" {HEX} +function quoted_cp(cp) { + return (should_escape(cp) ? '' : `${bidi_qq(safe_str_from_cps([cp]))} `) + quote_cp(cp); +} + +// 20230211: some messages can be mixed-directional and result in spillover +// use 200E after a quoted string to force the remainder of a string from +// acquring the direction of the quote +// https://www.w3.org/International/questions/qa-bidi-unicode-controls#exceptions +function bidi_qq(s) { + return `"${s}"\u200E`; // strong LTR +} + +function check_label_extension(cps) { + if (cps.length >= 4 && cps[2] == HYPHEN && cps[3] == HYPHEN) { + throw new Error(`invalid label extension: "${str_from_cps(cps.slice(0, 4))}"`); // this can only be ascii so cant be bidi + } +} +function check_leading_underscore(cps) { + const UNDERSCORE = 0x5F; + for (let i = cps.lastIndexOf(UNDERSCORE); i > 0; ) { + if (cps[--i] !== UNDERSCORE) { + throw new Error('underscore allowed only at start'); + } + } +} +// check that a fenced cp is not leading, trailing, or touching another fenced cp +function check_fenced(cps) { + let cp = cps[0]; + let prev = FENCED.get(cp); + if (prev) throw error_placement(`leading ${prev}`); + let n = cps.length; + let last = -1; // prevents trailing from throwing + for (let i = 1; i < n; i++) { + cp = cps[i]; + let match = FENCED.get(cp); + if (match) { + // since cps[0] isn't fenced, cps[1] cannot throw + if (last == i) throw error_placement(`${prev} + ${match}`); + last = i + 1; + prev = match; + } + } + if (last == n) throw error_placement(`trailing ${prev}`); +} + +// create a safe to print string +// invisibles are escaped +// leading cm uses placeholder +// if cps exceed max, middle truncate with ellipsis +// quoter(cp) => string, eg. 3000 => "{3000}" +// note: in html, you'd call this function then replace [<>&] with entities +function safe_str_from_cps(cps, max = Infinity, quoter = quote_cp) { + //if (Number.isInteger(cps)) cps = [cps]; + //if (!Array.isArray(cps)) throw new TypeError(`expected codepoints`); + let buf = []; + if (is_combining_mark(cps[0])) buf.push('◌'); + if (cps.length > max) { + max >>= 1; + cps = [...cps.slice(0, max), 0x2026, ...cps.slice(-max)]; + } + let prev = 0; + let n = cps.length; + for (let i = 0; i < n; i++) { + let cp = cps[i]; + if (should_escape(cp)) { + buf.push(str_from_cps(cps.slice(prev, i))); + buf.push(quoter(cp)); + prev = i + 1; + } + } + buf.push(str_from_cps(cps.slice(prev, n))); + return buf.join(''); +} + +// note: set(s) cannot be exposed because they can be modified +// note: Object.freeze() doesn't work +function is_combining_mark(cp) { + init(); + return CM.has(cp); +} +function should_escape(cp) { + init(); + return ESCAPE.has(cp); +} + +function ens_normalize(name) { + return flatten(split(name, nfc, filter_fe0f)); +} + +function split(name, nf, ef) { + if (!name) return []; // 20230719: empty name allowance + init(); + let offset = 0; + // https://unicode.org/reports/tr46/#Validity_Criteria + // 4.) "The label must not contain a U+002E ( . ) FULL STOP." + return name.split(STOP_CH).map(label => { + let input = explode_cp(label); + let info = { + input, + offset, // codepoint, not substring! + }; + offset += input.length + 1; // + stop + try { + // 1.) "The label must be in Unicode Normalization Form NFC" + let tokens = info.tokens = tokens_from_str(input, nf, ef); + let token_count = tokens.length; + let type; + if (!token_count) { // the label was effectively empty (could of had ignored characters) + //norm = []; + //type = 'None'; // use this instead of next match, "ASCII" + // 20230120: change to strict + // https://discuss.ens.domains/t/ens-name-normalization-2nd/14564/59 + throw new Error(`empty label`); + } + let norm = info.output = tokens.flat(); + check_leading_underscore(norm); + let emoji = info.emoji = token_count > 1 || tokens[0].is_emoji; // same as: tokens.some(x => x.is_emoji); + if (!emoji && norm.every(cp => cp < 0x80)) { // special case for ascii + // 20230123: matches matches WHATWG, see note 3.3 + check_label_extension(norm); // only needed for ascii + // cant have fenced + // cant have cm + // cant have wholes + // see derive: "Fastpath ASCII" + type = 'ASCII'; + } else { + let chars = tokens.flatMap(x => x.is_emoji ? [] : x); // all of the nfc tokens concat together + if (!chars.length) { // theres no text, just emoji + type = 'Emoji'; + } else { + // 5.) "The label must not begin with a combining mark, that is: General_Category=Mark." + if (CM.has(norm[0])) throw error_placement('leading combining mark'); + for (let i = 1; i < token_count; i++) { // we've already checked the first token + let cps = tokens[i]; + if (!cps.is_emoji && CM.has(cps[0])) { // every text token has emoji neighbors, eg. EtEEEtEt... + // bidi_qq() not needed since emoji is LTR and cps is a CM + throw error_placement(`emoji + combining mark: "${str_from_cps(tokens[i-1])} + ${safe_str_from_cps([cps[0]])}"`); + } + } + check_fenced(norm); + let unique = Array_from(new Set(chars)); + let [g] = determine_group(unique); // take the first match + // see derive: "Matching Groups have Same CM Style" + // alternative: could form a hybrid type: Latin/Japanese/... + check_group(g, chars); // need text in order + check_whole(g, unique); // only need unique text (order would be required for multiple-char confusables) + type = g.N; + // 20230121: consider exposing restricted flag + // it's simpler to just check for 'Restricted' + // or even better: type.endsWith(']') + //if (g.R) info.restricted = true; + } + } + info.type = type; + } catch (err) { + info.error = err; // use full error object + } + return info; + }); +} + +function check_whole(group, unique) { + let maker; + let shared = []; + for (let cp of unique) { + let whole = WHOLE_MAP.get(cp); + if (whole === UNIQUE_PH) return; // unique, non-confusable + if (whole) { + let set = whole.M.get(cp); // groups which have a character that look-like this character + maker = maker ? maker.filter(g => set.has(g)) : Array_from(set); + if (!maker.length) return; // confusable intersection is empty + } else { + shared.push(cp); + } + } + if (maker) { + // we have 1+ confusable + // check if any of the remaining groups + // contain the shared characters too + for (let g of maker) { + if (shared.every(cp => group_has_cp(g, cp))) { + throw new Error(`whole-script confusable: ${group.N}/${g.N}`); + } + } + } +} + +// assumption: unique.size > 0 +// returns list of matching groups +function determine_group(unique) { + let groups = GROUPS; + for (let cp of unique) { + // note: we need to dodge CM that are whitelisted + // but that code isn't currently necessary + let gs = groups.filter(g => group_has_cp(g, cp)); + if (!gs.length) { + if (!GROUPS.some(g => group_has_cp(g, cp))) { + // the character was composed of valid parts + // but it's NFC form is invalid + // 20230716: change to more exact statement, see: ENSNormalize.{cs,java} + // note: this doesn't have to be a composition + // 20230720: change to full check + throw error_disallowed(cp); // this should be rare + } else { + // there is no group that contains all these characters + // throw using the highest priority group that matched + // https://www.unicode.org/reports/tr39/#mixed_script_confusables + throw error_group_member(groups[0], cp); + } + } + groups = gs; + if (gs.length == 1) break; // there is only one group left + } + // there are at least 1 group(s) with all of these characters + return groups; +} + +// throw on first error +function flatten(split) { + return split.map(({input, error, output}) => { + if (error) { + // don't print label again if just a single label + let msg = error.message; + // bidi_qq() only necessary if msg is digits + throw new Error(split.length == 1 ? msg : `Invalid label ${bidi_qq(safe_str_from_cps(input, 63))}: ${msg}`); + } + return str_from_cps(output); + }).join(STOP_CH); +} + +function error_disallowed(cp) { + // TODO: add cp to error? + return new Error(`disallowed character: ${quoted_cp(cp)}`); +} +function error_group_member(g, cp) { + let quoted = quoted_cp(cp); + let gg = GROUPS.find(g => g.P.has(cp)); // only check primary + if (gg) { + quoted = `${gg.N} ${quoted}`; + } + return new Error(`illegal mixture: ${g.N} + ${quoted}`); +} +function error_placement(where) { + return new Error(`illegal placement: ${where}`); +} + +// assumption: cps.length > 0 +// assumption: cps[0] isn't a CM +// assumption: the previous character isn't an emoji +function check_group(g, cps) { + for (let cp of cps) { + if (!group_has_cp(g, cp)) { + // for whitelisted scripts, this will throw illegal mixture on invalid cm, eg. "e{300}{300}" + // at the moment, it's unnecessary to introduce an extra error type + // until there exists a whitelisted multi-character + // eg. if (M < 0 && is_combining_mark(cp)) { ... } + // there are 3 cases: + // 1. illegal cm for wrong group => mixture error + // 2. illegal cm for same group => cm error + // requires set of whitelist cm per group: + // eg. new Set([...g.P, ...g.Q].flatMap(nfc).filter(cp => CM.has(cp))) + // 3. wrong group => mixture error + throw error_group_member(g, cp); + } + } + //if (M >= 0) { // we have a known fixed cm count + if (g.M) { // we need to check for NSM + let decomposed = nfd(cps); + for (let i = 1, e = decomposed.length; i < e; i++) { // see: assumption + // 20230210: bugfix: using cps instead of decomposed h/t Carbon225 + /* + if (CM.has(decomposed[i])) { + let j = i + 1; + while (j < e && CM.has(decomposed[j])) j++; + if (j - i > M) { + throw new Error(`too many combining marks: ${g.N} ${bidi_qq(str_from_cps(decomposed.slice(i-1, j)))} (${j-i}/${M})`); + } + i = j; + } + */ + // 20230217: switch to NSM counting + // https://www.unicode.org/reports/tr39/#Optional_Detection + if (NSM.has(decomposed[i])) { + let j = i + 1; + for (let cp; j < e && NSM.has(cp = decomposed[j]); j++) { + // a. Forbid sequences of the same nonspacing mark. + for (let k = i; k < j; k++) { // O(n^2) but n < 100 + if (decomposed[k] == cp) { + throw new Error(`duplicate non-spacing marks: ${quoted_cp(cp)}`); + } + } + } + // parse to end so we have full nsm count + // b. Forbid sequences of more than 4 nonspacing marks (gc=Mn or gc=Me). + if (j - i > NSM_MAX) { + // note: this slice starts with a base char or spacing-mark cm + throw new Error(`excessive non-spacing marks: ${bidi_qq(safe_str_from_cps(decomposed.slice(i-1, j)))} (${j-i}/${NSM_MAX})`); + } + i = j; + } + } + } + // *** this code currently isn't needed *** + /* + let cm_whitelist = M instanceof Map; + for (let i = 0, e = cps.length; i < e; ) { + let cp = cps[i++]; + let seqs = cm_whitelist && M.get(cp); + if (seqs) { + // list of codepoints that can follow + // if this exists, this will always be 1+ + let j = i; + while (j < e && CM.has(cps[j])) j++; + let cms = cps.slice(i, j); + let match = seqs.find(seq => !compare_arrays(seq, cms)); + if (!match) throw new Error(`disallowed combining mark sequence: "${safe_str_from_cps([cp, ...cms])}"`); + i = j; + } else if (!V.has(cp)) { + // https://www.unicode.org/reports/tr39/#mixed_script_confusables + let quoted = quoted_cp(cp); + for (let cp of cps) { + let u = UNIQUE.get(cp); + if (u && u !== g) { + // if both scripts are restricted this error is confusing + // because we don't differentiate RestrictedA from RestrictedB + if (!u.R) quoted = `${quoted} is ${u.N}`; + break; + } + } + throw new Error(`disallowed ${g.N} character: ${quoted}`); + //throw new Error(`disallowed character: ${quoted} (expected ${g.N})`); + //throw new Error(`${g.N} does not allow: ${quoted}`); + } + } + if (!cm_whitelist) { + let decomposed = nfd(cps); + for (let i = 1, e = decomposed.length; i < e; i++) { // we know it can't be cm leading + if (CM.has(decomposed[i])) { + let j = i + 1; + while (j < e && CM.has(decomposed[j])) j++; + if (j - i > M) { + throw new Error(`too many combining marks: "${str_from_cps(decomposed.slice(i-1, j))}" (${j-i}/${M})`); + } + i = j; + } + } + } + */ +} + +// given a list of codepoints +// returns a list of lists, where emoji are a fully-qualified (as Array subclass) +// eg. explode_cp("abc💩d") => [[61, 62, 63], Emoji[1F4A9, FE0F], [64]] +// 20230818: rename for 'process' name collision h/t Javarome +// https://github.com/adraffy/ens-normalize.js/issues/23 +function tokens_from_str(input, nf, ef) { + let ret = []; + let chars = []; + input = input.slice().reverse(); // flip so we can pop + while (input.length) { + let emoji = consume_emoji_reversed(input); + if (emoji) { + if (chars.length) { + ret.push(nf(chars)); + chars = []; + } + ret.push(ef(emoji)); + } else { + let cp = input.pop(); + if (VALID.has(cp)) { + chars.push(cp); + } else { + let cps = MAPPED.get(cp); + if (cps) { + chars.push(...cps); // less than 10 elements + } else if (!IGNORED.has(cp)) { + // 20230912: unicode 15.1 changed the order of processing such that + // disallowed parts are only rejected after NFC + // https://unicode.org/reports/tr46/#Validity_Criteria + // this doesn't impact normalization as of today + // technically, this error can be removed as the group logic will apply similar logic + // however the error type might be less clear + throw error_disallowed(cp); + } + } + } + } + if (chars.length) { + ret.push(nf(chars)); + } + return ret; +} + +function filter_fe0f(cps) { + return cps.filter(cp => cp != FE0F); +} + +// given array of codepoints +// returns the longest valid emoji sequence (or undefined if no match) +// *MUTATES* the supplied array +// disallows interleaved ignored characters +// fills (optional) eaten array with matched codepoints +function consume_emoji_reversed(cps, eaten) { + let node = EMOJI_ROOT; + let emoji; + let pos = cps.length; + while (pos) { + node = node.get(cps[--pos]); + if (!node) break; + let {V} = node; + if (V) { // this is a valid emoji (so far) + emoji = V; + if (eaten) eaten.push(...cps.slice(pos).reverse()); // (optional) copy input, used for ens_tokenize() + cps.length = pos; // truncate + } + } + return emoji; +} + +const Zeros = new Uint8Array(32); +Zeros.fill(0); +function checkComponent(comp) { + assertArgument(comp.length !== 0, "invalid ENS name; empty component", "comp", comp); + return comp; +} +function ensNameSplit(name) { + const bytes = toUtf8Bytes$1(ensNormalize(name)); + const comps = []; + if (name.length === 0) { + return comps; + } + let last = 0; + for (let i = 0; i < bytes.length; i++) { + const d = bytes[i]; + // A separator (i.e. "."); copy this component + if (d === 0x2e) { + comps.push(checkComponent(bytes.slice(last, i))); + last = i + 1; + } + } + // There was a stray separator at the end of the name + assertArgument(last < bytes.length, "invalid ENS name; empty component", "name", name); + comps.push(checkComponent(bytes.slice(last))); + return comps; +} +/** + * Returns the ENS %%name%% normalized. + */ +function ensNormalize(name) { + try { + if (name.length === 0) { + throw new Error("empty label"); + } + return ens_normalize(name); + } + catch (error) { + assertArgument(false, `invalid ENS name (${error.message})`, "name", name); + } +} +/** + * Returns the [[link-namehash]] for %%name%%. + */ +function namehash(name) { + assertArgument(typeof (name) === "string", "invalid ENS name; not a string", "name", name); + assertArgument(name.length, `invalid ENS name (empty label)`, "name", name); + let result = Zeros; + const comps = ensNameSplit(name); + while (comps.length) { + result = keccak256$1(concat$3([result, keccak256$1((comps.pop()))])); + } + return hexlify(result); +} +/** + * Returns the DNS encoded %%name%%. + * + * This is used for various parts of ENS name resolution, such + * as the wildcard resolution. + */ +function dnsEncode(name, _maxLength) { + const length = (_maxLength != null) ? _maxLength : 63; + assertArgument(length <= 255, "DNS encoded label cannot exceed 255", "length", length); + return hexlify(concat$3(ensNameSplit(name).map((comp) => { + assertArgument(comp.length <= length, `label ${JSON.stringify(name)} exceeds ${length} bytes`, "name", name); + const bytes = new Uint8Array(comp.length + 1); + bytes.set(comp, 1); + bytes[0] = bytes.length - 1; + return bytes; + }))) + "00"; +} + +function accessSetify(addr, storageKeys) { + return { + address: getAddress(addr), + storageKeys: storageKeys.map((storageKey, index) => { + assertArgument(isHexString$1(storageKey, 32), "invalid slot", `storageKeys[${index}]`, storageKey); + return storageKey.toLowerCase(); + }) + }; +} +/** + * Returns a [[AccessList]] from any ethers-supported access-list structure. + */ +function accessListify(value) { + if (Array.isArray(value)) { + return value.map((set, index) => { + if (Array.isArray(set)) { + assertArgument(set.length === 2, "invalid slot set", `value[${index}]`, set); + return accessSetify(set[0], set[1]); + } + assertArgument(set != null && typeof (set) === "object", "invalid address-slot set", "value", value); + return accessSetify(set.address, set.storageKeys); + }); + } + assertArgument(value != null && typeof (value) === "object", "invalid access list", "value", value); + const result = Object.keys(value).map((addr) => { + const storageKeys = value[addr].reduce((accum, storageKey) => { + accum[storageKey] = true; + return accum; + }, {}); + return accessSetify(addr, Object.keys(storageKeys).sort()); + }); + result.sort((a, b) => (a.address.localeCompare(b.address))); + return result; +} + +/** + * Returns the address for the %%key%%. + * + * The key may be any standard form of public key or a private key. + */ +function computeAddress(key) { + let pubkey; + if (typeof (key) === "string") { + pubkey = SigningKey.computePublicKey(key, false); + } + else { + pubkey = key.publicKey; + } + return getAddress(keccak256$1("0x" + pubkey.substring(4)).substring(26)); +} +/** + * Returns the recovered address for the private key that was + * used to sign %%digest%% that resulted in %%signature%%. + */ +function recoverAddress(digest, signature) { + return computeAddress(SigningKey.recoverPublicKey(digest, signature)); +} + +const BN_0$4 = BigInt(0); +const BN_2$1 = BigInt(2); +const BN_27 = BigInt(27); +const BN_28 = BigInt(28); +const BN_35 = BigInt(35); +const BN_MAX_UINT = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); +const BLOB_SIZE = 4096 * 32; +function getVersionedHash(version, hash) { + let versioned = version.toString(16); + while (versioned.length < 2) { + versioned = "0" + versioned; + } + versioned += sha256(hash).substring(4); + return "0x" + versioned; +} +function handleAddress(value) { + if (value === "0x") { + return null; + } + return getAddress(value); +} +function handleAccessList(value, param) { + try { + return accessListify(value); + } + catch (error) { + assertArgument(false, error.message, param, value); + } +} +function handleNumber(_value, param) { + if (_value === "0x") { + return 0; + } + return getNumber(_value, param); +} +function handleUint(_value, param) { + if (_value === "0x") { + return BN_0$4; + } + const value = getBigInt(_value, param); + assertArgument(value <= BN_MAX_UINT, "value exceeds uint size", param, value); + return value; +} +function formatNumber(_value, name) { + const value = getBigInt(_value, "value"); + const result = toBeArray(value); + assertArgument(result.length <= 32, `value too large`, `tx.${name}`, value); + return result; +} +function formatAccessList(value) { + return accessListify(value).map((set) => [set.address, set.storageKeys]); +} +function formatHashes(value, param) { + assertArgument(Array.isArray(value), `invalid ${param}`, "value", value); + for (let i = 0; i < value.length; i++) { + assertArgument(isHexString$1(value[i], 32), "invalid ${ param } hash", `value[${i}]`, value[i]); + } + return value; +} +function _parseLegacy(data) { + const fields = decodeRlp(data); + assertArgument(Array.isArray(fields) && (fields.length === 9 || fields.length === 6), "invalid field count for legacy transaction", "data", data); + const tx = { + type: 0, + nonce: handleNumber(fields[0], "nonce"), + gasPrice: handleUint(fields[1], "gasPrice"), + gasLimit: handleUint(fields[2], "gasLimit"), + to: handleAddress(fields[3]), + value: handleUint(fields[4], "value"), + data: hexlify(fields[5]), + chainId: BN_0$4 + }; + // Legacy unsigned transaction + if (fields.length === 6) { + return tx; + } + const v = handleUint(fields[6], "v"); + const r = handleUint(fields[7], "r"); + const s = handleUint(fields[8], "s"); + if (r === BN_0$4 && s === BN_0$4) { + // EIP-155 unsigned transaction + tx.chainId = v; + } + else { + // Compute the EIP-155 chain ID (or 0 for legacy) + let chainId = (v - BN_35) / BN_2$1; + if (chainId < BN_0$4) { + chainId = BN_0$4; + } + tx.chainId = chainId; + // Signed Legacy Transaction + assertArgument(chainId !== BN_0$4 || (v === BN_27 || v === BN_28), "non-canonical legacy v", "v", fields[6]); + tx.signature = Signature.from({ + r: zeroPadValue(fields[7], 32), + s: zeroPadValue(fields[8], 32), + v + }); + //tx.hash = keccak256(data); + } + return tx; +} +function _serializeLegacy(tx, sig) { + const fields = [ + formatNumber(tx.nonce, "nonce"), + formatNumber(tx.gasPrice || 0, "gasPrice"), + formatNumber(tx.gasLimit, "gasLimit"), + (tx.to || "0x"), + formatNumber(tx.value, "value"), + tx.data, + ]; + let chainId = BN_0$4; + if (tx.chainId != BN_0$4) { + // A chainId was provided; if non-zero we'll use EIP-155 + chainId = getBigInt(tx.chainId, "tx.chainId"); + // We have a chainId in the tx and an EIP-155 v in the signature, + // make sure they agree with each other + assertArgument(!sig || sig.networkV == null || sig.legacyChainId === chainId, "tx.chainId/sig.v mismatch", "sig", sig); + } + else if (tx.signature) { + // No explicit chainId, but EIP-155 have a derived implicit chainId + const legacy = tx.signature.legacyChainId; + if (legacy != null) { + chainId = legacy; + } + } + // Requesting an unsigned transaction + if (!sig) { + // We have an EIP-155 transaction (chainId was specified and non-zero) + if (chainId !== BN_0$4) { + fields.push(toBeArray(chainId)); + fields.push("0x"); + fields.push("0x"); + } + return encodeRlp(fields); + } + // @TODO: We should probably check that tx.signature, chainId, and sig + // match but that logic could break existing code, so schedule + // this for the next major bump. + // Compute the EIP-155 v + let v = BigInt(27 + sig.yParity); + if (chainId !== BN_0$4) { + v = Signature.getChainIdV(chainId, sig.v); + } + else if (BigInt(sig.v) !== v) { + assertArgument(false, "tx.chainId/sig.v mismatch", "sig", sig); + } + // Add the signature + fields.push(toBeArray(v)); + fields.push(toBeArray(sig.r)); + fields.push(toBeArray(sig.s)); + return encodeRlp(fields); +} +function _parseEipSignature(tx, fields) { + let yParity; + try { + yParity = handleNumber(fields[0], "yParity"); + if (yParity !== 0 && yParity !== 1) { + throw new Error("bad yParity"); + } + } + catch (error) { + assertArgument(false, "invalid yParity", "yParity", fields[0]); + } + const r = zeroPadValue(fields[1], 32); + const s = zeroPadValue(fields[2], 32); + const signature = Signature.from({ r, s, yParity }); + tx.signature = signature; +} +function _parseEip1559(data) { + const fields = decodeRlp(getBytes(data).slice(1)); + assertArgument(Array.isArray(fields) && (fields.length === 9 || fields.length === 12), "invalid field count for transaction type: 2", "data", hexlify(data)); + const tx = { + type: 2, + chainId: handleUint(fields[0], "chainId"), + nonce: handleNumber(fields[1], "nonce"), + maxPriorityFeePerGas: handleUint(fields[2], "maxPriorityFeePerGas"), + maxFeePerGas: handleUint(fields[3], "maxFeePerGas"), + gasPrice: null, + gasLimit: handleUint(fields[4], "gasLimit"), + to: handleAddress(fields[5]), + value: handleUint(fields[6], "value"), + data: hexlify(fields[7]), + accessList: handleAccessList(fields[8], "accessList"), + }; + // Unsigned EIP-1559 Transaction + if (fields.length === 9) { + return tx; + } + //tx.hash = keccak256(data); + _parseEipSignature(tx, fields.slice(9)); + return tx; +} +function _serializeEip1559(tx, sig) { + const fields = [ + formatNumber(tx.chainId, "chainId"), + formatNumber(tx.nonce, "nonce"), + formatNumber(tx.maxPriorityFeePerGas || 0, "maxPriorityFeePerGas"), + formatNumber(tx.maxFeePerGas || 0, "maxFeePerGas"), + formatNumber(tx.gasLimit, "gasLimit"), + (tx.to || "0x"), + formatNumber(tx.value, "value"), + tx.data, + formatAccessList(tx.accessList || []) + ]; + if (sig) { + fields.push(formatNumber(sig.yParity, "yParity")); + fields.push(toBeArray(sig.r)); + fields.push(toBeArray(sig.s)); + } + return concat$3(["0x02", encodeRlp(fields)]); +} +function _parseEip2930(data) { + const fields = decodeRlp(getBytes(data).slice(1)); + assertArgument(Array.isArray(fields) && (fields.length === 8 || fields.length === 11), "invalid field count for transaction type: 1", "data", hexlify(data)); + const tx = { + type: 1, + chainId: handleUint(fields[0], "chainId"), + nonce: handleNumber(fields[1], "nonce"), + gasPrice: handleUint(fields[2], "gasPrice"), + gasLimit: handleUint(fields[3], "gasLimit"), + to: handleAddress(fields[4]), + value: handleUint(fields[5], "value"), + data: hexlify(fields[6]), + accessList: handleAccessList(fields[7], "accessList") + }; + // Unsigned EIP-2930 Transaction + if (fields.length === 8) { + return tx; + } + //tx.hash = keccak256(data); + _parseEipSignature(tx, fields.slice(8)); + return tx; +} +function _serializeEip2930(tx, sig) { + const fields = [ + formatNumber(tx.chainId, "chainId"), + formatNumber(tx.nonce, "nonce"), + formatNumber(tx.gasPrice || 0, "gasPrice"), + formatNumber(tx.gasLimit, "gasLimit"), + (tx.to || "0x"), + formatNumber(tx.value, "value"), + tx.data, + formatAccessList(tx.accessList || []) + ]; + if (sig) { + fields.push(formatNumber(sig.yParity, "recoveryParam")); + fields.push(toBeArray(sig.r)); + fields.push(toBeArray(sig.s)); + } + return concat$3(["0x01", encodeRlp(fields)]); +} +function _parseEip4844(data) { + let fields = decodeRlp(getBytes(data).slice(1)); + let typeName = "3"; + let blobs = null; + // Parse the network format + if (fields.length === 4 && Array.isArray(fields[0])) { + typeName = "3 (network format)"; + const fBlobs = fields[1], fCommits = fields[2], fProofs = fields[3]; + assertArgument(Array.isArray(fBlobs), "invalid network format: blobs not an array", "fields[1]", fBlobs); + assertArgument(Array.isArray(fCommits), "invalid network format: commitments not an array", "fields[2]", fCommits); + assertArgument(Array.isArray(fProofs), "invalid network format: proofs not an array", "fields[3]", fProofs); + assertArgument(fBlobs.length === fCommits.length, "invalid network format: blobs/commitments length mismatch", "fields", fields); + assertArgument(fBlobs.length === fProofs.length, "invalid network format: blobs/proofs length mismatch", "fields", fields); + blobs = []; + for (let i = 0; i < fields[1].length; i++) { + blobs.push({ + data: fBlobs[i], + commitment: fCommits[i], + proof: fProofs[i], + }); + } + fields = fields[0]; + } + assertArgument(Array.isArray(fields) && (fields.length === 11 || fields.length === 14), `invalid field count for transaction type: ${typeName}`, "data", hexlify(data)); + const tx = { + type: 3, + chainId: handleUint(fields[0], "chainId"), + nonce: handleNumber(fields[1], "nonce"), + maxPriorityFeePerGas: handleUint(fields[2], "maxPriorityFeePerGas"), + maxFeePerGas: handleUint(fields[3], "maxFeePerGas"), + gasPrice: null, + gasLimit: handleUint(fields[4], "gasLimit"), + to: handleAddress(fields[5]), + value: handleUint(fields[6], "value"), + data: hexlify(fields[7]), + accessList: handleAccessList(fields[8], "accessList"), + maxFeePerBlobGas: handleUint(fields[9], "maxFeePerBlobGas"), + blobVersionedHashes: fields[10] + }; + if (blobs) { + tx.blobs = blobs; + } + assertArgument(tx.to != null, `invalid address for transaction type: ${typeName}`, "data", data); + assertArgument(Array.isArray(tx.blobVersionedHashes), "invalid blobVersionedHashes: must be an array", "data", data); + for (let i = 0; i < tx.blobVersionedHashes.length; i++) { + assertArgument(isHexString$1(tx.blobVersionedHashes[i], 32), `invalid blobVersionedHash at index ${i}: must be length 32`, "data", data); + } + // Unsigned EIP-4844 Transaction + if (fields.length === 11) { + return tx; + } + // @TODO: Do we need to do this? This is only called internally + // and used to verify hashes; it might save time to not do this + //tx.hash = keccak256(concat([ "0x03", encodeRlp(fields) ])); + _parseEipSignature(tx, fields.slice(11)); + return tx; +} +function _serializeEip4844(tx, sig, blobs) { + const fields = [ + formatNumber(tx.chainId, "chainId"), + formatNumber(tx.nonce, "nonce"), + formatNumber(tx.maxPriorityFeePerGas || 0, "maxPriorityFeePerGas"), + formatNumber(tx.maxFeePerGas || 0, "maxFeePerGas"), + formatNumber(tx.gasLimit, "gasLimit"), + (tx.to || ZeroAddress), + formatNumber(tx.value, "value"), + tx.data, + formatAccessList(tx.accessList || []), + formatNumber(tx.maxFeePerBlobGas || 0, "maxFeePerBlobGas"), + formatHashes(tx.blobVersionedHashes || [], "blobVersionedHashes") + ]; + if (sig) { + fields.push(formatNumber(sig.yParity, "yParity")); + fields.push(toBeArray(sig.r)); + fields.push(toBeArray(sig.s)); + // We have blobs; return the network wrapped format + if (blobs) { + return concat$3([ + "0x03", + encodeRlp([ + fields, + blobs.map((b) => b.data), + blobs.map((b) => b.commitment), + blobs.map((b) => b.proof), + ]) + ]); + } + } + return concat$3(["0x03", encodeRlp(fields)]); +} +/** + * A **Transaction** describes an operation to be executed on + * Ethereum by an Externally Owned Account (EOA). It includes + * who (the [[to]] address), what (the [[data]]) and how much (the + * [[value]] in ether) the operation should entail. + * + * @example: + * tx = new Transaction() + * //_result: + * + * tx.data = "0x1234"; + * //_result: + */ +class Transaction { + #type; + #to; + #data; + #nonce; + #gasLimit; + #gasPrice; + #maxPriorityFeePerGas; + #maxFeePerGas; + #value; + #chainId; + #sig; + #accessList; + #maxFeePerBlobGas; + #blobVersionedHashes; + #kzg; + #blobs; + /** + * The transaction type. + * + * If null, the type will be automatically inferred based on + * explicit properties. + */ + get type() { return this.#type; } + set type(value) { + switch (value) { + case null: + this.#type = null; + break; + case 0: + case "legacy": + this.#type = 0; + break; + case 1: + case "berlin": + case "eip-2930": + this.#type = 1; + break; + case 2: + case "london": + case "eip-1559": + this.#type = 2; + break; + case 3: + case "cancun": + case "eip-4844": + this.#type = 3; + break; + default: + assertArgument(false, "unsupported transaction type", "type", value); + } + } + /** + * The name of the transaction type. + */ + get typeName() { + switch (this.type) { + case 0: return "legacy"; + case 1: return "eip-2930"; + case 2: return "eip-1559"; + case 3: return "eip-4844"; + } + return null; + } + /** + * The ``to`` address for the transaction or ``null`` if the + * transaction is an ``init`` transaction. + */ + get to() { + const value = this.#to; + if (value == null && this.type === 3) { + return ZeroAddress; + } + return value; + } + set to(value) { + this.#to = (value == null) ? null : getAddress(value); + } + /** + * The transaction nonce. + */ + get nonce() { return this.#nonce; } + set nonce(value) { this.#nonce = getNumber(value, "value"); } + /** + * The gas limit. + */ + get gasLimit() { return this.#gasLimit; } + set gasLimit(value) { this.#gasLimit = getBigInt(value); } + /** + * The gas price. + * + * On legacy networks this defines the fee that will be paid. On + * EIP-1559 networks, this should be ``null``. + */ + get gasPrice() { + const value = this.#gasPrice; + if (value == null && (this.type === 0 || this.type === 1)) { + return BN_0$4; + } + return value; + } + set gasPrice(value) { + this.#gasPrice = (value == null) ? null : getBigInt(value, "gasPrice"); + } + /** + * The maximum priority fee per unit of gas to pay. On legacy + * networks this should be ``null``. + */ + get maxPriorityFeePerGas() { + const value = this.#maxPriorityFeePerGas; + if (value == null) { + if (this.type === 2 || this.type === 3) { + return BN_0$4; + } + return null; + } + return value; + } + set maxPriorityFeePerGas(value) { + this.#maxPriorityFeePerGas = (value == null) ? null : getBigInt(value, "maxPriorityFeePerGas"); + } + /** + * The maximum total fee per unit of gas to pay. On legacy + * networks this should be ``null``. + */ + get maxFeePerGas() { + const value = this.#maxFeePerGas; + if (value == null) { + if (this.type === 2 || this.type === 3) { + return BN_0$4; + } + return null; + } + return value; + } + set maxFeePerGas(value) { + this.#maxFeePerGas = (value == null) ? null : getBigInt(value, "maxFeePerGas"); + } + /** + * The transaction data. For ``init`` transactions this is the + * deployment code. + */ + get data() { return this.#data; } + set data(value) { this.#data = hexlify(value); } + /** + * The amount of ether (in wei) to send in this transactions. + */ + get value() { return this.#value; } + set value(value) { + this.#value = getBigInt(value, "value"); + } + /** + * The chain ID this transaction is valid on. + */ + get chainId() { return this.#chainId; } + set chainId(value) { this.#chainId = getBigInt(value); } + /** + * If signed, the signature for this transaction. + */ + get signature() { return this.#sig || null; } + set signature(value) { + this.#sig = (value == null) ? null : Signature.from(value); + } + /** + * The access list. + * + * An access list permits discounted (but pre-paid) access to + * bytecode and state variable access within contract execution. + */ + get accessList() { + const value = this.#accessList || null; + if (value == null) { + if (this.type === 1 || this.type === 2 || this.type === 3) { + // @TODO: in v7, this should assign the value or become + // a live object itself, otherwise mutation is inconsistent + return []; + } + return null; + } + return value; + } + set accessList(value) { + this.#accessList = (value == null) ? null : accessListify(value); + } + /** + * The max fee per blob gas for Cancun transactions. + */ + get maxFeePerBlobGas() { + const value = this.#maxFeePerBlobGas; + if (value == null && this.type === 3) { + return BN_0$4; + } + return value; + } + set maxFeePerBlobGas(value) { + this.#maxFeePerBlobGas = (value == null) ? null : getBigInt(value, "maxFeePerBlobGas"); + } + /** + * The BLOb versioned hashes for Cancun transactions. + */ + get blobVersionedHashes() { + // @TODO: Mutation is inconsistent; if unset, the returned value + // cannot mutate the object, if set it can + let value = this.#blobVersionedHashes; + if (value == null && this.type === 3) { + return []; + } + return value; + } + set blobVersionedHashes(value) { + if (value != null) { + assertArgument(Array.isArray(value), "blobVersionedHashes must be an Array", "value", value); + value = value.slice(); + for (let i = 0; i < value.length; i++) { + assertArgument(isHexString$1(value[i], 32), "invalid blobVersionedHash", `value[${i}]`, value[i]); + } + } + this.#blobVersionedHashes = value; + } + /** + * The BLObs for the Transaction, if any. + * + * If ``blobs`` is non-``null``, then the [[seriailized]] + * will return the network formatted sidecar, otherwise it + * will return the standard [[link-eip-2718]] payload. The + * [[unsignedSerialized]] is unaffected regardless. + * + * When setting ``blobs``, either fully valid [[Blob]] objects + * may be specified (i.e. correctly padded, with correct + * committments and proofs) or a raw [[BytesLike]] may + * be provided. + * + * If raw [[BytesLike]] are provided, the [[kzg]] property **must** + * be already set. The blob will be correctly padded and the + * [[KzgLibrary]] will be used to compute the committment and + * proof for the blob. + * + * A BLOb is a sequence of field elements, each of which must + * be within the BLS field modulo, so some additional processing + * may be required to encode arbitrary data to ensure each 32 byte + * field is within the valid range. + * + * Setting this automatically populates [[blobVersionedHashes]], + * overwriting any existing values. Setting this to ``null`` + * does **not** remove the [[blobVersionedHashes]], leaving them + * present. + */ + get blobs() { + if (this.#blobs == null) { + return null; + } + return this.#blobs.map((b) => Object.assign({}, b)); + } + set blobs(_blobs) { + if (_blobs == null) { + this.#blobs = null; + return; + } + const blobs = []; + const versionedHashes = []; + for (let i = 0; i < _blobs.length; i++) { + const blob = _blobs[i]; + if (isBytesLike(blob)) { + assert$5(this.#kzg, "adding a raw blob requires a KZG library", "UNSUPPORTED_OPERATION", { + operation: "set blobs()" + }); + let data = getBytes(blob); + assertArgument(data.length <= BLOB_SIZE, "blob is too large", `blobs[${i}]`, blob); + // Pad blob if necessary + if (data.length !== BLOB_SIZE) { + const padded = new Uint8Array(BLOB_SIZE); + padded.set(data); + data = padded; + } + const commit = this.#kzg.blobToKzgCommitment(data); + const proof = hexlify(this.#kzg.computeBlobKzgProof(data, commit)); + blobs.push({ + data: hexlify(data), + commitment: hexlify(commit), + proof + }); + versionedHashes.push(getVersionedHash(1, commit)); + } + else { + const commit = hexlify(blob.commitment); + blobs.push({ + data: hexlify(blob.data), + commitment: commit, + proof: hexlify(blob.proof) + }); + versionedHashes.push(getVersionedHash(1, commit)); + } + } + this.#blobs = blobs; + this.#blobVersionedHashes = versionedHashes; + } + get kzg() { return this.#kzg; } + set kzg(kzg) { + this.#kzg = kzg; + } + /** + * Creates a new Transaction with default values. + */ + constructor() { + this.#type = null; + this.#to = null; + this.#nonce = 0; + this.#gasLimit = BN_0$4; + this.#gasPrice = null; + this.#maxPriorityFeePerGas = null; + this.#maxFeePerGas = null; + this.#data = "0x"; + this.#value = BN_0$4; + this.#chainId = BN_0$4; + this.#sig = null; + this.#accessList = null; + this.#maxFeePerBlobGas = null; + this.#blobVersionedHashes = null; + this.#blobs = null; + this.#kzg = null; + } + /** + * The transaction hash, if signed. Otherwise, ``null``. + */ + get hash() { + if (this.signature == null) { + return null; + } + return keccak256$1(this.#getSerialized(true, false)); + } + /** + * The pre-image hash of this transaction. + * + * This is the digest that a [[Signer]] must sign to authorize + * this transaction. + */ + get unsignedHash() { + return keccak256$1(this.unsignedSerialized); + } + /** + * The sending address, if signed. Otherwise, ``null``. + */ + get from() { + if (this.signature == null) { + return null; + } + return recoverAddress(this.unsignedHash, this.signature); + } + /** + * The public key of the sender, if signed. Otherwise, ``null``. + */ + get fromPublicKey() { + if (this.signature == null) { + return null; + } + return SigningKey.recoverPublicKey(this.unsignedHash, this.signature); + } + /** + * Returns true if signed. + * + * This provides a Type Guard that properties requiring a signed + * transaction are non-null. + */ + isSigned() { + return this.signature != null; + } + #getSerialized(signed, sidecar) { + assert$5(!signed || this.signature != null, "cannot serialize unsigned transaction; maybe you meant .unsignedSerialized", "UNSUPPORTED_OPERATION", { operation: ".serialized" }); + const sig = signed ? this.signature : null; + switch (this.inferType()) { + case 0: + return _serializeLegacy(this, sig); + case 1: + return _serializeEip2930(this, sig); + case 2: + return _serializeEip1559(this, sig); + case 3: + return _serializeEip4844(this, sig, sidecar ? this.blobs : null); + } + assert$5(false, "unsupported transaction type", "UNSUPPORTED_OPERATION", { operation: ".serialized" }); + } + /** + * The serialized transaction. + * + * This throws if the transaction is unsigned. For the pre-image, + * use [[unsignedSerialized]]. + */ + get serialized() { + return this.#getSerialized(true, true); + } + /** + * The transaction pre-image. + * + * The hash of this is the digest which needs to be signed to + * authorize this transaction. + */ + get unsignedSerialized() { + return this.#getSerialized(false, false); + } + /** + * Return the most "likely" type; currently the highest + * supported transaction type. + */ + inferType() { + const types = this.inferTypes(); + // Prefer London (EIP-1559) over Cancun (BLOb) + if (types.indexOf(2) >= 0) { + return 2; + } + // Return the highest inferred type + return (types.pop()); + } + /** + * Validates the explicit properties and returns a list of compatible + * transaction types. + */ + inferTypes() { + // Checks that there are no conflicting properties set + const hasGasPrice = this.gasPrice != null; + const hasFee = (this.maxFeePerGas != null || this.maxPriorityFeePerGas != null); + const hasAccessList = (this.accessList != null); + const hasBlob = (this.#maxFeePerBlobGas != null || this.#blobVersionedHashes); + //if (hasGasPrice && hasFee) { + // throw new Error("transaction cannot have gasPrice and maxFeePerGas"); + //} + if (this.maxFeePerGas != null && this.maxPriorityFeePerGas != null) { + assert$5(this.maxFeePerGas >= this.maxPriorityFeePerGas, "priorityFee cannot be more than maxFee", "BAD_DATA", { value: this }); + } + //if (this.type === 2 && hasGasPrice) { + // throw new Error("eip-1559 transaction cannot have gasPrice"); + //} + assert$5(!hasFee || (this.type !== 0 && this.type !== 1), "transaction type cannot have maxFeePerGas or maxPriorityFeePerGas", "BAD_DATA", { value: this }); + assert$5(this.type !== 0 || !hasAccessList, "legacy transaction cannot have accessList", "BAD_DATA", { value: this }); + const types = []; + // Explicit type + if (this.type != null) { + types.push(this.type); + } + else { + if (hasFee) { + types.push(2); + } + else if (hasGasPrice) { + types.push(1); + if (!hasAccessList) { + types.push(0); + } + } + else if (hasAccessList) { + types.push(1); + types.push(2); + } + else if (hasBlob && this.to) { + types.push(3); + } + else { + types.push(0); + types.push(1); + types.push(2); + types.push(3); + } + } + types.sort(); + return types; + } + /** + * Returns true if this transaction is a legacy transaction (i.e. + * ``type === 0``). + * + * This provides a Type Guard that the related properties are + * non-null. + */ + isLegacy() { + return (this.type === 0); + } + /** + * Returns true if this transaction is berlin hardform transaction (i.e. + * ``type === 1``). + * + * This provides a Type Guard that the related properties are + * non-null. + */ + isBerlin() { + return (this.type === 1); + } + /** + * Returns true if this transaction is london hardform transaction (i.e. + * ``type === 2``). + * + * This provides a Type Guard that the related properties are + * non-null. + */ + isLondon() { + return (this.type === 2); + } + /** + * Returns true if this transaction is an [[link-eip-4844]] BLOB + * transaction. + * + * This provides a Type Guard that the related properties are + * non-null. + */ + isCancun() { + return (this.type === 3); + } + /** + * Create a copy of this transaciton. + */ + clone() { + return Transaction.from(this); + } + /** + * Return a JSON-friendly object. + */ + toJSON() { + const s = (v) => { + if (v == null) { + return null; + } + return v.toString(); + }; + return { + type: this.type, + to: this.to, + // from: this.from, + data: this.data, + nonce: this.nonce, + gasLimit: s(this.gasLimit), + gasPrice: s(this.gasPrice), + maxPriorityFeePerGas: s(this.maxPriorityFeePerGas), + maxFeePerGas: s(this.maxFeePerGas), + value: s(this.value), + chainId: s(this.chainId), + sig: this.signature ? this.signature.toJSON() : null, + accessList: this.accessList + }; + } + /** + * Create a **Transaction** from a serialized transaction or a + * Transaction-like object. + */ + static from(tx) { + if (tx == null) { + return new Transaction(); + } + if (typeof (tx) === "string") { + const payload = getBytes(tx); + if (payload[0] >= 0x7f) { // @TODO: > vs >= ?? + return Transaction.from(_parseLegacy(payload)); + } + switch (payload[0]) { + case 1: return Transaction.from(_parseEip2930(payload)); + case 2: return Transaction.from(_parseEip1559(payload)); + case 3: return Transaction.from(_parseEip4844(payload)); + } + assert$5(false, "unsupported transaction type", "UNSUPPORTED_OPERATION", { operation: "from" }); + } + const result = new Transaction(); + if (tx.type != null) { + result.type = tx.type; + } + if (tx.to != null) { + result.to = tx.to; + } + if (tx.nonce != null) { + result.nonce = tx.nonce; + } + if (tx.gasLimit != null) { + result.gasLimit = tx.gasLimit; + } + if (tx.gasPrice != null) { + result.gasPrice = tx.gasPrice; + } + if (tx.maxPriorityFeePerGas != null) { + result.maxPriorityFeePerGas = tx.maxPriorityFeePerGas; + } + if (tx.maxFeePerGas != null) { + result.maxFeePerGas = tx.maxFeePerGas; + } + if (tx.maxFeePerBlobGas != null) { + result.maxFeePerBlobGas = tx.maxFeePerBlobGas; + } + if (tx.data != null) { + result.data = tx.data; + } + if (tx.value != null) { + result.value = tx.value; + } + if (tx.chainId != null) { + result.chainId = tx.chainId; + } + if (tx.signature != null) { + result.signature = Signature.from(tx.signature); + } + if (tx.accessList != null) { + result.accessList = tx.accessList; + } + // This will get overwritten by blobs, if present + if (tx.blobVersionedHashes != null) { + result.blobVersionedHashes = tx.blobVersionedHashes; + } + // Make sure we assign the kzg before assigning blobs, which + // require the library in the event raw blob data is provided. + if (tx.kzg != null) { + result.kzg = tx.kzg; + } + if (tx.blobs != null) { + result.blobs = tx.blobs; + } + if (tx.hash != null) { + assertArgument(result.isSigned(), "unsigned transaction cannot define '.hash'", "tx", tx); + assertArgument(result.hash === tx.hash, "hash mismatch", "tx", tx); + } + if (tx.from != null) { + assertArgument(result.isSigned(), "unsigned transaction cannot define '.from'", "tx", tx); + assertArgument(result.from.toLowerCase() === (tx.from || "").toLowerCase(), "from mismatch", "tx", tx); + } + return result; + } +} + +/** + * Computes the [[link-eip-191]] personal-sign message digest to sign. + * + * This prefixes the message with [[MessagePrefix]] and the decimal length + * of %%message%% and computes the [[keccak256]] digest. + * + * If %%message%% is a string, it is converted to its UTF-8 bytes + * first. To compute the digest of a [[DataHexString]], it must be converted + * to [bytes](getBytes). + * + * @example: + * hashMessage("Hello World") + * //_result: + * + * // Hashes the SIX (6) string characters, i.e. + * // [ "0", "x", "4", "2", "4", "3" ] + * hashMessage("0x4243") + * //_result: + * + * // Hashes the TWO (2) bytes [ 0x42, 0x43 ]... + * hashMessage(getBytes("0x4243")) + * //_result: + * + * // ...which is equal to using data + * hashMessage(new Uint8Array([ 0x42, 0x43 ])) + * //_result: + * + */ +function hashMessage(message) { + if (typeof (message) === "string") { + message = toUtf8Bytes$1(message); + } + return keccak256$1(concat$3([ + toUtf8Bytes$1(MessagePrefix), + toUtf8Bytes$1(String(message.length)), + message + ])); +} + +//import { TypedDataDomain, TypedDataField } from "@ethersproject/providerabstract-signer"; +const padding = new Uint8Array(32); +padding.fill(0); +const BN__1 = BigInt(-1); +const BN_0$3 = BigInt(0); +const BN_1 = BigInt(1); +const BN_MAX_UINT256 = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); +function hexPadRight(value) { + const bytes = getBytes(value); + const padOffset = bytes.length % 32; + if (padOffset) { + return concat$3([bytes, padding.slice(padOffset)]); + } + return hexlify(bytes); +} +const hexTrue = toBeHex(BN_1, 32); +const hexFalse = toBeHex(BN_0$3, 32); +const domainFieldTypes = { + name: "string", + version: "string", + chainId: "uint256", + verifyingContract: "address", + salt: "bytes32" +}; +const domainFieldNames = [ + "name", "version", "chainId", "verifyingContract", "salt" +]; +function checkString(key) { + return function (value) { + assertArgument(typeof (value) === "string", `invalid domain value for ${JSON.stringify(key)}`, `domain.${key}`, value); + return value; + }; +} +const domainChecks = { + name: checkString("name"), + version: checkString("version"), + chainId: function (_value) { + const value = getBigInt(_value, "domain.chainId"); + assertArgument(value >= 0, "invalid chain ID", "domain.chainId", _value); + if (Number.isSafeInteger(value)) { + return Number(value); + } + return toQuantity(value); + }, + verifyingContract: function (value) { + try { + return getAddress(value).toLowerCase(); + } + catch (error) { } + assertArgument(false, `invalid domain value "verifyingContract"`, "domain.verifyingContract", value); + }, + salt: function (value) { + const bytes = getBytes(value, "domain.salt"); + assertArgument(bytes.length === 32, `invalid domain value "salt"`, "domain.salt", value); + return hexlify(bytes); + } +}; +function getBaseEncoder(type) { + // intXX and uintXX + { + const match = type.match(/^(u?)int(\d+)$/); + if (match) { + const signed = (match[1] === ""); + const width = parseInt(match[2]); + assertArgument(width % 8 === 0 && width !== 0 && width <= 256 && match[2] === String(width), "invalid numeric width", "type", type); + const boundsUpper = mask(BN_MAX_UINT256, signed ? (width - 1) : width); + const boundsLower = signed ? ((boundsUpper + BN_1) * BN__1) : BN_0$3; + return function (_value) { + const value = getBigInt(_value, "value"); + assertArgument(value >= boundsLower && value <= boundsUpper, `value out-of-bounds for ${type}`, "value", value); + return toBeHex(signed ? toTwos(value, 256) : value, 32); + }; + } + } + // bytesXX + { + const match = type.match(/^bytes(\d+)$/); + if (match) { + const width = parseInt(match[1]); + assertArgument(width !== 0 && width <= 32 && match[1] === String(width), "invalid bytes width", "type", type); + return function (value) { + const bytes = getBytes(value); + assertArgument(bytes.length === width, `invalid length for ${type}`, "value", value); + return hexPadRight(value); + }; + } + } + switch (type) { + case "address": return function (value) { + return zeroPadValue(getAddress(value), 32); + }; + case "bool": return function (value) { + return ((!value) ? hexFalse : hexTrue); + }; + case "bytes": return function (value) { + return keccak256$1(value); + }; + case "string": return function (value) { + return id$1(value); + }; + } + return null; +} +function encodeType(name, fields) { + return `${name}(${fields.map(({ name, type }) => (type + " " + name)).join(",")})`; +} +// foo[][3] => { base: "foo", index: "[][3]", array: { +// base: "foo", prefix: "foo[]", count: 3 } } +function splitArray(type) { + const match = type.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/); + if (match) { + return { + base: match[1], + index: (match[2] + match[4]), + array: { + base: match[1], + prefix: (match[1] + match[2]), + count: (match[5] ? parseInt(match[5]) : -1), + } + }; + } + return { base: type }; +} +/** + * A **TypedDataEncode** prepares and encodes [[link-eip-712]] payloads + * for signed typed data. + * + * This is useful for those that wish to compute various components of a + * typed data hash, primary types, or sub-components, but generally the + * higher level [[Signer-signTypedData]] is more useful. + */ +class TypedDataEncoder { + /** + * The primary type for the structured [[types]]. + * + * This is derived automatically from the [[types]], since no + * recursion is possible, once the DAG for the types is consturcted + * internally, the primary type must be the only remaining type with + * no parent nodes. + */ + primaryType; + #types; + /** + * The types. + */ + get types() { + return JSON.parse(this.#types); + } + #fullTypes; + #encoderCache; + /** + * Create a new **TypedDataEncoder** for %%types%%. + * + * This performs all necessary checking that types are valid and + * do not violate the [[link-eip-712]] structural constraints as + * well as computes the [[primaryType]]. + */ + constructor(_types) { + this.#fullTypes = new Map(); + this.#encoderCache = new Map(); + // Link struct types to their direct child structs + const links = new Map(); + // Link structs to structs which contain them as a child + const parents = new Map(); + // Link all subtypes within a given struct + const subtypes = new Map(); + const types = {}; + Object.keys(_types).forEach((type) => { + types[type] = _types[type].map(({ name, type }) => { + // Normalize the base type (unless name conflict) + let { base, index } = splitArray(type); + if (base === "int" && !_types["int"]) { + base = "int256"; + } + if (base === "uint" && !_types["uint"]) { + base = "uint256"; + } + return { name, type: (base + (index || "")) }; + }); + links.set(type, new Set()); + parents.set(type, []); + subtypes.set(type, new Set()); + }); + this.#types = JSON.stringify(types); + for (const name in types) { + const uniqueNames = new Set(); + for (const field of types[name]) { + // Check each field has a unique name + assertArgument(!uniqueNames.has(field.name), `duplicate variable name ${JSON.stringify(field.name)} in ${JSON.stringify(name)}`, "types", _types); + uniqueNames.add(field.name); + // Get the base type (drop any array specifiers) + const baseType = splitArray(field.type).base; + assertArgument(baseType !== name, `circular type reference to ${JSON.stringify(baseType)}`, "types", _types); + // Is this a base encoding type? + const encoder = getBaseEncoder(baseType); + if (encoder) { + continue; + } + assertArgument(parents.has(baseType), `unknown type ${JSON.stringify(baseType)}`, "types", _types); + // Add linkage + parents.get(baseType).push(name); + links.get(name).add(baseType); + } + } + // Deduce the primary type + const primaryTypes = Array.from(parents.keys()).filter((n) => (parents.get(n).length === 0)); + assertArgument(primaryTypes.length !== 0, "missing primary type", "types", _types); + assertArgument(primaryTypes.length === 1, `ambiguous primary types or unused types: ${primaryTypes.map((t) => (JSON.stringify(t))).join(", ")}`, "types", _types); + defineProperties(this, { primaryType: primaryTypes[0] }); + // Check for circular type references + function checkCircular(type, found) { + assertArgument(!found.has(type), `circular type reference to ${JSON.stringify(type)}`, "types", _types); + found.add(type); + for (const child of links.get(type)) { + if (!parents.has(child)) { + continue; + } + // Recursively check children + checkCircular(child, found); + // Mark all ancestors as having this decendant + for (const subtype of found) { + subtypes.get(subtype).add(child); + } + } + found.delete(type); + } + checkCircular(this.primaryType, new Set()); + // Compute each fully describe type + for (const [name, set] of subtypes) { + const st = Array.from(set); + st.sort(); + this.#fullTypes.set(name, encodeType(name, types[name]) + st.map((t) => encodeType(t, types[t])).join("")); + } + } + /** + * Returnthe encoder for the specific %%type%%. + */ + getEncoder(type) { + let encoder = this.#encoderCache.get(type); + if (!encoder) { + encoder = this.#getEncoder(type); + this.#encoderCache.set(type, encoder); + } + return encoder; + } + #getEncoder(type) { + // Basic encoder type (address, bool, uint256, etc) + { + const encoder = getBaseEncoder(type); + if (encoder) { + return encoder; + } + } + // Array + const array = splitArray(type).array; + if (array) { + const subtype = array.prefix; + const subEncoder = this.getEncoder(subtype); + return (value) => { + assertArgument(array.count === -1 || array.count === value.length, `array length mismatch; expected length ${array.count}`, "value", value); + let result = value.map(subEncoder); + if (this.#fullTypes.has(subtype)) { + result = result.map(keccak256$1); + } + return keccak256$1(concat$3(result)); + }; + } + // Struct + const fields = this.types[type]; + if (fields) { + const encodedType = id$1(this.#fullTypes.get(type)); + return (value) => { + const values = fields.map(({ name, type }) => { + const result = this.getEncoder(type)(value[name]); + if (this.#fullTypes.has(type)) { + return keccak256$1(result); + } + return result; + }); + values.unshift(encodedType); + return concat$3(values); + }; + } + assertArgument(false, `unknown type: ${type}`, "type", type); + } + /** + * Return the full type for %%name%%. + */ + encodeType(name) { + const result = this.#fullTypes.get(name); + assertArgument(result, `unknown type: ${JSON.stringify(name)}`, "name", name); + return result; + } + /** + * Return the encoded %%value%% for the %%type%%. + */ + encodeData(type, value) { + return this.getEncoder(type)(value); + } + /** + * Returns the hash of %%value%% for the type of %%name%%. + */ + hashStruct(name, value) { + return keccak256$1(this.encodeData(name, value)); + } + /** + * Return the fulled encoded %%value%% for the [[types]]. + */ + encode(value) { + return this.encodeData(this.primaryType, value); + } + /** + * Return the hash of the fully encoded %%value%% for the [[types]]. + */ + hash(value) { + return this.hashStruct(this.primaryType, value); + } + /** + * @_ignore: + */ + _visit(type, value, callback) { + // Basic encoder type (address, bool, uint256, etc) + { + const encoder = getBaseEncoder(type); + if (encoder) { + return callback(type, value); + } + } + // Array + const array = splitArray(type).array; + if (array) { + assertArgument(array.count === -1 || array.count === value.length, `array length mismatch; expected length ${array.count}`, "value", value); + return value.map((v) => this._visit(array.prefix, v, callback)); + } + // Struct + const fields = this.types[type]; + if (fields) { + return fields.reduce((accum, { name, type }) => { + accum[name] = this._visit(type, value[name], callback); + return accum; + }, {}); + } + assertArgument(false, `unknown type: ${type}`, "type", type); + } + /** + * Call %%calback%% for each value in %%value%%, passing the type and + * component within %%value%%. + * + * This is useful for replacing addresses or other transformation that + * may be desired on each component, based on its type. + */ + visit(value, callback) { + return this._visit(this.primaryType, value, callback); + } + /** + * Create a new **TypedDataEncoder** for %%types%%. + */ + static from(types) { + return new TypedDataEncoder(types); + } + /** + * Return the primary type for %%types%%. + */ + static getPrimaryType(types) { + return TypedDataEncoder.from(types).primaryType; + } + /** + * Return the hashed struct for %%value%% using %%types%% and %%name%%. + */ + static hashStruct(name, types, value) { + return TypedDataEncoder.from(types).hashStruct(name, value); + } + /** + * Return the domain hash for %%domain%%. + */ + static hashDomain(domain) { + const domainFields = []; + for (const name in domain) { + if (domain[name] == null) { + continue; + } + const type = domainFieldTypes[name]; + assertArgument(type, `invalid typed-data domain key: ${JSON.stringify(name)}`, "domain", domain); + domainFields.push({ name, type }); + } + domainFields.sort((a, b) => { + return domainFieldNames.indexOf(a.name) - domainFieldNames.indexOf(b.name); + }); + return TypedDataEncoder.hashStruct("EIP712Domain", { EIP712Domain: domainFields }, domain); + } + /** + * Return the fully encoded [[link-eip-712]] %%value%% for %%types%% with %%domain%%. + */ + static encode(domain, types, value) { + return concat$3([ + "0x1901", + TypedDataEncoder.hashDomain(domain), + TypedDataEncoder.from(types).hash(value) + ]); + } + /** + * Return the hash of the fully encoded [[link-eip-712]] %%value%% for %%types%% with %%domain%%. + */ + static hash(domain, types, value) { + return keccak256$1(TypedDataEncoder.encode(domain, types, value)); + } + // Replaces all address types with ENS names with their looked up address + /** + * Resolves to the value from resolving all addresses in %%value%% for + * %%types%% and the %%domain%%. + */ + static async resolveNames(domain, types, value, resolveName) { + // Make a copy to isolate it from the object passed in + domain = Object.assign({}, domain); + // Allow passing null to ignore value + for (const key in domain) { + if (domain[key] == null) { + delete domain[key]; + } + } + // Look up all ENS names + const ensCache = {}; + // Do we need to look up the domain's verifyingContract? + if (domain.verifyingContract && !isHexString$1(domain.verifyingContract, 20)) { + ensCache[domain.verifyingContract] = "0x"; + } + // We are going to use the encoder to visit all the base values + const encoder = TypedDataEncoder.from(types); + // Get a list of all the addresses + encoder.visit(value, (type, value) => { + if (type === "address" && !isHexString$1(value, 20)) { + ensCache[value] = "0x"; + } + return value; + }); + // Lookup each name + for (const name in ensCache) { + ensCache[name] = await resolveName(name); + } + // Replace the domain verifyingContract if needed + if (domain.verifyingContract && ensCache[domain.verifyingContract]) { + domain.verifyingContract = ensCache[domain.verifyingContract]; + } + // Replace all ENS names with their address + value = encoder.visit(value, (type, value) => { + if (type === "address" && ensCache[value]) { + return ensCache[value]; + } + return value; + }); + return { domain, value }; + } + /** + * Returns the JSON-encoded payload expected by nodes which implement + * the JSON-RPC [[link-eip-712]] method. + */ + static getPayload(domain, types, value) { + // Validate the domain fields + TypedDataEncoder.hashDomain(domain); + // Derive the EIP712Domain Struct reference type + const domainValues = {}; + const domainTypes = []; + domainFieldNames.forEach((name) => { + const value = domain[name]; + if (value == null) { + return; + } + domainValues[name] = domainChecks[name](value); + domainTypes.push({ name, type: domainFieldTypes[name] }); + }); + const encoder = TypedDataEncoder.from(types); + // Get the normalized types + types = encoder.types; + const typesWithDomain = Object.assign({}, types); + assertArgument(typesWithDomain.EIP712Domain == null, "types must not contain EIP712Domain type", "types.EIP712Domain", types); + typesWithDomain.EIP712Domain = domainTypes; + // Validate the data structures and types + encoder.encode(value); + return { + types: typesWithDomain, + domain: domainValues, + primaryType: encoder.primaryType, + message: encoder.visit(value, (type, value) => { + // bytes + if (type.match(/^bytes(\d*)/)) { + return hexlify(getBytes(value)); + } + // uint or int + if (type.match(/^u?int/)) { + return getBigInt(value).toString(); + } + switch (type) { + case "address": + return value.toLowerCase(); + case "bool": + return !!value; + case "string": + assertArgument(typeof (value) === "string", "invalid string", "value", value); + return value; + } + assertArgument(false, "unsupported type", "type", type); + }) + }; + } +} + +/** + * A fragment is a single item from an ABI, which may represent any of: + * + * - [Functions](FunctionFragment) + * - [Events](EventFragment) + * - [Constructors](ConstructorFragment) + * - Custom [Errors](ErrorFragment) + * - [Fallback or Receive](FallbackFragment) functions + * + * @_subsection api/abi/abi-coder:Fragments [about-fragments] + */ +// [ "a", "b" ] => { "a": 1, "b": 1 } +function setify(items) { + const result = new Set(); + items.forEach((k) => result.add(k)); + return Object.freeze(result); +} +const _kwVisibDeploy = "external public payable override"; +const KwVisibDeploy = setify(_kwVisibDeploy.split(" ")); +// Visibility Keywords +const _kwVisib = "constant external internal payable private public pure view override"; +const KwVisib = setify(_kwVisib.split(" ")); +const _kwTypes = "constructor error event fallback function receive struct"; +const KwTypes = setify(_kwTypes.split(" ")); +const _kwModifiers = "calldata memory storage payable indexed"; +const KwModifiers = setify(_kwModifiers.split(" ")); +const _kwOther = "tuple returns"; +// All Keywords +const _keywords = [_kwTypes, _kwModifiers, _kwOther, _kwVisib].join(" "); +const Keywords = setify(_keywords.split(" ")); +// Single character tokens +const SimpleTokens = { + "(": "OPEN_PAREN", ")": "CLOSE_PAREN", + "[": "OPEN_BRACKET", "]": "CLOSE_BRACKET", + ",": "COMMA", "@": "AT" +}; +// Parser regexes to consume the next token +const regexWhitespacePrefix = new RegExp("^(\\s*)"); +const regexNumberPrefix = new RegExp("^([0-9]+)"); +const regexIdPrefix = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"); +// Parser regexs to check validity +const regexId = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"); +const regexType = new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"); +class TokenString { + #offset; + #tokens; + get offset() { return this.#offset; } + get length() { return this.#tokens.length - this.#offset; } + constructor(tokens) { + this.#offset = 0; + this.#tokens = tokens.slice(); + } + clone() { return new TokenString(this.#tokens); } + reset() { this.#offset = 0; } + #subTokenString(from = 0, to = 0) { + return new TokenString(this.#tokens.slice(from, to).map((t) => { + return Object.freeze(Object.assign({}, t, { + match: (t.match - from), + linkBack: (t.linkBack - from), + linkNext: (t.linkNext - from), + })); + })); + } + // Pops and returns the value of the next token, if it is a keyword in allowed; throws if out of tokens + popKeyword(allowed) { + const top = this.peek(); + if (top.type !== "KEYWORD" || !allowed.has(top.text)) { + throw new Error(`expected keyword ${top.text}`); + } + return this.pop().text; + } + // Pops and returns the value of the next token if it is `type`; throws if out of tokens + popType(type) { + if (this.peek().type !== type) { + const top = this.peek(); + throw new Error(`expected ${type}; got ${top.type} ${JSON.stringify(top.text)}`); + } + return this.pop().text; + } + // Pops and returns a "(" TOKENS ")" + popParen() { + const top = this.peek(); + if (top.type !== "OPEN_PAREN") { + throw new Error("bad start"); + } + const result = this.#subTokenString(this.#offset + 1, top.match + 1); + this.#offset = top.match + 1; + return result; + } + // Pops and returns the items within "(" ITEM1 "," ITEM2 "," ... ")" + popParams() { + const top = this.peek(); + if (top.type !== "OPEN_PAREN") { + throw new Error("bad start"); + } + const result = []; + while (this.#offset < top.match - 1) { + const link = this.peek().linkNext; + result.push(this.#subTokenString(this.#offset + 1, link)); + this.#offset = link; + } + this.#offset = top.match + 1; + return result; + } + // Returns the top Token, throwing if out of tokens + peek() { + if (this.#offset >= this.#tokens.length) { + throw new Error("out-of-bounds"); + } + return this.#tokens[this.#offset]; + } + // Returns the next value, if it is a keyword in `allowed` + peekKeyword(allowed) { + const top = this.peekType("KEYWORD"); + return (top != null && allowed.has(top)) ? top : null; + } + // Returns the value of the next token if it is `type` + peekType(type) { + if (this.length === 0) { + return null; + } + const top = this.peek(); + return (top.type === type) ? top.text : null; + } + // Returns the next token; throws if out of tokens + pop() { + const result = this.peek(); + this.#offset++; + return result; + } + toString() { + const tokens = []; + for (let i = this.#offset; i < this.#tokens.length; i++) { + const token = this.#tokens[i]; + tokens.push(`${token.type}:${token.text}`); + } + return ``; + } +} +function lex(text) { + const tokens = []; + const throwError = (message) => { + const token = (offset < text.length) ? JSON.stringify(text[offset]) : "$EOI"; + throw new Error(`invalid token ${token} at ${offset}: ${message}`); + }; + let brackets = []; + let commas = []; + let offset = 0; + while (offset < text.length) { + // Strip off any leading whitespace + let cur = text.substring(offset); + let match = cur.match(regexWhitespacePrefix); + if (match) { + offset += match[1].length; + cur = text.substring(offset); + } + const token = { depth: brackets.length, linkBack: -1, linkNext: -1, match: -1, type: "", text: "", offset, value: -1 }; + tokens.push(token); + let type = (SimpleTokens[cur[0]] || ""); + if (type) { + token.type = type; + token.text = cur[0]; + offset++; + if (type === "OPEN_PAREN") { + brackets.push(tokens.length - 1); + commas.push(tokens.length - 1); + } + else if (type == "CLOSE_PAREN") { + if (brackets.length === 0) { + throwError("no matching open bracket"); + } + token.match = brackets.pop(); + (tokens[token.match]).match = tokens.length - 1; + token.depth--; + token.linkBack = commas.pop(); + (tokens[token.linkBack]).linkNext = tokens.length - 1; + } + else if (type === "COMMA") { + token.linkBack = commas.pop(); + (tokens[token.linkBack]).linkNext = tokens.length - 1; + commas.push(tokens.length - 1); + } + else if (type === "OPEN_BRACKET") { + token.type = "BRACKET"; + } + else if (type === "CLOSE_BRACKET") { + // Remove the CLOSE_BRACKET + let suffix = tokens.pop().text; + if (tokens.length > 0 && tokens[tokens.length - 1].type === "NUMBER") { + const value = tokens.pop().text; + suffix = value + suffix; + (tokens[tokens.length - 1]).value = getNumber(value); + } + if (tokens.length === 0 || tokens[tokens.length - 1].type !== "BRACKET") { + throw new Error("missing opening bracket"); + } + (tokens[tokens.length - 1]).text += suffix; + } + continue; + } + match = cur.match(regexIdPrefix); + if (match) { + token.text = match[1]; + offset += token.text.length; + if (Keywords.has(token.text)) { + token.type = "KEYWORD"; + continue; + } + if (token.text.match(regexType)) { + token.type = "TYPE"; + continue; + } + token.type = "ID"; + continue; + } + match = cur.match(regexNumberPrefix); + if (match) { + token.text = match[1]; + token.type = "NUMBER"; + offset += token.text.length; + continue; + } + throw new Error(`unexpected token ${JSON.stringify(cur[0])} at position ${offset}`); + } + return new TokenString(tokens.map((t) => Object.freeze(t))); +} +// Check only one of `allowed` is in `set` +function allowSingle(set, allowed) { + let included = []; + for (const key in allowed.keys()) { + if (set.has(key)) { + included.push(key); + } + } + if (included.length > 1) { + throw new Error(`conflicting types: ${included.join(", ")}`); + } +} +// Functions to process a Solidity Signature TokenString from left-to-right for... +// ...the name with an optional type, returning the name +function consumeName(type, tokens) { + if (tokens.peekKeyword(KwTypes)) { + const keyword = tokens.pop().text; + if (keyword !== type) { + throw new Error(`expected ${type}, got ${keyword}`); + } + } + return tokens.popType("ID"); +} +// ...all keywords matching allowed, returning the keywords +function consumeKeywords(tokens, allowed) { + const keywords = new Set(); + while (true) { + const keyword = tokens.peekType("KEYWORD"); + if (keyword == null || (allowed && !allowed.has(keyword))) { + break; + } + tokens.pop(); + if (keywords.has(keyword)) { + throw new Error(`duplicate keywords: ${JSON.stringify(keyword)}`); + } + keywords.add(keyword); + } + return Object.freeze(keywords); +} +// ...all visibility keywords, returning the coalesced mutability +function consumeMutability(tokens) { + let modifiers = consumeKeywords(tokens, KwVisib); + // Detect conflicting modifiers + allowSingle(modifiers, setify("constant payable nonpayable".split(" "))); + allowSingle(modifiers, setify("pure view payable nonpayable".split(" "))); + // Process mutability states + if (modifiers.has("view")) { + return "view"; + } + if (modifiers.has("pure")) { + return "pure"; + } + if (modifiers.has("payable")) { + return "payable"; + } + if (modifiers.has("nonpayable")) { + return "nonpayable"; + } + // Process legacy `constant` last + if (modifiers.has("constant")) { + return "view"; + } + return "nonpayable"; +} +// ...a parameter list, returning the ParamType list +function consumeParams(tokens, allowIndexed) { + return tokens.popParams().map((t) => ParamType.from(t, allowIndexed)); +} +// ...a gas limit, returning a BigNumber or null if none +function consumeGas(tokens) { + if (tokens.peekType("AT")) { + tokens.pop(); + if (tokens.peekType("NUMBER")) { + return getBigInt(tokens.pop().text); + } + throw new Error("invalid gas"); + } + return null; +} +function consumeEoi(tokens) { + if (tokens.length) { + throw new Error(`unexpected tokens at offset ${tokens.offset}: ${tokens.toString()}`); + } +} +const regexArrayType = new RegExp(/^(.*)\[([0-9]*)\]$/); +function verifyBasicType(type) { + const match = type.match(regexType); + assertArgument(match, "invalid type", "type", type); + if (type === "uint") { + return "uint256"; + } + if (type === "int") { + return "int256"; + } + if (match[2]) { + // bytesXX + const length = parseInt(match[2]); + assertArgument(length !== 0 && length <= 32, "invalid bytes length", "type", type); + } + else if (match[3]) { + // intXX or uintXX + const size = parseInt(match[3]); + assertArgument(size !== 0 && size <= 256 && (size % 8) === 0, "invalid numeric width", "type", type); + } + return type; +} +// Make the Fragment constructors effectively private +const _guard$2 = {}; +const internal$1 = Symbol.for("_ethers_internal"); +const ParamTypeInternal = "_ParamTypeInternal"; +const ErrorFragmentInternal = "_ErrorInternal"; +const EventFragmentInternal = "_EventInternal"; +const ConstructorFragmentInternal = "_ConstructorInternal"; +const FallbackFragmentInternal = "_FallbackInternal"; +const FunctionFragmentInternal = "_FunctionInternal"; +const StructFragmentInternal = "_StructInternal"; +/** + * Each input and output of a [[Fragment]] is an Array of **ParamType**. + */ +class ParamType { + /** + * The local name of the parameter (or ``""`` if unbound) + */ + name; + /** + * The fully qualified type (e.g. ``"address"``, ``"tuple(address)"``, + * ``"uint256[3][]"``) + */ + type; + /** + * The base type (e.g. ``"address"``, ``"tuple"``, ``"array"``) + */ + baseType; + /** + * True if the parameters is indexed. + * + * For non-indexable types this is ``null``. + */ + indexed; + /** + * The components for the tuple. + * + * For non-tuple types this is ``null``. + */ + components; + /** + * The array length, or ``-1`` for dynamic-lengthed arrays. + * + * For non-array types this is ``null``. + */ + arrayLength; + /** + * The type of each child in the array. + * + * For non-array types this is ``null``. + */ + arrayChildren; + /** + * @private + */ + constructor(guard, name, type, baseType, indexed, components, arrayLength, arrayChildren) { + assertPrivate(guard, _guard$2, "ParamType"); + Object.defineProperty(this, internal$1, { value: ParamTypeInternal }); + if (components) { + components = Object.freeze(components.slice()); + } + if (baseType === "array") { + if (arrayLength == null || arrayChildren == null) { + throw new Error(""); + } + } + else if (arrayLength != null || arrayChildren != null) { + throw new Error(""); + } + if (baseType === "tuple") { + if (components == null) { + throw new Error(""); + } + } + else if (components != null) { + throw new Error(""); + } + defineProperties(this, { + name, type, baseType, indexed, components, arrayLength, arrayChildren + }); + } + /** + * Return a string representation of this type. + * + * For example, + * + * ``sighash" => "(uint256,address)"`` + * + * ``"minimal" => "tuple(uint256,address) indexed"`` + * + * ``"full" => "tuple(uint256 foo, address bar) indexed baz"`` + */ + format(format) { + if (format == null) { + format = "sighash"; + } + if (format === "json") { + const name = this.name || ""; + if (this.isArray()) { + const result = JSON.parse(this.arrayChildren.format("json")); + result.name = name; + result.type += `[${(this.arrayLength < 0 ? "" : String(this.arrayLength))}]`; + return JSON.stringify(result); + } + const result = { + type: ((this.baseType === "tuple") ? "tuple" : this.type), + name + }; + if (typeof (this.indexed) === "boolean") { + result.indexed = this.indexed; + } + if (this.isTuple()) { + result.components = this.components.map((c) => JSON.parse(c.format(format))); + } + return JSON.stringify(result); + } + let result = ""; + // Array + if (this.isArray()) { + result += this.arrayChildren.format(format); + result += `[${(this.arrayLength < 0 ? "" : String(this.arrayLength))}]`; + } + else { + if (this.isTuple()) { + result += "(" + this.components.map((comp) => comp.format(format)).join((format === "full") ? ", " : ",") + ")"; + } + else { + result += this.type; + } + } + if (format !== "sighash") { + if (this.indexed === true) { + result += " indexed"; + } + if (format === "full" && this.name) { + result += " " + this.name; + } + } + return result; + } + /** + * Returns true if %%this%% is an Array type. + * + * This provides a type gaurd ensuring that [[arrayChildren]] + * and [[arrayLength]] are non-null. + */ + isArray() { + return (this.baseType === "array"); + } + /** + * Returns true if %%this%% is a Tuple type. + * + * This provides a type gaurd ensuring that [[components]] + * is non-null. + */ + isTuple() { + return (this.baseType === "tuple"); + } + /** + * Returns true if %%this%% is an Indexable type. + * + * This provides a type gaurd ensuring that [[indexed]] + * is non-null. + */ + isIndexable() { + return (this.indexed != null); + } + /** + * Walks the **ParamType** with %%value%%, calling %%process%% + * on each type, destructing the %%value%% recursively. + */ + walk(value, process) { + if (this.isArray()) { + if (!Array.isArray(value)) { + throw new Error("invalid array value"); + } + if (this.arrayLength !== -1 && value.length !== this.arrayLength) { + throw new Error("array is wrong length"); + } + const _this = this; + return value.map((v) => (_this.arrayChildren.walk(v, process))); + } + if (this.isTuple()) { + if (!Array.isArray(value)) { + throw new Error("invalid tuple value"); + } + if (value.length !== this.components.length) { + throw new Error("array is wrong length"); + } + const _this = this; + return value.map((v, i) => (_this.components[i].walk(v, process))); + } + return process(this.type, value); + } + #walkAsync(promises, value, process, setValue) { + if (this.isArray()) { + if (!Array.isArray(value)) { + throw new Error("invalid array value"); + } + if (this.arrayLength !== -1 && value.length !== this.arrayLength) { + throw new Error("array is wrong length"); + } + const childType = this.arrayChildren; + const result = value.slice(); + result.forEach((value, index) => { + childType.#walkAsync(promises, value, process, (value) => { + result[index] = value; + }); + }); + setValue(result); + return; + } + if (this.isTuple()) { + const components = this.components; + // Convert the object into an array + let result; + if (Array.isArray(value)) { + result = value.slice(); + } + else { + if (value == null || typeof (value) !== "object") { + throw new Error("invalid tuple value"); + } + result = components.map((param) => { + if (!param.name) { + throw new Error("cannot use object value with unnamed components"); + } + if (!(param.name in value)) { + throw new Error(`missing value for component ${param.name}`); + } + return value[param.name]; + }); + } + if (result.length !== this.components.length) { + throw new Error("array is wrong length"); + } + result.forEach((value, index) => { + components[index].#walkAsync(promises, value, process, (value) => { + result[index] = value; + }); + }); + setValue(result); + return; + } + const result = process(this.type, value); + if (result.then) { + promises.push((async function () { setValue(await result); })()); + } + else { + setValue(result); + } + } + /** + * Walks the **ParamType** with %%value%%, asynchronously calling + * %%process%% on each type, destructing the %%value%% recursively. + * + * This can be used to resolve ENS naes by walking and resolving each + * ``"address"`` type. + */ + async walkAsync(value, process) { + const promises = []; + const result = [value]; + this.#walkAsync(promises, value, process, (value) => { + result[0] = value; + }); + if (promises.length) { + await Promise.all(promises); + } + return result[0]; + } + /** + * Creates a new **ParamType** for %%obj%%. + * + * If %%allowIndexed%% then the ``indexed`` keyword is permitted, + * otherwise the ``indexed`` keyword will throw an error. + */ + static from(obj, allowIndexed) { + if (ParamType.isParamType(obj)) { + return obj; + } + if (typeof (obj) === "string") { + try { + return ParamType.from(lex(obj), allowIndexed); + } + catch (error) { + assertArgument(false, "invalid param type", "obj", obj); + } + } + else if (obj instanceof TokenString) { + let type = "", baseType = ""; + let comps = null; + if (consumeKeywords(obj, setify(["tuple"])).has("tuple") || obj.peekType("OPEN_PAREN")) { + // Tuple + baseType = "tuple"; + comps = obj.popParams().map((t) => ParamType.from(t)); + type = `tuple(${comps.map((c) => c.format()).join(",")})`; + } + else { + // Normal + type = verifyBasicType(obj.popType("TYPE")); + baseType = type; + } + // Check for Array + let arrayChildren = null; + let arrayLength = null; + while (obj.length && obj.peekType("BRACKET")) { + const bracket = obj.pop(); //arrays[i]; + arrayChildren = new ParamType(_guard$2, "", type, baseType, null, comps, arrayLength, arrayChildren); + arrayLength = bracket.value; + type += bracket.text; + baseType = "array"; + comps = null; + } + let indexed = null; + const keywords = consumeKeywords(obj, KwModifiers); + if (keywords.has("indexed")) { + if (!allowIndexed) { + throw new Error(""); + } + indexed = true; + } + const name = (obj.peekType("ID") ? obj.pop().text : ""); + if (obj.length) { + throw new Error("leftover tokens"); + } + return new ParamType(_guard$2, name, type, baseType, indexed, comps, arrayLength, arrayChildren); + } + const name = obj.name; + assertArgument(!name || (typeof (name) === "string" && name.match(regexId)), "invalid name", "obj.name", name); + let indexed = obj.indexed; + if (indexed != null) { + assertArgument(allowIndexed, "parameter cannot be indexed", "obj.indexed", obj.indexed); + indexed = !!indexed; + } + let type = obj.type; + let arrayMatch = type.match(regexArrayType); + if (arrayMatch) { + const arrayLength = parseInt(arrayMatch[2] || "-1"); + const arrayChildren = ParamType.from({ + type: arrayMatch[1], + components: obj.components + }); + return new ParamType(_guard$2, name || "", type, "array", indexed, null, arrayLength, arrayChildren); + } + if (type === "tuple" || type.startsWith("tuple(" /* fix: ) */) || type.startsWith("(" /* fix: ) */)) { + const comps = (obj.components != null) ? obj.components.map((c) => ParamType.from(c)) : null; + const tuple = new ParamType(_guard$2, name || "", type, "tuple", indexed, comps, null, null); + // @TODO: use lexer to validate and normalize type + return tuple; + } + type = verifyBasicType(obj.type); + return new ParamType(_guard$2, name || "", type, type, indexed, null, null, null); + } + /** + * Returns true if %%value%% is a **ParamType**. + */ + static isParamType(value) { + return (value && value[internal$1] === ParamTypeInternal); + } +} +/** + * An abstract class to represent An individual fragment from a parse ABI. + */ +class Fragment { + /** + * The type of the fragment. + */ + type; + /** + * The inputs for the fragment. + */ + inputs; + /** + * @private + */ + constructor(guard, type, inputs) { + assertPrivate(guard, _guard$2, "Fragment"); + inputs = Object.freeze(inputs.slice()); + defineProperties(this, { type, inputs }); + } + /** + * Creates a new **Fragment** for %%obj%%, wich can be any supported + * ABI frgament type. + */ + static from(obj) { + if (typeof (obj) === "string") { + // Try parsing JSON... + try { + Fragment.from(JSON.parse(obj)); + } + catch (e) { } + // ...otherwise, use the human-readable lexer + return Fragment.from(lex(obj)); + } + if (obj instanceof TokenString) { + // Human-readable ABI (already lexed) + const type = obj.peekKeyword(KwTypes); + switch (type) { + case "constructor": return ConstructorFragment.from(obj); + case "error": return ErrorFragment.from(obj); + case "event": return EventFragment.from(obj); + case "fallback": + case "receive": + return FallbackFragment.from(obj); + case "function": return FunctionFragment.from(obj); + case "struct": return StructFragment.from(obj); + } + } + else if (typeof (obj) === "object") { + // JSON ABI + switch (obj.type) { + case "constructor": return ConstructorFragment.from(obj); + case "error": return ErrorFragment.from(obj); + case "event": return EventFragment.from(obj); + case "fallback": + case "receive": + return FallbackFragment.from(obj); + case "function": return FunctionFragment.from(obj); + case "struct": return StructFragment.from(obj); + } + assert$5(false, `unsupported type: ${obj.type}`, "UNSUPPORTED_OPERATION", { + operation: "Fragment.from" + }); + } + assertArgument(false, "unsupported frgament object", "obj", obj); + } + /** + * Returns true if %%value%% is a [[ConstructorFragment]]. + */ + static isConstructor(value) { + return ConstructorFragment.isFragment(value); + } + /** + * Returns true if %%value%% is an [[ErrorFragment]]. + */ + static isError(value) { + return ErrorFragment.isFragment(value); + } + /** + * Returns true if %%value%% is an [[EventFragment]]. + */ + static isEvent(value) { + return EventFragment.isFragment(value); + } + /** + * Returns true if %%value%% is a [[FunctionFragment]]. + */ + static isFunction(value) { + return FunctionFragment.isFragment(value); + } + /** + * Returns true if %%value%% is a [[StructFragment]]. + */ + static isStruct(value) { + return StructFragment.isFragment(value); + } +} +/** + * An abstract class to represent An individual fragment + * which has a name from a parse ABI. + */ +class NamedFragment extends Fragment { + /** + * The name of the fragment. + */ + name; + /** + * @private + */ + constructor(guard, type, name, inputs) { + super(guard, type, inputs); + assertArgument(typeof (name) === "string" && name.match(regexId), "invalid identifier", "name", name); + inputs = Object.freeze(inputs.slice()); + defineProperties(this, { name }); + } +} +function joinParams(format, params) { + return "(" + params.map((p) => p.format(format)).join((format === "full") ? ", " : ",") + ")"; +} +/** + * A Fragment which represents a //Custom Error//. + */ +class ErrorFragment extends NamedFragment { + /** + * @private + */ + constructor(guard, name, inputs) { + super(guard, "error", name, inputs); + Object.defineProperty(this, internal$1, { value: ErrorFragmentInternal }); + } + /** + * The Custom Error selector. + */ + get selector() { + return id$1(this.format("sighash")).substring(0, 10); + } + /** + * Returns a string representation of this fragment as %%format%%. + */ + format(format) { + if (format == null) { + format = "sighash"; + } + if (format === "json") { + return JSON.stringify({ + type: "error", + name: this.name, + inputs: this.inputs.map((input) => JSON.parse(input.format(format))), + }); + } + const result = []; + if (format !== "sighash") { + result.push("error"); + } + result.push(this.name + joinParams(format, this.inputs)); + return result.join(" "); + } + /** + * Returns a new **ErrorFragment** for %%obj%%. + */ + static from(obj) { + if (ErrorFragment.isFragment(obj)) { + return obj; + } + if (typeof (obj) === "string") { + return ErrorFragment.from(lex(obj)); + } + else if (obj instanceof TokenString) { + const name = consumeName("error", obj); + const inputs = consumeParams(obj); + consumeEoi(obj); + return new ErrorFragment(_guard$2, name, inputs); + } + return new ErrorFragment(_guard$2, obj.name, obj.inputs ? obj.inputs.map(ParamType.from) : []); + } + /** + * Returns ``true`` and provides a type guard if %%value%% is an + * **ErrorFragment**. + */ + static isFragment(value) { + return (value && value[internal$1] === ErrorFragmentInternal); + } +} +/** + * A Fragment which represents an Event. + */ +class EventFragment extends NamedFragment { + /** + * Whether this event is anonymous. + */ + anonymous; + /** + * @private + */ + constructor(guard, name, inputs, anonymous) { + super(guard, "event", name, inputs); + Object.defineProperty(this, internal$1, { value: EventFragmentInternal }); + defineProperties(this, { anonymous }); + } + /** + * The Event topic hash. + */ + get topicHash() { + return id$1(this.format("sighash")); + } + /** + * Returns a string representation of this event as %%format%%. + */ + format(format) { + if (format == null) { + format = "sighash"; + } + if (format === "json") { + return JSON.stringify({ + type: "event", + anonymous: this.anonymous, + name: this.name, + inputs: this.inputs.map((i) => JSON.parse(i.format(format))) + }); + } + const result = []; + if (format !== "sighash") { + result.push("event"); + } + result.push(this.name + joinParams(format, this.inputs)); + if (format !== "sighash" && this.anonymous) { + result.push("anonymous"); + } + return result.join(" "); + } + /** + * Return the topic hash for an event with %%name%% and %%params%%. + */ + static getTopicHash(name, params) { + params = (params || []).map((p) => ParamType.from(p)); + const fragment = new EventFragment(_guard$2, name, params, false); + return fragment.topicHash; + } + /** + * Returns a new **EventFragment** for %%obj%%. + */ + static from(obj) { + if (EventFragment.isFragment(obj)) { + return obj; + } + if (typeof (obj) === "string") { + try { + return EventFragment.from(lex(obj)); + } + catch (error) { + assertArgument(false, "invalid event fragment", "obj", obj); + } + } + else if (obj instanceof TokenString) { + const name = consumeName("event", obj); + const inputs = consumeParams(obj, true); + const anonymous = !!consumeKeywords(obj, setify(["anonymous"])).has("anonymous"); + consumeEoi(obj); + return new EventFragment(_guard$2, name, inputs, anonymous); + } + return new EventFragment(_guard$2, obj.name, obj.inputs ? obj.inputs.map((p) => ParamType.from(p, true)) : [], !!obj.anonymous); + } + /** + * Returns ``true`` and provides a type guard if %%value%% is an + * **EventFragment**. + */ + static isFragment(value) { + return (value && value[internal$1] === EventFragmentInternal); + } +} +/** + * A Fragment which represents a constructor. + */ +class ConstructorFragment extends Fragment { + /** + * Whether the constructor can receive an endowment. + */ + payable; + /** + * The recommended gas limit for deployment or ``null``. + */ + gas; + /** + * @private + */ + constructor(guard, type, inputs, payable, gas) { + super(guard, type, inputs); + Object.defineProperty(this, internal$1, { value: ConstructorFragmentInternal }); + defineProperties(this, { payable, gas }); + } + /** + * Returns a string representation of this constructor as %%format%%. + */ + format(format) { + assert$5(format != null && format !== "sighash", "cannot format a constructor for sighash", "UNSUPPORTED_OPERATION", { operation: "format(sighash)" }); + if (format === "json") { + return JSON.stringify({ + type: "constructor", + stateMutability: (this.payable ? "payable" : "undefined"), + payable: this.payable, + gas: ((this.gas != null) ? this.gas : undefined), + inputs: this.inputs.map((i) => JSON.parse(i.format(format))) + }); + } + const result = [`constructor${joinParams(format, this.inputs)}`]; + if (this.payable) { + result.push("payable"); + } + if (this.gas != null) { + result.push(`@${this.gas.toString()}`); + } + return result.join(" "); + } + /** + * Returns a new **ConstructorFragment** for %%obj%%. + */ + static from(obj) { + if (ConstructorFragment.isFragment(obj)) { + return obj; + } + if (typeof (obj) === "string") { + try { + return ConstructorFragment.from(lex(obj)); + } + catch (error) { + assertArgument(false, "invalid constuctor fragment", "obj", obj); + } + } + else if (obj instanceof TokenString) { + consumeKeywords(obj, setify(["constructor"])); + const inputs = consumeParams(obj); + const payable = !!consumeKeywords(obj, KwVisibDeploy).has("payable"); + const gas = consumeGas(obj); + consumeEoi(obj); + return new ConstructorFragment(_guard$2, "constructor", inputs, payable, gas); + } + return new ConstructorFragment(_guard$2, "constructor", obj.inputs ? obj.inputs.map(ParamType.from) : [], !!obj.payable, (obj.gas != null) ? obj.gas : null); + } + /** + * Returns ``true`` and provides a type guard if %%value%% is a + * **ConstructorFragment**. + */ + static isFragment(value) { + return (value && value[internal$1] === ConstructorFragmentInternal); + } +} +/** + * A Fragment which represents a method. + */ +class FallbackFragment extends Fragment { + /** + * If the function can be sent value during invocation. + */ + payable; + constructor(guard, inputs, payable) { + super(guard, "fallback", inputs); + Object.defineProperty(this, internal$1, { value: FallbackFragmentInternal }); + defineProperties(this, { payable }); + } + /** + * Returns a string representation of this fallback as %%format%%. + */ + format(format) { + const type = ((this.inputs.length === 0) ? "receive" : "fallback"); + if (format === "json") { + const stateMutability = (this.payable ? "payable" : "nonpayable"); + return JSON.stringify({ type, stateMutability }); + } + return `${type}()${this.payable ? " payable" : ""}`; + } + /** + * Returns a new **FallbackFragment** for %%obj%%. + */ + static from(obj) { + if (FallbackFragment.isFragment(obj)) { + return obj; + } + if (typeof (obj) === "string") { + try { + return FallbackFragment.from(lex(obj)); + } + catch (error) { + assertArgument(false, "invalid fallback fragment", "obj", obj); + } + } + else if (obj instanceof TokenString) { + const errorObj = obj.toString(); + const topIsValid = obj.peekKeyword(setify(["fallback", "receive"])); + assertArgument(topIsValid, "type must be fallback or receive", "obj", errorObj); + const type = obj.popKeyword(setify(["fallback", "receive"])); + // receive() + if (type === "receive") { + const inputs = consumeParams(obj); + assertArgument(inputs.length === 0, `receive cannot have arguments`, "obj.inputs", inputs); + consumeKeywords(obj, setify(["payable"])); + consumeEoi(obj); + return new FallbackFragment(_guard$2, [], true); + } + // fallback() [payable] + // fallback(bytes) [payable] returns (bytes) + let inputs = consumeParams(obj); + if (inputs.length) { + assertArgument(inputs.length === 1 && inputs[0].type === "bytes", "invalid fallback inputs", "obj.inputs", inputs.map((i) => i.format("minimal")).join(", ")); + } + else { + inputs = [ParamType.from("bytes")]; + } + const mutability = consumeMutability(obj); + assertArgument(mutability === "nonpayable" || mutability === "payable", "fallback cannot be constants", "obj.stateMutability", mutability); + if (consumeKeywords(obj, setify(["returns"])).has("returns")) { + const outputs = consumeParams(obj); + assertArgument(outputs.length === 1 && outputs[0].type === "bytes", "invalid fallback outputs", "obj.outputs", outputs.map((i) => i.format("minimal")).join(", ")); + } + consumeEoi(obj); + return new FallbackFragment(_guard$2, inputs, mutability === "payable"); + } + if (obj.type === "receive") { + return new FallbackFragment(_guard$2, [], true); + } + if (obj.type === "fallback") { + const inputs = [ParamType.from("bytes")]; + const payable = (obj.stateMutability === "payable"); + return new FallbackFragment(_guard$2, inputs, payable); + } + assertArgument(false, "invalid fallback description", "obj", obj); + } + /** + * Returns ``true`` and provides a type guard if %%value%% is a + * **FallbackFragment**. + */ + static isFragment(value) { + return (value && value[internal$1] === FallbackFragmentInternal); + } +} +/** + * A Fragment which represents a method. + */ +class FunctionFragment extends NamedFragment { + /** + * If the function is constant (e.g. ``pure`` or ``view`` functions). + */ + constant; + /** + * The returned types for the result of calling this function. + */ + outputs; + /** + * The state mutability (e.g. ``payable``, ``nonpayable``, ``view`` + * or ``pure``) + */ + stateMutability; + /** + * If the function can be sent value during invocation. + */ + payable; + /** + * The recommended gas limit to send when calling this function. + */ + gas; + /** + * @private + */ + constructor(guard, name, stateMutability, inputs, outputs, gas) { + super(guard, "function", name, inputs); + Object.defineProperty(this, internal$1, { value: FunctionFragmentInternal }); + outputs = Object.freeze(outputs.slice()); + const constant = (stateMutability === "view" || stateMutability === "pure"); + const payable = (stateMutability === "payable"); + defineProperties(this, { constant, gas, outputs, payable, stateMutability }); + } + /** + * The Function selector. + */ + get selector() { + return id$1(this.format("sighash")).substring(0, 10); + } + /** + * Returns a string representation of this function as %%format%%. + */ + format(format) { + if (format == null) { + format = "sighash"; + } + if (format === "json") { + return JSON.stringify({ + type: "function", + name: this.name, + constant: this.constant, + stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability : undefined), + payable: this.payable, + gas: ((this.gas != null) ? this.gas : undefined), + inputs: this.inputs.map((i) => JSON.parse(i.format(format))), + outputs: this.outputs.map((o) => JSON.parse(o.format(format))), + }); + } + const result = []; + if (format !== "sighash") { + result.push("function"); + } + result.push(this.name + joinParams(format, this.inputs)); + if (format !== "sighash") { + if (this.stateMutability !== "nonpayable") { + result.push(this.stateMutability); + } + if (this.outputs && this.outputs.length) { + result.push("returns"); + result.push(joinParams(format, this.outputs)); + } + if (this.gas != null) { + result.push(`@${this.gas.toString()}`); + } + } + return result.join(" "); + } + /** + * Return the selector for a function with %%name%% and %%params%%. + */ + static getSelector(name, params) { + params = (params || []).map((p) => ParamType.from(p)); + const fragment = new FunctionFragment(_guard$2, name, "view", params, [], null); + return fragment.selector; + } + /** + * Returns a new **FunctionFragment** for %%obj%%. + */ + static from(obj) { + if (FunctionFragment.isFragment(obj)) { + return obj; + } + if (typeof (obj) === "string") { + try { + return FunctionFragment.from(lex(obj)); + } + catch (error) { + assertArgument(false, "invalid function fragment", "obj", obj); + } + } + else if (obj instanceof TokenString) { + const name = consumeName("function", obj); + const inputs = consumeParams(obj); + const mutability = consumeMutability(obj); + let outputs = []; + if (consumeKeywords(obj, setify(["returns"])).has("returns")) { + outputs = consumeParams(obj); + } + const gas = consumeGas(obj); + consumeEoi(obj); + return new FunctionFragment(_guard$2, name, mutability, inputs, outputs, gas); + } + let stateMutability = obj.stateMutability; + // Use legacy Solidity ABI logic if stateMutability is missing + if (stateMutability == null) { + stateMutability = "payable"; + if (typeof (obj.constant) === "boolean") { + stateMutability = "view"; + if (!obj.constant) { + stateMutability = "payable"; + if (typeof (obj.payable) === "boolean" && !obj.payable) { + stateMutability = "nonpayable"; + } + } + } + else if (typeof (obj.payable) === "boolean" && !obj.payable) { + stateMutability = "nonpayable"; + } + } + // @TODO: verifyState for stateMutability (e.g. throw if + // payable: false but stateMutability is "nonpayable") + return new FunctionFragment(_guard$2, obj.name, stateMutability, obj.inputs ? obj.inputs.map(ParamType.from) : [], obj.outputs ? obj.outputs.map(ParamType.from) : [], (obj.gas != null) ? obj.gas : null); + } + /** + * Returns ``true`` and provides a type guard if %%value%% is a + * **FunctionFragment**. + */ + static isFragment(value) { + return (value && value[internal$1] === FunctionFragmentInternal); + } +} +/** + * A Fragment which represents a structure. + */ +class StructFragment extends NamedFragment { + /** + * @private + */ + constructor(guard, name, inputs) { + super(guard, "struct", name, inputs); + Object.defineProperty(this, internal$1, { value: StructFragmentInternal }); + } + /** + * Returns a string representation of this struct as %%format%%. + */ + format() { + throw new Error("@TODO"); + } + /** + * Returns a new **StructFragment** for %%obj%%. + */ + static from(obj) { + if (typeof (obj) === "string") { + try { + return StructFragment.from(lex(obj)); + } + catch (error) { + assertArgument(false, "invalid struct fragment", "obj", obj); + } + } + else if (obj instanceof TokenString) { + const name = consumeName("struct", obj); + const inputs = consumeParams(obj); + consumeEoi(obj); + return new StructFragment(_guard$2, name, inputs); + } + return new StructFragment(_guard$2, obj.name, obj.inputs ? obj.inputs.map(ParamType.from) : []); + } + // @TODO: fix this return type + /** + * Returns ``true`` and provides a type guard if %%value%% is a + * **StructFragment**. + */ + static isFragment(value) { + return (value && value[internal$1] === StructFragmentInternal); + } +} + +/** + * When sending values to or receiving values from a [[Contract]], the + * data is generally encoded using the [ABI standard](link-solc-abi). + * + * The AbiCoder provides a utility to encode values to ABI data and + * decode values from ABI data. + * + * Most of the time, developers should favour the [[Contract]] class, + * which further abstracts a lot of the finer details of ABI data. + * + * @_section api/abi/abi-coder:ABI Encoding + */ +// See: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI +// https://docs.soliditylang.org/en/v0.8.17/control-structures.html +const PanicReasons$1 = new Map(); +PanicReasons$1.set(0x00, "GENERIC_PANIC"); +PanicReasons$1.set(0x01, "ASSERT_FALSE"); +PanicReasons$1.set(0x11, "OVERFLOW"); +PanicReasons$1.set(0x12, "DIVIDE_BY_ZERO"); +PanicReasons$1.set(0x21, "ENUM_RANGE_ERROR"); +PanicReasons$1.set(0x22, "BAD_STORAGE_DATA"); +PanicReasons$1.set(0x31, "STACK_UNDERFLOW"); +PanicReasons$1.set(0x32, "ARRAY_RANGE_ERROR"); +PanicReasons$1.set(0x41, "OUT_OF_MEMORY"); +PanicReasons$1.set(0x51, "UNINITIALIZED_FUNCTION_CALL"); +const paramTypeBytes = new RegExp(/^bytes([0-9]*)$/); +const paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/); +let defaultCoder = null; +let defaultMaxInflation = 1024; +function getBuiltinCallException(action, tx, data, abiCoder) { + let message = "missing revert data"; + let reason = null; + const invocation = null; + let revert = null; + if (data) { + message = "execution reverted"; + const bytes = getBytes(data); + data = hexlify(data); + if (bytes.length === 0) { + message += " (no data present; likely require(false) occurred"; + reason = "require(false)"; + } + else if (bytes.length % 32 !== 4) { + message += " (could not decode reason; invalid data length)"; + } + else if (hexlify(bytes.slice(0, 4)) === "0x08c379a0") { + // Error(string) + try { + reason = abiCoder.decode(["string"], bytes.slice(4))[0]; + revert = { + signature: "Error(string)", + name: "Error", + args: [reason] + }; + message += `: ${JSON.stringify(reason)}`; + } + catch (error) { + message += " (could not decode reason; invalid string data)"; + } + } + else if (hexlify(bytes.slice(0, 4)) === "0x4e487b71") { + // Panic(uint256) + try { + const code = Number(abiCoder.decode(["uint256"], bytes.slice(4))[0]); + revert = { + signature: "Panic(uint256)", + name: "Panic", + args: [code] + }; + reason = `Panic due to ${PanicReasons$1.get(code) || "UNKNOWN"}(${code})`; + message += `: ${reason}`; + } + catch (error) { + message += " (could not decode panic code)"; + } + } + else { + message += " (unknown custom error)"; + } + } + const transaction = { + to: (tx.to ? getAddress(tx.to) : null), + data: (tx.data || "0x") + }; + if (tx.from) { + transaction.from = getAddress(tx.from); + } + return makeError(message, "CALL_EXCEPTION", { + action, data, reason, transaction, invocation, revert + }); +} +/** + * The **AbiCoder** is a low-level class responsible for encoding JavaScript + * values into binary data and decoding binary data into JavaScript values. + */ +class AbiCoder { + #getCoder(param) { + if (param.isArray()) { + return new ArrayCoder(this.#getCoder(param.arrayChildren), param.arrayLength, param.name); + } + if (param.isTuple()) { + return new TupleCoder(param.components.map((c) => this.#getCoder(c)), param.name); + } + switch (param.baseType) { + case "address": + return new AddressCoder(param.name); + case "bool": + return new BooleanCoder(param.name); + case "string": + return new StringCoder(param.name); + case "bytes": + return new BytesCoder(param.name); + case "": + return new NullCoder(param.name); + } + // u?int[0-9]* + let match = param.type.match(paramTypeNumber); + if (match) { + let size = parseInt(match[2] || "256"); + assertArgument(size !== 0 && size <= 256 && (size % 8) === 0, "invalid " + match[1] + " bit length", "param", param); + return new NumberCoder(size / 8, (match[1] === "int"), param.name); + } + // bytes[0-9]+ + match = param.type.match(paramTypeBytes); + if (match) { + let size = parseInt(match[1]); + assertArgument(size !== 0 && size <= 32, "invalid bytes length", "param", param); + return new FixedBytesCoder(size, param.name); + } + assertArgument(false, "invalid type", "type", param.type); + } + /** + * Get the default values for the given %%types%%. + * + * For example, a ``uint`` is by default ``0`` and ``bool`` + * is by default ``false``. + */ + getDefaultValue(types) { + const coders = types.map((type) => this.#getCoder(ParamType.from(type))); + const coder = new TupleCoder(coders, "_"); + return coder.defaultValue(); + } + /** + * Encode the %%values%% as the %%types%% into ABI data. + * + * @returns DataHexstring + */ + encode(types, values) { + assertArgumentCount(values.length, types.length, "types/values length mismatch"); + const coders = types.map((type) => this.#getCoder(ParamType.from(type))); + const coder = (new TupleCoder(coders, "_")); + const writer = new Writer(); + coder.encode(writer, values); + return writer.data; + } + /** + * Decode the ABI %%data%% as the %%types%% into values. + * + * If %%loose%% decoding is enabled, then strict padding is + * not enforced. Some older versions of Solidity incorrectly + * padded event data emitted from ``external`` functions. + */ + decode(types, data, loose) { + const coders = types.map((type) => this.#getCoder(ParamType.from(type))); + const coder = new TupleCoder(coders, "_"); + return coder.decode(new Reader(data, loose, defaultMaxInflation)); + } + static _setDefaultMaxInflation(value) { + assertArgument(typeof (value) === "number" && Number.isInteger(value), "invalid defaultMaxInflation factor", "value", value); + defaultMaxInflation = value; + } + /** + * Returns the shared singleton instance of a default [[AbiCoder]]. + * + * On the first call, the instance is created internally. + */ + static defaultAbiCoder() { + if (defaultCoder == null) { + defaultCoder = new AbiCoder(); + } + return defaultCoder; + } + /** + * Returns an ethers-compatible [[CallExceptionError]] Error for the given + * result %%data%% for the [[CallExceptionAction]] %%action%% against + * the Transaction %%tx%%. + */ + static getBuiltinCallException(action, tx, data) { + return getBuiltinCallException(action, tx, data, AbiCoder.defaultAbiCoder()); + } +} + +/** + * The Interface class is a low-level class that accepts an + * ABI and provides all the necessary functionality to encode + * and decode paramaters to and results from methods, events + * and errors. + * + * It also provides several convenience methods to automatically + * search and find matching transactions and events to parse them. + * + * @_subsection api/abi:Interfaces [interfaces] + */ +/** + * When using the [[Interface-parseLog]] to automatically match a Log to its event + * for parsing, a **LogDescription** is returned. + */ +class LogDescription { + /** + * The matching fragment for the ``topic0``. + */ + fragment; + /** + * The name of the Event. + */ + name; + /** + * The full Event signature. + */ + signature; + /** + * The topic hash for the Event. + */ + topic; + /** + * The arguments passed into the Event with ``emit``. + */ + args; + /** + * @_ignore: + */ + constructor(fragment, topic, args) { + const name = fragment.name, signature = fragment.format(); + defineProperties(this, { + fragment, name, signature, topic, args + }); + } +} +/** + * When using the [[Interface-parseTransaction]] to automatically match + * a transaction data to its function for parsing, + * a **TransactionDescription** is returned. + */ +class TransactionDescription { + /** + * The matching fragment from the transaction ``data``. + */ + fragment; + /** + * The name of the Function from the transaction ``data``. + */ + name; + /** + * The arguments passed to the Function from the transaction ``data``. + */ + args; + /** + * The full Function signature from the transaction ``data``. + */ + signature; + /** + * The selector for the Function from the transaction ``data``. + */ + selector; + /** + * The ``value`` (in wei) from the transaction. + */ + value; + /** + * @_ignore: + */ + constructor(fragment, selector, args, value) { + const name = fragment.name, signature = fragment.format(); + defineProperties(this, { + fragment, name, args, signature, selector, value + }); + } +} +/** + * When using the [[Interface-parseError]] to automatically match an + * error for a call result for parsing, an **ErrorDescription** is returned. + */ +class ErrorDescription { + /** + * The matching fragment. + */ + fragment; + /** + * The name of the Error. + */ + name; + /** + * The arguments passed to the Error with ``revert``. + */ + args; + /** + * The full Error signature. + */ + signature; + /** + * The selector for the Error. + */ + selector; + /** + * @_ignore: + */ + constructor(fragment, selector, args) { + const name = fragment.name, signature = fragment.format(); + defineProperties(this, { + fragment, name, args, signature, selector + }); + } +} +/** + * An **Indexed** is used as a value when a value that does not + * fit within a topic (i.e. not a fixed-length, 32-byte type). It + * is the ``keccak256`` of the value, and used for types such as + * arrays, tuples, bytes and strings. + */ +class Indexed { + /** + * The ``keccak256`` of the value logged. + */ + hash; + /** + * @_ignore: + */ + _isIndexed; + /** + * Returns ``true`` if %%value%% is an **Indexed**. + * + * This provides a Type Guard for property access. + */ + static isIndexed(value) { + return !!(value && value._isIndexed); + } + /** + * @_ignore: + */ + constructor(hash) { + defineProperties(this, { hash, _isIndexed: true }); + } +} +// https://docs.soliditylang.org/en/v0.8.13/control-structures.html?highlight=panic#panic-via-assert-and-error-via-require +const PanicReasons = { + "0": "generic panic", + "1": "assert(false)", + "17": "arithmetic overflow", + "18": "division or modulo by zero", + "33": "enum overflow", + "34": "invalid encoded storage byte array accessed", + "49": "out-of-bounds array access; popping on an empty array", + "50": "out-of-bounds access of an array or bytesN", + "65": "out of memory", + "81": "uninitialized function", +}; +const BuiltinErrors = { + "0x08c379a0": { + signature: "Error(string)", + name: "Error", + inputs: ["string"], + reason: (message) => { + return `reverted with reason string ${JSON.stringify(message)}`; + } + }, + "0x4e487b71": { + signature: "Panic(uint256)", + name: "Panic", + inputs: ["uint256"], + reason: (code) => { + let reason = "unknown panic code"; + if (code >= 0 && code <= 0xff && PanicReasons[code.toString()]) { + reason = PanicReasons[code.toString()]; + } + return `reverted with panic code 0x${code.toString(16)} (${reason})`; + } + } +}; +/** + * An Interface abstracts many of the low-level details for + * encoding and decoding the data on the blockchain. + * + * An ABI provides information on how to encode data to send to + * a Contract, how to decode the results and events and how to + * interpret revert errors. + * + * The ABI can be specified by [any supported format](InterfaceAbi). + */ +class Interface { + /** + * All the Contract ABI members (i.e. methods, events, errors, etc). + */ + fragments; + /** + * The Contract constructor. + */ + deploy; + /** + * The Fallback method, if any. + */ + fallback; + /** + * If receiving ether is supported. + */ + receive; + #errors; + #events; + #functions; + // #structs: Map; + #abiCoder; + /** + * Create a new Interface for the %%fragments%%. + */ + constructor(fragments) { + let abi = []; + if (typeof (fragments) === "string") { + abi = JSON.parse(fragments); + } + else { + abi = fragments; + } + this.#functions = new Map(); + this.#errors = new Map(); + this.#events = new Map(); + // this.#structs = new Map(); + const frags = []; + for (const a of abi) { + try { + frags.push(Fragment.from(a)); + } + catch (error) { + console.log(`[Warning] Invalid Fragment ${JSON.stringify(a)}:`, error.message); + } + } + defineProperties(this, { + fragments: Object.freeze(frags) + }); + let fallback = null; + let receive = false; + this.#abiCoder = this.getAbiCoder(); + // Add all fragments by their signature + this.fragments.forEach((fragment, index) => { + let bucket; + switch (fragment.type) { + case "constructor": + if (this.deploy) { + console.log("duplicate definition - constructor"); + return; + } + //checkNames(fragment, "input", fragment.inputs); + defineProperties(this, { deploy: fragment }); + return; + case "fallback": + if (fragment.inputs.length === 0) { + receive = true; + } + else { + assertArgument(!fallback || fragment.payable !== fallback.payable, "conflicting fallback fragments", `fragments[${index}]`, fragment); + fallback = fragment; + receive = fallback.payable; + } + return; + case "function": + //checkNames(fragment, "input", fragment.inputs); + //checkNames(fragment, "output", (fragment).outputs); + bucket = this.#functions; + break; + case "event": + //checkNames(fragment, "input", fragment.inputs); + bucket = this.#events; + break; + case "error": + bucket = this.#errors; + break; + default: + return; + } + // Two identical entries; ignore it + const signature = fragment.format(); + if (bucket.has(signature)) { + return; + } + bucket.set(signature, fragment); + }); + // If we do not have a constructor add a default + if (!this.deploy) { + defineProperties(this, { + deploy: ConstructorFragment.from("constructor()") + }); + } + defineProperties(this, { fallback, receive }); + } + /** + * Returns the entire Human-Readable ABI, as an array of + * signatures, optionally as %%minimal%% strings, which + * removes parameter names and unneceesary spaces. + */ + format(minimal) { + const format = (minimal ? "minimal" : "full"); + const abi = this.fragments.map((f) => f.format(format)); + return abi; + } + /** + * Return the JSON-encoded ABI. This is the format Solidiy + * returns. + */ + formatJson() { + const abi = this.fragments.map((f) => f.format("json")); + // We need to re-bundle the JSON fragments a bit + return JSON.stringify(abi.map((j) => JSON.parse(j))); + } + /** + * The ABI coder that will be used to encode and decode binary + * data. + */ + getAbiCoder() { + return AbiCoder.defaultAbiCoder(); + } + // Find a function definition by any means necessary (unless it is ambiguous) + #getFunction(key, values, forceUnique) { + // Selector + if (isHexString$1(key)) { + const selector = key.toLowerCase(); + for (const fragment of this.#functions.values()) { + if (selector === fragment.selector) { + return fragment; + } + } + return null; + } + // It is a bare name, look up the function (will return null if ambiguous) + if (key.indexOf("(") === -1) { + const matching = []; + for (const [name, fragment] of this.#functions) { + if (name.split("(" /* fix:) */)[0] === key) { + matching.push(fragment); + } + } + if (values) { + const lastValue = (values.length > 0) ? values[values.length - 1] : null; + let valueLength = values.length; + let allowOptions = true; + if (Typed.isTyped(lastValue) && lastValue.type === "overrides") { + allowOptions = false; + valueLength--; + } + // Remove all matches that don't have a compatible length. The args + // may contain an overrides, so the match may have n or n - 1 parameters + for (let i = matching.length - 1; i >= 0; i--) { + const inputs = matching[i].inputs.length; + if (inputs !== valueLength && (!allowOptions || inputs !== valueLength - 1)) { + matching.splice(i, 1); + } + } + // Remove all matches that don't match the Typed signature + for (let i = matching.length - 1; i >= 0; i--) { + const inputs = matching[i].inputs; + for (let j = 0; j < values.length; j++) { + // Not a typed value + if (!Typed.isTyped(values[j])) { + continue; + } + // We are past the inputs + if (j >= inputs.length) { + if (values[j].type === "overrides") { + continue; + } + matching.splice(i, 1); + break; + } + // Make sure the value type matches the input type + if (values[j].type !== inputs[j].baseType) { + matching.splice(i, 1); + break; + } + } + } + } + // We found a single matching signature with an overrides, but the + // last value is something that cannot possibly be an options + if (matching.length === 1 && values && values.length !== matching[0].inputs.length) { + const lastArg = values[values.length - 1]; + if (lastArg == null || Array.isArray(lastArg) || typeof (lastArg) !== "object") { + matching.splice(0, 1); + } + } + if (matching.length === 0) { + return null; + } + if (matching.length > 1 && forceUnique) { + const matchStr = matching.map((m) => JSON.stringify(m.format())).join(", "); + assertArgument(false, `ambiguous function description (i.e. matches ${matchStr})`, "key", key); + } + return matching[0]; + } + // Normalize the signature and lookup the function + const result = this.#functions.get(FunctionFragment.from(key).format()); + if (result) { + return result; + } + return null; + } + /** + * Get the function name for %%key%%, which may be a function selector, + * function name or function signature that belongs to the ABI. + */ + getFunctionName(key) { + const fragment = this.#getFunction(key, null, false); + assertArgument(fragment, "no matching function", "key", key); + return fragment.name; + } + /** + * Returns true if %%key%% (a function selector, function name or + * function signature) is present in the ABI. + * + * In the case of a function name, the name may be ambiguous, so + * accessing the [[FunctionFragment]] may require refinement. + */ + hasFunction(key) { + return !!this.#getFunction(key, null, false); + } + /** + * Get the [[FunctionFragment]] for %%key%%, which may be a function + * selector, function name or function signature that belongs to the ABI. + * + * If %%values%% is provided, it will use the Typed API to handle + * ambiguous cases where multiple functions match by name. + * + * If the %%key%% and %%values%% do not refine to a single function in + * the ABI, this will throw. + */ + getFunction(key, values) { + return this.#getFunction(key, values || null, true); + } + /** + * Iterate over all functions, calling %%callback%%, sorted by their name. + */ + forEachFunction(callback) { + const names = Array.from(this.#functions.keys()); + names.sort((a, b) => a.localeCompare(b)); + for (let i = 0; i < names.length; i++) { + const name = names[i]; + callback((this.#functions.get(name)), i); + } + } + // Find an event definition by any means necessary (unless it is ambiguous) + #getEvent(key, values, forceUnique) { + // EventTopic + if (isHexString$1(key)) { + const eventTopic = key.toLowerCase(); + for (const fragment of this.#events.values()) { + if (eventTopic === fragment.topicHash) { + return fragment; + } + } + return null; + } + // It is a bare name, look up the function (will return null if ambiguous) + if (key.indexOf("(") === -1) { + const matching = []; + for (const [name, fragment] of this.#events) { + if (name.split("(" /* fix:) */)[0] === key) { + matching.push(fragment); + } + } + if (values) { + // Remove all matches that don't have a compatible length. + for (let i = matching.length - 1; i >= 0; i--) { + if (matching[i].inputs.length < values.length) { + matching.splice(i, 1); + } + } + // Remove all matches that don't match the Typed signature + for (let i = matching.length - 1; i >= 0; i--) { + const inputs = matching[i].inputs; + for (let j = 0; j < values.length; j++) { + // Not a typed value + if (!Typed.isTyped(values[j])) { + continue; + } + // Make sure the value type matches the input type + if (values[j].type !== inputs[j].baseType) { + matching.splice(i, 1); + break; + } + } + } + } + if (matching.length === 0) { + return null; + } + if (matching.length > 1 && forceUnique) { + const matchStr = matching.map((m) => JSON.stringify(m.format())).join(", "); + assertArgument(false, `ambiguous event description (i.e. matches ${matchStr})`, "key", key); + } + return matching[0]; + } + // Normalize the signature and lookup the function + const result = this.#events.get(EventFragment.from(key).format()); + if (result) { + return result; + } + return null; + } + /** + * Get the event name for %%key%%, which may be a topic hash, + * event name or event signature that belongs to the ABI. + */ + getEventName(key) { + const fragment = this.#getEvent(key, null, false); + assertArgument(fragment, "no matching event", "key", key); + return fragment.name; + } + /** + * Returns true if %%key%% (an event topic hash, event name or + * event signature) is present in the ABI. + * + * In the case of an event name, the name may be ambiguous, so + * accessing the [[EventFragment]] may require refinement. + */ + hasEvent(key) { + return !!this.#getEvent(key, null, false); + } + /** + * Get the [[EventFragment]] for %%key%%, which may be a topic hash, + * event name or event signature that belongs to the ABI. + * + * If %%values%% is provided, it will use the Typed API to handle + * ambiguous cases where multiple events match by name. + * + * If the %%key%% and %%values%% do not refine to a single event in + * the ABI, this will throw. + */ + getEvent(key, values) { + return this.#getEvent(key, values || null, true); + } + /** + * Iterate over all events, calling %%callback%%, sorted by their name. + */ + forEachEvent(callback) { + const names = Array.from(this.#events.keys()); + names.sort((a, b) => a.localeCompare(b)); + for (let i = 0; i < names.length; i++) { + const name = names[i]; + callback((this.#events.get(name)), i); + } + } + /** + * Get the [[ErrorFragment]] for %%key%%, which may be an error + * selector, error name or error signature that belongs to the ABI. + * + * If %%values%% is provided, it will use the Typed API to handle + * ambiguous cases where multiple errors match by name. + * + * If the %%key%% and %%values%% do not refine to a single error in + * the ABI, this will throw. + */ + getError(key, values) { + if (isHexString$1(key)) { + const selector = key.toLowerCase(); + if (BuiltinErrors[selector]) { + return ErrorFragment.from(BuiltinErrors[selector].signature); + } + for (const fragment of this.#errors.values()) { + if (selector === fragment.selector) { + return fragment; + } + } + return null; + } + // It is a bare name, look up the function (will return null if ambiguous) + if (key.indexOf("(") === -1) { + const matching = []; + for (const [name, fragment] of this.#errors) { + if (name.split("(" /* fix:) */)[0] === key) { + matching.push(fragment); + } + } + if (matching.length === 0) { + if (key === "Error") { + return ErrorFragment.from("error Error(string)"); + } + if (key === "Panic") { + return ErrorFragment.from("error Panic(uint256)"); + } + return null; + } + else if (matching.length > 1) { + const matchStr = matching.map((m) => JSON.stringify(m.format())).join(", "); + assertArgument(false, `ambiguous error description (i.e. ${matchStr})`, "name", key); + } + return matching[0]; + } + // Normalize the signature and lookup the function + key = ErrorFragment.from(key).format(); + if (key === "Error(string)") { + return ErrorFragment.from("error Error(string)"); + } + if (key === "Panic(uint256)") { + return ErrorFragment.from("error Panic(uint256)"); + } + const result = this.#errors.get(key); + if (result) { + return result; + } + return null; + } + /** + * Iterate over all errors, calling %%callback%%, sorted by their name. + */ + forEachError(callback) { + const names = Array.from(this.#errors.keys()); + names.sort((a, b) => a.localeCompare(b)); + for (let i = 0; i < names.length; i++) { + const name = names[i]; + callback((this.#errors.get(name)), i); + } + } + // Get the 4-byte selector used by Solidity to identify a function + /* +getSelector(fragment: ErrorFragment | FunctionFragment): string { + if (typeof(fragment) === "string") { + const matches: Array = [ ]; + + try { matches.push(this.getFunction(fragment)); } catch (error) { } + try { matches.push(this.getError(fragment)); } catch (_) { } + + if (matches.length === 0) { + logger.throwArgumentError("unknown fragment", "key", fragment); + } else if (matches.length > 1) { + logger.throwArgumentError("ambiguous fragment matches function and error", "key", fragment); + } + + fragment = matches[0]; + } + + return dataSlice(id(fragment.format()), 0, 4); +} + */ + // Get the 32-byte topic hash used by Solidity to identify an event + /* + getEventTopic(fragment: EventFragment): string { + //if (typeof(fragment) === "string") { fragment = this.getEvent(eventFragment); } + return id(fragment.format()); + } + */ + _decodeParams(params, data) { + return this.#abiCoder.decode(params, data); + } + _encodeParams(params, values) { + return this.#abiCoder.encode(params, values); + } + /** + * Encodes a ``tx.data`` object for deploying the Contract with + * the %%values%% as the constructor arguments. + */ + encodeDeploy(values) { + return this._encodeParams(this.deploy.inputs, values || []); + } + /** + * Decodes the result %%data%% (e.g. from an ``eth_call``) for the + * specified error (see [[getError]] for valid values for + * %%key%%). + * + * Most developers should prefer the [[parseCallResult]] method instead, + * which will automatically detect a ``CALL_EXCEPTION`` and throw the + * corresponding error. + */ + decodeErrorResult(fragment, data) { + if (typeof (fragment) === "string") { + const f = this.getError(fragment); + assertArgument(f, "unknown error", "fragment", fragment); + fragment = f; + } + assertArgument(dataSlice(data, 0, 4) === fragment.selector, `data signature does not match error ${fragment.name}.`, "data", data); + return this._decodeParams(fragment.inputs, dataSlice(data, 4)); + } + /** + * Encodes the transaction revert data for a call result that + * reverted from the the Contract with the sepcified %%error%% + * (see [[getError]] for valid values for %%fragment%%) with the %%values%%. + * + * This is generally not used by most developers, unless trying to mock + * a result from a Contract. + */ + encodeErrorResult(fragment, values) { + if (typeof (fragment) === "string") { + const f = this.getError(fragment); + assertArgument(f, "unknown error", "fragment", fragment); + fragment = f; + } + return concat$3([ + fragment.selector, + this._encodeParams(fragment.inputs, values || []) + ]); + } + /** + * Decodes the %%data%% from a transaction ``tx.data`` for + * the function specified (see [[getFunction]] for valid values + * for %%fragment%%). + * + * Most developers should prefer the [[parseTransaction]] method + * instead, which will automatically detect the fragment. + */ + decodeFunctionData(fragment, data) { + if (typeof (fragment) === "string") { + const f = this.getFunction(fragment); + assertArgument(f, "unknown function", "fragment", fragment); + fragment = f; + } + assertArgument(dataSlice(data, 0, 4) === fragment.selector, `data signature does not match function ${fragment.name}.`, "data", data); + return this._decodeParams(fragment.inputs, dataSlice(data, 4)); + } + /** + * Encodes the ``tx.data`` for a transaction that calls the function + * specified (see [[getFunction]] for valid values for %%fragment%%) with + * the %%values%%. + */ + encodeFunctionData(fragment, values) { + if (typeof (fragment) === "string") { + const f = this.getFunction(fragment); + assertArgument(f, "unknown function", "fragment", fragment); + fragment = f; + } + return concat$3([ + fragment.selector, + this._encodeParams(fragment.inputs, values || []) + ]); + } + /** + * Decodes the result %%data%% (e.g. from an ``eth_call``) for the + * specified function (see [[getFunction]] for valid values for + * %%key%%). + * + * Most developers should prefer the [[parseCallResult]] method instead, + * which will automatically detect a ``CALL_EXCEPTION`` and throw the + * corresponding error. + */ + decodeFunctionResult(fragment, data) { + if (typeof (fragment) === "string") { + const f = this.getFunction(fragment); + assertArgument(f, "unknown function", "fragment", fragment); + fragment = f; + } + let message = "invalid length for result data"; + const bytes = getBytesCopy(data); + if ((bytes.length % 32) === 0) { + try { + return this.#abiCoder.decode(fragment.outputs, bytes); + } + catch (error) { + message = "could not decode result data"; + } + } + // Call returned data with no error, but the data is junk + assert$5(false, message, "BAD_DATA", { + value: hexlify(bytes), + info: { method: fragment.name, signature: fragment.format() } + }); + } + makeError(_data, tx) { + const data = getBytes(_data, "data"); + const error = AbiCoder.getBuiltinCallException("call", tx, data); + // Not a built-in error; try finding a custom error + const customPrefix = "execution reverted (unknown custom error)"; + if (error.message.startsWith(customPrefix)) { + const selector = hexlify(data.slice(0, 4)); + const ef = this.getError(selector); + if (ef) { + try { + const args = this.#abiCoder.decode(ef.inputs, data.slice(4)); + error.revert = { + name: ef.name, signature: ef.format(), args + }; + error.reason = error.revert.signature; + error.message = `execution reverted: ${error.reason}`; + } + catch (e) { + error.message = `execution reverted (coult not decode custom error)`; + } + } + } + // Add the invocation, if available + const parsed = this.parseTransaction(tx); + if (parsed) { + error.invocation = { + method: parsed.name, + signature: parsed.signature, + args: parsed.args + }; + } + return error; + } + /** + * Encodes the result data (e.g. from an ``eth_call``) for the + * specified function (see [[getFunction]] for valid values + * for %%fragment%%) with %%values%%. + * + * This is generally not used by most developers, unless trying to mock + * a result from a Contract. + */ + encodeFunctionResult(fragment, values) { + if (typeof (fragment) === "string") { + const f = this.getFunction(fragment); + assertArgument(f, "unknown function", "fragment", fragment); + fragment = f; + } + return hexlify(this.#abiCoder.encode(fragment.outputs, values || [])); + } + /* + spelunk(inputs: Array, values: ReadonlyArray, processfunc: (type: string, value: any) => Promise): Promise> { + const promises: Array> = [ ]; + const process = function(type: ParamType, value: any): any { + if (type.baseType === "array") { + return descend(type.child + } + if (type. === "address") { + } + }; + + const descend = function (inputs: Array, values: ReadonlyArray) { + if (inputs.length !== values.length) { throw new Error("length mismatch"); } + + }; + + const result: Array = [ ]; + values.forEach((value, index) => { + if (value == null) { + topics.push(null); + } else if (param.baseType === "array" || param.baseType === "tuple") { + logger.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value); + } else if (Array.isArray(value)) { + topics.push(value.map((value) => encodeTopic(param, value))); + } else { + topics.push(encodeTopic(param, value)); + } + }); + } + */ + // Create the filter for the event with search criteria (e.g. for eth_filterLog) + encodeFilterTopics(fragment, values) { + if (typeof (fragment) === "string") { + const f = this.getEvent(fragment); + assertArgument(f, "unknown event", "eventFragment", fragment); + fragment = f; + } + assert$5(values.length <= fragment.inputs.length, `too many arguments for ${fragment.format()}`, "UNEXPECTED_ARGUMENT", { count: values.length, expectedCount: fragment.inputs.length }); + const topics = []; + if (!fragment.anonymous) { + topics.push(fragment.topicHash); + } + // @TODO: Use the coders for this; to properly support tuples, etc. + const encodeTopic = (param, value) => { + if (param.type === "string") { + return id$1(value); + } + else if (param.type === "bytes") { + return keccak256$1(hexlify(value)); + } + if (param.type === "bool" && typeof (value) === "boolean") { + value = (value ? "0x01" : "0x00"); + } + else if (param.type.match(/^u?int/)) { + value = toBeHex(value); // @TODO: Should this toTwos?? + } + else if (param.type.match(/^bytes/)) { + value = zeroPadBytes(value, 32); + } + else if (param.type === "address") { + // Check addresses are valid + this.#abiCoder.encode(["address"], [value]); + } + return zeroPadValue(hexlify(value), 32); + }; + values.forEach((value, index) => { + const param = fragment.inputs[index]; + if (!param.indexed) { + assertArgument(value == null, "cannot filter non-indexed parameters; must be null", ("contract." + param.name), value); + return; + } + if (value == null) { + topics.push(null); + } + else if (param.baseType === "array" || param.baseType === "tuple") { + assertArgument(false, "filtering with tuples or arrays not supported", ("contract." + param.name), value); + } + else if (Array.isArray(value)) { + topics.push(value.map((value) => encodeTopic(param, value))); + } + else { + topics.push(encodeTopic(param, value)); + } + }); + // Trim off trailing nulls + while (topics.length && topics[topics.length - 1] === null) { + topics.pop(); + } + return topics; + } + encodeEventLog(fragment, values) { + if (typeof (fragment) === "string") { + const f = this.getEvent(fragment); + assertArgument(f, "unknown event", "eventFragment", fragment); + fragment = f; + } + const topics = []; + const dataTypes = []; + const dataValues = []; + if (!fragment.anonymous) { + topics.push(fragment.topicHash); + } + assertArgument(values.length === fragment.inputs.length, "event arguments/values mismatch", "values", values); + fragment.inputs.forEach((param, index) => { + const value = values[index]; + if (param.indexed) { + if (param.type === "string") { + topics.push(id$1(value)); + } + else if (param.type === "bytes") { + topics.push(keccak256$1(value)); + } + else if (param.baseType === "tuple" || param.baseType === "array") { + // @TODO + throw new Error("not implemented"); + } + else { + topics.push(this.#abiCoder.encode([param.type], [value])); + } + } + else { + dataTypes.push(param); + dataValues.push(value); + } + }); + return { + data: this.#abiCoder.encode(dataTypes, dataValues), + topics: topics + }; + } + // Decode a filter for the event and the search criteria + decodeEventLog(fragment, data, topics) { + if (typeof (fragment) === "string") { + const f = this.getEvent(fragment); + assertArgument(f, "unknown event", "eventFragment", fragment); + fragment = f; + } + if (topics != null && !fragment.anonymous) { + const eventTopic = fragment.topicHash; + assertArgument(isHexString$1(topics[0], 32) && topics[0].toLowerCase() === eventTopic, "fragment/topic mismatch", "topics[0]", topics[0]); + topics = topics.slice(1); + } + const indexed = []; + const nonIndexed = []; + const dynamic = []; + fragment.inputs.forEach((param, index) => { + if (param.indexed) { + if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") { + indexed.push(ParamType.from({ type: "bytes32", name: param.name })); + dynamic.push(true); + } + else { + indexed.push(param); + dynamic.push(false); + } + } + else { + nonIndexed.push(param); + dynamic.push(false); + } + }); + const resultIndexed = (topics != null) ? this.#abiCoder.decode(indexed, concat$3(topics)) : null; + const resultNonIndexed = this.#abiCoder.decode(nonIndexed, data, true); + //const result: (Array & { [ key: string ]: any }) = [ ]; + const values = []; + const keys = []; + let nonIndexedIndex = 0, indexedIndex = 0; + fragment.inputs.forEach((param, index) => { + let value = null; + if (param.indexed) { + if (resultIndexed == null) { + value = new Indexed(null); + } + else if (dynamic[index]) { + value = new Indexed(resultIndexed[indexedIndex++]); + } + else { + try { + value = resultIndexed[indexedIndex++]; + } + catch (error) { + value = error; + } + } + } + else { + try { + value = resultNonIndexed[nonIndexedIndex++]; + } + catch (error) { + value = error; + } + } + values.push(value); + keys.push(param.name || null); + }); + return Result.fromItems(values, keys); + } + /** + * Parses a transaction, finding the matching function and extracts + * the parameter values along with other useful function details. + * + * If the matching function cannot be found, return null. + */ + parseTransaction(tx) { + const data = getBytes(tx.data, "tx.data"); + const value = getBigInt((tx.value != null) ? tx.value : 0, "tx.value"); + const fragment = this.getFunction(hexlify(data.slice(0, 4))); + if (!fragment) { + return null; + } + const args = this.#abiCoder.decode(fragment.inputs, data.slice(4)); + return new TransactionDescription(fragment, fragment.selector, args, value); + } + parseCallResult(data) { + throw new Error("@TODO"); + } + /** + * Parses a receipt log, finding the matching event and extracts + * the parameter values along with other useful event details. + * + * If the matching event cannot be found, returns null. + */ + parseLog(log) { + const fragment = this.getEvent(log.topics[0]); + if (!fragment || fragment.anonymous) { + return null; + } + // @TODO: If anonymous, and the only method, and the input count matches, should we parse? + // Probably not, because just because it is the only event in the ABI does + // not mean we have the full ABI; maybe just a fragment? + return new LogDescription(fragment, fragment.topicHash, this.decodeEventLog(fragment, log.data, log.topics)); + } + /** + * Parses a revert data, finding the matching error and extracts + * the parameter values along with other useful error details. + * + * If the matching error cannot be found, returns null. + */ + parseError(data) { + const hexData = hexlify(data); + const fragment = this.getError(dataSlice(hexData, 0, 4)); + if (!fragment) { + return null; + } + const args = this.#abiCoder.decode(fragment.inputs, dataSlice(hexData, 4)); + return new ErrorDescription(fragment, fragment.selector, args); + } + /** + * Creates a new [[Interface]] from the ABI %%value%%. + * + * The %%value%% may be provided as an existing [[Interface]] object, + * a JSON-encoded ABI or any Human-Readable ABI format. + */ + static from(value) { + // Already an Interface, which is immutable + if (value instanceof Interface) { + return value; + } + // JSON + if (typeof (value) === "string") { + return new Interface(JSON.parse(value)); + } + // Maybe an interface from an older version, or from a symlinked copy + if (typeof (value.format) === "function") { + return new Interface(value.format("json")); + } + // Array of fragments + return new Interface(value); + } +} + +//import { resolveAddress } from "@ethersproject/address"; +const BN_0$2 = BigInt(0); +// ----------------------- +function getValue(value) { + if (value == null) { + return null; + } + return value; +} +function toJson(value) { + if (value == null) { + return null; + } + return value.toString(); +} +// @TODO? implements Required +/** + * A **FeeData** wraps all the fee-related values associated with + * the network. + */ +class FeeData { + /** + * The gas price for legacy networks. + */ + gasPrice; + /** + * The maximum fee to pay per gas. + * + * The base fee per gas is defined by the network and based on + * congestion, increasing the cost during times of heavy load + * and lowering when less busy. + * + * The actual fee per gas will be the base fee for the block + * and the priority fee, up to the max fee per gas. + * + * This will be ``null`` on legacy networks (i.e. [pre-EIP-1559](link-eip-1559)) + */ + maxFeePerGas; + /** + * The additional amout to pay per gas to encourage a validator + * to include the transaction. + * + * The purpose of this is to compensate the validator for the + * adjusted risk for including a given transaction. + * + * This will be ``null`` on legacy networks (i.e. [pre-EIP-1559](link-eip-1559)) + */ + maxPriorityFeePerGas; + /** + * Creates a new FeeData for %%gasPrice%%, %%maxFeePerGas%% and + * %%maxPriorityFeePerGas%%. + */ + constructor(gasPrice, maxFeePerGas, maxPriorityFeePerGas) { + defineProperties(this, { + gasPrice: getValue(gasPrice), + maxFeePerGas: getValue(maxFeePerGas), + maxPriorityFeePerGas: getValue(maxPriorityFeePerGas) + }); + } + /** + * Returns a JSON-friendly value. + */ + toJSON() { + const { gasPrice, maxFeePerGas, maxPriorityFeePerGas } = this; + return { + _type: "FeeData", + gasPrice: toJson(gasPrice), + maxFeePerGas: toJson(maxFeePerGas), + maxPriorityFeePerGas: toJson(maxPriorityFeePerGas), + }; + } +} +/** + * Returns a copy of %%req%% with all properties coerced to their strict + * types. + */ +function copyRequest(req) { + const result = {}; + // These could be addresses, ENS names or Addressables + if (req.to) { + result.to = req.to; + } + if (req.from) { + result.from = req.from; + } + if (req.data) { + result.data = hexlify(req.data); + } + const bigIntKeys = "chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/); + for (const key of bigIntKeys) { + if (!(key in req) || req[key] == null) { + continue; + } + result[key] = getBigInt(req[key], `request.${key}`); + } + const numberKeys = "type,nonce".split(/,/); + for (const key of numberKeys) { + if (!(key in req) || req[key] == null) { + continue; + } + result[key] = getNumber(req[key], `request.${key}`); + } + if (req.accessList) { + result.accessList = accessListify(req.accessList); + } + if ("blockTag" in req) { + result.blockTag = req.blockTag; + } + if ("enableCcipRead" in req) { + result.enableCcipRead = !!req.enableCcipRead; + } + if ("customData" in req) { + result.customData = req.customData; + } + if ("blobVersionedHashes" in req && req.blobVersionedHashes) { + result.blobVersionedHashes = req.blobVersionedHashes.slice(); + } + if ("kzg" in req) { + result.kzg = req.kzg; + } + if ("blobs" in req && req.blobs) { + result.blobs = req.blobs.map((b) => { + if (isBytesLike(b)) { + return hexlify(b); + } + return Object.assign({}, b); + }); + } + return result; +} +/** + * A **Block** represents the data associated with a full block on + * Ethereum. + */ +class Block { + /** + * The provider connected to the block used to fetch additional details + * if necessary. + */ + provider; + /** + * The block number, sometimes called the block height. This is a + * sequential number that is one higher than the parent block. + */ + number; + /** + * The block hash. + * + * This hash includes all properties, so can be safely used to identify + * an exact set of block properties. + */ + hash; + /** + * The timestamp for this block, which is the number of seconds since + * epoch that this block was included. + */ + timestamp; + /** + * The block hash of the parent block. + */ + parentHash; + /** + * The hash tree root of the parent beacon block for the given + * execution block. See [[link-eip-4788]]. + */ + parentBeaconBlockRoot; + /** + * The nonce. + * + * On legacy networks, this is the random number inserted which + * permitted the difficulty target to be reached. + */ + nonce; + /** + * The difficulty target. + * + * On legacy networks, this is the proof-of-work target required + * for a block to meet the protocol rules to be included. + * + * On modern networks, this is a random number arrived at using + * randao. @TODO: Find links? + */ + difficulty; + /** + * The total gas limit for this block. + */ + gasLimit; + /** + * The total gas used in this block. + */ + gasUsed; + /** + * The root hash for the global state after applying changes + * in this block. + */ + stateRoot; + /** + * The hash of the transaction receipts trie. + */ + receiptsRoot; + /** + * The total amount of blob gas consumed by the transactions + * within the block. See [[link-eip-4844]]. + */ + blobGasUsed; + /** + * The running total of blob gas consumed in excess of the + * target, prior to the block. See [[link-eip-4844]]. + */ + excessBlobGas; + /** + * The miner coinbase address, wihch receives any subsidies for + * including this block. + */ + miner; + /** + * The latest RANDAO mix of the post beacon state of + * the previous block. + */ + prevRandao; + /** + * Any extra data the validator wished to include. + */ + extraData; + /** + * The base fee per gas that all transactions in this block were + * charged. + * + * This adjusts after each block, depending on how congested the network + * is. + */ + baseFeePerGas; + #transactions; + /** + * Create a new **Block** object. + * + * This should generally not be necessary as the unless implementing a + * low-level library. + */ + constructor(block, provider) { + this.#transactions = block.transactions.map((tx) => { + if (typeof (tx) !== "string") { + return new TransactionResponse(tx, provider); + } + return tx; + }); + defineProperties(this, { + provider, + hash: getValue(block.hash), + number: block.number, + timestamp: block.timestamp, + parentHash: block.parentHash, + parentBeaconBlockRoot: block.parentBeaconBlockRoot, + nonce: block.nonce, + difficulty: block.difficulty, + gasLimit: block.gasLimit, + gasUsed: block.gasUsed, + blobGasUsed: block.blobGasUsed, + excessBlobGas: block.excessBlobGas, + miner: block.miner, + prevRandao: getValue(block.prevRandao), + extraData: block.extraData, + baseFeePerGas: getValue(block.baseFeePerGas), + stateRoot: block.stateRoot, + receiptsRoot: block.receiptsRoot, + }); + } + /** + * Returns the list of transaction hashes, in the order + * they were executed within the block. + */ + get transactions() { + return this.#transactions.map((tx) => { + if (typeof (tx) === "string") { + return tx; + } + return tx.hash; + }); + } + /** + * Returns the complete transactions, in the order they + * were executed within the block. + * + * This is only available for blocks which prefetched + * transactions, by passing ``true`` to %%prefetchTxs%% + * into [[Provider-getBlock]]. + */ + get prefetchedTransactions() { + const txs = this.#transactions.slice(); + // Doesn't matter... + if (txs.length === 0) { + return []; + } + // Make sure we prefetched the transactions + assert$5(typeof (txs[0]) === "object", "transactions were not prefetched with block request", "UNSUPPORTED_OPERATION", { + operation: "transactionResponses()" + }); + return txs; + } + /** + * Returns a JSON-friendly value. + */ + toJSON() { + const { baseFeePerGas, difficulty, extraData, gasLimit, gasUsed, hash, miner, prevRandao, nonce, number, parentHash, parentBeaconBlockRoot, stateRoot, receiptsRoot, timestamp, transactions } = this; + return { + _type: "Block", + baseFeePerGas: toJson(baseFeePerGas), + difficulty: toJson(difficulty), + extraData, + gasLimit: toJson(gasLimit), + gasUsed: toJson(gasUsed), + blobGasUsed: toJson(this.blobGasUsed), + excessBlobGas: toJson(this.excessBlobGas), + hash, miner, prevRandao, nonce, number, parentHash, timestamp, + parentBeaconBlockRoot, stateRoot, receiptsRoot, + transactions, + }; + } + [Symbol.iterator]() { + let index = 0; + const txs = this.transactions; + return { + next: () => { + if (index < this.length) { + return { + value: txs[index++], done: false + }; + } + return { value: undefined, done: true }; + } + }; + } + /** + * The number of transactions in this block. + */ + get length() { return this.#transactions.length; } + /** + * The [[link-js-date]] this block was included at. + */ + get date() { + if (this.timestamp == null) { + return null; + } + return new Date(this.timestamp * 1000); + } + /** + * Get the transaction at %%indexe%% within this block. + */ + async getTransaction(indexOrHash) { + // Find the internal value by its index or hash + let tx = undefined; + if (typeof (indexOrHash) === "number") { + tx = this.#transactions[indexOrHash]; + } + else { + const hash = indexOrHash.toLowerCase(); + for (const v of this.#transactions) { + if (typeof (v) === "string") { + if (v !== hash) { + continue; + } + tx = v; + break; + } + else { + if (v.hash === hash) { + continue; + } + tx = v; + break; + } + } + } + if (tx == null) { + throw new Error("no such tx"); + } + if (typeof (tx) === "string") { + return (await this.provider.getTransaction(tx)); + } + else { + return tx; + } + } + /** + * If a **Block** was fetched with a request to include the transactions + * this will allow synchronous access to those transactions. + * + * If the transactions were not prefetched, this will throw. + */ + getPrefetchedTransaction(indexOrHash) { + const txs = this.prefetchedTransactions; + if (typeof (indexOrHash) === "number") { + return txs[indexOrHash]; + } + indexOrHash = indexOrHash.toLowerCase(); + for (const tx of txs) { + if (tx.hash === indexOrHash) { + return tx; + } + } + assertArgument(false, "no matching transaction", "indexOrHash", indexOrHash); + } + /** + * Returns true if this block been mined. This provides a type guard + * for all properties on a [[MinedBlock]]. + */ + isMined() { return !!this.hash; } + /** + * Returns true if this block is an [[link-eip-2930]] block. + */ + isLondon() { + return !!this.baseFeePerGas; + } + /** + * @_ignore: + */ + orphanedEvent() { + if (!this.isMined()) { + throw new Error(""); + } + return createOrphanedBlockFilter(this); + } +} +////////////////////// +// Log +/** + * A **Log** in Ethereum represents an event that has been included in a + * transaction using the ``LOG*`` opcodes, which are most commonly used by + * Solidity's emit for announcing events. + */ +class Log { + /** + * The provider connected to the log used to fetch additional details + * if necessary. + */ + provider; + /** + * The transaction hash of the transaction this log occurred in. Use the + * [[Log-getTransaction]] to get the [[TransactionResponse]]. + */ + transactionHash; + /** + * The block hash of the block this log occurred in. Use the + * [[Log-getBlock]] to get the [[Block]]. + */ + blockHash; + /** + * The block number of the block this log occurred in. It is preferred + * to use the [[Block-hash]] when fetching the related [[Block]], + * since in the case of an orphaned block, the block at that height may + * have changed. + */ + blockNumber; + /** + * If the **Log** represents a block that was removed due to an orphaned + * block, this will be true. + * + * This can only happen within an orphan event listener. + */ + removed; + /** + * The address of the contract that emitted this log. + */ + address; + /** + * The data included in this log when it was emitted. + */ + data; + /** + * The indexed topics included in this log when it was emitted. + * + * All topics are included in the bloom filters, so they can be + * efficiently filtered using the [[Provider-getLogs]] method. + */ + topics; + /** + * The index within the block this log occurred at. This is generally + * not useful to developers, but can be used with the various roots + * to proof inclusion within a block. + */ + index; + /** + * The index within the transaction of this log. + */ + transactionIndex; + /** + * @_ignore: + */ + constructor(log, provider) { + this.provider = provider; + const topics = Object.freeze(log.topics.slice()); + defineProperties(this, { + transactionHash: log.transactionHash, + blockHash: log.blockHash, + blockNumber: log.blockNumber, + removed: log.removed, + address: log.address, + data: log.data, + topics, + index: log.index, + transactionIndex: log.transactionIndex, + }); + } + /** + * Returns a JSON-compatible object. + */ + toJSON() { + const { address, blockHash, blockNumber, data, index, removed, topics, transactionHash, transactionIndex } = this; + return { + _type: "log", + address, blockHash, blockNumber, data, index, + removed, topics, transactionHash, transactionIndex + }; + } + /** + * Returns the block that this log occurred in. + */ + async getBlock() { + const block = await this.provider.getBlock(this.blockHash); + assert$5(!!block, "failed to find transaction", "UNKNOWN_ERROR", {}); + return block; + } + /** + * Returns the transaction that this log occurred in. + */ + async getTransaction() { + const tx = await this.provider.getTransaction(this.transactionHash); + assert$5(!!tx, "failed to find transaction", "UNKNOWN_ERROR", {}); + return tx; + } + /** + * Returns the transaction receipt fot the transaction that this + * log occurred in. + */ + async getTransactionReceipt() { + const receipt = await this.provider.getTransactionReceipt(this.transactionHash); + assert$5(!!receipt, "failed to find transaction receipt", "UNKNOWN_ERROR", {}); + return receipt; + } + /** + * @_ignore: + */ + removedEvent() { + return createRemovedLogFilter(this); + } +} +////////////////////// +// Transaction Receipt +/* +export interface LegacyTransactionReceipt { + byzantium: false; + status: null; + root: string; +} + +export interface ByzantiumTransactionReceipt { + byzantium: true; + status: number; + root: null; +} +*/ +/** + * A **TransactionReceipt** includes additional information about a + * transaction that is only available after it has been mined. + */ +class TransactionReceipt { + /** + * The provider connected to the log used to fetch additional details + * if necessary. + */ + provider; + /** + * The address the transaction was sent to. + */ + to; + /** + * The sender of the transaction. + */ + from; + /** + * The address of the contract if the transaction was directly + * responsible for deploying one. + * + * This is non-null **only** if the ``to`` is empty and the ``data`` + * was successfully executed as initcode. + */ + contractAddress; + /** + * The transaction hash. + */ + hash; + /** + * The index of this transaction within the block transactions. + */ + index; + /** + * The block hash of the [[Block]] this transaction was included in. + */ + blockHash; + /** + * The block number of the [[Block]] this transaction was included in. + */ + blockNumber; + /** + * The bloom filter bytes that represent all logs that occurred within + * this transaction. This is generally not useful for most developers, + * but can be used to validate the included logs. + */ + logsBloom; + /** + * The actual amount of gas used by this transaction. + * + * When creating a transaction, the amount of gas that will be used can + * only be approximated, but the sender must pay the gas fee for the + * entire gas limit. After the transaction, the difference is refunded. + */ + gasUsed; + /** + * The gas used for BLObs. See [[link-eip-4844]]. + */ + blobGasUsed; + /** + * The amount of gas used by all transactions within the block for this + * and all transactions with a lower ``index``. + * + * This is generally not useful for developers but can be used to + * validate certain aspects of execution. + */ + cumulativeGasUsed; + /** + * The actual gas price used during execution. + * + * Due to the complexity of [[link-eip-1559]] this value can only + * be caluclated after the transaction has been mined, snce the base + * fee is protocol-enforced. + */ + gasPrice; + /** + * The price paid per BLOB in gas. See [[link-eip-4844]]. + */ + blobGasPrice; + /** + * The [[link-eip-2718]] transaction type. + */ + type; + //readonly byzantium!: boolean; + /** + * The status of this transaction, indicating success (i.e. ``1``) or + * a revert (i.e. ``0``). + * + * This is available in post-byzantium blocks, but some backends may + * backfill this value. + */ + status; + /** + * The root hash of this transaction. + * + * This is no present and was only included in pre-byzantium blocks, but + * could be used to validate certain parts of the receipt. + */ + root; + #logs; + /** + * @_ignore: + */ + constructor(tx, provider) { + this.#logs = Object.freeze(tx.logs.map((log) => { + return new Log(log, provider); + })); + let gasPrice = BN_0$2; + if (tx.effectiveGasPrice != null) { + gasPrice = tx.effectiveGasPrice; + } + else if (tx.gasPrice != null) { + gasPrice = tx.gasPrice; + } + defineProperties(this, { + provider, + to: tx.to, + from: tx.from, + contractAddress: tx.contractAddress, + hash: tx.hash, + index: tx.index, + blockHash: tx.blockHash, + blockNumber: tx.blockNumber, + logsBloom: tx.logsBloom, + gasUsed: tx.gasUsed, + cumulativeGasUsed: tx.cumulativeGasUsed, + blobGasUsed: tx.blobGasUsed, + gasPrice, + blobGasPrice: tx.blobGasPrice, + type: tx.type, + //byzantium: tx.byzantium, + status: tx.status, + root: tx.root + }); + } + /** + * The logs for this transaction. + */ + get logs() { return this.#logs; } + /** + * Returns a JSON-compatible representation. + */ + toJSON() { + const { to, from, contractAddress, hash, index, blockHash, blockNumber, logsBloom, logs, //byzantium, + status, root } = this; + return { + _type: "TransactionReceipt", + blockHash, blockNumber, + //byzantium, + contractAddress, + cumulativeGasUsed: toJson(this.cumulativeGasUsed), + from, + gasPrice: toJson(this.gasPrice), + blobGasUsed: toJson(this.blobGasUsed), + blobGasPrice: toJson(this.blobGasPrice), + gasUsed: toJson(this.gasUsed), + hash, index, logs, logsBloom, root, status, to + }; + } + /** + * @_ignore: + */ + get length() { return this.logs.length; } + [Symbol.iterator]() { + let index = 0; + return { + next: () => { + if (index < this.length) { + return { value: this.logs[index++], done: false }; + } + return { value: undefined, done: true }; + } + }; + } + /** + * The total fee for this transaction, in wei. + */ + get fee() { + return this.gasUsed * this.gasPrice; + } + /** + * Resolves to the block this transaction occurred in. + */ + async getBlock() { + const block = await this.provider.getBlock(this.blockHash); + if (block == null) { + throw new Error("TODO"); + } + return block; + } + /** + * Resolves to the transaction this transaction occurred in. + */ + async getTransaction() { + const tx = await this.provider.getTransaction(this.hash); + if (tx == null) { + throw new Error("TODO"); + } + return tx; + } + /** + * Resolves to the return value of the execution of this transaction. + * + * Support for this feature is limited, as it requires an archive node + * with the ``debug_`` or ``trace_`` API enabled. + */ + async getResult() { + return (await this.provider.getTransactionResult(this.hash)); + } + /** + * Resolves to the number of confirmations this transaction has. + */ + async confirmations() { + return (await this.provider.getBlockNumber()) - this.blockNumber + 1; + } + /** + * @_ignore: + */ + removedEvent() { + return createRemovedTransactionFilter(this); + } + /** + * @_ignore: + */ + reorderedEvent(other) { + assert$5(!other || other.isMined(), "unmined 'other' transction cannot be orphaned", "UNSUPPORTED_OPERATION", { operation: "reorderedEvent(other)" }); + return createReorderedTransactionFilter(this, other); + } +} +/** + * A **TransactionResponse** includes all properties about a transaction + * that was sent to the network, which may or may not be included in a + * block. + * + * The [[TransactionResponse-isMined]] can be used to check if the + * transaction has been mined as well as type guard that the otherwise + * possibly ``null`` properties are defined. + */ +class TransactionResponse { + /** + * The provider this is connected to, which will influence how its + * methods will resolve its async inspection methods. + */ + provider; + /** + * The block number of the block that this transaction was included in. + * + * This is ``null`` for pending transactions. + */ + blockNumber; + /** + * The blockHash of the block that this transaction was included in. + * + * This is ``null`` for pending transactions. + */ + blockHash; + /** + * The index within the block that this transaction resides at. + */ + index; + /** + * The transaction hash. + */ + hash; + /** + * The [[link-eip-2718]] transaction envelope type. This is + * ``0`` for legacy transactions types. + */ + type; + /** + * The receiver of this transaction. + * + * If ``null``, then the transaction is an initcode transaction. + * This means the result of executing the [[data]] will be deployed + * as a new contract on chain (assuming it does not revert) and the + * address may be computed using [[getCreateAddress]]. + */ + to; + /** + * The sender of this transaction. It is implicitly computed + * from the transaction pre-image hash (as the digest) and the + * [[signature]] using ecrecover. + */ + from; + /** + * The nonce, which is used to prevent replay attacks and offer + * a method to ensure transactions from a given sender are explicitly + * ordered. + * + * When sending a transaction, this must be equal to the number of + * transactions ever sent by [[from]]. + */ + nonce; + /** + * The maximum units of gas this transaction can consume. If execution + * exceeds this, the entries transaction is reverted and the sender + * is charged for the full amount, despite not state changes being made. + */ + gasLimit; + /** + * The gas price can have various values, depending on the network. + * + * In modern networks, for transactions that are included this is + * the //effective gas price// (the fee per gas that was actually + * charged), while for transactions that have not been included yet + * is the [[maxFeePerGas]]. + * + * For legacy transactions, or transactions on legacy networks, this + * is the fee that will be charged per unit of gas the transaction + * consumes. + */ + gasPrice; + /** + * The maximum priority fee (per unit of gas) to allow a + * validator to charge the sender. This is inclusive of the + * [[maxFeeFeePerGas]]. + */ + maxPriorityFeePerGas; + /** + * The maximum fee (per unit of gas) to allow this transaction + * to charge the sender. + */ + maxFeePerGas; + /** + * The [[link-eip-4844]] max fee per BLOb gas. + */ + maxFeePerBlobGas; + /** + * The data. + */ + data; + /** + * The value, in wei. Use [[formatEther]] to format this value + * as ether. + */ + value; + /** + * The chain ID. + */ + chainId; + /** + * The signature. + */ + signature; + /** + * The [[link-eip-2930]] access list for transaction types that + * support it, otherwise ``null``. + */ + accessList; + /** + * The [[link-eip-4844]] BLOb versioned hashes. + */ + blobVersionedHashes; + #startBlock; + /** + * @_ignore: + */ + constructor(tx, provider) { + this.provider = provider; + this.blockNumber = (tx.blockNumber != null) ? tx.blockNumber : null; + this.blockHash = (tx.blockHash != null) ? tx.blockHash : null; + this.hash = tx.hash; + this.index = tx.index; + this.type = tx.type; + this.from = tx.from; + this.to = tx.to || null; + this.gasLimit = tx.gasLimit; + this.nonce = tx.nonce; + this.data = tx.data; + this.value = tx.value; + this.gasPrice = tx.gasPrice; + this.maxPriorityFeePerGas = (tx.maxPriorityFeePerGas != null) ? tx.maxPriorityFeePerGas : null; + this.maxFeePerGas = (tx.maxFeePerGas != null) ? tx.maxFeePerGas : null; + this.maxFeePerBlobGas = (tx.maxFeePerBlobGas != null) ? tx.maxFeePerBlobGas : null; + this.chainId = tx.chainId; + this.signature = tx.signature; + this.accessList = (tx.accessList != null) ? tx.accessList : null; + this.blobVersionedHashes = (tx.blobVersionedHashes != null) ? tx.blobVersionedHashes : null; + this.#startBlock = -1; + } + /** + * Returns a JSON-compatible representation of this transaction. + */ + toJSON() { + const { blockNumber, blockHash, index, hash, type, to, from, nonce, data, signature, accessList, blobVersionedHashes } = this; + return { + _type: "TransactionResponse", + accessList, blockNumber, blockHash, + blobVersionedHashes, + chainId: toJson(this.chainId), + data, from, + gasLimit: toJson(this.gasLimit), + gasPrice: toJson(this.gasPrice), + hash, + maxFeePerGas: toJson(this.maxFeePerGas), + maxPriorityFeePerGas: toJson(this.maxPriorityFeePerGas), + maxFeePerBlobGas: toJson(this.maxFeePerBlobGas), + nonce, signature, to, index, type, + value: toJson(this.value), + }; + } + /** + * Resolves to the Block that this transaction was included in. + * + * This will return null if the transaction has not been included yet. + */ + async getBlock() { + let blockNumber = this.blockNumber; + if (blockNumber == null) { + const tx = await this.getTransaction(); + if (tx) { + blockNumber = tx.blockNumber; + } + } + if (blockNumber == null) { + return null; + } + const block = this.provider.getBlock(blockNumber); + if (block == null) { + throw new Error("TODO"); + } + return block; + } + /** + * Resolves to this transaction being re-requested from the + * provider. This can be used if you have an unmined transaction + * and wish to get an up-to-date populated instance. + */ + async getTransaction() { + return this.provider.getTransaction(this.hash); + } + /** + * Resolve to the number of confirmations this transaction has. + */ + async confirmations() { + if (this.blockNumber == null) { + const { tx, blockNumber } = await resolveProperties({ + tx: this.getTransaction(), + blockNumber: this.provider.getBlockNumber() + }); + // Not mined yet... + if (tx == null || tx.blockNumber == null) { + return 0; + } + return blockNumber - tx.blockNumber + 1; + } + const blockNumber = await this.provider.getBlockNumber(); + return blockNumber - this.blockNumber + 1; + } + /** + * Resolves once this transaction has been mined and has + * %%confirms%% blocks including it (default: ``1``) with an + * optional %%timeout%%. + * + * This can resolve to ``null`` only if %%confirms%% is ``0`` + * and the transaction has not been mined, otherwise this will + * wait until enough confirmations have completed. + */ + async wait(_confirms, _timeout) { + const confirms = (_confirms == null) ? 1 : _confirms; + const timeout = (_timeout == null) ? 0 : _timeout; + let startBlock = this.#startBlock; + let nextScan = -1; + let stopScanning = (startBlock === -1) ? true : false; + const checkReplacement = async () => { + // Get the current transaction count for this sender + if (stopScanning) { + return null; + } + const { blockNumber, nonce } = await resolveProperties({ + blockNumber: this.provider.getBlockNumber(), + nonce: this.provider.getTransactionCount(this.from) + }); + // No transaction or our nonce has not been mined yet; but we + // can start scanning later when we do start + if (nonce < this.nonce) { + startBlock = blockNumber; + return; + } + // We were mined; no replacement + if (stopScanning) { + return null; + } + const mined = await this.getTransaction(); + if (mined && mined.blockNumber != null) { + return; + } + // We were replaced; start scanning for that transaction + // Starting to scan; look back a few extra blocks for safety + if (nextScan === -1) { + nextScan = startBlock - 3; + if (nextScan < this.#startBlock) { + nextScan = this.#startBlock; + } + } + while (nextScan <= blockNumber) { + // Get the next block to scan + if (stopScanning) { + return null; + } + const block = await this.provider.getBlock(nextScan, true); + // This should not happen; but we'll try again shortly + if (block == null) { + return; + } + // We were mined; no replacement + for (const hash of block) { + if (hash === this.hash) { + return; + } + } + // Search for the transaction that replaced us + for (let i = 0; i < block.length; i++) { + const tx = await block.getTransaction(i); + if (tx.from === this.from && tx.nonce === this.nonce) { + // Get the receipt + if (stopScanning) { + return null; + } + const receipt = await this.provider.getTransactionReceipt(tx.hash); + // This should not happen; but we'll try again shortly + if (receipt == null) { + return; + } + // We will retry this on the next block (this case could be optimized) + if ((blockNumber - receipt.blockNumber + 1) < confirms) { + return; + } + // The reason we were replaced + let reason = "replaced"; + if (tx.data === this.data && tx.to === this.to && tx.value === this.value) { + reason = "repriced"; + } + else if (tx.data === "0x" && tx.from === tx.to && tx.value === BN_0$2) { + reason = "cancelled"; + } + assert$5(false, "transaction was replaced", "TRANSACTION_REPLACED", { + cancelled: (reason === "replaced" || reason === "cancelled"), + reason, + replacement: tx.replaceableTransaction(startBlock), + hash: tx.hash, + receipt + }); + } + } + nextScan++; + } + return; + }; + const checkReceipt = (receipt) => { + if (receipt == null || receipt.status !== 0) { + return receipt; + } + assert$5(false, "transaction execution reverted", "CALL_EXCEPTION", { + action: "sendTransaction", + data: null, reason: null, invocation: null, revert: null, + transaction: { + to: receipt.to, + from: receipt.from, + data: "" // @TODO: in v7, split out sendTransaction properties + }, receipt + }); + }; + const receipt = await this.provider.getTransactionReceipt(this.hash); + if (confirms === 0) { + return checkReceipt(receipt); + } + if (receipt) { + if ((await receipt.confirmations()) >= confirms) { + return checkReceipt(receipt); + } + } + else { + // Check for a replacement; throws if a replacement was found + await checkReplacement(); + // Allow null only when the confirms is 0 + if (confirms === 0) { + return null; + } + } + const waiter = new Promise((resolve, reject) => { + // List of things to cancel when we have a result (one way or the other) + const cancellers = []; + const cancel = () => { cancellers.forEach((c) => c()); }; + // On cancel, stop scanning for replacements + cancellers.push(() => { stopScanning = true; }); + // Set up any timeout requested + if (timeout > 0) { + const timer = setTimeout(() => { + cancel(); + reject(makeError("wait for transaction timeout", "TIMEOUT")); + }, timeout); + cancellers.push(() => { clearTimeout(timer); }); + } + const txListener = async (receipt) => { + // Done; return it! + if ((await receipt.confirmations()) >= confirms) { + cancel(); + try { + resolve(checkReceipt(receipt)); + } + catch (error) { + reject(error); + } + } + }; + cancellers.push(() => { this.provider.off(this.hash, txListener); }); + this.provider.on(this.hash, txListener); + // We support replacement detection; start checking + if (startBlock >= 0) { + const replaceListener = async () => { + try { + // Check for a replacement; this throws only if one is found + await checkReplacement(); + } + catch (error) { + // We were replaced (with enough confirms); re-throw the error + if (isError(error, "TRANSACTION_REPLACED")) { + cancel(); + reject(error); + return; + } + } + // Rescheudle a check on the next block + if (!stopScanning) { + this.provider.once("block", replaceListener); + } + }; + cancellers.push(() => { this.provider.off("block", replaceListener); }); + this.provider.once("block", replaceListener); + } + }); + return await waiter; + } + /** + * Returns ``true`` if this transaction has been included. + * + * This is effective only as of the time the TransactionResponse + * was instantiated. To get up-to-date information, use + * [[getTransaction]]. + * + * This provides a Type Guard that this transaction will have + * non-null property values for properties that are null for + * unmined transactions. + */ + isMined() { + return (this.blockHash != null); + } + /** + * Returns true if the transaction is a legacy (i.e. ``type == 0``) + * transaction. + * + * This provides a Type Guard that this transaction will have + * the ``null``-ness for hardfork-specific properties set correctly. + */ + isLegacy() { + return (this.type === 0); + } + /** + * Returns true if the transaction is a Berlin (i.e. ``type == 1``) + * transaction. See [[link-eip-2070]]. + * + * This provides a Type Guard that this transaction will have + * the ``null``-ness for hardfork-specific properties set correctly. + */ + isBerlin() { + return (this.type === 1); + } + /** + * Returns true if the transaction is a London (i.e. ``type == 2``) + * transaction. See [[link-eip-1559]]. + * + * This provides a Type Guard that this transaction will have + * the ``null``-ness for hardfork-specific properties set correctly. + */ + isLondon() { + return (this.type === 2); + } + /** + * Returns true if hte transaction is a Cancun (i.e. ``type == 3``) + * transaction. See [[link-eip-4844]]. + */ + isCancun() { + return (this.type === 3); + } + /** + * Returns a filter which can be used to listen for orphan events + * that evict this transaction. + */ + removedEvent() { + assert$5(this.isMined(), "unmined transaction canot be orphaned", "UNSUPPORTED_OPERATION", { operation: "removeEvent()" }); + return createRemovedTransactionFilter(this); + } + /** + * Returns a filter which can be used to listen for orphan events + * that re-order this event against %%other%%. + */ + reorderedEvent(other) { + assert$5(this.isMined(), "unmined transaction canot be orphaned", "UNSUPPORTED_OPERATION", { operation: "removeEvent()" }); + assert$5(!other || other.isMined(), "unmined 'other' transaction canot be orphaned", "UNSUPPORTED_OPERATION", { operation: "removeEvent()" }); + return createReorderedTransactionFilter(this, other); + } + /** + * Returns a new TransactionResponse instance which has the ability to + * detect (and throw an error) if the transaction is replaced, which + * will begin scanning at %%startBlock%%. + * + * This should generally not be used by developers and is intended + * primarily for internal use. Setting an incorrect %%startBlock%% can + * have devastating performance consequences if used incorrectly. + */ + replaceableTransaction(startBlock) { + assertArgument(Number.isInteger(startBlock) && startBlock >= 0, "invalid startBlock", "startBlock", startBlock); + const tx = new TransactionResponse(this, this.provider); + tx.#startBlock = startBlock; + return tx; + } +} +function createOrphanedBlockFilter(block) { + return { orphan: "drop-block", hash: block.hash, number: block.number }; +} +function createReorderedTransactionFilter(tx, other) { + return { orphan: "reorder-transaction", tx, other }; +} +function createRemovedTransactionFilter(tx) { + return { orphan: "drop-transaction", tx }; +} +function createRemovedLogFilter(log) { + return { orphan: "drop-log", log: { + transactionHash: log.transactionHash, + blockHash: log.blockHash, + blockNumber: log.blockNumber, + address: log.address, + data: log.data, + topics: Object.freeze(log.topics.slice()), + index: log.index + } }; +} + +// import from provider.ts instead of index.ts to prevent circular dep +// from EtherscanProvider +/** + * An **EventLog** contains additional properties parsed from the [[Log]]. + */ +class EventLog extends Log { + /** + * The Contract Interface. + */ + interface; + /** + * The matching event. + */ + fragment; + /** + * The parsed arguments passed to the event by ``emit``. + */ + args; + /** + * @_ignore: + */ + constructor(log, iface, fragment) { + super(log, log.provider); + const args = iface.decodeEventLog(fragment, log.data, log.topics); + defineProperties(this, { args, fragment, interface: iface }); + } + /** + * The name of the event. + */ + get eventName() { return this.fragment.name; } + /** + * The signature of the event. + */ + get eventSignature() { return this.fragment.format(); } +} +/** + * An **EventLog** contains additional properties parsed from the [[Log]]. + */ +class UndecodedEventLog extends Log { + /** + * The error encounted when trying to decode the log. + */ + error; + /** + * @_ignore: + */ + constructor(log, error) { + super(log, log.provider); + defineProperties(this, { error }); + } +} +/** + * A **ContractTransactionReceipt** includes the parsed logs from a + * [[TransactionReceipt]]. + */ +class ContractTransactionReceipt extends TransactionReceipt { + #iface; + /** + * @_ignore: + */ + constructor(iface, provider, tx) { + super(tx, provider); + this.#iface = iface; + } + /** + * The parsed logs for any [[Log]] which has a matching event in the + * Contract ABI. + */ + get logs() { + return super.logs.map((log) => { + const fragment = log.topics.length ? this.#iface.getEvent(log.topics[0]) : null; + if (fragment) { + try { + return new EventLog(log, this.#iface, fragment); + } + catch (error) { + return new UndecodedEventLog(log, error); + } + } + return log; + }); + } +} +/** + * A **ContractTransactionResponse** will return a + * [[ContractTransactionReceipt]] when waited on. + */ +class ContractTransactionResponse extends TransactionResponse { + #iface; + /** + * @_ignore: + */ + constructor(iface, provider, tx) { + super(tx, provider); + this.#iface = iface; + } + /** + * Resolves once this transaction has been mined and has + * %%confirms%% blocks including it (default: ``1``) with an + * optional %%timeout%%. + * + * This can resolve to ``null`` only if %%confirms%% is ``0`` + * and the transaction has not been mined, otherwise this will + * wait until enough confirmations have completed. + */ + async wait(confirms, timeout) { + const receipt = await super.wait(confirms, timeout); + if (receipt == null) { + return null; + } + return new ContractTransactionReceipt(this.#iface, this.provider, receipt); + } +} +/** + * A **ContractUnknownEventPayload** is included as the last parameter to + * Contract Events when the event does not match any events in the ABI. + */ +class ContractUnknownEventPayload extends EventPayload { + /** + * The log with no matching events. + */ + log; + /** + * @_event: + */ + constructor(contract, listener, filter, log) { + super(contract, listener, filter); + defineProperties(this, { log }); + } + /** + * Resolves to the block the event occured in. + */ + async getBlock() { + return await this.log.getBlock(); + } + /** + * Resolves to the transaction the event occured in. + */ + async getTransaction() { + return await this.log.getTransaction(); + } + /** + * Resolves to the transaction receipt the event occured in. + */ + async getTransactionReceipt() { + return await this.log.getTransactionReceipt(); + } +} +/** + * A **ContractEventPayload** is included as the last parameter to + * Contract Events when the event is known. + */ +class ContractEventPayload extends ContractUnknownEventPayload { + /** + * @_ignore: + */ + constructor(contract, listener, filter, fragment, _log) { + super(contract, listener, filter, new EventLog(_log, contract.interface, fragment)); + const args = contract.interface.decodeEventLog(fragment, this.log.data, this.log.topics); + defineProperties(this, { args, fragment }); + } + /** + * The event name. + */ + get eventName() { + return this.fragment.name; + } + /** + * The event signature. + */ + get eventSignature() { + return this.fragment.format(); + } +} + +const BN_0$1 = BigInt(0); +function canCall(value) { + return (value && typeof (value.call) === "function"); +} +function canEstimate(value) { + return (value && typeof (value.estimateGas) === "function"); +} +function canResolve(value) { + return (value && typeof (value.resolveName) === "function"); +} +function canSend(value) { + return (value && typeof (value.sendTransaction) === "function"); +} +function getResolver(value) { + if (value != null) { + if (canResolve(value)) { + return value; + } + if (value.provider) { + return value.provider; + } + } + return undefined; +} +class PreparedTopicFilter { + #filter; + fragment; + constructor(contract, fragment, args) { + defineProperties(this, { fragment }); + if (fragment.inputs.length < args.length) { + throw new Error("too many arguments"); + } + // Recursively descend into args and resolve any addresses + const runner = getRunner(contract.runner, "resolveName"); + const resolver = canResolve(runner) ? runner : null; + this.#filter = (async function () { + const resolvedArgs = await Promise.all(fragment.inputs.map((param, index) => { + const arg = args[index]; + if (arg == null) { + return null; + } + return param.walkAsync(args[index], (type, value) => { + if (type === "address") { + if (Array.isArray(value)) { + return Promise.all(value.map((v) => resolveAddress(v, resolver))); + } + return resolveAddress(value, resolver); + } + return value; + }); + })); + return contract.interface.encodeFilterTopics(fragment, resolvedArgs); + })(); + } + getTopicFilter() { + return this.#filter; + } +} +// A = Arguments passed in as a tuple +// R = The result type of the call (i.e. if only one return type, +// the qualified type, otherwise Result) +// D = The type the default call will return (i.e. R for view/pure, +// TransactionResponse otherwise) +//export interface ContractMethod = Array, R = any, D extends R | ContractTransactionResponse = ContractTransactionResponse> { +function getRunner(value, feature) { + if (value == null) { + return null; + } + if (typeof (value[feature]) === "function") { + return value; + } + if (value.provider && typeof (value.provider[feature]) === "function") { + return value.provider; + } + return null; +} +function getProvider(value) { + if (value == null) { + return null; + } + return value.provider || null; +} +/** + * @_ignore: + */ +async function copyOverrides(arg, allowed) { + // Make sure the overrides passed in are a valid overrides object + const _overrides = Typed.dereference(arg, "overrides"); + assertArgument(typeof (_overrides) === "object", "invalid overrides parameter", "overrides", arg); + // Create a shallow copy (we'll deep-ify anything needed during normalizing) + const overrides = copyRequest(_overrides); + assertArgument(overrides.to == null || (allowed || []).indexOf("to") >= 0, "cannot override to", "overrides.to", overrides.to); + assertArgument(overrides.data == null || (allowed || []).indexOf("data") >= 0, "cannot override data", "overrides.data", overrides.data); + // Resolve any from + if (overrides.from) { + overrides.from = overrides.from; + } + return overrides; +} +/** + * @_ignore: + */ +async function resolveArgs(_runner, inputs, args) { + // Recursively descend into args and resolve any addresses + const runner = getRunner(_runner, "resolveName"); + const resolver = canResolve(runner) ? runner : null; + return await Promise.all(inputs.map((param, index) => { + return param.walkAsync(args[index], (type, value) => { + value = Typed.dereference(value, type); + if (type === "address") { + return resolveAddress(value, resolver); + } + return value; + }); + })); +} +function buildWrappedFallback(contract) { + const populateTransaction = async function (overrides) { + // If an overrides was passed in, copy it and normalize the values + const tx = (await copyOverrides(overrides, ["data"])); + tx.to = await contract.getAddress(); + if (tx.from) { + tx.from = await resolveAddress(tx.from, getResolver(contract.runner)); + } + const iface = contract.interface; + const noValue = (getBigInt((tx.value || BN_0$1), "overrides.value") === BN_0$1); + const noData = ((tx.data || "0x") === "0x"); + if (iface.fallback && !iface.fallback.payable && iface.receive && !noData && !noValue) { + assertArgument(false, "cannot send data to receive or send value to non-payable fallback", "overrides", overrides); + } + assertArgument(iface.fallback || noData, "cannot send data to receive-only contract", "overrides.data", tx.data); + // Only allow payable contracts to set non-zero value + const payable = iface.receive || (iface.fallback && iface.fallback.payable); + assertArgument(payable || noValue, "cannot send value to non-payable fallback", "overrides.value", tx.value); + // Only allow fallback contracts to set non-empty data + assertArgument(iface.fallback || noData, "cannot send data to receive-only contract", "overrides.data", tx.data); + return tx; + }; + const staticCall = async function (overrides) { + const runner = getRunner(contract.runner, "call"); + assert$5(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" }); + const tx = await populateTransaction(overrides); + try { + return await runner.call(tx); + } + catch (error) { + if (isCallException(error) && error.data) { + throw contract.interface.makeError(error.data, tx); + } + throw error; + } + }; + const send = async function (overrides) { + const runner = contract.runner; + assert$5(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" }); + const tx = await runner.sendTransaction(await populateTransaction(overrides)); + const provider = getProvider(contract.runner); + // @TODO: the provider can be null; make a custom dummy provider that will throw a + // meaningful error + return new ContractTransactionResponse(contract.interface, provider, tx); + }; + const estimateGas = async function (overrides) { + const runner = getRunner(contract.runner, "estimateGas"); + assert$5(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" }); + return await runner.estimateGas(await populateTransaction(overrides)); + }; + const method = async (overrides) => { + return await send(overrides); + }; + defineProperties(method, { + _contract: contract, + estimateGas, + populateTransaction, + send, staticCall + }); + return method; +} +function buildWrappedMethod(contract, key) { + const getFragment = function (...args) { + const fragment = contract.interface.getFunction(key, args); + assert$5(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", { + operation: "fragment", + info: { key, args } + }); + return fragment; + }; + const populateTransaction = async function (...args) { + const fragment = getFragment(...args); + // If an overrides was passed in, copy it and normalize the values + let overrides = {}; + if (fragment.inputs.length + 1 === args.length) { + overrides = await copyOverrides(args.pop()); + if (overrides.from) { + overrides.from = await resolveAddress(overrides.from, getResolver(contract.runner)); + } + } + if (fragment.inputs.length !== args.length) { + throw new Error("internal error: fragment inputs doesn't match arguments; should not happen"); + } + const resolvedArgs = await resolveArgs(contract.runner, fragment.inputs, args); + return Object.assign({}, overrides, await resolveProperties({ + to: contract.getAddress(), + data: contract.interface.encodeFunctionData(fragment, resolvedArgs) + })); + }; + const staticCall = async function (...args) { + const result = await staticCallResult(...args); + if (result.length === 1) { + return result[0]; + } + return result; + }; + const send = async function (...args) { + const runner = contract.runner; + assert$5(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" }); + const tx = await runner.sendTransaction(await populateTransaction(...args)); + const provider = getProvider(contract.runner); + // @TODO: the provider can be null; make a custom dummy provider that will throw a + // meaningful error + return new ContractTransactionResponse(contract.interface, provider, tx); + }; + const estimateGas = async function (...args) { + const runner = getRunner(contract.runner, "estimateGas"); + assert$5(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" }); + return await runner.estimateGas(await populateTransaction(...args)); + }; + const staticCallResult = async function (...args) { + const runner = getRunner(contract.runner, "call"); + assert$5(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" }); + const tx = await populateTransaction(...args); + let result = "0x"; + try { + result = await runner.call(tx); + } + catch (error) { + if (isCallException(error) && error.data) { + throw contract.interface.makeError(error.data, tx); + } + throw error; + } + const fragment = getFragment(...args); + return contract.interface.decodeFunctionResult(fragment, result); + }; + const method = async (...args) => { + const fragment = getFragment(...args); + if (fragment.constant) { + return await staticCall(...args); + } + return await send(...args); + }; + defineProperties(method, { + name: contract.interface.getFunctionName(key), + _contract: contract, _key: key, + getFragment, + estimateGas, + populateTransaction, + send, staticCall, staticCallResult, + }); + // Only works on non-ambiguous keys (refined fragment is always non-ambiguous) + Object.defineProperty(method, "fragment", { + configurable: false, + enumerable: true, + get: () => { + const fragment = contract.interface.getFunction(key); + assert$5(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", { + operation: "fragment", + info: { key } + }); + return fragment; + } + }); + return method; +} +function buildWrappedEvent(contract, key) { + const getFragment = function (...args) { + const fragment = contract.interface.getEvent(key, args); + assert$5(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", { + operation: "fragment", + info: { key, args } + }); + return fragment; + }; + const method = function (...args) { + return new PreparedTopicFilter(contract, getFragment(...args), args); + }; + defineProperties(method, { + name: contract.interface.getEventName(key), + _contract: contract, _key: key, + getFragment + }); + // Only works on non-ambiguous keys (refined fragment is always non-ambiguous) + Object.defineProperty(method, "fragment", { + configurable: false, + enumerable: true, + get: () => { + const fragment = contract.interface.getEvent(key); + assert$5(fragment, "no matching fragment", "UNSUPPORTED_OPERATION", { + operation: "fragment", + info: { key } + }); + return fragment; + } + }); + return method; +} +// The combination of TypeScrype, Private Fields and Proxies makes +// the world go boom; so we hide variables with some trickery keeping +// a symbol attached to each BaseContract which its sub-class (even +// via a Proxy) can reach and use to look up its internal values. +const internal = Symbol.for("_ethersInternal_contract"); +const internalValues = new WeakMap(); +function setInternal(contract, values) { + internalValues.set(contract[internal], values); +} +function getInternal(contract) { + return internalValues.get(contract[internal]); +} +function isDeferred(value) { + return (value && typeof (value) === "object" && ("getTopicFilter" in value) && + (typeof (value.getTopicFilter) === "function") && value.fragment); +} +async function getSubInfo(contract, event) { + let topics; + let fragment = null; + // Convert named events to topicHash and get the fragment for + // events which need deconstructing. + if (Array.isArray(event)) { + const topicHashify = function (name) { + if (isHexString$1(name, 32)) { + return name; + } + const fragment = contract.interface.getEvent(name); + assertArgument(fragment, "unknown fragment", "name", name); + return fragment.topicHash; + }; + // Array of Topics and Names; e.g. `[ "0x1234...89ab", "Transfer(address)" ]` + topics = event.map((e) => { + if (e == null) { + return null; + } + if (Array.isArray(e)) { + return e.map(topicHashify); + } + return topicHashify(e); + }); + } + else if (event === "*") { + topics = [null]; + } + else if (typeof (event) === "string") { + if (isHexString$1(event, 32)) { + // Topic Hash + topics = [event]; + } + else { + // Name or Signature; e.g. `"Transfer", `"Transfer(address)"` + fragment = contract.interface.getEvent(event); + assertArgument(fragment, "unknown fragment", "event", event); + topics = [fragment.topicHash]; + } + } + else if (isDeferred(event)) { + // Deferred Topic Filter; e.g. `contract.filter.Transfer(from)` + topics = await event.getTopicFilter(); + } + else if ("fragment" in event) { + // ContractEvent; e.g. `contract.filter.Transfer` + fragment = event.fragment; + topics = [fragment.topicHash]; + } + else { + assertArgument(false, "unknown event name", "event", event); + } + // Normalize topics and sort TopicSets + topics = topics.map((t) => { + if (t == null) { + return null; + } + if (Array.isArray(t)) { + const items = Array.from(new Set(t.map((t) => t.toLowerCase())).values()); + if (items.length === 1) { + return items[0]; + } + items.sort(); + return items; + } + return t.toLowerCase(); + }); + const tag = topics.map((t) => { + if (t == null) { + return "null"; + } + if (Array.isArray(t)) { + return t.join("|"); + } + return t; + }).join("&"); + return { fragment, tag, topics }; +} +async function hasSub(contract, event) { + const { subs } = getInternal(contract); + return subs.get((await getSubInfo(contract, event)).tag) || null; +} +async function getSub(contract, operation, event) { + // Make sure our runner can actually subscribe to events + const provider = getProvider(contract.runner); + assert$5(provider, "contract runner does not support subscribing", "UNSUPPORTED_OPERATION", { operation }); + const { fragment, tag, topics } = await getSubInfo(contract, event); + const { addr, subs } = getInternal(contract); + let sub = subs.get(tag); + if (!sub) { + const address = (addr ? addr : contract); + const filter = { address, topics }; + const listener = (log) => { + let foundFragment = fragment; + if (foundFragment == null) { + try { + foundFragment = contract.interface.getEvent(log.topics[0]); + } + catch (error) { } + } + // If fragment is null, we do not deconstruct the args to emit + if (foundFragment) { + const _foundFragment = foundFragment; + const args = fragment ? contract.interface.decodeEventLog(fragment, log.data, log.topics) : []; + emit(contract, event, args, (listener) => { + return new ContractEventPayload(contract, listener, event, _foundFragment, log); + }); + } + else { + emit(contract, event, [], (listener) => { + return new ContractUnknownEventPayload(contract, listener, event, log); + }); + } + }; + let starting = []; + const start = () => { + if (starting.length) { + return; + } + starting.push(provider.on(filter, listener)); + }; + const stop = async () => { + if (starting.length == 0) { + return; + } + let started = starting; + starting = []; + await Promise.all(started); + provider.off(filter, listener); + }; + sub = { tag, listeners: [], start, stop }; + subs.set(tag, sub); + } + return sub; +} +// We use this to ensure one emit resolves before firing the next to +// ensure correct ordering (note this cannot throw and just adds the +// notice to the event queu using setTimeout). +let lastEmit = Promise.resolve(); +async function _emit(contract, event, args, payloadFunc) { + await lastEmit; + const sub = await hasSub(contract, event); + if (!sub) { + return false; + } + const count = sub.listeners.length; + sub.listeners = sub.listeners.filter(({ listener, once }) => { + const passArgs = Array.from(args); + if (payloadFunc) { + passArgs.push(payloadFunc(once ? null : listener)); + } + try { + listener.call(contract, ...passArgs); + } + catch (error) { } + return !once; + }); + if (sub.listeners.length === 0) { + sub.stop(); + getInternal(contract).subs.delete(sub.tag); + } + return (count > 0); +} +async function emit(contract, event, args, payloadFunc) { + try { + await lastEmit; + } + catch (error) { } + const resultPromise = _emit(contract, event, args, payloadFunc); + lastEmit = resultPromise; + return await resultPromise; +} +const passProperties = ["then"]; +class BaseContract { + /** + * The target to connect to. + * + * This can be an address, ENS name or any [[Addressable]], such as + * another contract. To get the resovled address, use the ``getAddress`` + * method. + */ + target; + /** + * The contract Interface. + */ + interface; + /** + * The connected runner. This is generally a [[Provider]] or a + * [[Signer]], which dictates what operations are supported. + * + * For example, a **Contract** connected to a [[Provider]] may + * only execute read-only operations. + */ + runner; + /** + * All the Events available on this contract. + */ + filters; + /** + * @_ignore: + */ + [internal]; + /** + * The fallback or receive function if any. + */ + fallback; + /** + * Creates a new contract connected to %%target%% with the %%abi%% and + * optionally connected to a %%runner%% to perform operations on behalf + * of. + */ + constructor(target, abi, runner, _deployTx) { + assertArgument(typeof (target) === "string" || isAddressable(target), "invalid value for Contract target", "target", target); + if (runner == null) { + runner = null; + } + const iface = Interface.from(abi); + defineProperties(this, { target, runner, interface: iface }); + Object.defineProperty(this, internal, { value: {} }); + let addrPromise; + let addr = null; + let deployTx = null; + if (_deployTx) { + const provider = getProvider(runner); + // @TODO: the provider can be null; make a custom dummy provider that will throw a + // meaningful error + deployTx = new ContractTransactionResponse(this.interface, provider, _deployTx); + } + let subs = new Map(); + // Resolve the target as the address + if (typeof (target) === "string") { + if (isHexString$1(target)) { + addr = target; + addrPromise = Promise.resolve(target); + } + else { + const resolver = getRunner(runner, "resolveName"); + if (!canResolve(resolver)) { + throw makeError("contract runner does not support name resolution", "UNSUPPORTED_OPERATION", { + operation: "resolveName" + }); + } + addrPromise = resolver.resolveName(target).then((addr) => { + if (addr == null) { + throw makeError("an ENS name used for a contract target must be correctly configured", "UNCONFIGURED_NAME", { + value: target + }); + } + getInternal(this).addr = addr; + return addr; + }); + } + } + else { + addrPromise = target.getAddress().then((addr) => { + if (addr == null) { + throw new Error("TODO"); + } + getInternal(this).addr = addr; + return addr; + }); + } + // Set our private values + setInternal(this, { addrPromise, addr, deployTx, subs }); + // Add the event filters + const filters = new Proxy({}, { + get: (target, prop, receiver) => { + // Pass important checks (like `then` for Promise) through + if (typeof (prop) === "symbol" || passProperties.indexOf(prop) >= 0) { + return Reflect.get(target, prop, receiver); + } + try { + return this.getEvent(prop); + } + catch (error) { + if (!isError(error, "INVALID_ARGUMENT") || error.argument !== "key") { + throw error; + } + } + return undefined; + }, + has: (target, prop) => { + // Pass important checks (like `then` for Promise) through + if (passProperties.indexOf(prop) >= 0) { + return Reflect.has(target, prop); + } + return Reflect.has(target, prop) || this.interface.hasEvent(String(prop)); + } + }); + defineProperties(this, { filters }); + defineProperties(this, { + fallback: ((iface.receive || iface.fallback) ? (buildWrappedFallback(this)) : null) + }); + // Return a Proxy that will respond to functions + return new Proxy(this, { + get: (target, prop, receiver) => { + if (typeof (prop) === "symbol" || prop in target || passProperties.indexOf(prop) >= 0) { + return Reflect.get(target, prop, receiver); + } + // Undefined properties should return undefined + try { + return target.getFunction(prop); + } + catch (error) { + if (!isError(error, "INVALID_ARGUMENT") || error.argument !== "key") { + throw error; + } + } + return undefined; + }, + has: (target, prop) => { + if (typeof (prop) === "symbol" || prop in target || passProperties.indexOf(prop) >= 0) { + return Reflect.has(target, prop); + } + return target.interface.hasFunction(prop); + } + }); + } + /** + * Return a new Contract instance with the same target and ABI, but + * a different %%runner%%. + */ + connect(runner) { + return new BaseContract(this.target, this.interface, runner); + } + /** + * Return a new Contract instance with the same ABI and runner, but + * a different %%target%%. + */ + attach(target) { + return new BaseContract(target, this.interface, this.runner); + } + /** + * Return the resolved address of this Contract. + */ + async getAddress() { return await getInternal(this).addrPromise; } + /** + * Return the deployed bytecode or null if no bytecode is found. + */ + async getDeployedCode() { + const provider = getProvider(this.runner); + assert$5(provider, "runner does not support .provider", "UNSUPPORTED_OPERATION", { operation: "getDeployedCode" }); + const code = await provider.getCode(await this.getAddress()); + if (code === "0x") { + return null; + } + return code; + } + /** + * Resolve to this Contract once the bytecode has been deployed, or + * resolve immediately if already deployed. + */ + async waitForDeployment() { + // We have the deployement transaction; just use that (throws if deployement fails) + const deployTx = this.deploymentTransaction(); + if (deployTx) { + await deployTx.wait(); + return this; + } + // Check for code + const code = await this.getDeployedCode(); + if (code != null) { + return this; + } + // Make sure we can subscribe to a provider event + const provider = getProvider(this.runner); + assert$5(provider != null, "contract runner does not support .provider", "UNSUPPORTED_OPERATION", { operation: "waitForDeployment" }); + return new Promise((resolve, reject) => { + const checkCode = async () => { + try { + const code = await this.getDeployedCode(); + if (code != null) { + return resolve(this); + } + provider.once("block", checkCode); + } + catch (error) { + reject(error); + } + }; + checkCode(); + }); + } + /** + * Return the transaction used to deploy this contract. + * + * This is only available if this instance was returned from a + * [[ContractFactory]]. + */ + deploymentTransaction() { + return getInternal(this).deployTx; + } + /** + * Return the function for a given name. This is useful when a contract + * method name conflicts with a JavaScript name such as ``prototype`` or + * when using a Contract programatically. + */ + getFunction(key) { + if (typeof (key) !== "string") { + key = key.format(); + } + const func = buildWrappedMethod(this, key); + return func; + } + /** + * Return the event for a given name. This is useful when a contract + * event name conflicts with a JavaScript name such as ``prototype`` or + * when using a Contract programatically. + */ + getEvent(key) { + if (typeof (key) !== "string") { + key = key.format(); + } + return buildWrappedEvent(this, key); + } + /** + * @_ignore: + */ + async queryTransaction(hash) { + throw new Error("@TODO"); + } + /* + // @TODO: this is a non-backwards compatible change, but will be added + // in v7 and in a potential SmartContract class in an upcoming + // v6 release + async getTransactionReceipt(hash: string): Promise { + const provider = getProvider(this.runner); + assert(provider, "contract runner does not have a provider", + "UNSUPPORTED_OPERATION", { operation: "queryTransaction" }); + + const receipt = await provider.getTransactionReceipt(hash); + if (receipt == null) { return null; } + + return new ContractTransactionReceipt(this.interface, provider, receipt); + } + */ + /** + * Provide historic access to event data for %%event%% in the range + * %%fromBlock%% (default: ``0``) to %%toBlock%% (default: ``"latest"``) + * inclusive. + */ + async queryFilter(event, fromBlock, toBlock) { + if (fromBlock == null) { + fromBlock = 0; + } + if (toBlock == null) { + toBlock = "latest"; + } + const { addr, addrPromise } = getInternal(this); + const address = (addr ? addr : (await addrPromise)); + const { fragment, topics } = await getSubInfo(this, event); + const filter = { address, topics, fromBlock, toBlock }; + const provider = getProvider(this.runner); + assert$5(provider, "contract runner does not have a provider", "UNSUPPORTED_OPERATION", { operation: "queryFilter" }); + return (await provider.getLogs(filter)).map((log) => { + let foundFragment = fragment; + if (foundFragment == null) { + try { + foundFragment = this.interface.getEvent(log.topics[0]); + } + catch (error) { } + } + if (foundFragment) { + try { + return new EventLog(log, this.interface, foundFragment); + } + catch (error) { + return new UndecodedEventLog(log, error); + } + } + return new Log(log, provider); + }); + } + /** + * Add an event %%listener%% for the %%event%%. + */ + async on(event, listener) { + const sub = await getSub(this, "on", event); + sub.listeners.push({ listener, once: false }); + sub.start(); + return this; + } + /** + * Add an event %%listener%% for the %%event%%, but remove the listener + * after it is fired once. + */ + async once(event, listener) { + const sub = await getSub(this, "once", event); + sub.listeners.push({ listener, once: true }); + sub.start(); + return this; + } + /** + * Emit an %%event%% calling all listeners with %%args%%. + * + * Resolves to ``true`` if any listeners were called. + */ + async emit(event, ...args) { + return await emit(this, event, args, null); + } + /** + * Resolves to the number of listeners of %%event%% or the total number + * of listeners if unspecified. + */ + async listenerCount(event) { + if (event) { + const sub = await hasSub(this, event); + if (!sub) { + return 0; + } + return sub.listeners.length; + } + const { subs } = getInternal(this); + let total = 0; + for (const { listeners } of subs.values()) { + total += listeners.length; + } + return total; + } + /** + * Resolves to the listeners subscribed to %%event%% or all listeners + * if unspecified. + */ + async listeners(event) { + if (event) { + const sub = await hasSub(this, event); + if (!sub) { + return []; + } + return sub.listeners.map(({ listener }) => listener); + } + const { subs } = getInternal(this); + let result = []; + for (const { listeners } of subs.values()) { + result = result.concat(listeners.map(({ listener }) => listener)); + } + return result; + } + /** + * Remove the %%listener%% from the listeners for %%event%% or remove + * all listeners if unspecified. + */ + async off(event, listener) { + const sub = await hasSub(this, event); + if (!sub) { + return this; + } + if (listener) { + const index = sub.listeners.map(({ listener }) => listener).indexOf(listener); + if (index >= 0) { + sub.listeners.splice(index, 1); + } + } + if (listener == null || sub.listeners.length === 0) { + sub.stop(); + getInternal(this).subs.delete(sub.tag); + } + return this; + } + /** + * Remove all the listeners for %%event%% or remove all listeners if + * unspecified. + */ + async removeAllListeners(event) { + if (event) { + const sub = await hasSub(this, event); + if (!sub) { + return this; + } + sub.stop(); + getInternal(this).subs.delete(sub.tag); + } + else { + const { subs } = getInternal(this); + for (const { tag, stop } of subs.values()) { + stop(); + subs.delete(tag); + } + } + return this; + } + /** + * Alias for [on]. + */ + async addListener(event, listener) { + return await this.on(event, listener); + } + /** + * Alias for [off]. + */ + async removeListener(event, listener) { + return await this.off(event, listener); + } + /** + * Create a new Class for the %%abi%%. + */ + static buildClass(abi) { + class CustomContract extends BaseContract { + constructor(address, runner = null) { + super(address, abi, runner); + } + } + return CustomContract; + } + ; + /** + * Create a new BaseContract with a specified Interface. + */ + static from(target, abi, runner) { + if (runner == null) { + runner = null; + } + const contract = new this(target, abi, runner); + return contract; + } +} +function _ContractBase() { + return BaseContract; +} +/** + * A [[BaseContract]] with no type guards on its methods or events. + */ +class Contract extends _ContractBase() { +} + +// A = Arguments to the constructor +// I = Interface of deployed contracts +/** + * A **ContractFactory** is used to deploy a Contract to the blockchain. + */ +class ContractFactory { + /** + * The Contract Interface. + */ + interface; + /** + * The Contract deployment bytecode. Often called the initcode. + */ + bytecode; + /** + * The ContractRunner to deploy the Contract as. + */ + runner; + /** + * Create a new **ContractFactory** with %%abi%% and %%bytecode%%, + * optionally connected to %%runner%%. + * + * The %%bytecode%% may be the ``bytecode`` property within the + * standard Solidity JSON output. + */ + constructor(abi, bytecode, runner) { + const iface = Interface.from(abi); + // Dereference Solidity bytecode objects and allow a missing `0x`-prefix + if (bytecode instanceof Uint8Array) { + bytecode = hexlify(getBytes(bytecode)); + } + else { + if (typeof (bytecode) === "object") { + bytecode = bytecode.object; + } + if (!bytecode.startsWith("0x")) { + bytecode = "0x" + bytecode; + } + bytecode = hexlify(getBytes(bytecode)); + } + defineProperties(this, { + bytecode, interface: iface, runner: (runner || null) + }); + } + attach(target) { + return new BaseContract(target, this.interface, this.runner); + } + /** + * Resolves to the transaction to deploy the contract, passing %%args%% + * into the constructor. + */ + async getDeployTransaction(...args) { + let overrides = {}; + const fragment = this.interface.deploy; + if (fragment.inputs.length + 1 === args.length) { + overrides = await copyOverrides(args.pop()); + } + if (fragment.inputs.length !== args.length) { + throw new Error("incorrect number of arguments to constructor"); + } + const resolvedArgs = await resolveArgs(this.runner, fragment.inputs, args); + const data = concat$3([this.bytecode, this.interface.encodeDeploy(resolvedArgs)]); + return Object.assign({}, overrides, { data }); + } + /** + * Resolves to the Contract deployed by passing %%args%% into the + * constructor. + * + * This will resolve to the Contract before it has been deployed to the + * network, so the [[BaseContract-waitForDeployment]] should be used before + * sending any transactions to it. + */ + async deploy(...args) { + const tx = await this.getDeployTransaction(...args); + assert$5(this.runner && typeof (this.runner.sendTransaction) === "function", "factory runner does not support sending transactions", "UNSUPPORTED_OPERATION", { + operation: "sendTransaction" + }); + const sentTx = await this.runner.sendTransaction(tx); + const address = getCreateAddress(sentTx); + return new BaseContract(address, this.interface, this.runner, sentTx); + } + /** + * Return a new **ContractFactory** with the same ABI and bytecode, + * but connected to %%runner%%. + */ + connect(runner) { + return new ContractFactory(this.interface, this.bytecode, runner); + } + /** + * Create a new **ContractFactory** from the standard Solidity JSON output. + */ + static fromSolidity(output, runner) { + assertArgument(output != null, "bad compiler output", "output", output); + if (typeof (output) === "string") { + output = JSON.parse(output); + } + const abi = output.abi; + let bytecode = ""; + if (output.bytecode) { + bytecode = output.bytecode; + } + else if (output.evm && output.evm.bytecode) { + bytecode = output.evm.bytecode; + } + return new this(abi, bytecode, runner); + } +} + +/** + * ENS is a service which allows easy-to-remember names to map to + * network addresses. + * + * @_section: api/providers/ens-resolver:ENS Resolver [about-ens-rsolver] + */ +// @TODO: This should use the fetch-data:ipfs gateway +// Trim off the ipfs:// prefix and return the default gateway URL +function getIpfsLink(link) { + if (link.match(/^ipfs:\/\/ipfs\//i)) { + link = link.substring(12); + } + else if (link.match(/^ipfs:\/\//i)) { + link = link.substring(7); + } + else { + assertArgument(false, "unsupported IPFS format", "link", link); + } + return `https:/\/gateway.ipfs.io/ipfs/${link}`; +} +/** + * A provider plugin super-class for processing multicoin address types. + */ +class MulticoinProviderPlugin { + /** + * The name. + */ + name; + /** + * Creates a new **MulticoinProviderPluing** for %%name%%. + */ + constructor(name) { + defineProperties(this, { name }); + } + connect(proivder) { + return this; + } + /** + * Returns ``true`` if %%coinType%% is supported by this plugin. + */ + supportsCoinType(coinType) { + return false; + } + /** + * Resovles to the encoded %%address%% for %%coinType%%. + */ + async encodeAddress(coinType, address) { + throw new Error("unsupported coin"); + } + /** + * Resovles to the decoded %%data%% for %%coinType%%. + */ + async decodeAddress(coinType, data) { + throw new Error("unsupported coin"); + } +} +const matcherIpfs = new RegExp("^(ipfs):/\/(.*)$", "i"); +const matchers = [ + new RegExp("^(https):/\/(.*)$", "i"), + new RegExp("^(data):(.*)$", "i"), + matcherIpfs, + new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$", "i"), +]; +/** + * A connected object to a resolved ENS name resolver, which can be + * used to query additional details. + */ +class EnsResolver { + /** + * The connected provider. + */ + provider; + /** + * The address of the resolver. + */ + address; + /** + * The name this resolver was resolved against. + */ + name; + // For EIP-2544 names, the ancestor that provided the resolver + #supports2544; + #resolver; + constructor(provider, address, name) { + defineProperties(this, { provider, address, name }); + this.#supports2544 = null; + this.#resolver = new Contract(address, [ + "function supportsInterface(bytes4) view returns (bool)", + "function resolve(bytes, bytes) view returns (bytes)", + "function addr(bytes32) view returns (address)", + "function addr(bytes32, uint) view returns (bytes)", + "function text(bytes32, string) view returns (string)", + "function contenthash(bytes32) view returns (bytes)", + ], provider); + } + /** + * Resolves to true if the resolver supports wildcard resolution. + */ + async supportsWildcard() { + if (this.#supports2544 == null) { + this.#supports2544 = (async () => { + try { + return await this.#resolver.supportsInterface("0x9061b923"); + } + catch (error) { + // Wildcard resolvers must understand supportsInterface + // and return true. + if (isError(error, "CALL_EXCEPTION")) { + return false; + } + // Let future attempts try again... + this.#supports2544 = null; + throw error; + } + })(); + } + return await this.#supports2544; + } + async #fetch(funcName, params) { + params = (params || []).slice(); + const iface = this.#resolver.interface; + // The first parameters is always the nodehash + params.unshift(namehash(this.name)); + let fragment = null; + if (await this.supportsWildcard()) { + fragment = iface.getFunction(funcName); + assert$5(fragment, "missing fragment", "UNKNOWN_ERROR", { + info: { funcName } + }); + params = [ + dnsEncode(this.name, 255), + iface.encodeFunctionData(fragment, params) + ]; + funcName = "resolve(bytes,bytes)"; + } + params.push({ + enableCcipRead: true + }); + try { + const result = await this.#resolver[funcName](...params); + if (fragment) { + return iface.decodeFunctionResult(fragment, result)[0]; + } + return result; + } + catch (error) { + if (!isError(error, "CALL_EXCEPTION")) { + throw error; + } + } + return null; + } + /** + * Resolves to the address for %%coinType%% or null if the + * provided %%coinType%% has not been configured. + */ + async getAddress(coinType) { + if (coinType == null) { + coinType = 60; + } + if (coinType === 60) { + try { + const result = await this.#fetch("addr(bytes32)"); + // No address + if (result == null || result === ZeroAddress) { + return null; + } + return result; + } + catch (error) { + if (isError(error, "CALL_EXCEPTION")) { + return null; + } + throw error; + } + } + // Try decoding its EVM canonical chain as an EVM chain address first + if (coinType >= 0 && coinType < 0x80000000) { + let ethCoinType = coinType + 0x80000000; + const data = await this.#fetch("addr(bytes32,uint)", [ethCoinType]); + if (isHexString$1(data, 20)) { + return getAddress(data); + } + } + let coinPlugin = null; + for (const plugin of this.provider.plugins) { + if (!(plugin instanceof MulticoinProviderPlugin)) { + continue; + } + if (plugin.supportsCoinType(coinType)) { + coinPlugin = plugin; + break; + } + } + if (coinPlugin == null) { + return null; + } + // keccak256("addr(bytes32,uint256") + const data = await this.#fetch("addr(bytes32,uint)", [coinType]); + // No address + if (data == null || data === "0x") { + return null; + } + // Compute the address + const address = await coinPlugin.decodeAddress(coinType, data); + if (address != null) { + return address; + } + assert$5(false, `invalid coin data`, "UNSUPPORTED_OPERATION", { + operation: `getAddress(${coinType})`, + info: { coinType, data } + }); + } + /** + * Resolves to the EIP-634 text record for %%key%%, or ``null`` + * if unconfigured. + */ + async getText(key) { + const data = await this.#fetch("text(bytes32,string)", [key]); + if (data == null || data === "0x") { + return null; + } + return data; + } + /** + * Rsolves to the content-hash or ``null`` if unconfigured. + */ + async getContentHash() { + // keccak256("contenthash()") + const data = await this.#fetch("contenthash(bytes32)"); + // No contenthash + if (data == null || data === "0x") { + return null; + } + // IPFS (CID: 1, Type: 70=DAG-PB, 72=libp2p-key) + const ipfs = data.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/); + if (ipfs) { + const scheme = (ipfs[1] === "e3010170") ? "ipfs" : "ipns"; + const length = parseInt(ipfs[4], 16); + if (ipfs[5].length === length * 2) { + return `${scheme}:/\/${encodeBase58("0x" + ipfs[2])}`; + } + } + // Swarm (CID: 1, Type: swarm-manifest; hash/length hard-coded to keccak256/32) + const swarm = data.match(/^0xe40101fa011b20([0-9a-f]*)$/); + if (swarm && swarm[1].length === 64) { + return `bzz:/\/${swarm[1]}`; + } + assert$5(false, `invalid or unsupported content hash data`, "UNSUPPORTED_OPERATION", { + operation: "getContentHash()", + info: { data } + }); + } + /** + * Resolves to the avatar url or ``null`` if the avatar is either + * unconfigured or incorrectly configured (e.g. references an NFT + * not owned by the address). + * + * If diagnosing issues with configurations, the [[_getAvatar]] + * method may be useful. + */ + async getAvatar() { + const avatar = await this._getAvatar(); + return avatar.url; + } + /** + * When resolving an avatar, there are many steps involved, such + * fetching metadata and possibly validating ownership of an + * NFT. + * + * This method can be used to examine each step and the value it + * was working from. + */ + async _getAvatar() { + const linkage = [{ type: "name", value: this.name }]; + try { + // test data for ricmoo.eth + //const avatar = "eip155:1/erc721:0x265385c7f4132228A0d54EB1A9e7460b91c0cC68/29233"; + const avatar = await this.getText("avatar"); + if (avatar == null) { + linkage.push({ type: "!avatar", value: "" }); + return { url: null, linkage }; + } + linkage.push({ type: "avatar", value: avatar }); + for (let i = 0; i < matchers.length; i++) { + const match = avatar.match(matchers[i]); + if (match == null) { + continue; + } + const scheme = match[1].toLowerCase(); + switch (scheme) { + case "https": + case "data": + linkage.push({ type: "url", value: avatar }); + return { linkage, url: avatar }; + case "ipfs": { + const url = getIpfsLink(avatar); + linkage.push({ type: "ipfs", value: avatar }); + linkage.push({ type: "url", value: url }); + return { linkage, url }; + } + case "erc721": + case "erc1155": { + // Depending on the ERC type, use tokenURI(uint256) or url(uint256) + const selector = (scheme === "erc721") ? "tokenURI(uint256)" : "uri(uint256)"; + linkage.push({ type: scheme, value: avatar }); + // The owner of this name + const owner = await this.getAddress(); + if (owner == null) { + linkage.push({ type: "!owner", value: "" }); + return { url: null, linkage }; + } + const comps = (match[2] || "").split("/"); + if (comps.length !== 2) { + linkage.push({ type: `!${scheme}caip`, value: (match[2] || "") }); + return { url: null, linkage }; + } + const tokenId = comps[1]; + const contract = new Contract(comps[0], [ + // ERC-721 + "function tokenURI(uint) view returns (string)", + "function ownerOf(uint) view returns (address)", + // ERC-1155 + "function uri(uint) view returns (string)", + "function balanceOf(address, uint256) view returns (uint)" + ], this.provider); + // Check that this account owns the token + if (scheme === "erc721") { + const tokenOwner = await contract.ownerOf(tokenId); + if (owner !== tokenOwner) { + linkage.push({ type: "!owner", value: tokenOwner }); + return { url: null, linkage }; + } + linkage.push({ type: "owner", value: tokenOwner }); + } + else if (scheme === "erc1155") { + const balance = await contract.balanceOf(owner, tokenId); + if (!balance) { + linkage.push({ type: "!balance", value: "0" }); + return { url: null, linkage }; + } + linkage.push({ type: "balance", value: balance.toString() }); + } + // Call the token contract for the metadata URL + let metadataUrl = await contract[selector](tokenId); + if (metadataUrl == null || metadataUrl === "0x") { + linkage.push({ type: "!metadata-url", value: "" }); + return { url: null, linkage }; + } + linkage.push({ type: "metadata-url-base", value: metadataUrl }); + // ERC-1155 allows a generic {id} in the URL + if (scheme === "erc1155") { + metadataUrl = metadataUrl.replace("{id}", toBeHex(tokenId, 32).substring(2)); + linkage.push({ type: "metadata-url-expanded", value: metadataUrl }); + } + // Transform IPFS metadata links + if (metadataUrl.match(/^ipfs:/i)) { + metadataUrl = getIpfsLink(metadataUrl); + } + linkage.push({ type: "metadata-url", value: metadataUrl }); + // Get the token metadata + let metadata = {}; + const response = await (new FetchRequest(metadataUrl)).send(); + response.assertOk(); + try { + metadata = response.bodyJson; + } + catch (error) { + try { + linkage.push({ type: "!metadata", value: response.bodyText }); + } + catch (error) { + const bytes = response.body; + if (bytes) { + linkage.push({ type: "!metadata", value: hexlify(bytes) }); + } + return { url: null, linkage }; + } + return { url: null, linkage }; + } + if (!metadata) { + linkage.push({ type: "!metadata", value: "" }); + return { url: null, linkage }; + } + linkage.push({ type: "metadata", value: JSON.stringify(metadata) }); + // Pull the image URL out + let imageUrl = metadata.image; + if (typeof (imageUrl) !== "string") { + linkage.push({ type: "!imageUrl", value: "" }); + return { url: null, linkage }; + } + if (imageUrl.match(/^(https:\/\/|data:)/i)) { + // Allow + } + else { + // Transform IPFS link to gateway + const ipfs = imageUrl.match(matcherIpfs); + if (ipfs == null) { + linkage.push({ type: "!imageUrl-ipfs", value: imageUrl }); + return { url: null, linkage }; + } + linkage.push({ type: "imageUrl-ipfs", value: imageUrl }); + imageUrl = getIpfsLink(imageUrl); + } + linkage.push({ type: "url", value: imageUrl }); + return { linkage, url: imageUrl }; + } + } + } + } + catch (error) { } + return { linkage, url: null }; + } + static async getEnsAddress(provider) { + const network = await provider.getNetwork(); + const ensPlugin = network.getPlugin("org.ethers.plugins.network.Ens"); + // No ENS... + assert$5(ensPlugin, "network does not support ENS", "UNSUPPORTED_OPERATION", { + operation: "getEnsAddress", info: { network } + }); + return ensPlugin.address; + } + static async #getResolver(provider, name) { + const ensAddr = await EnsResolver.getEnsAddress(provider); + try { + const contract = new Contract(ensAddr, [ + "function resolver(bytes32) view returns (address)" + ], provider); + const addr = await contract.resolver(namehash(name), { + enableCcipRead: true + }); + if (addr === ZeroAddress) { + return null; + } + return addr; + } + catch (error) { + // ENS registry cannot throw errors on resolver(bytes32), + // so probably a link error + throw error; + } + return null; + } + /** + * Resolve to the ENS resolver for %%name%% using %%provider%% or + * ``null`` if unconfigured. + */ + static async fromName(provider, name) { + let currentName = name; + while (true) { + if (currentName === "" || currentName === ".") { + return null; + } + // Optimization since the eth node cannot change and does + // not have a wildcard resolver + if (name !== "eth" && currentName === "eth") { + return null; + } + // Check the current node for a resolver + const addr = await EnsResolver.#getResolver(provider, currentName); + // Found a resolver! + if (addr != null) { + const resolver = new EnsResolver(provider, addr, name); + // Legacy resolver found, using EIP-2544 so it isn't safe to use + if (currentName !== name && !(await resolver.supportsWildcard())) { + return null; + } + return resolver; + } + // Get the parent node + currentName = currentName.split(".").slice(1).join("."); + } + } +} + +/** + * @_ignore + */ +const BN_0 = BigInt(0); +function allowNull(format, nullValue) { + return (function (value) { + if (value == null) { + return nullValue; + } + return format(value); + }); +} +function arrayOf(format, allowNull) { + return ((array) => { + if (allowNull && array == null) { + return null; + } + if (!Array.isArray(array)) { + throw new Error("not an array"); + } + return array.map((i) => format(i)); + }); +} +// Requires an object which matches a fleet of other formatters +// Any FormatFunc may return `undefined` to have the value omitted +// from the result object. Calls preserve `this`. +function object(format, altNames) { + return ((value) => { + const result = {}; + for (const key in format) { + let srcKey = key; + if (altNames && key in altNames && !(srcKey in value)) { + for (const altKey of altNames[key]) { + if (altKey in value) { + srcKey = altKey; + break; + } + } + } + try { + const nv = format[key](value[srcKey]); + if (nv !== undefined) { + result[key] = nv; + } + } + catch (error) { + const message = (error instanceof Error) ? error.message : "not-an-error"; + assert$5(false, `invalid value for value.${key} (${message})`, "BAD_DATA", { value }); + } + } + return result; + }); +} +function formatBoolean(value) { + switch (value) { + case true: + case "true": + return true; + case false: + case "false": + return false; + } + assertArgument(false, `invalid boolean; ${JSON.stringify(value)}`, "value", value); +} +function formatData(value) { + assertArgument(isHexString$1(value, true), "invalid data", "value", value); + return value; +} +function formatHash(value) { + assertArgument(isHexString$1(value, 32), "invalid hash", "value", value); + return value; +} +const _formatLog = object({ + address: getAddress, + blockHash: formatHash, + blockNumber: getNumber, + data: formatData, + index: getNumber, + removed: allowNull(formatBoolean, false), + topics: arrayOf(formatHash), + transactionHash: formatHash, + transactionIndex: getNumber, +}, { + index: ["logIndex"] +}); +function formatLog(value) { + return _formatLog(value); +} +const _formatBlock = object({ + hash: allowNull(formatHash), + parentHash: formatHash, + parentBeaconBlockRoot: allowNull(formatHash, null), + number: getNumber, + timestamp: getNumber, + nonce: allowNull(formatData), + difficulty: getBigInt, + gasLimit: getBigInt, + gasUsed: getBigInt, + stateRoot: allowNull(formatHash, null), + receiptsRoot: allowNull(formatHash, null), + blobGasUsed: allowNull(getBigInt, null), + excessBlobGas: allowNull(getBigInt, null), + miner: allowNull(getAddress), + prevRandao: allowNull(formatHash, null), + extraData: formatData, + baseFeePerGas: allowNull(getBigInt) +}, { + prevRandao: ["mixHash"] +}); +function formatBlock(value) { + const result = _formatBlock(value); + result.transactions = value.transactions.map((tx) => { + if (typeof (tx) === "string") { + return tx; + } + return formatTransactionResponse(tx); + }); + return result; +} +const _formatReceiptLog = object({ + transactionIndex: getNumber, + blockNumber: getNumber, + transactionHash: formatHash, + address: getAddress, + topics: arrayOf(formatHash), + data: formatData, + index: getNumber, + blockHash: formatHash, +}, { + index: ["logIndex"] +}); +function formatReceiptLog(value) { + return _formatReceiptLog(value); +} +const _formatTransactionReceipt = object({ + to: allowNull(getAddress, null), + from: allowNull(getAddress, null), + contractAddress: allowNull(getAddress, null), + // should be allowNull(hash), but broken-EIP-658 support is handled in receipt + index: getNumber, + root: allowNull(hexlify), + gasUsed: getBigInt, + blobGasUsed: allowNull(getBigInt, null), + logsBloom: allowNull(formatData), + blockHash: formatHash, + hash: formatHash, + logs: arrayOf(formatReceiptLog), + blockNumber: getNumber, + //confirmations: allowNull(getNumber, null), + cumulativeGasUsed: getBigInt, + effectiveGasPrice: allowNull(getBigInt), + blobGasPrice: allowNull(getBigInt, null), + status: allowNull(getNumber), + type: allowNull(getNumber, 0) +}, { + effectiveGasPrice: ["gasPrice"], + hash: ["transactionHash"], + index: ["transactionIndex"], +}); +function formatTransactionReceipt(value) { + return _formatTransactionReceipt(value); +} +function formatTransactionResponse(value) { + // Some clients (TestRPC) do strange things like return 0x0 for the + // 0 address; correct this to be a real address + if (value.to && getBigInt(value.to) === BN_0) { + value.to = "0x0000000000000000000000000000000000000000"; + } + const result = object({ + hash: formatHash, + // Some nodes do not return this, usually test nodes (like Ganache) + index: allowNull(getNumber, undefined), + type: (value) => { + if (value === "0x" || value == null) { + return 0; + } + return getNumber(value); + }, + accessList: allowNull(accessListify, null), + blobVersionedHashes: allowNull(arrayOf(formatHash, true), null), + blockHash: allowNull(formatHash, null), + blockNumber: allowNull(getNumber, null), + transactionIndex: allowNull(getNumber, null), + from: getAddress, + // either (gasPrice) or (maxPriorityFeePerGas + maxFeePerGas) must be set + gasPrice: allowNull(getBigInt), + maxPriorityFeePerGas: allowNull(getBigInt), + maxFeePerGas: allowNull(getBigInt), + maxFeePerBlobGas: allowNull(getBigInt, null), + gasLimit: getBigInt, + to: allowNull(getAddress, null), + value: getBigInt, + nonce: getNumber, + data: formatData, + creates: allowNull(getAddress, null), + chainId: allowNull(getBigInt, null) + }, { + data: ["input"], + gasLimit: ["gas"], + index: ["transactionIndex"] + })(value); + // If to and creates are empty, populate the creates from the value + if (result.to == null && result.creates == null) { + result.creates = getCreateAddress(result); + } + // @TODO: Check fee data + // Add an access list to supported transaction types + if ((value.type === 1 || value.type === 2) && value.accessList == null) { + result.accessList = []; + } + // Compute the signature + if (value.signature) { + result.signature = Signature.from(value.signature); + } + else { + result.signature = Signature.from(value); + } + // Some backends omit ChainId on legacy transactions, but we can compute it + if (result.chainId == null) { + const chainId = result.signature.legacyChainId; + if (chainId != null) { + result.chainId = chainId; + } + } + // @TODO: check chainID + /* + if (value.chainId != null) { + let chainId = value.chainId; + + if (isHexString(chainId)) { + chainId = BigNumber.from(chainId).toNumber(); + } + + result.chainId = chainId; + + } else { + let chainId = value.networkId; + + // geth-etc returns chainId + if (chainId == null && result.v == null) { + chainId = value.chainId; + } + + if (isHexString(chainId)) { + chainId = BigNumber.from(chainId).toNumber(); + } + + if (typeof(chainId) !== "number" && result.v != null) { + chainId = (result.v - 35) / 2; + if (chainId < 0) { chainId = 0; } + chainId = parseInt(chainId); + } + + if (typeof(chainId) !== "number") { chainId = 0; } + + result.chainId = chainId; + } + */ + // 0x0000... should actually be null + if (result.blockHash && getBigInt(result.blockHash) === BN_0) { + result.blockHash = null; + } + return result; +} + +const EnsAddress = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"; +/** + * A **NetworkPlugin** provides additional functionality on a [[Network]]. + */ +class NetworkPlugin { + /** + * The name of the plugin. + * + * It is recommended to use reverse-domain-notation, which permits + * unique names with a known authority as well as hierarchal entries. + */ + name; + /** + * Creates a new **NetworkPlugin**. + */ + constructor(name) { + defineProperties(this, { name }); + } + /** + * Creates a copy of this plugin. + */ + clone() { + return new NetworkPlugin(this.name); + } +} +/** + * A **GasCostPlugin** allows a network to provide alternative values when + * computing the intrinsic gas required for a transaction. + */ +class GasCostPlugin extends NetworkPlugin { + /** + * The block number to treat these values as valid from. + * + * This allows a hardfork to have updated values included as well as + * mulutiple hardforks to be supported. + */ + effectiveBlock; + /** + * The transactions base fee. + */ + txBase; + /** + * The fee for creating a new account. + */ + txCreate; + /** + * The fee per zero-byte in the data. + */ + txDataZero; + /** + * The fee per non-zero-byte in the data. + */ + txDataNonzero; + /** + * The fee per storage key in the [[link-eip-2930]] access list. + */ + txAccessListStorageKey; + /** + * The fee per address in the [[link-eip-2930]] access list. + */ + txAccessListAddress; + /** + * Creates a new GasCostPlugin from %%effectiveBlock%% until the + * latest block or another GasCostPlugin supercedes that block number, + * with the associated %%costs%%. + */ + constructor(effectiveBlock, costs) { + if (effectiveBlock == null) { + effectiveBlock = 0; + } + super(`org.ethers.network.plugins.GasCost#${(effectiveBlock || 0)}`); + const props = { effectiveBlock }; + function set(name, nullish) { + let value = (costs || {})[name]; + if (value == null) { + value = nullish; + } + assertArgument(typeof (value) === "number", `invalud value for ${name}`, "costs", costs); + props[name] = value; + } + set("txBase", 21000); + set("txCreate", 32000); + set("txDataZero", 4); + set("txDataNonzero", 16); + set("txAccessListStorageKey", 1900); + set("txAccessListAddress", 2400); + defineProperties(this, props); + } + clone() { + return new GasCostPlugin(this.effectiveBlock, this); + } +} +/** + * An **EnsPlugin** allows a [[Network]] to specify the ENS Registry + * Contract address and the target network to use when using that + * contract. + * + * Various testnets have their own instance of the contract to use, but + * in general, the mainnet instance supports multi-chain addresses and + * should be used. + */ +class EnsPlugin extends NetworkPlugin { + /** + * The ENS Registrty Contract address. + */ + address; + /** + * The chain ID that the ENS contract lives on. + */ + targetNetwork; + /** + * Creates a new **EnsPlugin** connected to %%address%% on the + * %%targetNetwork%%. The default ENS address and mainnet is used + * if unspecified. + */ + constructor(address, targetNetwork) { + super("org.ethers.plugins.network.Ens"); + defineProperties(this, { + address: (address || EnsAddress), + targetNetwork: ((targetNetwork == null) ? 1 : targetNetwork) + }); + } + clone() { + return new EnsPlugin(this.address, this.targetNetwork); + } +} +class FetchUrlFeeDataNetworkPlugin extends NetworkPlugin { + #url; + #processFunc; + /** + * The URL to initialize the FetchRequest with in %%processFunc%%. + */ + get url() { return this.#url; } + /** + * The callback to use when computing the FeeData. + */ + get processFunc() { return this.#processFunc; } + /** + * Creates a new **FetchUrlFeeDataNetworkPlugin** which will + * be used when computing the fee data for the network. + */ + constructor(url, processFunc) { + super("org.ethers.plugins.network.FetchUrlFeeDataPlugin"); + this.#url = url; + this.#processFunc = processFunc; + } + // We are immutable, so we can serve as our own clone + clone() { return this; } +} +/* +export class CustomBlockNetworkPlugin extends NetworkPlugin { + readonly #blockFunc: (provider: Provider, block: BlockParams) => Block; + readonly #blockWithTxsFunc: (provider: Provider, block: BlockParams) => Block; + + constructor(blockFunc: (provider: Provider, block: BlockParams) => Block, blockWithTxsFunc: (provider: Provider, block: BlockParams) => Block) { + super("org.ethers.network-plugins.custom-block"); + this.#blockFunc = blockFunc; + this.#blockWithTxsFunc = blockWithTxsFunc; + } + + async getBlock(provider: Provider, block: BlockParams): Promise> { + return await this.#blockFunc(provider, block); + } + + async getBlockions(provider: Provider, block: BlockParams): Promise> { + return await this.#blockWithTxsFunc(provider, block); + } + + clone(): CustomBlockNetworkPlugin { + return new CustomBlockNetworkPlugin(this.#blockFunc, this.#blockWithTxsFunc); + } +} +*/ + +/** + * A **Network** encapsulates the various properties required to + * interact with a specific chain. + * + * @_subsection: api/providers:Networks [networks] + */ +/* * * * +// Networks which operation against an L2 can use this plugin to +// specify how to access L1, for the purpose of resolving ENS, +// for example. +export class LayerOneConnectionPlugin extends NetworkPlugin { + readonly provider!: Provider; +// @TODO: Rename to ChainAccess and allow for connecting to any chain + constructor(provider: Provider) { + super("org.ethers.plugins.layer-one-connection"); + defineProperties(this, { provider }); + } + + clone(): LayerOneConnectionPlugin { + return new LayerOneConnectionPlugin(this.provider); + } +} +*/ +const Networks = new Map(); +/** + * A **Network** provides access to a chain's properties and allows + * for plug-ins to extend functionality. + */ +class Network { + #name; + #chainId; + #plugins; + /** + * Creates a new **Network** for %%name%% and %%chainId%%. + */ + constructor(name, chainId) { + this.#name = name; + this.#chainId = getBigInt(chainId); + this.#plugins = new Map(); + } + /** + * Returns a JSON-compatible representation of a Network. + */ + toJSON() { + return { name: this.name, chainId: String(this.chainId) }; + } + /** + * The network common name. + * + * This is the canonical name, as networks migh have multiple + * names. + */ + get name() { return this.#name; } + set name(value) { this.#name = value; } + /** + * The network chain ID. + */ + get chainId() { return this.#chainId; } + set chainId(value) { this.#chainId = getBigInt(value, "chainId"); } + /** + * Returns true if %%other%% matches this network. Any chain ID + * must match, and if no chain ID is present, the name must match. + * + * This method does not currently check for additional properties, + * such as ENS address or plug-in compatibility. + */ + matches(other) { + if (other == null) { + return false; + } + if (typeof (other) === "string") { + try { + return (this.chainId === getBigInt(other)); + } + catch (error) { } + return (this.name === other); + } + if (typeof (other) === "number" || typeof (other) === "bigint") { + try { + return (this.chainId === getBigInt(other)); + } + catch (error) { } + return false; + } + if (typeof (other) === "object") { + if (other.chainId != null) { + try { + return (this.chainId === getBigInt(other.chainId)); + } + catch (error) { } + return false; + } + if (other.name != null) { + return (this.name === other.name); + } + return false; + } + return false; + } + /** + * Returns the list of plugins currently attached to this Network. + */ + get plugins() { + return Array.from(this.#plugins.values()); + } + /** + * Attach a new %%plugin%% to this Network. The network name + * must be unique, excluding any fragment. + */ + attachPlugin(plugin) { + if (this.#plugins.get(plugin.name)) { + throw new Error(`cannot replace existing plugin: ${plugin.name} `); + } + this.#plugins.set(plugin.name, plugin.clone()); + return this; + } + /** + * Return the plugin, if any, matching %%name%% exactly. Plugins + * with fragments will not be returned unless %%name%% includes + * a fragment. + */ + getPlugin(name) { + return (this.#plugins.get(name)) || null; + } + /** + * Gets a list of all plugins that match %%name%%, with otr without + * a fragment. + */ + getPlugins(basename) { + return (this.plugins.filter((p) => (p.name.split("#")[0] === basename))); + } + /** + * Create a copy of this Network. + */ + clone() { + const clone = new Network(this.name, this.chainId); + this.plugins.forEach((plugin) => { + clone.attachPlugin(plugin.clone()); + }); + return clone; + } + /** + * Compute the intrinsic gas required for a transaction. + * + * A GasCostPlugin can be attached to override the default + * values. + */ + computeIntrinsicGas(tx) { + const costs = this.getPlugin("org.ethers.plugins.network.GasCost") || (new GasCostPlugin()); + let gas = costs.txBase; + if (tx.to == null) { + gas += costs.txCreate; + } + if (tx.data) { + for (let i = 2; i < tx.data.length; i += 2) { + if (tx.data.substring(i, i + 2) === "00") { + gas += costs.txDataZero; + } + else { + gas += costs.txDataNonzero; + } + } + } + if (tx.accessList) { + const accessList = accessListify(tx.accessList); + for (const addr in accessList) { + gas += costs.txAccessListAddress + costs.txAccessListStorageKey * accessList[addr].storageKeys.length; + } + } + return gas; + } + /** + * Returns a new Network for the %%network%% name or chainId. + */ + static from(network) { + injectCommonNetworks(); + // Default network + if (network == null) { + return Network.from("mainnet"); + } + // Canonical name or chain ID + if (typeof (network) === "number") { + network = BigInt(network); + } + if (typeof (network) === "string" || typeof (network) === "bigint") { + const networkFunc = Networks.get(network); + if (networkFunc) { + return networkFunc(); + } + if (typeof (network) === "bigint") { + return new Network("unknown", network); + } + assertArgument(false, "unknown network", "network", network); + } + // Clonable with network-like abilities + if (typeof (network.clone) === "function") { + const clone = network.clone(); + //if (typeof(network.name) !== "string" || typeof(network.chainId) !== "number") { + //} + return clone; + } + // Networkish + if (typeof (network) === "object") { + assertArgument(typeof (network.name) === "string" && typeof (network.chainId) === "number", "invalid network object name or chainId", "network", network); + const custom = new Network((network.name), (network.chainId)); + if (network.ensAddress || network.ensNetwork != null) { + custom.attachPlugin(new EnsPlugin(network.ensAddress, network.ensNetwork)); + } + //if ((network).layerOneConnection) { + // custom.attachPlugin(new LayerOneConnectionPlugin((network).layerOneConnection)); + //} + return custom; + } + assertArgument(false, "invalid network", "network", network); + } + /** + * Register %%nameOrChainId%% with a function which returns + * an instance of a Network representing that chain. + */ + static register(nameOrChainId, networkFunc) { + if (typeof (nameOrChainId) === "number") { + nameOrChainId = BigInt(nameOrChainId); + } + const existing = Networks.get(nameOrChainId); + if (existing) { + assertArgument(false, `conflicting network for ${JSON.stringify(existing.name)}`, "nameOrChainId", nameOrChainId); + } + Networks.set(nameOrChainId, networkFunc); + } +} +// We don't want to bring in formatUnits because it is backed by +// FixedNumber and we want to keep Networks tiny. The values +// included by the Gas Stations are also IEEE 754 with lots of +// rounding issues and exceed the strict checks formatUnits has. +function parseUnits(_value, decimals) { + const value = String(_value); + if (!value.match(/^[0-9.]+$/)) { + throw new Error(`invalid gwei value: ${_value}`); + } + // Break into [ whole, fraction ] + const comps = value.split("."); + if (comps.length === 1) { + comps.push(""); + } + // More than 1 decimal point or too many fractional positions + if (comps.length !== 2) { + throw new Error(`invalid gwei value: ${_value}`); + } + // Pad the fraction to 9 decimalplaces + while (comps[1].length < decimals) { + comps[1] += "0"; + } + // Too many decimals and some non-zero ending, take the ceiling + if (comps[1].length > 9) { + let frac = BigInt(comps[1].substring(0, 9)); + if (!comps[1].substring(9).match(/^0+$/)) { + frac++; + } + comps[1] = frac.toString(); + } + return BigInt(comps[0] + comps[1]); +} +// Used by Polygon to use a gas station for fee data +function getGasStationPlugin(url) { + return new FetchUrlFeeDataNetworkPlugin(url, async (fetchFeeData, provider, request) => { + // Prevent Cloudflare from blocking our request in node.js + request.setHeader("User-Agent", "ethers"); + let response; + try { + const [_response, _feeData] = await Promise.all([ + request.send(), fetchFeeData() + ]); + response = _response; + const payload = response.bodyJson.standard; + const feeData = { + gasPrice: _feeData.gasPrice, + maxFeePerGas: parseUnits(payload.maxFee, 9), + maxPriorityFeePerGas: parseUnits(payload.maxPriorityFee, 9), + }; + return feeData; + } + catch (error) { + assert$5(false, `error encountered with polygon gas station (${JSON.stringify(request.url)})`, "SERVER_ERROR", { request, response, error }); + } + }); +} +// See: https://chainlist.org +let injected = false; +function injectCommonNetworks() { + if (injected) { + return; + } + injected = true; + /// Register popular Ethereum networks + function registerEth(name, chainId, options) { + const func = function () { + const network = new Network(name, chainId); + // We use 0 to disable ENS + if (options.ensNetwork != null) { + network.attachPlugin(new EnsPlugin(null, options.ensNetwork)); + } + network.attachPlugin(new GasCostPlugin()); + (options.plugins || []).forEach((plugin) => { + network.attachPlugin(plugin); + }); + return network; + }; + // Register the network by name and chain ID + Network.register(name, func); + Network.register(chainId, func); + if (options.altNames) { + options.altNames.forEach((name) => { + Network.register(name, func); + }); + } + } + registerEth("mainnet", 1, { ensNetwork: 1, altNames: ["homestead"] }); + registerEth("ropsten", 3, { ensNetwork: 3 }); + registerEth("rinkeby", 4, { ensNetwork: 4 }); + registerEth("goerli", 5, { ensNetwork: 5 }); + registerEth("kovan", 42, { ensNetwork: 42 }); + registerEth("sepolia", 11155111, { ensNetwork: 11155111 }); + registerEth("holesky", 17000, { ensNetwork: 17000 }); + registerEth("classic", 61, {}); + registerEth("classicKotti", 6, {}); + registerEth("arbitrum", 42161, { + ensNetwork: 1, + }); + registerEth("arbitrum-goerli", 421613, {}); + registerEth("arbitrum-sepolia", 421614, {}); + registerEth("base", 8453, { ensNetwork: 1 }); + registerEth("base-goerli", 84531, {}); + registerEth("base-sepolia", 84532, {}); + registerEth("bnb", 56, { ensNetwork: 1 }); + registerEth("bnbt", 97, {}); + registerEth("linea", 59144, { ensNetwork: 1 }); + registerEth("linea-goerli", 59140, {}); + registerEth("linea-sepolia", 59141, {}); + registerEth("matic", 137, { + ensNetwork: 1, + plugins: [ + getGasStationPlugin("https:/\/gasstation.polygon.technology/v2") + ] + }); + registerEth("matic-amoy", 80002, {}); + registerEth("matic-mumbai", 80001, { + altNames: ["maticMumbai", "maticmum"], + plugins: [ + getGasStationPlugin("https:/\/gasstation-testnet.polygon.technology/v2") + ] + }); + registerEth("optimism", 10, { + ensNetwork: 1, + plugins: [] + }); + registerEth("optimism-goerli", 420, {}); + registerEth("optimism-sepolia", 11155420, {}); + registerEth("xdai", 100, { ensNetwork: 1 }); +} + +function copy$3(obj) { + return JSON.parse(JSON.stringify(obj)); +} +// @TODO: refactor this +/** + * A **PollingBlockSubscriber** polls at a regular interval for a change + * in the block number. + * + * @_docloc: api/providers/abstract-provider + */ +class PollingBlockSubscriber { + #provider; + #poller; + #interval; + // The most recent block we have scanned for events. The value -2 + // indicates we still need to fetch an initial block number + #blockNumber; + /** + * Create a new **PollingBlockSubscriber** attached to %%provider%%. + */ + constructor(provider) { + this.#provider = provider; + this.#poller = null; + this.#interval = 4000; + this.#blockNumber = -2; + } + /** + * The polling interval. + */ + get pollingInterval() { return this.#interval; } + set pollingInterval(value) { this.#interval = value; } + async #poll() { + try { + const blockNumber = await this.#provider.getBlockNumber(); + // Bootstrap poll to setup our initial block number + if (this.#blockNumber === -2) { + this.#blockNumber = blockNumber; + return; + } + // @TODO: Put a cap on the maximum number of events per loop? + if (blockNumber !== this.#blockNumber) { + for (let b = this.#blockNumber + 1; b <= blockNumber; b++) { + // We have been stopped + if (this.#poller == null) { + return; + } + await this.#provider.emit("block", b); + } + this.#blockNumber = blockNumber; + } + } + catch (error) { + // @TODO: Minor bump, add an "error" event to let subscribers + // know things went awry. + //console.log(error); + } + // We have been stopped + if (this.#poller == null) { + return; + } + this.#poller = this.#provider._setTimeout(this.#poll.bind(this), this.#interval); + } + start() { + if (this.#poller) { + return; + } + this.#poller = this.#provider._setTimeout(this.#poll.bind(this), this.#interval); + this.#poll(); + } + stop() { + if (!this.#poller) { + return; + } + this.#provider._clearTimeout(this.#poller); + this.#poller = null; + } + pause(dropWhilePaused) { + this.stop(); + if (dropWhilePaused) { + this.#blockNumber = -2; + } + } + resume() { + this.start(); + } +} +/** + * An **OnBlockSubscriber** can be sub-classed, with a [[_poll]] + * implmentation which will be called on every new block. + * + * @_docloc: api/providers/abstract-provider + */ +class OnBlockSubscriber { + #provider; + #poll; + #running; + /** + * Create a new **OnBlockSubscriber** attached to %%provider%%. + */ + constructor(provider) { + this.#provider = provider; + this.#running = false; + this.#poll = (blockNumber) => { + this._poll(blockNumber, this.#provider); + }; + } + /** + * Called on every new block. + */ + async _poll(blockNumber, provider) { + throw new Error("sub-classes must override this"); + } + start() { + if (this.#running) { + return; + } + this.#running = true; + this.#poll(-2); + this.#provider.on("block", this.#poll); + } + stop() { + if (!this.#running) { + return; + } + this.#running = false; + this.#provider.off("block", this.#poll); + } + pause(dropWhilePaused) { this.stop(); } + resume() { this.start(); } +} +class PollingBlockTagSubscriber extends OnBlockSubscriber { + #tag; + #lastBlock; + constructor(provider, tag) { + super(provider); + this.#tag = tag; + this.#lastBlock = -2; + } + pause(dropWhilePaused) { + if (dropWhilePaused) { + this.#lastBlock = -2; + } + super.pause(dropWhilePaused); + } + async _poll(blockNumber, provider) { + const block = await provider.getBlock(this.#tag); + if (block == null) { + return; + } + if (this.#lastBlock === -2) { + this.#lastBlock = block.number; + } + else if (block.number > this.#lastBlock) { + provider.emit(this.#tag, block.number); + this.#lastBlock = block.number; + } + } +} +/** + * @_ignore: + * + * @_docloc: api/providers/abstract-provider + */ +class PollingOrphanSubscriber extends OnBlockSubscriber { + #filter; + constructor(provider, filter) { + super(provider); + this.#filter = copy$3(filter); + } + async _poll(blockNumber, provider) { + throw new Error("@TODO"); + } +} +/** + * A **PollingTransactionSubscriber** will poll for a given transaction + * hash for its receipt. + * + * @_docloc: api/providers/abstract-provider + */ +class PollingTransactionSubscriber extends OnBlockSubscriber { + #hash; + /** + * Create a new **PollingTransactionSubscriber** attached to + * %%provider%%, listening for %%hash%%. + */ + constructor(provider, hash) { + super(provider); + this.#hash = hash; + } + async _poll(blockNumber, provider) { + const tx = await provider.getTransactionReceipt(this.#hash); + if (tx) { + provider.emit(this.#hash, tx); + } + } +} +/** + * A **PollingEventSubscriber** will poll for a given filter for its logs. + * + * @_docloc: api/providers/abstract-provider + */ +class PollingEventSubscriber { + #provider; + #filter; + #poller; + #running; + // The most recent block we have scanned for events. The value -2 + // indicates we still need to fetch an initial block number + #blockNumber; + /** + * Create a new **PollingTransactionSubscriber** attached to + * %%provider%%, listening for %%filter%%. + */ + constructor(provider, filter) { + this.#provider = provider; + this.#filter = copy$3(filter); + this.#poller = this.#poll.bind(this); + this.#running = false; + this.#blockNumber = -2; + } + async #poll(blockNumber) { + // The initial block hasn't been determined yet + if (this.#blockNumber === -2) { + return; + } + const filter = copy$3(this.#filter); + filter.fromBlock = this.#blockNumber + 1; + filter.toBlock = blockNumber; + const logs = await this.#provider.getLogs(filter); + // No logs could just mean the node has not indexed them yet, + // so we keep a sliding window of 60 blocks to keep scanning + if (logs.length === 0) { + if (this.#blockNumber < blockNumber - 60) { + this.#blockNumber = blockNumber - 60; + } + return; + } + for (const log of logs) { + this.#provider.emit(this.#filter, log); + // Only advance the block number when logs were found to + // account for networks (like BNB and Polygon) which may + // sacrifice event consistency for block event speed + this.#blockNumber = log.blockNumber; + } + } + start() { + if (this.#running) { + return; + } + this.#running = true; + if (this.#blockNumber === -2) { + this.#provider.getBlockNumber().then((blockNumber) => { + this.#blockNumber = blockNumber; + }); + } + this.#provider.on("block", this.#poller); + } + stop() { + if (!this.#running) { + return; + } + this.#running = false; + this.#provider.off("block", this.#poller); + } + pause(dropWhilePaused) { + this.stop(); + if (dropWhilePaused) { + this.#blockNumber = -2; + } + } + resume() { + this.start(); + } +} + +/** + * The available providers should suffice for most developers purposes, + * but the [[AbstractProvider]] class has many features which enable + * sub-classing it for specific purposes. + * + * @_section: api/providers/abstract-provider: Subclassing Provider [abstract-provider] + */ +// @TODO +// Event coalescence +// When we register an event with an async value (e.g. address is a Signer +// or ENS name), we need to add it immeidately for the Event API, but also +// need time to resolve the address. Upon resolving the address, we need to +// migrate the listener to the static event. We also need to maintain a map +// of Signer/ENS name to address so we can sync respond to listenerCount. +// Constants +const BN_2 = BigInt(2); +const MAX_CCIP_REDIRECTS = 10; +function isPromise(value) { + return (value && typeof (value.then) === "function"); +} +function getTag(prefix, value) { + return prefix + ":" + JSON.stringify(value, (k, v) => { + if (v == null) { + return "null"; + } + if (typeof (v) === "bigint") { + return `bigint:${v.toString()}`; + } + if (typeof (v) === "string") { + return v.toLowerCase(); + } + // Sort object keys + if (typeof (v) === "object" && !Array.isArray(v)) { + const keys = Object.keys(v); + keys.sort(); + return keys.reduce((accum, key) => { + accum[key] = v[key]; + return accum; + }, {}); + } + return v; + }); +} +/** + * An **UnmanagedSubscriber** is useful for events which do not require + * any additional management, such as ``"debug"`` which only requires + * emit in synchronous event loop triggered calls. + */ +class UnmanagedSubscriber { + /** + * The name fof the event. + */ + name; + /** + * Create a new UnmanagedSubscriber with %%name%%. + */ + constructor(name) { defineProperties(this, { name }); } + start() { } + stop() { } + pause(dropWhilePaused) { } + resume() { } +} +function copy$2(value) { + return JSON.parse(JSON.stringify(value)); +} +function concisify(items) { + items = Array.from((new Set(items)).values()); + items.sort(); + return items; +} +async function getSubscription(_event, provider) { + if (_event == null) { + throw new Error("invalid event"); + } + // Normalize topic array info an EventFilter + if (Array.isArray(_event)) { + _event = { topics: _event }; + } + if (typeof (_event) === "string") { + switch (_event) { + case "block": + case "debug": + case "error": + case "finalized": + case "network": + case "pending": + case "safe": { + return { type: _event, tag: _event }; + } + } + } + if (isHexString$1(_event, 32)) { + const hash = _event.toLowerCase(); + return { type: "transaction", tag: getTag("tx", { hash }), hash }; + } + if (_event.orphan) { + const event = _event; + // @TODO: Should lowercase and whatnot things here instead of copy... + return { type: "orphan", tag: getTag("orphan", event), filter: copy$2(event) }; + } + if ((_event.address || _event.topics)) { + const event = _event; + const filter = { + topics: ((event.topics || []).map((t) => { + if (t == null) { + return null; + } + if (Array.isArray(t)) { + return concisify(t.map((t) => t.toLowerCase())); + } + return t.toLowerCase(); + })) + }; + if (event.address) { + const addresses = []; + const promises = []; + const addAddress = (addr) => { + if (isHexString$1(addr)) { + addresses.push(addr); + } + else { + promises.push((async () => { + addresses.push(await resolveAddress(addr, provider)); + })()); + } + }; + if (Array.isArray(event.address)) { + event.address.forEach(addAddress); + } + else { + addAddress(event.address); + } + if (promises.length) { + await Promise.all(promises); + } + filter.address = concisify(addresses.map((a) => a.toLowerCase())); + } + return { filter, tag: getTag("event", filter), type: "event" }; + } + assertArgument(false, "unknown ProviderEvent", "event", _event); +} +function getTime() { return (new Date()).getTime(); } +const defaultOptions$1 = { + cacheTimeout: 250, + pollingInterval: 4000 +}; +/** + * An **AbstractProvider** provides a base class for other sub-classes to + * implement the [[Provider]] API by normalizing input arguments and + * formatting output results as well as tracking events for consistent + * behaviour on an eventually-consistent network. + */ +class AbstractProvider { + #subs; + #plugins; + // null=unpaused, true=paused+dropWhilePaused, false=paused + #pausedState; + #destroyed; + #networkPromise; + #anyNetwork; + #performCache; + // The most recent block number if running an event or -1 if no "block" event + #lastBlockNumber; + #nextTimer; + #timers; + #disableCcipRead; + #options; + /** + * Create a new **AbstractProvider** connected to %%network%%, or + * use the various network detection capabilities to discover the + * [[Network]] if necessary. + */ + constructor(_network, options) { + this.#options = Object.assign({}, defaultOptions$1, options || {}); + if (_network === "any") { + this.#anyNetwork = true; + this.#networkPromise = null; + } + else if (_network) { + const network = Network.from(_network); + this.#anyNetwork = false; + this.#networkPromise = Promise.resolve(network); + setTimeout(() => { this.emit("network", network, null); }, 0); + } + else { + this.#anyNetwork = false; + this.#networkPromise = null; + } + this.#lastBlockNumber = -1; + this.#performCache = new Map(); + this.#subs = new Map(); + this.#plugins = new Map(); + this.#pausedState = null; + this.#destroyed = false; + this.#nextTimer = 1; + this.#timers = new Map(); + this.#disableCcipRead = false; + } + get pollingInterval() { return this.#options.pollingInterval; } + /** + * Returns ``this``, to allow an **AbstractProvider** to implement + * the [[ContractRunner]] interface. + */ + get provider() { return this; } + /** + * Returns all the registered plug-ins. + */ + get plugins() { + return Array.from(this.#plugins.values()); + } + /** + * Attach a new plug-in. + */ + attachPlugin(plugin) { + if (this.#plugins.get(plugin.name)) { + throw new Error(`cannot replace existing plugin: ${plugin.name} `); + } + this.#plugins.set(plugin.name, plugin.connect(this)); + return this; + } + /** + * Get a plugin by name. + */ + getPlugin(name) { + return (this.#plugins.get(name)) || null; + } + /** + * Prevent any CCIP-read operation, regardless of whether requested + * in a [[call]] using ``enableCcipRead``. + */ + get disableCcipRead() { return this.#disableCcipRead; } + set disableCcipRead(value) { this.#disableCcipRead = !!value; } + // Shares multiple identical requests made during the same 250ms + async #perform(req) { + const timeout = this.#options.cacheTimeout; + // Caching disabled + if (timeout < 0) { + return await this._perform(req); + } + // Create a tag + const tag = getTag(req.method, req); + let perform = this.#performCache.get(tag); + if (!perform) { + perform = this._perform(req); + this.#performCache.set(tag, perform); + setTimeout(() => { + if (this.#performCache.get(tag) === perform) { + this.#performCache.delete(tag); + } + }, timeout); + } + return await perform; + } + /** + * Resolves to the data for executing the CCIP-read operations. + */ + async ccipReadFetch(tx, calldata, urls) { + if (this.disableCcipRead || urls.length === 0 || tx.to == null) { + return null; + } + const sender = tx.to.toLowerCase(); + const data = calldata.toLowerCase(); + const errorMessages = []; + for (let i = 0; i < urls.length; i++) { + const url = urls[i]; + // URL expansion + const href = url.replace("{sender}", sender).replace("{data}", data); + // If no {data} is present, use POST; otherwise GET + //const json: string | null = (url.indexOf("{data}") >= 0) ? null: JSON.stringify({ data, sender }); + //const result = await fetchJson({ url: href, errorPassThrough: true }, json, (value, response) => { + // value.status = response.statusCode; + // return value; + //}); + const request = new FetchRequest(href); + if (url.indexOf("{data}") === -1) { + request.body = { data, sender }; + } + this.emit("debug", { action: "sendCcipReadFetchRequest", request, index: i, urls }); + let errorMessage = "unknown error"; + const resp = await request.send(); + try { + const result = resp.bodyJson; + if (result.data) { + this.emit("debug", { action: "receiveCcipReadFetchResult", request, result }); + return result.data; + } + if (result.message) { + errorMessage = result.message; + } + this.emit("debug", { action: "receiveCcipReadFetchError", request, result }); + } + catch (error) { } + // 4xx indicates the result is not present; stop + assert$5(resp.statusCode < 400 || resp.statusCode >= 500, `response not found during CCIP fetch: ${errorMessage}`, "OFFCHAIN_FAULT", { reason: "404_MISSING_RESOURCE", transaction: tx, info: { url, errorMessage } }); + // 5xx indicates server issue; try the next url + errorMessages.push(errorMessage); + } + assert$5(false, `error encountered during CCIP fetch: ${errorMessages.map((m) => JSON.stringify(m)).join(", ")}`, "OFFCHAIN_FAULT", { + reason: "500_SERVER_ERROR", + transaction: tx, info: { urls, errorMessages } + }); + } + /** + * Provides the opportunity for a sub-class to wrap a block before + * returning it, to add additional properties or an alternate + * sub-class of [[Block]]. + */ + _wrapBlock(value, network) { + return new Block(formatBlock(value), this); + } + /** + * Provides the opportunity for a sub-class to wrap a log before + * returning it, to add additional properties or an alternate + * sub-class of [[Log]]. + */ + _wrapLog(value, network) { + return new Log(formatLog(value), this); + } + /** + * Provides the opportunity for a sub-class to wrap a transaction + * receipt before returning it, to add additional properties or an + * alternate sub-class of [[TransactionReceipt]]. + */ + _wrapTransactionReceipt(value, network) { + return new TransactionReceipt(formatTransactionReceipt(value), this); + } + /** + * Provides the opportunity for a sub-class to wrap a transaction + * response before returning it, to add additional properties or an + * alternate sub-class of [[TransactionResponse]]. + */ + _wrapTransactionResponse(tx, network) { + return new TransactionResponse(formatTransactionResponse(tx), this); + } + /** + * Resolves to the Network, forcing a network detection using whatever + * technique the sub-class requires. + * + * Sub-classes **must** override this. + */ + _detectNetwork() { + assert$5(false, "sub-classes must implement this", "UNSUPPORTED_OPERATION", { + operation: "_detectNetwork" + }); + } + /** + * Sub-classes should use this to perform all built-in operations. All + * methods sanitizes and normalizes the values passed into this. + * + * Sub-classes **must** override this. + */ + async _perform(req) { + assert$5(false, `unsupported method: ${req.method}`, "UNSUPPORTED_OPERATION", { + operation: req.method, + info: req + }); + } + // State + async getBlockNumber() { + const blockNumber = getNumber(await this.#perform({ method: "getBlockNumber" }), "%response"); + if (this.#lastBlockNumber >= 0) { + this.#lastBlockNumber = blockNumber; + } + return blockNumber; + } + /** + * Returns or resolves to the address for %%address%%, resolving ENS + * names and [[Addressable]] objects and returning if already an + * address. + */ + _getAddress(address) { + return resolveAddress(address, this); + } + /** + * Returns or resolves to a valid block tag for %%blockTag%%, resolving + * negative values and returning if already a valid block tag. + */ + _getBlockTag(blockTag) { + if (blockTag == null) { + return "latest"; + } + switch (blockTag) { + case "earliest": + return "0x0"; + case "finalized": + case "latest": + case "pending": + case "safe": + return blockTag; + } + if (isHexString$1(blockTag)) { + if (isHexString$1(blockTag, 32)) { + return blockTag; + } + return toQuantity(blockTag); + } + if (typeof (blockTag) === "bigint") { + blockTag = getNumber(blockTag, "blockTag"); + } + if (typeof (blockTag) === "number") { + if (blockTag >= 0) { + return toQuantity(blockTag); + } + if (this.#lastBlockNumber >= 0) { + return toQuantity(this.#lastBlockNumber + blockTag); + } + return this.getBlockNumber().then((b) => toQuantity(b + blockTag)); + } + assertArgument(false, "invalid blockTag", "blockTag", blockTag); + } + /** + * Returns or resolves to a filter for %%filter%%, resolving any ENS + * names or [[Addressable]] object and returning if already a valid + * filter. + */ + _getFilter(filter) { + // Create a canonical representation of the topics + const topics = (filter.topics || []).map((t) => { + if (t == null) { + return null; + } + if (Array.isArray(t)) { + return concisify(t.map((t) => t.toLowerCase())); + } + return t.toLowerCase(); + }); + const blockHash = ("blockHash" in filter) ? filter.blockHash : undefined; + const resolve = (_address, fromBlock, toBlock) => { + let address = undefined; + switch (_address.length) { + case 0: break; + case 1: + address = _address[0]; + break; + default: + _address.sort(); + address = _address; + } + if (blockHash) { + if (fromBlock != null || toBlock != null) { + throw new Error("invalid filter"); + } + } + const filter = {}; + if (address) { + filter.address = address; + } + if (topics.length) { + filter.topics = topics; + } + if (fromBlock) { + filter.fromBlock = fromBlock; + } + if (toBlock) { + filter.toBlock = toBlock; + } + if (blockHash) { + filter.blockHash = blockHash; + } + return filter; + }; + // Addresses could be async (ENS names or Addressables) + let address = []; + if (filter.address) { + if (Array.isArray(filter.address)) { + for (const addr of filter.address) { + address.push(this._getAddress(addr)); + } + } + else { + address.push(this._getAddress(filter.address)); + } + } + let fromBlock = undefined; + if ("fromBlock" in filter) { + fromBlock = this._getBlockTag(filter.fromBlock); + } + let toBlock = undefined; + if ("toBlock" in filter) { + toBlock = this._getBlockTag(filter.toBlock); + } + if (address.filter((a) => (typeof (a) !== "string")).length || + (fromBlock != null && typeof (fromBlock) !== "string") || + (toBlock != null && typeof (toBlock) !== "string")) { + return Promise.all([Promise.all(address), fromBlock, toBlock]).then((result) => { + return resolve(result[0], result[1], result[2]); + }); + } + return resolve(address, fromBlock, toBlock); + } + /** + * Returns or resovles to a transaction for %%request%%, resolving + * any ENS names or [[Addressable]] and returning if already a valid + * transaction. + */ + _getTransactionRequest(_request) { + const request = copyRequest(_request); + const promises = []; + ["to", "from"].forEach((key) => { + if (request[key] == null) { + return; + } + const addr = resolveAddress(request[key], this); + if (isPromise(addr)) { + promises.push((async function () { request[key] = await addr; })()); + } + else { + request[key] = addr; + } + }); + if (request.blockTag != null) { + const blockTag = this._getBlockTag(request.blockTag); + if (isPromise(blockTag)) { + promises.push((async function () { request.blockTag = await blockTag; })()); + } + else { + request.blockTag = blockTag; + } + } + if (promises.length) { + return (async function () { + await Promise.all(promises); + return request; + })(); + } + return request; + } + async getNetwork() { + // No explicit network was set and this is our first time + if (this.#networkPromise == null) { + // Detect the current network (shared with all calls) + const detectNetwork = (async () => { + try { + const network = await this._detectNetwork(); + this.emit("network", network, null); + return network; + } + catch (error) { + if (this.#networkPromise === detectNetwork) { + this.#networkPromise = null; + } + throw error; + } + })(); + this.#networkPromise = detectNetwork; + return (await detectNetwork).clone(); + } + const networkPromise = this.#networkPromise; + const [expected, actual] = await Promise.all([ + networkPromise, + this._detectNetwork() // The actual connected network + ]); + if (expected.chainId !== actual.chainId) { + if (this.#anyNetwork) { + // The "any" network can change, so notify listeners + this.emit("network", actual, expected); + // Update the network if something else hasn't already changed it + if (this.#networkPromise === networkPromise) { + this.#networkPromise = Promise.resolve(actual); + } + } + else { + // Otherwise, we do not allow changes to the underlying network + assert$5(false, `network changed: ${expected.chainId} => ${actual.chainId} `, "NETWORK_ERROR", { + event: "changed" + }); + } + } + return expected.clone(); + } + async getFeeData() { + const network = await this.getNetwork(); + const getFeeDataFunc = async () => { + const { _block, gasPrice, priorityFee } = await resolveProperties({ + _block: this.#getBlock("latest", false), + gasPrice: ((async () => { + try { + const value = await this.#perform({ method: "getGasPrice" }); + return getBigInt(value, "%response"); + } + catch (error) { } + return null; + })()), + priorityFee: ((async () => { + try { + const value = await this.#perform({ method: "getPriorityFee" }); + return getBigInt(value, "%response"); + } + catch (error) { } + return null; + })()) + }); + let maxFeePerGas = null; + let maxPriorityFeePerGas = null; + // These are the recommended EIP-1559 heuristics for fee data + const block = this._wrapBlock(_block, network); + if (block && block.baseFeePerGas) { + maxPriorityFeePerGas = (priorityFee != null) ? priorityFee : BigInt("1000000000"); + maxFeePerGas = (block.baseFeePerGas * BN_2) + maxPriorityFeePerGas; + } + return new FeeData(gasPrice, maxFeePerGas, maxPriorityFeePerGas); + }; + // Check for a FeeDataNetWorkPlugin + const plugin = network.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin"); + if (plugin) { + const req = new FetchRequest(plugin.url); + const feeData = await plugin.processFunc(getFeeDataFunc, this, req); + return new FeeData(feeData.gasPrice, feeData.maxFeePerGas, feeData.maxPriorityFeePerGas); + } + return await getFeeDataFunc(); + } + async estimateGas(_tx) { + let tx = this._getTransactionRequest(_tx); + if (isPromise(tx)) { + tx = await tx; + } + return getBigInt(await this.#perform({ + method: "estimateGas", transaction: tx + }), "%response"); + } + async #call(tx, blockTag, attempt) { + assert$5(attempt < MAX_CCIP_REDIRECTS, "CCIP read exceeded maximum redirections", "OFFCHAIN_FAULT", { + reason: "TOO_MANY_REDIRECTS", + transaction: Object.assign({}, tx, { blockTag, enableCcipRead: true }) + }); + // This came in as a PerformActionTransaction, so to/from are safe; we can cast + const transaction = copyRequest(tx); + try { + return hexlify(await this._perform({ method: "call", transaction, blockTag })); + } + catch (error) { + // CCIP Read OffchainLookup + if (!this.disableCcipRead && isCallException(error) && error.data && attempt >= 0 && blockTag === "latest" && transaction.to != null && dataSlice(error.data, 0, 4) === "0x556f1830") { + const data = error.data; + const txSender = await resolveAddress(transaction.to, this); + // Parse the CCIP Read Arguments + let ccipArgs; + try { + ccipArgs = parseOffchainLookup(dataSlice(error.data, 4)); + } + catch (error) { + assert$5(false, error.message, "OFFCHAIN_FAULT", { + reason: "BAD_DATA", transaction, info: { data } + }); + } + // Check the sender of the OffchainLookup matches the transaction + assert$5(ccipArgs.sender.toLowerCase() === txSender.toLowerCase(), "CCIP Read sender mismatch", "CALL_EXCEPTION", { + action: "call", + data, + reason: "OffchainLookup", + transaction: transaction, + invocation: null, + revert: { + signature: "OffchainLookup(address,string[],bytes,bytes4,bytes)", + name: "OffchainLookup", + args: ccipArgs.errorArgs + } + }); + const ccipResult = await this.ccipReadFetch(transaction, ccipArgs.calldata, ccipArgs.urls); + assert$5(ccipResult != null, "CCIP Read failed to fetch data", "OFFCHAIN_FAULT", { + reason: "FETCH_FAILED", transaction, info: { data: error.data, errorArgs: ccipArgs.errorArgs } + }); + const tx = { + to: txSender, + data: concat$3([ccipArgs.selector, encodeBytes([ccipResult, ccipArgs.extraData])]) + }; + this.emit("debug", { action: "sendCcipReadCall", transaction: tx }); + try { + const result = await this.#call(tx, blockTag, attempt + 1); + this.emit("debug", { action: "receiveCcipReadCallResult", transaction: Object.assign({}, tx), result }); + return result; + } + catch (error) { + this.emit("debug", { action: "receiveCcipReadCallError", transaction: Object.assign({}, tx), error }); + throw error; + } + } + throw error; + } + } + async #checkNetwork(promise) { + const { value } = await resolveProperties({ + network: this.getNetwork(), + value: promise + }); + return value; + } + async call(_tx) { + const { tx, blockTag } = await resolveProperties({ + tx: this._getTransactionRequest(_tx), + blockTag: this._getBlockTag(_tx.blockTag) + }); + return await this.#checkNetwork(this.#call(tx, blockTag, _tx.enableCcipRead ? 0 : -1)); + } + // Account + async #getAccountValue(request, _address, _blockTag) { + let address = this._getAddress(_address); + let blockTag = this._getBlockTag(_blockTag); + if (typeof (address) !== "string" || typeof (blockTag) !== "string") { + [address, blockTag] = await Promise.all([address, blockTag]); + } + return await this.#checkNetwork(this.#perform(Object.assign(request, { address, blockTag }))); + } + async getBalance(address, blockTag) { + return getBigInt(await this.#getAccountValue({ method: "getBalance" }, address, blockTag), "%response"); + } + async getTransactionCount(address, blockTag) { + return getNumber(await this.#getAccountValue({ method: "getTransactionCount" }, address, blockTag), "%response"); + } + async getCode(address, blockTag) { + return hexlify(await this.#getAccountValue({ method: "getCode" }, address, blockTag)); + } + async getStorage(address, _position, blockTag) { + const position = getBigInt(_position, "position"); + return hexlify(await this.#getAccountValue({ method: "getStorage", position }, address, blockTag)); + } + // Write + async broadcastTransaction(signedTx) { + const { blockNumber, hash, network } = await resolveProperties({ + blockNumber: this.getBlockNumber(), + hash: this._perform({ + method: "broadcastTransaction", + signedTransaction: signedTx + }), + network: this.getNetwork() + }); + const tx = Transaction.from(signedTx); + if (tx.hash !== hash) { + throw new Error("@TODO: the returned hash did not match"); + } + return this._wrapTransactionResponse(tx, network).replaceableTransaction(blockNumber); + } + async #getBlock(block, includeTransactions) { + // @TODO: Add CustomBlockPlugin check + if (isHexString$1(block, 32)) { + return await this.#perform({ + method: "getBlock", blockHash: block, includeTransactions + }); + } + let blockTag = this._getBlockTag(block); + if (typeof (blockTag) !== "string") { + blockTag = await blockTag; + } + return await this.#perform({ + method: "getBlock", blockTag, includeTransactions + }); + } + // Queries + async getBlock(block, prefetchTxs) { + const { network, params } = await resolveProperties({ + network: this.getNetwork(), + params: this.#getBlock(block, !!prefetchTxs) + }); + if (params == null) { + return null; + } + return this._wrapBlock(params, network); + } + async getTransaction(hash) { + const { network, params } = await resolveProperties({ + network: this.getNetwork(), + params: this.#perform({ method: "getTransaction", hash }) + }); + if (params == null) { + return null; + } + return this._wrapTransactionResponse(params, network); + } + async getTransactionReceipt(hash) { + const { network, params } = await resolveProperties({ + network: this.getNetwork(), + params: this.#perform({ method: "getTransactionReceipt", hash }) + }); + if (params == null) { + return null; + } + // Some backends did not backfill the effectiveGasPrice into old transactions + // in the receipt, so we look it up manually and inject it. + if (params.gasPrice == null && params.effectiveGasPrice == null) { + const tx = await this.#perform({ method: "getTransaction", hash }); + if (tx == null) { + throw new Error("report this; could not find tx or effectiveGasPrice"); + } + params.effectiveGasPrice = tx.gasPrice; + } + return this._wrapTransactionReceipt(params, network); + } + async getTransactionResult(hash) { + const { result } = await resolveProperties({ + network: this.getNetwork(), + result: this.#perform({ method: "getTransactionResult", hash }) + }); + if (result == null) { + return null; + } + return hexlify(result); + } + // Bloom-filter Queries + async getLogs(_filter) { + let filter = this._getFilter(_filter); + if (isPromise(filter)) { + filter = await filter; + } + const { network, params } = await resolveProperties({ + network: this.getNetwork(), + params: this.#perform({ method: "getLogs", filter }) + }); + return params.map((p) => this._wrapLog(p, network)); + } + // ENS + _getProvider(chainId) { + assert$5(false, "provider cannot connect to target network", "UNSUPPORTED_OPERATION", { + operation: "_getProvider()" + }); + } + async getResolver(name) { + return await EnsResolver.fromName(this, name); + } + async getAvatar(name) { + const resolver = await this.getResolver(name); + if (resolver) { + return await resolver.getAvatar(); + } + return null; + } + async resolveName(name) { + const resolver = await this.getResolver(name); + if (resolver) { + return await resolver.getAddress(); + } + return null; + } + async lookupAddress(address) { + address = getAddress(address); + const node = namehash(address.substring(2).toLowerCase() + ".addr.reverse"); + try { + const ensAddr = await EnsResolver.getEnsAddress(this); + const ensContract = new Contract(ensAddr, [ + "function resolver(bytes32) view returns (address)" + ], this); + const resolver = await ensContract.resolver(node); + if (resolver == null || resolver === ZeroAddress) { + return null; + } + const resolverContract = new Contract(resolver, [ + "function name(bytes32) view returns (string)" + ], this); + const name = await resolverContract.name(node); + // Failed forward resolution + const check = await this.resolveName(name); + if (check !== address) { + return null; + } + return name; + } + catch (error) { + // No data was returned from the resolver + if (isError(error, "BAD_DATA") && error.value === "0x") { + return null; + } + // Something reerted + if (isError(error, "CALL_EXCEPTION")) { + return null; + } + throw error; + } + return null; + } + async waitForTransaction(hash, _confirms, timeout) { + const confirms = (_confirms != null) ? _confirms : 1; + if (confirms === 0) { + return this.getTransactionReceipt(hash); + } + return new Promise(async (resolve, reject) => { + let timer = null; + const listener = (async (blockNumber) => { + try { + const receipt = await this.getTransactionReceipt(hash); + if (receipt != null) { + if (blockNumber - receipt.blockNumber + 1 >= confirms) { + resolve(receipt); + //this.off("block", listener); + if (timer) { + clearTimeout(timer); + timer = null; + } + return; + } + } + } + catch (error) { + console.log("EEE", error); + } + this.once("block", listener); + }); + if (timeout != null) { + timer = setTimeout(() => { + if (timer == null) { + return; + } + timer = null; + this.off("block", listener); + reject(makeError("timeout", "TIMEOUT", { reason: "timeout" })); + }, timeout); + } + listener(await this.getBlockNumber()); + }); + } + async waitForBlock(blockTag) { + assert$5(false, "not implemented yet", "NOT_IMPLEMENTED", { + operation: "waitForBlock" + }); + } + /** + * Clear a timer created using the [[_setTimeout]] method. + */ + _clearTimeout(timerId) { + const timer = this.#timers.get(timerId); + if (!timer) { + return; + } + if (timer.timer) { + clearTimeout(timer.timer); + } + this.#timers.delete(timerId); + } + /** + * Create a timer that will execute %%func%% after at least %%timeout%% + * (in ms). If %%timeout%% is unspecified, then %%func%% will execute + * in the next event loop. + * + * [Pausing](AbstractProvider-paused) the provider will pause any + * associated timers. + */ + _setTimeout(_func, timeout) { + if (timeout == null) { + timeout = 0; + } + const timerId = this.#nextTimer++; + const func = () => { + this.#timers.delete(timerId); + _func(); + }; + if (this.paused) { + this.#timers.set(timerId, { timer: null, func, time: timeout }); + } + else { + const timer = setTimeout(func, timeout); + this.#timers.set(timerId, { timer, func, time: getTime() }); + } + return timerId; + } + /** + * Perform %%func%% on each subscriber. + */ + _forEachSubscriber(func) { + for (const sub of this.#subs.values()) { + func(sub.subscriber); + } + } + /** + * Sub-classes may override this to customize subscription + * implementations. + */ + _getSubscriber(sub) { + switch (sub.type) { + case "debug": + case "error": + case "network": + return new UnmanagedSubscriber(sub.type); + case "block": { + const subscriber = new PollingBlockSubscriber(this); + subscriber.pollingInterval = this.pollingInterval; + return subscriber; + } + case "safe": + case "finalized": + return new PollingBlockTagSubscriber(this, sub.type); + case "event": + return new PollingEventSubscriber(this, sub.filter); + case "transaction": + return new PollingTransactionSubscriber(this, sub.hash); + case "orphan": + return new PollingOrphanSubscriber(this, sub.filter); + } + throw new Error(`unsupported event: ${sub.type}`); + } + /** + * If a [[Subscriber]] fails and needs to replace itself, this + * method may be used. + * + * For example, this is used for providers when using the + * ``eth_getFilterChanges`` method, which can return null if state + * filters are not supported by the backend, allowing the Subscriber + * to swap in a [[PollingEventSubscriber]]. + */ + _recoverSubscriber(oldSub, newSub) { + for (const sub of this.#subs.values()) { + if (sub.subscriber === oldSub) { + if (sub.started) { + sub.subscriber.stop(); + } + sub.subscriber = newSub; + if (sub.started) { + newSub.start(); + } + if (this.#pausedState != null) { + newSub.pause(this.#pausedState); + } + break; + } + } + } + async #hasSub(event, emitArgs) { + let sub = await getSubscription(event, this); + // This is a log that is removing an existing log; we actually want + // to emit an orphan event for the removed log + if (sub.type === "event" && emitArgs && emitArgs.length > 0 && emitArgs[0].removed === true) { + sub = await getSubscription({ orphan: "drop-log", log: emitArgs[0] }, this); + } + return this.#subs.get(sub.tag) || null; + } + async #getSub(event) { + const subscription = await getSubscription(event, this); + // Prevent tampering with our tag in any subclass' _getSubscriber + const tag = subscription.tag; + let sub = this.#subs.get(tag); + if (!sub) { + const subscriber = this._getSubscriber(subscription); + const addressableMap = new WeakMap(); + const nameMap = new Map(); + sub = { subscriber, tag, addressableMap, nameMap, started: false, listeners: [] }; + this.#subs.set(tag, sub); + } + return sub; + } + async on(event, listener) { + const sub = await this.#getSub(event); + sub.listeners.push({ listener, once: false }); + if (!sub.started) { + sub.subscriber.start(); + sub.started = true; + if (this.#pausedState != null) { + sub.subscriber.pause(this.#pausedState); + } + } + return this; + } + async once(event, listener) { + const sub = await this.#getSub(event); + sub.listeners.push({ listener, once: true }); + if (!sub.started) { + sub.subscriber.start(); + sub.started = true; + if (this.#pausedState != null) { + sub.subscriber.pause(this.#pausedState); + } + } + return this; + } + async emit(event, ...args) { + const sub = await this.#hasSub(event, args); + // If there is not subscription or if a recent emit removed + // the last of them (which also deleted the sub) do nothing + if (!sub || sub.listeners.length === 0) { + return false; + } + const count = sub.listeners.length; + sub.listeners = sub.listeners.filter(({ listener, once }) => { + const payload = new EventPayload(this, (once ? null : listener), event); + try { + listener.call(this, ...args, payload); + } + catch (error) { } + return !once; + }); + if (sub.listeners.length === 0) { + if (sub.started) { + sub.subscriber.stop(); + } + this.#subs.delete(sub.tag); + } + return (count > 0); + } + async listenerCount(event) { + if (event) { + const sub = await this.#hasSub(event); + if (!sub) { + return 0; + } + return sub.listeners.length; + } + let total = 0; + for (const { listeners } of this.#subs.values()) { + total += listeners.length; + } + return total; + } + async listeners(event) { + if (event) { + const sub = await this.#hasSub(event); + if (!sub) { + return []; + } + return sub.listeners.map(({ listener }) => listener); + } + let result = []; + for (const { listeners } of this.#subs.values()) { + result = result.concat(listeners.map(({ listener }) => listener)); + } + return result; + } + async off(event, listener) { + const sub = await this.#hasSub(event); + if (!sub) { + return this; + } + if (listener) { + const index = sub.listeners.map(({ listener }) => listener).indexOf(listener); + if (index >= 0) { + sub.listeners.splice(index, 1); + } + } + if (!listener || sub.listeners.length === 0) { + if (sub.started) { + sub.subscriber.stop(); + } + this.#subs.delete(sub.tag); + } + return this; + } + async removeAllListeners(event) { + if (event) { + const { tag, started, subscriber } = await this.#getSub(event); + if (started) { + subscriber.stop(); + } + this.#subs.delete(tag); + } + else { + for (const [tag, { started, subscriber }] of this.#subs) { + if (started) { + subscriber.stop(); + } + this.#subs.delete(tag); + } + } + return this; + } + // Alias for "on" + async addListener(event, listener) { + return await this.on(event, listener); + } + // Alias for "off" + async removeListener(event, listener) { + return this.off(event, listener); + } + /** + * If this provider has been destroyed using the [[destroy]] method. + * + * Once destroyed, all resources are reclaimed, internal event loops + * and timers are cleaned up and no further requests may be sent to + * the provider. + */ + get destroyed() { + return this.#destroyed; + } + /** + * Sub-classes may use this to shutdown any sockets or release their + * resources and reject any pending requests. + * + * Sub-classes **must** call ``super.destroy()``. + */ + destroy() { + // Stop all listeners + this.removeAllListeners(); + // Shut down all tiemrs + for (const timerId of this.#timers.keys()) { + this._clearTimeout(timerId); + } + this.#destroyed = true; + } + /** + * Whether the provider is currently paused. + * + * A paused provider will not emit any events, and generally should + * not make any requests to the network, but that is up to sub-classes + * to manage. + * + * Setting ``paused = true`` is identical to calling ``.pause(false)``, + * which will buffer any events that occur while paused until the + * provider is unpaused. + */ + get paused() { return (this.#pausedState != null); } + set paused(pause) { + if (!!pause === this.paused) { + return; + } + if (this.paused) { + this.resume(); + } + else { + this.pause(false); + } + } + /** + * Pause the provider. If %%dropWhilePaused%%, any events that occur + * while paused are dropped, otherwise all events will be emitted once + * the provider is unpaused. + */ + pause(dropWhilePaused) { + this.#lastBlockNumber = -1; + if (this.#pausedState != null) { + if (this.#pausedState == !!dropWhilePaused) { + return; + } + assert$5(false, "cannot change pause type; resume first", "UNSUPPORTED_OPERATION", { + operation: "pause" + }); + } + this._forEachSubscriber((s) => s.pause(dropWhilePaused)); + this.#pausedState = !!dropWhilePaused; + for (const timer of this.#timers.values()) { + // Clear the timer + if (timer.timer) { + clearTimeout(timer.timer); + } + // Remaining time needed for when we become unpaused + timer.time = getTime() - timer.time; + } + } + /** + * Resume the provider. + */ + resume() { + if (this.#pausedState == null) { + return; + } + this._forEachSubscriber((s) => s.resume()); + this.#pausedState = null; + for (const timer of this.#timers.values()) { + // Remaining time when we were paused + let timeout = timer.time; + if (timeout < 0) { + timeout = 0; + } + // Start time (in cause paused, so we con compute remaininf time) + timer.time = getTime(); + // Start the timer + setTimeout(timer.func, timeout); + } + } +} +function _parseString(result, start) { + try { + const bytes = _parseBytes(result, start); + if (bytes) { + return toUtf8String(bytes); + } + } + catch (error) { } + return null; +} +function _parseBytes(result, start) { + if (result === "0x") { + return null; + } + try { + const offset = getNumber(dataSlice(result, start, start + 32)); + const length = getNumber(dataSlice(result, offset, offset + 32)); + return dataSlice(result, offset + 32, offset + 32 + length); + } + catch (error) { } + return null; +} +function numPad(value) { + const result = toBeArray(value); + if (result.length > 32) { + throw new Error("internal; should not happen"); + } + const padded = new Uint8Array(32); + padded.set(result, 32 - result.length); + return padded; +} +function bytesPad(value) { + if ((value.length % 32) === 0) { + return value; + } + const result = new Uint8Array(Math.ceil(value.length / 32) * 32); + result.set(value); + return result; +} +const empty = new Uint8Array([]); +// ABI Encodes a series of (bytes, bytes, ...) +function encodeBytes(datas) { + const result = []; + let byteCount = 0; + // Add place-holders for pointers as we add items + for (let i = 0; i < datas.length; i++) { + result.push(empty); + byteCount += 32; + } + for (let i = 0; i < datas.length; i++) { + const data = getBytes(datas[i]); + // Update the bytes offset + result[i] = numPad(byteCount); + // The length and padded value of data + result.push(numPad(data.length)); + result.push(bytesPad(data)); + byteCount += 32 + Math.ceil(data.length / 32) * 32; + } + return concat$3(result); +} +const zeros = "0x0000000000000000000000000000000000000000000000000000000000000000"; +function parseOffchainLookup(data) { + const result = { + sender: "", urls: [], calldata: "", selector: "", extraData: "", errorArgs: [] + }; + assert$5(dataLength(data) >= 5 * 32, "insufficient OffchainLookup data", "OFFCHAIN_FAULT", { + reason: "insufficient OffchainLookup data" + }); + const sender = dataSlice(data, 0, 32); + assert$5(dataSlice(sender, 0, 12) === dataSlice(zeros, 0, 12), "corrupt OffchainLookup sender", "OFFCHAIN_FAULT", { + reason: "corrupt OffchainLookup sender" + }); + result.sender = dataSlice(sender, 12); + // Read the URLs from the response + try { + const urls = []; + const urlsOffset = getNumber(dataSlice(data, 32, 64)); + const urlsLength = getNumber(dataSlice(data, urlsOffset, urlsOffset + 32)); + const urlsData = dataSlice(data, urlsOffset + 32); + for (let u = 0; u < urlsLength; u++) { + const url = _parseString(urlsData, u * 32); + if (url == null) { + throw new Error("abort"); + } + urls.push(url); + } + result.urls = urls; + } + catch (error) { + assert$5(false, "corrupt OffchainLookup urls", "OFFCHAIN_FAULT", { + reason: "corrupt OffchainLookup urls" + }); + } + // Get the CCIP calldata to forward + try { + const calldata = _parseBytes(data, 64); + if (calldata == null) { + throw new Error("abort"); + } + result.calldata = calldata; + } + catch (error) { + assert$5(false, "corrupt OffchainLookup calldata", "OFFCHAIN_FAULT", { + reason: "corrupt OffchainLookup calldata" + }); + } + // Get the callbackSelector (bytes4) + assert$5(dataSlice(data, 100, 128) === dataSlice(zeros, 0, 28), "corrupt OffchainLookup callbaackSelector", "OFFCHAIN_FAULT", { + reason: "corrupt OffchainLookup callbaackSelector" + }); + result.selector = dataSlice(data, 96, 100); + // Get the extra data to send back to the contract as context + try { + const extraData = _parseBytes(data, 128); + if (extraData == null) { + throw new Error("abort"); + } + result.extraData = extraData; + } + catch (error) { + assert$5(false, "corrupt OffchainLookup extraData", "OFFCHAIN_FAULT", { + reason: "corrupt OffchainLookup extraData" + }); + } + result.errorArgs = "sender,urls,calldata,selector,extraData".split(/,/).map((k) => result[k]); + return result; +} + +/** + * Generally the [[Wallet]] and [[JsonRpcSigner]] and their sub-classes + * are sufficent for most developers, but this is provided to + * fascilitate more complex Signers. + * + * @_section: api/providers/abstract-signer: Subclassing Signer [abstract-signer] + */ +function checkProvider(signer, operation) { + if (signer.provider) { + return signer.provider; + } + assert$5(false, "missing provider", "UNSUPPORTED_OPERATION", { operation }); +} +async function populate(signer, tx) { + let pop = copyRequest(tx); + if (pop.to != null) { + pop.to = resolveAddress(pop.to, signer); + } + if (pop.from != null) { + const from = pop.from; + pop.from = Promise.all([ + signer.getAddress(), + resolveAddress(from, signer) + ]).then(([address, from]) => { + assertArgument(address.toLowerCase() === from.toLowerCase(), "transaction from mismatch", "tx.from", from); + return address; + }); + } + else { + pop.from = signer.getAddress(); + } + return await resolveProperties(pop); +} +/** + * An **AbstractSigner** includes most of teh functionality required + * to get a [[Signer]] working as expected, but requires a few + * Signer-specific methods be overridden. + * + */ +class AbstractSigner { + /** + * The provider this signer is connected to. + */ + provider; + /** + * Creates a new Signer connected to %%provider%%. + */ + constructor(provider) { + defineProperties(this, { provider: (provider || null) }); + } + async getNonce(blockTag) { + return checkProvider(this, "getTransactionCount").getTransactionCount(await this.getAddress(), blockTag); + } + async populateCall(tx) { + const pop = await populate(this, tx); + return pop; + } + async populateTransaction(tx) { + const provider = checkProvider(this, "populateTransaction"); + const pop = await populate(this, tx); + if (pop.nonce == null) { + pop.nonce = await this.getNonce("pending"); + } + if (pop.gasLimit == null) { + pop.gasLimit = await this.estimateGas(pop); + } + // Populate the chain ID + const network = await (this.provider).getNetwork(); + if (pop.chainId != null) { + const chainId = getBigInt(pop.chainId); + assertArgument(chainId === network.chainId, "transaction chainId mismatch", "tx.chainId", tx.chainId); + } + else { + pop.chainId = network.chainId; + } + // Do not allow mixing pre-eip-1559 and eip-1559 properties + const hasEip1559 = (pop.maxFeePerGas != null || pop.maxPriorityFeePerGas != null); + if (pop.gasPrice != null && (pop.type === 2 || hasEip1559)) { + assertArgument(false, "eip-1559 transaction do not support gasPrice", "tx", tx); + } + else if ((pop.type === 0 || pop.type === 1) && hasEip1559) { + assertArgument(false, "pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "tx", tx); + } + if ((pop.type === 2 || pop.type == null) && (pop.maxFeePerGas != null && pop.maxPriorityFeePerGas != null)) { + // Fully-formed EIP-1559 transaction (skip getFeeData) + pop.type = 2; + } + else if (pop.type === 0 || pop.type === 1) { + // Explicit Legacy or EIP-2930 transaction + // We need to get fee data to determine things + const feeData = await provider.getFeeData(); + assert$5(feeData.gasPrice != null, "network does not support gasPrice", "UNSUPPORTED_OPERATION", { + operation: "getGasPrice" + }); + // Populate missing gasPrice + if (pop.gasPrice == null) { + pop.gasPrice = feeData.gasPrice; + } + } + else { + // We need to get fee data to determine things + const feeData = await provider.getFeeData(); + if (pop.type == null) { + // We need to auto-detect the intended type of this transaction... + if (feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null) { + // The network supports EIP-1559! + // Upgrade transaction from null to eip-1559 + pop.type = 2; + if (pop.gasPrice != null) { + // Using legacy gasPrice property on an eip-1559 network, + // so use gasPrice as both fee properties + const gasPrice = pop.gasPrice; + delete pop.gasPrice; + pop.maxFeePerGas = gasPrice; + pop.maxPriorityFeePerGas = gasPrice; + } + else { + // Populate missing fee data + if (pop.maxFeePerGas == null) { + pop.maxFeePerGas = feeData.maxFeePerGas; + } + if (pop.maxPriorityFeePerGas == null) { + pop.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; + } + } + } + else if (feeData.gasPrice != null) { + // Network doesn't support EIP-1559... + // ...but they are trying to use EIP-1559 properties + assert$5(!hasEip1559, "network does not support EIP-1559", "UNSUPPORTED_OPERATION", { + operation: "populateTransaction" + }); + // Populate missing fee data + if (pop.gasPrice == null) { + pop.gasPrice = feeData.gasPrice; + } + // Explicitly set untyped transaction to legacy + // @TODO: Maybe this shold allow type 1? + pop.type = 0; + } + else { + // getFeeData has failed us. + assert$5(false, "failed to get consistent fee data", "UNSUPPORTED_OPERATION", { + operation: "signer.getFeeData" + }); + } + } + else if (pop.type === 2 || pop.type === 3) { + // Explicitly using EIP-1559 or EIP-4844 + // Populate missing fee data + if (pop.maxFeePerGas == null) { + pop.maxFeePerGas = feeData.maxFeePerGas; + } + if (pop.maxPriorityFeePerGas == null) { + pop.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; + } + } + } + //@TOOD: Don't await all over the place; save them up for + // the end for better batching + return await resolveProperties(pop); + } + async estimateGas(tx) { + return checkProvider(this, "estimateGas").estimateGas(await this.populateCall(tx)); + } + async call(tx) { + return checkProvider(this, "call").call(await this.populateCall(tx)); + } + async resolveName(name) { + const provider = checkProvider(this, "resolveName"); + return await provider.resolveName(name); + } + async sendTransaction(tx) { + const provider = checkProvider(this, "sendTransaction"); + const pop = await this.populateTransaction(tx); + delete pop.from; + const txObj = Transaction.from(pop); + return await provider.broadcastTransaction(await this.signTransaction(txObj)); + } +} +/** + * A **VoidSigner** is a class deisgned to allow an address to be used + * in any API which accepts a Signer, but for which there are no + * credentials available to perform any actual signing. + * + * This for example allow impersonating an account for the purpose of + * static calls or estimating gas, but does not allow sending transactions. + */ +class VoidSigner extends AbstractSigner { + /** + * The signer address. + */ + address; + /** + * Creates a new **VoidSigner** with %%address%% attached to + * %%provider%%. + */ + constructor(address, provider) { + super(provider); + defineProperties(this, { address }); + } + async getAddress() { return this.address; } + connect(provider) { + return new VoidSigner(this.address, provider); + } + #throwUnsupported(suffix, operation) { + assert$5(false, `VoidSigner cannot sign ${suffix}`, "UNSUPPORTED_OPERATION", { operation }); + } + async signTransaction(tx) { + this.#throwUnsupported("transactions", "signTransaction"); + } + async signMessage(message) { + this.#throwUnsupported("messages", "signMessage"); + } + async signTypedData(domain, types, value) { + this.#throwUnsupported("typed-data", "signTypedData"); + } +} + +function copy$1(obj) { + return JSON.parse(JSON.stringify(obj)); +} +/** + * Some backends support subscribing to events using a Filter ID. + * + * When subscribing with this technique, the node issues a unique + * //Filter ID//. At this point the node dedicates resources to + * the filter, so that periodic calls to follow up on the //Filter ID// + * will receive any events since the last call. + * + * @_docloc: api/providers/abstract-provider + */ +class FilterIdSubscriber { + #provider; + #filterIdPromise; + #poller; + #running; + #network; + #hault; + /** + * Creates a new **FilterIdSubscriber** which will used [[_subscribe]] + * and [[_emitResults]] to setup the subscription and provide the event + * to the %%provider%%. + */ + constructor(provider) { + this.#provider = provider; + this.#filterIdPromise = null; + this.#poller = this.#poll.bind(this); + this.#running = false; + this.#network = null; + this.#hault = false; + } + /** + * Sub-classes **must** override this to begin the subscription. + */ + _subscribe(provider) { + throw new Error("subclasses must override this"); + } + /** + * Sub-classes **must** override this handle the events. + */ + _emitResults(provider, result) { + throw new Error("subclasses must override this"); + } + /** + * Sub-classes **must** override this handle recovery on errors. + */ + _recover(provider) { + throw new Error("subclasses must override this"); + } + async #poll(blockNumber) { + try { + // Subscribe if necessary + if (this.#filterIdPromise == null) { + this.#filterIdPromise = this._subscribe(this.#provider); + } + // Get the Filter ID + let filterId = null; + try { + filterId = await this.#filterIdPromise; + } + catch (error) { + if (!isError(error, "UNSUPPORTED_OPERATION") || error.operation !== "eth_newFilter") { + throw error; + } + } + // The backend does not support Filter ID; downgrade to + // polling + if (filterId == null) { + this.#filterIdPromise = null; + this.#provider._recoverSubscriber(this, this._recover(this.#provider)); + return; + } + const network = await this.#provider.getNetwork(); + if (!this.#network) { + this.#network = network; + } + if (this.#network.chainId !== network.chainId) { + throw new Error("chaid changed"); + } + if (this.#hault) { + return; + } + const result = await this.#provider.send("eth_getFilterChanges", [filterId]); + await this._emitResults(this.#provider, result); + } + catch (error) { + console.log("@TODO", error); + } + this.#provider.once("block", this.#poller); + } + #teardown() { + const filterIdPromise = this.#filterIdPromise; + if (filterIdPromise) { + this.#filterIdPromise = null; + filterIdPromise.then((filterId) => { + if (this.#provider.destroyed) { + return; + } + this.#provider.send("eth_uninstallFilter", [filterId]); + }); + } + } + start() { + if (this.#running) { + return; + } + this.#running = true; + this.#poll(-2); + } + stop() { + if (!this.#running) { + return; + } + this.#running = false; + this.#hault = true; + this.#teardown(); + this.#provider.off("block", this.#poller); + } + pause(dropWhilePaused) { + if (dropWhilePaused) { + this.#teardown(); + } + this.#provider.off("block", this.#poller); + } + resume() { this.start(); } +} +/** + * A **FilterIdSubscriber** for receiving contract events. + * + * @_docloc: api/providers/abstract-provider + */ +class FilterIdEventSubscriber extends FilterIdSubscriber { + #event; + /** + * Creates a new **FilterIdEventSubscriber** attached to %%provider%% + * listening for %%filter%%. + */ + constructor(provider, filter) { + super(provider); + this.#event = copy$1(filter); + } + _recover(provider) { + return new PollingEventSubscriber(provider, this.#event); + } + async _subscribe(provider) { + const filterId = await provider.send("eth_newFilter", [this.#event]); + return filterId; + } + async _emitResults(provider, results) { + for (const result of results) { + provider.emit(this.#event, provider._wrapLog(result, provider._network)); + } + } +} +/** + * A **FilterIdSubscriber** for receiving pending transactions events. + * + * @_docloc: api/providers/abstract-provider + */ +class FilterIdPendingSubscriber extends FilterIdSubscriber { + async _subscribe(provider) { + return await provider.send("eth_newPendingTransactionFilter", []); + } + async _emitResults(provider, results) { + for (const result of results) { + provider.emit("pending", result); + } + } +} + +/** + * One of the most common ways to interact with the blockchain is + * by a node running a JSON-RPC interface which can be connected to, + * based on the transport, using: + * + * - HTTP or HTTPS - [[JsonRpcProvider]] + * - WebSocket - [[WebSocketProvider]] + * - IPC - [[IpcSocketProvider]] + * + * @_section: api/providers/jsonrpc:JSON-RPC Provider [about-jsonrpcProvider] + */ +// @TODO: +// - Add the batching API +// https://playground.open-rpc.org/?schemaUrl=https://raw.githubusercontent.com/ethereum/eth1.0-apis/assembled-spec/openrpc.json&uiSchema%5BappBar%5D%5Bui:splitView%5D=true&uiSchema%5BappBar%5D%5Bui:input%5D=false&uiSchema%5BappBar%5D%5Bui:examplesDropdown%5D=false +const Primitive = "bigint,boolean,function,number,string,symbol".split(/,/g); +//const Methods = "getAddress,then".split(/,/g); +function deepCopy(value) { + if (value == null || Primitive.indexOf(typeof (value)) >= 0) { + return value; + } + // Keep any Addressable + if (typeof (value.getAddress) === "function") { + return value; + } + if (Array.isArray(value)) { + return (value.map(deepCopy)); + } + if (typeof (value) === "object") { + return Object.keys(value).reduce((accum, key) => { + accum[key] = value[key]; + return accum; + }, {}); + } + throw new Error(`should not happen: ${value} (${typeof (value)})`); +} +function stall$2(duration) { + return new Promise((resolve) => { setTimeout(resolve, duration); }); +} +function getLowerCase(value) { + if (value) { + return value.toLowerCase(); + } + return value; +} +function isPollable(value) { + return (value && typeof (value.pollingInterval) === "number"); +} +const defaultOptions = { + polling: false, + staticNetwork: null, + batchStallTime: 10, + batchMaxSize: (1 << 20), + batchMaxCount: 100, + cacheTimeout: 250, + pollingInterval: 4000 +}; +// @TODO: Unchecked Signers +class JsonRpcSigner extends AbstractSigner { + address; + constructor(provider, address) { + super(provider); + address = getAddress(address); + defineProperties(this, { address }); + } + connect(provider) { + assert$5(false, "cannot reconnect JsonRpcSigner", "UNSUPPORTED_OPERATION", { + operation: "signer.connect" + }); + } + async getAddress() { + return this.address; + } + // JSON-RPC will automatially fill in nonce, etc. so we just check from + async populateTransaction(tx) { + return await this.populateCall(tx); + } + // Returns just the hash of the transaction after sent, which is what + // the bare JSON-RPC API does; + async sendUncheckedTransaction(_tx) { + const tx = deepCopy(_tx); + const promises = []; + // Make sure the from matches the sender + if (tx.from) { + const _from = tx.from; + promises.push((async () => { + const from = await resolveAddress(_from, this.provider); + assertArgument(from != null && from.toLowerCase() === this.address.toLowerCase(), "from address mismatch", "transaction", _tx); + tx.from = from; + })()); + } + else { + tx.from = this.address; + } + // The JSON-RPC for eth_sendTransaction uses 90000 gas; if the user + // wishes to use this, it is easy to specify explicitly, otherwise + // we look it up for them. + if (tx.gasLimit == null) { + promises.push((async () => { + tx.gasLimit = await this.provider.estimateGas({ ...tx, from: this.address }); + })()); + } + // The address may be an ENS name or Addressable + if (tx.to != null) { + const _to = tx.to; + promises.push((async () => { + tx.to = await resolveAddress(_to, this.provider); + })()); + } + // Wait until all of our properties are filled in + if (promises.length) { + await Promise.all(promises); + } + const hexTx = this.provider.getRpcTransaction(tx); + return this.provider.send("eth_sendTransaction", [hexTx]); + } + async sendTransaction(tx) { + // This cannot be mined any earlier than any recent block + const blockNumber = await this.provider.getBlockNumber(); + // Send the transaction + const hash = await this.sendUncheckedTransaction(tx); + // Unfortunately, JSON-RPC only provides and opaque transaction hash + // for a response, and we need the actual transaction, so we poll + // for it; it should show up very quickly + return await (new Promise((resolve, reject) => { + const timeouts = [1000, 100]; + let invalids = 0; + const checkTx = async () => { + try { + // Try getting the transaction + const tx = await this.provider.getTransaction(hash); + if (tx != null) { + resolve(tx.replaceableTransaction(blockNumber)); + return; + } + } + catch (error) { + // If we were cancelled: stop polling. + // If the data is bad: the node returns bad transactions + // If the network changed: calling again will also fail + // If unsupported: likely destroyed + if (isError(error, "CANCELLED") || isError(error, "BAD_DATA") || + isError(error, "NETWORK_ERROR" )) { + if (error.info == null) { + error.info = {}; + } + error.info.sendTransactionHash = hash; + reject(error); + return; + } + // Stop-gap for misbehaving backends; see #4513 + if (isError(error, "INVALID_ARGUMENT")) { + invalids++; + if (error.info == null) { + error.info = {}; + } + error.info.sendTransactionHash = hash; + if (invalids > 10) { + reject(error); + return; + } + } + // Notify anyone that cares; but we will try again, since + // it is likely an intermittent service error + this.provider.emit("error", makeError("failed to fetch transation after sending (will try again)", "UNKNOWN_ERROR", { error })); + } + // Wait another 4 seconds + this.provider._setTimeout(() => { checkTx(); }, timeouts.pop() || 4000); + }; + checkTx(); + })); + } + async signTransaction(_tx) { + const tx = deepCopy(_tx); + // Make sure the from matches the sender + if (tx.from) { + const from = await resolveAddress(tx.from, this.provider); + assertArgument(from != null && from.toLowerCase() === this.address.toLowerCase(), "from address mismatch", "transaction", _tx); + tx.from = from; + } + else { + tx.from = this.address; + } + const hexTx = this.provider.getRpcTransaction(tx); + return await this.provider.send("eth_signTransaction", [hexTx]); + } + async signMessage(_message) { + const message = ((typeof (_message) === "string") ? toUtf8Bytes$1(_message) : _message); + return await this.provider.send("personal_sign", [ + hexlify(message), this.address.toLowerCase() + ]); + } + async signTypedData(domain, types, _value) { + const value = deepCopy(_value); + // Populate any ENS names (in-place) + const populated = await TypedDataEncoder.resolveNames(domain, types, value, async (value) => { + const address = await resolveAddress(value); + assertArgument(address != null, "TypedData does not support null address", "value", value); + return address; + }); + return await this.provider.send("eth_signTypedData_v4", [ + this.address.toLowerCase(), + JSON.stringify(TypedDataEncoder.getPayload(populated.domain, types, populated.value)) + ]); + } + async unlock(password) { + return this.provider.send("personal_unlockAccount", [ + this.address.toLowerCase(), password, null + ]); + } + // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign + async _legacySignMessage(_message) { + const message = ((typeof (_message) === "string") ? toUtf8Bytes$1(_message) : _message); + return await this.provider.send("eth_sign", [ + this.address.toLowerCase(), hexlify(message) + ]); + } +} +/** + * The JsonRpcApiProvider is an abstract class and **MUST** be + * sub-classed. + * + * It provides the base for all JSON-RPC-based Provider interaction. + * + * Sub-classing Notes: + * - a sub-class MUST override _send + * - a sub-class MUST call the `_start()` method once connected + */ +class JsonRpcApiProvider extends AbstractProvider { + #options; + // The next ID to use for the JSON-RPC ID field + #nextId; + // Payloads are queued and triggered in batches using the drainTimer + #payloads; + #drainTimer; + #notReady; + #network; + #pendingDetectNetwork; + #scheduleDrain() { + if (this.#drainTimer) { + return; + } + // If we aren't using batching, no harm in sending it immediately + const stallTime = (this._getOption("batchMaxCount") === 1) ? 0 : this._getOption("batchStallTime"); + this.#drainTimer = setTimeout(() => { + this.#drainTimer = null; + const payloads = this.#payloads; + this.#payloads = []; + while (payloads.length) { + // Create payload batches that satisfy our batch constraints + const batch = [(payloads.shift())]; + while (payloads.length) { + if (batch.length === this.#options.batchMaxCount) { + break; + } + batch.push((payloads.shift())); + const bytes = JSON.stringify(batch.map((p) => p.payload)); + if (bytes.length > this.#options.batchMaxSize) { + payloads.unshift((batch.pop())); + break; + } + } + // Process the result to each payload + (async () => { + const payload = ((batch.length === 1) ? batch[0].payload : batch.map((p) => p.payload)); + this.emit("debug", { action: "sendRpcPayload", payload }); + try { + const result = await this._send(payload); + this.emit("debug", { action: "receiveRpcResult", result }); + // Process results in batch order + for (const { resolve, reject, payload } of batch) { + if (this.destroyed) { + reject(makeError("provider destroyed; cancelled request", "UNSUPPORTED_OPERATION", { operation: payload.method })); + continue; + } + // Find the matching result + const resp = result.filter((r) => (r.id === payload.id))[0]; + // No result; the node failed us in unexpected ways + if (resp == null) { + const error = makeError("missing response for request", "BAD_DATA", { + value: result, info: { payload } + }); + this.emit("error", error); + reject(error); + continue; + } + // The response is an error + if ("error" in resp) { + reject(this.getRpcError(payload, resp)); + continue; + } + // All good; send the result + resolve(resp.result); + } + } + catch (error) { + this.emit("debug", { action: "receiveRpcError", error }); + for (const { reject } of batch) { + // @TODO: augment the error with the payload + reject(error); + } + } + })(); + } + }, stallTime); + } + constructor(network, options) { + super(network, options); + this.#nextId = 1; + this.#options = Object.assign({}, defaultOptions, options || {}); + this.#payloads = []; + this.#drainTimer = null; + this.#network = null; + this.#pendingDetectNetwork = null; + { + let resolve = null; + const promise = new Promise((_resolve) => { + resolve = _resolve; + }); + this.#notReady = { promise, resolve }; + } + const staticNetwork = this._getOption("staticNetwork"); + if (typeof (staticNetwork) === "boolean") { + assertArgument(!staticNetwork || network !== "any", "staticNetwork cannot be used on special network 'any'", "options", options); + if (staticNetwork && network != null) { + this.#network = Network.from(network); + } + } + else if (staticNetwork) { + // Make sure any static network is compatbile with the provided netwrok + assertArgument(network == null || staticNetwork.matches(network), "staticNetwork MUST match network object", "options", options); + this.#network = staticNetwork; + } + } + /** + * Returns the value associated with the option %%key%%. + * + * Sub-classes can use this to inquire about configuration options. + */ + _getOption(key) { + return this.#options[key]; + } + /** + * Gets the [[Network]] this provider has committed to. On each call, the network + * is detected, and if it has changed, the call will reject. + */ + get _network() { + assert$5(this.#network, "network is not available yet", "NETWORK_ERROR"); + return this.#network; + } + /** + * Resolves to the non-normalized value by performing %%req%%. + * + * Sub-classes may override this to modify behavior of actions, + * and should generally call ``super._perform`` as a fallback. + */ + async _perform(req) { + // Legacy networks do not like the type field being passed along (which + // is fair), so we delete type if it is 0 and a non-EIP-1559 network + if (req.method === "call" || req.method === "estimateGas") { + let tx = req.transaction; + if (tx && tx.type != null && getBigInt(tx.type)) { + // If there are no EIP-1559 properties, it might be non-EIP-a559 + if (tx.maxFeePerGas == null && tx.maxPriorityFeePerGas == null) { + const feeData = await this.getFeeData(); + if (feeData.maxFeePerGas == null && feeData.maxPriorityFeePerGas == null) { + // Network doesn't know about EIP-1559 (and hence type) + req = Object.assign({}, req, { + transaction: Object.assign({}, tx, { type: undefined }) + }); + } + } + } + } + const request = this.getRpcRequest(req); + if (request != null) { + return await this.send(request.method, request.args); + } + return super._perform(req); + } + /** + * Sub-classes may override this; it detects the *actual* network that + * we are **currently** connected to. + * + * Keep in mind that [[send]] may only be used once [[ready]], otherwise the + * _send primitive must be used instead. + */ + async _detectNetwork() { + const network = this._getOption("staticNetwork"); + if (network) { + if (network === true) { + if (this.#network) { + return this.#network; + } + } + else { + return network; + } + } + if (this.#pendingDetectNetwork) { + return await this.#pendingDetectNetwork; + } + // If we are ready, use ``send``, which enabled requests to be batched + if (this.ready) { + this.#pendingDetectNetwork = (async () => { + try { + const result = Network.from(getBigInt(await this.send("eth_chainId", []))); + this.#pendingDetectNetwork = null; + return result; + } + catch (error) { + this.#pendingDetectNetwork = null; + throw error; + } + })(); + return await this.#pendingDetectNetwork; + } + // We are not ready yet; use the primitive _send + this.#pendingDetectNetwork = (async () => { + const payload = { + id: this.#nextId++, method: "eth_chainId", params: [], jsonrpc: "2.0" + }; + this.emit("debug", { action: "sendRpcPayload", payload }); + let result; + try { + result = (await this._send(payload))[0]; + this.#pendingDetectNetwork = null; + } + catch (error) { + this.#pendingDetectNetwork = null; + this.emit("debug", { action: "receiveRpcError", error }); + throw error; + } + this.emit("debug", { action: "receiveRpcResult", result }); + if ("result" in result) { + return Network.from(getBigInt(result.result)); + } + throw this.getRpcError(payload, result); + })(); + return await this.#pendingDetectNetwork; + } + /** + * Sub-classes **MUST** call this. Until [[_start]] has been called, no calls + * will be passed to [[_send]] from [[send]]. If it is overridden, then + * ``super._start()`` **MUST** be called. + * + * Calling it multiple times is safe and has no effect. + */ + _start() { + if (this.#notReady == null || this.#notReady.resolve == null) { + return; + } + this.#notReady.resolve(); + this.#notReady = null; + (async () => { + // Bootstrap the network + while (this.#network == null && !this.destroyed) { + try { + this.#network = await this._detectNetwork(); + } + catch (error) { + if (this.destroyed) { + break; + } + console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"); + this.emit("error", makeError("failed to bootstrap network detection", "NETWORK_ERROR", { event: "initial-network-discovery", info: { error } })); + await stall$2(1000); + } + } + // Start dispatching requests + this.#scheduleDrain(); + })(); + } + /** + * Resolves once the [[_start]] has been called. This can be used in + * sub-classes to defer sending data until the connection has been + * established. + */ + async _waitUntilReady() { + if (this.#notReady == null) { + return; + } + return await this.#notReady.promise; + } + /** + * Return a Subscriber that will manage the %%sub%%. + * + * Sub-classes may override this to modify the behavior of + * subscription management. + */ + _getSubscriber(sub) { + // Pending Filters aren't availble via polling + if (sub.type === "pending") { + return new FilterIdPendingSubscriber(this); + } + if (sub.type === "event") { + if (this._getOption("polling")) { + return new PollingEventSubscriber(this, sub.filter); + } + return new FilterIdEventSubscriber(this, sub.filter); + } + // Orphaned Logs are handled automatically, by the filter, since + // logs with removed are emitted by it + if (sub.type === "orphan" && sub.filter.orphan === "drop-log") { + return new UnmanagedSubscriber("orphan"); + } + return super._getSubscriber(sub); + } + /** + * Returns true only if the [[_start]] has been called. + */ + get ready() { return this.#notReady == null; } + /** + * Returns %%tx%% as a normalized JSON-RPC transaction request, + * which has all values hexlified and any numeric values converted + * to Quantity values. + */ + getRpcTransaction(tx) { + const result = {}; + // JSON-RPC now requires numeric values to be "quantity" values + ["chainId", "gasLimit", "gasPrice", "type", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "value"].forEach((key) => { + if (tx[key] == null) { + return; + } + let dstKey = key; + if (key === "gasLimit") { + dstKey = "gas"; + } + result[dstKey] = toQuantity(getBigInt(tx[key], `tx.${key}`)); + }); + // Make sure addresses and data are lowercase + ["from", "to", "data"].forEach((key) => { + if (tx[key] == null) { + return; + } + result[key] = hexlify(tx[key]); + }); + // Normalize the access list object + if (tx.accessList) { + result["accessList"] = accessListify(tx.accessList); + } + return result; + } + /** + * Returns the request method and arguments required to perform + * %%req%%. + */ + getRpcRequest(req) { + switch (req.method) { + case "chainId": + return { method: "eth_chainId", args: [] }; + case "getBlockNumber": + return { method: "eth_blockNumber", args: [] }; + case "getGasPrice": + return { method: "eth_gasPrice", args: [] }; + case "getPriorityFee": + return { method: "eth_maxPriorityFeePerGas", args: [] }; + case "getBalance": + return { + method: "eth_getBalance", + args: [getLowerCase(req.address), req.blockTag] + }; + case "getTransactionCount": + return { + method: "eth_getTransactionCount", + args: [getLowerCase(req.address), req.blockTag] + }; + case "getCode": + return { + method: "eth_getCode", + args: [getLowerCase(req.address), req.blockTag] + }; + case "getStorage": + return { + method: "eth_getStorageAt", + args: [ + getLowerCase(req.address), + ("0x" + req.position.toString(16)), + req.blockTag + ] + }; + case "broadcastTransaction": + return { + method: "eth_sendRawTransaction", + args: [req.signedTransaction] + }; + case "getBlock": + if ("blockTag" in req) { + return { + method: "eth_getBlockByNumber", + args: [req.blockTag, !!req.includeTransactions] + }; + } + else if ("blockHash" in req) { + return { + method: "eth_getBlockByHash", + args: [req.blockHash, !!req.includeTransactions] + }; + } + break; + case "getTransaction": + return { + method: "eth_getTransactionByHash", + args: [req.hash] + }; + case "getTransactionReceipt": + return { + method: "eth_getTransactionReceipt", + args: [req.hash] + }; + case "call": + return { + method: "eth_call", + args: [this.getRpcTransaction(req.transaction), req.blockTag] + }; + case "estimateGas": { + return { + method: "eth_estimateGas", + args: [this.getRpcTransaction(req.transaction)] + }; + } + case "getLogs": + if (req.filter && req.filter.address != null) { + if (Array.isArray(req.filter.address)) { + req.filter.address = req.filter.address.map(getLowerCase); + } + else { + req.filter.address = getLowerCase(req.filter.address); + } + } + return { method: "eth_getLogs", args: [req.filter] }; + } + return null; + } + /** + * Returns an ethers-style Error for the given JSON-RPC error + * %%payload%%, coalescing the various strings and error shapes + * that different nodes return, coercing them into a machine-readable + * standardized error. + */ + getRpcError(payload, _error) { + const { method } = payload; + const { error } = _error; + if (method === "eth_estimateGas" && error.message) { + const msg = error.message; + if (!msg.match(/revert/i) && msg.match(/insufficient funds/i)) { + return makeError("insufficient funds", "INSUFFICIENT_FUNDS", { + transaction: (payload.params[0]), + info: { payload, error } + }); + } + } + if (method === "eth_call" || method === "eth_estimateGas") { + const result = spelunkData(error); + const e = AbiCoder.getBuiltinCallException((method === "eth_call") ? "call" : "estimateGas", (payload.params[0]), (result ? result.data : null)); + e.info = { error, payload }; + return e; + } + // Only estimateGas and call can return arbitrary contract-defined text, so now we + // we can process text safely. + const message = JSON.stringify(spelunkMessage(error)); + if (typeof (error.message) === "string" && error.message.match(/user denied|ethers-user-denied/i)) { + const actionMap = { + eth_sign: "signMessage", + personal_sign: "signMessage", + eth_signTypedData_v4: "signTypedData", + eth_signTransaction: "signTransaction", + eth_sendTransaction: "sendTransaction", + eth_requestAccounts: "requestAccess", + wallet_requestAccounts: "requestAccess", + }; + return makeError(`user rejected action`, "ACTION_REJECTED", { + action: (actionMap[method] || "unknown"), + reason: "rejected", + info: { payload, error } + }); + } + if (method === "eth_sendRawTransaction" || method === "eth_sendTransaction") { + const transaction = (payload.params[0]); + if (message.match(/insufficient funds|base fee exceeds gas limit/i)) { + return makeError("insufficient funds for intrinsic transaction cost", "INSUFFICIENT_FUNDS", { + transaction, info: { error } + }); + } + if (message.match(/nonce/i) && message.match(/too low/i)) { + return makeError("nonce has already been used", "NONCE_EXPIRED", { transaction, info: { error } }); + } + // "replacement transaction underpriced" + if (message.match(/replacement transaction/i) && message.match(/underpriced/i)) { + return makeError("replacement fee too low", "REPLACEMENT_UNDERPRICED", { transaction, info: { error } }); + } + if (message.match(/only replay-protected/i)) { + return makeError("legacy pre-eip-155 transactions not supported", "UNSUPPORTED_OPERATION", { + operation: method, info: { transaction, info: { error } } + }); + } + } + let unsupported = !!message.match(/the method .* does not exist/i); + if (!unsupported) { + if (error && error.details && error.details.startsWith("Unauthorized method:")) { + unsupported = true; + } + } + if (unsupported) { + return makeError("unsupported operation", "UNSUPPORTED_OPERATION", { + operation: payload.method, info: { error, payload } + }); + } + return makeError("could not coalesce error", "UNKNOWN_ERROR", { error, payload }); + } + /** + * Requests the %%method%% with %%params%% via the JSON-RPC protocol + * over the underlying channel. This can be used to call methods + * on the backend that do not have a high-level API within the Provider + * API. + * + * This method queues requests according to the batch constraints + * in the options, assigns the request a unique ID. + * + * **Do NOT override** this method in sub-classes; instead + * override [[_send]] or force the options values in the + * call to the constructor to modify this method's behavior. + */ + send(method, params) { + // @TODO: cache chainId?? purge on switch_networks + // We have been destroyed; no operations are supported anymore + if (this.destroyed) { + return Promise.reject(makeError("provider destroyed; cancelled request", "UNSUPPORTED_OPERATION", { operation: method })); + } + const id = this.#nextId++; + const promise = new Promise((resolve, reject) => { + this.#payloads.push({ + resolve, reject, + payload: { method, params, id, jsonrpc: "2.0" } + }); + }); + // If there is not a pending drainTimer, set one + this.#scheduleDrain(); + return promise; + } + /** + * Resolves to the [[Signer]] account for %%address%% managed by + * the client. + * + * If the %%address%% is a number, it is used as an index in the + * the accounts from [[listAccounts]]. + * + * This can only be used on clients which manage accounts (such as + * Geth with imported account or MetaMask). + * + * Throws if the account doesn't exist. + */ + async getSigner(address) { + if (address == null) { + address = 0; + } + const accountsPromise = this.send("eth_accounts", []); + // Account index + if (typeof (address) === "number") { + const accounts = (await accountsPromise); + if (address >= accounts.length) { + throw new Error("no such account"); + } + return new JsonRpcSigner(this, accounts[address]); + } + const { accounts } = await resolveProperties({ + network: this.getNetwork(), + accounts: accountsPromise + }); + // Account address + address = getAddress(address); + for (const account of accounts) { + if (getAddress(account) === address) { + return new JsonRpcSigner(this, address); + } + } + throw new Error("invalid account"); + } + async listAccounts() { + const accounts = await this.send("eth_accounts", []); + return accounts.map((a) => new JsonRpcSigner(this, a)); + } + destroy() { + // Stop processing requests + if (this.#drainTimer) { + clearTimeout(this.#drainTimer); + this.#drainTimer = null; + } + // Cancel all pending requests + for (const { payload, reject } of this.#payloads) { + reject(makeError("provider destroyed; cancelled request", "UNSUPPORTED_OPERATION", { operation: payload.method })); + } + this.#payloads = []; + // Parent clean-up + super.destroy(); + } +} +// @TODO: remove this in v7, it is not exported because this functionality +// is exposed in the JsonRpcApiProvider by setting polling to true. It should +// be safe to remove regardless, because it isn't reachable, but just in case. +/** + * @_ignore: + */ +class JsonRpcApiPollingProvider extends JsonRpcApiProvider { + #pollingInterval; + constructor(network, options) { + super(network, options); + this.#pollingInterval = 4000; + } + _getSubscriber(sub) { + const subscriber = super._getSubscriber(sub); + if (isPollable(subscriber)) { + subscriber.pollingInterval = this.#pollingInterval; + } + return subscriber; + } + /** + * The polling interval (default: 4000 ms) + */ + get pollingInterval() { return this.#pollingInterval; } + set pollingInterval(value) { + if (!Number.isInteger(value) || value < 0) { + throw new Error("invalid interval"); + } + this.#pollingInterval = value; + this._forEachSubscriber((sub) => { + if (isPollable(sub)) { + sub.pollingInterval = this.#pollingInterval; + } + }); + } +} +/** + * The JsonRpcProvider is one of the most common Providers, + * which performs all operations over HTTP (or HTTPS) requests. + * + * Events are processed by polling the backend for the current block + * number; when it advances, all block-base events are then checked + * for updates. + */ +class JsonRpcProvider extends JsonRpcApiPollingProvider { + #connect; + constructor(url, network, options) { + if (url == null) { + url = "http:/\/localhost:8545"; + } + super(network, options); + if (typeof (url) === "string") { + this.#connect = new FetchRequest(url); + } + else { + this.#connect = url.clone(); + } + } + _getConnection() { + return this.#connect.clone(); + } + async send(method, params) { + // All requests are over HTTP, so we can just start handling requests + // We do this here rather than the constructor so that we don't send any + // requests to the network (i.e. eth_chainId) until we absolutely have to. + await this._start(); + return await super.send(method, params); + } + async _send(payload) { + // Configure a POST connection for the requested method + const request = this._getConnection(); + request.body = JSON.stringify(payload); + request.setHeader("content-type", "application/json"); + const response = await request.send(); + response.assertOk(); + let resp = response.bodyJson; + if (!Array.isArray(resp)) { + resp = [resp]; + } + return resp; + } +} +function spelunkData(value) { + if (value == null) { + return null; + } + // These *are* the droids we're looking for. + if (typeof (value.message) === "string" && value.message.match(/revert/i) && isHexString$1(value.data)) { + return { message: value.message, data: value.data }; + } + // Spelunk further... + if (typeof (value) === "object") { + for (const key in value) { + const result = spelunkData(value[key]); + if (result) { + return result; + } + } + return null; + } + // Might be a JSON string we can further descend... + if (typeof (value) === "string") { + try { + return spelunkData(JSON.parse(value)); + } + catch (error) { } + } + return null; +} +function _spelunkMessage(value, result) { + if (value == null) { + return; + } + // These *are* the droids we're looking for. + if (typeof (value.message) === "string") { + result.push(value.message); + } + // Spelunk further... + if (typeof (value) === "object") { + for (const key in value) { + _spelunkMessage(value[key], result); + } + } + // Might be a JSON string we can further descend... + if (typeof (value) === "string") { + try { + return _spelunkMessage(JSON.parse(value), result); + } + catch (error) { } + } +} +function spelunkMessage(value) { + const result = []; + _spelunkMessage(value, result); + return result; +} + +var bufferUtil$1 = {exports: {}}; + +var constants$4 = { + BINARY_TYPES: ['nodebuffer', 'arraybuffer', 'fragments'], + EMPTY_BUFFER: Buffer.alloc(0), + GUID: '258EAFA5-E914-47DA-95CA-C5AB0DC85B11', + kForOnEventAttribute: Symbol('kIsForOnEventAttribute'), + kListener: Symbol('kListener'), + kStatusCode: Symbol('status-code'), + kWebSocket: Symbol('websocket'), + NOOP: () => {} +}; + +const { EMPTY_BUFFER: EMPTY_BUFFER$3 } = constants$4; + +/** + * Merges an array of buffers into a new buffer. + * + * @param {Buffer[]} list The array of buffers to concat + * @param {Number} totalLength The total length of buffers in the list + * @return {Buffer} The resulting buffer + * @public + */ +function concat$2(list, totalLength) { + if (list.length === 0) return EMPTY_BUFFER$3; + if (list.length === 1) return list[0]; + + const target = Buffer.allocUnsafe(totalLength); + let offset = 0; + + for (let i = 0; i < list.length; i++) { + const buf = list[i]; + target.set(buf, offset); + offset += buf.length; + } + + if (offset < totalLength) return target.slice(0, offset); + + return target; +} + +/** + * Masks a buffer using the given mask. + * + * @param {Buffer} source The buffer to mask + * @param {Buffer} mask The mask to use + * @param {Buffer} output The buffer where to store the result + * @param {Number} offset The offset at which to start writing + * @param {Number} length The number of bytes to mask. + * @public + */ +function _mask(source, mask, output, offset, length) { + for (let i = 0; i < length; i++) { + output[offset + i] = source[i] ^ mask[i & 3]; + } +} + +/** + * Unmasks a buffer using the given mask. + * + * @param {Buffer} buffer The buffer to unmask + * @param {Buffer} mask The mask to use + * @public + */ +function _unmask(buffer, mask) { + for (let i = 0; i < buffer.length; i++) { + buffer[i] ^= mask[i & 3]; + } +} + +/** + * Converts a buffer to an `ArrayBuffer`. + * + * @param {Buffer} buf The buffer to convert + * @return {ArrayBuffer} Converted buffer + * @public + */ +function toArrayBuffer$1(buf) { + if (buf.byteLength === buf.buffer.byteLength) { + return buf.buffer; + } + + return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); +} + +/** + * Converts `data` to a `Buffer`. + * + * @param {*} data The data to convert + * @return {Buffer} The buffer + * @throws {TypeError} + * @public + */ +function toBuffer$4(data) { + toBuffer$4.readOnly = true; + + if (Buffer.isBuffer(data)) return data; + + let buf; + + if (data instanceof ArrayBuffer) { + buf = Buffer.from(data); + } else if (ArrayBuffer.isView(data)) { + buf = Buffer.from(data.buffer, data.byteOffset, data.byteLength); + } else { + buf = Buffer.from(data); + toBuffer$4.readOnly = false; + } + + return buf; +} + +try { + const bufferUtil = require('bufferutil'); + + bufferUtil$1.exports = { + concat: concat$2, + mask(source, mask, output, offset, length) { + if (length < 48) _mask(source, mask, output, offset, length); + else bufferUtil.mask(source, mask, output, offset, length); + }, + toArrayBuffer: toArrayBuffer$1, + toBuffer: toBuffer$4, + unmask(buffer, mask) { + if (buffer.length < 32) _unmask(buffer, mask); + else bufferUtil.unmask(buffer, mask); + } + }; +} catch (e) /* istanbul ignore next */ { + bufferUtil$1.exports = { + concat: concat$2, + mask: _mask, + toArrayBuffer: toArrayBuffer$1, + toBuffer: toBuffer$4, + unmask: _unmask + }; +} + +var bufferUtilExports = bufferUtil$1.exports; + +const kDone = Symbol('kDone'); +const kRun = Symbol('kRun'); + +/** + * A very simple job queue with adjustable concurrency. Adapted from + * https://github.com/STRML/async-limiter + */ +let Limiter$1 = class Limiter { + /** + * Creates a new `Limiter`. + * + * @param {Number} [concurrency=Infinity] The maximum number of jobs allowed + * to run concurrently + */ + constructor(concurrency) { + this[kDone] = () => { + this.pending--; + this[kRun](); + }; + this.concurrency = concurrency || Infinity; + this.jobs = []; + this.pending = 0; + } + + /** + * Adds a job to the queue. + * + * @param {Function} job The job to run + * @public + */ + add(job) { + this.jobs.push(job); + this[kRun](); + } + + /** + * Removes a job from the queue and runs it if possible. + * + * @private + */ + [kRun]() { + if (this.pending === this.concurrency) return; + + if (this.jobs.length) { + const job = this.jobs.shift(); + + this.pending++; + job(this[kDone]); + } + } +}; + +var limiter = Limiter$1; + +const zlib = zlib$1; + +const bufferUtil = bufferUtilExports; +const Limiter = limiter; +const { kStatusCode: kStatusCode$2 } = constants$4; + +const TRAILER = Buffer.from([0x00, 0x00, 0xff, 0xff]); +const kPerMessageDeflate = Symbol('permessage-deflate'); +const kTotalLength = Symbol('total-length'); +const kCallback = Symbol('callback'); +const kBuffers = Symbol('buffers'); +const kError$1 = Symbol('error'); + +// +// We limit zlib concurrency, which prevents severe memory fragmentation +// as documented in https://github.com/nodejs/node/issues/8871#issuecomment-250915913 +// and https://github.com/websockets/ws/issues/1202 +// +// Intentionally global; it's the global thread pool that's an issue. +// +let zlibLimiter; + +/** + * permessage-deflate implementation. + */ +let PerMessageDeflate$3 = class PerMessageDeflate { + /** + * Creates a PerMessageDeflate instance. + * + * @param {Object} [options] Configuration options + * @param {(Boolean|Number)} [options.clientMaxWindowBits] Advertise support + * for, or request, a custom client window size + * @param {Boolean} [options.clientNoContextTakeover=false] Advertise/ + * acknowledge disabling of client context takeover + * @param {Number} [options.concurrencyLimit=10] The number of concurrent + * calls to zlib + * @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the + * use of a custom server window size + * @param {Boolean} [options.serverNoContextTakeover=false] Request/accept + * disabling of server context takeover + * @param {Number} [options.threshold=1024] Size (in bytes) below which + * messages should not be compressed if context takeover is disabled + * @param {Object} [options.zlibDeflateOptions] Options to pass to zlib on + * deflate + * @param {Object} [options.zlibInflateOptions] Options to pass to zlib on + * inflate + * @param {Boolean} [isServer=false] Create the instance in either server or + * client mode + * @param {Number} [maxPayload=0] The maximum allowed message length + */ + constructor(options, isServer, maxPayload) { + this._maxPayload = maxPayload | 0; + this._options = options || {}; + this._threshold = + this._options.threshold !== undefined ? this._options.threshold : 1024; + this._isServer = !!isServer; + this._deflate = null; + this._inflate = null; + + this.params = null; + + if (!zlibLimiter) { + const concurrency = + this._options.concurrencyLimit !== undefined + ? this._options.concurrencyLimit + : 10; + zlibLimiter = new Limiter(concurrency); + } + } + + /** + * @type {String} + */ + static get extensionName() { + return 'permessage-deflate'; + } + + /** + * Create an extension negotiation offer. + * + * @return {Object} Extension parameters + * @public + */ + offer() { + const params = {}; + + if (this._options.serverNoContextTakeover) { + params.server_no_context_takeover = true; + } + if (this._options.clientNoContextTakeover) { + params.client_no_context_takeover = true; + } + if (this._options.serverMaxWindowBits) { + params.server_max_window_bits = this._options.serverMaxWindowBits; + } + if (this._options.clientMaxWindowBits) { + params.client_max_window_bits = this._options.clientMaxWindowBits; + } else if (this._options.clientMaxWindowBits == null) { + params.client_max_window_bits = true; + } + + return params; + } + + /** + * Accept an extension negotiation offer/response. + * + * @param {Array} configurations The extension negotiation offers/reponse + * @return {Object} Accepted configuration + * @public + */ + accept(configurations) { + configurations = this.normalizeParams(configurations); + + this.params = this._isServer + ? this.acceptAsServer(configurations) + : this.acceptAsClient(configurations); + + return this.params; + } + + /** + * Releases all resources used by the extension. + * + * @public + */ + cleanup() { + if (this._inflate) { + this._inflate.close(); + this._inflate = null; + } + + if (this._deflate) { + const callback = this._deflate[kCallback]; + + this._deflate.close(); + this._deflate = null; + + if (callback) { + callback( + new Error( + 'The deflate stream was closed while data was being processed' + ) + ); + } + } + } + + /** + * Accept an extension negotiation offer. + * + * @param {Array} offers The extension negotiation offers + * @return {Object} Accepted configuration + * @private + */ + acceptAsServer(offers) { + const opts = this._options; + const accepted = offers.find((params) => { + if ( + (opts.serverNoContextTakeover === false && + params.server_no_context_takeover) || + (params.server_max_window_bits && + (opts.serverMaxWindowBits === false || + (typeof opts.serverMaxWindowBits === 'number' && + opts.serverMaxWindowBits > params.server_max_window_bits))) || + (typeof opts.clientMaxWindowBits === 'number' && + !params.client_max_window_bits) + ) { + return false; + } + + return true; + }); + + if (!accepted) { + throw new Error('None of the extension offers can be accepted'); + } + + if (opts.serverNoContextTakeover) { + accepted.server_no_context_takeover = true; + } + if (opts.clientNoContextTakeover) { + accepted.client_no_context_takeover = true; + } + if (typeof opts.serverMaxWindowBits === 'number') { + accepted.server_max_window_bits = opts.serverMaxWindowBits; + } + if (typeof opts.clientMaxWindowBits === 'number') { + accepted.client_max_window_bits = opts.clientMaxWindowBits; + } else if ( + accepted.client_max_window_bits === true || + opts.clientMaxWindowBits === false + ) { + delete accepted.client_max_window_bits; + } + + return accepted; + } + + /** + * Accept the extension negotiation response. + * + * @param {Array} response The extension negotiation response + * @return {Object} Accepted configuration + * @private + */ + acceptAsClient(response) { + const params = response[0]; + + if ( + this._options.clientNoContextTakeover === false && + params.client_no_context_takeover + ) { + throw new Error('Unexpected parameter "client_no_context_takeover"'); + } + + if (!params.client_max_window_bits) { + if (typeof this._options.clientMaxWindowBits === 'number') { + params.client_max_window_bits = this._options.clientMaxWindowBits; + } + } else if ( + this._options.clientMaxWindowBits === false || + (typeof this._options.clientMaxWindowBits === 'number' && + params.client_max_window_bits > this._options.clientMaxWindowBits) + ) { + throw new Error( + 'Unexpected or invalid parameter "client_max_window_bits"' + ); + } + + return params; + } + + /** + * Normalize parameters. + * + * @param {Array} configurations The extension negotiation offers/reponse + * @return {Array} The offers/response with normalized parameters + * @private + */ + normalizeParams(configurations) { + configurations.forEach((params) => { + Object.keys(params).forEach((key) => { + let value = params[key]; + + if (value.length > 1) { + throw new Error(`Parameter "${key}" must have only a single value`); + } + + value = value[0]; + + if (key === 'client_max_window_bits') { + if (value !== true) { + const num = +value; + if (!Number.isInteger(num) || num < 8 || num > 15) { + throw new TypeError( + `Invalid value for parameter "${key}": ${value}` + ); + } + value = num; + } else if (!this._isServer) { + throw new TypeError( + `Invalid value for parameter "${key}": ${value}` + ); + } + } else if (key === 'server_max_window_bits') { + const num = +value; + if (!Number.isInteger(num) || num < 8 || num > 15) { + throw new TypeError( + `Invalid value for parameter "${key}": ${value}` + ); + } + value = num; + } else if ( + key === 'client_no_context_takeover' || + key === 'server_no_context_takeover' + ) { + if (value !== true) { + throw new TypeError( + `Invalid value for parameter "${key}": ${value}` + ); + } + } else { + throw new Error(`Unknown parameter "${key}"`); + } + + params[key] = value; + }); + }); + + return configurations; + } + + /** + * Decompress data. Concurrency limited. + * + * @param {Buffer} data Compressed data + * @param {Boolean} fin Specifies whether or not this is the last fragment + * @param {Function} callback Callback + * @public + */ + decompress(data, fin, callback) { + zlibLimiter.add((done) => { + this._decompress(data, fin, (err, result) => { + done(); + callback(err, result); + }); + }); + } + + /** + * Compress data. Concurrency limited. + * + * @param {(Buffer|String)} data Data to compress + * @param {Boolean} fin Specifies whether or not this is the last fragment + * @param {Function} callback Callback + * @public + */ + compress(data, fin, callback) { + zlibLimiter.add((done) => { + this._compress(data, fin, (err, result) => { + done(); + callback(err, result); + }); + }); + } + + /** + * Decompress data. + * + * @param {Buffer} data Compressed data + * @param {Boolean} fin Specifies whether or not this is the last fragment + * @param {Function} callback Callback + * @private + */ + _decompress(data, fin, callback) { + const endpoint = this._isServer ? 'client' : 'server'; + + if (!this._inflate) { + const key = `${endpoint}_max_window_bits`; + const windowBits = + typeof this.params[key] !== 'number' + ? zlib.Z_DEFAULT_WINDOWBITS + : this.params[key]; + + this._inflate = zlib.createInflateRaw({ + ...this._options.zlibInflateOptions, + windowBits + }); + this._inflate[kPerMessageDeflate] = this; + this._inflate[kTotalLength] = 0; + this._inflate[kBuffers] = []; + this._inflate.on('error', inflateOnError); + this._inflate.on('data', inflateOnData); + } + + this._inflate[kCallback] = callback; + + this._inflate.write(data); + if (fin) this._inflate.write(TRAILER); + + this._inflate.flush(() => { + const err = this._inflate[kError$1]; + + if (err) { + this._inflate.close(); + this._inflate = null; + callback(err); + return; + } + + const data = bufferUtil.concat( + this._inflate[kBuffers], + this._inflate[kTotalLength] + ); + + if (this._inflate._readableState.endEmitted) { + this._inflate.close(); + this._inflate = null; + } else { + this._inflate[kTotalLength] = 0; + this._inflate[kBuffers] = []; + + if (fin && this.params[`${endpoint}_no_context_takeover`]) { + this._inflate.reset(); + } + } + + callback(null, data); + }); + } + + /** + * Compress data. + * + * @param {(Buffer|String)} data Data to compress + * @param {Boolean} fin Specifies whether or not this is the last fragment + * @param {Function} callback Callback + * @private + */ + _compress(data, fin, callback) { + const endpoint = this._isServer ? 'server' : 'client'; + + if (!this._deflate) { + const key = `${endpoint}_max_window_bits`; + const windowBits = + typeof this.params[key] !== 'number' + ? zlib.Z_DEFAULT_WINDOWBITS + : this.params[key]; + + this._deflate = zlib.createDeflateRaw({ + ...this._options.zlibDeflateOptions, + windowBits + }); + + this._deflate[kTotalLength] = 0; + this._deflate[kBuffers] = []; + + this._deflate.on('data', deflateOnData); + } + + this._deflate[kCallback] = callback; + + this._deflate.write(data); + this._deflate.flush(zlib.Z_SYNC_FLUSH, () => { + if (!this._deflate) { + // + // The deflate stream was closed while data was being processed. + // + return; + } + + let data = bufferUtil.concat( + this._deflate[kBuffers], + this._deflate[kTotalLength] + ); + + if (fin) data = data.slice(0, data.length - 4); + + // + // Ensure that the callback will not be called again in + // `PerMessageDeflate#cleanup()`. + // + this._deflate[kCallback] = null; + + this._deflate[kTotalLength] = 0; + this._deflate[kBuffers] = []; + + if (fin && this.params[`${endpoint}_no_context_takeover`]) { + this._deflate.reset(); + } + + callback(null, data); + }); + } +}; + +var permessageDeflate = PerMessageDeflate$3; + +/** + * The listener of the `zlib.DeflateRaw` stream `'data'` event. + * + * @param {Buffer} chunk A chunk of data + * @private + */ +function deflateOnData(chunk) { + this[kBuffers].push(chunk); + this[kTotalLength] += chunk.length; +} + +/** + * The listener of the `zlib.InflateRaw` stream `'data'` event. + * + * @param {Buffer} chunk A chunk of data + * @private + */ +function inflateOnData(chunk) { + this[kTotalLength] += chunk.length; + + if ( + this[kPerMessageDeflate]._maxPayload < 1 || + this[kTotalLength] <= this[kPerMessageDeflate]._maxPayload + ) { + this[kBuffers].push(chunk); + return; + } + + this[kError$1] = new RangeError('Max payload size exceeded'); + this[kError$1].code = 'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH'; + this[kError$1][kStatusCode$2] = 1009; + this.removeListener('data', inflateOnData); + this.reset(); +} + +/** + * The listener of the `zlib.InflateRaw` stream `'error'` event. + * + * @param {Error} err The emitted error + * @private + */ +function inflateOnError(err) { + // + // There is no need to call `Zlib#close()` as the handle is automatically + // closed when an error is emitted. + // + this[kPerMessageDeflate]._inflate = null; + err[kStatusCode$2] = 1007; + this[kCallback](err); +} + +var validation$2 = {exports: {}}; + +// +// Allowed token characters: +// +// '!', '#', '$', '%', '&', ''', '*', '+', '-', +// '.', 0-9, A-Z, '^', '_', '`', a-z, '|', '~' +// +// tokenChars[32] === 0 // ' ' +// tokenChars[33] === 1 // '!' +// tokenChars[34] === 0 // '"' +// ... +// +// prettier-ignore +const tokenChars$1 = [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 15 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 - 31 + 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, // 32 - 47 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 48 - 63 + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 64 - 79 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, // 80 - 95 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 96 - 111 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0 // 112 - 127 +]; + +/** + * Checks if a status code is allowed in a close frame. + * + * @param {Number} code The status code + * @return {Boolean} `true` if the status code is valid, else `false` + * @public + */ +function isValidStatusCode$2(code) { + return ( + (code >= 1000 && + code <= 1014 && + code !== 1004 && + code !== 1005 && + code !== 1006) || + (code >= 3000 && code <= 4999) + ); +} + +/** + * Checks if a given buffer contains only correct UTF-8. + * Ported from https://www.cl.cam.ac.uk/%7Emgk25/ucs/utf8_check.c by + * Markus Kuhn. + * + * @param {Buffer} buf The buffer to check + * @return {Boolean} `true` if `buf` contains only correct UTF-8, else `false` + * @public + */ +function _isValidUTF8(buf) { + const len = buf.length; + let i = 0; + + while (i < len) { + if ((buf[i] & 0x80) === 0) { + // 0xxxxxxx + i++; + } else if ((buf[i] & 0xe0) === 0xc0) { + // 110xxxxx 10xxxxxx + if ( + i + 1 === len || + (buf[i + 1] & 0xc0) !== 0x80 || + (buf[i] & 0xfe) === 0xc0 // Overlong + ) { + return false; + } + + i += 2; + } else if ((buf[i] & 0xf0) === 0xe0) { + // 1110xxxx 10xxxxxx 10xxxxxx + if ( + i + 2 >= len || + (buf[i + 1] & 0xc0) !== 0x80 || + (buf[i + 2] & 0xc0) !== 0x80 || + (buf[i] === 0xe0 && (buf[i + 1] & 0xe0) === 0x80) || // Overlong + (buf[i] === 0xed && (buf[i + 1] & 0xe0) === 0xa0) // Surrogate (U+D800 - U+DFFF) + ) { + return false; + } + + i += 3; + } else if ((buf[i] & 0xf8) === 0xf0) { + // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + if ( + i + 3 >= len || + (buf[i + 1] & 0xc0) !== 0x80 || + (buf[i + 2] & 0xc0) !== 0x80 || + (buf[i + 3] & 0xc0) !== 0x80 || + (buf[i] === 0xf0 && (buf[i + 1] & 0xf0) === 0x80) || // Overlong + (buf[i] === 0xf4 && buf[i + 1] > 0x8f) || + buf[i] > 0xf4 // > U+10FFFF + ) { + return false; + } + + i += 4; + } else { + return false; + } + } + + return true; +} + +try { + const isValidUTF8 = require('utf-8-validate'); + + validation$2.exports = { + isValidStatusCode: isValidStatusCode$2, + isValidUTF8(buf) { + return buf.length < 150 ? _isValidUTF8(buf) : isValidUTF8(buf); + }, + tokenChars: tokenChars$1 + }; +} catch (e) /* istanbul ignore next */ { + validation$2.exports = { + isValidStatusCode: isValidStatusCode$2, + isValidUTF8: _isValidUTF8, + tokenChars: tokenChars$1 + }; +} + +var validationExports = validation$2.exports; + +const { Writable } = Stream; + +const PerMessageDeflate$2 = permessageDeflate; +const { + BINARY_TYPES: BINARY_TYPES$1, + EMPTY_BUFFER: EMPTY_BUFFER$2, + kStatusCode: kStatusCode$1, + kWebSocket: kWebSocket$1 +} = constants$4; +const { concat: concat$1, toArrayBuffer, unmask } = bufferUtilExports; +const { isValidStatusCode: isValidStatusCode$1, isValidUTF8 } = validationExports; + +const GET_INFO = 0; +const GET_PAYLOAD_LENGTH_16 = 1; +const GET_PAYLOAD_LENGTH_64 = 2; +const GET_MASK = 3; +const GET_DATA = 4; +const INFLATING = 5; + +/** + * HyBi Receiver implementation. + * + * @extends Writable + */ +let Receiver$1 = class Receiver extends Writable { + /** + * Creates a Receiver instance. + * + * @param {Object} [options] Options object + * @param {String} [options.binaryType=nodebuffer] The type for binary data + * @param {Object} [options.extensions] An object containing the negotiated + * extensions + * @param {Boolean} [options.isServer=false] Specifies whether to operate in + * client or server mode + * @param {Number} [options.maxPayload=0] The maximum allowed message length + * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or + * not to skip UTF-8 validation for text and close messages + */ + constructor(options = {}) { + super(); + + this._binaryType = options.binaryType || BINARY_TYPES$1[0]; + this._extensions = options.extensions || {}; + this._isServer = !!options.isServer; + this._maxPayload = options.maxPayload | 0; + this._skipUTF8Validation = !!options.skipUTF8Validation; + this[kWebSocket$1] = undefined; + + this._bufferedBytes = 0; + this._buffers = []; + + this._compressed = false; + this._payloadLength = 0; + this._mask = undefined; + this._fragmented = 0; + this._masked = false; + this._fin = false; + this._opcode = 0; + + this._totalPayloadLength = 0; + this._messageLength = 0; + this._fragments = []; + + this._state = GET_INFO; + this._loop = false; + } + + /** + * Implements `Writable.prototype._write()`. + * + * @param {Buffer} chunk The chunk of data to write + * @param {String} encoding The character encoding of `chunk` + * @param {Function} cb Callback + * @private + */ + _write(chunk, encoding, cb) { + if (this._opcode === 0x08 && this._state == GET_INFO) return cb(); + + this._bufferedBytes += chunk.length; + this._buffers.push(chunk); + this.startLoop(cb); + } + + /** + * Consumes `n` bytes from the buffered data. + * + * @param {Number} n The number of bytes to consume + * @return {Buffer} The consumed bytes + * @private + */ + consume(n) { + this._bufferedBytes -= n; + + if (n === this._buffers[0].length) return this._buffers.shift(); + + if (n < this._buffers[0].length) { + const buf = this._buffers[0]; + this._buffers[0] = buf.slice(n); + return buf.slice(0, n); + } + + const dst = Buffer.allocUnsafe(n); + + do { + const buf = this._buffers[0]; + const offset = dst.length - n; + + if (n >= buf.length) { + dst.set(this._buffers.shift(), offset); + } else { + dst.set(new Uint8Array(buf.buffer, buf.byteOffset, n), offset); + this._buffers[0] = buf.slice(n); + } + + n -= buf.length; + } while (n > 0); + + return dst; + } + + /** + * Starts the parsing loop. + * + * @param {Function} cb Callback + * @private + */ + startLoop(cb) { + let err; + this._loop = true; + + do { + switch (this._state) { + case GET_INFO: + err = this.getInfo(); + break; + case GET_PAYLOAD_LENGTH_16: + err = this.getPayloadLength16(); + break; + case GET_PAYLOAD_LENGTH_64: + err = this.getPayloadLength64(); + break; + case GET_MASK: + this.getMask(); + break; + case GET_DATA: + err = this.getData(cb); + break; + default: + // `INFLATING` + this._loop = false; + return; + } + } while (this._loop); + + cb(err); + } + + /** + * Reads the first two bytes of a frame. + * + * @return {(RangeError|undefined)} A possible error + * @private + */ + getInfo() { + if (this._bufferedBytes < 2) { + this._loop = false; + return; + } + + const buf = this.consume(2); + + if ((buf[0] & 0x30) !== 0x00) { + this._loop = false; + return error$j( + RangeError, + 'RSV2 and RSV3 must be clear', + true, + 1002, + 'WS_ERR_UNEXPECTED_RSV_2_3' + ); + } + + const compressed = (buf[0] & 0x40) === 0x40; + + if (compressed && !this._extensions[PerMessageDeflate$2.extensionName]) { + this._loop = false; + return error$j( + RangeError, + 'RSV1 must be clear', + true, + 1002, + 'WS_ERR_UNEXPECTED_RSV_1' + ); + } + + this._fin = (buf[0] & 0x80) === 0x80; + this._opcode = buf[0] & 0x0f; + this._payloadLength = buf[1] & 0x7f; + + if (this._opcode === 0x00) { + if (compressed) { + this._loop = false; + return error$j( + RangeError, + 'RSV1 must be clear', + true, + 1002, + 'WS_ERR_UNEXPECTED_RSV_1' + ); + } + + if (!this._fragmented) { + this._loop = false; + return error$j( + RangeError, + 'invalid opcode 0', + true, + 1002, + 'WS_ERR_INVALID_OPCODE' + ); + } + + this._opcode = this._fragmented; + } else if (this._opcode === 0x01 || this._opcode === 0x02) { + if (this._fragmented) { + this._loop = false; + return error$j( + RangeError, + `invalid opcode ${this._opcode}`, + true, + 1002, + 'WS_ERR_INVALID_OPCODE' + ); + } + + this._compressed = compressed; + } else if (this._opcode > 0x07 && this._opcode < 0x0b) { + if (!this._fin) { + this._loop = false; + return error$j( + RangeError, + 'FIN must be set', + true, + 1002, + 'WS_ERR_EXPECTED_FIN' + ); + } + + if (compressed) { + this._loop = false; + return error$j( + RangeError, + 'RSV1 must be clear', + true, + 1002, + 'WS_ERR_UNEXPECTED_RSV_1' + ); + } + + if (this._payloadLength > 0x7d) { + this._loop = false; + return error$j( + RangeError, + `invalid payload length ${this._payloadLength}`, + true, + 1002, + 'WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH' + ); + } + } else { + this._loop = false; + return error$j( + RangeError, + `invalid opcode ${this._opcode}`, + true, + 1002, + 'WS_ERR_INVALID_OPCODE' + ); + } + + if (!this._fin && !this._fragmented) this._fragmented = this._opcode; + this._masked = (buf[1] & 0x80) === 0x80; + + if (this._isServer) { + if (!this._masked) { + this._loop = false; + return error$j( + RangeError, + 'MASK must be set', + true, + 1002, + 'WS_ERR_EXPECTED_MASK' + ); + } + } else if (this._masked) { + this._loop = false; + return error$j( + RangeError, + 'MASK must be clear', + true, + 1002, + 'WS_ERR_UNEXPECTED_MASK' + ); + } + + if (this._payloadLength === 126) this._state = GET_PAYLOAD_LENGTH_16; + else if (this._payloadLength === 127) this._state = GET_PAYLOAD_LENGTH_64; + else return this.haveLength(); + } + + /** + * Gets extended payload length (7+16). + * + * @return {(RangeError|undefined)} A possible error + * @private + */ + getPayloadLength16() { + if (this._bufferedBytes < 2) { + this._loop = false; + return; + } + + this._payloadLength = this.consume(2).readUInt16BE(0); + return this.haveLength(); + } + + /** + * Gets extended payload length (7+64). + * + * @return {(RangeError|undefined)} A possible error + * @private + */ + getPayloadLength64() { + if (this._bufferedBytes < 8) { + this._loop = false; + return; + } + + const buf = this.consume(8); + const num = buf.readUInt32BE(0); + + // + // The maximum safe integer in JavaScript is 2^53 - 1. An error is returned + // if payload length is greater than this number. + // + if (num > Math.pow(2, 53 - 32) - 1) { + this._loop = false; + return error$j( + RangeError, + 'Unsupported WebSocket frame: payload length > 2^53 - 1', + false, + 1009, + 'WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH' + ); + } + + this._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4); + return this.haveLength(); + } + + /** + * Payload length has been read. + * + * @return {(RangeError|undefined)} A possible error + * @private + */ + haveLength() { + if (this._payloadLength && this._opcode < 0x08) { + this._totalPayloadLength += this._payloadLength; + if (this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) { + this._loop = false; + return error$j( + RangeError, + 'Max payload size exceeded', + false, + 1009, + 'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH' + ); + } + } + + if (this._masked) this._state = GET_MASK; + else this._state = GET_DATA; + } + + /** + * Reads mask bytes. + * + * @private + */ + getMask() { + if (this._bufferedBytes < 4) { + this._loop = false; + return; + } + + this._mask = this.consume(4); + this._state = GET_DATA; + } + + /** + * Reads data bytes. + * + * @param {Function} cb Callback + * @return {(Error|RangeError|undefined)} A possible error + * @private + */ + getData(cb) { + let data = EMPTY_BUFFER$2; + + if (this._payloadLength) { + if (this._bufferedBytes < this._payloadLength) { + this._loop = false; + return; + } + + data = this.consume(this._payloadLength); + + if ( + this._masked && + (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0 + ) { + unmask(data, this._mask); + } + } + + if (this._opcode > 0x07) return this.controlMessage(data); + + if (this._compressed) { + this._state = INFLATING; + this.decompress(data, cb); + return; + } + + if (data.length) { + // + // This message is not compressed so its length is the sum of the payload + // length of all fragments. + // + this._messageLength = this._totalPayloadLength; + this._fragments.push(data); + } + + return this.dataMessage(); + } + + /** + * Decompresses data. + * + * @param {Buffer} data Compressed data + * @param {Function} cb Callback + * @private + */ + decompress(data, cb) { + const perMessageDeflate = this._extensions[PerMessageDeflate$2.extensionName]; + + perMessageDeflate.decompress(data, this._fin, (err, buf) => { + if (err) return cb(err); + + if (buf.length) { + this._messageLength += buf.length; + if (this._messageLength > this._maxPayload && this._maxPayload > 0) { + return cb( + error$j( + RangeError, + 'Max payload size exceeded', + false, + 1009, + 'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH' + ) + ); + } + + this._fragments.push(buf); + } + + const er = this.dataMessage(); + if (er) return cb(er); + + this.startLoop(cb); + }); + } + + /** + * Handles a data message. + * + * @return {(Error|undefined)} A possible error + * @private + */ + dataMessage() { + if (this._fin) { + const messageLength = this._messageLength; + const fragments = this._fragments; + + this._totalPayloadLength = 0; + this._messageLength = 0; + this._fragmented = 0; + this._fragments = []; + + if (this._opcode === 2) { + let data; + + if (this._binaryType === 'nodebuffer') { + data = concat$1(fragments, messageLength); + } else if (this._binaryType === 'arraybuffer') { + data = toArrayBuffer(concat$1(fragments, messageLength)); + } else { + data = fragments; + } + + this.emit('message', data, true); + } else { + const buf = concat$1(fragments, messageLength); + + if (!this._skipUTF8Validation && !isValidUTF8(buf)) { + this._loop = false; + return error$j( + Error, + 'invalid UTF-8 sequence', + true, + 1007, + 'WS_ERR_INVALID_UTF8' + ); + } + + this.emit('message', buf, false); + } + } + + this._state = GET_INFO; + } + + /** + * Handles a control message. + * + * @param {Buffer} data Data to handle + * @return {(Error|RangeError|undefined)} A possible error + * @private + */ + controlMessage(data) { + if (this._opcode === 0x08) { + this._loop = false; + + if (data.length === 0) { + this.emit('conclude', 1005, EMPTY_BUFFER$2); + this.end(); + } else if (data.length === 1) { + return error$j( + RangeError, + 'invalid payload length 1', + true, + 1002, + 'WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH' + ); + } else { + const code = data.readUInt16BE(0); + + if (!isValidStatusCode$1(code)) { + return error$j( + RangeError, + `invalid status code ${code}`, + true, + 1002, + 'WS_ERR_INVALID_CLOSE_CODE' + ); + } + + const buf = data.slice(2); + + if (!this._skipUTF8Validation && !isValidUTF8(buf)) { + return error$j( + Error, + 'invalid UTF-8 sequence', + true, + 1007, + 'WS_ERR_INVALID_UTF8' + ); + } + + this.emit('conclude', code, buf); + this.end(); + } + } else if (this._opcode === 0x09) { + this.emit('ping', data); + } else { + this.emit('pong', data); + } + + this._state = GET_INFO; + } +}; + +var receiver = Receiver$1; + +/** + * Builds an error object. + * + * @param {function(new:Error|RangeError)} ErrorCtor The error constructor + * @param {String} message The error message + * @param {Boolean} prefix Specifies whether or not to add a default prefix to + * `message` + * @param {Number} statusCode The status code + * @param {String} errorCode The exposed error code + * @return {(Error|RangeError)} The error + * @private + */ +function error$j(ErrorCtor, message, prefix, statusCode, errorCode) { + const err = new ErrorCtor( + prefix ? `Invalid WebSocket frame: ${message}` : message + ); + + Error.captureStackTrace(err, error$j); + err.code = errorCode; + err[kStatusCode$1] = statusCode; + return err; +} + +/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^net|tls$" }] */ +const { randomFillSync } = require$$5; + +const PerMessageDeflate$1 = permessageDeflate; +const { EMPTY_BUFFER: EMPTY_BUFFER$1 } = constants$4; +const { isValidStatusCode } = validationExports; +const { mask: applyMask, toBuffer: toBuffer$3 } = bufferUtilExports; + +const kByteLength = Symbol('kByteLength'); +const maskBuffer = Buffer.alloc(4); + +/** + * HyBi Sender implementation. + */ +let Sender$1 = class Sender { + /** + * Creates a Sender instance. + * + * @param {(net.Socket|tls.Socket)} socket The connection socket + * @param {Object} [extensions] An object containing the negotiated extensions + * @param {Function} [generateMask] The function used to generate the masking + * key + */ + constructor(socket, extensions, generateMask) { + this._extensions = extensions || {}; + + if (generateMask) { + this._generateMask = generateMask; + this._maskBuffer = Buffer.alloc(4); + } + + this._socket = socket; + + this._firstFragment = true; + this._compress = false; + + this._bufferedBytes = 0; + this._deflating = false; + this._queue = []; + } + + /** + * Frames a piece of data according to the HyBi WebSocket protocol. + * + * @param {(Buffer|String)} data The data to frame + * @param {Object} options Options object + * @param {Boolean} [options.fin=false] Specifies whether or not to set the + * FIN bit + * @param {Function} [options.generateMask] The function used to generate the + * masking key + * @param {Boolean} [options.mask=false] Specifies whether or not to mask + * `data` + * @param {Buffer} [options.maskBuffer] The buffer used to store the masking + * key + * @param {Number} options.opcode The opcode + * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be + * modified + * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the + * RSV1 bit + * @return {(Buffer|String)[]} The framed data + * @public + */ + static frame(data, options) { + let mask; + let merge = false; + let offset = 2; + let skipMasking = false; + + if (options.mask) { + mask = options.maskBuffer || maskBuffer; + + if (options.generateMask) { + options.generateMask(mask); + } else { + randomFillSync(mask, 0, 4); + } + + skipMasking = (mask[0] | mask[1] | mask[2] | mask[3]) === 0; + offset = 6; + } + + let dataLength; + + if (typeof data === 'string') { + if ( + (!options.mask || skipMasking) && + options[kByteLength] !== undefined + ) { + dataLength = options[kByteLength]; + } else { + data = Buffer.from(data); + dataLength = data.length; + } + } else { + dataLength = data.length; + merge = options.mask && options.readOnly && !skipMasking; + } + + let payloadLength = dataLength; + + if (dataLength >= 65536) { + offset += 8; + payloadLength = 127; + } else if (dataLength > 125) { + offset += 2; + payloadLength = 126; + } + + const target = Buffer.allocUnsafe(merge ? dataLength + offset : offset); + + target[0] = options.fin ? options.opcode | 0x80 : options.opcode; + if (options.rsv1) target[0] |= 0x40; + + target[1] = payloadLength; + + if (payloadLength === 126) { + target.writeUInt16BE(dataLength, 2); + } else if (payloadLength === 127) { + target[2] = target[3] = 0; + target.writeUIntBE(dataLength, 4, 6); + } + + if (!options.mask) return [target, data]; + + target[1] |= 0x80; + target[offset - 4] = mask[0]; + target[offset - 3] = mask[1]; + target[offset - 2] = mask[2]; + target[offset - 1] = mask[3]; + + if (skipMasking) return [target, data]; + + if (merge) { + applyMask(data, mask, target, offset, dataLength); + return [target]; + } + + applyMask(data, mask, data, 0, dataLength); + return [target, data]; + } + + /** + * Sends a close message to the other peer. + * + * @param {Number} [code] The status code component of the body + * @param {(String|Buffer)} [data] The message component of the body + * @param {Boolean} [mask=false] Specifies whether or not to mask the message + * @param {Function} [cb] Callback + * @public + */ + close(code, data, mask, cb) { + let buf; + + if (code === undefined) { + buf = EMPTY_BUFFER$1; + } else if (typeof code !== 'number' || !isValidStatusCode(code)) { + throw new TypeError('First argument must be a valid error code number'); + } else if (data === undefined || !data.length) { + buf = Buffer.allocUnsafe(2); + buf.writeUInt16BE(code, 0); + } else { + const length = Buffer.byteLength(data); + + if (length > 123) { + throw new RangeError('The message must not be greater than 123 bytes'); + } + + buf = Buffer.allocUnsafe(2 + length); + buf.writeUInt16BE(code, 0); + + if (typeof data === 'string') { + buf.write(data, 2); + } else { + buf.set(data, 2); + } + } + + const options = { + [kByteLength]: buf.length, + fin: true, + generateMask: this._generateMask, + mask, + maskBuffer: this._maskBuffer, + opcode: 0x08, + readOnly: false, + rsv1: false + }; + + if (this._deflating) { + this.enqueue([this.dispatch, buf, false, options, cb]); + } else { + this.sendFrame(Sender.frame(buf, options), cb); + } + } + + /** + * Sends a ping message to the other peer. + * + * @param {*} data The message to send + * @param {Boolean} [mask=false] Specifies whether or not to mask `data` + * @param {Function} [cb] Callback + * @public + */ + ping(data, mask, cb) { + let byteLength; + let readOnly; + + if (typeof data === 'string') { + byteLength = Buffer.byteLength(data); + readOnly = false; + } else { + data = toBuffer$3(data); + byteLength = data.length; + readOnly = toBuffer$3.readOnly; + } + + if (byteLength > 125) { + throw new RangeError('The data size must not be greater than 125 bytes'); + } + + const options = { + [kByteLength]: byteLength, + fin: true, + generateMask: this._generateMask, + mask, + maskBuffer: this._maskBuffer, + opcode: 0x09, + readOnly, + rsv1: false + }; + + if (this._deflating) { + this.enqueue([this.dispatch, data, false, options, cb]); + } else { + this.sendFrame(Sender.frame(data, options), cb); + } + } + + /** + * Sends a pong message to the other peer. + * + * @param {*} data The message to send + * @param {Boolean} [mask=false] Specifies whether or not to mask `data` + * @param {Function} [cb] Callback + * @public + */ + pong(data, mask, cb) { + let byteLength; + let readOnly; + + if (typeof data === 'string') { + byteLength = Buffer.byteLength(data); + readOnly = false; + } else { + data = toBuffer$3(data); + byteLength = data.length; + readOnly = toBuffer$3.readOnly; + } + + if (byteLength > 125) { + throw new RangeError('The data size must not be greater than 125 bytes'); + } + + const options = { + [kByteLength]: byteLength, + fin: true, + generateMask: this._generateMask, + mask, + maskBuffer: this._maskBuffer, + opcode: 0x0a, + readOnly, + rsv1: false + }; + + if (this._deflating) { + this.enqueue([this.dispatch, data, false, options, cb]); + } else { + this.sendFrame(Sender.frame(data, options), cb); + } + } + + /** + * Sends a data message to the other peer. + * + * @param {*} data The message to send + * @param {Object} options Options object + * @param {Boolean} [options.binary=false] Specifies whether `data` is binary + * or text + * @param {Boolean} [options.compress=false] Specifies whether or not to + * compress `data` + * @param {Boolean} [options.fin=false] Specifies whether the fragment is the + * last one + * @param {Boolean} [options.mask=false] Specifies whether or not to mask + * `data` + * @param {Function} [cb] Callback + * @public + */ + send(data, options, cb) { + const perMessageDeflate = this._extensions[PerMessageDeflate$1.extensionName]; + let opcode = options.binary ? 2 : 1; + let rsv1 = options.compress; + + let byteLength; + let readOnly; + + if (typeof data === 'string') { + byteLength = Buffer.byteLength(data); + readOnly = false; + } else { + data = toBuffer$3(data); + byteLength = data.length; + readOnly = toBuffer$3.readOnly; + } + + if (this._firstFragment) { + this._firstFragment = false; + if ( + rsv1 && + perMessageDeflate && + perMessageDeflate.params[ + perMessageDeflate._isServer + ? 'server_no_context_takeover' + : 'client_no_context_takeover' + ] + ) { + rsv1 = byteLength >= perMessageDeflate._threshold; + } + this._compress = rsv1; + } else { + rsv1 = false; + opcode = 0; + } + + if (options.fin) this._firstFragment = true; + + if (perMessageDeflate) { + const opts = { + [kByteLength]: byteLength, + fin: options.fin, + generateMask: this._generateMask, + mask: options.mask, + maskBuffer: this._maskBuffer, + opcode, + readOnly, + rsv1 + }; + + if (this._deflating) { + this.enqueue([this.dispatch, data, this._compress, opts, cb]); + } else { + this.dispatch(data, this._compress, opts, cb); + } + } else { + this.sendFrame( + Sender.frame(data, { + [kByteLength]: byteLength, + fin: options.fin, + generateMask: this._generateMask, + mask: options.mask, + maskBuffer: this._maskBuffer, + opcode, + readOnly, + rsv1: false + }), + cb + ); + } + } + + /** + * Dispatches a message. + * + * @param {(Buffer|String)} data The message to send + * @param {Boolean} [compress=false] Specifies whether or not to compress + * `data` + * @param {Object} options Options object + * @param {Boolean} [options.fin=false] Specifies whether or not to set the + * FIN bit + * @param {Function} [options.generateMask] The function used to generate the + * masking key + * @param {Boolean} [options.mask=false] Specifies whether or not to mask + * `data` + * @param {Buffer} [options.maskBuffer] The buffer used to store the masking + * key + * @param {Number} options.opcode The opcode + * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be + * modified + * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the + * RSV1 bit + * @param {Function} [cb] Callback + * @private + */ + dispatch(data, compress, options, cb) { + if (!compress) { + this.sendFrame(Sender.frame(data, options), cb); + return; + } + + const perMessageDeflate = this._extensions[PerMessageDeflate$1.extensionName]; + + this._bufferedBytes += options[kByteLength]; + this._deflating = true; + perMessageDeflate.compress(data, options.fin, (_, buf) => { + if (this._socket.destroyed) { + const err = new Error( + 'The socket was closed while data was being compressed' + ); + + if (typeof cb === 'function') cb(err); + + for (let i = 0; i < this._queue.length; i++) { + const params = this._queue[i]; + const callback = params[params.length - 1]; + + if (typeof callback === 'function') callback(err); + } + + return; + } + + this._bufferedBytes -= options[kByteLength]; + this._deflating = false; + options.readOnly = false; + this.sendFrame(Sender.frame(buf, options), cb); + this.dequeue(); + }); + } + + /** + * Executes queued send operations. + * + * @private + */ + dequeue() { + while (!this._deflating && this._queue.length) { + const params = this._queue.shift(); + + this._bufferedBytes -= params[3][kByteLength]; + Reflect.apply(params[0], this, params.slice(1)); + } + } + + /** + * Enqueues a send operation. + * + * @param {Array} params Send operation parameters. + * @private + */ + enqueue(params) { + this._bufferedBytes += params[3][kByteLength]; + this._queue.push(params); + } + + /** + * Sends a frame. + * + * @param {Buffer[]} list The frame to send + * @param {Function} [cb] Callback + * @private + */ + sendFrame(list, cb) { + if (list.length === 2) { + this._socket.cork(); + this._socket.write(list[0]); + this._socket.write(list[1], cb); + this._socket.uncork(); + } else { + this._socket.write(list[0], cb); + } + } +}; + +var sender = Sender$1; + +const { kForOnEventAttribute: kForOnEventAttribute$1, kListener: kListener$1 } = constants$4; + +const kCode = Symbol('kCode'); +const kData = Symbol('kData'); +const kError = Symbol('kError'); +const kMessage = Symbol('kMessage'); +const kReason = Symbol('kReason'); +const kTarget = Symbol('kTarget'); +const kType = Symbol('kType'); +const kWasClean = Symbol('kWasClean'); + +/** + * Class representing an event. + */ +let Event$1 = class Event { + /** + * Create a new `Event`. + * + * @param {String} type The name of the event + * @throws {TypeError} If the `type` argument is not specified + */ + constructor(type) { + this[kTarget] = null; + this[kType] = type; + } + + /** + * @type {*} + */ + get target() { + return this[kTarget]; + } + + /** + * @type {String} + */ + get type() { + return this[kType]; + } +}; + +Object.defineProperty(Event$1.prototype, 'target', { enumerable: true }); +Object.defineProperty(Event$1.prototype, 'type', { enumerable: true }); + +/** + * Class representing a close event. + * + * @extends Event + */ +class CloseEvent extends Event$1 { + /** + * Create a new `CloseEvent`. + * + * @param {String} type The name of the event + * @param {Object} [options] A dictionary object that allows for setting + * attributes via object members of the same name + * @param {Number} [options.code=0] The status code explaining why the + * connection was closed + * @param {String} [options.reason=''] A human-readable string explaining why + * the connection was closed + * @param {Boolean} [options.wasClean=false] Indicates whether or not the + * connection was cleanly closed + */ + constructor(type, options = {}) { + super(type); + + this[kCode] = options.code === undefined ? 0 : options.code; + this[kReason] = options.reason === undefined ? '' : options.reason; + this[kWasClean] = options.wasClean === undefined ? false : options.wasClean; + } + + /** + * @type {Number} + */ + get code() { + return this[kCode]; + } + + /** + * @type {String} + */ + get reason() { + return this[kReason]; + } + + /** + * @type {Boolean} + */ + get wasClean() { + return this[kWasClean]; + } +} + +Object.defineProperty(CloseEvent.prototype, 'code', { enumerable: true }); +Object.defineProperty(CloseEvent.prototype, 'reason', { enumerable: true }); +Object.defineProperty(CloseEvent.prototype, 'wasClean', { enumerable: true }); + +/** + * Class representing an error event. + * + * @extends Event + */ +class ErrorEvent extends Event$1 { + /** + * Create a new `ErrorEvent`. + * + * @param {String} type The name of the event + * @param {Object} [options] A dictionary object that allows for setting + * attributes via object members of the same name + * @param {*} [options.error=null] The error that generated this event + * @param {String} [options.message=''] The error message + */ + constructor(type, options = {}) { + super(type); + + this[kError] = options.error === undefined ? null : options.error; + this[kMessage] = options.message === undefined ? '' : options.message; + } + + /** + * @type {*} + */ + get error() { + return this[kError]; + } + + /** + * @type {String} + */ + get message() { + return this[kMessage]; + } +} + +Object.defineProperty(ErrorEvent.prototype, 'error', { enumerable: true }); +Object.defineProperty(ErrorEvent.prototype, 'message', { enumerable: true }); + +/** + * Class representing a message event. + * + * @extends Event + */ +class MessageEvent extends Event$1 { + /** + * Create a new `MessageEvent`. + * + * @param {String} type The name of the event + * @param {Object} [options] A dictionary object that allows for setting + * attributes via object members of the same name + * @param {*} [options.data=null] The message content + */ + constructor(type, options = {}) { + super(type); + + this[kData] = options.data === undefined ? null : options.data; + } + + /** + * @type {*} + */ + get data() { + return this[kData]; + } +} + +Object.defineProperty(MessageEvent.prototype, 'data', { enumerable: true }); + +/** + * This provides methods for emulating the `EventTarget` interface. It's not + * meant to be used directly. + * + * @mixin + */ +const EventTarget$1 = { + /** + * Register an event listener. + * + * @param {String} type A string representing the event type to listen for + * @param {Function} listener The listener to add + * @param {Object} [options] An options object specifies characteristics about + * the event listener + * @param {Boolean} [options.once=false] A `Boolean` indicating that the + * listener should be invoked at most once after being added. If `true`, + * the listener would be automatically removed when invoked. + * @public + */ + addEventListener(type, listener, options = {}) { + let wrapper; + + if (type === 'message') { + wrapper = function onMessage(data, isBinary) { + const event = new MessageEvent('message', { + data: isBinary ? data : data.toString() + }); + + event[kTarget] = this; + listener.call(this, event); + }; + } else if (type === 'close') { + wrapper = function onClose(code, message) { + const event = new CloseEvent('close', { + code, + reason: message.toString(), + wasClean: this._closeFrameReceived && this._closeFrameSent + }); + + event[kTarget] = this; + listener.call(this, event); + }; + } else if (type === 'error') { + wrapper = function onError(error) { + const event = new ErrorEvent('error', { + error, + message: error.message + }); + + event[kTarget] = this; + listener.call(this, event); + }; + } else if (type === 'open') { + wrapper = function onOpen() { + const event = new Event$1('open'); + + event[kTarget] = this; + listener.call(this, event); + }; + } else { + return; + } + + wrapper[kForOnEventAttribute$1] = !!options[kForOnEventAttribute$1]; + wrapper[kListener$1] = listener; + + if (options.once) { + this.once(type, wrapper); + } else { + this.on(type, wrapper); + } + }, + + /** + * Remove an event listener. + * + * @param {String} type A string representing the event type to remove + * @param {Function} handler The listener to remove + * @public + */ + removeEventListener(type, handler) { + for (const listener of this.listeners(type)) { + if (listener[kListener$1] === handler && !listener[kForOnEventAttribute$1]) { + this.removeListener(type, listener); + break; + } + } + } +}; + +var eventTarget = { + CloseEvent, + ErrorEvent, + Event: Event$1, + EventTarget: EventTarget$1, + MessageEvent +}; + +const { tokenChars } = validationExports; + +/** + * Adds an offer to the map of extension offers or a parameter to the map of + * parameters. + * + * @param {Object} dest The map of extension offers or parameters + * @param {String} name The extension or parameter name + * @param {(Object|Boolean|String)} elem The extension parameters or the + * parameter value + * @private + */ +function push(dest, name, elem) { + if (dest[name] === undefined) dest[name] = [elem]; + else dest[name].push(elem); +} + +/** + * Parses the `Sec-WebSocket-Extensions` header into an object. + * + * @param {String} header The field value of the header + * @return {Object} The parsed object + * @public + */ +function parse$1(header) { + const offers = Object.create(null); + let params = Object.create(null); + let mustUnescape = false; + let isEscaping = false; + let inQuotes = false; + let extensionName; + let paramName; + let start = -1; + let code = -1; + let end = -1; + let i = 0; + + for (; i < header.length; i++) { + code = header.charCodeAt(i); + + if (extensionName === undefined) { + if (end === -1 && tokenChars[code] === 1) { + if (start === -1) start = i; + } else if ( + i !== 0 && + (code === 0x20 /* ' ' */ || code === 0x09) /* '\t' */ + ) { + if (end === -1 && start !== -1) end = i; + } else if (code === 0x3b /* ';' */ || code === 0x2c /* ',' */) { + if (start === -1) { + throw new SyntaxError(`Unexpected character at index ${i}`); + } + + if (end === -1) end = i; + const name = header.slice(start, end); + if (code === 0x2c) { + push(offers, name, params); + params = Object.create(null); + } else { + extensionName = name; + } + + start = end = -1; + } else { + throw new SyntaxError(`Unexpected character at index ${i}`); + } + } else if (paramName === undefined) { + if (end === -1 && tokenChars[code] === 1) { + if (start === -1) start = i; + } else if (code === 0x20 || code === 0x09) { + if (end === -1 && start !== -1) end = i; + } else if (code === 0x3b || code === 0x2c) { + if (start === -1) { + throw new SyntaxError(`Unexpected character at index ${i}`); + } + + if (end === -1) end = i; + push(params, header.slice(start, end), true); + if (code === 0x2c) { + push(offers, extensionName, params); + params = Object.create(null); + extensionName = undefined; + } + + start = end = -1; + } else if (code === 0x3d /* '=' */ && start !== -1 && end === -1) { + paramName = header.slice(start, i); + start = end = -1; + } else { + throw new SyntaxError(`Unexpected character at index ${i}`); + } + } else { + // + // The value of a quoted-string after unescaping must conform to the + // token ABNF, so only token characters are valid. + // Ref: https://tools.ietf.org/html/rfc6455#section-9.1 + // + if (isEscaping) { + if (tokenChars[code] !== 1) { + throw new SyntaxError(`Unexpected character at index ${i}`); + } + if (start === -1) start = i; + else if (!mustUnescape) mustUnescape = true; + isEscaping = false; + } else if (inQuotes) { + if (tokenChars[code] === 1) { + if (start === -1) start = i; + } else if (code === 0x22 /* '"' */ && start !== -1) { + inQuotes = false; + end = i; + } else if (code === 0x5c /* '\' */) { + isEscaping = true; + } else { + throw new SyntaxError(`Unexpected character at index ${i}`); + } + } else if (code === 0x22 && header.charCodeAt(i - 1) === 0x3d) { + inQuotes = true; + } else if (end === -1 && tokenChars[code] === 1) { + if (start === -1) start = i; + } else if (start !== -1 && (code === 0x20 || code === 0x09)) { + if (end === -1) end = i; + } else if (code === 0x3b || code === 0x2c) { + if (start === -1) { + throw new SyntaxError(`Unexpected character at index ${i}`); + } + + if (end === -1) end = i; + let value = header.slice(start, end); + if (mustUnescape) { + value = value.replace(/\\/g, ''); + mustUnescape = false; + } + push(params, paramName, value); + if (code === 0x2c) { + push(offers, extensionName, params); + params = Object.create(null); + extensionName = undefined; + } + + paramName = undefined; + start = end = -1; + } else { + throw new SyntaxError(`Unexpected character at index ${i}`); + } + } + } + + if (start === -1 || inQuotes || code === 0x20 || code === 0x09) { + throw new SyntaxError('Unexpected end of input'); + } + + if (end === -1) end = i; + const token = header.slice(start, end); + if (extensionName === undefined) { + push(offers, token, params); + } else { + if (paramName === undefined) { + push(params, token, true); + } else if (mustUnescape) { + push(params, paramName, token.replace(/\\/g, '')); + } else { + push(params, paramName, token); + } + push(offers, extensionName, params); + } + + return offers; +} + +/** + * Builds the `Sec-WebSocket-Extensions` header field value. + * + * @param {Object} extensions The map of extensions and parameters to format + * @return {String} A string representing the given object + * @public + */ +function format$4(extensions) { + return Object.keys(extensions) + .map((extension) => { + let configurations = extensions[extension]; + if (!Array.isArray(configurations)) configurations = [configurations]; + return configurations + .map((params) => { + return [extension] + .concat( + Object.keys(params).map((k) => { + let values = params[k]; + if (!Array.isArray(values)) values = [values]; + return values + .map((v) => (v === true ? k : `${k}=${v}`)) + .join('; '); + }) + ) + .join('; '); + }) + .join(', '); + }) + .join(', '); +} + +var extension = { format: format$4, parse: parse$1 }; + +/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Readable$" }] */ + +const EventEmitter = require$$0$3; +const https$1 = https$2; +const http$1 = http$2; +const net$4 = require$$0$4; +const tls$3 = require$$1$3; +const { randomBytes, createHash } = require$$5; +const { URL: URL$3 } = Url; + +const PerMessageDeflate = permessageDeflate; +const Receiver = receiver; +const Sender = sender; +const { + BINARY_TYPES, + EMPTY_BUFFER, + GUID, + kForOnEventAttribute, + kListener, + kStatusCode, + kWebSocket, + NOOP +} = constants$4; +const { + EventTarget: { addEventListener, removeEventListener } +} = eventTarget; +const { format: format$3, parse } = extension; +const { toBuffer: toBuffer$2 } = bufferUtilExports; + +const readyStates = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED']; +const subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/; +const protocolVersions = [8, 13]; +const closeTimeout = 30 * 1000; + +/** + * Class representing a WebSocket. + * + * @extends EventEmitter + */ +class WebSocket extends EventEmitter { + /** + * Create a new `WebSocket`. + * + * @param {(String|URL)} address The URL to which to connect + * @param {(String|String[])} [protocols] The subprotocols + * @param {Object} [options] Connection options + */ + constructor(address, protocols, options) { + super(); + + this._binaryType = BINARY_TYPES[0]; + this._closeCode = 1006; + this._closeFrameReceived = false; + this._closeFrameSent = false; + this._closeMessage = EMPTY_BUFFER; + this._closeTimer = null; + this._extensions = {}; + this._paused = false; + this._protocol = ''; + this._readyState = WebSocket.CONNECTING; + this._receiver = null; + this._sender = null; + this._socket = null; + + if (address !== null) { + this._bufferedAmount = 0; + this._isServer = false; + this._redirects = 0; + + if (protocols === undefined) { + protocols = []; + } else if (!Array.isArray(protocols)) { + if (typeof protocols === 'object' && protocols !== null) { + options = protocols; + protocols = []; + } else { + protocols = [protocols]; + } + } + + initAsClient(this, address, protocols, options); + } else { + this._isServer = true; + } + } + + /** + * This deviates from the WHATWG interface since ws doesn't support the + * required default "blob" type (instead we define a custom "nodebuffer" + * type). + * + * @type {String} + */ + get binaryType() { + return this._binaryType; + } + + set binaryType(type) { + if (!BINARY_TYPES.includes(type)) return; + + this._binaryType = type; + + // + // Allow to change `binaryType` on the fly. + // + if (this._receiver) this._receiver._binaryType = type; + } + + /** + * @type {Number} + */ + get bufferedAmount() { + if (!this._socket) return this._bufferedAmount; + + return this._socket._writableState.length + this._sender._bufferedBytes; + } + + /** + * @type {String} + */ + get extensions() { + return Object.keys(this._extensions).join(); + } + + /** + * @type {Boolean} + */ + get isPaused() { + return this._paused; + } + + /** + * @type {Function} + */ + /* istanbul ignore next */ + get onclose() { + return null; + } + + /** + * @type {Function} + */ + /* istanbul ignore next */ + get onerror() { + return null; + } + + /** + * @type {Function} + */ + /* istanbul ignore next */ + get onopen() { + return null; + } + + /** + * @type {Function} + */ + /* istanbul ignore next */ + get onmessage() { + return null; + } + + /** + * @type {String} + */ + get protocol() { + return this._protocol; + } + + /** + * @type {Number} + */ + get readyState() { + return this._readyState; + } + + /** + * @type {String} + */ + get url() { + return this._url; + } + + /** + * Set up the socket and the internal resources. + * + * @param {(net.Socket|tls.Socket)} socket The network socket between the + * server and client + * @param {Buffer} head The first packet of the upgraded stream + * @param {Object} options Options object + * @param {Function} [options.generateMask] The function used to generate the + * masking key + * @param {Number} [options.maxPayload=0] The maximum allowed message size + * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or + * not to skip UTF-8 validation for text and close messages + * @private + */ + setSocket(socket, head, options) { + const receiver = new Receiver({ + binaryType: this.binaryType, + extensions: this._extensions, + isServer: this._isServer, + maxPayload: options.maxPayload, + skipUTF8Validation: options.skipUTF8Validation + }); + + this._sender = new Sender(socket, this._extensions, options.generateMask); + this._receiver = receiver; + this._socket = socket; + + receiver[kWebSocket] = this; + socket[kWebSocket] = this; + + receiver.on('conclude', receiverOnConclude); + receiver.on('drain', receiverOnDrain); + receiver.on('error', receiverOnError); + receiver.on('message', receiverOnMessage); + receiver.on('ping', receiverOnPing); + receiver.on('pong', receiverOnPong); + + socket.setTimeout(0); + socket.setNoDelay(); + + if (head.length > 0) socket.unshift(head); + + socket.on('close', socketOnClose); + socket.on('data', socketOnData); + socket.on('end', socketOnEnd); + socket.on('error', socketOnError); + + this._readyState = WebSocket.OPEN; + this.emit('open'); + } + + /** + * Emit the `'close'` event. + * + * @private + */ + emitClose() { + if (!this._socket) { + this._readyState = WebSocket.CLOSED; + this.emit('close', this._closeCode, this._closeMessage); + return; + } + + if (this._extensions[PerMessageDeflate.extensionName]) { + this._extensions[PerMessageDeflate.extensionName].cleanup(); + } + + this._receiver.removeAllListeners(); + this._readyState = WebSocket.CLOSED; + this.emit('close', this._closeCode, this._closeMessage); + } + + /** + * Start a closing handshake. + * + * +----------+ +-----------+ +----------+ + * - - -|ws.close()|-->|close frame|-->|ws.close()|- - - + * | +----------+ +-----------+ +----------+ | + * +----------+ +-----------+ | + * CLOSING |ws.close()|<--|close frame|<--+-----+ CLOSING + * +----------+ +-----------+ | + * | | | +---+ | + * +------------------------+-->|fin| - - - - + * | +---+ | +---+ + * - - - - -|fin|<---------------------+ + * +---+ + * + * @param {Number} [code] Status code explaining why the connection is closing + * @param {(String|Buffer)} [data] The reason why the connection is + * closing + * @public + */ + close(code, data) { + if (this.readyState === WebSocket.CLOSED) return; + if (this.readyState === WebSocket.CONNECTING) { + const msg = 'WebSocket was closed before the connection was established'; + return abortHandshake(this, this._req, msg); + } + + if (this.readyState === WebSocket.CLOSING) { + if ( + this._closeFrameSent && + (this._closeFrameReceived || this._receiver._writableState.errorEmitted) + ) { + this._socket.end(); + } + + return; + } + + this._readyState = WebSocket.CLOSING; + this._sender.close(code, data, !this._isServer, (err) => { + // + // This error is handled by the `'error'` listener on the socket. We only + // want to know if the close frame has been sent here. + // + if (err) return; + + this._closeFrameSent = true; + + if ( + this._closeFrameReceived || + this._receiver._writableState.errorEmitted + ) { + this._socket.end(); + } + }); + + // + // Specify a timeout for the closing handshake to complete. + // + this._closeTimer = setTimeout( + this._socket.destroy.bind(this._socket), + closeTimeout + ); + } + + /** + * Pause the socket. + * + * @public + */ + pause() { + if ( + this.readyState === WebSocket.CONNECTING || + this.readyState === WebSocket.CLOSED + ) { + return; + } + + this._paused = true; + this._socket.pause(); + } + + /** + * Send a ping. + * + * @param {*} [data] The data to send + * @param {Boolean} [mask] Indicates whether or not to mask `data` + * @param {Function} [cb] Callback which is executed when the ping is sent + * @public + */ + ping(data, mask, cb) { + if (this.readyState === WebSocket.CONNECTING) { + throw new Error('WebSocket is not open: readyState 0 (CONNECTING)'); + } + + if (typeof data === 'function') { + cb = data; + data = mask = undefined; + } else if (typeof mask === 'function') { + cb = mask; + mask = undefined; + } + + if (typeof data === 'number') data = data.toString(); + + if (this.readyState !== WebSocket.OPEN) { + sendAfterClose(this, data, cb); + return; + } + + if (mask === undefined) mask = !this._isServer; + this._sender.ping(data || EMPTY_BUFFER, mask, cb); + } + + /** + * Send a pong. + * + * @param {*} [data] The data to send + * @param {Boolean} [mask] Indicates whether or not to mask `data` + * @param {Function} [cb] Callback which is executed when the pong is sent + * @public + */ + pong(data, mask, cb) { + if (this.readyState === WebSocket.CONNECTING) { + throw new Error('WebSocket is not open: readyState 0 (CONNECTING)'); + } + + if (typeof data === 'function') { + cb = data; + data = mask = undefined; + } else if (typeof mask === 'function') { + cb = mask; + mask = undefined; + } + + if (typeof data === 'number') data = data.toString(); + + if (this.readyState !== WebSocket.OPEN) { + sendAfterClose(this, data, cb); + return; + } + + if (mask === undefined) mask = !this._isServer; + this._sender.pong(data || EMPTY_BUFFER, mask, cb); + } + + /** + * Resume the socket. + * + * @public + */ + resume() { + if ( + this.readyState === WebSocket.CONNECTING || + this.readyState === WebSocket.CLOSED + ) { + return; + } + + this._paused = false; + if (!this._receiver._writableState.needDrain) this._socket.resume(); + } + + /** + * Send a data message. + * + * @param {*} data The message to send + * @param {Object} [options] Options object + * @param {Boolean} [options.binary] Specifies whether `data` is binary or + * text + * @param {Boolean} [options.compress] Specifies whether or not to compress + * `data` + * @param {Boolean} [options.fin=true] Specifies whether the fragment is the + * last one + * @param {Boolean} [options.mask] Specifies whether or not to mask `data` + * @param {Function} [cb] Callback which is executed when data is written out + * @public + */ + send(data, options, cb) { + if (this.readyState === WebSocket.CONNECTING) { + throw new Error('WebSocket is not open: readyState 0 (CONNECTING)'); + } + + if (typeof options === 'function') { + cb = options; + options = {}; + } + + if (typeof data === 'number') data = data.toString(); + + if (this.readyState !== WebSocket.OPEN) { + sendAfterClose(this, data, cb); + return; + } + + const opts = { + binary: typeof data !== 'string', + mask: !this._isServer, + compress: true, + fin: true, + ...options + }; + + if (!this._extensions[PerMessageDeflate.extensionName]) { + opts.compress = false; + } + + this._sender.send(data || EMPTY_BUFFER, opts, cb); + } + + /** + * Forcibly close the connection. + * + * @public + */ + terminate() { + if (this.readyState === WebSocket.CLOSED) return; + if (this.readyState === WebSocket.CONNECTING) { + const msg = 'WebSocket was closed before the connection was established'; + return abortHandshake(this, this._req, msg); + } + + if (this._socket) { + this._readyState = WebSocket.CLOSING; + this._socket.destroy(); + } + } +} + +/** + * @constant {Number} CONNECTING + * @memberof WebSocket + */ +Object.defineProperty(WebSocket, 'CONNECTING', { + enumerable: true, + value: readyStates.indexOf('CONNECTING') +}); + +/** + * @constant {Number} CONNECTING + * @memberof WebSocket.prototype + */ +Object.defineProperty(WebSocket.prototype, 'CONNECTING', { + enumerable: true, + value: readyStates.indexOf('CONNECTING') +}); + +/** + * @constant {Number} OPEN + * @memberof WebSocket + */ +Object.defineProperty(WebSocket, 'OPEN', { + enumerable: true, + value: readyStates.indexOf('OPEN') +}); + +/** + * @constant {Number} OPEN + * @memberof WebSocket.prototype + */ +Object.defineProperty(WebSocket.prototype, 'OPEN', { + enumerable: true, + value: readyStates.indexOf('OPEN') +}); + +/** + * @constant {Number} CLOSING + * @memberof WebSocket + */ +Object.defineProperty(WebSocket, 'CLOSING', { + enumerable: true, + value: readyStates.indexOf('CLOSING') +}); + +/** + * @constant {Number} CLOSING + * @memberof WebSocket.prototype + */ +Object.defineProperty(WebSocket.prototype, 'CLOSING', { + enumerable: true, + value: readyStates.indexOf('CLOSING') +}); + +/** + * @constant {Number} CLOSED + * @memberof WebSocket + */ +Object.defineProperty(WebSocket, 'CLOSED', { + enumerable: true, + value: readyStates.indexOf('CLOSED') +}); + +/** + * @constant {Number} CLOSED + * @memberof WebSocket.prototype + */ +Object.defineProperty(WebSocket.prototype, 'CLOSED', { + enumerable: true, + value: readyStates.indexOf('CLOSED') +}); + +[ + 'binaryType', + 'bufferedAmount', + 'extensions', + 'isPaused', + 'protocol', + 'readyState', + 'url' +].forEach((property) => { + Object.defineProperty(WebSocket.prototype, property, { enumerable: true }); +}); + +// +// Add the `onopen`, `onerror`, `onclose`, and `onmessage` attributes. +// See https://html.spec.whatwg.org/multipage/comms.html#the-websocket-interface +// +['open', 'error', 'close', 'message'].forEach((method) => { + Object.defineProperty(WebSocket.prototype, `on${method}`, { + enumerable: true, + get() { + for (const listener of this.listeners(method)) { + if (listener[kForOnEventAttribute]) return listener[kListener]; + } + + return null; + }, + set(handler) { + for (const listener of this.listeners(method)) { + if (listener[kForOnEventAttribute]) { + this.removeListener(method, listener); + break; + } + } + + if (typeof handler !== 'function') return; + + this.addEventListener(method, handler, { + [kForOnEventAttribute]: true + }); + } + }); +}); + +WebSocket.prototype.addEventListener = addEventListener; +WebSocket.prototype.removeEventListener = removeEventListener; + +/** + * Initialize a WebSocket client. + * + * @param {WebSocket} websocket The client to initialize + * @param {(String|URL)} address The URL to which to connect + * @param {Array} protocols The subprotocols + * @param {Object} [options] Connection options + * @param {Boolean} [options.followRedirects=false] Whether or not to follow + * redirects + * @param {Function} [options.generateMask] The function used to generate the + * masking key + * @param {Number} [options.handshakeTimeout] Timeout in milliseconds for the + * handshake request + * @param {Number} [options.maxPayload=104857600] The maximum allowed message + * size + * @param {Number} [options.maxRedirects=10] The maximum number of redirects + * allowed + * @param {String} [options.origin] Value of the `Origin` or + * `Sec-WebSocket-Origin` header + * @param {(Boolean|Object)} [options.perMessageDeflate=true] Enable/disable + * permessage-deflate + * @param {Number} [options.protocolVersion=13] Value of the + * `Sec-WebSocket-Version` header + * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or + * not to skip UTF-8 validation for text and close messages + * @private + */ +function initAsClient(websocket, address, protocols, options) { + const opts = { + protocolVersion: protocolVersions[1], + maxPayload: 100 * 1024 * 1024, + skipUTF8Validation: false, + perMessageDeflate: true, + followRedirects: false, + maxRedirects: 10, + ...options, + createConnection: undefined, + socketPath: undefined, + hostname: undefined, + protocol: undefined, + timeout: undefined, + method: undefined, + host: undefined, + path: undefined, + port: undefined + }; + + if (!protocolVersions.includes(opts.protocolVersion)) { + throw new RangeError( + `Unsupported protocol version: ${opts.protocolVersion} ` + + `(supported versions: ${protocolVersions.join(', ')})` + ); + } + + let parsedUrl; + + if (address instanceof URL$3) { + parsedUrl = address; + websocket._url = address.href; + } else { + try { + parsedUrl = new URL$3(address); + } catch (e) { + throw new SyntaxError(`Invalid URL: ${address}`); + } + + websocket._url = address; + } + + const isSecure = parsedUrl.protocol === 'wss:'; + const isUnixSocket = parsedUrl.protocol === 'ws+unix:'; + let invalidURLMessage; + + if (parsedUrl.protocol !== 'ws:' && !isSecure && !isUnixSocket) { + invalidURLMessage = + 'The URL\'s protocol must be one of "ws:", "wss:", or "ws+unix:"'; + } else if (isUnixSocket && !parsedUrl.pathname) { + invalidURLMessage = "The URL's pathname is empty"; + } else if (parsedUrl.hash) { + invalidURLMessage = 'The URL contains a fragment identifier'; + } + + if (invalidURLMessage) { + const err = new SyntaxError(invalidURLMessage); + + if (websocket._redirects === 0) { + throw err; + } else { + emitErrorAndClose(websocket, err); + return; + } + } + + const defaultPort = isSecure ? 443 : 80; + const key = randomBytes(16).toString('base64'); + const get = isSecure ? https$1.get : http$1.get; + const protocolSet = new Set(); + let perMessageDeflate; + + opts.createConnection = isSecure ? tlsConnect : netConnect; + opts.defaultPort = opts.defaultPort || defaultPort; + opts.port = parsedUrl.port || defaultPort; + opts.host = parsedUrl.hostname.startsWith('[') + ? parsedUrl.hostname.slice(1, -1) + : parsedUrl.hostname; + opts.headers = { + 'Sec-WebSocket-Version': opts.protocolVersion, + 'Sec-WebSocket-Key': key, + Connection: 'Upgrade', + Upgrade: 'websocket', + ...opts.headers + }; + opts.path = parsedUrl.pathname + parsedUrl.search; + opts.timeout = opts.handshakeTimeout; + + if (opts.perMessageDeflate) { + perMessageDeflate = new PerMessageDeflate( + opts.perMessageDeflate !== true ? opts.perMessageDeflate : {}, + false, + opts.maxPayload + ); + opts.headers['Sec-WebSocket-Extensions'] = format$3({ + [PerMessageDeflate.extensionName]: perMessageDeflate.offer() + }); + } + if (protocols.length) { + for (const protocol of protocols) { + if ( + typeof protocol !== 'string' || + !subprotocolRegex.test(protocol) || + protocolSet.has(protocol) + ) { + throw new SyntaxError( + 'An invalid or duplicated subprotocol was specified' + ); + } + + protocolSet.add(protocol); + } + + opts.headers['Sec-WebSocket-Protocol'] = protocols.join(','); + } + if (opts.origin) { + if (opts.protocolVersion < 13) { + opts.headers['Sec-WebSocket-Origin'] = opts.origin; + } else { + opts.headers.Origin = opts.origin; + } + } + if (parsedUrl.username || parsedUrl.password) { + opts.auth = `${parsedUrl.username}:${parsedUrl.password}`; + } + + if (isUnixSocket) { + const parts = opts.path.split(':'); + + opts.socketPath = parts[0]; + opts.path = parts[1]; + } + + if (opts.followRedirects) { + if (websocket._redirects === 0) { + websocket._originalHost = parsedUrl.host; + + const headers = options && options.headers; + + // + // Shallow copy the user provided options so that headers can be changed + // without mutating the original object. + // + options = { ...options, headers: {} }; + + if (headers) { + for (const [key, value] of Object.entries(headers)) { + options.headers[key.toLowerCase()] = value; + } + } + } else if (parsedUrl.host !== websocket._originalHost) { + // + // Match curl 7.77.0 behavior and drop the following headers. These + // headers are also dropped when following a redirect to a subdomain. + // + delete opts.headers.authorization; + delete opts.headers.cookie; + delete opts.headers.host; + opts.auth = undefined; + } + + // + // Match curl 7.77.0 behavior and make the first `Authorization` header win. + // If the `Authorization` header is set, then there is nothing to do as it + // will take precedence. + // + if (opts.auth && !options.headers.authorization) { + options.headers.authorization = + 'Basic ' + Buffer.from(opts.auth).toString('base64'); + } + } + + let req = (websocket._req = get(opts)); + + if (opts.timeout) { + req.on('timeout', () => { + abortHandshake(websocket, req, 'Opening handshake has timed out'); + }); + } + + req.on('error', (err) => { + if (req === null || req.aborted) return; + + req = websocket._req = null; + emitErrorAndClose(websocket, err); + }); + + req.on('response', (res) => { + const location = res.headers.location; + const statusCode = res.statusCode; + + if ( + location && + opts.followRedirects && + statusCode >= 300 && + statusCode < 400 + ) { + if (++websocket._redirects > opts.maxRedirects) { + abortHandshake(websocket, req, 'Maximum redirects exceeded'); + return; + } + + req.abort(); + + let addr; + + try { + addr = new URL$3(location, address); + } catch (e) { + const err = new SyntaxError(`Invalid URL: ${location}`); + emitErrorAndClose(websocket, err); + return; + } + + initAsClient(websocket, addr, protocols, options); + } else if (!websocket.emit('unexpected-response', req, res)) { + abortHandshake( + websocket, + req, + `Unexpected server response: ${res.statusCode}` + ); + } + }); + + req.on('upgrade', (res, socket, head) => { + websocket.emit('upgrade', res); + + // + // The user may have closed the connection from a listener of the `upgrade` + // event. + // + if (websocket.readyState !== WebSocket.CONNECTING) return; + + req = websocket._req = null; + + const digest = createHash('sha1') + .update(key + GUID) + .digest('base64'); + + if (res.headers['sec-websocket-accept'] !== digest) { + abortHandshake(websocket, socket, 'Invalid Sec-WebSocket-Accept header'); + return; + } + + const serverProt = res.headers['sec-websocket-protocol']; + let protError; + + if (serverProt !== undefined) { + if (!protocolSet.size) { + protError = 'Server sent a subprotocol but none was requested'; + } else if (!protocolSet.has(serverProt)) { + protError = 'Server sent an invalid subprotocol'; + } + } else if (protocolSet.size) { + protError = 'Server sent no subprotocol'; + } + + if (protError) { + abortHandshake(websocket, socket, protError); + return; + } + + if (serverProt) websocket._protocol = serverProt; + + const secWebSocketExtensions = res.headers['sec-websocket-extensions']; + + if (secWebSocketExtensions !== undefined) { + if (!perMessageDeflate) { + const message = + 'Server sent a Sec-WebSocket-Extensions header but no extension ' + + 'was requested'; + abortHandshake(websocket, socket, message); + return; + } + + let extensions; + + try { + extensions = parse(secWebSocketExtensions); + } catch (err) { + const message = 'Invalid Sec-WebSocket-Extensions header'; + abortHandshake(websocket, socket, message); + return; + } + + const extensionNames = Object.keys(extensions); + + if ( + extensionNames.length !== 1 || + extensionNames[0] !== PerMessageDeflate.extensionName + ) { + const message = 'Server indicated an extension that was not requested'; + abortHandshake(websocket, socket, message); + return; + } + + try { + perMessageDeflate.accept(extensions[PerMessageDeflate.extensionName]); + } catch (err) { + const message = 'Invalid Sec-WebSocket-Extensions header'; + abortHandshake(websocket, socket, message); + return; + } + + websocket._extensions[PerMessageDeflate.extensionName] = + perMessageDeflate; + } + + websocket.setSocket(socket, head, { + generateMask: opts.generateMask, + maxPayload: opts.maxPayload, + skipUTF8Validation: opts.skipUTF8Validation + }); + }); +} + +/** + * Emit the `'error'` and `'close'` event. + * + * @param {WebSocket} websocket The WebSocket instance + * @param {Error} The error to emit + * @private + */ +function emitErrorAndClose(websocket, err) { + websocket._readyState = WebSocket.CLOSING; + websocket.emit('error', err); + websocket.emitClose(); +} + +/** + * Create a `net.Socket` and initiate a connection. + * + * @param {Object} options Connection options + * @return {net.Socket} The newly created socket used to start the connection + * @private + */ +function netConnect(options) { + options.path = options.socketPath; + return net$4.connect(options); +} + +/** + * Create a `tls.TLSSocket` and initiate a connection. + * + * @param {Object} options Connection options + * @return {tls.TLSSocket} The newly created socket used to start the connection + * @private + */ +function tlsConnect(options) { + options.path = undefined; + + if (!options.servername && options.servername !== '') { + options.servername = net$4.isIP(options.host) ? '' : options.host; + } + + return tls$3.connect(options); +} + +/** + * Abort the handshake and emit an error. + * + * @param {WebSocket} websocket The WebSocket instance + * @param {(http.ClientRequest|net.Socket|tls.Socket)} stream The request to + * abort or the socket to destroy + * @param {String} message The error message + * @private + */ +function abortHandshake(websocket, stream, message) { + websocket._readyState = WebSocket.CLOSING; + + const err = new Error(message); + Error.captureStackTrace(err, abortHandshake); + + if (stream.setHeader) { + stream.abort(); + + if (stream.socket && !stream.socket.destroyed) { + // + // On Node.js >= 14.3.0 `request.abort()` does not destroy the socket if + // called after the request completed. See + // https://github.com/websockets/ws/issues/1869. + // + stream.socket.destroy(); + } + + stream.once('abort', websocket.emitClose.bind(websocket)); + websocket.emit('error', err); + } else { + stream.destroy(err); + stream.once('error', websocket.emit.bind(websocket, 'error')); + stream.once('close', websocket.emitClose.bind(websocket)); + } +} + +/** + * Handle cases where the `ping()`, `pong()`, or `send()` methods are called + * when the `readyState` attribute is `CLOSING` or `CLOSED`. + * + * @param {WebSocket} websocket The WebSocket instance + * @param {*} [data] The data to send + * @param {Function} [cb] Callback + * @private + */ +function sendAfterClose(websocket, data, cb) { + if (data) { + const length = toBuffer$2(data).length; + + // + // The `_bufferedAmount` property is used only when the peer is a client and + // the opening handshake fails. Under these circumstances, in fact, the + // `setSocket()` method is not called, so the `_socket` and `_sender` + // properties are set to `null`. + // + if (websocket._socket) websocket._sender._bufferedBytes += length; + else websocket._bufferedAmount += length; + } + + if (cb) { + const err = new Error( + `WebSocket is not open: readyState ${websocket.readyState} ` + + `(${readyStates[websocket.readyState]})` + ); + cb(err); + } +} + +/** + * The listener of the `Receiver` `'conclude'` event. + * + * @param {Number} code The status code + * @param {Buffer} reason The reason for closing + * @private + */ +function receiverOnConclude(code, reason) { + const websocket = this[kWebSocket]; + + websocket._closeFrameReceived = true; + websocket._closeMessage = reason; + websocket._closeCode = code; + + if (websocket._socket[kWebSocket] === undefined) return; + + websocket._socket.removeListener('data', socketOnData); + process.nextTick(resume$1, websocket._socket); + + if (code === 1005) websocket.close(); + else websocket.close(code, reason); +} + +/** + * The listener of the `Receiver` `'drain'` event. + * + * @private + */ +function receiverOnDrain() { + const websocket = this[kWebSocket]; + + if (!websocket.isPaused) websocket._socket.resume(); +} + +/** + * The listener of the `Receiver` `'error'` event. + * + * @param {(RangeError|Error)} err The emitted error + * @private + */ +function receiverOnError(err) { + const websocket = this[kWebSocket]; + + if (websocket._socket[kWebSocket] !== undefined) { + websocket._socket.removeListener('data', socketOnData); + + // + // On Node.js < 14.0.0 the `'error'` event is emitted synchronously. See + // https://github.com/websockets/ws/issues/1940. + // + process.nextTick(resume$1, websocket._socket); + + websocket.close(err[kStatusCode]); + } + + websocket.emit('error', err); +} + +/** + * The listener of the `Receiver` `'finish'` event. + * + * @private + */ +function receiverOnFinish() { + this[kWebSocket].emitClose(); +} + +/** + * The listener of the `Receiver` `'message'` event. + * + * @param {Buffer|ArrayBuffer|Buffer[])} data The message + * @param {Boolean} isBinary Specifies whether the message is binary or not + * @private + */ +function receiverOnMessage(data, isBinary) { + this[kWebSocket].emit('message', data, isBinary); +} + +/** + * The listener of the `Receiver` `'ping'` event. + * + * @param {Buffer} data The data included in the ping frame + * @private + */ +function receiverOnPing(data) { + const websocket = this[kWebSocket]; + + websocket.pong(data, !websocket._isServer, NOOP); + websocket.emit('ping', data); +} + +/** + * The listener of the `Receiver` `'pong'` event. + * + * @param {Buffer} data The data included in the pong frame + * @private + */ +function receiverOnPong(data) { + this[kWebSocket].emit('pong', data); +} + +/** + * Resume a readable stream + * + * @param {Readable} stream The readable stream + * @private + */ +function resume$1(stream) { + stream.resume(); +} + +/** + * The listener of the `net.Socket` `'close'` event. + * + * @private + */ +function socketOnClose() { + const websocket = this[kWebSocket]; + + this.removeListener('close', socketOnClose); + this.removeListener('data', socketOnData); + this.removeListener('end', socketOnEnd); + + websocket._readyState = WebSocket.CLOSING; + + let chunk; + + // + // The close frame might not have been received or the `'end'` event emitted, + // for example, if the socket was destroyed due to an error. Ensure that the + // `receiver` stream is closed after writing any remaining buffered data to + // it. If the readable side of the socket is in flowing mode then there is no + // buffered data as everything has been already written and `readable.read()` + // will return `null`. If instead, the socket is paused, any possible buffered + // data will be read as a single chunk. + // + if ( + !this._readableState.endEmitted && + !websocket._closeFrameReceived && + !websocket._receiver._writableState.errorEmitted && + (chunk = websocket._socket.read()) !== null + ) { + websocket._receiver.write(chunk); + } + + websocket._receiver.end(); + + this[kWebSocket] = undefined; + + clearTimeout(websocket._closeTimer); + + if ( + websocket._receiver._writableState.finished || + websocket._receiver._writableState.errorEmitted + ) { + websocket.emitClose(); + } else { + websocket._receiver.on('error', receiverOnFinish); + websocket._receiver.on('finish', receiverOnFinish); + } +} + +/** + * The listener of the `net.Socket` `'data'` event. + * + * @param {Buffer} chunk A chunk of data + * @private + */ +function socketOnData(chunk) { + if (!this[kWebSocket]._receiver.write(chunk)) { + this.pause(); + } +} + +/** + * The listener of the `net.Socket` `'end'` event. + * + * @private + */ +function socketOnEnd() { + const websocket = this[kWebSocket]; + + websocket._readyState = WebSocket.CLOSING; + websocket._receiver.end(); + this.end(); +} + +/** + * The listener of the `net.Socket` `'error'` event. + * + * @private + */ +function socketOnError() { + const websocket = this[kWebSocket]; + + this.removeListener('error', socketOnError); + this.on('error', NOOP); + + if (websocket) { + websocket._readyState = WebSocket.CLOSING; + this.destroy(); + } +} + +/** + * A **FallbackProvider** provides resilience, security and performance + * in a way that is customizable and configurable. + * + * @_section: api/providers/fallback-provider:Fallback Provider [about-fallback-provider] + */ +BigInt("1"); +BigInt("2"); + +/** + * The **BaseWallet** is a stream-lined implementation of a + * [[Signer]] that operates with a private key. + * + * It is preferred to use the [[Wallet]] class, as it offers + * additional functionality and simplifies loading a variety + * of JSON formats, Mnemonic Phrases, etc. + * + * This class may be of use for those attempting to implement + * a minimal Signer. + */ +class BaseWallet extends AbstractSigner { + /** + * The wallet address. + */ + address; + #signingKey; + /** + * Creates a new BaseWallet for %%privateKey%%, optionally + * connected to %%provider%%. + * + * If %%provider%% is not specified, only offline methods can + * be used. + */ + constructor(privateKey, provider) { + super(provider); + assertArgument(privateKey && typeof (privateKey.sign) === "function", "invalid private key", "privateKey", "[ REDACTED ]"); + this.#signingKey = privateKey; + const address = computeAddress(this.signingKey.publicKey); + defineProperties(this, { address }); + } + // Store private values behind getters to reduce visibility + // in console.log + /** + * The [[SigningKey]] used for signing payloads. + */ + get signingKey() { return this.#signingKey; } + /** + * The private key for this wallet. + */ + get privateKey() { return this.signingKey.privateKey; } + async getAddress() { return this.address; } + connect(provider) { + return new BaseWallet(this.#signingKey, provider); + } + async signTransaction(tx) { + // Replace any Addressable or ENS name with an address + const { to, from } = await resolveProperties({ + to: (tx.to ? resolveAddress(tx.to, this.provider) : undefined), + from: (tx.from ? resolveAddress(tx.from, this.provider) : undefined) + }); + if (to != null) { + tx.to = to; + } + if (from != null) { + tx.from = from; + } + if (tx.from != null) { + assertArgument(getAddress((tx.from)) === this.address, "transaction from address mismatch", "tx.from", tx.from); + delete tx.from; + } + // Build the transaction + const btx = Transaction.from(tx); + btx.signature = this.signingKey.sign(btx.unsignedHash); + return btx.serialized; + } + async signMessage(message) { + return this.signMessageSync(message); + } + // @TODO: Add a secialized signTx and signTyped sync that enforces + // all parameters are known? + /** + * Returns the signature for %%message%% signed with this wallet. + */ + signMessageSync(message) { + return this.signingKey.sign(hashMessage(message)).serialized; + } + async signTypedData(domain, types, value) { + // Populate any ENS names + const populated = await TypedDataEncoder.resolveNames(domain, types, value, async (name) => { + // @TODO: this should use resolveName; addresses don't + // need a provider + assert$5(this.provider != null, "cannot resolve ENS names without a provider", "UNSUPPORTED_OPERATION", { + operation: "resolveName", + info: { name } + }); + const address = await this.provider.resolveName(name); + assert$5(address != null, "unconfigured ENS name", "UNCONFIGURED_NAME", { + value: name + }); + return address; + }); + return this.signingKey.sign(TypedDataEncoder.hash(populated.domain, types, populated.value)).serialized; + } +} + +const subsChrs = " !#$%&'()*+,-./<=>?@[]^_`{|}~"; +const Word = /^[a-z]*$/i; +function unfold(words, sep) { + let initial = 97; + return words.reduce((accum, word) => { + if (word === sep) { + initial++; + } + else if (word.match(Word)) { + accum.push(String.fromCharCode(initial) + word); + } + else { + initial = 97; + accum.push(word); + } + return accum; + }, []); +} +/** + * @_ignore + */ +function decode(data, subs) { + // Replace all the substitutions with their expanded form + for (let i = subsChrs.length - 1; i >= 0; i--) { + data = data.split(subsChrs[i]).join(subs.substring(2 * i, 2 * i + 2)); + } + // Get all tle clumps; each suffix, first-increment and second-increment + const clumps = []; + const leftover = data.replace(/(:|([0-9])|([A-Z][a-z]*))/g, (all, item, semi, word) => { + if (semi) { + for (let i = parseInt(semi); i >= 0; i--) { + clumps.push(";"); + } + } + else { + clumps.push(item.toLowerCase()); + } + return ""; + }); + /* c8 ignore start */ + if (leftover) { + throw new Error(`leftovers: ${JSON.stringify(leftover)}`); + } + /* c8 ignore stop */ + return unfold(unfold(clumps, ";"), ":"); +} +/** + * @_ignore + */ +function decodeOwl(data) { + assertArgument(data[0] === "0", "unsupported auwl data", "data", data); + return decode(data.substring(1 + 2 * subsChrs.length), data.substring(1, 1 + 2 * subsChrs.length)); +} + +/** + * A Wordlist represents a collection of language-specific + * words used to encode and devoce [[link-bip-39]] encoded data + * by mapping words to 11-bit values and vice versa. + */ +class Wordlist { + locale; + /** + * Creates a new Wordlist instance. + * + * Sub-classes MUST call this if they provide their own constructor, + * passing in the locale string of the language. + * + * Generally there is no need to create instances of a Wordlist, + * since each language-specific Wordlist creates an instance and + * there is no state kept internally, so they are safe to share. + */ + constructor(locale) { + defineProperties(this, { locale }); + } + /** + * Sub-classes may override this to provide a language-specific + * method for spliting %%phrase%% into individual words. + * + * By default, %%phrase%% is split using any sequences of + * white-space as defined by regular expressions (i.e. ``/\s+/``). + */ + split(phrase) { + return phrase.toLowerCase().split(/\s+/g); + } + /** + * Sub-classes may override this to provider a language-specific + * method for joining %%words%% into a phrase. + * + * By default, %%words%% are joined by a single space. + */ + join(words) { + return words.join(" "); + } +} + +// Use the encode-latin.js script to create the necessary +// data files to be consumed by this class +/** + * An OWL format Wordlist is an encoding method that exploits + * the general locality of alphabetically sorted words to + * achieve a simple but effective means of compression. + * + * This class is generally not useful to most developers as + * it is used mainly internally to keep Wordlists for languages + * based on ASCII-7 small. + * + * If necessary, there are tools within the ``generation/`` folder + * to create the necessary data. + */ +class WordlistOwl extends Wordlist { + #data; + #checksum; + /** + * Creates a new Wordlist for %%locale%% using the OWL %%data%% + * and validated against the %%checksum%%. + */ + constructor(locale, data, checksum) { + super(locale); + this.#data = data; + this.#checksum = checksum; + this.#words = null; + } + /** + * The OWL-encoded data. + */ + get _data() { return this.#data; } + /** + * Decode all the words for the wordlist. + */ + _decodeWords() { + return decodeOwl(this.#data); + } + #words; + #loadWords() { + if (this.#words == null) { + const words = this._decodeWords(); + // Verify the computed list matches the official list + const checksum = id$1(words.join("\n") + "\n"); + /* c8 ignore start */ + if (checksum !== this.#checksum) { + throw new Error(`BIP39 Wordlist for ${this.locale} FAILED`); + } + /* c8 ignore stop */ + this.#words = words; + } + return this.#words; + } + getWord(index) { + const words = this.#loadWords(); + assertArgument(index >= 0 && index < words.length, `invalid word index: ${index}`, "index", index); + return words[index]; + } + getWordIndex(word) { + return this.#loadWords().indexOf(word); + } +} + +const words$5 = "0erleonalorenseinceregesticitStanvetearctssi#ch2Athck&tneLl0And#Il.yLeOutO=S|S%b/ra@SurdU'0Ce[Cid|CountCu'Hie=IdOu,-Qui*Ro[TT]T%T*[Tu$0AptDD-tD*[Ju,M.UltV<)Vi)0Rob-0FairF%dRaid0A(EEntRee0Ead0MRRp%tS!_rmBumCoholErtI&LLeyLowMo,O}PhaReadySoT Ways0A>urAz(gOngOuntU'd0Aly,Ch%Ci|G G!GryIm$K!Noun)Nu$O` Sw T&naTiqueXietyY1ArtOlogyPe?P!Pro=Ril1ChCt-EaEnaGueMMedM%MyOundR<+Re,Ri=RowTTefa@Ti,Tw%k0KPe@SaultSetSi,SumeThma0H!>OmTa{T&dT.udeTra@0Ct]D.Gu,NtTh%ToTumn0Era+OcadoOid0AkeA*AyEsomeFulKw?d0Is:ByChel%C#D+GL<)Lc#y~MbooN_{Ad!AftAmA}AshAt AwlAzyEamEd.EekEwI{etImeIspIt-OpO[Ou^OwdUci$UelUi'Umb!Un^UshYY,$2BeLtu*PPbo?dRiousRr|Rta(R=Sh]/omTe3C!:DMa+MpN)Ng R(gShUght WnY3AlBa>BrisCadeCemb CideCl(eC%a>C*a'ErF&'F(eFyG*eLayLiv M3AgramAlAm#dAryCeE'lEtFf G.$Gn.yLemmaNn NosaurRe@RtSag*eScov Sea'ShSmi[S%d Splay/<)V tVideV%)Zzy5Ct%Cum|G~Lph(Ma(Na>NkeyN%OrSeUb!Ve_ftAg#AmaA,-AwEamE[IftIllInkIpI=OpUmY2CkMbNeR(g/T^Ty1Arf1Nam-:G G!RlyRnR`Sily/Sy1HoOlogyOnomy0GeItUca>1F%t0G1GhtTh 2BowD E@r-EgSe0B?kBodyBra)Er+Ot]PloyPow Pty0Ab!A@DD![D%'EmyErgyF%)Ga+G(eH<)JoyLi,OughR-hRollSu*T Ti*TryVelope1Isode0U$Uip0AA'OdeOs]R%Upt0CapeSayS&)Ta>0Ern$H-s1Id&)IlOkeOl=1A@Amp!Ce[Ch<+C.eCludeCu'Ecu>Erci'Hau,Hib.I!I,ItOt-PM&'Mu}Pa@Po'Pro=Pul'0ChCludeComeC*a'DexD-a>Do%Du,ryFN Noc|PutQuirySSue0Em1Ory:CketGu?RZz3AlousAns~yWel9BInKeUr}yY5D+I)MpNg!Ni%Nk/:Ng?oo3EnEpT^upY3CkDD}yNdNgdomSsTT^&TeTt&Wi4EeIfeO{Ow:BBelB%Dd DyKeMpNgua+PtopR+T T(UghUndryVaWWnWsu.Y Zy3Ad AfArnA=Ctu*FtGG$G&dIsu*M#NdNg`NsOp?dSs#Tt Vel3ArB tyBr?yC&'FeFtGhtKeMbM.NkOnQuid/Tt!VeZ?d5AdAnB, C$CkG-NelyNgOpTt yUdUn+VeY$5CkyGga+Mb N?N^Xury3R-s:Ch(eDG-G}tIdIlInJ%KeMm$NNa+Nda>NgoNs]Nu$P!Rb!R^Rg(R(eRketRria+SkSs/ T^T i$ThTrixTt XimumZe3AdowAnAsu*AtCh<-D$DiaLodyLtMb M%yNt]NuRcyR+R.RryShSsa+T$Thod3Dd!DnightLk~]M-NdNimumN%Nu>Rac!Rr%S ySs/akeXXedXtu*5Bi!DelDifyMM|N.%NkeyN, N`OnR$ReRn(gSqu.oTh T]T%Unta(U'VeVie5ChFf(LeLtiplySc!SeumShroomS-/Tu$3Self/ yTh:I=MePk(Rrow/yT]Tu*3ArCkEdGati=G!@I` PhewR=/TTw%kUtr$V WsXt3CeGht5B!I'M(eeOd!Rm$R`SeTab!TeTh(gTi)VelW5C!?Mb R'T:K0EyJe@Li+Scu*S =Ta(Vious0CurEAyEa'Ed+U{UgUn+2EmEtIntL?LeLi)NdNyOlPul?Rt]S.]Ssib!/TatoTt yV tyWd W _@i)Ai'Ed-tEf Epa*Es|EttyEv|I)IdeIm?yIntI%.yIs#Iva>IzeOb!mO)[Odu)Of.OgramOje@Omo>OofOp tyOsp O>@OudOvide2Bl-Dd(g~LpL'Mpk(N^PilPpyR^a'R.yRpo'R'ShTZz!3Ramid:99Al.yAntumArt E,]I{ItIzO>:Bb.Cco#CeCkD?DioIlInI'~yMpN^NdomN+PidReTeTh V&WZ%3AdyAlAs#BelBuildC$lCei=CipeC%dCyc!Du)F!@F%mFu'G]G*tGul?Je@LaxLea'LiefLyMa(Memb M(dMo=Nd NewNtOp&PairPeatPla)P%tQui*ScueSemb!Si,Sour)Sp#'SultTi*T*atTurnUn]Ve$ViewW?d2Y`m0BBb#CeChDeD+F!GhtGidNgOtPp!SkTu$V$V 5AdA,BotBu,CketM<)OfOkieOmSeTa>UghUndU>Y$5Bb DeGLeNNwayR$:DDd!D}[FeIlLadLm#L#LtLu>MeMp!NdTisfyToshiU)Usa+VeY1A!AnA*Att E}HemeHoolI&)I[%sOrp]OutRapRe&RiptRub1AAr^As#AtC#dC*tCt]Cur.yEdEkGm|Le@~M(?Ni%N'Nt&)RiesRvi)Ss]Tt!TupV&_dowAftAllowA*EdEllEriffIeldIftI}IpIv O{OeOotOpOrtOuld O=RimpRugUff!Y0Bl(gCkDeE+GhtGnL|Lk~yLv Mil?Mp!N)NgR&/ Tua>XZe1A>Et^IIllInIrtUll0AbAmEepEnd I)IdeIghtImOgAyEakEelEmEpE*oI{IllIngO{Oma^O}OolOryO=Ra>gyReetRikeR#gRugg!Ud|UffUmb!Y!0Bje@Bm.BwayC)[ChDd&Ff G?G+,ItMm NNnyN'tP PplyP*meReRfa)R+Rpri'RroundR=ySpe@/a(1AllowAmpApArmE?EetIftImIngIt^Ord1MbolMptomRup/em:B!Ck!GIlL|LkNkPeR+tSk/eTtooXi3A^Am~NNGradeHoldOnP Set1BOng::Rd3Ar~ow9UUngU`:3BraRo9NeO"; +const checksum$5 = "0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"; +let wordlist$7 = null; +/** + * The [[link-bip39-en]] for [mnemonic phrases](link-bip-39). + * + * @_docloc: api/wordlists + */ +class LangEn extends WordlistOwl { + /** + * Creates a new instance of the English language Wordlist. + * + * This should be unnecessary most of the time as the exported + * [[langEn]] should suffice. + * + * @_ignore: + */ + constructor() { super("en", words$5, checksum$5); } + /** + * Returns a singleton instance of a ``LangEn``, creating it + * if this is the first time being called. + */ + static wordlist() { + if (wordlist$7 == null) { + wordlist$7 = new LangEn(); + } + return wordlist$7; + } +} + +// Returns a byte with the MSB bits set +function getUpperMask(bits) { + return ((1 << bits) - 1) << (8 - bits) & 0xff; +} +// Returns a byte with the LSB bits set +function getLowerMask(bits) { + return ((1 << bits) - 1) & 0xff; +} +function mnemonicToEntropy(mnemonic, wordlist) { + assertNormalize("NFKD"); + if (wordlist == null) { + wordlist = LangEn.wordlist(); + } + const words = wordlist.split(mnemonic); + assertArgument((words.length % 3) === 0 && words.length >= 12 && words.length <= 24, "invalid mnemonic length", "mnemonic", "[ REDACTED ]"); + const entropy = new Uint8Array(Math.ceil(11 * words.length / 8)); + let offset = 0; + for (let i = 0; i < words.length; i++) { + let index = wordlist.getWordIndex(words[i].normalize("NFKD")); + assertArgument(index >= 0, `invalid mnemonic word at index ${i}`, "mnemonic", "[ REDACTED ]"); + for (let bit = 0; bit < 11; bit++) { + if (index & (1 << (10 - bit))) { + entropy[offset >> 3] |= (1 << (7 - (offset % 8))); + } + offset++; + } + } + const entropyBits = 32 * words.length / 3; + const checksumBits = words.length / 3; + const checksumMask = getUpperMask(checksumBits); + const checksum = getBytes(sha256(entropy.slice(0, entropyBits / 8)))[0] & checksumMask; + assertArgument(checksum === (entropy[entropy.length - 1] & checksumMask), "invalid mnemonic checksum", "mnemonic", "[ REDACTED ]"); + return hexlify(entropy.slice(0, entropyBits / 8)); +} +function entropyToMnemonic(entropy, wordlist) { + assertArgument((entropy.length % 4) === 0 && entropy.length >= 16 && entropy.length <= 32, "invalid entropy size", "entropy", "[ REDACTED ]"); + if (wordlist == null) { + wordlist = LangEn.wordlist(); + } + const indices = [0]; + let remainingBits = 11; + for (let i = 0; i < entropy.length; i++) { + // Consume the whole byte (with still more to go) + if (remainingBits > 8) { + indices[indices.length - 1] <<= 8; + indices[indices.length - 1] |= entropy[i]; + remainingBits -= 8; + // This byte will complete an 11-bit index + } + else { + indices[indices.length - 1] <<= remainingBits; + indices[indices.length - 1] |= entropy[i] >> (8 - remainingBits); + // Start the next word + indices.push(entropy[i] & getLowerMask(8 - remainingBits)); + remainingBits += 3; + } + } + // Compute the checksum bits + const checksumBits = entropy.length / 4; + const checksum = parseInt(sha256(entropy).substring(2, 4), 16) & getUpperMask(checksumBits); + // Shift the checksum into the word indices + indices[indices.length - 1] <<= checksumBits; + indices[indices.length - 1] |= (checksum >> (8 - checksumBits)); + return wordlist.join(indices.map((index) => wordlist.getWord(index))); +} +const _guard$1 = {}; +/** + * A **Mnemonic** wraps all properties required to compute [[link-bip-39]] + * seeds and convert between phrases and entropy. + */ +class Mnemonic { + /** + * The mnemonic phrase of 12, 15, 18, 21 or 24 words. + * + * Use the [[wordlist]] ``split`` method to get the individual words. + */ + phrase; + /** + * The password used for this mnemonic. If no password is used this + * is the empty string (i.e. ``""``) as per the specification. + */ + password; + /** + * The wordlist for this mnemonic. + */ + wordlist; + /** + * The underlying entropy which the mnemonic encodes. + */ + entropy; + /** + * @private + */ + constructor(guard, entropy, phrase, password, wordlist) { + if (password == null) { + password = ""; + } + if (wordlist == null) { + wordlist = LangEn.wordlist(); + } + assertPrivate(guard, _guard$1, "Mnemonic"); + defineProperties(this, { phrase, password, wordlist, entropy }); + } + /** + * Returns the seed for the mnemonic. + */ + computeSeed() { + const salt = toUtf8Bytes$1("mnemonic" + this.password, "NFKD"); + return pbkdf2$1(toUtf8Bytes$1(this.phrase, "NFKD"), salt, 2048, 64, "sha512"); + } + /** + * Creates a new Mnemonic for the %%phrase%%. + * + * The default %%password%% is the empty string and the default + * wordlist is the [English wordlists](LangEn). + */ + static fromPhrase(phrase, password, wordlist) { + // Normalize the case and space; throws if invalid + const entropy = mnemonicToEntropy(phrase, wordlist); + phrase = entropyToMnemonic(getBytes(entropy), wordlist); + return new Mnemonic(_guard$1, entropy, phrase, password, wordlist); + } + /** + * Create a new **Mnemonic** from the %%entropy%%. + * + * The default %%password%% is the empty string and the default + * wordlist is the [English wordlists](LangEn). + */ + static fromEntropy(_entropy, password, wordlist) { + const entropy = getBytes(_entropy, "entropy"); + const phrase = entropyToMnemonic(entropy, wordlist); + return new Mnemonic(_guard$1, hexlify(entropy), phrase, password, wordlist); + } + /** + * Returns the phrase for %%mnemonic%%. + */ + static entropyToPhrase(_entropy, wordlist) { + const entropy = getBytes(_entropy, "entropy"); + return entropyToMnemonic(entropy, wordlist); + } + /** + * Returns the entropy for %%phrase%%. + */ + static phraseToEntropy(phrase, wordlist) { + return mnemonicToEntropy(phrase, wordlist); + } + /** + * Returns true if %%phrase%% is a valid [[link-bip-39]] phrase. + * + * This checks all the provided words belong to the %%wordlist%%, + * that the length is valid and the checksum is correct. + */ + static isValidMnemonic(phrase, wordlist) { + try { + mnemonicToEntropy(phrase, wordlist); + return true; + } + catch (error) { } + return false; + } +} + +/*! MIT License. Copyright 2015-2022 Richard Moore . See LICENSE.txt. */ +var __classPrivateFieldGet$2 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +}; +var __classPrivateFieldSet$2 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +}; +var _AES_key, _AES_Kd, _AES_Ke; +// Number of rounds by keysize +const numberOfRounds = { 16: 10, 24: 12, 32: 14 }; +// Round constant words +const rcon = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91]; +// S-box and Inverse S-box (S is for Substitution) +const S = [0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16]; +const Si = [0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d]; +// Transformations for encryption +const T1 = [0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d, 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554, 0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d, 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a, 0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87, 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b, 0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea, 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b, 0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a, 0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f, 0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108, 0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f, 0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e, 0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5, 0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d, 0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f, 0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e, 0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb, 0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce, 0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497, 0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c, 0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed, 0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b, 0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a, 0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16, 0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594, 0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81, 0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3, 0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a, 0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504, 0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163, 0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d, 0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f, 0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739, 0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47, 0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395, 0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f, 0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883, 0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c, 0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76, 0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e, 0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4, 0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6, 0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b, 0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7, 0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0, 0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25, 0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818, 0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72, 0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651, 0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21, 0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85, 0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa, 0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12, 0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0, 0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9, 0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133, 0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7, 0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920, 0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a, 0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17, 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8, 0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11, 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a]; +const T2 = [0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b, 0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5, 0x50603030, 0x03020101, 0xa9ce6767, 0x7d562b2b, 0x19e7fefe, 0x62b5d7d7, 0xe64dabab, 0x9aec7676, 0x458fcaca, 0x9d1f8282, 0x4089c9c9, 0x87fa7d7d, 0x15effafa, 0xebb25959, 0xc98e4747, 0x0bfbf0f0, 0xec41adad, 0x67b3d4d4, 0xfd5fa2a2, 0xea45afaf, 0xbf239c9c, 0xf753a4a4, 0x96e47272, 0x5b9bc0c0, 0xc275b7b7, 0x1ce1fdfd, 0xae3d9393, 0x6a4c2626, 0x5a6c3636, 0x417e3f3f, 0x02f5f7f7, 0x4f83cccc, 0x5c683434, 0xf451a5a5, 0x34d1e5e5, 0x08f9f1f1, 0x93e27171, 0x73abd8d8, 0x53623131, 0x3f2a1515, 0x0c080404, 0x5295c7c7, 0x65462323, 0x5e9dc3c3, 0x28301818, 0xa1379696, 0x0f0a0505, 0xb52f9a9a, 0x090e0707, 0x36241212, 0x9b1b8080, 0x3ddfe2e2, 0x26cdebeb, 0x694e2727, 0xcd7fb2b2, 0x9fea7575, 0x1b120909, 0x9e1d8383, 0x74582c2c, 0x2e341a1a, 0x2d361b1b, 0xb2dc6e6e, 0xeeb45a5a, 0xfb5ba0a0, 0xf6a45252, 0x4d763b3b, 0x61b7d6d6, 0xce7db3b3, 0x7b522929, 0x3edde3e3, 0x715e2f2f, 0x97138484, 0xf5a65353, 0x68b9d1d1, 0x00000000, 0x2cc1eded, 0x60402020, 0x1fe3fcfc, 0xc879b1b1, 0xedb65b5b, 0xbed46a6a, 0x468dcbcb, 0xd967bebe, 0x4b723939, 0xde944a4a, 0xd4984c4c, 0xe8b05858, 0x4a85cfcf, 0x6bbbd0d0, 0x2ac5efef, 0xe54faaaa, 0x16edfbfb, 0xc5864343, 0xd79a4d4d, 0x55663333, 0x94118585, 0xcf8a4545, 0x10e9f9f9, 0x06040202, 0x81fe7f7f, 0xf0a05050, 0x44783c3c, 0xba259f9f, 0xe34ba8a8, 0xf3a25151, 0xfe5da3a3, 0xc0804040, 0x8a058f8f, 0xad3f9292, 0xbc219d9d, 0x48703838, 0x04f1f5f5, 0xdf63bcbc, 0xc177b6b6, 0x75afdada, 0x63422121, 0x30201010, 0x1ae5ffff, 0x0efdf3f3, 0x6dbfd2d2, 0x4c81cdcd, 0x14180c0c, 0x35261313, 0x2fc3ecec, 0xe1be5f5f, 0xa2359797, 0xcc884444, 0x392e1717, 0x5793c4c4, 0xf255a7a7, 0x82fc7e7e, 0x477a3d3d, 0xacc86464, 0xe7ba5d5d, 0x2b321919, 0x95e67373, 0xa0c06060, 0x98198181, 0xd19e4f4f, 0x7fa3dcdc, 0x66442222, 0x7e542a2a, 0xab3b9090, 0x830b8888, 0xca8c4646, 0x29c7eeee, 0xd36bb8b8, 0x3c281414, 0x79a7dede, 0xe2bc5e5e, 0x1d160b0b, 0x76addbdb, 0x3bdbe0e0, 0x56643232, 0x4e743a3a, 0x1e140a0a, 0xdb924949, 0x0a0c0606, 0x6c482424, 0xe4b85c5c, 0x5d9fc2c2, 0x6ebdd3d3, 0xef43acac, 0xa6c46262, 0xa8399191, 0xa4319595, 0x37d3e4e4, 0x8bf27979, 0x32d5e7e7, 0x438bc8c8, 0x596e3737, 0xb7da6d6d, 0x8c018d8d, 0x64b1d5d5, 0xd29c4e4e, 0xe049a9a9, 0xb4d86c6c, 0xfaac5656, 0x07f3f4f4, 0x25cfeaea, 0xafca6565, 0x8ef47a7a, 0xe947aeae, 0x18100808, 0xd56fbaba, 0x88f07878, 0x6f4a2525, 0x725c2e2e, 0x24381c1c, 0xf157a6a6, 0xc773b4b4, 0x5197c6c6, 0x23cbe8e8, 0x7ca1dddd, 0x9ce87474, 0x213e1f1f, 0xdd964b4b, 0xdc61bdbd, 0x860d8b8b, 0x850f8a8a, 0x90e07070, 0x427c3e3e, 0xc471b5b5, 0xaacc6666, 0xd8904848, 0x05060303, 0x01f7f6f6, 0x121c0e0e, 0xa3c26161, 0x5f6a3535, 0xf9ae5757, 0xd069b9b9, 0x91178686, 0x5899c1c1, 0x273a1d1d, 0xb9279e9e, 0x38d9e1e1, 0x13ebf8f8, 0xb32b9898, 0x33221111, 0xbbd26969, 0x70a9d9d9, 0x89078e8e, 0xa7339494, 0xb62d9b9b, 0x223c1e1e, 0x92158787, 0x20c9e9e9, 0x4987cece, 0xffaa5555, 0x78502828, 0x7aa5dfdf, 0x8f038c8c, 0xf859a1a1, 0x80098989, 0x171a0d0d, 0xda65bfbf, 0x31d7e6e6, 0xc6844242, 0xb8d06868, 0xc3824141, 0xb0299999, 0x775a2d2d, 0x111e0f0f, 0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616]; +const T3 = [0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b, 0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5, 0x30506030, 0x01030201, 0x67a9ce67, 0x2b7d562b, 0xfe19e7fe, 0xd762b5d7, 0xabe64dab, 0x769aec76, 0xca458fca, 0x829d1f82, 0xc94089c9, 0x7d87fa7d, 0xfa15effa, 0x59ebb259, 0x47c98e47, 0xf00bfbf0, 0xadec41ad, 0xd467b3d4, 0xa2fd5fa2, 0xafea45af, 0x9cbf239c, 0xa4f753a4, 0x7296e472, 0xc05b9bc0, 0xb7c275b7, 0xfd1ce1fd, 0x93ae3d93, 0x266a4c26, 0x365a6c36, 0x3f417e3f, 0xf702f5f7, 0xcc4f83cc, 0x345c6834, 0xa5f451a5, 0xe534d1e5, 0xf108f9f1, 0x7193e271, 0xd873abd8, 0x31536231, 0x153f2a15, 0x040c0804, 0xc75295c7, 0x23654623, 0xc35e9dc3, 0x18283018, 0x96a13796, 0x050f0a05, 0x9ab52f9a, 0x07090e07, 0x12362412, 0x809b1b80, 0xe23ddfe2, 0xeb26cdeb, 0x27694e27, 0xb2cd7fb2, 0x759fea75, 0x091b1209, 0x839e1d83, 0x2c74582c, 0x1a2e341a, 0x1b2d361b, 0x6eb2dc6e, 0x5aeeb45a, 0xa0fb5ba0, 0x52f6a452, 0x3b4d763b, 0xd661b7d6, 0xb3ce7db3, 0x297b5229, 0xe33edde3, 0x2f715e2f, 0x84971384, 0x53f5a653, 0xd168b9d1, 0x00000000, 0xed2cc1ed, 0x20604020, 0xfc1fe3fc, 0xb1c879b1, 0x5bedb65b, 0x6abed46a, 0xcb468dcb, 0xbed967be, 0x394b7239, 0x4ade944a, 0x4cd4984c, 0x58e8b058, 0xcf4a85cf, 0xd06bbbd0, 0xef2ac5ef, 0xaae54faa, 0xfb16edfb, 0x43c58643, 0x4dd79a4d, 0x33556633, 0x85941185, 0x45cf8a45, 0xf910e9f9, 0x02060402, 0x7f81fe7f, 0x50f0a050, 0x3c44783c, 0x9fba259f, 0xa8e34ba8, 0x51f3a251, 0xa3fe5da3, 0x40c08040, 0x8f8a058f, 0x92ad3f92, 0x9dbc219d, 0x38487038, 0xf504f1f5, 0xbcdf63bc, 0xb6c177b6, 0xda75afda, 0x21634221, 0x10302010, 0xff1ae5ff, 0xf30efdf3, 0xd26dbfd2, 0xcd4c81cd, 0x0c14180c, 0x13352613, 0xec2fc3ec, 0x5fe1be5f, 0x97a23597, 0x44cc8844, 0x17392e17, 0xc45793c4, 0xa7f255a7, 0x7e82fc7e, 0x3d477a3d, 0x64acc864, 0x5de7ba5d, 0x192b3219, 0x7395e673, 0x60a0c060, 0x81981981, 0x4fd19e4f, 0xdc7fa3dc, 0x22664422, 0x2a7e542a, 0x90ab3b90, 0x88830b88, 0x46ca8c46, 0xee29c7ee, 0xb8d36bb8, 0x143c2814, 0xde79a7de, 0x5ee2bc5e, 0x0b1d160b, 0xdb76addb, 0xe03bdbe0, 0x32566432, 0x3a4e743a, 0x0a1e140a, 0x49db9249, 0x060a0c06, 0x246c4824, 0x5ce4b85c, 0xc25d9fc2, 0xd36ebdd3, 0xacef43ac, 0x62a6c462, 0x91a83991, 0x95a43195, 0xe437d3e4, 0x798bf279, 0xe732d5e7, 0xc8438bc8, 0x37596e37, 0x6db7da6d, 0x8d8c018d, 0xd564b1d5, 0x4ed29c4e, 0xa9e049a9, 0x6cb4d86c, 0x56faac56, 0xf407f3f4, 0xea25cfea, 0x65afca65, 0x7a8ef47a, 0xaee947ae, 0x08181008, 0xbad56fba, 0x7888f078, 0x256f4a25, 0x2e725c2e, 0x1c24381c, 0xa6f157a6, 0xb4c773b4, 0xc65197c6, 0xe823cbe8, 0xdd7ca1dd, 0x749ce874, 0x1f213e1f, 0x4bdd964b, 0xbddc61bd, 0x8b860d8b, 0x8a850f8a, 0x7090e070, 0x3e427c3e, 0xb5c471b5, 0x66aacc66, 0x48d89048, 0x03050603, 0xf601f7f6, 0x0e121c0e, 0x61a3c261, 0x355f6a35, 0x57f9ae57, 0xb9d069b9, 0x86911786, 0xc15899c1, 0x1d273a1d, 0x9eb9279e, 0xe138d9e1, 0xf813ebf8, 0x98b32b98, 0x11332211, 0x69bbd269, 0xd970a9d9, 0x8e89078e, 0x94a73394, 0x9bb62d9b, 0x1e223c1e, 0x87921587, 0xe920c9e9, 0xce4987ce, 0x55ffaa55, 0x28785028, 0xdf7aa5df, 0x8c8f038c, 0xa1f859a1, 0x89800989, 0x0d171a0d, 0xbfda65bf, 0xe631d7e6, 0x42c68442, 0x68b8d068, 0x41c38241, 0x99b02999, 0x2d775a2d, 0x0f111e0f, 0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16]; +const T4 = [0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6, 0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491, 0x30305060, 0x01010302, 0x6767a9ce, 0x2b2b7d56, 0xfefe19e7, 0xd7d762b5, 0xababe64d, 0x76769aec, 0xcaca458f, 0x82829d1f, 0xc9c94089, 0x7d7d87fa, 0xfafa15ef, 0x5959ebb2, 0x4747c98e, 0xf0f00bfb, 0xadadec41, 0xd4d467b3, 0xa2a2fd5f, 0xafafea45, 0x9c9cbf23, 0xa4a4f753, 0x727296e4, 0xc0c05b9b, 0xb7b7c275, 0xfdfd1ce1, 0x9393ae3d, 0x26266a4c, 0x36365a6c, 0x3f3f417e, 0xf7f702f5, 0xcccc4f83, 0x34345c68, 0xa5a5f451, 0xe5e534d1, 0xf1f108f9, 0x717193e2, 0xd8d873ab, 0x31315362, 0x15153f2a, 0x04040c08, 0xc7c75295, 0x23236546, 0xc3c35e9d, 0x18182830, 0x9696a137, 0x05050f0a, 0x9a9ab52f, 0x0707090e, 0x12123624, 0x80809b1b, 0xe2e23ddf, 0xebeb26cd, 0x2727694e, 0xb2b2cd7f, 0x75759fea, 0x09091b12, 0x83839e1d, 0x2c2c7458, 0x1a1a2e34, 0x1b1b2d36, 0x6e6eb2dc, 0x5a5aeeb4, 0xa0a0fb5b, 0x5252f6a4, 0x3b3b4d76, 0xd6d661b7, 0xb3b3ce7d, 0x29297b52, 0xe3e33edd, 0x2f2f715e, 0x84849713, 0x5353f5a6, 0xd1d168b9, 0x00000000, 0xeded2cc1, 0x20206040, 0xfcfc1fe3, 0xb1b1c879, 0x5b5bedb6, 0x6a6abed4, 0xcbcb468d, 0xbebed967, 0x39394b72, 0x4a4ade94, 0x4c4cd498, 0x5858e8b0, 0xcfcf4a85, 0xd0d06bbb, 0xefef2ac5, 0xaaaae54f, 0xfbfb16ed, 0x4343c586, 0x4d4dd79a, 0x33335566, 0x85859411, 0x4545cf8a, 0xf9f910e9, 0x02020604, 0x7f7f81fe, 0x5050f0a0, 0x3c3c4478, 0x9f9fba25, 0xa8a8e34b, 0x5151f3a2, 0xa3a3fe5d, 0x4040c080, 0x8f8f8a05, 0x9292ad3f, 0x9d9dbc21, 0x38384870, 0xf5f504f1, 0xbcbcdf63, 0xb6b6c177, 0xdada75af, 0x21216342, 0x10103020, 0xffff1ae5, 0xf3f30efd, 0xd2d26dbf, 0xcdcd4c81, 0x0c0c1418, 0x13133526, 0xecec2fc3, 0x5f5fe1be, 0x9797a235, 0x4444cc88, 0x1717392e, 0xc4c45793, 0xa7a7f255, 0x7e7e82fc, 0x3d3d477a, 0x6464acc8, 0x5d5de7ba, 0x19192b32, 0x737395e6, 0x6060a0c0, 0x81819819, 0x4f4fd19e, 0xdcdc7fa3, 0x22226644, 0x2a2a7e54, 0x9090ab3b, 0x8888830b, 0x4646ca8c, 0xeeee29c7, 0xb8b8d36b, 0x14143c28, 0xdede79a7, 0x5e5ee2bc, 0x0b0b1d16, 0xdbdb76ad, 0xe0e03bdb, 0x32325664, 0x3a3a4e74, 0x0a0a1e14, 0x4949db92, 0x06060a0c, 0x24246c48, 0x5c5ce4b8, 0xc2c25d9f, 0xd3d36ebd, 0xacacef43, 0x6262a6c4, 0x9191a839, 0x9595a431, 0xe4e437d3, 0x79798bf2, 0xe7e732d5, 0xc8c8438b, 0x3737596e, 0x6d6db7da, 0x8d8d8c01, 0xd5d564b1, 0x4e4ed29c, 0xa9a9e049, 0x6c6cb4d8, 0x5656faac, 0xf4f407f3, 0xeaea25cf, 0x6565afca, 0x7a7a8ef4, 0xaeaee947, 0x08081810, 0xbabad56f, 0x787888f0, 0x25256f4a, 0x2e2e725c, 0x1c1c2438, 0xa6a6f157, 0xb4b4c773, 0xc6c65197, 0xe8e823cb, 0xdddd7ca1, 0x74749ce8, 0x1f1f213e, 0x4b4bdd96, 0xbdbddc61, 0x8b8b860d, 0x8a8a850f, 0x707090e0, 0x3e3e427c, 0xb5b5c471, 0x6666aacc, 0x4848d890, 0x03030506, 0xf6f601f7, 0x0e0e121c, 0x6161a3c2, 0x35355f6a, 0x5757f9ae, 0xb9b9d069, 0x86869117, 0xc1c15899, 0x1d1d273a, 0x9e9eb927, 0xe1e138d9, 0xf8f813eb, 0x9898b32b, 0x11113322, 0x6969bbd2, 0xd9d970a9, 0x8e8e8907, 0x9494a733, 0x9b9bb62d, 0x1e1e223c, 0x87879215, 0xe9e920c9, 0xcece4987, 0x5555ffaa, 0x28287850, 0xdfdf7aa5, 0x8c8c8f03, 0xa1a1f859, 0x89898009, 0x0d0d171a, 0xbfbfda65, 0xe6e631d7, 0x4242c684, 0x6868b8d0, 0x4141c382, 0x9999b029, 0x2d2d775a, 0x0f0f111e, 0xb0b0cb7b, 0x5454fca8, 0xbbbbd66d, 0x16163a2c]; +// Transformations for decryption +const T5 = [0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96, 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393, 0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25, 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f, 0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1, 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6, 0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da, 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844, 0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd, 0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4, 0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45, 0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94, 0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7, 0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a, 0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5, 0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c, 0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1, 0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a, 0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75, 0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051, 0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46, 0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff, 0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77, 0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb, 0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000, 0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e, 0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927, 0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a, 0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e, 0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16, 0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d, 0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8, 0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd, 0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34, 0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163, 0xd731dcca, 0x42638510, 0x13972240, 0x84c61120, 0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d, 0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0, 0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422, 0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef, 0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36, 0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4, 0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662, 0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5, 0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3, 0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b, 0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8, 0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6, 0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6, 0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0, 0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815, 0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f, 0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df, 0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f, 0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e, 0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713, 0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89, 0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c, 0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf, 0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86, 0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f, 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541, 0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190, 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742]; +const T6 = [0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e, 0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303, 0x552030fa, 0xf6ad766d, 0x9188cc76, 0x25f5024c, 0xfc4fe5d7, 0xd7c52acb, 0x80263544, 0x8fb562a3, 0x49deb15a, 0x6725ba1b, 0x9845ea0e, 0xe15dfec0, 0x02c32f75, 0x12814cf0, 0xa38d4697, 0xc66bd3f9, 0xe7038f5f, 0x9515929c, 0xebbf6d7a, 0xda955259, 0x2dd4be83, 0xd3587421, 0x2949e069, 0x448ec9c8, 0x6a75c289, 0x78f48e79, 0x6b99583e, 0xdd27b971, 0xb6bee14f, 0x17f088ad, 0x66c920ac, 0xb47dce3a, 0x1863df4a, 0x82e51a31, 0x60975133, 0x4562537f, 0xe0b16477, 0x84bb6bae, 0x1cfe81a0, 0x94f9082b, 0x58704868, 0x198f45fd, 0x8794de6c, 0xb7527bf8, 0x23ab73d3, 0xe2724b02, 0x57e31f8f, 0x2a6655ab, 0x07b2eb28, 0x032fb5c2, 0x9a86c57b, 0xa5d33708, 0xf2302887, 0xb223bfa5, 0xba02036a, 0x5ced1682, 0x2b8acf1c, 0x92a779b4, 0xf0f307f2, 0xa14e69e2, 0xcd65daf4, 0xd50605be, 0x1fd13462, 0x8ac4a6fe, 0x9d342e53, 0xa0a2f355, 0x32058ae1, 0x75a4f6eb, 0x390b83ec, 0xaa4060ef, 0x065e719f, 0x51bd6e10, 0xf93e218a, 0x3d96dd06, 0xaedd3e05, 0x464de6bd, 0xb591548d, 0x0571c45d, 0x6f0406d4, 0xff605015, 0x241998fb, 0x97d6bde9, 0xcc894043, 0x7767d99e, 0xbdb0e842, 0x8807898b, 0x38e7195b, 0xdb79c8ee, 0x47a17c0a, 0xe97c420f, 0xc9f8841e, 0x00000000, 0x83098086, 0x48322bed, 0xac1e1170, 0x4e6c5a72, 0xfbfd0eff, 0x560f8538, 0x1e3daed5, 0x27362d39, 0x640a0fd9, 0x21685ca6, 0xd19b5b54, 0x3a24362e, 0xb10c0a67, 0x0f9357e7, 0xd2b4ee96, 0x9e1b9b91, 0x4f80c0c5, 0xa261dc20, 0x695a774b, 0x161c121a, 0x0ae293ba, 0xe5c0a02a, 0x433c22e0, 0x1d121b17, 0x0b0e090d, 0xadf28bc7, 0xb92db6a8, 0xc8141ea9, 0x8557f119, 0x4caf7507, 0xbbee99dd, 0xfda37f60, 0x9ff70126, 0xbc5c72f5, 0xc544663b, 0x345bfb7e, 0x768b4329, 0xdccb23c6, 0x68b6edfc, 0x63b8e4f1, 0xcad731dc, 0x10426385, 0x40139722, 0x2084c611, 0x7d854a24, 0xf8d2bb3d, 0x11aef932, 0x6dc729a1, 0x4b1d9e2f, 0xf3dcb230, 0xec0d8652, 0xd077c1e3, 0x6c2bb316, 0x99a970b9, 0xfa119448, 0x2247e964, 0xc4a8fc8c, 0x1aa0f03f, 0xd8567d2c, 0xef223390, 0xc787494e, 0xc1d938d1, 0xfe8ccaa2, 0x3698d40b, 0xcfa6f581, 0x28a57ade, 0x26dab78e, 0xa43fadbf, 0xe42c3a9d, 0x0d507892, 0x9b6a5fcc, 0x62547e46, 0xc2f68d13, 0xe890d8b8, 0x5e2e39f7, 0xf582c3af, 0xbe9f5d80, 0x7c69d093, 0xa96fd52d, 0xb3cf2512, 0x3bc8ac99, 0xa710187d, 0x6ee89c63, 0x7bdb3bbb, 0x09cd2678, 0xf46e5918, 0x01ec9ab7, 0xa8834f9a, 0x65e6956e, 0x7eaaffe6, 0x0821bccf, 0xe6ef15e8, 0xd9bae79b, 0xce4a6f36, 0xd4ea9f09, 0xd629b07c, 0xaf31a4b2, 0x312a3f23, 0x30c6a594, 0xc035a266, 0x37744ebc, 0xa6fc82ca, 0xb0e090d0, 0x1533a7d8, 0x4af10498, 0xf741ecda, 0x0e7fcd50, 0x2f1791f6, 0x8d764dd6, 0x4d43efb0, 0x54ccaa4d, 0xdfe49604, 0xe39ed1b5, 0x1b4c6a88, 0xb8c12c1f, 0x7f466551, 0x049d5eea, 0x5d018c35, 0x73fa8774, 0x2efb0b41, 0x5ab3671d, 0x5292dbd2, 0x33e91056, 0x136dd647, 0x8c9ad761, 0x7a37a10c, 0x8e59f814, 0x89eb133c, 0xeecea927, 0x35b761c9, 0xede11ce5, 0x3c7a47b1, 0x599cd2df, 0x3f55f273, 0x791814ce, 0xbf73c737, 0xea53f7cd, 0x5b5ffdaa, 0x14df3d6f, 0x867844db, 0x81caaff3, 0x3eb968c4, 0x2c382434, 0x5fc2a340, 0x72161dc3, 0x0cbce225, 0x8b283c49, 0x41ff0d95, 0x7139a801, 0xde080cb3, 0x9cd8b4e4, 0x906456c1, 0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857]; +const T7 = [0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27, 0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3, 0xfa552030, 0x6df6ad76, 0x769188cc, 0x4c25f502, 0xd7fc4fe5, 0xcbd7c52a, 0x44802635, 0xa38fb562, 0x5a49deb1, 0x1b6725ba, 0x0e9845ea, 0xc0e15dfe, 0x7502c32f, 0xf012814c, 0x97a38d46, 0xf9c66bd3, 0x5fe7038f, 0x9c951592, 0x7aebbf6d, 0x59da9552, 0x832dd4be, 0x21d35874, 0x692949e0, 0xc8448ec9, 0x896a75c2, 0x7978f48e, 0x3e6b9958, 0x71dd27b9, 0x4fb6bee1, 0xad17f088, 0xac66c920, 0x3ab47dce, 0x4a1863df, 0x3182e51a, 0x33609751, 0x7f456253, 0x77e0b164, 0xae84bb6b, 0xa01cfe81, 0x2b94f908, 0x68587048, 0xfd198f45, 0x6c8794de, 0xf8b7527b, 0xd323ab73, 0x02e2724b, 0x8f57e31f, 0xab2a6655, 0x2807b2eb, 0xc2032fb5, 0x7b9a86c5, 0x08a5d337, 0x87f23028, 0xa5b223bf, 0x6aba0203, 0x825ced16, 0x1c2b8acf, 0xb492a779, 0xf2f0f307, 0xe2a14e69, 0xf4cd65da, 0xbed50605, 0x621fd134, 0xfe8ac4a6, 0x539d342e, 0x55a0a2f3, 0xe132058a, 0xeb75a4f6, 0xec390b83, 0xefaa4060, 0x9f065e71, 0x1051bd6e, 0x8af93e21, 0x063d96dd, 0x05aedd3e, 0xbd464de6, 0x8db59154, 0x5d0571c4, 0xd46f0406, 0x15ff6050, 0xfb241998, 0xe997d6bd, 0x43cc8940, 0x9e7767d9, 0x42bdb0e8, 0x8b880789, 0x5b38e719, 0xeedb79c8, 0x0a47a17c, 0x0fe97c42, 0x1ec9f884, 0x00000000, 0x86830980, 0xed48322b, 0x70ac1e11, 0x724e6c5a, 0xfffbfd0e, 0x38560f85, 0xd51e3dae, 0x3927362d, 0xd9640a0f, 0xa621685c, 0x54d19b5b, 0x2e3a2436, 0x67b10c0a, 0xe70f9357, 0x96d2b4ee, 0x919e1b9b, 0xc54f80c0, 0x20a261dc, 0x4b695a77, 0x1a161c12, 0xba0ae293, 0x2ae5c0a0, 0xe0433c22, 0x171d121b, 0x0d0b0e09, 0xc7adf28b, 0xa8b92db6, 0xa9c8141e, 0x198557f1, 0x074caf75, 0xddbbee99, 0x60fda37f, 0x269ff701, 0xf5bc5c72, 0x3bc54466, 0x7e345bfb, 0x29768b43, 0xc6dccb23, 0xfc68b6ed, 0xf163b8e4, 0xdccad731, 0x85104263, 0x22401397, 0x112084c6, 0x247d854a, 0x3df8d2bb, 0x3211aef9, 0xa16dc729, 0x2f4b1d9e, 0x30f3dcb2, 0x52ec0d86, 0xe3d077c1, 0x166c2bb3, 0xb999a970, 0x48fa1194, 0x642247e9, 0x8cc4a8fc, 0x3f1aa0f0, 0x2cd8567d, 0x90ef2233, 0x4ec78749, 0xd1c1d938, 0xa2fe8cca, 0x0b3698d4, 0x81cfa6f5, 0xde28a57a, 0x8e26dab7, 0xbfa43fad, 0x9de42c3a, 0x920d5078, 0xcc9b6a5f, 0x4662547e, 0x13c2f68d, 0xb8e890d8, 0xf75e2e39, 0xaff582c3, 0x80be9f5d, 0x937c69d0, 0x2da96fd5, 0x12b3cf25, 0x993bc8ac, 0x7da71018, 0x636ee89c, 0xbb7bdb3b, 0x7809cd26, 0x18f46e59, 0xb701ec9a, 0x9aa8834f, 0x6e65e695, 0xe67eaaff, 0xcf0821bc, 0xe8e6ef15, 0x9bd9bae7, 0x36ce4a6f, 0x09d4ea9f, 0x7cd629b0, 0xb2af31a4, 0x23312a3f, 0x9430c6a5, 0x66c035a2, 0xbc37744e, 0xcaa6fc82, 0xd0b0e090, 0xd81533a7, 0x984af104, 0xdaf741ec, 0x500e7fcd, 0xf62f1791, 0xd68d764d, 0xb04d43ef, 0x4d54ccaa, 0x04dfe496, 0xb5e39ed1, 0x881b4c6a, 0x1fb8c12c, 0x517f4665, 0xea049d5e, 0x355d018c, 0x7473fa87, 0x412efb0b, 0x1d5ab367, 0xd25292db, 0x5633e910, 0x47136dd6, 0x618c9ad7, 0x0c7a37a1, 0x148e59f8, 0x3c89eb13, 0x27eecea9, 0xc935b761, 0xe5ede11c, 0xb13c7a47, 0xdf599cd2, 0x733f55f2, 0xce791814, 0x37bf73c7, 0xcdea53f7, 0xaa5b5ffd, 0x6f14df3d, 0xdb867844, 0xf381caaf, 0xc43eb968, 0x342c3824, 0x405fc2a3, 0xc372161d, 0x250cbce2, 0x498b283c, 0x9541ff0d, 0x017139a8, 0xb3de080c, 0xe49cd8b4, 0xc1906456, 0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8]; +const T8 = [0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a, 0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b, 0x30fa5520, 0x766df6ad, 0xcc769188, 0x024c25f5, 0xe5d7fc4f, 0x2acbd7c5, 0x35448026, 0x62a38fb5, 0xb15a49de, 0xba1b6725, 0xea0e9845, 0xfec0e15d, 0x2f7502c3, 0x4cf01281, 0x4697a38d, 0xd3f9c66b, 0x8f5fe703, 0x929c9515, 0x6d7aebbf, 0x5259da95, 0xbe832dd4, 0x7421d358, 0xe0692949, 0xc9c8448e, 0xc2896a75, 0x8e7978f4, 0x583e6b99, 0xb971dd27, 0xe14fb6be, 0x88ad17f0, 0x20ac66c9, 0xce3ab47d, 0xdf4a1863, 0x1a3182e5, 0x51336097, 0x537f4562, 0x6477e0b1, 0x6bae84bb, 0x81a01cfe, 0x082b94f9, 0x48685870, 0x45fd198f, 0xde6c8794, 0x7bf8b752, 0x73d323ab, 0x4b02e272, 0x1f8f57e3, 0x55ab2a66, 0xeb2807b2, 0xb5c2032f, 0xc57b9a86, 0x3708a5d3, 0x2887f230, 0xbfa5b223, 0x036aba02, 0x16825ced, 0xcf1c2b8a, 0x79b492a7, 0x07f2f0f3, 0x69e2a14e, 0xdaf4cd65, 0x05bed506, 0x34621fd1, 0xa6fe8ac4, 0x2e539d34, 0xf355a0a2, 0x8ae13205, 0xf6eb75a4, 0x83ec390b, 0x60efaa40, 0x719f065e, 0x6e1051bd, 0x218af93e, 0xdd063d96, 0x3e05aedd, 0xe6bd464d, 0x548db591, 0xc45d0571, 0x06d46f04, 0x5015ff60, 0x98fb2419, 0xbde997d6, 0x4043cc89, 0xd99e7767, 0xe842bdb0, 0x898b8807, 0x195b38e7, 0xc8eedb79, 0x7c0a47a1, 0x420fe97c, 0x841ec9f8, 0x00000000, 0x80868309, 0x2bed4832, 0x1170ac1e, 0x5a724e6c, 0x0efffbfd, 0x8538560f, 0xaed51e3d, 0x2d392736, 0x0fd9640a, 0x5ca62168, 0x5b54d19b, 0x362e3a24, 0x0a67b10c, 0x57e70f93, 0xee96d2b4, 0x9b919e1b, 0xc0c54f80, 0xdc20a261, 0x774b695a, 0x121a161c, 0x93ba0ae2, 0xa02ae5c0, 0x22e0433c, 0x1b171d12, 0x090d0b0e, 0x8bc7adf2, 0xb6a8b92d, 0x1ea9c814, 0xf1198557, 0x75074caf, 0x99ddbbee, 0x7f60fda3, 0x01269ff7, 0x72f5bc5c, 0x663bc544, 0xfb7e345b, 0x4329768b, 0x23c6dccb, 0xedfc68b6, 0xe4f163b8, 0x31dccad7, 0x63851042, 0x97224013, 0xc6112084, 0x4a247d85, 0xbb3df8d2, 0xf93211ae, 0x29a16dc7, 0x9e2f4b1d, 0xb230f3dc, 0x8652ec0d, 0xc1e3d077, 0xb3166c2b, 0x70b999a9, 0x9448fa11, 0xe9642247, 0xfc8cc4a8, 0xf03f1aa0, 0x7d2cd856, 0x3390ef22, 0x494ec787, 0x38d1c1d9, 0xcaa2fe8c, 0xd40b3698, 0xf581cfa6, 0x7ade28a5, 0xb78e26da, 0xadbfa43f, 0x3a9de42c, 0x78920d50, 0x5fcc9b6a, 0x7e466254, 0x8d13c2f6, 0xd8b8e890, 0x39f75e2e, 0xc3aff582, 0x5d80be9f, 0xd0937c69, 0xd52da96f, 0x2512b3cf, 0xac993bc8, 0x187da710, 0x9c636ee8, 0x3bbb7bdb, 0x267809cd, 0x5918f46e, 0x9ab701ec, 0x4f9aa883, 0x956e65e6, 0xffe67eaa, 0xbccf0821, 0x15e8e6ef, 0xe79bd9ba, 0x6f36ce4a, 0x9f09d4ea, 0xb07cd629, 0xa4b2af31, 0x3f23312a, 0xa59430c6, 0xa266c035, 0x4ebc3774, 0x82caa6fc, 0x90d0b0e0, 0xa7d81533, 0x04984af1, 0xecdaf741, 0xcd500e7f, 0x91f62f17, 0x4dd68d76, 0xefb04d43, 0xaa4d54cc, 0x9604dfe4, 0xd1b5e39e, 0x6a881b4c, 0x2c1fb8c1, 0x65517f46, 0x5eea049d, 0x8c355d01, 0x877473fa, 0x0b412efb, 0x671d5ab3, 0xdbd25292, 0x105633e9, 0xd647136d, 0xd7618c9a, 0xa10c7a37, 0xf8148e59, 0x133c89eb, 0xa927eece, 0x61c935b7, 0x1ce5ede1, 0x47b13c7a, 0xd2df599c, 0xf2733f55, 0x14ce7918, 0xc737bf73, 0xf7cdea53, 0xfdaa5b5f, 0x3d6f14df, 0x44db8678, 0xaff381ca, 0x68c43eb9, 0x24342c38, 0xa3405fc2, 0x1dc37216, 0xe2250cbc, 0x3c498b28, 0x0d9541ff, 0xa8017139, 0x0cb3de08, 0xb4e49cd8, 0x56c19064, 0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0]; +// Transformations for decryption key expansion +const U1 = [0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3]; +const U2 = [0x00000000, 0x0b0e090d, 0x161c121a, 0x1d121b17, 0x2c382434, 0x27362d39, 0x3a24362e, 0x312a3f23, 0x58704868, 0x537e4165, 0x4e6c5a72, 0x4562537f, 0x74486c5c, 0x7f466551, 0x62547e46, 0x695a774b, 0xb0e090d0, 0xbbee99dd, 0xa6fc82ca, 0xadf28bc7, 0x9cd8b4e4, 0x97d6bde9, 0x8ac4a6fe, 0x81caaff3, 0xe890d8b8, 0xe39ed1b5, 0xfe8ccaa2, 0xf582c3af, 0xc4a8fc8c, 0xcfa6f581, 0xd2b4ee96, 0xd9bae79b, 0x7bdb3bbb, 0x70d532b6, 0x6dc729a1, 0x66c920ac, 0x57e31f8f, 0x5ced1682, 0x41ff0d95, 0x4af10498, 0x23ab73d3, 0x28a57ade, 0x35b761c9, 0x3eb968c4, 0x0f9357e7, 0x049d5eea, 0x198f45fd, 0x12814cf0, 0xcb3bab6b, 0xc035a266, 0xdd27b971, 0xd629b07c, 0xe7038f5f, 0xec0d8652, 0xf11f9d45, 0xfa119448, 0x934be303, 0x9845ea0e, 0x8557f119, 0x8e59f814, 0xbf73c737, 0xb47dce3a, 0xa96fd52d, 0xa261dc20, 0xf6ad766d, 0xfda37f60, 0xe0b16477, 0xebbf6d7a, 0xda955259, 0xd19b5b54, 0xcc894043, 0xc787494e, 0xaedd3e05, 0xa5d33708, 0xb8c12c1f, 0xb3cf2512, 0x82e51a31, 0x89eb133c, 0x94f9082b, 0x9ff70126, 0x464de6bd, 0x4d43efb0, 0x5051f4a7, 0x5b5ffdaa, 0x6a75c289, 0x617bcb84, 0x7c69d093, 0x7767d99e, 0x1e3daed5, 0x1533a7d8, 0x0821bccf, 0x032fb5c2, 0x32058ae1, 0x390b83ec, 0x241998fb, 0x2f1791f6, 0x8d764dd6, 0x867844db, 0x9b6a5fcc, 0x906456c1, 0xa14e69e2, 0xaa4060ef, 0xb7527bf8, 0xbc5c72f5, 0xd50605be, 0xde080cb3, 0xc31a17a4, 0xc8141ea9, 0xf93e218a, 0xf2302887, 0xef223390, 0xe42c3a9d, 0x3d96dd06, 0x3698d40b, 0x2b8acf1c, 0x2084c611, 0x11aef932, 0x1aa0f03f, 0x07b2eb28, 0x0cbce225, 0x65e6956e, 0x6ee89c63, 0x73fa8774, 0x78f48e79, 0x49deb15a, 0x42d0b857, 0x5fc2a340, 0x54ccaa4d, 0xf741ecda, 0xfc4fe5d7, 0xe15dfec0, 0xea53f7cd, 0xdb79c8ee, 0xd077c1e3, 0xcd65daf4, 0xc66bd3f9, 0xaf31a4b2, 0xa43fadbf, 0xb92db6a8, 0xb223bfa5, 0x83098086, 0x8807898b, 0x9515929c, 0x9e1b9b91, 0x47a17c0a, 0x4caf7507, 0x51bd6e10, 0x5ab3671d, 0x6b99583e, 0x60975133, 0x7d854a24, 0x768b4329, 0x1fd13462, 0x14df3d6f, 0x09cd2678, 0x02c32f75, 0x33e91056, 0x38e7195b, 0x25f5024c, 0x2efb0b41, 0x8c9ad761, 0x8794de6c, 0x9a86c57b, 0x9188cc76, 0xa0a2f355, 0xabacfa58, 0xb6bee14f, 0xbdb0e842, 0xd4ea9f09, 0xdfe49604, 0xc2f68d13, 0xc9f8841e, 0xf8d2bb3d, 0xf3dcb230, 0xeecea927, 0xe5c0a02a, 0x3c7a47b1, 0x37744ebc, 0x2a6655ab, 0x21685ca6, 0x10426385, 0x1b4c6a88, 0x065e719f, 0x0d507892, 0x640a0fd9, 0x6f0406d4, 0x72161dc3, 0x791814ce, 0x48322bed, 0x433c22e0, 0x5e2e39f7, 0x552030fa, 0x01ec9ab7, 0x0ae293ba, 0x17f088ad, 0x1cfe81a0, 0x2dd4be83, 0x26dab78e, 0x3bc8ac99, 0x30c6a594, 0x599cd2df, 0x5292dbd2, 0x4f80c0c5, 0x448ec9c8, 0x75a4f6eb, 0x7eaaffe6, 0x63b8e4f1, 0x68b6edfc, 0xb10c0a67, 0xba02036a, 0xa710187d, 0xac1e1170, 0x9d342e53, 0x963a275e, 0x8b283c49, 0x80263544, 0xe97c420f, 0xe2724b02, 0xff605015, 0xf46e5918, 0xc544663b, 0xce4a6f36, 0xd3587421, 0xd8567d2c, 0x7a37a10c, 0x7139a801, 0x6c2bb316, 0x6725ba1b, 0x560f8538, 0x5d018c35, 0x40139722, 0x4b1d9e2f, 0x2247e964, 0x2949e069, 0x345bfb7e, 0x3f55f273, 0x0e7fcd50, 0x0571c45d, 0x1863df4a, 0x136dd647, 0xcad731dc, 0xc1d938d1, 0xdccb23c6, 0xd7c52acb, 0xe6ef15e8, 0xede11ce5, 0xf0f307f2, 0xfbfd0eff, 0x92a779b4, 0x99a970b9, 0x84bb6bae, 0x8fb562a3, 0xbe9f5d80, 0xb591548d, 0xa8834f9a, 0xa38d4697]; +const U3 = [0x00000000, 0x0d0b0e09, 0x1a161c12, 0x171d121b, 0x342c3824, 0x3927362d, 0x2e3a2436, 0x23312a3f, 0x68587048, 0x65537e41, 0x724e6c5a, 0x7f456253, 0x5c74486c, 0x517f4665, 0x4662547e, 0x4b695a77, 0xd0b0e090, 0xddbbee99, 0xcaa6fc82, 0xc7adf28b, 0xe49cd8b4, 0xe997d6bd, 0xfe8ac4a6, 0xf381caaf, 0xb8e890d8, 0xb5e39ed1, 0xa2fe8cca, 0xaff582c3, 0x8cc4a8fc, 0x81cfa6f5, 0x96d2b4ee, 0x9bd9bae7, 0xbb7bdb3b, 0xb670d532, 0xa16dc729, 0xac66c920, 0x8f57e31f, 0x825ced16, 0x9541ff0d, 0x984af104, 0xd323ab73, 0xde28a57a, 0xc935b761, 0xc43eb968, 0xe70f9357, 0xea049d5e, 0xfd198f45, 0xf012814c, 0x6bcb3bab, 0x66c035a2, 0x71dd27b9, 0x7cd629b0, 0x5fe7038f, 0x52ec0d86, 0x45f11f9d, 0x48fa1194, 0x03934be3, 0x0e9845ea, 0x198557f1, 0x148e59f8, 0x37bf73c7, 0x3ab47dce, 0x2da96fd5, 0x20a261dc, 0x6df6ad76, 0x60fda37f, 0x77e0b164, 0x7aebbf6d, 0x59da9552, 0x54d19b5b, 0x43cc8940, 0x4ec78749, 0x05aedd3e, 0x08a5d337, 0x1fb8c12c, 0x12b3cf25, 0x3182e51a, 0x3c89eb13, 0x2b94f908, 0x269ff701, 0xbd464de6, 0xb04d43ef, 0xa75051f4, 0xaa5b5ffd, 0x896a75c2, 0x84617bcb, 0x937c69d0, 0x9e7767d9, 0xd51e3dae, 0xd81533a7, 0xcf0821bc, 0xc2032fb5, 0xe132058a, 0xec390b83, 0xfb241998, 0xf62f1791, 0xd68d764d, 0xdb867844, 0xcc9b6a5f, 0xc1906456, 0xe2a14e69, 0xefaa4060, 0xf8b7527b, 0xf5bc5c72, 0xbed50605, 0xb3de080c, 0xa4c31a17, 0xa9c8141e, 0x8af93e21, 0x87f23028, 0x90ef2233, 0x9de42c3a, 0x063d96dd, 0x0b3698d4, 0x1c2b8acf, 0x112084c6, 0x3211aef9, 0x3f1aa0f0, 0x2807b2eb, 0x250cbce2, 0x6e65e695, 0x636ee89c, 0x7473fa87, 0x7978f48e, 0x5a49deb1, 0x5742d0b8, 0x405fc2a3, 0x4d54ccaa, 0xdaf741ec, 0xd7fc4fe5, 0xc0e15dfe, 0xcdea53f7, 0xeedb79c8, 0xe3d077c1, 0xf4cd65da, 0xf9c66bd3, 0xb2af31a4, 0xbfa43fad, 0xa8b92db6, 0xa5b223bf, 0x86830980, 0x8b880789, 0x9c951592, 0x919e1b9b, 0x0a47a17c, 0x074caf75, 0x1051bd6e, 0x1d5ab367, 0x3e6b9958, 0x33609751, 0x247d854a, 0x29768b43, 0x621fd134, 0x6f14df3d, 0x7809cd26, 0x7502c32f, 0x5633e910, 0x5b38e719, 0x4c25f502, 0x412efb0b, 0x618c9ad7, 0x6c8794de, 0x7b9a86c5, 0x769188cc, 0x55a0a2f3, 0x58abacfa, 0x4fb6bee1, 0x42bdb0e8, 0x09d4ea9f, 0x04dfe496, 0x13c2f68d, 0x1ec9f884, 0x3df8d2bb, 0x30f3dcb2, 0x27eecea9, 0x2ae5c0a0, 0xb13c7a47, 0xbc37744e, 0xab2a6655, 0xa621685c, 0x85104263, 0x881b4c6a, 0x9f065e71, 0x920d5078, 0xd9640a0f, 0xd46f0406, 0xc372161d, 0xce791814, 0xed48322b, 0xe0433c22, 0xf75e2e39, 0xfa552030, 0xb701ec9a, 0xba0ae293, 0xad17f088, 0xa01cfe81, 0x832dd4be, 0x8e26dab7, 0x993bc8ac, 0x9430c6a5, 0xdf599cd2, 0xd25292db, 0xc54f80c0, 0xc8448ec9, 0xeb75a4f6, 0xe67eaaff, 0xf163b8e4, 0xfc68b6ed, 0x67b10c0a, 0x6aba0203, 0x7da71018, 0x70ac1e11, 0x539d342e, 0x5e963a27, 0x498b283c, 0x44802635, 0x0fe97c42, 0x02e2724b, 0x15ff6050, 0x18f46e59, 0x3bc54466, 0x36ce4a6f, 0x21d35874, 0x2cd8567d, 0x0c7a37a1, 0x017139a8, 0x166c2bb3, 0x1b6725ba, 0x38560f85, 0x355d018c, 0x22401397, 0x2f4b1d9e, 0x642247e9, 0x692949e0, 0x7e345bfb, 0x733f55f2, 0x500e7fcd, 0x5d0571c4, 0x4a1863df, 0x47136dd6, 0xdccad731, 0xd1c1d938, 0xc6dccb23, 0xcbd7c52a, 0xe8e6ef15, 0xe5ede11c, 0xf2f0f307, 0xfffbfd0e, 0xb492a779, 0xb999a970, 0xae84bb6b, 0xa38fb562, 0x80be9f5d, 0x8db59154, 0x9aa8834f, 0x97a38d46]; +const U4 = [0x00000000, 0x090d0b0e, 0x121a161c, 0x1b171d12, 0x24342c38, 0x2d392736, 0x362e3a24, 0x3f23312a, 0x48685870, 0x4165537e, 0x5a724e6c, 0x537f4562, 0x6c5c7448, 0x65517f46, 0x7e466254, 0x774b695a, 0x90d0b0e0, 0x99ddbbee, 0x82caa6fc, 0x8bc7adf2, 0xb4e49cd8, 0xbde997d6, 0xa6fe8ac4, 0xaff381ca, 0xd8b8e890, 0xd1b5e39e, 0xcaa2fe8c, 0xc3aff582, 0xfc8cc4a8, 0xf581cfa6, 0xee96d2b4, 0xe79bd9ba, 0x3bbb7bdb, 0x32b670d5, 0x29a16dc7, 0x20ac66c9, 0x1f8f57e3, 0x16825ced, 0x0d9541ff, 0x04984af1, 0x73d323ab, 0x7ade28a5, 0x61c935b7, 0x68c43eb9, 0x57e70f93, 0x5eea049d, 0x45fd198f, 0x4cf01281, 0xab6bcb3b, 0xa266c035, 0xb971dd27, 0xb07cd629, 0x8f5fe703, 0x8652ec0d, 0x9d45f11f, 0x9448fa11, 0xe303934b, 0xea0e9845, 0xf1198557, 0xf8148e59, 0xc737bf73, 0xce3ab47d, 0xd52da96f, 0xdc20a261, 0x766df6ad, 0x7f60fda3, 0x6477e0b1, 0x6d7aebbf, 0x5259da95, 0x5b54d19b, 0x4043cc89, 0x494ec787, 0x3e05aedd, 0x3708a5d3, 0x2c1fb8c1, 0x2512b3cf, 0x1a3182e5, 0x133c89eb, 0x082b94f9, 0x01269ff7, 0xe6bd464d, 0xefb04d43, 0xf4a75051, 0xfdaa5b5f, 0xc2896a75, 0xcb84617b, 0xd0937c69, 0xd99e7767, 0xaed51e3d, 0xa7d81533, 0xbccf0821, 0xb5c2032f, 0x8ae13205, 0x83ec390b, 0x98fb2419, 0x91f62f17, 0x4dd68d76, 0x44db8678, 0x5fcc9b6a, 0x56c19064, 0x69e2a14e, 0x60efaa40, 0x7bf8b752, 0x72f5bc5c, 0x05bed506, 0x0cb3de08, 0x17a4c31a, 0x1ea9c814, 0x218af93e, 0x2887f230, 0x3390ef22, 0x3a9de42c, 0xdd063d96, 0xd40b3698, 0xcf1c2b8a, 0xc6112084, 0xf93211ae, 0xf03f1aa0, 0xeb2807b2, 0xe2250cbc, 0x956e65e6, 0x9c636ee8, 0x877473fa, 0x8e7978f4, 0xb15a49de, 0xb85742d0, 0xa3405fc2, 0xaa4d54cc, 0xecdaf741, 0xe5d7fc4f, 0xfec0e15d, 0xf7cdea53, 0xc8eedb79, 0xc1e3d077, 0xdaf4cd65, 0xd3f9c66b, 0xa4b2af31, 0xadbfa43f, 0xb6a8b92d, 0xbfa5b223, 0x80868309, 0x898b8807, 0x929c9515, 0x9b919e1b, 0x7c0a47a1, 0x75074caf, 0x6e1051bd, 0x671d5ab3, 0x583e6b99, 0x51336097, 0x4a247d85, 0x4329768b, 0x34621fd1, 0x3d6f14df, 0x267809cd, 0x2f7502c3, 0x105633e9, 0x195b38e7, 0x024c25f5, 0x0b412efb, 0xd7618c9a, 0xde6c8794, 0xc57b9a86, 0xcc769188, 0xf355a0a2, 0xfa58abac, 0xe14fb6be, 0xe842bdb0, 0x9f09d4ea, 0x9604dfe4, 0x8d13c2f6, 0x841ec9f8, 0xbb3df8d2, 0xb230f3dc, 0xa927eece, 0xa02ae5c0, 0x47b13c7a, 0x4ebc3774, 0x55ab2a66, 0x5ca62168, 0x63851042, 0x6a881b4c, 0x719f065e, 0x78920d50, 0x0fd9640a, 0x06d46f04, 0x1dc37216, 0x14ce7918, 0x2bed4832, 0x22e0433c, 0x39f75e2e, 0x30fa5520, 0x9ab701ec, 0x93ba0ae2, 0x88ad17f0, 0x81a01cfe, 0xbe832dd4, 0xb78e26da, 0xac993bc8, 0xa59430c6, 0xd2df599c, 0xdbd25292, 0xc0c54f80, 0xc9c8448e, 0xf6eb75a4, 0xffe67eaa, 0xe4f163b8, 0xedfc68b6, 0x0a67b10c, 0x036aba02, 0x187da710, 0x1170ac1e, 0x2e539d34, 0x275e963a, 0x3c498b28, 0x35448026, 0x420fe97c, 0x4b02e272, 0x5015ff60, 0x5918f46e, 0x663bc544, 0x6f36ce4a, 0x7421d358, 0x7d2cd856, 0xa10c7a37, 0xa8017139, 0xb3166c2b, 0xba1b6725, 0x8538560f, 0x8c355d01, 0x97224013, 0x9e2f4b1d, 0xe9642247, 0xe0692949, 0xfb7e345b, 0xf2733f55, 0xcd500e7f, 0xc45d0571, 0xdf4a1863, 0xd647136d, 0x31dccad7, 0x38d1c1d9, 0x23c6dccb, 0x2acbd7c5, 0x15e8e6ef, 0x1ce5ede1, 0x07f2f0f3, 0x0efffbfd, 0x79b492a7, 0x70b999a9, 0x6bae84bb, 0x62a38fb5, 0x5d80be9f, 0x548db591, 0x4f9aa883, 0x4697a38d]; +function convertToInt32(bytes) { + const result = []; + for (let i = 0; i < bytes.length; i += 4) { + result.push((bytes[i] << 24) | (bytes[i + 1] << 16) | (bytes[i + 2] << 8) | bytes[i + 3]); + } + return result; +} +class AES { + get key() { return __classPrivateFieldGet$2(this, _AES_key, "f").slice(); } + constructor(key) { + _AES_key.set(this, void 0); + _AES_Kd.set(this, void 0); + _AES_Ke.set(this, void 0); + if (!(this instanceof AES)) { + throw Error('AES must be instanitated with `new`'); + } + __classPrivateFieldSet$2(this, _AES_key, new Uint8Array(key), "f"); + const rounds = numberOfRounds[this.key.length]; + if (rounds == null) { + throw new TypeError('invalid key size (must be 16, 24 or 32 bytes)'); + } + // encryption round keys + __classPrivateFieldSet$2(this, _AES_Ke, [], "f"); + // decryption round keys + __classPrivateFieldSet$2(this, _AES_Kd, [], "f"); + for (let i = 0; i <= rounds; i++) { + __classPrivateFieldGet$2(this, _AES_Ke, "f").push([0, 0, 0, 0]); + __classPrivateFieldGet$2(this, _AES_Kd, "f").push([0, 0, 0, 0]); + } + const roundKeyCount = (rounds + 1) * 4; + const KC = this.key.length / 4; + // convert the key into ints + const tk = convertToInt32(this.key); + // copy values into round key arrays + let index; + for (let i = 0; i < KC; i++) { + index = i >> 2; + __classPrivateFieldGet$2(this, _AES_Ke, "f")[index][i % 4] = tk[i]; + __classPrivateFieldGet$2(this, _AES_Kd, "f")[rounds - index][i % 4] = tk[i]; + } + // key expansion (fips-197 section 5.2) + let rconpointer = 0; + let t = KC, tt; + while (t < roundKeyCount) { + tt = tk[KC - 1]; + tk[0] ^= ((S[(tt >> 16) & 0xFF] << 24) ^ + (S[(tt >> 8) & 0xFF] << 16) ^ + (S[tt & 0xFF] << 8) ^ + S[(tt >> 24) & 0xFF] ^ + (rcon[rconpointer] << 24)); + rconpointer += 1; + // key expansion (for non-256 bit) + if (KC != 8) { + for (let i = 1; i < KC; i++) { + tk[i] ^= tk[i - 1]; + } + // key expansion for 256-bit keys is "slightly different" (fips-197) + } + else { + for (let i = 1; i < (KC / 2); i++) { + tk[i] ^= tk[i - 1]; + } + tt = tk[(KC / 2) - 1]; + tk[KC / 2] ^= (S[tt & 0xFF] ^ + (S[(tt >> 8) & 0xFF] << 8) ^ + (S[(tt >> 16) & 0xFF] << 16) ^ + (S[(tt >> 24) & 0xFF] << 24)); + for (let i = (KC / 2) + 1; i < KC; i++) { + tk[i] ^= tk[i - 1]; + } + } + // copy values into round key arrays + let i = 0, r, c; + while (i < KC && t < roundKeyCount) { + r = t >> 2; + c = t % 4; + __classPrivateFieldGet$2(this, _AES_Ke, "f")[r][c] = tk[i]; + __classPrivateFieldGet$2(this, _AES_Kd, "f")[rounds - r][c] = tk[i++]; + t++; + } + } + // inverse-cipher-ify the decryption round key (fips-197 section 5.3) + for (let r = 1; r < rounds; r++) { + for (let c = 0; c < 4; c++) { + tt = __classPrivateFieldGet$2(this, _AES_Kd, "f")[r][c]; + __classPrivateFieldGet$2(this, _AES_Kd, "f")[r][c] = (U1[(tt >> 24) & 0xFF] ^ + U2[(tt >> 16) & 0xFF] ^ + U3[(tt >> 8) & 0xFF] ^ + U4[tt & 0xFF]); + } + } + } + encrypt(plaintext) { + if (plaintext.length != 16) { + throw new TypeError('invalid plaintext size (must be 16 bytes)'); + } + const rounds = __classPrivateFieldGet$2(this, _AES_Ke, "f").length - 1; + const a = [0, 0, 0, 0]; + // convert plaintext to (ints ^ key) + let t = convertToInt32(plaintext); + for (let i = 0; i < 4; i++) { + t[i] ^= __classPrivateFieldGet$2(this, _AES_Ke, "f")[0][i]; + } + // apply round transforms + for (let r = 1; r < rounds; r++) { + for (let i = 0; i < 4; i++) { + a[i] = (T1[(t[i] >> 24) & 0xff] ^ + T2[(t[(i + 1) % 4] >> 16) & 0xff] ^ + T3[(t[(i + 2) % 4] >> 8) & 0xff] ^ + T4[t[(i + 3) % 4] & 0xff] ^ + __classPrivateFieldGet$2(this, _AES_Ke, "f")[r][i]); + } + t = a.slice(); + } + // the last round is special + const result = new Uint8Array(16); + let tt = 0; + for (let i = 0; i < 4; i++) { + tt = __classPrivateFieldGet$2(this, _AES_Ke, "f")[rounds][i]; + result[4 * i] = (S[(t[i] >> 24) & 0xff] ^ (tt >> 24)) & 0xff; + result[4 * i + 1] = (S[(t[(i + 1) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff; + result[4 * i + 2] = (S[(t[(i + 2) % 4] >> 8) & 0xff] ^ (tt >> 8)) & 0xff; + result[4 * i + 3] = (S[t[(i + 3) % 4] & 0xff] ^ tt) & 0xff; + } + return result; + } + decrypt(ciphertext) { + if (ciphertext.length != 16) { + throw new TypeError('invalid ciphertext size (must be 16 bytes)'); + } + const rounds = __classPrivateFieldGet$2(this, _AES_Kd, "f").length - 1; + const a = [0, 0, 0, 0]; + // convert plaintext to (ints ^ key) + let t = convertToInt32(ciphertext); + for (let i = 0; i < 4; i++) { + t[i] ^= __classPrivateFieldGet$2(this, _AES_Kd, "f")[0][i]; + } + // apply round transforms + for (let r = 1; r < rounds; r++) { + for (let i = 0; i < 4; i++) { + a[i] = (T5[(t[i] >> 24) & 0xff] ^ + T6[(t[(i + 3) % 4] >> 16) & 0xff] ^ + T7[(t[(i + 2) % 4] >> 8) & 0xff] ^ + T8[t[(i + 1) % 4] & 0xff] ^ + __classPrivateFieldGet$2(this, _AES_Kd, "f")[r][i]); + } + t = a.slice(); + } + // the last round is special + const result = new Uint8Array(16); + let tt = 0; + for (let i = 0; i < 4; i++) { + tt = __classPrivateFieldGet$2(this, _AES_Kd, "f")[rounds][i]; + result[4 * i] = (Si[(t[i] >> 24) & 0xff] ^ (tt >> 24)) & 0xff; + result[4 * i + 1] = (Si[(t[(i + 3) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff; + result[4 * i + 2] = (Si[(t[(i + 2) % 4] >> 8) & 0xff] ^ (tt >> 8)) & 0xff; + result[4 * i + 3] = (Si[t[(i + 1) % 4] & 0xff] ^ tt) & 0xff; + } + return result; + } +} +_AES_key = new WeakMap(), _AES_Kd = new WeakMap(), _AES_Ke = new WeakMap(); + +class ModeOfOperation { + constructor(name, key, cls) { + if (cls && !(this instanceof cls)) { + throw new Error(`${name} must be instantiated with "new"`); + } + Object.defineProperties(this, { + aes: { enumerable: true, value: new AES(key) }, + name: { enumerable: true, value: name } + }); + } +} + +// Cipher Block Chaining +var __classPrivateFieldSet$1 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +}; +var __classPrivateFieldGet$1 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +}; +var _CBC_iv, _CBC_lastBlock; +class CBC extends ModeOfOperation { + constructor(key, iv) { + super("ECC", key, CBC); + _CBC_iv.set(this, void 0); + _CBC_lastBlock.set(this, void 0); + if (iv) { + if (iv.length % 16) { + throw new TypeError("invalid iv size (must be 16 bytes)"); + } + __classPrivateFieldSet$1(this, _CBC_iv, new Uint8Array(iv), "f"); + } + else { + __classPrivateFieldSet$1(this, _CBC_iv, new Uint8Array(16), "f"); + } + __classPrivateFieldSet$1(this, _CBC_lastBlock, this.iv, "f"); + } + get iv() { return new Uint8Array(__classPrivateFieldGet$1(this, _CBC_iv, "f")); } + encrypt(plaintext) { + if (plaintext.length % 16) { + throw new TypeError("invalid plaintext size (must be multiple of 16 bytes)"); + } + const ciphertext = new Uint8Array(plaintext.length); + for (let i = 0; i < plaintext.length; i += 16) { + for (let j = 0; j < 16; j++) { + __classPrivateFieldGet$1(this, _CBC_lastBlock, "f")[j] ^= plaintext[i + j]; + } + __classPrivateFieldSet$1(this, _CBC_lastBlock, this.aes.encrypt(__classPrivateFieldGet$1(this, _CBC_lastBlock, "f")), "f"); + ciphertext.set(__classPrivateFieldGet$1(this, _CBC_lastBlock, "f"), i); + } + return ciphertext; + } + decrypt(ciphertext) { + if (ciphertext.length % 16) { + throw new TypeError("invalid ciphertext size (must be multiple of 16 bytes)"); + } + const plaintext = new Uint8Array(ciphertext.length); + for (let i = 0; i < ciphertext.length; i += 16) { + const block = this.aes.decrypt(ciphertext.subarray(i, i + 16)); + for (let j = 0; j < 16; j++) { + plaintext[i + j] = block[j] ^ __classPrivateFieldGet$1(this, _CBC_lastBlock, "f")[j]; + __classPrivateFieldGet$1(this, _CBC_lastBlock, "f")[j] = ciphertext[i + j]; + } + } + return plaintext; + } +} +_CBC_iv = new WeakMap(), _CBC_lastBlock = new WeakMap(); + +// Counter Mode +var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +}; +var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +}; +var _CTR_remaining, _CTR_remainingIndex, _CTR_counter; +class CTR extends ModeOfOperation { + constructor(key, initialValue) { + super("CTR", key, CTR); + // Remaining bytes for the one-time pad + _CTR_remaining.set(this, void 0); + _CTR_remainingIndex.set(this, void 0); + // The current counter + _CTR_counter.set(this, void 0); + __classPrivateFieldSet(this, _CTR_counter, new Uint8Array(16), "f"); + __classPrivateFieldGet(this, _CTR_counter, "f").fill(0); + __classPrivateFieldSet(this, _CTR_remaining, __classPrivateFieldGet(this, _CTR_counter, "f"), "f"); // This will be discarded immediately + __classPrivateFieldSet(this, _CTR_remainingIndex, 16, "f"); + if (initialValue == null) { + initialValue = 1; + } + if (typeof (initialValue) === "number") { + this.setCounterValue(initialValue); + } + else { + this.setCounterBytes(initialValue); + } + } + get counter() { return new Uint8Array(__classPrivateFieldGet(this, _CTR_counter, "f")); } + setCounterValue(value) { + if (!Number.isInteger(value) || value < 0 || value > Number.MAX_SAFE_INTEGER) { + throw new TypeError("invalid counter initial integer value"); + } + for (let index = 15; index >= 0; --index) { + __classPrivateFieldGet(this, _CTR_counter, "f")[index] = value % 256; + value = Math.floor(value / 256); + } + } + setCounterBytes(value) { + if (value.length !== 16) { + throw new TypeError("invalid counter initial Uint8Array value length"); + } + __classPrivateFieldGet(this, _CTR_counter, "f").set(value); + } + increment() { + for (let i = 15; i >= 0; i--) { + if (__classPrivateFieldGet(this, _CTR_counter, "f")[i] === 255) { + __classPrivateFieldGet(this, _CTR_counter, "f")[i] = 0; + } + else { + __classPrivateFieldGet(this, _CTR_counter, "f")[i]++; + break; + } + } + } + encrypt(plaintext) { + var _a, _b; + const crypttext = new Uint8Array(plaintext); + for (let i = 0; i < crypttext.length; i++) { + if (__classPrivateFieldGet(this, _CTR_remainingIndex, "f") === 16) { + __classPrivateFieldSet(this, _CTR_remaining, this.aes.encrypt(__classPrivateFieldGet(this, _CTR_counter, "f")), "f"); + __classPrivateFieldSet(this, _CTR_remainingIndex, 0, "f"); + this.increment(); + } + crypttext[i] ^= __classPrivateFieldGet(this, _CTR_remaining, "f")[__classPrivateFieldSet(this, _CTR_remainingIndex, (_b = __classPrivateFieldGet(this, _CTR_remainingIndex, "f"), _a = _b++, _b), "f"), _a]; + } + return crypttext; + } + decrypt(ciphertext) { + return this.encrypt(ciphertext); + } +} +_CTR_remaining = new WeakMap(), _CTR_remainingIndex = new WeakMap(), _CTR_counter = new WeakMap(); + +function pkcs7Strip(data) { + if (data.length < 16) { + throw new TypeError('PKCS#7 invalid length'); + } + const padder = data[data.length - 1]; + if (padder > 16) { + throw new TypeError('PKCS#7 padding byte out of range'); + } + const length = data.length - padder; + for (let i = 0; i < padder; i++) { + if (data[length + i] !== padder) { + throw new TypeError('PKCS#7 invalid padding byte'); + } + } + return new Uint8Array(data.subarray(0, length)); +} + +/** + * @_ignore + */ +function looseArrayify(hexString) { + if (typeof (hexString) === "string" && !hexString.startsWith("0x")) { + hexString = "0x" + hexString; + } + return getBytesCopy(hexString); +} +function zpad$1(value, length) { + value = String(value); + while (value.length < length) { + value = '0' + value; + } + return value; +} +function getPassword(password) { + if (typeof (password) === 'string') { + return toUtf8Bytes$1(password, "NFKC"); + } + return getBytesCopy(password); +} +function spelunk(object, _path) { + const match = _path.match(/^([a-z0-9$_.-]*)(:([a-z]+))?(!)?$/i); + assertArgument(match != null, "invalid path", "path", _path); + const path = match[1]; + const type = match[3]; + const reqd = (match[4] === "!"); + let cur = object; + for (const comp of path.toLowerCase().split('.')) { + // Search for a child object with a case-insensitive matching key + if (Array.isArray(cur)) { + if (!comp.match(/^[0-9]+$/)) { + break; + } + cur = cur[parseInt(comp)]; + } + else if (typeof (cur) === "object") { + let found = null; + for (const key in cur) { + if (key.toLowerCase() === comp) { + found = cur[key]; + break; + } + } + cur = found; + } + else { + cur = null; + } + if (cur == null) { + break; + } + } + assertArgument(!reqd || cur != null, "missing required value", "path", path); + if (type && cur != null) { + if (type === "int") { + if (typeof (cur) === "string" && cur.match(/^-?[0-9]+$/)) { + return parseInt(cur); + } + else if (Number.isSafeInteger(cur)) { + return cur; + } + } + if (type === "number") { + if (typeof (cur) === "string" && cur.match(/^-?[0-9.]*$/)) { + return parseFloat(cur); + } + } + if (type === "data") { + if (typeof (cur) === "string") { + return looseArrayify(cur); + } + } + if (type === "array" && Array.isArray(cur)) { + return cur; + } + if (type === typeof (cur)) { + return cur; + } + assertArgument(false, `wrong type found for ${type} `, "path", path); + } + return cur; +} +/* +export function follow(object: any, path: string): null | string { + let currentChild = object; + + for (const comp of path.toLowerCase().split('/')) { + + // Search for a child object with a case-insensitive matching key + let matchingChild = null; + for (const key in currentChild) { + if (key.toLowerCase() === comp) { + matchingChild = currentChild[key]; + break; + } + } + + if (matchingChild === null) { return null; } + + currentChild = matchingChild; + } + + return currentChild; +} + +// "path/to/something:type!" +export function followRequired(data: any, path: string): string { + const value = follow(data, path); + if (value != null) { return value; } + return logger.throwArgumentError("invalid value", `data:${ path }`, + JSON.stringify(data)); +} +*/ +// See: https://www.ietf.org/rfc/rfc4122.txt (Section 4.4) +/* +export function uuidV4(randomBytes: BytesLike): string { + const bytes = getBytes(randomBytes, "randomBytes"); + + // Section: 4.1.3: + // - time_hi_and_version[12:16] = 0b0100 + bytes[6] = (bytes[6] & 0x0f) | 0x40; + + // Section 4.4 + // - clock_seq_hi_and_reserved[6] = 0b0 + // - clock_seq_hi_and_reserved[7] = 0b1 + bytes[8] = (bytes[8] & 0x3f) | 0x80; + + const value = hexlify(bytes); + + return [ + value.substring(2, 10), + value.substring(10, 14), + value.substring(14, 18), + value.substring(18, 22), + value.substring(22, 34), + ].join("-"); +} +*/ + +/** + * The JSON Wallet formats allow a simple way to store the private + * keys needed in Ethereum along with related information and allows + * for extensible forms of encryption. + * + * These utilities facilitate decrypting and encrypting the most common + * JSON Wallet formats. + * + * @_subsection: api/wallet:JSON Wallets [json-wallets] + */ +const defaultPath$1 = "m/44'/60'/0'/0/0"; +/** + * Returns true if %%json%% is a valid JSON Keystore Wallet. + */ +function isKeystoreJson(json) { + try { + const data = JSON.parse(json); + const version = ((data.version != null) ? parseInt(data.version) : 0); + if (version === 3) { + return true; + } + } + catch (error) { } + return false; +} +function decrypt(data, key, ciphertext) { + const cipher = spelunk(data, "crypto.cipher:string"); + if (cipher === "aes-128-ctr") { + const iv = spelunk(data, "crypto.cipherparams.iv:data!"); + const aesCtr = new CTR(key, iv); + return hexlify(aesCtr.decrypt(ciphertext)); + } + assert$5(false, "unsupported cipher", "UNSUPPORTED_OPERATION", { + operation: "decrypt" + }); +} +function getAccount(data, _key) { + const key = getBytes(_key); + const ciphertext = spelunk(data, "crypto.ciphertext:data!"); + const computedMAC = hexlify(keccak256$1(concat$3([key.slice(16, 32), ciphertext]))).substring(2); + assertArgument(computedMAC === spelunk(data, "crypto.mac:string!").toLowerCase(), "incorrect password", "password", "[ REDACTED ]"); + const privateKey = decrypt(data, key.slice(0, 16), ciphertext); + const address = computeAddress(privateKey); + if (data.address) { + let check = data.address.toLowerCase(); + if (!check.startsWith("0x")) { + check = "0x" + check; + } + assertArgument(getAddress(check) === address, "keystore address/privateKey mismatch", "address", data.address); + } + const account = { address, privateKey }; + // Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase + const version = spelunk(data, "x-ethers.version:string"); + if (version === "0.1") { + const mnemonicKey = key.slice(32, 64); + const mnemonicCiphertext = spelunk(data, "x-ethers.mnemonicCiphertext:data!"); + const mnemonicIv = spelunk(data, "x-ethers.mnemonicCounter:data!"); + const mnemonicAesCtr = new CTR(mnemonicKey, mnemonicIv); + account.mnemonic = { + path: (spelunk(data, "x-ethers.path:string") || defaultPath$1), + locale: (spelunk(data, "x-ethers.locale:string") || "en"), + entropy: hexlify(getBytes(mnemonicAesCtr.decrypt(mnemonicCiphertext))) + }; + } + return account; +} +function getDecryptKdfParams(data) { + const kdf = spelunk(data, "crypto.kdf:string"); + if (kdf && typeof (kdf) === "string") { + if (kdf.toLowerCase() === "scrypt") { + const salt = spelunk(data, "crypto.kdfparams.salt:data!"); + const N = spelunk(data, "crypto.kdfparams.n:int!"); + const r = spelunk(data, "crypto.kdfparams.r:int!"); + const p = spelunk(data, "crypto.kdfparams.p:int!"); + // Make sure N is a power of 2 + assertArgument(N > 0 && (N & (N - 1)) === 0, "invalid kdf.N", "kdf.N", N); + assertArgument(r > 0 && p > 0, "invalid kdf", "kdf", kdf); + const dkLen = spelunk(data, "crypto.kdfparams.dklen:int!"); + assertArgument(dkLen === 32, "invalid kdf.dklen", "kdf.dflen", dkLen); + return { name: "scrypt", salt, N, r, p, dkLen: 64 }; + } + else if (kdf.toLowerCase() === "pbkdf2") { + const salt = spelunk(data, "crypto.kdfparams.salt:data!"); + const prf = spelunk(data, "crypto.kdfparams.prf:string!"); + const algorithm = prf.split("-").pop(); + assertArgument(algorithm === "sha256" || algorithm === "sha512", "invalid kdf.pdf", "kdf.pdf", prf); + const count = spelunk(data, "crypto.kdfparams.c:int!"); + const dkLen = spelunk(data, "crypto.kdfparams.dklen:int!"); + assertArgument(dkLen === 32, "invalid kdf.dklen", "kdf.dklen", dkLen); + return { name: "pbkdf2", salt, count, dkLen, algorithm }; + } + } + assertArgument(false, "unsupported key-derivation function", "kdf", kdf); +} +/** + * Returns the account details for the JSON Keystore Wallet %%json%% + * using %%password%%. + * + * It is preferred to use the [async version](decryptKeystoreJson) + * instead, which allows a [[ProgressCallback]] to keep the user informed + * as to the decryption status. + * + * This method will block the event loop (freezing all UI) until decryption + * is complete, which can take quite some time, depending on the wallet + * paramters and platform. + */ +function decryptKeystoreJsonSync(json, _password) { + const data = JSON.parse(json); + const password = getPassword(_password); + const params = getDecryptKdfParams(data); + if (params.name === "pbkdf2") { + const { salt, count, dkLen, algorithm } = params; + const key = pbkdf2$1(password, salt, count, dkLen, algorithm); + return getAccount(data, key); + } + assert$5(params.name === "scrypt", "cannot be reached", "UNKNOWN_ERROR", { params }); + const { salt, N, r, p, dkLen } = params; + const key = scryptSync(password, salt, N, r, p, dkLen); + return getAccount(data, key); +} +function stall$1(duration) { + return new Promise((resolve) => { setTimeout(() => { resolve(); }, duration); }); +} +/** + * Resolves to the decrypted JSON Keystore Wallet %%json%% using the + * %%password%%. + * + * If provided, %%progress%% will be called periodically during the + * decrpytion to provide feedback, and if the function returns + * ``false`` will halt decryption. + * + * The %%progressCallback%% will **always** receive ``0`` before + * decryption begins and ``1`` when complete. + */ +async function decryptKeystoreJson(json, _password, progress) { + const data = JSON.parse(json); + const password = getPassword(_password); + const params = getDecryptKdfParams(data); + if (params.name === "pbkdf2") { + if (progress) { + progress(0); + await stall$1(0); + } + const { salt, count, dkLen, algorithm } = params; + const key = pbkdf2$1(password, salt, count, dkLen, algorithm); + if (progress) { + progress(1); + await stall$1(0); + } + return getAccount(data, key); + } + assert$5(params.name === "scrypt", "cannot be reached", "UNKNOWN_ERROR", { params }); + const { salt, N, r, p, dkLen } = params; + const key = await scrypt(password, salt, N, r, p, dkLen, progress); + return getAccount(data, key); +} +function getEncryptKdfParams(options) { + // Check/generate the salt + const salt = (options.salt != null) ? getBytes(options.salt, "options.salt") : randomBytes$1(32); + // Override the scrypt password-based key derivation function parameters + let N = (1 << 17), r = 8, p = 1; + if (options.scrypt) { + if (options.scrypt.N) { + N = options.scrypt.N; + } + if (options.scrypt.r) { + r = options.scrypt.r; + } + if (options.scrypt.p) { + p = options.scrypt.p; + } + } + assertArgument(typeof (N) === "number" && N > 0 && Number.isSafeInteger(N) && (BigInt(N) & BigInt(N - 1)) === BigInt(0), "invalid scrypt N parameter", "options.N", N); + assertArgument(typeof (r) === "number" && r > 0 && Number.isSafeInteger(r), "invalid scrypt r parameter", "options.r", r); + assertArgument(typeof (p) === "number" && p > 0 && Number.isSafeInteger(p), "invalid scrypt p parameter", "options.p", p); + return { name: "scrypt", dkLen: 32, salt, N, r, p }; +} +function _encryptKeystore(key, kdf, account, options) { + const privateKey = getBytes(account.privateKey, "privateKey"); + // Override initialization vector + const iv = (options.iv != null) ? getBytes(options.iv, "options.iv") : randomBytes$1(16); + assertArgument(iv.length === 16, "invalid options.iv length", "options.iv", options.iv); + // Override the uuid + const uuidRandom = (options.uuid != null) ? getBytes(options.uuid, "options.uuid") : randomBytes$1(16); + assertArgument(uuidRandom.length === 16, "invalid options.uuid length", "options.uuid", options.iv); + // This will be used to encrypt the wallet (as per Web3 secret storage) + // - 32 bytes As normal for the Web3 secret storage (derivedKey, macPrefix) + // - 32 bytes AES key to encrypt mnemonic with (required here to be Ethers Wallet) + const derivedKey = key.slice(0, 16); + const macPrefix = key.slice(16, 32); + // Encrypt the private key + const aesCtr = new CTR(derivedKey, iv); + const ciphertext = getBytes(aesCtr.encrypt(privateKey)); + // Compute the message authentication code, used to check the password + const mac = keccak256$1(concat$3([macPrefix, ciphertext])); + // See: https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition + const data = { + address: account.address.substring(2).toLowerCase(), + id: uuidV4(uuidRandom), + version: 3, + Crypto: { + cipher: "aes-128-ctr", + cipherparams: { + iv: hexlify(iv).substring(2), + }, + ciphertext: hexlify(ciphertext).substring(2), + kdf: "scrypt", + kdfparams: { + salt: hexlify(kdf.salt).substring(2), + n: kdf.N, + dklen: 32, + p: kdf.p, + r: kdf.r + }, + mac: mac.substring(2) + } + }; + // If we have a mnemonic, encrypt it into the JSON wallet + if (account.mnemonic) { + const client = (options.client != null) ? options.client : `ethers/${version$4}`; + const path = account.mnemonic.path || defaultPath$1; + const locale = account.mnemonic.locale || "en"; + const mnemonicKey = key.slice(32, 64); + const entropy = getBytes(account.mnemonic.entropy, "account.mnemonic.entropy"); + const mnemonicIv = randomBytes$1(16); + const mnemonicAesCtr = new CTR(mnemonicKey, mnemonicIv); + const mnemonicCiphertext = getBytes(mnemonicAesCtr.encrypt(entropy)); + const now = new Date(); + const timestamp = (now.getUTCFullYear() + "-" + + zpad$1(now.getUTCMonth() + 1, 2) + "-" + + zpad$1(now.getUTCDate(), 2) + "T" + + zpad$1(now.getUTCHours(), 2) + "-" + + zpad$1(now.getUTCMinutes(), 2) + "-" + + zpad$1(now.getUTCSeconds(), 2) + ".0Z"); + const gethFilename = ("UTC--" + timestamp + "--" + data.address); + data["x-ethers"] = { + client, gethFilename, path, locale, + mnemonicCounter: hexlify(mnemonicIv).substring(2), + mnemonicCiphertext: hexlify(mnemonicCiphertext).substring(2), + version: "0.1" + }; + } + return JSON.stringify(data); +} +/** + * Return the JSON Keystore Wallet for %%account%% encrypted with + * %%password%%. + * + * The %%options%% can be used to tune the password-based key + * derivation function parameters, explicitly set the random values + * used. Any provided [[ProgressCallback]] is ignord. + */ +function encryptKeystoreJsonSync(account, password, options) { + if (options == null) { + options = {}; + } + const passwordBytes = getPassword(password); + const kdf = getEncryptKdfParams(options); + const key = scryptSync(passwordBytes, kdf.salt, kdf.N, kdf.r, kdf.p, 64); + return _encryptKeystore(getBytes(key), kdf, account, options); +} +/** + * Resolved to the JSON Keystore Wallet for %%account%% encrypted + * with %%password%%. + * + * The %%options%% can be used to tune the password-based key + * derivation function parameters, explicitly set the random values + * used and provide a [[ProgressCallback]] to receive periodic updates + * on the completion status.. + */ +async function encryptKeystoreJson(account, password, options) { + if (options == null) { + options = {}; + } + const passwordBytes = getPassword(password); + const kdf = getEncryptKdfParams(options); + const key = await scrypt(passwordBytes, kdf.salt, kdf.N, kdf.r, kdf.p, 64, options.progressCallback); + return _encryptKeystore(getBytes(key), kdf, account, options); +} + +/** + * Explain HD Wallets.. + * + * @_subsection: api/wallet:HD Wallets [hd-wallets] + */ +/** + * The default derivation path for Ethereum HD Nodes. (i.e. ``"m/44'/60'/0'/0/0"``) + */ +const defaultPath = "m/44'/60'/0'/0/0"; +// "Bitcoin seed" +const MasterSecret = new Uint8Array([66, 105, 116, 99, 111, 105, 110, 32, 115, 101, 101, 100]); +const HardenedBit = 0x80000000; +const N = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"); +const Nibbles = "0123456789abcdef"; +function zpad(value, length) { + let result = ""; + while (value) { + result = Nibbles[value % 16] + result; + value = Math.trunc(value / 16); + } + while (result.length < length * 2) { + result = "0" + result; + } + return "0x" + result; +} +function encodeBase58Check(_value) { + const value = getBytes(_value); + const check = dataSlice(sha256(sha256(value)), 0, 4); + const bytes = concat$3([value, check]); + return encodeBase58(bytes); +} +const _guard = {}; +function ser_I(index, chainCode, publicKey, privateKey) { + const data = new Uint8Array(37); + if (index & HardenedBit) { + assert$5(privateKey != null, "cannot derive child of neutered node", "UNSUPPORTED_OPERATION", { + operation: "deriveChild" + }); + // Data = 0x00 || ser_256(k_par) + data.set(getBytes(privateKey), 1); + } + else { + // Data = ser_p(point(k_par)) + data.set(getBytes(publicKey)); + } + // Data += ser_32(i) + for (let i = 24; i >= 0; i -= 8) { + data[33 + (i >> 3)] = ((index >> (24 - i)) & 0xff); + } + const I = getBytes(computeHmac("sha512", chainCode, data)); + return { IL: I.slice(0, 32), IR: I.slice(32) }; +} +function derivePath(node, path) { + const components = path.split("/"); + assertArgument(components.length > 0, "invalid path", "path", path); + if (components[0] === "m") { + assertArgument(node.depth === 0, `cannot derive root path (i.e. path starting with "m/") for a node at non-zero depth ${node.depth}`, "path", path); + components.shift(); + } + let result = node; + for (let i = 0; i < components.length; i++) { + const component = components[i]; + if (component.match(/^[0-9]+'$/)) { + const index = parseInt(component.substring(0, component.length - 1)); + assertArgument(index < HardenedBit, "invalid path index", `path[${i}]`, component); + result = result.deriveChild(HardenedBit + index); + } + else if (component.match(/^[0-9]+$/)) { + const index = parseInt(component); + assertArgument(index < HardenedBit, "invalid path index", `path[${i}]`, component); + result = result.deriveChild(index); + } + else { + assertArgument(false, "invalid path component", `path[${i}]`, component); + } + } + return result; +} +/** + * An **HDNodeWallet** is a [[Signer]] backed by the private key derived + * from an HD Node using the [[link-bip-32]] stantard. + * + * An HD Node forms a hierarchal structure with each HD Node having a + * private key and the ability to derive child HD Nodes, defined by + * a path indicating the index of each child. + */ +class HDNodeWallet extends BaseWallet { + /** + * The compressed public key. + */ + publicKey; + /** + * The fingerprint. + * + * A fingerprint allows quick qay to detect parent and child nodes, + * but developers should be prepared to deal with collisions as it + * is only 4 bytes. + */ + fingerprint; + /** + * The parent fingerprint. + */ + parentFingerprint; + /** + * The mnemonic used to create this HD Node, if available. + * + * Sources such as extended keys do not encode the mnemonic, in + * which case this will be ``null``. + */ + mnemonic; + /** + * The chaincode, which is effectively a public key used + * to derive children. + */ + chainCode; + /** + * The derivation path of this wallet. + * + * Since extended keys do not provider full path details, this + * may be ``null``, if instantiated from a source that does not + * enocde it. + */ + path; + /** + * The child index of this wallet. Values over ``2 *\* 31`` indicate + * the node is hardened. + */ + index; + /** + * The depth of this wallet, which is the number of components + * in its path. + */ + depth; + /** + * @private + */ + constructor(guard, signingKey, parentFingerprint, chainCode, path, index, depth, mnemonic, provider) { + super(signingKey, provider); + assertPrivate(guard, _guard, "HDNodeWallet"); + defineProperties(this, { publicKey: signingKey.compressedPublicKey }); + const fingerprint = dataSlice(ripemd160(sha256(this.publicKey)), 0, 4); + defineProperties(this, { + parentFingerprint, fingerprint, + chainCode, path, index, depth + }); + defineProperties(this, { mnemonic }); + } + connect(provider) { + return new HDNodeWallet(_guard, this.signingKey, this.parentFingerprint, this.chainCode, this.path, this.index, this.depth, this.mnemonic, provider); + } + #account() { + const account = { address: this.address, privateKey: this.privateKey }; + const m = this.mnemonic; + if (this.path && m && m.wordlist.locale === "en" && m.password === "") { + account.mnemonic = { + path: this.path, + locale: "en", + entropy: m.entropy + }; + } + return account; + } + /** + * Resolves to a [JSON Keystore Wallet](json-wallets) encrypted with + * %%password%%. + * + * If %%progressCallback%% is specified, it will receive periodic + * updates as the encryption process progreses. + */ + async encrypt(password, progressCallback) { + return await encryptKeystoreJson(this.#account(), password, { progressCallback }); + } + /** + * Returns a [JSON Keystore Wallet](json-wallets) encryped with + * %%password%%. + * + * It is preferred to use the [async version](encrypt) instead, + * which allows a [[ProgressCallback]] to keep the user informed. + * + * This method will block the event loop (freezing all UI) until + * it is complete, which may be a non-trivial duration. + */ + encryptSync(password) { + return encryptKeystoreJsonSync(this.#account(), password); + } + /** + * The extended key. + * + * This key will begin with the prefix ``xpriv`` and can be used to + * reconstruct this HD Node to derive its children. + */ + get extendedKey() { + // We only support the mainnet values for now, but if anyone needs + // testnet values, let me know. I believe current sentiment is that + // we should always use mainnet, and use BIP-44 to derive the network + // - Mainnet: public=0x0488B21E, private=0x0488ADE4 + // - Testnet: public=0x043587CF, private=0x04358394 + assert$5(this.depth < 256, "Depth too deep", "UNSUPPORTED_OPERATION", { operation: "extendedKey" }); + return encodeBase58Check(concat$3([ + "0x0488ADE4", zpad(this.depth, 1), this.parentFingerprint, + zpad(this.index, 4), this.chainCode, + concat$3(["0x00", this.privateKey]) + ])); + } + /** + * Returns true if this wallet has a path, providing a Type Guard + * that the path is non-null. + */ + hasPath() { return (this.path != null); } + /** + * Returns a neutered HD Node, which removes the private details + * of an HD Node. + * + * A neutered node has no private key, but can be used to derive + * child addresses and other public data about the HD Node. + */ + neuter() { + return new HDNodeVoidWallet(_guard, this.address, this.publicKey, this.parentFingerprint, this.chainCode, this.path, this.index, this.depth, this.provider); + } + /** + * Return the child for %%index%%. + */ + deriveChild(_index) { + const index = getNumber(_index, "index"); + assertArgument(index <= 0xffffffff, "invalid index", "index", index); + // Base path + let path = this.path; + if (path) { + path += "/" + (index & ~HardenedBit); + if (index & HardenedBit) { + path += "'"; + } + } + const { IR, IL } = ser_I(index, this.chainCode, this.publicKey, this.privateKey); + const ki = new SigningKey(toBeHex((toBigInt(IL) + BigInt(this.privateKey)) % N, 32)); + return new HDNodeWallet(_guard, ki, this.fingerprint, hexlify(IR), path, index, this.depth + 1, this.mnemonic, this.provider); + } + /** + * Return the HDNode for %%path%% from this node. + */ + derivePath(path) { + return derivePath(this, path); + } + static #fromSeed(_seed, mnemonic) { + assertArgument(isBytesLike(_seed), "invalid seed", "seed", "[REDACTED]"); + const seed = getBytes(_seed, "seed"); + assertArgument(seed.length >= 16 && seed.length <= 64, "invalid seed", "seed", "[REDACTED]"); + const I = getBytes(computeHmac("sha512", MasterSecret, seed)); + const signingKey = new SigningKey(hexlify(I.slice(0, 32))); + return new HDNodeWallet(_guard, signingKey, "0x00000000", hexlify(I.slice(32)), "m", 0, 0, mnemonic, null); + } + /** + * Creates a new HD Node from %%extendedKey%%. + * + * If the %%extendedKey%% will either have a prefix or ``xpub`` or + * ``xpriv``, returning a neutered HD Node ([[HDNodeVoidWallet]]) + * or full HD Node ([[HDNodeWallet) respectively. + */ + static fromExtendedKey(extendedKey) { + const bytes = toBeArray(decodeBase58(extendedKey)); // @TODO: redact + assertArgument(bytes.length === 82 || encodeBase58Check(bytes.slice(0, 78)) === extendedKey, "invalid extended key", "extendedKey", "[ REDACTED ]"); + const depth = bytes[4]; + const parentFingerprint = hexlify(bytes.slice(5, 9)); + const index = parseInt(hexlify(bytes.slice(9, 13)).substring(2), 16); + const chainCode = hexlify(bytes.slice(13, 45)); + const key = bytes.slice(45, 78); + switch (hexlify(bytes.slice(0, 4))) { + // Public Key + case "0x0488b21e": + case "0x043587cf": { + const publicKey = hexlify(key); + return new HDNodeVoidWallet(_guard, computeAddress(publicKey), publicKey, parentFingerprint, chainCode, null, index, depth, null); + } + // Private Key + case "0x0488ade4": + case "0x04358394 ": + if (key[0] !== 0) { + break; + } + return new HDNodeWallet(_guard, new SigningKey(key.slice(1)), parentFingerprint, chainCode, null, index, depth, null, null); + } + assertArgument(false, "invalid extended key prefix", "extendedKey", "[ REDACTED ]"); + } + /** + * Creates a new random HDNode. + */ + static createRandom(password, path, wordlist) { + if (password == null) { + password = ""; + } + if (path == null) { + path = defaultPath; + } + if (wordlist == null) { + wordlist = LangEn.wordlist(); + } + const mnemonic = Mnemonic.fromEntropy(randomBytes$1(16), password, wordlist); + return HDNodeWallet.#fromSeed(mnemonic.computeSeed(), mnemonic).derivePath(path); + } + /** + * Create an HD Node from %%mnemonic%%. + */ + static fromMnemonic(mnemonic, path) { + if (!path) { + path = defaultPath; + } + return HDNodeWallet.#fromSeed(mnemonic.computeSeed(), mnemonic).derivePath(path); + } + /** + * Creates an HD Node from a mnemonic %%phrase%%. + */ + static fromPhrase(phrase, password, path, wordlist) { + if (password == null) { + password = ""; + } + if (path == null) { + path = defaultPath; + } + if (wordlist == null) { + wordlist = LangEn.wordlist(); + } + const mnemonic = Mnemonic.fromPhrase(phrase, password, wordlist); + return HDNodeWallet.#fromSeed(mnemonic.computeSeed(), mnemonic).derivePath(path); + } + /** + * Creates an HD Node from a %%seed%%. + */ + static fromSeed(seed) { + return HDNodeWallet.#fromSeed(seed, null); + } +} +/** + * A **HDNodeVoidWallet** cannot sign, but provides access to + * the children nodes of a [[link-bip-32]] HD wallet addresses. + * + * The can be created by using an extended ``xpub`` key to + * [[HDNodeWallet_fromExtendedKey]] or by + * [nuetering](HDNodeWallet-neuter) a [[HDNodeWallet]]. + */ +class HDNodeVoidWallet extends VoidSigner { + /** + * The compressed public key. + */ + publicKey; + /** + * The fingerprint. + * + * A fingerprint allows quick qay to detect parent and child nodes, + * but developers should be prepared to deal with collisions as it + * is only 4 bytes. + */ + fingerprint; + /** + * The parent node fingerprint. + */ + parentFingerprint; + /** + * The chaincode, which is effectively a public key used + * to derive children. + */ + chainCode; + /** + * The derivation path of this wallet. + * + * Since extended keys do not provider full path details, this + * may be ``null``, if instantiated from a source that does not + * enocde it. + */ + path; + /** + * The child index of this wallet. Values over ``2 *\* 31`` indicate + * the node is hardened. + */ + index; + /** + * The depth of this wallet, which is the number of components + * in its path. + */ + depth; + /** + * @private + */ + constructor(guard, address, publicKey, parentFingerprint, chainCode, path, index, depth, provider) { + super(address, provider); + assertPrivate(guard, _guard, "HDNodeVoidWallet"); + defineProperties(this, { publicKey }); + const fingerprint = dataSlice(ripemd160(sha256(publicKey)), 0, 4); + defineProperties(this, { + publicKey, fingerprint, parentFingerprint, chainCode, path, index, depth + }); + } + connect(provider) { + return new HDNodeVoidWallet(_guard, this.address, this.publicKey, this.parentFingerprint, this.chainCode, this.path, this.index, this.depth, provider); + } + /** + * The extended key. + * + * This key will begin with the prefix ``xpub`` and can be used to + * reconstruct this neutered key to derive its children addresses. + */ + get extendedKey() { + // We only support the mainnet values for now, but if anyone needs + // testnet values, let me know. I believe current sentiment is that + // we should always use mainnet, and use BIP-44 to derive the network + // - Mainnet: public=0x0488B21E, private=0x0488ADE4 + // - Testnet: public=0x043587CF, private=0x04358394 + assert$5(this.depth < 256, "Depth too deep", "UNSUPPORTED_OPERATION", { operation: "extendedKey" }); + return encodeBase58Check(concat$3([ + "0x0488B21E", + zpad(this.depth, 1), + this.parentFingerprint, + zpad(this.index, 4), + this.chainCode, + this.publicKey, + ])); + } + /** + * Returns true if this wallet has a path, providing a Type Guard + * that the path is non-null. + */ + hasPath() { return (this.path != null); } + /** + * Return the child for %%index%%. + */ + deriveChild(_index) { + const index = getNumber(_index, "index"); + assertArgument(index <= 0xffffffff, "invalid index", "index", index); + // Base path + let path = this.path; + if (path) { + path += "/" + (index & ~HardenedBit); + if (index & HardenedBit) { + path += "'"; + } + } + const { IR, IL } = ser_I(index, this.chainCode, this.publicKey, null); + const Ki = SigningKey.addPoints(IL, this.publicKey, true); + const address = computeAddress(Ki); + return new HDNodeVoidWallet(_guard, address, Ki, this.fingerprint, hexlify(IR), path, index, this.depth + 1, this.provider); + } + /** + * Return the signer for %%path%% from this node. + */ + derivePath(path) { + return derivePath(this, path); + } +} + +/** + * @_subsection: api/wallet:JSON Wallets [json-wallets] + */ +/** + * Returns true if %%json%% is a valid JSON Crowdsale wallet. + */ +function isCrowdsaleJson(json) { + try { + const data = JSON.parse(json); + if (data.encseed) { + return true; + } + } + catch (error) { } + return false; +} +// See: https://github.com/ethereum/pyethsaletool +/** + * Before Ethereum launched, it was necessary to create a wallet + * format for backers to use, which would be used to receive ether + * as a reward for contributing to the project. + * + * The [[link-crowdsale]] format is now obsolete, but it is still + * useful to support and the additional code is fairly trivial as + * all the primitives required are used through core portions of + * the library. + */ +function decryptCrowdsaleJson(json, _password) { + const data = JSON.parse(json); + const password = getPassword(_password); + // Ethereum Address + const address = getAddress(spelunk(data, "ethaddr:string!")); + // Encrypted Seed + const encseed = looseArrayify(spelunk(data, "encseed:string!")); + assertArgument(encseed && (encseed.length % 16) === 0, "invalid encseed", "json", json); + const key = getBytes(pbkdf2$1(password, password, 2000, 32, "sha256")).slice(0, 16); + const iv = encseed.slice(0, 16); + const encryptedSeed = encseed.slice(16); + // Decrypt the seed + const aesCbc = new CBC(key, iv); + const seed = pkcs7Strip(getBytes(aesCbc.decrypt(encryptedSeed))); + // This wallet format is weird... Convert the binary encoded hex to a string. + let seedHex = ""; + for (let i = 0; i < seed.length; i++) { + seedHex += String.fromCharCode(seed[i]); + } + return { address, privateKey: id$1(seedHex) }; +} + +function stall(duration) { + return new Promise((resolve) => { setTimeout(() => { resolve(); }, duration); }); +} +/** + * A **Wallet** manages a single private key which is used to sign + * transactions, messages and other common payloads. + * + * This class is generally the main entry point for developers + * that wish to use a private key directly, as it can create + * instances from a large variety of common sources, including + * raw private key, [[link-bip-39]] mnemonics and encrypte JSON + * wallets. + */ +class Wallet extends BaseWallet { + /** + * Create a new wallet for the private %%key%%, optionally connected + * to %%provider%%. + */ + constructor(key, provider) { + if (typeof (key) === "string" && !key.startsWith("0x")) { + key = "0x" + key; + } + let signingKey = (typeof (key) === "string") ? new SigningKey(key) : key; + super(signingKey, provider); + } + connect(provider) { + return new Wallet(this.signingKey, provider); + } + /** + * Resolves to a [JSON Keystore Wallet](json-wallets) encrypted with + * %%password%%. + * + * If %%progressCallback%% is specified, it will receive periodic + * updates as the encryption process progreses. + */ + async encrypt(password, progressCallback) { + const account = { address: this.address, privateKey: this.privateKey }; + return await encryptKeystoreJson(account, password, { progressCallback }); + } + /** + * Returns a [JSON Keystore Wallet](json-wallets) encryped with + * %%password%%. + * + * It is preferred to use the [async version](encrypt) instead, + * which allows a [[ProgressCallback]] to keep the user informed. + * + * This method will block the event loop (freezing all UI) until + * it is complete, which may be a non-trivial duration. + */ + encryptSync(password) { + const account = { address: this.address, privateKey: this.privateKey }; + return encryptKeystoreJsonSync(account, password); + } + static #fromAccount(account) { + assertArgument(account, "invalid JSON wallet", "json", "[ REDACTED ]"); + if ("mnemonic" in account && account.mnemonic && account.mnemonic.locale === "en") { + const mnemonic = Mnemonic.fromEntropy(account.mnemonic.entropy); + const wallet = HDNodeWallet.fromMnemonic(mnemonic, account.mnemonic.path); + if (wallet.address === account.address && wallet.privateKey === account.privateKey) { + return wallet; + } + console.log("WARNING: JSON mismatch address/privateKey != mnemonic; fallback onto private key"); + } + const wallet = new Wallet(account.privateKey); + assertArgument(wallet.address === account.address, "address/privateKey mismatch", "json", "[ REDACTED ]"); + return wallet; + } + /** + * Creates (asynchronously) a **Wallet** by decrypting the %%json%% + * with %%password%%. + * + * If %%progress%% is provided, it is called periodically during + * decryption so that any UI can be updated. + */ + static async fromEncryptedJson(json, password, progress) { + let account = null; + if (isKeystoreJson(json)) { + account = await decryptKeystoreJson(json, password, progress); + } + else if (isCrowdsaleJson(json)) { + if (progress) { + progress(0); + await stall(0); + } + account = decryptCrowdsaleJson(json, password); + if (progress) { + progress(1); + await stall(0); + } + } + return Wallet.#fromAccount(account); + } + /** + * Creates a **Wallet** by decrypting the %%json%% with %%password%%. + * + * The [[fromEncryptedJson]] method is preferred, as this method + * will lock up and freeze the UI during decryption, which may take + * some time. + */ + static fromEncryptedJsonSync(json, password) { + let account = null; + if (isKeystoreJson(json)) { + account = decryptKeystoreJsonSync(json, password); + } + else if (isCrowdsaleJson(json)) { + account = decryptCrowdsaleJson(json, password); + } + else { + assertArgument(false, "invalid JSON wallet", "json", "[ REDACTED ]"); + } + return Wallet.#fromAccount(account); + } + /** + * Creates a new random [[HDNodeWallet]] using the available + * [cryptographic random source](randomBytes). + * + * If there is no crytographic random source, this will throw. + */ + static createRandom(provider) { + const wallet = HDNodeWallet.createRandom(); + if (provider) { + return wallet.connect(provider); + } + return wallet; + } + /** + * Creates a [[HDNodeWallet]] for %%phrase%%. + */ + static fromPhrase(phrase, provider) { + const wallet = HDNodeWallet.fromPhrase(phrase); + if (provider) { + return wallet.connect(provider); + } + return wallet; + } +} + +const Base64 = ")!@#$%^&*(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_"; +/** + * @_ignore + */ +function decodeBits(width, data) { + const maxValue = (1 << width) - 1; + const result = []; + let accum = 0, bits = 0, flood = 0; + for (let i = 0; i < data.length; i++) { + // Accumulate 6 bits of data + accum = ((accum << 6) | Base64.indexOf(data[i])); + bits += 6; + // While we have enough for a word... + while (bits >= width) { + // ...read the word + const value = (accum >> (bits - width)); + accum &= (1 << (bits - width)) - 1; + bits -= width; + // A value of 0 indicates we exceeded maxValue, it + // floods over into the next value + if (value === 0) { + flood += maxValue; + } + else { + result.push(value + flood); + flood = 0; + } + } + } + return result; +} + +/** + * @_ignore + */ +function decodeOwlA(data, accents) { + let words = decodeOwl(data).join(","); + // Inject the accents + accents.split(/,/g).forEach((accent) => { + const match = accent.match(/^([a-z]*)([0-9]+)([0-9])(.*)$/); + assertArgument(match !== null, "internal error parsing accents", "accents", accents); + let posOffset = 0; + const positions = decodeBits(parseInt(match[3]), match[4]); + const charCode = parseInt(match[2]); + const regex = new RegExp(`([${match[1]}])`, "g"); + words = words.replace(regex, (all, letter) => { + const rem = --positions[posOffset]; + if (rem === 0) { + letter = String.fromCharCode(letter.charCodeAt(0), charCode); + posOffset++; + } + return letter; + }); + }); + return words.split(","); +} + +/** + * An OWL-A format Wordlist extends the OWL format to add an + * overlay onto an OWL format Wordlist to support diacritic + * marks. + * + * This class is generally not useful to most developers as + * it is used mainly internally to keep Wordlists for languages + * based on latin-1 small. + * + * If necessary, there are tools within the ``generation/`` folder + * to create the necessary data. + */ +class WordlistOwlA extends WordlistOwl { + #accent; + /** + * Creates a new Wordlist for %%locale%% using the OWLA %%data%% + * and %%accent%% data and validated against the %%checksum%%. + */ + constructor(locale, data, accent, checksum) { + super(locale, data, checksum); + this.#accent = accent; + } + /** + * The OWLA-encoded accent data. + */ + get _accent() { return this.#accent; } + /** + * Decode all the words for the wordlist. + */ + _decodeWords() { + return decodeOwlA(this._data, this._accent); + } +} + +const words$4 = "0itatkastcenaovo$taouleraeki&chor*teci%enbalodaeladet'!Chn=0Di#%E%^1Resa2Rese3CeT'#0EjKohol0Pu)%0A&sDul#Ekdo)Ke)Ti#Ul|3}aOgan%0FaltI$@tPi,%TmaTronom0LasL{i#Ol0Tobus4Yl:B#}R'?TaUb_U/!U^U+Ur!Xer2A^v#Ambo,An#AtrEp)Ike)KoLohOnzOskevUn{#Usin#Z^Zy2Bl.Bn|})D _D#D'aF{Jar(Kv?LdokLvaN^NkrRzaTikVolZola3D+tL.T'#0Ukot:PartRev&3DrDu+J/JnLaLerLkemLn?N.Nn(N'#NtrumNzZ(2O&2KolivUv!4It_N(0Dn(Ke)KrPot0Ak~AlIkRkot2Kli$a:L-oRe[T_Tum1E,1B!a}'#Cib_Fic Fla%KlKr{Mokr!PreseRbyS#T-tiv3Kob,zKt|O^P]mSkSp+jV`]Vo/2AhaOuhoUhopis1Es0BroByt-C@t}ut DnesH+dHo^H,JemJn?Kl`KolaKtAzeDolObn(OgerieOzdSn(T Z(2B@}'noD-HaH'#S SnoT(0Oj?Or>2Nam :9O]gOnomie0EktronIpsa0AilIseO%P!ie2Izo^O/aOpejOs2EjEn%K<)Kymo0Ike)0FR&S]Zky3StOhOup(T!Ub.U/o)0AtO)Yz0IsOjivoOut0Bl.Boj}DinyDl!Dno)D|Jn(KejLin#L#LubMo+N [No,%RalR^RizontRkoRliv>RmonRn.RoskopR$voSpo^St.T'(U[UfUp!Us#V<2Ad[An?Av(Az^Bo+kD.D]D(N-Ob#Oma^OtOu^Oz@St#Ub(Yz!2B@(B~D[KotMrS aSto)0Ozd2Bn(D,ntGie&M&Sterik:2Yl#3Ned2O&0Uze0Un a0F-%Fla%KasoOva%Sp-%Tern{Vali^Ve$N)rRmarkRoSanSnoT#VD+Dn!_HlanKotL@L oMn(NomP?S{erV Zd>Zero3NakNdyNo/Sk,Sto)Trn?Zva3En|1Gurt5R):Bar{B_Bin{}&D{Did]HanJakJu)KaoKtusLam aLhotyLibrLn(Me,MkolivM&Ni[lNoeNtB#BlihaBylaC*rH=J@>KosKtejlLapsLe^LizeLoMandoMe)MikMn!aMo,MpasMun aN!N%ptNd?N>NfeseNgresN.NkursN)ktNzervaPan>PieP~Pr'#Rb_R-tSt#T_T+)T*lUk!Up_&Us-Uz]VbojZaZMe+cMivoOcanOkOni#Op OupaOv#T-Uh`]Up?Ut(Vin#Y/+Yp)Y$alYt2Dlan#FrJn(KlaLaj^Li/L#Lom{Ltu,NaPodivuRtRzV`]:B,d<})nDn(IkKom>M_aMpaN'#S?SoStu,Tin#V.3B#CkdyD@Dn?D'#Dv.G@^GieG,%H%Hk(H~KtvarNo/odNtil#P@#Pid]T`]T>TmoTokruhVhartV a%Vobok3B,}ot#DojedDsk(H'.Jav>L-M{#NieN#No+umStop`T.T|5Bi$aDivodGi#GopedKal aK{Mc|P!aPu/RdSosTrU^lUhU#Usk!V>3Tiv(1Cer&CiferMpSkSt,%0I%2RaRi#S.:DamD]Gi$rHagonJ{-J _J< aKakK'?Kr_aL[L.L|Lv?Min#Nd+NkoRn(SakrSkotSopu$T?Tri#Tur aZan>ZivoZl Zur#2Lo[0}anikD a%D'.LasaL*nNtol#TlaTo^TrZe,3G,%H~Hu+K.KrofonL@>Lim{rL(Mi#Nc'&Ni[rNom{Nul(S#StrX|2Ad(HaH'.OkS!Uv 1I/Ohem0BilCn(D_#Dl [HylaKroL-ulaM@t#Nar/aNoklN$rumNt|NzunSazSkytStTiva%T<#Ty#U/aUdr(Zai#Z-Zol2AmKevTvolaZ{Zut(0T _1DrcF]nL!MieN?S{Ta%ZeumZi#nt3Sliv>0Da:B*r!}yt!Da%Dbyt-DhozDobroDpisHlasHn!Hodi+H,d Iv aJedn*Ji$oJm=K]n Kon>Krm LevoMaz!Mluv Nom{rOkoOpakO$roP`!PevnoPln P~Pos+dPr(oRod RubyRy/]S` S-!S+poSt!TolikV@-Vr/VzdR&Ru[RysSahSluhaS)r!UvVazVin VodVyk+Yv!_Z<0AsElEn Hl` Ho)H,&It~0BojByt}odCiz Ebr!Esl!Evzd!EzvaH`%Hod J{JinudKazK*p LivLu#Ml#Oln(P`PisPl=PLivoLu[Mf+tMls-N@#Ni#N&N|N$voNtof+Pri#Rke)RodieR)Ru#Ry[Se#Siv aSt_#T@tTro&V*kZnehtZ*r-3C#DagogJs-K]LotonNal)Ndr-NzeRiskopRoStr(Tar^T?Tro+jVn.Xeso3Ani$aHaJav?K+KnikL.Ln(Lul#Nze)Pe)S!_Sto+Tev&Vn?V'ar2A%n)Ak!Am@Ane)A$i#At Avid]AzE/Em@oEn)EsEtivoEv_Iv!N NoO/aOd.Om[OutUkYn2Bav Byt}odC Ctiv>D!D%n Deps!Dh+dDiv Dkl`Dman DnikDo[Dpo,D,zD$!aDvodDzimEzieHan#Hnut#H'S*d SpoluS)vaSud-SypTahT#nT+skTom-T,vaTupaTvo,U#zUtoUzdroVahaVidlaVlakVozVr/V$!VykVzde/Zd,vZem-Zn!-ZAp<-AseAv^IncipKnoObud O%ntoOdejOfeseOh,Oj-tO]m Omi+Onik!Op`OrokOs[OtonOut-OvazS#v#St@Udk(UtV-VohOvodTruh0Actvo0Ber)}DlKav>Kl.Kr+LtMpaNcP@SaSin#St.T|Ty#3Rami^SkT_::C-}otDia%Dn?DonFtGbyKe)K'.M@oMp*/NdeRa/R aS'&StrTo+$Zan%Zid]3Ag|Ak%CeptDaktMizd!Mo)N #Rdin#San#T_ Z[Z@?0Or0H|1B,n#CeseD`]Dim@tD]Hn!Jm=Ke,K)Kun^KvojeM@oNoRvisS` Sho,SkokSl!St,SuvSyp!T[T.Tk!T~Trv!VerZ&m2O^R~0FonLn?R#Rot-RupTua%1AfandrAliskoAnz@AutEptikIcaL`[L@?LoLuzO[O#nOroRip)RzUp.V(Vr&0Abi#Adid]An.A$Avn(Ed|Ep>EvaEz.IbI&Izn?OnOup-OvoU/UhaUn%Up#Za0A,gdE)&Il$voL*vaOgR`RkRt#Ut-Ysl0AdAhaOb0Bo)}aD'#KolP#TvaUbojUc Ud%UhlasUl`Um,kUp,vaUsedUtokUvis{0Al'&As _IsLavOd-Oj@>OluOnzOvn!P@StUb1An?Ar(aAti#Av[EhnoEz#OdolaO+kOpaOrnoOup!Ra/ResRh~RomRu&Ud&Upn?VolYk0Bj-tBtropy}arD(KnoNd!N=Rik!aR'.0AhAl$voEtrAt[Az-Is+It-Obo^Odid]Or#Rab2Kav#KotN-N'>P!Pk(R'(S_T(:B+t#Bu+H*nJemnoJfunJgaJ Jn(Kti#Mh+MponNc|N>NkerPe)V@.Z!_3}ni#HdyKut.LefonMno)Nd@%Ni$aNU/l Uhl?UsV!2DyH~H(Nd,Ri$aR&jZemsko0ArohOr[Rd(Rz2GrKev:0Oh(OzeR!R*s-RusYt'&0HoTiv(0Iv 3R` 1Edn!I$ M=0Az!_Lidn Lon Otv Roj 0I%I)Ov 0Yv`]0Av IfR*s 1Al Oln Oz'#3D,v ElEn.L.N!:GonL/aL*nNaN^lNil#RanRhanyR|1ElkuHod0Ova0DroGe)%J%Lbl*dL{rhL _LmocLry[Nk'Ran^RzeS_#SkrzeSn?SpoduS)Ter.Ver#3B,%}rDeoh,D.D+LaN?S{Tal aZeZ #0Ezd0L`Us0Aj#AkAs>EvoHk(IvN'#Oup!1Uc|Uk0DaDiv(Doz&kD$voJ@skyJ&JskoLantL[L LnoSk'#Zid]Z'&0Ravo1Ab>A%tAhA)Ba}o+kH!StvaTu+0Ad T*p Tup0Ip4Bav Br!}|D!D,Fot H+d!H~Hod H,d Hub Jasn J{Jm=K]p Kon!L-!Maz!Mez Miz{Mys+tNe/!Nik!Nut P`!Pl! P,v Pu$ Raz R'n!Rv!Sl' SokoS)v Su~Syp!Tas Tes!Tr! Vi~Vol!Vrh_Zdob Zn!0AduBud }op DJ{Ji$ K+p!K*p Lep Mez Mot!Mys+tNe/!Nik!Pl! Poj Ps!Raz S)v Su~Taj Temn Tk~Ujm=Val Ve+tVin Vol!Vrt!Zvon 0Av RusuUd|Yt-1A+#ArmaAtn(IvoOb RojVihYm`]0L@.ManM.Pt!Z`uZdola2At Lt~Lubo#Ot' Ru[0MaMn?0Emn 0Lam!Oum!R!#Umav#0AtoEh#O[OmO$Ozvyk0Ap|ArAt-IjeIz{Ocn Odr!Rzl.Ut|0AkAl(Am@!Ovu0B,z Tav Ub-Ufa+0Lod Omal RavaR( Rud#Rvu1A^An C`]N (NoOv&Y/l Zav(1I/aR! 0B'.Br0Ed~EnkuEs_aOnR!Uk'odYk"; +const checksum$4 = "0x25f44555f4af25b51a711136e1c7d6e50ce9f8917d39d6b1f076b2bb4d2fac1a"; +let wordlist$6 = null; +/** + * The [[link-bip39-cz]] for [mnemonic phrases](link-bip-39). + * + * @_docloc: api/wordlists + */ +class LangCz extends WordlistOwl { + /** + * Creates a new instance of the Czech language Wordlist. + * + * Using the constructor should be unnecessary, instead use the + * [[wordlist]] singleton method. + * + * @_ignore: + */ + constructor() { super("cz", words$4, checksum$4); } + /** + * Returns a singleton instance of a ``LangCz``, creating it + * if this is the first time being called. + */ + static wordlist() { + if (wordlist$6 == null) { + wordlist$6 = new LangCz(); + } + return wordlist$6; + } +} + +const words$3 = "0arertoiotadonoaRteirroenaNonaLsolocoiliaralaorrenadaChoN$n0A>Dom,EjaI!#Oga&O'Or#RazoR*Ue=U<0Ab Adem@CeLe%OmoRa!RozUn0DazD$GeLaM,#S,)T^0AlAnceA+EEl]`E`EstruzI.I<2ErU{U'0Af[nArO)Uc Uf_Ul:BaB^|eH@IleJ Lanz/c.LdeMbuN>Nd-oRb(>RnizR+Scu]S#nSu[Tal]T!@T*Tu%UlZ 3BeBid/=S SoSt@3|oEnNgo2An>OqueUsa2ABi`BoCaCi`DaDegaIn//!oLsaMb-{dNi#N}saiRdeRr SqueTeTinVe{Zal2AvoAzoEchaEveIl=In>IsaOcaOmaOnceO)UjaUs>U#2CeoCleE'EyFan{F.HoIt_L#Rbuj(l(+Sc TacaZ.:Bal=BezaBi`B[CaoDav!D,aErFeI{ImanJaJ.LLam Lc$L&Li{dLleLm/^LvoMaMb$Mel=Mi'Mp}c!Nd?Nel-gu+Nic-#N-.ObaOsPazPi%nPo)Pt Puch((b.RcelRe%Rg(i'RneRpe%R+R%SaS>S!oSpaS#rT^ceT_U{lUsaZo3Bol]D!D+Ld/eb_LoAmpuAnc]ApaAr]I>Is)IvoOqueOzaUle%Up 0Cl.EgoE=EnEr#F[G +M->NeN%P_sR>Rue]SneTaU{d2Am^AnA+AseAveI,)ImaInica2B_Cc~|i'Ci`CoDigoDoF_G!He)JinJoL/ch/eg$Lg Lin/l LmoLum`Mba)M!Mi{Mo&Mpr-deNej}g-oc!Nsej}t PaPi(az.Rba%RchoR&nR.(r!S!SmosS%2AneoAt!E Ec!Ei&EmaIaIm,Ip%IsisOmoOnicaOque%U&Uz2Ad+Ar#At+BoBr*| aEl=En#Er{Es%EvaId Lebr/p/#Mb_Mpl*N-e%O%P.Pul( R$Se'Sf[zVaVi'5BleCeL^Ming}N Ra&Rm*RAu%EchaOrO%U*UjoU^2B@CaGa%G.L$Lle#N&Rm(+Rtun(z SaTo2AcaA'AsaAtisAveIe%Il=IpeIsI#OG Gu!aJaMb_Ng}^Nr((mig('St?Yo5E>ElgaEr%ENgl-$Nt Pit!R S#V,?Zg :7Lo5A]:B$C$C[DoD+nG #GrimaGu`I>M!Mi`Mp --ch-gos%NzaPizRgoRvaStimaTaTexT*U_lV Zo3AlCc~|eC#rErG~Gumb_Ja'Ngu-#NaOnOp &S~TalT[VeY,{3B!%dB+C^D!Di EnzoGaG!oMaMi)M.Mp$NceN&Ne-go)N}t!`Qui&SoS%T!aT$T+2AgaAmaAn#AveEg En Ev Or Ov!Uv@2BoC~CoCu[GicaG+MbrizM}jaTe5|aC*G J}-esPaSt+ToZ:Ce%|oD!aD_Du+Est+F@G@GoIzL{dLe%Ll/oMaMboMutN>N&Nej Ng-iquiNj N}Re(f?Rg,Ri&RmolR+nR)sRzoSaSc aSivoT T!@TizTrizXimoY^Z^ca3|aDal]D$Du]J?]J^L,/.M^i-^NsajeN)NuRca&R,gueRi#SS.TaT!To&T+Zc]3E&ElEmb+G/Lag+Lit Ll.M}-!}im}u#OpeR SaS!@S?SmoTadTo5|?aC~DaDe=HoJ LdeL!Li'M,#Mi- c-ed-j-#NoRad(d!Re'R*R+Rs(%lScaStr TivoV!V?Zo5|oD EbleE]Er)Est[G_J!L/e%L%N&Nec(alRoScu=SeoSgoSicaS=:C C~D IpeRanj(izRr SalTalTivoTu[lUseaValVeVi{d3C$Ct G Goc$G+OnRv$ToUt+V V!a3|oDoEb]E#NezNoTi&Vel5Bleza|eMin(i(m()TaTic@Va#Ve]V$5BeCaCleoD?=DoE[EveEzLoM!oTr@:Sis0EC~E[In On!T TicaUes#1Ac~A&rAlBi%CaD,EjaGa'G@Gul=I,)Ig,Il]OQues%Uga0Ad@Cu+Ez'OT[0O'Ro1EjaU=1I&Ige'0En)0O':C#D_El]Gi`GoIsJ oLabr/>Le%Li&Lm/om/p NNalNi>Nt!-ue=PaPelP?]Que)R Rcel(edR*RoRpa&RqueR[foR)S SeoS~SoS%TaT$Tr@UsaU%VoYa<3A#nCa&C!a|oDalD*G IneL L{'Le/ig+LlejoLoLuc--s N.OnOrPi'Que'R(ch(d!Rez(f?Ri>Rl(mizEgun%Em$EnsaE|!oD^Eb=Er%Es#Lg/*Lm.LpoLrNd*N%P #Pet*PoN{PaP!oSaScaSt+T 5BiB^DoE{G*I&In/e%LoMboM^Ptu[TaTi`:Ba&B!B$BleC GazG[&L/&L!oL*Lm.L.Ls/#LudLv Mb-c~Ndi-e Ng_Ni{dN}#PoQueRdin()nSt_TanU`Xof.3Cc~CoC_#C%DGu*IsL=LvaMa`M?l-d-Re'Rg*S#T?:Ba>BiqueB]BuCoC#JoL L>L,#Ll/.Ma'Mb^Ng}quePaPe)P@P.Qu?l(deRe(if(je%RotR+R%TuajeU+ZaZ.3At+|oC]CnicaJa&J!Ji&L/efo'MaM^Mp=NazNd!N!NisNRmi'Rnur(+rSisSo+StigoT!aX#Z3B$Bu+nEmpoEn{Er[EPoR(.TanT!eTu=Za5Al]B?=C Ci'DoG/&M N}#P PeQueRaxR!oRm,%RneoRoRpe&R_RS!Xi>2AbajoAc#rA!Afi>AgoAjeAmoAnceA#AumaAz EbolEguaEin%EnEp EsIbuIgoIpaIs)IunfoOfeoOmpaOn>OpaO)OzoU>Ue'Ufa2B!@BoEr#MbaM^NelNic(bin(ismoR'T^:0Ic 9C!a0B[l0I{dIrIv! b) { + return 1; + } + return 0; + } + // Load all the words + for (let length = 3; length <= 9; length++) { + const d = data$2[length - 3]; + for (let offset = 0; offset < d.length; offset += length) { + const word = []; + for (let i = 0; i < length; i++) { + const k = mapping.indexOf(d[offset + i]); + word.push(227); + word.push((k & 0x40) ? 130 : 129); + word.push((k & 0x3f) + 128); + } + wordlist.push(toString$2(word)); + } + } + wordlist.sort(sortJapanese); + // For some reason kyoku and kiyoku are flipped in node (!!). + // The order SHOULD be: + // - kyoku + // - kiyoku + // This should ignore "if", but that doesn't work here?? + /* c8 ignore start */ + if (hex(wordlist[442]) === KiYoKu && hex(wordlist[443]) === KyoKu) { + const tmp = wordlist[442]; + wordlist[442] = wordlist[443]; + wordlist[443] = tmp; + } + /* c8 ignore stop */ + // Verify the computed list matches the official list + /* istanbul ignore if */ + const checksum = id$1(wordlist.join("\n") + "\n"); + /* c8 ignore start */ + if (checksum !== "0xcb36b09e6baa935787fd762ce65e80b0c6a8dabdfbc3a7f86ac0e2c4fd111600") { + throw new Error("BIP39 Wordlist for ja (Japanese) FAILED"); + } + /* c8 ignore stop */ + _wordlist$2 = wordlist; + return wordlist; +} +let wordlist$3 = null; +/** + * The [[link-bip39-ja]] for [mnemonic phrases](link-bip-39). + * + * @_docloc: api/wordlists + */ +class LangJa extends Wordlist { + /** + * Creates a new instance of the Japanese language Wordlist. + * + * This should be unnecessary most of the time as the exported + * [[langJa]] should suffice. + * + * @_ignore: + */ + constructor() { super("ja"); } + getWord(index) { + const words = loadWords$2(); + assertArgument(index >= 0 && index < words.length, `invalid word index: ${index}`, "index", index); + return words[index]; + } + getWordIndex(word) { + return loadWords$2().indexOf(word); + } + split(phrase) { + //logger.assertNormalize(); + return phrase.split(/(?:\u3000| )+/g); + } + join(words) { + return words.join("\u3000"); + } + /** + * Returns a singleton instance of a ``LangJa``, creating it + * if this is the first time being called. + */ + static wordlist() { + if (wordlist$3 == null) { + wordlist$3 = new LangJa(); + } + return wordlist$3; + } +} + +const data$1 = [ + "OYAa", + "ATAZoATBl3ATCTrATCl8ATDloATGg3ATHT8ATJT8ATJl3ATLlvATLn4ATMT8ATMX8ATMboATMgoAToLbAToMTATrHgATvHnAT3AnAT3JbAT3MTAT8DbAT8JTAT8LmAT8MYAT8MbAT#LnAUHT8AUHZvAUJXrAUJX8AULnrAXJnvAXLUoAXLgvAXMn6AXRg3AXrMbAX3JTAX3QbAYLn3AZLgvAZrSUAZvAcAZ8AaAZ8AbAZ8AnAZ8HnAZ8LgAZ8MYAZ8MgAZ8OnAaAboAaDTrAaFTrAaJTrAaJboAaLVoAaMXvAaOl8AaSeoAbAUoAbAg8AbAl4AbGnrAbMT8AbMXrAbMn4AbQb8AbSV8AbvRlAb8AUAb8AnAb8HgAb8JTAb8NTAb8RbAcGboAcLnvAcMT8AcMX8AcSToAcrAaAcrFnAc8AbAc8MgAfGgrAfHboAfJnvAfLV8AfLkoAfMT8AfMnoAfQb8AfScrAfSgrAgAZ8AgFl3AgGX8AgHZvAgHgrAgJXoAgJX8AgJboAgLZoAgLn4AgOX8AgoATAgoAnAgoCUAgoJgAgoLXAgoMYAgoSeAgrDUAgrJTAhrFnAhrLjAhrQgAjAgoAjJnrAkMX8AkOnoAlCTvAlCV8AlClvAlFg4AlFl6AlFn3AloSnAlrAXAlrAfAlrFUAlrFbAlrGgAlrOXAlvKnAlvMTAl3AbAl3MnAnATrAnAcrAnCZ3AnCl8AnDg8AnFboAnFl3AnHX4AnHbrAnHgrAnIl3AnJgvAnLXoAnLX4AnLbrAnLgrAnLhrAnMXoAnMgrAnOn3AnSbrAnSeoAnvLnAn3OnCTGgvCTSlvCTvAUCTvKnCTvNTCT3CZCT3GUCT3MTCT8HnCUCZrCULf8CULnvCU3HnCU3JUCY6NUCbDb8CbFZoCbLnrCboOTCboScCbrFnCbvLnCb8AgCb8HgCb$LnCkLfoClBn3CloDUDTHT8DTLl3DTSU8DTrAaDTrLXDTrLjDTrOYDTrOgDTvFXDTvFnDT3HUDT3LfDUCT9DUDT4DUFVoDUFV8DUFkoDUGgrDUJnrDULl8DUMT8DUMXrDUMX4DUMg8DUOUoDUOgvDUOg8DUSToDUSZ8DbDXoDbDgoDbGT8DbJn3DbLg3DbLn4DbMXrDbMg8DbOToDboJXGTClvGTDT8GTFZrGTLVoGTLlvGTLl3GTMg8GTOTvGTSlrGToCUGTrDgGTrJYGTrScGTtLnGTvAnGTvQgGUCZrGUDTvGUFZoGUHXrGULnvGUMT8GUoMgGXoLnGXrMXGXrMnGXvFnGYLnvGZOnvGZvOnGZ8LaGZ8LmGbAl3GbDYvGbDlrGbHX3GbJl4GbLV8GbLn3GbMn4GboJTGboRfGbvFUGb3GUGb4JnGgDX3GgFl$GgJlrGgLX6GgLZoGgLf8GgOXoGgrAgGgrJXGgrMYGgrScGgvATGgvOYGnAgoGnJgvGnLZoGnLg3GnLnrGnQn8GnSbrGnrMgHTClvHTDToHTFT3HTQT8HToJTHToJgHTrDUHTrMnHTvFYHTvRfHT8MnHT8SUHUAZ8HUBb4HUDTvHUoMYHXFl6HXJX6HXQlrHXrAUHXrMnHXrSbHXvFYHXvKXHX3LjHX3MeHYvQlHZrScHZvDbHbAcrHbFT3HbFl3HbJT8HbLTrHbMT8HbMXrHbMbrHbQb8HbSX3HboDbHboJTHbrFUHbrHgHbrJTHb8JTHb8MnHb8QgHgAlrHgDT3HgGgrHgHgrHgJTrHgJT8HgLX@HgLnrHgMT8HgMX8HgMboHgOnrHgQToHgRg3HgoHgHgrCbHgrFnHgrLVHgvAcHgvAfHnAloHnCTrHnCnvHnGTrHnGZ8HnGnvHnJT8HnLf8HnLkvHnMg8HnRTrITvFUITvFnJTAXrJTCV8JTFT3JTFT8JTFn4JTGgvJTHT8JTJT8JTJXvJTJl3JTJnvJTLX4JTLf8JTLhvJTMT8JTMXrJTMnrJTObrJTQT8JTSlvJT8DUJT8FkJT8MTJT8OXJT8OgJT8QUJT8RfJUHZoJXFT4JXFlrJXGZ8JXGnrJXLV8JXLgvJXMXoJXMX3JXNboJXPlvJXoJTJXoLkJXrAXJXrHUJXrJgJXvJTJXvOnJX4KnJYAl3JYJT8JYLhvJYQToJYrQXJY6NUJbAl3JbCZrJbDloJbGT8JbGgrJbJXvJbJboJbLf8JbLhrJbLl3JbMnvJbRg8JbSZ8JboDbJbrCZJbrSUJb3KnJb8LnJfRn8JgAXrJgCZrJgDTrJgGZrJgGZ8JgHToJgJT8JgJXoJgJgvJgLX4JgLZ3JgLZ8JgLn4JgMgrJgMn4JgOgvJgPX6JgRnvJgSToJgoCZJgoJbJgoMYJgrJXJgrJgJgrLjJg6MTJlCn3JlGgvJlJl8Jl4AnJl8FnJl8HgJnAToJnATrJnAbvJnDUoJnGnrJnJXrJnJXvJnLhvJnLnrJnLnvJnMToJnMT8JnMXvJnMX3JnMg8JnMlrJnMn4JnOX8JnST4JnSX3JnoAgJnoAnJnoJTJnoObJnrAbJnrAkJnrHnJnrJTJnrJYJnrOYJnrScJnvCUJnvFaJnvJgJnvJnJnvOYJnvQUJnvRUJn3FnJn3JTKnFl3KnLT6LTDlvLTMnoLTOn3LTRl3LTSb4LTSlrLToAnLToJgLTrAULTrAcLTrCULTrHgLTrMgLT3JnLULnrLUMX8LUoJgLVATrLVDTrLVLb8LVoJgLV8MgLV8RTLXDg3LXFlrLXrCnLXrLXLX3GTLX4GgLX4OYLZAXrLZAcrLZAgrLZAhrLZDXyLZDlrLZFbrLZFl3LZJX6LZJX8LZLc8LZLnrLZSU8LZoJTLZoJnLZrAgLZrAnLZrJYLZrLULZrMgLZrSkLZvAnLZvGULZvJeLZvOTLZ3FZLZ4JXLZ8STLZ8ScLaAT3LaAl3LaHT8LaJTrLaJT8LaJXrLaJgvLaJl4LaLVoLaMXrLaMXvLaMX8LbClvLbFToLbHlrLbJn4LbLZ3LbLhvLbMXrLbMnoLbvSULcLnrLc8HnLc8MTLdrMnLeAgoLeOgvLeOn3LfAl3LfLnvLfMl3LfOX8Lf8AnLf8JXLf8LXLgJTrLgJXrLgJl8LgMX8LgRZrLhCToLhrAbLhrFULhrJXLhvJYLjHTrLjHX4LjJX8LjLhrLjSX3LjSZ4LkFX4LkGZ8LkGgvLkJTrLkMXoLkSToLkSU8LkSZ8LkoOYLl3FfLl3MgLmAZrLmCbrLmGgrLmHboLmJnoLmJn3LmLfoLmLhrLmSToLnAX6LnAb6LnCZ3LnCb3LnDTvLnDb8LnFl3LnGnrLnHZvLnHgvLnITvLnJT8LnJX8LnJlvLnLf8LnLg6LnLhvLnLnoLnMXrLnMg8LnQlvLnSbrLnrAgLnrAnLnrDbLnrFkLnrJdLnrMULnrOYLnrSTLnvAnLnvDULnvHgLnvOYLnvOnLn3GgLn4DULn4JTLn4JnMTAZoMTAloMTDb8MTFT8MTJnoMTJnrMTLZrMTLhrMTLkvMTMX8MTRTrMToATMTrDnMTrOnMT3JnMT4MnMT8FUMT8FaMT8FlMT8GTMT8GbMT8GnMT8HnMT8JTMT8JbMT8OTMUCl8MUJTrMUJU8MUMX8MURTrMUSToMXAX6MXAb6MXCZoMXFXrMXHXrMXLgvMXOgoMXrAUMXrAnMXrHgMXrJYMXrJnMXrMTMXrMgMXrOYMXrSZMXrSgMXvDUMXvOTMX3JgMX3OTMX4JnMX8DbMX8FnMX8HbMX8HgMX8HnMX8LbMX8MnMX8OnMYAb8MYGboMYHTvMYHX4MYLTrMYLnvMYMToMYOgvMYRg3MYSTrMbAToMbAXrMbAl3MbAn8MbGZ8MbJT8MbJXrMbMXvMbMX8MbMnoMbrMUMb8AfMb8FbMb8FkMcJXoMeLnrMgFl3MgGTvMgGXoMgGgrMgGnrMgHT8MgHZrMgJnoMgLnrMgLnvMgMT8MgQUoMgrHnMgvAnMg8HgMg8JYMg8LfMloJnMl8ATMl8AXMl8JYMnAToMnAT4MnAZ8MnAl3MnAl4MnCl8MnHT8MnHg8MnJnoMnLZoMnLhrMnMXoMnMX3MnMnrMnOgvMnrFbMnrFfMnrFnMnrNTMnvJXNTMl8OTCT3OTFV8OTFn3OTHZvOTJXrOTOl3OT3ATOT3JUOT3LZOT3LeOT3MbOT8ATOT8AbOT8AgOT8MbOUCXvOUMX3OXHXvOXLl3OXrMUOXvDbOX6NUOX8JbOYFZoOYLbrOYLkoOYMg8OYSX3ObHTrObHT4ObJgrObLhrObMX3ObOX8Ob8FnOeAlrOeJT8OeJXrOeJnrOeLToOeMb8OgJXoOgLXoOgMnrOgOXrOgOloOgoAgOgoJbOgoMYOgoSTOg8AbOjLX4OjMnoOjSV8OnLVoOnrAgOn3DUPXQlrPXvFXPbvFTPdAT3PlFn3PnvFbQTLn4QToAgQToMTQULV8QURg8QUoJnQXCXvQbFbrQb8AaQb8AcQb8FbQb8MYQb8ScQeAlrQeLhrQjAn3QlFXoQloJgQloSnRTLnvRTrGURTrJTRUJZrRUoJlRUrQnRZrLmRZrMnRZrSnRZ8ATRZ8JbRZ8ScRbMT8RbST3RfGZrRfMX8RfMgrRfSZrRnAbrRnGT8RnvJgRnvLfRnvMTRn8AaSTClvSTJgrSTOXrSTRg3STRnvSToAcSToAfSToAnSToHnSToLjSToMTSTrAaSTrEUST3BYST8AgST8LmSUAZvSUAgrSUDT4SUDT8SUGgvSUJXoSUJXvSULTrSU8JTSU8LjSV8AnSV8JgSXFToSXLf8SYvAnSZrDUSZrMUSZrMnSZ8HgSZ8JTSZ8JgSZ8MYSZ8QUSaQUoSbCT3SbHToSbQYvSbSl4SboJnSbvFbSb8HbSb8JgSb8OTScGZrScHgrScJTvScMT8ScSToScoHbScrMTScvAnSeAZrSeAcrSeHboSeJUoSeLhrSeMT8SeMXrSe6JgSgHTrSkJnoSkLnvSk8CUSlFl3SlrSnSl8GnSmAboSmGT8SmJU8", + "ATLnDlATrAZoATrJX4ATrMT8ATrMX4ATrRTrATvDl8ATvJUoATvMl8AT3AToAT3MX8AT8CT3AT8DT8AT8HZrAT8HgoAUAgFnAUCTFnAXoMX8AXrAT8AXrGgvAXrJXvAXrOgoAXvLl3AZvAgoAZvFbrAZvJXoAZvJl8AZvJn3AZvMX8AZvSbrAZ8FZoAZ8LZ8AZ8MU8AZ8OTvAZ8SV8AZ8SX3AbAgFZAboJnoAbvGboAb8ATrAb8AZoAb8AgrAb8Al4Ab8Db8Ab8JnoAb8LX4Ab8LZrAb8LhrAb8MT8Ab8OUoAb8Qb8Ab8ST8AcrAUoAcrAc8AcrCZ3AcrFT3AcrFZrAcrJl4AcrJn3AcrMX3AcrOTvAc8AZ8Ac8MT8AfAcJXAgoFn4AgoGgvAgoGnrAgoLc8AgoMXoAgrLnrAkrSZ8AlFXCTAloHboAlrHbrAlrLhrAlrLkoAl3CZrAl3LUoAl3LZrAnrAl4AnrMT8An3HT4BT3IToBX4MnvBb!Ln$CTGXMnCToLZ4CTrHT8CT3JTrCT3RZrCT#GTvCU6GgvCU8Db8CU8GZrCU8HT8CboLl3CbrGgrCbrMU8Cb8DT3Cb8GnrCb8LX4Cb8MT8Cb8ObrCgrGgvCgrKX4Cl8FZoDTrAbvDTrDboDTrGT6DTrJgrDTrMX3DTrRZrDTrRg8DTvAVvDTvFZoDT3DT8DT3Ln3DT4HZrDT4MT8DT8AlrDT8MT8DUAkGbDUDbJnDYLnQlDbDUOYDbMTAnDbMXSnDboAT3DboFn4DboLnvDj6JTrGTCgFTGTGgFnGTJTMnGTLnPlGToJT8GTrCT3GTrLVoGTrLnvGTrMX3GTrMboGTvKl3GZClFnGZrDT3GZ8DTrGZ8FZ8GZ8MXvGZ8On8GZ8ST3GbCnQXGbMbFnGboFboGboJg3GboMXoGb3JTvGb3JboGb3Mn6Gb3Qb8GgDXLjGgMnAUGgrDloGgrHX4GgrSToGgvAXrGgvAZvGgvFbrGgvLl3GgvMnvGnDnLXGnrATrGnrMboGnuLl3HTATMnHTAgCnHTCTCTHTrGTvHTrHTvHTrJX8HTrLl8HTrMT8HTrMgoHTrOTrHTuOn3HTvAZrHTvDTvHTvGboHTvJU8HTvLl3HTvMXrHTvQb4HT4GT6HT4JT8HT4Jb#HT8Al3HT8GZrHT8GgrHT8HX4HT8Jb8HT8JnoHT8LTrHT8LgvHT8SToHT8SV8HUoJUoHUoJX8HUoLnrHXrLZoHXvAl3HX3LnrHX4FkvHX4LhrHX4MXoHX4OnoHZrAZ8HZrDb8HZrGZ8HZrJnrHZvGZ8HZvLnvHZ8JnvHZ8LhrHbCXJlHbMTAnHboJl4HbpLl3HbrJX8HbrLnrHbrMnvHbvRYrHgoSTrHgrFV8HgrGZ8HgrJXoHgrRnvHgvBb!HgvGTrHgvHX4HgvHn!HgvLTrHgvSU8HnDnLbHnFbJbHnvDn8Hn6GgvHn!BTvJTCTLnJTQgFnJTrAnvJTrLX4JTrOUoJTvFn3JTvLnrJTvNToJT3AgoJT3Jn4JT3LhvJT3ObrJT8AcrJT8Al3JT8JT8JT8JnoJT8LX4JT8LnrJT8MX3JT8Rg3JT8Sc8JUoBTvJU8AToJU8GZ8JU8GgvJU8JTrJU8JXrJU8JnrJU8LnvJU8ScvJXHnJlJXrGgvJXrJU8JXrLhrJXrMT8JXrMXrJXrQUoJXvCTvJXvGZ8JXvGgrJXvQT8JX8Ab8JX8DT8JX8GZ8JX8HZvJX8LnrJX8MT8JX8MXoJX8MnvJX8ST3JYGnCTJbAkGbJbCTAnJbLTAcJboDT3JboLb6JbrAnvJbrCn3JbrDl8JbrGboJbrIZoJbrJnvJbrMnvJbrQb4Jb8RZrJeAbAnJgJnFbJgScAnJgrATrJgvHZ8JgvMn4JlJlFbJlLiQXJlLjOnJlRbOlJlvNXoJlvRl3Jl4AcrJl8AUoJl8MnrJnFnMlJnHgGbJnoDT8JnoFV8JnoGgvJnoIT8JnoQToJnoRg3JnrCZ3JnrGgrJnrHTvJnrLf8JnrOX8JnvAT3JnvFZoJnvGT8JnvJl4JnvMT8JnvMX8JnvOXrJnvPX6JnvSX3JnvSZrJn3MT8Jn3MX8Jn3RTrLTATKnLTJnLTLTMXKnLTRTQlLToGb8LTrAZ8LTrCZ8LTrDb8LTrHT8LT3PX6LT4FZoLT$CTvLT$GgrLUvHX3LVoATrLVoAgoLVoJboLVoMX3LVoRg3LV8CZ3LV8FZoLV8GTvLXrDXoLXrFbrLXvAgvLXvFlrLXvLl3LXvRn6LX4Mb8LX8GT8LYCXMnLYrMnrLZoSTvLZrAZvLZrAloLZrFToLZrJXvLZrJboLZrJl4LZrLnrLZrMT8LZrOgvLZrRnvLZrST4LZvMX8LZvSlvLZ8AgoLZ8CT3LZ8JT8LZ8LV8LZ8LZoLZ8Lg8LZ8SV8LZ8SbrLZ$HT8LZ$Mn4La6CTvLbFbMnLbRYFTLbSnFZLboJT8LbrAT9LbrGb3LbrQb8LcrJX8LcrMXrLerHTvLerJbrLerNboLgrDb8LgrGZ8LgrHTrLgrMXrLgrSU8LgvJTrLgvLl3Lg6Ll3LhrLnrLhrMT8LhvAl4LiLnQXLkoAgrLkoJT8LkoJn4LlrSU8Ll3FZoLl3HTrLl3JX8Ll3JnoLl3LToLmLeFbLnDUFbLnLVAnLnrATrLnrAZoLnrAb8LnrAlrLnrGgvLnrJU8LnrLZrLnrLhrLnrMb8LnrOXrLnrSZ8LnvAb4LnvDTrLnvDl8LnvHTrLnvHbrLnvJT8LnvJU8LnvJbrLnvLhvLnvMX8LnvMb8LnvNnoLnvSU8Ln3Al3Ln4FZoLn4GT6Ln4JgvLn4LhrLn4MT8Ln4SToMToCZrMToJX8MToLX4MToLf8MToRg3MTrEloMTvGb6MT3BTrMT3Lb6MT8AcrMT8AgrMT8GZrMT8JnoMT8LnrMT8MX3MUOUAnMXAbFnMXoAloMXoJX8MXoLf8MXoLl8MXrAb8MXrDTvMXrGT8MXrGgrMXrHTrMXrLf8MXrMU8MXrOXvMXrQb8MXvGT8MXvHTrMXvLVoMX3AX3MX3Jn3MX3LhrMX3MX3MX4AlrMX4OboMX8GTvMX8GZrMX8GgrMX8JT8MX8JX8MX8LhrMX8MT8MYDUFbMYMgDbMbGnFfMbvLX4MbvLl3Mb8Mb8Mb8ST4MgGXCnMg8ATrMg8AgoMg8CZrMg8DTrMg8DboMg8HTrMg8JgrMg8LT8MloJXoMl8AhrMl8JT8MnLgAUMnoJXrMnoLX4MnoLhrMnoMT8MnrAl4MnrDb8MnrOTvMnrOgvMnrQb8MnrSU8MnvGgrMnvHZ8Mn3MToMn4DTrMn4LTrMn4Mg8NnBXAnOTFTFnOToAToOTrGgvOTrJX8OT3JXoOT6MTrOT8GgrOT8HTpOT8MToOUoHT8OUoJT8OUoLn3OXrAgoOXrDg8OXrMT8OXvSToOX6CTvOX8CZrOX8OgrOb6HgvOb8AToOb8MT8OcvLZ8OgvAlrOgvHTvOgvJTrOgvJnrOgvLZrOgvLn4OgvMT8OgvRTrOg8AZoOg8DbvOnrOXoOnvJn4OnvLhvOnvRTrOn3GgoOn3JnvOn6JbvOn8OTrPTGYFTPbBnFnPbGnDnPgDYQTPlrAnvPlrETvPlrLnvPlrMXvPlvFX4QTMTAnQTrJU8QYCnJlQYJlQlQbGTQbQb8JnrQb8LZoQb8LnvQb8MT8Qb8Ml8Qb8ST4QloAl4QloHZvQloJX8QloMn8QnJZOlRTrAZvRTrDTrRTvJn4RTvLhvRT4Jb8RZrAZrRZ8AkrRZ8JU8RZ8LV8RZ8LnvRbJlQXRg3GboRg3MnvRg8AZ8Rg8JboRg8Jl4RnLTCbRnvFl3RnvQb8SToAl4SToCZrSToFZoSToHXrSToJU8SToJgvSToJl4SToLhrSToMX3STrAlvSTrCT9STrCgrSTrGgrSTrHXrSTrHboSTrJnoSTrNboSTvLnrST4AZoST8Ab8ST8JT8SUoJn3SU6HZ#SU6JTvSU8Db8SU8HboSU8LgrSV8JT8SZrAcrSZrAl3SZrJT8SZrJnvSZrMT8SZvLUoSZ4FZoSZ8JnoSZ8RZrScoLnrScoMT8ScoMX8ScrAT4ScrAZ8ScrLZ8ScrLkvScvDb8ScvLf8ScvNToSgrFZrShvKnrSloHUoSloLnrSlrMXoSl8HgrSmrJUoSn3BX6", + "ATFlOn3ATLgrDYAT4MTAnAT8LTMnAYJnRTrAbGgJnrAbLV8LnAbvNTAnAeFbLg3AgOYMXoAlQbFboAnDboAfAnJgoJTBToDgAnBUJbAl3BboDUAnCTDlvLnCTFTrSnCYoQTLnDTwAbAnDUDTrSnDUHgHgrDX8LXFnDbJXAcrETvLTLnGTFTQbrGTMnGToGT3DUFbGUJlPX3GbQg8LnGboJbFnGb3GgAYGgAg8ScGgMbAXrGgvAbAnGnJTLnvGnvATFgHTDT6ATHTrDlJnHYLnMn8HZrSbJTHZ8LTFnHbFTJUoHgSeMT8HgrLjAnHgvAbAnHlFUrDlHnDgvAnHnHTFT3HnQTGnrJTAaMXvJTGbCn3JTOgrAnJXvAXMnJbMg8SnJbMnRg3Jb8LTMnJnAl3OnJnGYrQlJnJlQY3LTDlCn3LTJjLg3LTLgvFXLTMg3GTLV8HUOgLXFZLg3LXNXrMnLX8QXFnLX9AlMYLYLXPXrLZAbJU8LZDUJU8LZMXrSnLZ$AgFnLaPXrDULbFYrMnLbMn8LXLboJgJgLeFbLg3LgLZrSnLgOYAgoLhrRnJlLkCTrSnLkOnLhrLnFX%AYLnFZoJXLnHTvJbLnLloAbMTATLf8MTHgJn3MTMXrAXMT3MTFnMUITvFnMXFX%AYMXMXvFbMXrFTDbMYAcMX3MbLf8SnMb8JbFnMgMXrMTMgvAXFnMgvGgCmMnAloSnMnFnJTrOXvMXSnOX8HTMnObJT8ScObLZFl3ObMXCZoPTLgrQXPUFnoQXPU3RXJlPX3RkQXPbrJXQlPlrJbFnQUAhrDbQXGnCXvQYLnHlvQbLfLnvRTOgvJbRXJYrQlRYLnrQlRbLnrQlRlFT8JlRlFnrQXSTClCn3STHTrAnSTLZQlrSTMnGTrSToHgGbSTrGTDnSTvGXCnST3HgFbSU3HXAXSbAnJn3SbFT8LnScLfLnv", + "AT3JgJX8AT8FZoSnAT8JgFV8AT8LhrDbAZ8JT8DbAb8GgLhrAb8SkLnvAe8MT8SnAlMYJXLVAl3GYDTvAl3LfLnvBUDTvLl3CTOn3HTrCT3DUGgrCU8MT8AbCbFTrJUoCgrDb8MTDTLV8JX8DTLnLXQlDT8LZrSnDUQb8FZ8DUST4JnvDb8ScOUoDj6GbJl4GTLfCYMlGToAXvFnGboAXvLnGgAcrJn3GgvFnSToGnLf8JnvGn#HTDToHTLnFXJlHTvATFToHTvHTDToHTvMTAgoHT3STClvHT4AlFl6HT8HTDToHUoDgJTrHUoScMX3HbRZrMXoHboJg8LTHgDb8JTrHgMToLf8HgvLnLnoHnHn3HT4Hn6MgvAnJTJU8ScvJT3AaQT8JT8HTrAnJXrRg8AnJbAloMXoJbrATFToJbvMnoSnJgDb6GgvJgDb8MXoJgSX3JU8JguATFToJlPYLnQlJlQkDnLbJlQlFYJlJl8Lf8OTJnCTFnLbJnLTHXMnJnLXGXCnJnoFfRg3JnrMYRg3Jn3HgFl3KT8Dg8LnLTRlFnPTLTvPbLbvLVoSbrCZLXMY6HT3LXNU7DlrLXNXDTATLX8DX8LnLZDb8JU8LZMnoLhrLZSToJU8LZrLaLnrLZvJn3SnLZ8LhrSnLaJnoMT8LbFlrHTvLbrFTLnrLbvATLlvLb6OTFn3LcLnJZOlLeAT6Mn4LeJT3ObrLg6LXFlrLhrJg8LnLhvDlPX4LhvLfLnvLj6JTFT3LnFbrMXoLnQluCTvLnrQXCY6LnvLfLnvLnvMgLnvLnvSeLf8MTMbrJn3MT3JgST3MT8AnATrMT8LULnrMUMToCZrMUScvLf8MXoDT8SnMX6ATFToMX8AXMT8MX8FkMT8MX8HTrDUMX8ScoSnMYJT6CTvMgAcrMXoMg8SToAfMlvAXLg3MnFl3AnvOT3AnFl3OUoATHT8OU3RnLXrOXrOXrSnObPbvFn6Og8HgrSnOg8OX8DbPTvAgoJgPU3RYLnrPXrDnJZrPb8CTGgvPlrLTDlvPlvFUJnoQUvFXrQlQeMnoAl3QlrQlrSnRTFTrJUoSTDlLiLXSTFg6HT3STJgoMn4STrFTJTrSTrLZFl3ST4FnMXoSUrDlHUoScvHTvSnSfLkvMXo", + "AUoAcrMXoAZ8HboAg8AbOg6ATFgAg8AloMXoAl3AT8JTrAl8MX8MXoCT3SToJU8Cl8Db8MXoDT8HgrATrDboOT8MXoGTOTrATMnGT8LhrAZ8GnvFnGnQXHToGgvAcrHTvAXvLl3HbrAZoMXoHgBlFXLg3HgMnFXrSnHgrSb8JUoHn6HT8LgvITvATrJUoJUoLZrRnvJU8HT8Jb8JXvFX8QT8JXvLToJTrJYrQnGnQXJgrJnoATrJnoJU8ScvJnvMnvMXoLTCTLgrJXLTJlRTvQlLbRnJlQYvLbrMb8LnvLbvFn3RnoLdCVSTGZrLeSTvGXCnLg3MnoLn3MToLlrETvMT8SToAl3MbrDU6GTvMb8LX4LhrPlrLXGXCnSToLf8Rg3STrDb8LTrSTvLTHXMnSb3RYLnMnSgOg6ATFg", + "HUDlGnrQXrJTrHgLnrAcJYMb8DULc8LTvFgGnCk3Mg8JbAnLX4QYvFYHnMXrRUoJnGnvFnRlvFTJlQnoSTrBXHXrLYSUJgLfoMT8Se8DTrHbDb", + "AbDl8SToJU8An3RbAb8ST8DUSTrGnrAgoLbFU6Db8LTrMg8AaHT8Jb8ObDl8SToJU8Pb3RlvFYoJl" +]; +const codes$1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*"; +function getHangul(code) { + if (code >= 40) { + code = code + 168 - 40; + } + else if (code >= 19) { + code = code + 97 - 19; + } + return toUtf8String(new Uint8Array([225, (code >> 6) + 132, (code & 0x3f) + 128])); +} +let _wordlist$1 = null; +function loadWords$1() { + if (_wordlist$1 != null) { + return _wordlist$1; + } + const wordlist = []; + data$1.forEach((data, length) => { + length += 4; + for (let i = 0; i < data.length; i += length) { + let word = ""; + for (let j = 0; j < length; j++) { + word += getHangul(codes$1.indexOf(data[i + j])); + } + wordlist.push(word); + } + }); + wordlist.sort(); + // Verify the computed list matches the official list + /* istanbul ignore if */ + const checksum = id$1(wordlist.join("\n") + "\n"); + /* c8 ignore start */ + if (checksum !== "0xf9eddeace9c5d3da9c93cf7d3cd38f6a13ed3affb933259ae865714e8a3ae71a") { + throw new Error("BIP39 Wordlist for ko (Korean) FAILED"); + } + /* c8 ignore stop */ + _wordlist$1 = wordlist; + return wordlist; +} +let wordlist$2 = null; +/** + * The [[link-bip39-ko]] for [mnemonic phrases](link-bip-39). + * + * @_docloc: api/wordlists + */ +class LangKo extends Wordlist { + /** + * Creates a new instance of the Korean language Wordlist. + * + * This should be unnecessary most of the time as the exported + * [[langKo]] should suffice. + * + * @_ignore: + */ + constructor() { + super("ko"); + } + getWord(index) { + const words = loadWords$1(); + assertArgument(index >= 0 && index < words.length, `invalid word index: ${index}`, "index", index); + return words[index]; + } + getWordIndex(word) { + return loadWords$1().indexOf(word); + } + /** + * Returns a singleton instance of a ``LangKo``, creating it + * if this is the first time being called. + */ + static wordlist() { + if (wordlist$2 == null) { + wordlist$2 = new LangKo(); + } + return wordlist$2; + } +} + +const words$1 = "0torea noica!iosorolotaleratelanena%oiadoencotivomai t ca%a0A]Bagl'Bin#E.Is(Oli!Rasi_Rog#0Cade!C[$Cus#E Roba+U 0Ag'Deb{DomeEgu#Eri!IpeOtt&Ul&1Fabi,Fe|Fis(F-n Oris`O(R~$0AveEn.E_,Ganc'I!It&OnismoR>*Rume Uzzo4AbardaA Bat)Ber#BoBumeCeCol>E|Ertu-OdePari!Pe^ Pogg'P)@Pun Ri,1Ab~AchideAgos+Ald~Anc'Atu-AzzoBit)Chiv'D{Eni,G[ GiSoTef%eZil*0Ciu|Col EpsiEtt>Fal I$O/Pir#P)Sagg'SeSolu Sur@TaT[u T%eT-|0Av>EismoOm>O$TesaTiv&Tor$Tr{Tua,0Sil'Str?Tis+To$moTun$0Anz#E!V[i!Vi(Volge!3IoS(Tos+Ttu U,VaVosa3C]FfaLg'LvaNdaNe_,Nig$Nzi=ReRli=Ta3Bi+CiDoR@S]Tan>T^$Zzo*2Acc'AdipoA`An}Avu-E.l/Eve|EzzaIgl?Il/n.Ind&Oc]*O@Onzi=Ul*U$2BboT+di$UffoVet+Vi,2Ass>In~O)2C]Dar@D%eE!n.G$meLl&Lm#Lo!Lpo(L^v#LzaMaMe+M`n@Mo@Mpu.rMuS+n.Ttu-V#2A.!Avat+E#Ede!Emo(Esci+E+Ice I=,IsiIt>OceO=}Os++Uc?,Us}2Ci!Cu*Gi$Ll#Po/R#!R(!R_Sci$S de:DoI$L`+Meri$Nie/N$(Nz&T#Van^Vve)3Bu|C[n'Ci(Cli$Col*C! D%#Fin{FormeG$Leg&Lfi$Lir'L+M[zaNot#Nt)Pos{Rapa+Riv&RogaScri|Ser Sider'Sume!Tersi_Vo 3Amet)Cemb!Ed)Fe(Ffu(Geri!Gi+,Luv'Nam>N=nziPin P*`Po*Rad&ReRo|RupoSag'Sc! Sf&Sge*Spos S+nzaSu`$ToVa$Vel Vide!Vor#5B*I}MoSaU(0An#B,`Es(I)O^_Oz'U*0Dem>Du)Erg?FasiO.}Tr&Zi`1A^.I*goI(d'O},Pu!0U#!0Ar'BaBo(EdeEmi+Ige!Met>OeOsi_Ran.0Ago$AmeAnimeAudi!CaEmp'Erc{Ib{Ig[.Is.!I OfagoOrt#O(Pan(P!s(S[zaSoTe(Tim&Ton?T)(Ult&0Il>N>Rus]To0ClideoRopa0A(Id[zaIt#Olu Viva:Bbr~Cc[daChi)L]Migl?Na,Nfa-NgoN+s`ReRfal/Ri$(R`]Sc?S (Sul*T%&ToVo*(3Bb!Co/DeG#LpaLt)Mmi=Nde!Nome$Rm[ R)R^,Ssu-S^_T+U@3AbaDuc?FaGur#LoNanzaNest-Ni!O!S},S>Ume2A]Cacc?Co(Der#Gl'La+Lc*!Lgo!Nd[.Net>N?N+=Rb{Rchet+Res+Rm~R='RoR.zzaRz&Sf#S(2A}s(A=Assi$A.l*Eccet+E=+Es]IgoOlli$OndeUga,Ut+2Ci/+Cs?Gg[.LmiT Ud'ZeboZzel/3CoLa^=L(Mel*Mm#NeN{!N='No^poRgo2Epar@Iacc'Isa0Al*LdaNep)Oc&Oiel*Or$OveR#RoAmmoAndeAtt&A_(Az?E}EggeIfoIll'O*RaR>Roge$2IeLude!0Bal*Bevu Boc]Bu MaO.siP~1IdeLandaOn>Rig#Ror&0Ol#O poTer>Titu Tr%e0Al?Er&:::Bb)Birin C}Cer#Cri`Cu=D@veGoMpoNcet+N.r=R@(RgaRingeSt-T[zaTi$TtugaVag=Vo)3Ga,Gge)MboN.zzaNzaOGl?G<.G)Iol~LafedeLg-@Lin.(Lsa$L Lumo!NaNc?N@r/Ngi&Nifes N=)Nov-NsardaN^deNubr'PpaR#=Rci!Ret+RmoRsup'Sche-Ssa?S^$Te-s(Tr>/T Ce=.DesimoDit&GaLassaLisLod?NingeNoN(/Rcur'R[daR*Schi$SeSse!S *Tal*To@T.!3Agol&CaCel'Che,C)boDol*E,Gl'!La$Li.MosaNe-,NiNo!Ri$R^l*Sce/SsivaS Sur&TezzaTig&T-T.n.4Emon>0Del*Dif~Du*Ga$G'LeLos(Nas.)N]Ndi=Ne+r'Ni,No $N(3Cch?NfaTi@5Bi,Ci_DoMeMi=Rd>R`,RvegeseSt-$T&Tiz?Ttur$Vel/5C,oL/Me)O_Tri!Vo/Z?,:Si0Bedi!BligoElis]L'O*So, 0Cas'B-EgaIss'<0Do(E!IceNi_)O!_,Ta1Er#In'IgiDel/D)Ri.RolisiTo2AceboAn&As`A+$E=r'2ChezzaDe)(DismoEs?Ggi&L[+Ligo$Ll%eLmoni.Lpet+L(Lt)=Lve!M%eMo@)N.Po*(Rfi@Ro(Rpo-R!R++SaSi^_Sses(Stul#Tass'Te!2AnzoAssiAt~Eclu(Ed~Efis(Egi#Elie_Eme!E$t&Epar#Es[zaE.s Eval(I`IncipeIv#Ob,`Ocu-Odur!OfumoOge|OlungaOmessaO$meOpos+O)gaO.(OvaUd[.Ug=Ur{0Iche1Bbl>D~Gil#G$LceL{Lsan.Nt&PazzoPil/Ro:99Ad)Al]saAsiE!/O+:C]l D@pp'D~,Dun#Ff~GazzoG'*Dur!Fas&F,s(For`Fug'G&Gett#Ghel*Lass#Lev#MaT)_Un'Bus Cc?CoDagg'De!D{!G{Ll'Mant>Mpe!Nz'Sol&SpoTan.Ton@Tu/Vesc'5BizzoBr~GaLli$Mi:B#Bbi&Bot#Go`Las(Ldatu-Lgem`Liv&LmoEtt)HedaHie=IarpaI[zaInde!IppoI)ppoI_*Ler&Odel/Olp{Ompar Onfor Opri!Or+Os(Mul#Nfon?Ngo*Nist)NoN.siNu(idePar'S`S ,Tu#2It+Ogatu-Ove$0Arr{Emor#En^ E-l@IlzoOnt&Ott#Uss#0Elli!Erv#O@0BbalzoBr'C]r(C?,Da,Ffi|G$Ld#L[M`NdaNe|Nnife)Pi!Ppe(P-Rge!Rpas(Rri(R(R.gg'R_l#Spi)S+T^,0AdaAl/Arge!A /Av[ Azzo/EcieEdi!EgRappoReg#Ridu*Rozz&Ru|Ucc&UfoUp[@0B[t)C](Do!Gger{GoL+$On&PerboPpor Rgel#R)g#Ssur)Tu-0Ag&EdeseEgl'El&Enu Ez?IluppoIs+Izze-Ol+Uot&:Bac]Bul#Cci&Citur$LeLis`$MpoVer=Vo/+Zza3CaCn>Lefo$Me-r'MpoMu N@Pog-foRagg'RoTan'To*Tuban.Z'Zzo<5Cc&L,r&L Mbo/MoNfoNsil/Paz'Po*g?PpaRbaRn&R)L,t+Lo)(Lut&L_/Mpa+Ng&N{(NoN+gg'Nve-Po!Ra$Rc#R?n.S}3Det+DovaDu Ge+,I]*Lc)Li=Llu LoceN#Ndemm?N RaceRba,Rgog=Rif~RoRru}Rt~,Sc~Ssil*S+,Te-$Tri=Tus 3Andan.B-n.C[daChingoCi=nzaDim&Gil?G< Go!LeL/$MiniNc{!O/Pe-Rgo/Ro*goRu,n S](S'5Cche)Fo*LuPpa"; +const checksum$1 = "0x5c1362d88fd4cf614a96f3234941d29f7d37c08c5292fde03bf62c2db6ff7620"; +let wordlist$1 = null; +/** + * The [[link-bip39-it]] for [mnemonic phrases](link-bip-39). + * + * @_docloc: api/wordlists + */ +class LangIt extends WordlistOwl { + /** + * Creates a new instance of the Italian language Wordlist. + * + * This should be unnecessary most of the time as the exported + * [[langIt]] should suffice. + * + * @_ignore: + */ + constructor() { super("it", words$1, checksum$1); } + /** + * Returns a singleton instance of a ``LangIt``, creating it + * if this is the first time being called. + */ + static wordlist() { + if (wordlist$1 == null) { + wordlist$1 = new LangIt(); + } + return wordlist$1; + } +} + +const words = "0arad!ototealirertainrasoent hoandoaR#riareha!aroele'oronul0Aca%AixoAl A%rDuz'El]Er$IsmoO$ Rum S-&T(i&TigoVo[=0F&.Il#P' S?S* So&/Sun$Tr&0Ac#Adu+Al/A[f E End(Er_EuIng'Ir?IvoOl{oRac Revi=RizU&Um0Di$rM-.R>o+TismoT|@Tu 0Ali An%Ar@Ent&Es,I?Is Ul,1Ila1Ar E=Ei%Ulejo:B BosaC&]uCh `C@GagemI+c>~/Se#S)n%Ta)Te=rTidaTomTuc Unil]3B(IjoIr^IsebolLd!eLezaLgaLisc Ndi$Ng&aNz(RimbauRl*d>_Sou_XigaZ(_3CoCu=En&Foc&Furc G|naLhe%Mest[Mo$rOlog@OmboOsf(aPol Rr-$Scoi$Sne$SpoSsex$TolaZ _2Ind#OcoOque 2A$BagemC#CejoChec]Ico.L^LetimL]LoMb{oNdeNecoNi)Rb~h>d>e&R+c]V*oXe?2AncoAsaAvezaEuIgaIl/Inc OaOchu+Onze O$Uxo2C]DismoF LeRacoScaS$Z*a:Bimb Rn{oRpe%R['>)zRv&/SacoScaSeb[S%loS~oT a)Tiv UleUs?U%l V&oV(na3BolaDil]G}]Lebr L~ Nou+N,N%ioRc Rr#R%'oRvejaTimV^2Aco)Al{aAm#Ap^ArmeAticeAveEfeEg^E'oEqueIco%If[In`oOc&/Ov(UmboU.Uva0CatrizCl}eD!eD['aEn%Gcui$Rurg@T 2A[zaE_Ic OneUbe2A=Ag'Ba@B($rBr C^El/Ent_E,Gum`oIb'IfaIo%L L{aLh(Lid'Lme@L}oLunaM<=Mb* M-.MitivaMov(MplexoMumNc]N=rNec.Nfu,Ng` Nhec(Njug Nsum'Nt+$Nvi%Op( P{oPi?PoQue%lRagemRdi&Rne)R}h>p|&R[ioR%joRuj>voSs-oS%laT}e%U_UveVilZ*]2A%+AvoEcheE=rEmeErEspoI^Im*&Io~oIseItic Os)UaUz{o2B+m SafioSbo.Sc<,S-/Sfi#Sgas%Sigu&SlizeSmam SovaSpesaS)queSvi T&h T-$rT} Tri$UsaV(Vi=Vot#Z-a3Ag+maAle$Da)Fu,Gi.Lat#Lu-%M*u'Nast@Nh{oOceseRe$Sc[)Sf ceSp oSque%Ssip S)n%T?UrnoV(,Vi,rV~g Z(5Br?L|i=M?M*#NativoNz`>m-%Rs&SagemUr#U$r2EnagemIbleOg @2El EndeE$PloQues><%Vi=,:1Lod'O Olog@0Ific It&Uc#1Ei$Etiv 3E.1Ab| Eg(Ei$rEncoEv?Im* Ogi 0B goBol#Br~/Buti=EndaErg'Is,rPat@P-/P*#Polg P[goPurr Ul?0CaixeC-#Ch-%C}t_Deus Doss Faix Fei%FimGaj#G-/Glob Gom#G+x Gu@Jo La.Qu<$Raiz Rol#Rug SaioSe^S*oSop#T<$Te#Tid!eT|.Tr^T~/V(g Vi#Volv(XameX($Xof[Xu$1Id(me0Uip 0E$Gui=Ra)VaVil]0Bopeu0Acu Ap| AsivoEntu&Id-%Olu'1Ag(oAl Am* A$Aus$Ces,Ci.Clam Ecu.EmploIb'Ig-%On( Pof>p>tu+T@T|V|i)X*aZ-da3Ch#Ijo^I+n%L*oM**oNdaNoR>i#RrugemRv(S%j T&Ud&3ApoB_seC Ch{oGur#L{aL/LmeLtr RmezaSg^Ssu+TaV`aX?Xo2AcidezAm*goAn`aEch^O+Utu Uxo2C&C*/Foc GoGue%IceLg#Lhe$Rj Rmig>noR%ScoSsa2Aga)AldaAngoAscoA%rnoE'aEn%E.IezaI,Itu+On]Ustr U%'a2G'L+faSodu$S$TaTil/Ve)Z`a3L#Le@LoM^M(Mi=N(o,NgivaNi&NomaN_Ologi>?Rm* S,S$r3Nas)Nc*o2Aci&IcoseOb&Orio,2ElaIabaLfeLpe Rdu+Rje)R_S$,T{aV(n 2AcejoAdu&Afi%Al]AmpoAn^Atui$Ave$AxaEgoElh EveIloIs&/I.@Os,O%scoUd#Unhi=U)2AcheA+niAx*imEr[ I Inc/Is#LaLo,Ru:Bi.Rm}@S%V(3C.eRd Res@Si.3A$B(n D+.EnaNoPismoPnosePo%ca5JeLofo%MemNes$Nr#Rm}&Sped 5M|#:Te2E@O,2N|#RejaUdimR_SmimToV&iZida3Jum9An*]Elh^G?I>n&Rr Vem5BaDeuDocaIzLg?L/R#Ris)RoS)::B edaB|&C[C)n%Dril/G )GoaJeMb(M-.M* MpejoNchePid P,R{>gu+S<]St_T(&Ti=VfimRgemR*/Rmi)Ro$RquiseR[coR%loRujoSco%Sm|+SsagemStig Tag&T(noT*&Tu.Xil 3D&]DidaDusaGaf}eIgaLc/Sc~ SeuSic&:Ci}&D?JaMo_R*>r#Sc(TivaTu[zaV&]Veg Vio3Bl*aB~o,GativaGoci Gri$Rvo,TaUr&VascaVo{o3N N/TidezV` 5B[zaI%IvaMe M*&Rdes%R% T Tici TurnoV`oVil/Vo5Bl#DezM(&Pci&Tr'Vem:0Cec#Edec(JetivoRig#Scu_S%t+T(Tur 0Id-%Io,Orr(Ulis)Up#2Eg<%EnsivaEr-daIc*aUsc#0Iva4Ar@Eo,H Iv{a0B_Ele%Is,It'0D~#E_,Tem1Ci}&Er?On-%OrtunoOs$1ArBi.DemD*&Fci&Rd&RedeRtidaSmoSs#S%lTam T-%T* T_noUl^Us 3C~i D& Dest[D@t+D+G^I$r&IxeLeLicplexoRsi<>%nceRucaSc#SquisaS,aTisc 3AdaC#Ed!eGm-$Last+Lh#Lo.M-)Nc`NguimN]No%N.On{oPocaQue%ResRue)Sc S$laTg-$Rje)Tur Ud!eXof}eZ}&3C C~ DaD-$Di#Do,Du$rGm-$G[=Gun=IvaLe$LvagemM<&M-%N?N/rNsu&Nt#P #Rei>*g>+RvoTemb_T|3GiloLhue)Lic}eMetr@Mpat@M~ N&Nc(oNg~ NopseN$ni>-eRiTu#5B(fis)Rp[s>[&Rt'Sp'oS%n$:B`aBle%Bu^C/G `aLh(LoLvezMdioRef>j>+xaTuagemUr*oXativoXis)3Atr&C(Ci=Cl#Dio,IaIm Lef}eLh#Mp(oN-%N,rN.Rm&RnoRr-oSeSou+St#ToXtu+Xugo3A+G`aJoloMbr MidezNgi=N%'oRagemT~ 5Al]C]L( LiceM^Mil/N`Ntu+Pe%R>ci=RneioRqueRr!>$S.UcaUp{aX*a2Ab&/Acej Adu$rAfeg Aje$AmaAnc ApoAs{oAt?Av E*oEm(Epid EvoIagemIboIcicloId-%Ilog@Ind!eIploItur Iunf&Oc Ombe)OvaUnfoUque2B~ CquesaT` T|i&:7V 3Bigo0HaId!eIf|me3Olog@SoTigaUbu0A=InaUfru':C*aDi G o,I=,LaL-%Lid!eLo[sN)gemQu{oRe)Rr(Sc~ Sil]S,u+Z Zio3A=D Ge.Ic~ L{oLhiceLu=Nce=rNdav&N( Nt[Rb&Rd!eRe?Rg}h>m`/RnizRs R%n%SpaSti=T|i&3Adu$AgemAj Atu+Br?D{aDr @ElaGaG-%Gi G| L ejoNcoNhe)NilOle)R!>tudeSi.S$Tr&V{oZ*/5A=rArG&L<%LeibolL)gemLumo,Nt!e5L$Vuz`a::D[zRope3QueRe.Rife3Ng ::Ng#Rp 3BuL?9Mb Olog@5Mbi="; +const checksum = "0x2219000926df7b50d8aa0a3d495826b988287df4657fbd100e6fe596c8f737ac"; +let wordlist = null; +/** + * The [[link-bip39-pt]] for [mnemonic phrases](link-bip-39). + * + * @_docloc: api/wordlists + */ +class LangPt extends WordlistOwl { + /** + * Creates a new instance of the Portuguese language Wordlist. + * + * This should be unnecessary most of the time as the exported + * [[langPt]] should suffice. + * + * @_ignore: + */ + constructor() { super("pt", words, checksum); } + /** + * Returns a singleton instance of a ``LangPt``, creating it + * if this is the first time being called. + */ + static wordlist() { + if (wordlist == null) { + wordlist = new LangPt(); + } + return wordlist; + } +} + +const data = "}aE#4A=Yv&co#4N#6G=cJ&SM#66|/Z#4t&kn~46#4K~4q%b9=IR#7l,mB#7W_X2*dl}Uo~7s}Uf&Iw#9c&cw~6O&H6&wx&IG%v5=IQ~8a&Pv#47$PR&50%Ko&QM&3l#5f,D9#4L|/H&tQ;v0~6n]nN> 2), + 128 + codes.indexOf(data[i * 3 + 1]), + 128 + codes.indexOf(data[i * 3 + 2]), + ]; + if (locale === "zh_tw") { + const common = s % 4; + for (let i = common; i < 3; i++) { + bytes[i] = codes.indexOf(deltaData[deltaOffset++]) + ((i == 0) ? 228 : 128); + } + } + wordlist.push(toUtf8String(new Uint8Array(bytes))); + } + // Verify the computed list matches the official list + const checksum = id$1(wordlist.join("\n") + "\n"); + /* c8 ignore start */ + if (checksum !== Checks[locale]) { + throw new Error(`BIP39 Wordlist for ${locale} (Chinese) FAILED`); + } + /* c8 ignore stop */ + _wordlist[locale] = wordlist; + return wordlist; +} +const wordlists = {}; +/** + * The [[link-bip39-zh_cn]] and [[link-bip39-zh_tw]] for + * [mnemonic phrases](link-bip-39). + * + * @_docloc: api/wordlists + */ +class LangZh extends Wordlist { + /** + * Creates a new instance of the Chinese language Wordlist for + * the %%dialect%%, either ``"cn"`` or ``"tw"`` for simplified + * or traditional, respectively. + * + * This should be unnecessary most of the time as the exported + * [[langZhCn]] and [[langZhTw]] should suffice. + * + * @_ignore: + */ + constructor(dialect) { super("zh_" + dialect); } + getWord(index) { + const words = loadWords(this.locale); + assertArgument(index >= 0 && index < words.length, `invalid word index: ${index}`, "index", index); + return words[index]; + } + getWordIndex(word) { + return loadWords(this.locale).indexOf(word); + } + split(phrase) { + phrase = phrase.replace(/(?:\u3000| )+/g, ""); + return phrase.split(""); + } + /** + * Returns a singleton instance of a ``LangZh`` for %%dialect%%, + * creating it if this is the first time being called. + * + * Use the %%dialect%% ``"cn"`` or ``"tw"`` for simplified or + * traditional, respectively. + */ + static wordlist(dialect) { + if (wordlists[dialect] == null) { + wordlists[dialect] = new LangZh(dialect); + } + return wordlists[dialect]; + } +} + +/** + * The available Wordlists by their + * [ISO 639-1 Language Code](link-wiki-iso639). + * + * (**i.e.** [cz](LangCz), [en](LangEn), [es](LangEs), [fr](LangFr), + * [ja](LangJa), [ko](LangKo), [it](LangIt), [pt](LangPt), + * [zh_cn](LangZh), [zh_tw](LangZh)) + * + * The dist files (in the ``/dist`` folder) have had all languages + * except English stripped out, which reduces the library size by + * about 80kb. If required, they are available by importing the + * included ``wordlists-extra.min.js`` file. + */ +({ + cz: LangCz.wordlist(), + en: LangEn.wordlist(), + es: LangEs.wordlist(), + fr: LangFr.wordlist(), + it: LangIt.wordlist(), + pt: LangPt.wordlist(), + ja: LangJa.wordlist(), + ko: LangKo.wordlist(), + zh_cn: LangZh.wordlist("cn"), + zh_tw: LangZh.wordlist("tw"), +}); + +const _abi$1H = [ + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + }, + { + internalType: "uint256", + name: "balance", + type: "uint256" + }, + { + internalType: "uint256", + name: "needed", + type: "uint256" + }, + { + internalType: "uint256", + name: "tokenId", + type: "uint256" + } + ], + name: "ERC1155InsufficientBalance", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "approver", + type: "address" + } + ], + name: "ERC1155InvalidApprover", + type: "error" + }, + { + inputs: [ + { + internalType: "uint256", + name: "idsLength", + type: "uint256" + }, + { + internalType: "uint256", + name: "valuesLength", + type: "uint256" + } + ], + name: "ERC1155InvalidArrayLength", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "operator", + type: "address" + } + ], + name: "ERC1155InvalidOperator", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "receiver", + type: "address" + } + ], + name: "ERC1155InvalidReceiver", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + } + ], + name: "ERC1155InvalidSender", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "operator", + type: "address" + }, + { + internalType: "address", + name: "owner", + type: "address" + } + ], + name: "ERC1155MissingApprovalForAll", + type: "error" + } +]; +class IERC1155Errors__factory { + static createInterface() { + return new Interface(_abi$1H); + } + static connect(address, runner) { + return new Contract(address, _abi$1H, runner); + } +} +IERC1155Errors__factory.abi = _abi$1H; + +const _abi$1G = [ + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "allowance", + type: "uint256" + }, + { + internalType: "uint256", + name: "needed", + type: "uint256" + } + ], + name: "ERC20InsufficientAllowance", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + }, + { + internalType: "uint256", + name: "balance", + type: "uint256" + }, + { + internalType: "uint256", + name: "needed", + type: "uint256" + } + ], + name: "ERC20InsufficientBalance", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "approver", + type: "address" + } + ], + name: "ERC20InvalidApprover", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "receiver", + type: "address" + } + ], + name: "ERC20InvalidReceiver", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + } + ], + name: "ERC20InvalidSender", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "ERC20InvalidSpender", + type: "error" + } +]; +class IERC20Errors__factory { + static createInterface() { + return new Interface(_abi$1G); + } + static connect(address, runner) { + return new Contract(address, _abi$1G, runner); + } +} +IERC20Errors__factory.abi = _abi$1G; + +const _abi$1F = [ + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + }, + { + internalType: "uint256", + name: "tokenId", + type: "uint256" + }, + { + internalType: "address", + name: "owner", + type: "address" + } + ], + name: "ERC721IncorrectOwner", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "operator", + type: "address" + }, + { + internalType: "uint256", + name: "tokenId", + type: "uint256" + } + ], + name: "ERC721InsufficientApproval", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "approver", + type: "address" + } + ], + name: "ERC721InvalidApprover", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "operator", + type: "address" + } + ], + name: "ERC721InvalidOperator", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + } + ], + name: "ERC721InvalidOwner", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "receiver", + type: "address" + } + ], + name: "ERC721InvalidReceiver", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + } + ], + name: "ERC721InvalidSender", + type: "error" + }, + { + inputs: [ + { + internalType: "uint256", + name: "tokenId", + type: "uint256" + } + ], + name: "ERC721NonexistentToken", + type: "error" + } +]; +class IERC721Errors__factory { + static createInterface() { + return new Interface(_abi$1F); + } + static connect(address, runner) { + return new Contract(address, _abi$1F, runner); + } +} +IERC721Errors__factory.abi = _abi$1F; + +const _abi$1E = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +class IERC20Metadata__factory { + static createInterface() { + return new Interface(_abi$1E); + } + static connect(address, runner) { + return new Contract(address, _abi$1E, runner); + } +} +IERC20Metadata__factory.abi = _abi$1E; + +const _abi$1D = [ + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "allowance", + type: "uint256" + }, + { + internalType: "uint256", + name: "needed", + type: "uint256" + } + ], + name: "ERC20InsufficientAllowance", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + }, + { + internalType: "uint256", + name: "balance", + type: "uint256" + }, + { + internalType: "uint256", + name: "needed", + type: "uint256" + } + ], + name: "ERC20InsufficientBalance", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "approver", + type: "address" + } + ], + name: "ERC20InvalidApprover", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "receiver", + type: "address" + } + ], + name: "ERC20InvalidReceiver", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + } + ], + name: "ERC20InvalidSender", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "ERC20InvalidSpender", + type: "error" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +let ERC20__factory$1 = class ERC20__factory { + static createInterface() { + return new Interface(_abi$1D); + } + static connect(address, runner) { + return new Contract(address, _abi$1D, runner); + } +}; +ERC20__factory$1.abi = _abi$1D; + +const _abi$1C = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +let IERC20__factory$2 = class IERC20__factory { + static createInterface() { + return new Interface(_abi$1C); + } + static connect(address, runner) { + return new Contract(address, _abi$1C, runner); + } +}; +IERC20__factory$2.abi = _abi$1C; + +const _abi$1B = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "OwnershipTransferred", + type: "event" + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class Ownable__factory { + static createInterface() { + return new Interface(_abi$1B); + } + static connect(address, runner) { + return new Contract(address, _abi$1B, runner); + } +} +Ownable__factory.abi = _abi$1B; + +const _abi$1A = [ + { + stateMutability: "payable", + type: "fallback" + }, + { + stateMutability: "payable", + type: "receive" + } +]; +class Proxy__factory { + static createInterface() { + return new Interface(_abi$1A); + } + static connect(address, runner) { + return new Contract(address, _abi$1A, runner); + } +} +Proxy__factory.abi = _abi$1A; + +const _abi$1z = [ + { + inputs: [ + { + internalType: "address", + name: "_logic", + type: "address" + }, + { + internalType: "address", + name: "_admin", + type: "address" + }, + { + internalType: "bytes", + name: "_data", + type: "bytes" + } + ], + stateMutability: "payable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "previousAdmin", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "newAdmin", + type: "address" + } + ], + name: "AdminChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "implementation", + type: "address" + } + ], + name: "Upgraded", + type: "event" + }, + { + stateMutability: "payable", + type: "fallback" + }, + { + inputs: [], + name: "admin", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newAdmin", + type: "address" + } + ], + name: "changeAdmin", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "implementation", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address" + } + ], + name: "upgradeTo", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + stateMutability: "payable", + type: "receive" + } +]; +const _bytecode$V = "0x60806040526040516108dc3803806108dc8339818101604052606081101561002657600080fd5b8151602083015160408085018051915193959294830192918464010000000082111561005157600080fd5b90830190602082018581111561006657600080fd5b825164010000000081118282018810171561008057600080fd5b82525081516020918201929091019080838360005b838110156100ad578181015183820152602001610095565b50505050905090810190601f1680156100da5780820380516001836020036101000a031916815260200191505b50604052508491508290506100ee826101bf565b8051156101a6576000826001600160a01b0316826040518082805190602001908083835b602083106101315780518252601f199092019160209182019101610112565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114610191576040519150601f19603f3d011682016040523d82523d6000602084013e610196565b606091505b50509050806101a457600080fd5b505b506101ae9050565b6101b782610231565b50505061025b565b6101d28161025560201b6103b41760201c565b61020d5760405162461bcd60e51b81526004018080602001828103825260368152602001806108a66036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b3b151590565b61063c8061026a6000396000f3fe60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100985780635c60da1b146101185780638f28397014610149578063f851a4401461017c5761005d565b3661005d5761005b610191565b005b61005b610191565b34801561007157600080fd5b5061005b6004803603602081101561008857600080fd5b50356001600160a01b03166101ab565b61005b600480360360408110156100ae57600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100d957600080fd5b8201836020820111156100eb57600080fd5b8035906020019184600183028401116401000000008311171561010d57600080fd5b5090925090506101e5565b34801561012457600080fd5b5061012d610292565b604080516001600160a01b039092168252519081900360200190f35b34801561015557600080fd5b5061005b6004803603602081101561016c57600080fd5b50356001600160a01b03166102cf565b34801561018857600080fd5b5061012d610389565b6101996103ba565b6101a96101a461041a565b61043f565b565b6101b3610463565b6001600160a01b0316336001600160a01b031614156101da576101d581610488565b6101e2565b6101e2610191565b50565b6101ed610463565b6001600160a01b0316336001600160a01b031614156102855761020f83610488565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d806000811461026c576040519150601f19603f3d011682016040523d82523d6000602084013e610271565b606091505b505090508061027f57600080fd5b5061028d565b61028d610191565b505050565b600061029c610463565b6001600160a01b0316336001600160a01b031614156102c4576102bd61041a565b90506102cc565b6102cc610191565b90565b6102d7610463565b6001600160a01b0316336001600160a01b031614156101da576001600160a01b0381166103355760405162461bcd60e51b815260040180806020018281038252603a815260200180610555603a913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61035e610463565b604080516001600160a01b03928316815291841660208301528051918290030190a16101d5816104c8565b6000610393610463565b6001600160a01b0316336001600160a01b031614156102c4576102bd610463565b3b151590565b6103c2610463565b6001600160a01b0316336001600160a01b031614156104125760405162461bcd60e51b81526004018080602001828103825260428152602001806105c56042913960600191505060405180910390fd5b6101a96101a9565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e80801561045e573d6000f35b3d6000fd5b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b610491816104ec565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b6104f5816103b4565b6105305760405162461bcd60e51b815260040180806020018281038252603681526020018061058f6036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5556fe5472616e73706172656e745570677261646561626c6550726f78793a206e65772061646d696e20697320746865207a65726f20616464726573735570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e74726163745472616e73706172656e745570677261646561626c6550726f78793a2061646d696e2063616e6e6f742066616c6c6261636b20746f2070726f787920746172676574a26469706673582212200bf5c74f32000c92994fb0de053047d19f9c526eb1b1953df8bcb7d7e0df8d2864736f6c634300060c00335570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374"; +const isSuperArgs$V = (xs) => xs.length > 1; +class TransparentUpgradeableProxy__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$V(args)) { + super(...args); + } else { + super(_abi$1z, _bytecode$V, args[0]); + } + } + getDeployTransaction(_logic, _admin, _data, overrides) { + return super.getDeployTransaction(_logic, _admin, _data, overrides || {}); + } + deploy(_logic, _admin, _data, overrides) { + return super.deploy(_logic, _admin, _data, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$1z); + } + static connect(address, runner) { + return new Contract( + address, + _abi$1z, + runner + ); + } +} +TransparentUpgradeableProxy__factory.bytecode = _bytecode$V; +TransparentUpgradeableProxy__factory.abi = _abi$1z; + +const _abi$1y = [ + { + inputs: [ + { + internalType: "address", + name: "_logic", + type: "address" + }, + { + internalType: "bytes", + name: "_data", + type: "bytes" + } + ], + stateMutability: "payable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "implementation", + type: "address" + } + ], + name: "Upgraded", + type: "event" + }, + { + stateMutability: "payable", + type: "fallback" + }, + { + stateMutability: "payable", + type: "receive" + } +]; +const _bytecode$U = "0x60806040526040516103123803806103128339818101604052604081101561002657600080fd5b81516020830180516040519294929383019291908464010000000082111561004d57600080fd5b90830190602082018581111561006257600080fd5b825164010000000081118282018810171561007c57600080fd5b82525081516020918201929091019080838360005b838110156100a9578181015183820152602001610091565b50505050905090810190601f1680156100d65780820380516001836020036101000a031916815260200191505b50604052506100e3915050565b6100ec826101ab565b8051156101a4576000826001600160a01b0316826040518082805190602001908083835b6020831061012f5780518252601f199092019160209182019101610110565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461018f576040519150601f19603f3d011682016040523d82523d6000602084013e610194565b606091505b50509050806101a257600080fd5b505b5050610223565b6101be8161021d60201b6100271760201c565b6101f95760405162461bcd60e51b81526004018080602001828103825260368152602001806102dc6036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b3b151590565b60ab806102316000396000f3fe608060405236601057600e6013565b005b600e5b60196025565b60256021602d565b6052565b565b3b151590565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e8080156070573d6000f35b3d6000fdfea2646970667358221220621b7042bfb847b4073a3c58bdbea5295ce2e761b4e2307ca010caaac996d80c64736f6c634300060c00335570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374"; +const isSuperArgs$U = (xs) => xs.length > 1; +class UpgradeableProxy__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$U(args)) { + super(...args); + } else { + super(_abi$1y, _bytecode$U, args[0]); + } + } + getDeployTransaction(_logic, _data, overrides) { + return super.getDeployTransaction(_logic, _data, overrides || {}); + } + deploy(_logic, _data, overrides) { + return super.deploy(_logic, _data, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$1y); + } + static connect(address, runner) { + return new Contract(address, _abi$1y, runner); + } +} +UpgradeableProxy__factory.bytecode = _bytecode$U; +UpgradeableProxy__factory.abi = _abi$1y; + +const _abi$1x = [ + { + inputs: [ + { + internalType: "string", + name: "name", + type: "string" + }, + { + internalType: "string", + name: "symbol", + type: "string" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "subtractedValue", + type: "uint256" + } + ], + name: "decreaseAllowance", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "addedValue", + type: "uint256" + } + ], + name: "increaseAllowance", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + }, + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$T = "0x608060405234801561001057600080fd5b5060405162000c6238038062000c628339818101604052604081101561003557600080fd5b810190808051604051939291908464010000000082111561005557600080fd5b90830190602082018581111561006a57600080fd5b825164010000000081118282018810171561008457600080fd5b82525081516020918201929091019080838360005b838110156100b1578181015183820152602001610099565b50505050905090810190601f1680156100de5780820380516001836020036101000a031916815260200191505b506040526020018051604051939291908464010000000082111561010157600080fd5b90830190602082018581111561011657600080fd5b825164010000000081118282018810171561013057600080fd5b82525081516020918201929091019080838360005b8381101561015d578181015183820152602001610145565b50505050905090810190601f16801561018a5780820380516001836020036101000a031916815260200191505b50604052505082516101a4915060039060208501906101cd565b5080516101b89060049060208401906101cd565b50506005805460ff1916601217905550610260565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061020e57805160ff191683800117855561023b565b8280016001018555821561023b579182015b8281111561023b578251825591602001919060010190610220565b5061024792915061024b565b5090565b5b80821115610247576000815560010161024c565b6109f280620002706000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c8063395093511161007157806339509351146101d957806370a082311461020557806395d89b411461022b578063a457c2d714610233578063a9059cbb1461025f578063dd62ed3e1461028b576100a9565b806306fdde03146100ae578063095ea7b31461012b57806318160ddd1461016b57806323b872dd14610185578063313ce567146101bb575b600080fd5b6100b66102b9565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100f05781810151838201526020016100d8565b50505050905090810190601f16801561011d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101576004803603604081101561014157600080fd5b506001600160a01b03813516906020013561034f565b604080519115158252519081900360200190f35b61017361036c565b60408051918252519081900360200190f35b6101576004803603606081101561019b57600080fd5b506001600160a01b03813581169160208101359091169060400135610372565b6101c36103f9565b6040805160ff9092168252519081900360200190f35b610157600480360360408110156101ef57600080fd5b506001600160a01b038135169060200135610402565b6101736004803603602081101561021b57600080fd5b50356001600160a01b0316610450565b6100b661046b565b6101576004803603604081101561024957600080fd5b506001600160a01b0381351690602001356104cc565b6101576004803603604081101561027557600080fd5b506001600160a01b038135169060200135610534565b610173600480360360408110156102a157600080fd5b506001600160a01b0381358116916020013516610548565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156103455780601f1061031a57610100808354040283529160200191610345565b820191906000526020600020905b81548152906001019060200180831161032857829003601f168201915b5050505050905090565b600061036361035c610573565b8484610577565b50600192915050565b60025490565b600061037f848484610663565b6103ef8461038b610573565b6103ea85604051806060016040528060288152602001610927602891396001600160a01b038a166000908152600160205260408120906103c9610573565b6001600160a01b0316815260208101919091526040016000205491906107be565b610577565b5060019392505050565b60055460ff1690565b600061036361040f610573565b846103ea8560016000610420610573565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610855565b6001600160a01b031660009081526020819052604090205490565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156103455780601f1061031a57610100808354040283529160200191610345565b60006103636104d9610573565b846103ea856040518060600160405280602581526020016109986025913960016000610503610573565b6001600160a01b03908116825260208083019390935260409182016000908120918d168152925290205491906107be565b6000610363610541610573565b8484610663565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b3390565b6001600160a01b0383166105bc5760405162461bcd60e51b81526004018080602001828103825260248152602001806109746024913960400191505060405180910390fd5b6001600160a01b0382166106015760405162461bcd60e51b81526004018080602001828103825260228152602001806108df6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166106a85760405162461bcd60e51b815260040180806020018281038252602581526020018061094f6025913960400191505060405180910390fd5b6001600160a01b0382166106ed5760405162461bcd60e51b81526004018080602001828103825260238152602001806108bc6023913960400191505060405180910390fd5b6106f88383836108b6565b61073581604051806060016040528060268152602001610901602691396001600160a01b03861660009081526020819052604090205491906107be565b6001600160a01b0380851660009081526020819052604080822093909355908416815220546107649082610855565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000818484111561084d5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156108125781810151838201526020016107fa565b50505050905090810190601f16801561083f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000828201838110156108af576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b50505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220347718b9db0288208ab5957df73278c6f781963df0e13918151971217fc2827964736f6c634300060c0033"; +const isSuperArgs$T = (xs) => xs.length > 1; +let ERC20__factory$2 = class ERC20__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$T(args)) { + super(...args); + } else { + super(_abi$1x, _bytecode$T, args[0]); + } + } + getDeployTransaction(name, symbol, overrides) { + return super.getDeployTransaction(name, symbol, overrides || {}); + } + deploy(name, symbol, overrides) { + return super.deploy(name, symbol, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$1x); + } + static connect(address, runner) { + return new Contract(address, _abi$1x, runner); + } +}; +ERC20__factory$2.bytecode = _bytecode$T; +ERC20__factory$2.abi = _abi$1x; + +const _abi$1w = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "burn", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "burnFrom", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "subtractedValue", + type: "uint256" + } + ], + name: "decreaseAllowance", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "addedValue", + type: "uint256" + } + ], + name: "increaseAllowance", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + }, + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +class ERC20Burnable__factory { + static createInterface() { + return new Interface(_abi$1w); + } + static connect(address, runner) { + return new Contract(address, _abi$1w, runner); + } +} +ERC20Burnable__factory.abi = _abi$1w; + +const _abi$1v = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + }, + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +let IERC20__factory$1 = class IERC20__factory { + static createInterface() { + return new Interface(_abi$1v); + } + static connect(address, runner) { + return new Contract(address, _abi$1v, runner); + } +}; +IERC20__factory$1.abi = _abi$1v; + +const _abi$1u = [ + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "account", + type: "address" + } + ], + name: "Paused", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "account", + type: "address" + } + ], + name: "Unpaused", + type: "event" + }, + { + inputs: [], + name: "paused", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + } +]; +class Pausable__factory { + static createInterface() { + return new Interface(_abi$1u); + } + static connect(address, runner) { + return new Contract(address, _abi$1u, runner); + } +} +Pausable__factory.abi = _abi$1u; + +const _abi$1t = [ + { + inputs: [ + { + internalType: "uint256", + name: "in_xL", + type: "uint256" + }, + { + internalType: "uint256", + name: "in_xR", + type: "uint256" + } + ], + name: "MiMCSponge", + outputs: [ + { + internalType: "uint256", + name: "xL", + type: "uint256" + }, + { + internalType: "uint256", + name: "xR", + type: "uint256" + } + ], + stateMutability: "pure", + type: "function" + } +]; +class IHasher__factory { + static createInterface() { + return new Interface(_abi$1t); + } + static connect(address, runner) { + return new Contract(address, _abi$1t, runner); + } +} +IHasher__factory.abi = _abi$1t; + +const _abi$1s = [ + { + inputs: [ + { + internalType: "uint32", + name: "_levels", + type: "uint32" + }, + { + internalType: "contract IHasher", + name: "_hasher", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [], + name: "FIELD_SIZE", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "ROOT_HISTORY_SIZE", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "ZERO_VALUE", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "currentRootIndex", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "filledSubtrees", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getLastRoot", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IHasher", + name: "_hasher", + type: "address" + }, + { + internalType: "bytes32", + name: "_left", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "_right", + type: "bytes32" + } + ], + name: "hashLeftRight", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "pure", + type: "function" + }, + { + inputs: [], + name: "hasher", + outputs: [ + { + internalType: "contract IHasher", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_root", + type: "bytes32" + } + ], + name: "isKnownRoot", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "levels", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "nextIndex", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "roots", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "zeros", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$S = "0x60c0604052600380546001600160401b031916905534801561002057600080fd5b50604051610a10380380610a1083398101604081905261003f91610385565b60008263ffffffff16116100a65760405162461bcd60e51b815260206004820152602360248201527f5f6c6576656c732073686f756c642062652067726561746572207468616e207a60448201526265726f60e81b60648201526084015b60405180910390fd5b60208263ffffffff16106100fc5760405162461bcd60e51b815260206004820152601e60248201527f5f6c6576656c732073686f756c64206265206c657373207468616e2033320000604482015260640161009d565b63ffffffff821660a0526001600160a01b0381166080527f2fe54c60d3acabf3343a35b6eba15db4821b340f76e741e2249685ed4899af6c60005b8363ffffffff168163ffffffff1610156101845763ffffffff8116600090815260016020908152604080832085905590829052902082905561017a8383806101b8565b9150600101610137565b506000805260026020527fac33ff75c19e70fe83507db0d683fd3465c996598dc972688b7ace676c89077b55506103f89050565b60006000805160206109f083398151915283106102175760405162461bcd60e51b815260206004820181905260248201527f5f6c6566742073686f756c6420626520696e7369646520746865206669656c64604482015260640161009d565b6000805160206109f0833981519152821061027e5760405162461bcd60e51b815260206004820152602160248201527f5f72696768742073686f756c6420626520696e7369646520746865206669656c6044820152601960fa1b606482015260840161009d565b60405163f47d33b560e01b81526004810184905260006024820181905284916001600160a01b0387169063f47d33b5906044016040805180830381865afa1580156102cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102f191906103d4565b90925090506000805160206109f083398151915284830860405163f47d33b560e01b815260048101829052602481018390529092506001600160a01b0387169063f47d33b5906044016040805180830381865afa158015610356573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061037a91906103d4565b509695505050505050565b6000806040838503121561039857600080fd5b825163ffffffff811681146103ac57600080fd5b60208401519092506001600160a01b03811681146103c957600080fd5b809150509250929050565b600080604083850312156103e757600080fd5b505080516020909101519092909150565b60805160a0516105d361041d60003960006101010152600061020f01526105d36000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063c2b40ae41161008c578063ec73295911610066578063ec732959146101e3578063ed33639f1461020a578063f178e47c14610249578063fc7e9c6f1461026957600080fd5b8063c2b40ae41461019b578063cd87a3b4146101bb578063e8295588146101c357600080fd5b8063414a37ba146100d45780634ecf518b146100fc5780636d9833e3146101385780638ea3099e1461015b57806390eeb02b1461016e578063ba70f7571461017e575b600080fd5b6100e960008051602061057e83398151915281565b6040519081526020015b60405180910390f35b6101237f000000000000000000000000000000000000000000000000000000000000000081565b60405163ffffffff90911681526020016100f3565b61014b6101463660046104d1565b610281565b60405190151581526020016100f3565b6100e96101693660046104ea565b6102ff565b6003546101239063ffffffff1681565b60035463ffffffff166000908152600260205260409020546100e9565b6100e96101a93660046104d1565b60026020526000908152604090205481565b610123601e81565b6100e96101d13660046104d1565b60016020526000908152604090205481565b6100e97f2fe54c60d3acabf3343a35b6eba15db4821b340f76e741e2249685ed4899af6c81565b6102317f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100f3565b6100e96102573660046104d1565b60006020819052908152604090205481565b60035461012390640100000000900463ffffffff1681565b600081810361029257506000919050565b60035463ffffffff16805b63ffffffff811660009081526002602052604090205484036102c3575060019392505050565b8063ffffffff166000036102d55750601e5b806102df8161052b565b9150508163ffffffff168163ffffffff160361029d575060009392505050565b600060008051602061057e83398151915283106103635760405162461bcd60e51b815260206004820181905260248201527f5f6c6566742073686f756c6420626520696e7369646520746865206669656c6460448201526064015b60405180910390fd5b60008051602061057e83398151915282106103ca5760405162461bcd60e51b815260206004820152602160248201527f5f72696768742073686f756c6420626520696e7369646520746865206669656c6044820152601960fa1b606482015260840161035a565b60405163f47d33b560e01b81526004810184905260006024820181905284916001600160a01b0387169063f47d33b5906044016040805180830381865afa158015610419573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061043d9190610559565b909250905060008051602061057e83398151915284830860405163f47d33b560e01b815260048101829052602481018390529092506001600160a01b0387169063f47d33b5906044016040805180830381865afa1580156104a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104c69190610559565b509695505050505050565b6000602082840312156104e357600080fd5b5035919050565b6000806000606084860312156104ff57600080fd5b83356001600160a01b038116811461051657600080fd5b95602085013595506040909401359392505050565b600063ffffffff82168061054f57634e487b7160e01b600052601160045260246000fd5b6000190192915050565b6000806040838503121561056c57600080fd5b50508051602090910151909290915056fe30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001a2646970667358221220073b750aae4dba8655a2e525b0e8b02446e762412e24ec1684e134ada3303bda64736f6c6343000819003330644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001"; +const isSuperArgs$S = (xs) => xs.length > 1; +class MerkleTreeWithHistory__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$S(args)) { + super(...args); + } else { + super(_abi$1s, _bytecode$S, args[0]); + } + } + getDeployTransaction(_levels, _hasher, overrides) { + return super.getDeployTransaction(_levels, _hasher, overrides || {}); + } + deploy(_levels, _hasher, overrides) { + return super.deploy(_levels, _hasher, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$1s); + } + static connect(address, runner) { + return new Contract( + address, + _abi$1s, + runner + ); + } +} +MerkleTreeWithHistory__factory.bytecode = _bytecode$S; +MerkleTreeWithHistory__factory.abi = _abi$1s; + +const _abi$1r = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + inputs: [], + name: "_totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "who", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transfer", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class ERC20Basic__factory { + static createInterface() { + return new Interface(_abi$1r); + } + static connect(address, runner) { + return new Contract(address, _abi$1r, runner); + } +} +ERC20Basic__factory.abi = _abi$1r; + +const _abi$1q = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + inputs: [], + name: "_totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "approve", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "who", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transfer", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class IUSDT__factory { + static createInterface() { + return new Interface(_abi$1q); + } + static connect(address, runner) { + return new Contract(address, _abi$1q, runner); + } +} +IUSDT__factory.abi = _abi$1q; + +const _abi$1p = [ + { + stateMutability: "nonpayable", + type: "fallback" + } +]; +const _bytecode$R = "0x6080604052348015600f57600080fd5b50609c80601d6000396000f3fe6080604052348015600f57600080fd5b5060405162461bcd60e51b815260206004820152602160248201527f7468697320636f6e747261637420646f6573206e6f74206163636570742045546044820152600960fb1b606482015260840160405180910390fdfea264697066735822122034c2432feedadd0f30a6f66555381c20922b6ab7c9b3ede4c27896b23e802a8264736f6c63430008190033"; +const isSuperArgs$R = (xs) => xs.length > 1; +class BadRecipient__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$R(args)) { + super(...args); + } else { + super(_abi$1p, _bytecode$R, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$1p); + } + static connect(address, runner) { + return new Contract(address, _abi$1p, runner); + } +} +BadRecipient__factory.bytecode = _bytecode$R; +BadRecipient__factory.abi = _abi$1p; + +const _abi$1o = [ + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "allowance", + type: "uint256" + }, + { + internalType: "uint256", + name: "needed", + type: "uint256" + } + ], + name: "ERC20InsufficientAllowance", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + }, + { + internalType: "uint256", + name: "balance", + type: "uint256" + }, + { + internalType: "uint256", + name: "needed", + type: "uint256" + } + ], + name: "ERC20InsufficientBalance", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "approver", + type: "address" + } + ], + name: "ERC20InvalidApprover", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "receiver", + type: "address" + } + ], + name: "ERC20InvalidReceiver", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + } + ], + name: "ERC20InvalidSender", + type: "error" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "ERC20InvalidSpender", + type: "error" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "mint", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$Q = "0x608060405234801561001057600080fd5b50604051806040016040528060078152602001664441494d6f636b60c81b815250604051806040016040528060048152602001634441494d60e01b815250816003908161005d9190610113565b50600461006a8282610113565b5050506101d2565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061009c57607f821691505b6020821081036100bc57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561010e576000816000526020600020601f850160051c810160208610156100eb5750805b601f850160051c820191505b8181101561010a578281556001016100f7565b5050505b505050565b81516001600160401b0381111561012c5761012c610072565b6101408161013a8454610088565b846100c2565b602080601f831160018114610175576000841561015d5750858301515b600019600386901b1c1916600185901b17855561010a565b600085815260208120601f198616915b828110156101a457888601518255948401946001909101908401610185565b50858210156101c25787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b610785806101e16000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c806340c10f191161006657806340c10f191461011857806370a082311461012d57806395d89b4114610156578063a9059cbb1461015e578063dd62ed3e1461017157600080fd5b806306fdde03146100a3578063095ea7b3146100c157806318160ddd146100e457806323b872dd146100f6578063313ce56714610109575b600080fd5b6100ab6101aa565b6040516100b891906105ce565b60405180910390f35b6100d46100cf366004610639565b61023c565b60405190151581526020016100b8565b6002545b6040519081526020016100b8565b6100d4610104366004610663565b610256565b604051601281526020016100b8565b61012b610126366004610639565b61027a565b005b6100e861013b36600461069f565b6001600160a01b031660009081526020819052604090205490565b6100ab610288565b6100d461016c366004610639565b610297565b6100e861017f3660046106c1565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6060600380546101b9906106f4565b80601f01602080910402602001604051908101604052809291908181526020018280546101e5906106f4565b80156102325780601f1061020757610100808354040283529160200191610232565b820191906000526020600020905b81548152906001019060200180831161021557829003601f168201915b5050505050905090565b60003361024a8185856102a5565b60019150505b92915050565b6000336102648582856102b7565b61026f85858561033a565b506001949350505050565b6102848282610399565b5050565b6060600480546101b9906106f4565b60003361024a81858561033a565b6102b283838360016103cf565b505050565b6001600160a01b038381166000908152600160209081526040808320938616835292905220546000198114610334578181101561032557604051637dc7a0d960e11b81526001600160a01b038416600482015260248101829052604481018390526064015b60405180910390fd5b610334848484840360006103cf565b50505050565b6001600160a01b03831661036457604051634b637e8f60e11b81526000600482015260240161031c565b6001600160a01b03821661038e5760405163ec442f0560e01b81526000600482015260240161031c565b6102b28383836104a4565b6001600160a01b0382166103c35760405163ec442f0560e01b81526000600482015260240161031c565b610284600083836104a4565b6001600160a01b0384166103f95760405163e602df0560e01b81526000600482015260240161031c565b6001600160a01b03831661042357604051634a1406b160e11b81526000600482015260240161031c565b6001600160a01b038085166000908152600160209081526040808320938716835292905220829055801561033457826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161049691815260200190565b60405180910390a350505050565b6001600160a01b0383166104cf5780600260008282546104c4919061072e565b909155506105419050565b6001600160a01b038316600090815260208190526040902054818110156105225760405163391434e360e21b81526001600160a01b0385166004820152602481018290526044810183905260640161031c565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b03821661055d5760028054829003905561057c565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516105c191815260200190565b60405180910390a3505050565b60006020808352835180602085015260005b818110156105fc578581018301518582016040015282016105e0565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461063457600080fd5b919050565b6000806040838503121561064c57600080fd5b6106558361061d565b946020939093013593505050565b60008060006060848603121561067857600080fd5b6106818461061d565b925061068f6020850161061d565b9150604084013590509250925092565b6000602082840312156106b157600080fd5b6106ba8261061d565b9392505050565b600080604083850312156106d457600080fd5b6106dd8361061d565b91506106eb6020840161061d565b90509250929050565b600181811c9082168061070857607f821691505b60208210810361072857634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561025057634e487b7160e01b600052601160045260246000fdfea264697066735822122058942fcc650d3670455590fabbf6c5726b3ae7df7b57e75bc02cb2c66259d45b64736f6c63430008190033"; +const isSuperArgs$Q = (xs) => xs.length > 1; +class ERC20Mock__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$Q(args)) { + super(...args); + } else { + super(_abi$1o, _bytecode$Q, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$1o); + } + static connect(address, runner) { + return new Contract(address, _abi$1o, runner); + } +} +ERC20Mock__factory.bytecode = _bytecode$Q; +ERC20Mock__factory.abi = _abi$1o; + +const _abi$1n = [ + { + inputs: [ + { + internalType: "bytes", + name: "_initCode", + type: "bytes" + }, + { + internalType: "bytes32", + name: "_salt", + type: "bytes32" + } + ], + name: "deploy", + outputs: [ + { + internalType: "address payable", + name: "createdContract", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +let IDeployer__factory$1 = class IDeployer__factory { + static createInterface() { + return new Interface(_abi$1n); + } + static connect(address, runner) { + return new Contract(address, _abi$1n, runner); + } +}; +IDeployer__factory$1.abi = _abi$1n; + +const _abi$1m = [ + { + inputs: [ + { + internalType: "uint32", + name: "_treeLevels", + type: "uint32" + }, + { + internalType: "contract IHasher", + name: "_hasher", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [], + name: "FIELD_SIZE", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "ROOT_HISTORY_SIZE", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "ZERO_VALUE", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "currentRootIndex", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "filledSubtrees", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getLastRoot", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IHasher", + name: "_hasher", + type: "address" + }, + { + internalType: "bytes32", + name: "_left", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "_right", + type: "bytes32" + } + ], + name: "hashLeftRight", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "pure", + type: "function" + }, + { + inputs: [], + name: "hasher", + outputs: [ + { + internalType: "contract IHasher", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_leaf", + type: "bytes32" + } + ], + name: "insert", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_root", + type: "bytes32" + } + ], + name: "isKnownRoot", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "levels", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "nextIndex", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "roots", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "zeros", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$P = "0x60c0604052600380546001600160401b031916905534801561002057600080fd5b50604051610e3c380380610e3c83398101604081905261003f91610389565b818160008263ffffffff16116100a85760405162461bcd60e51b815260206004820152602360248201527f5f6c6576656c732073686f756c642062652067726561746572207468616e207a60448201526265726f60e81b60648201526084015b60405180910390fd5b60208263ffffffff16106100fe5760405162461bcd60e51b815260206004820152601e60248201527f5f6c6576656c732073686f756c64206265206c657373207468616e2033320000604482015260640161009f565b63ffffffff821660a0526001600160a01b0381166080527f2fe54c60d3acabf3343a35b6eba15db4821b340f76e741e2249685ed4899af6c60005b8363ffffffff168163ffffffff1610156101865763ffffffff8116600090815260016020908152604080832085905590829052902082905561017c8383806101bc565b9150600101610139565b506000805260026020527fac33ff75c19e70fe83507db0d683fd3465c996598dc972688b7ace676c89077b55506103fc92505050565b6000600080516020610e1c833981519152831061021b5760405162461bcd60e51b815260206004820181905260248201527f5f6c6566742073686f756c6420626520696e7369646520746865206669656c64604482015260640161009f565b600080516020610e1c83398151915282106102825760405162461bcd60e51b815260206004820152602160248201527f5f72696768742073686f756c6420626520696e7369646520746865206669656c6044820152601960fa1b606482015260840161009f565b60405163f47d33b560e01b81526004810184905260006024820181905284916001600160a01b0387169063f47d33b5906044016040805180830381865afa1580156102d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102f591906103d8565b9092509050600080516020610e1c83398151915284830860405163f47d33b560e01b815260048101829052602481018390529092506001600160a01b0387169063f47d33b5906044016040805180830381865afa15801561035a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061037e91906103d8565b509695505050505050565b6000806040838503121561039c57600080fd5b825163ffffffff811681146103b057600080fd5b60208401519092506001600160a01b03811681146103cd57600080fd5b809150509250929050565b600080604083850312156103eb57600080fd5b505080516020909101519092909150565b60805160a0516109e6610436600039600081816101310152818161052701526105c901526000818161023f015261066101526109e66000f3fe608060405234801561001057600080fd5b50600436106100ea5760003560e01c8063c2b40ae41161008c578063ec73295911610066578063ec73295914610213578063ed33639f1461023a578063f178e47c14610279578063fc7e9c6f1461029957600080fd5b8063c2b40ae4146101cb578063cd87a3b4146101eb578063e8295588146101f357600080fd5b80636d9833e3116100c85780636d9833e3146101685780638ea3099e1461018b57806390eeb02b1461019e578063ba70f757146101ae57600080fd5b80632d287e43146100ef578063414a37ba146101045780634ecf518b1461012c575b600080fd5b6101026100fd36600461072c565b6102b1565b005b61011960008051602061099183398151915281565b6040519081526020015b60405180910390f35b6101537f000000000000000000000000000000000000000000000000000000000000000081565b60405163ffffffff9091168152602001610123565b61017b61017636600461072c565b6102be565b6040519015158152602001610123565b610119610199366004610745565b61033c565b6003546101539063ffffffff1681565b60035463ffffffff16600090815260026020526040902054610119565b6101196101d936600461072c565b60026020526000908152604090205481565b610153601e81565b61011961020136600461072c565b60016020526000908152604090205481565b6101197f2fe54c60d3acabf3343a35b6eba15db4821b340f76e741e2249685ed4899af6c81565b6102617f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610123565b61011961028736600461072c565b60006020819052908152604090205481565b60035461015390640100000000900463ffffffff1681565b6102ba8161050e565b5050565b60008181036102cf57506000919050565b60035463ffffffff16805b63ffffffff81166000908152600260205260409020548403610300575060019392505050565b8063ffffffff166000036103125750601e5b8061031c8161079c565b9150508163ffffffff168163ffffffff16036102da575060009392505050565b600060008051602061099183398151915283106103a05760405162461bcd60e51b815260206004820181905260248201527f5f6c6566742073686f756c6420626520696e7369646520746865206669656c6460448201526064015b60405180910390fd5b60008051602061099183398151915282106104075760405162461bcd60e51b815260206004820152602160248201527f5f72696768742073686f756c6420626520696e7369646520746865206669656c6044820152601960fa1b6064820152608401610397565b60405163f47d33b560e01b81526004810184905260006024820181905284916001600160a01b0387169063f47d33b5906044016040805180830381865afa158015610456573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061047a91906107bc565b909250905060008051602061099183398151915284830860405163f47d33b560e01b815260048101829052602481018390529092506001600160a01b0387169063f47d33b5906044016040805180830381865afa1580156104df573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050391906107bc565b509695505050505050565b600354600090640100000000900463ffffffff1661054d7f00000000000000000000000000000000000000000000000000000000000000006002610909565b63ffffffff168163ffffffff16036105c05760405162461bcd60e51b815260206004820152603060248201527f4d65726b6c6520747265652069732066756c6c2e204e6f206d6f7265206c656160448201526f1d995cc818d85b88189948185919195960821b6064820152608401610397565b8083600080805b7f000000000000000000000000000000000000000000000000000000000000000063ffffffff168163ffffffff16101561069e57610606600286610926565b63ffffffff166000036106405763ffffffff811660009081526001602090815260408083205491839052909120859055849350915061065c565b63ffffffff811660009081526020819052604090205492508391505b6106877f0000000000000000000000000000000000000000000000000000000000000000848461033c565b9350610694600286610949565b94506001016105c7565b50600354600090601e906106b99063ffffffff16600161096c565b6106c39190610926565b6003805463ffffffff191663ffffffff8316908117909155600090815260026020526040902085905590506106f986600161096c565b6003805463ffffffff929092166401000000000267ffffffff000000001990921691909117905550939695505050505050565b60006020828403121561073e57600080fd5b5035919050565b60008060006060848603121561075a57600080fd5b83356001600160a01b038116811461077157600080fd5b95602085013595506040909401359392505050565b634e487b7160e01b600052601160045260246000fd5b600063ffffffff8216806107b2576107b2610786565b6000190192915050565b600080604083850312156107cf57600080fd5b505080516020909101519092909150565b634e487b7160e01b600052601260045260246000fd5b600181815b80851115610833578163ffffffff0482111561081957610819610786565b8085161561082657918102915b93841c93908002906107fb565b509250929050565b60008261084a57506001610903565b8161085757506000610903565b816001811461086d5760028114610877576108a8565b6001915050610903565b60ff84111561088857610888610786565b6001841b915063ffffffff8211156108a2576108a2610786565b50610903565b5060208310610133831016604e8410600b84101617156108df575081810a63ffffffff8111156108da576108da610786565b610903565b6108e983836107f6565b8063ffffffff048211156108ff576108ff610786565b0290505b92915050565b600063ffffffff61091e81851682851661083b565b949350505050565b600063ffffffff8084168061093d5761093d6107e0565b92169190910692915050565b600063ffffffff80841680610960576109606107e0565b92169190910492915050565b63ffffffff81811683821601908082111561098957610989610786565b509291505056fe30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001a26469706673582212202d7e980def4626c357f1bcdaac465eacf4317fbdecbf5d0a96b796c5d828cb7464736f6c6343000819003330644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001"; +const isSuperArgs$P = (xs) => xs.length > 1; +class MerkleTreeWithHistoryMock__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$P(args)) { + super(...args); + } else { + super(_abi$1m, _bytecode$P, args[0]); + } + } + getDeployTransaction(_treeLevels, _hasher, overrides) { + return super.getDeployTransaction(_treeLevels, _hasher, overrides || {}); + } + deploy(_treeLevels, _hasher, overrides) { + return super.deploy(_treeLevels, _hasher, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$1m); + } + static connect(address, runner) { + return new Contract( + address, + _abi$1m, + runner + ); + } +} +MerkleTreeWithHistoryMock__factory.bytecode = _bytecode$P; +MerkleTreeWithHistoryMock__factory.abi = _abi$1m; + +const _abi$1l = [ + { + inputs: [ + { + internalType: "bytes", + name: "_proof", + type: "bytes" + }, + { + internalType: "uint256[6]", + name: "_input", + type: "uint256[6]" + } + ], + name: "verifyProof", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +class IVerifier__factory { + static createInterface() { + return new Interface(_abi$1l); + } + static connect(address, runner) { + return new Contract(address, _abi$1l, runner); + } +} +IVerifier__factory.abi = _abi$1l; + +const _abi$1k = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "commitment", + type: "bytes32" + }, + { + indexed: false, + internalType: "uint32", + name: "leafIndex", + type: "uint32" + }, + { + indexed: false, + internalType: "uint256", + name: "timestamp", + type: "uint256" + } + ], + name: "Deposit", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "bytes32", + name: "nullifierHash", + type: "bytes32" + }, + { + indexed: true, + internalType: "address", + name: "relayer", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "fee", + type: "uint256" + } + ], + name: "Withdrawal", + type: "event" + }, + { + inputs: [], + name: "FIELD_SIZE", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "ROOT_HISTORY_SIZE", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "ZERO_VALUE", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + name: "commitments", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "currentRootIndex", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "denomination", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_commitment", + type: "bytes32" + } + ], + name: "deposit", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "filledSubtrees", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getLastRoot", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IHasher", + name: "_hasher", + type: "address" + }, + { + internalType: "bytes32", + name: "_left", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "_right", + type: "bytes32" + } + ], + name: "hashLeftRight", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "pure", + type: "function" + }, + { + inputs: [], + name: "hasher", + outputs: [ + { + internalType: "contract IHasher", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_root", + type: "bytes32" + } + ], + name: "isKnownRoot", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_nullifierHash", + type: "bytes32" + } + ], + name: "isSpent", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32[]", + name: "_nullifierHashes", + type: "bytes32[]" + } + ], + name: "isSpentArray", + outputs: [ + { + internalType: "bool[]", + name: "spent", + type: "bool[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "levels", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "nextIndex", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + name: "nullifierHashes", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "roots", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "verifier", + outputs: [ + { + internalType: "contract IVerifier", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes", + name: "_proof", + type: "bytes" + }, + { + internalType: "bytes32", + name: "_root", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "_nullifierHash", + type: "bytes32" + }, + { + internalType: "address payable", + name: "_recipient", + type: "address" + }, + { + internalType: "address payable", + name: "_relayer", + type: "address" + }, + { + internalType: "uint256", + name: "_fee", + type: "uint256" + }, + { + internalType: "uint256", + name: "_refund", + type: "uint256" + } + ], + name: "withdraw", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "zeros", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + } +]; +class Tornado__factory { + static createInterface() { + return new Interface(_abi$1k); + } + static connect(address, runner) { + return new Contract(address, _abi$1k, runner); + } +} +Tornado__factory.abi = _abi$1k; + +const _abi$1j = [ + { + inputs: [], + name: "denomination", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "commitment", + type: "bytes32" + } + ], + name: "deposit", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [], + name: "token", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes", + name: "proof", + type: "bytes" + }, + { + internalType: "bytes32", + name: "root", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "nullifierHash", + type: "bytes32" + }, + { + internalType: "address payable", + name: "recipient", + type: "address" + }, + { + internalType: "address payable", + name: "relayer", + type: "address" + }, + { + internalType: "uint256", + name: "fee", + type: "uint256" + }, + { + internalType: "uint256", + name: "refund", + type: "uint256" + } + ], + name: "withdraw", + outputs: [], + stateMutability: "payable", + type: "function" + } +]; +let ITornadoInstance__factory$1 = class ITornadoInstance__factory { + static createInterface() { + return new Interface(_abi$1j); + } + static connect(address, runner) { + return new Contract(address, _abi$1j, runner); + } +}; +ITornadoInstance__factory$1.abi = _abi$1j; + +const _abi$1i = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address" + }, + { + indexed: false, + internalType: "bytes", + name: "encryptedNote", + type: "bytes" + } + ], + name: "EncryptedNote", + type: "event" + }, + { + inputs: [ + { + internalType: "bytes[]", + name: "_encryptedNotes", + type: "bytes[]" + } + ], + name: "backupNotes", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "_tornado", + type: "address" + }, + { + internalType: "bytes32", + name: "_commitment", + type: "bytes32" + }, + { + internalType: "bytes", + name: "_encryptedNote", + type: "bytes" + } + ], + name: "deposit", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "_tornado", + type: "address" + }, + { + internalType: "bytes", + name: "_proof", + type: "bytes" + }, + { + internalType: "bytes32", + name: "_root", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "_nullifierHash", + type: "bytes32" + }, + { + internalType: "address payable", + name: "_recipient", + type: "address" + }, + { + internalType: "address payable", + name: "_relayer", + type: "address" + }, + { + internalType: "uint256", + name: "_fee", + type: "uint256" + }, + { + internalType: "uint256", + name: "_refund", + type: "uint256" + } + ], + name: "withdraw", + outputs: [], + stateMutability: "payable", + type: "function" + } +]; +const _bytecode$O = "0x608060405234801561001057600080fd5b506104f6806100206000396000f3fe6080604052600436106100345760003560e01c806313d98d13146100395780636485ba2a1461004e578063b438689f1461006e575b600080fd5b61004c6100473660046102c7565b610081565b005b34801561005a57600080fd5b5061004c610069366004610258565b61012a565b61004c61007c366004610321565b610198565b60405163b214faa560e01b81526001600160a01b0385169063b214faa59034906100af9087906004016103ec565b6000604051808303818588803b1580156100c857600080fd5b505af11580156100dc573d6000803e3d6000fd5b5050505050336001600160a01b03167ffa28df43db3553771f7209dcef046f3bdfea15870ab625dcda30ac58b82b4008838360405161011c9291906103f5565b60405180910390a250505050565b60005b8181101561019357337ffa28df43db3553771f7209dcef046f3bdfea15870ab625dcda30ac58b82b400884848481811061016357fe5b90506020028101906101759190610463565b6040516101839291906103f5565b60405180910390a260010161012d565b505050565b6040516310d056db60e11b81526001600160a01b038a16906321a0adb69034906101d4908c908c908c908c908c908c908c908c90600401610411565b6000604051808303818588803b1580156101ed57600080fd5b505af1158015610201573d6000803e3d6000fd5b5050505050505050505050505050565b60008083601f840112610222578182fd5b50813567ffffffffffffffff811115610239578182fd5b60208301915083602082850101111561025157600080fd5b9250929050565b6000806020838503121561026a578182fd5b823567ffffffffffffffff80821115610281578384fd5b818501915085601f830112610294578384fd5b8135818111156102a2578485fd5b86602080830285010111156102b5578485fd5b60209290920196919550909350505050565b600080600080606085870312156102dc578182fd5b84356102e7816104a8565b935060208501359250604085013567ffffffffffffffff811115610309578283fd5b61031587828801610211565b95989497509550505050565b60008060008060008060008060006101008a8c03121561033f578485fd5b893561034a816104a8565b985060208a013567ffffffffffffffff811115610365578586fd5b6103718c828d01610211565b90995097505060408a0135955060608a0135945060808a0135610393816104a8565b935060a08a01356103a3816104a8565b8093505060c08a0135915060e08a013590509295985092959850929598565b60008284528282602086013780602084860101526020601f19601f85011685010190509392505050565b90815260200190565b6000602082526104096020830184866103c2565b949350505050565b600060e0825261042560e083018a8c6103c2565b60208301989098525060408101959095526001600160a01b03938416606086015291909216608084015260a083019190915260c09091015292915050565b6000808335601e19843603018112610479578283fd5b83018035915067ffffffffffffffff821115610493578283fd5b60200191503681900382131561025157600080fd5b6001600160a01b03811681146104bd57600080fd5b5056fea26469706673582212209e714d6385e2c86cc03186c5204b41573676ba810258f1b09d9b7e267ca73d2f64736f6c634300060c0033"; +const isSuperArgs$O = (xs) => xs.length > 1; +class TornadoProxyLight__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$O(args)) { + super(...args); + } else { + super(_abi$1i, _bytecode$O, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$1i); + } + static connect(address, runner) { + return new Contract(address, _abi$1i, runner); + } +} +TornadoProxyLight__factory.bytecode = _bytecode$O; +TornadoProxyLight__factory.abi = _abi$1i; + +const _abi$1h = [ + { + inputs: [], + name: "DOMAIN_SEPARATOR", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + } + ], + name: "nonces", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "permit", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + }, + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +class IERC20__factory { + static createInterface() { + return new Interface(_abi$1h); + } + static connect(address, runner) { + return new Contract(address, _abi$1h, runner); + } +} +IERC20__factory.abi = _abi$1h; + +const _abi$1g = [ + { + inputs: [ + { + internalType: "contract IVerifier", + name: "_verifier", + type: "address" + }, + { + internalType: "contract IHasher", + name: "_hasher", + type: "address" + }, + { + internalType: "uint256", + name: "_denomination", + type: "uint256" + }, + { + internalType: "uint32", + name: "_merkleTreeHeight", + type: "uint32" + }, + { + internalType: "contract IERC20", + name: "_token", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "commitment", + type: "bytes32" + }, + { + indexed: false, + internalType: "uint32", + name: "leafIndex", + type: "uint32" + }, + { + indexed: false, + internalType: "uint256", + name: "timestamp", + type: "uint256" + } + ], + name: "Deposit", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "bytes32", + name: "nullifierHash", + type: "bytes32" + }, + { + indexed: true, + internalType: "address", + name: "relayer", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "fee", + type: "uint256" + } + ], + name: "Withdrawal", + type: "event" + }, + { + inputs: [], + name: "FIELD_SIZE", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "ROOT_HISTORY_SIZE", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "ZERO_VALUE", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + name: "commitments", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "currentRootIndex", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "denomination", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_commitment", + type: "bytes32" + } + ], + name: "deposit", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "filledSubtrees", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getLastRoot", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IHasher", + name: "_hasher", + type: "address" + }, + { + internalType: "bytes32", + name: "_left", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "_right", + type: "bytes32" + } + ], + name: "hashLeftRight", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "pure", + type: "function" + }, + { + inputs: [], + name: "hasher", + outputs: [ + { + internalType: "contract IHasher", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_root", + type: "bytes32" + } + ], + name: "isKnownRoot", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_nullifierHash", + type: "bytes32" + } + ], + name: "isSpent", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32[]", + name: "_nullifierHashes", + type: "bytes32[]" + } + ], + name: "isSpentArray", + outputs: [ + { + internalType: "bool[]", + name: "spent", + type: "bool[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "levels", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "nextIndex", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + name: "nullifierHashes", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "roots", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "token", + outputs: [ + { + internalType: "contract IERC20", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "verifier", + outputs: [ + { + internalType: "contract IVerifier", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes", + name: "_proof", + type: "bytes" + }, + { + internalType: "bytes32", + name: "_root", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "_nullifierHash", + type: "bytes32" + }, + { + internalType: "address payable", + name: "_recipient", + type: "address" + }, + { + internalType: "address payable", + name: "_relayer", + type: "address" + }, + { + internalType: "uint256", + name: "_fee", + type: "uint256" + }, + { + internalType: "uint256", + name: "_refund", + type: "uint256" + } + ], + name: "withdraw", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "zeros", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$N = "0x610120604052600380546001600160401b031916905534801561002157600080fd5b50604051611db8380380611db883398101604081905261004091610420565b84848484808360008263ffffffff16116100ad5760405162461bcd60e51b815260206004820152602360248201527f5f6c6576656c732073686f756c642062652067726561746572207468616e207a60448201526265726f60e81b60648201526084015b60405180910390fd5b60208263ffffffff16106101035760405162461bcd60e51b815260206004820152601e60248201527f5f6c6576656c732073686f756c64206265206c657373207468616e203332000060448201526064016100a4565b63ffffffff821660a0526001600160a01b0381166080527f2fe54c60d3acabf3343a35b6eba15db4821b340f76e741e2249685ed4899af6c60005b8363ffffffff168163ffffffff16101561018b5763ffffffff8116600090815260016020908152604080832085905590829052902082905561018183838061023b565b915060010161013e565b506000805260026020527fac33ff75c19e70fe83507db0d683fd3465c996598dc972688b7ace676c89077b5550506001600455816102195760405162461bcd60e51b815260206004820152602560248201527f64656e6f6d696e6174696f6e2073686f756c6420626520677265617465722074604482015264068616e20360dc1b60648201526084016100a4565b506001600160a01b0392831660c05260e052501661010052506104b892505050565b6000600080516020611d98833981519152831061029a5760405162461bcd60e51b815260206004820181905260248201527f5f6c6566742073686f756c6420626520696e7369646520746865206669656c6460448201526064016100a4565b600080516020611d9883398151915282106103015760405162461bcd60e51b815260206004820152602160248201527f5f72696768742073686f756c6420626520696e7369646520746865206669656c6044820152601960fa1b60648201526084016100a4565b60405163f47d33b560e01b81526004810184905260006024820181905284916001600160a01b0387169063f47d33b5906044016040805180830381865afa158015610350573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103749190610494565b9092509050600080516020611d9883398151915284830860405163f47d33b560e01b815260048101829052602481018390529092506001600160a01b0387169063f47d33b5906044016040805180830381865afa1580156103d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103fd9190610494565b509695505050505050565b6001600160a01b038116811461041d57600080fd5b50565b600080600080600060a0868803121561043857600080fd5b855161044381610408565b602087015190955061045481610408565b60408701516060880151919550935063ffffffff8116811461047557600080fd5b608087015190925061048681610408565b809150509295509295909350565b600080604083850312156104a757600080fd5b505080516020909101519092909150565b60805160a05160c05160e05161010051611856610542600039600081816104ca01528181610cfa01528181610d34015261108e0152600081816102bb0152818161056f01528181610ccc01526110b20152600081816101a601526106d801526000818161022201528181610e150152610eb70152600081816104690152610f4f01526118566000f3fe6080604052600436106101355760003560e01c8063b214faa5116100ab578063e82955881161006f578063e8295588146103f6578063ec73295914610423578063ed33639f14610457578063f178e47c1461048b578063fc0c546a146104b8578063fc7e9c6f146104ec57600080fd5b8063b214faa514610347578063ba70f7571461035a578063c2b40ae414610384578063cd87a3b4146103b1578063e5285dcc146103c657600080fd5b80636d9833e3116100fd5780636d9833e314610259578063839df945146102795780638bca6d16146102a95780638ea3099e146102dd57806390eeb02b146102fd5780639fa12d0b1461031a57600080fd5b806317cc915c1461013a57806321a0adb61461017f5780632b7ac3f314610194578063414a37ba146101e05780634ecf518b14610210575b600080fd5b34801561014657600080fd5b5061016a61015536600461131d565b60056020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b61019261018d36600461135e565b610511565b005b3480156101a057600080fd5b506101c87f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610176565b3480156101ec57600080fd5b5061020260008051602061180183398151915281565b604051908152602001610176565b34801561021c57600080fd5b506102447f000000000000000000000000000000000000000000000000000000000000000081565b60405163ffffffff9091168152602001610176565b34801561026557600080fd5b5061016a61027436600461131d565b61081c565b34801561028557600080fd5b5061016a61029436600461131d565b60066020526000908152604090205460ff1681565b3480156102b557600080fd5b506102027f000000000000000000000000000000000000000000000000000000000000000081565b3480156102e957600080fd5b506102026102f8366004611414565b61089a565b34801561030957600080fd5b506003546102449063ffffffff1681565b34801561032657600080fd5b5061033a610335366004611449565b610a67565b60405161017691906114be565b61019261035536600461131d565b610b23565b34801561036657600080fd5b5060035463ffffffff16600090815260026020526040902054610202565b34801561039057600080fd5b5061020261039f36600461131d565b60026020526000908152604090205481565b3480156103bd57600080fd5b50610244601e81565b3480156103d257600080fd5b5061016a6103e136600461131d565b60009081526005602052604090205460ff1690565b34801561040257600080fd5b5061020261041136600461131d565b60016020526000908152604090205481565b34801561042f57600080fd5b506102027f2fe54c60d3acabf3343a35b6eba15db4821b340f76e741e2249685ed4899af6c81565b34801561046357600080fd5b506101c87f000000000000000000000000000000000000000000000000000000000000000081565b34801561049757600080fd5b506102026104a636600461131d565b60006020819052908152604090205481565b3480156104c457600080fd5b506101c87f000000000000000000000000000000000000000000000000000000000000000081565b3480156104f857600080fd5b5060035461024490640100000000900463ffffffff1681565b6002600454036105685760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b60026004557f00000000000000000000000000000000000000000000000000000000000000008211156105dd5760405162461bcd60e51b815260206004820152601a60248201527f4665652065786365656473207472616e736665722076616c7565000000000000604482015260640161055f565b60008581526005602052604090205460ff161561063c5760405162461bcd60e51b815260206004820152601f60248201527f546865206e6f746520686173206265656e20616c7265616479207370656e7400604482015260640161055f565b6106458661081c565b6106915760405162461bcd60e51b815260206004820152601c60248201527f43616e6e6f742066696e6420796f7572206d65726b6c6520726f6f7400000000604482015260640161055f565b6040805160c081018252878152602081018790526001600160a01b038681168284015285811660608301526080820185905260a08201849052915163695ef6f960e01b81527f00000000000000000000000000000000000000000000000000000000000000009092169163695ef6f991610711918c918c91600401611504565b6020604051808303816000875af1158015610730573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107549190611562565b6107995760405162461bcd60e51b815260206004820152601660248201527524b73b30b634b2103bb4ba34323930bb90383937b7b360511b604482015260640161055f565b6000858152600560205260409020805460ff191660011790556107be84848484610c5a565b604080516001600160a01b03868116825260208201889052918101849052908416907fe9e508bad6d4c3227e881ca19068f099da81b5164dd6d62b2eaf1e8bc6c349319060600160405180910390a250506001600455505050505050565b600081810361082d57506000919050565b60035463ffffffff16805b63ffffffff8116600090815260026020526040902054840361085e575060019392505050565b8063ffffffff166000036108705750601e5b8061087a816115a1565b9150508163ffffffff168163ffffffff1603610838575060009392505050565b600060008051602061180183398151915283106108f95760405162461bcd60e51b815260206004820181905260248201527f5f6c6566742073686f756c6420626520696e7369646520746865206669656c64604482015260640161055f565b60008051602061180183398151915282106109605760405162461bcd60e51b815260206004820152602160248201527f5f72696768742073686f756c6420626520696e7369646520746865206669656c6044820152601960fa1b606482015260840161055f565b60405163f47d33b560e01b81526004810184905260006024820181905284916001600160a01b0387169063f47d33b5906044016040805180830381865afa1580156109af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d391906115c1565b909250905060008051602061180183398151915284830860405163f47d33b560e01b815260048101829052602481018390529092506001600160a01b0387169063f47d33b5906044016040805180830381865afa158015610a38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5c91906115c1565b509695505050505050565b60608167ffffffffffffffff811115610a8257610a826115fb565b604051908082528060200260200182016040528015610aab578160200160208202803683370190505b50905060005b82811015610b1c57610aea848483818110610ace57610ace611611565b9050602002013560009081526005602052604090205460ff1690565b15610b14576001828281518110610b0357610b03611611565b911515602092830291909101909101525b600101610ab1565b5092915050565b600260045403610b755760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161055f565b600260045560008181526006602052604090205460ff1615610be35760405162461bcd60e51b815260206004820152602160248201527f54686520636f6d6d69746d656e7420686173206265656e207375626d697474656044820152601960fa1b606482015260840161055f565b6000610bee82610dfc565b6000838152600660205260409020805460ff191660011790559050610c1161101a565b6040805163ffffffff8316815242602082015283917fa945e51eec50ab98c161376f0db4cf2aeba3ec92755fe2fcd388bdbbb80ff196910160405180910390a250506001600455565b803414610cc25760405162461bcd60e51b815260206004820152603060248201527f496e636f727265637420726566756e6420616d6f756e7420726563656976656460448201526f08189e481d1a194818dbdb9d1c9858dd60821b606482015260840161055f565b610d2184610cf0847f0000000000000000000000000000000000000000000000000000000000000000611627565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691906110d8565b8115610d5b57610d5b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001684846110d8565b8015610df6576000846001600160a01b03168260405160006040518083038185875af1925050503d8060008114610dae576040519150601f19603f3d011682016040523d82523d6000602084013e610db3565b606091505b5050905080610df4576040516001600160a01b0385169083156108fc029084906000818181858888f19350505050158015610df2573d6000803e3d6000fd5b505b505b50505050565b600354600090640100000000900463ffffffff16610e3b7f00000000000000000000000000000000000000000000000000000000000000006002611751565b63ffffffff168163ffffffff1603610eae5760405162461bcd60e51b815260206004820152603060248201527f4d65726b6c6520747265652069732066756c6c2e204e6f206d6f7265206c656160448201526f1d995cc818d85b88189948185919195960821b606482015260840161055f565b8083600080805b7f000000000000000000000000000000000000000000000000000000000000000063ffffffff168163ffffffff161015610f8c57610ef460028661176e565b63ffffffff16600003610f2e5763ffffffff8116600090815260016020908152604080832054918390529091208590558493509150610f4a565b63ffffffff811660009081526020819052604090205492508391505b610f757f0000000000000000000000000000000000000000000000000000000000000000848461089a565b9350610f82600286611791565b9450600101610eb5565b50600354600090601e90610fa79063ffffffff1660016117b4565b610fb1919061176e565b6003805463ffffffff191663ffffffff831690811790915560009081526002602052604090208590559050610fe78660016117b4565b6003805463ffffffff929092166401000000000267ffffffff000000001990921691909117905550939695505050505050565b34156110815760405162461bcd60e51b815260206004820152603060248201527f4554482076616c756520697320737570706f73656420746f206265203020666f60448201526f7220455243323020696e7374616e636560801b606482015260840161055f565b6110d66001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633307f00000000000000000000000000000000000000000000000000000000000000006111f1565b565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b179052915160009283929087169161113491906117d1565b6000604051808303816000865af19150503d8060008114611171576040519150601f19603f3d011682016040523d82523d6000602084013e611176565b606091505b50915091508161118857805181602001fd5b805115806111a55750808060200190518101906111a59190611562565b610df45760405162461bcd60e51b815260206004820152601e60248201527f5361666545524332303a20736166655472616e73666572206661696c65640000604482015260640161055f565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b179052915160009283929088169161125591906117d1565b6000604051808303816000865af19150503d8060008114611292576040519150601f19603f3d011682016040523d82523d6000602084013e611297565b606091505b5091509150816112a957805181602001fd5b805115806112c65750808060200190518101906112c69190611562565b610df25760405162461bcd60e51b815260206004820152602260248201527f5361666545524332303a20736166655472616e7366657246726f6d206661696c604482015261195960f21b606482015260840161055f565b60006020828403121561132f57600080fd5b5035919050565b6001600160a01b038116811461134b57600080fd5b50565b803561135981611336565b919050565b60008060008060008060008060e0898b03121561137a57600080fd5b883567ffffffffffffffff8082111561139257600080fd5b818b0191508b601f8301126113a657600080fd5b8135818111156113b557600080fd5b8c60208285010111156113c757600080fd5b60209283019a509850508901359550604089013594506113e960608a0161134e565b93506113f760808a0161134e565b925060a0890135915060c089013590509295985092959890939650565b60008060006060848603121561142957600080fd5b833561143481611336565b95602085013595506040909401359392505050565b6000806020838503121561145c57600080fd5b823567ffffffffffffffff8082111561147457600080fd5b818501915085601f83011261148857600080fd5b81358181111561149757600080fd5b8660208260051b85010111156114ac57600080fd5b60209290920196919550909350505050565b6020808252825182820181905260009190848201906040850190845b818110156114f85783511515835292840192918401916001016114da565b50909695505050505050565b60e081528260e08201526000610100848682850137600081868501015280601f19601f87011684010191505060208083018460005b600681101561155657815183529183019190830190600101611539565b50505050949350505050565b60006020828403121561157457600080fd5b8151801515811461158457600080fd5b9392505050565b634e487b7160e01b600052601160045260246000fd5b600063ffffffff8216806115b7576115b761158b565b6000190192915050565b600080604083850312156115d457600080fd5b505080516020909101519092909150565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b8181038181111561163a5761163a61158b565b92915050565b600181815b8085111561167d578163ffffffff048211156116635761166361158b565b8085161561167057918102915b93841c9390800290611645565b509250929050565b6000826116945750600161163a565b816116a15750600061163a565b81600181146116b757600281146116c1576116f2565b600191505061163a565b60ff8411156116d2576116d261158b565b6001841b915063ffffffff8211156116ec576116ec61158b565b5061163a565b5060208310610133831016604e8410600b8410161715611729575081810a63ffffffff8111156117245761172461158b565b61163a565b6117338383611640565b8063ffffffff048211156117495761174961158b565b029392505050565b600063ffffffff611766818516828516611685565b949350505050565b600063ffffffff80841680611785576117856115e5565b92169190910692915050565b600063ffffffff808416806117a8576117a86115e5565b92169190910492915050565b63ffffffff818116838216019080821115610b1c57610b1c61158b565b6000825160005b818110156117f257602081860181015185830152016117d8565b50600092019182525091905056fe30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001a264697066735822122090d9706fb3f8afcde53068158f22289b2796e92f9b67b63271c1f6de497a540f64736f6c6343000819003330644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001"; +const isSuperArgs$N = (xs) => xs.length > 1; +class ERC20Tornado__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$N(args)) { + super(...args); + } else { + super(_abi$1g, _bytecode$N, args[0]); + } + } + getDeployTransaction(_verifier, _hasher, _denomination, _merkleTreeHeight, _token, overrides) { + return super.getDeployTransaction( + _verifier, + _hasher, + _denomination, + _merkleTreeHeight, + _token, + overrides || {} + ); + } + deploy(_verifier, _hasher, _denomination, _merkleTreeHeight, _token, overrides) { + return super.deploy( + _verifier, + _hasher, + _denomination, + _merkleTreeHeight, + _token, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$1g); + } + static connect(address, runner) { + return new Contract(address, _abi$1g, runner); + } +} +ERC20Tornado__factory.bytecode = _bytecode$N; +ERC20Tornado__factory.abi = _abi$1g; + +const _abi$1f = [ + { + inputs: [ + { + internalType: "contract IVerifier", + name: "_verifier", + type: "address" + }, + { + internalType: "contract IHasher", + name: "_hasher", + type: "address" + }, + { + internalType: "uint256", + name: "_denomination", + type: "uint256" + }, + { + internalType: "uint32", + name: "_merkleTreeHeight", + type: "uint32" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "commitment", + type: "bytes32" + }, + { + indexed: false, + internalType: "uint32", + name: "leafIndex", + type: "uint32" + }, + { + indexed: false, + internalType: "uint256", + name: "timestamp", + type: "uint256" + } + ], + name: "Deposit", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "bytes32", + name: "nullifierHash", + type: "bytes32" + }, + { + indexed: true, + internalType: "address", + name: "relayer", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "fee", + type: "uint256" + } + ], + name: "Withdrawal", + type: "event" + }, + { + inputs: [], + name: "FIELD_SIZE", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "ROOT_HISTORY_SIZE", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "ZERO_VALUE", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + name: "commitments", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "currentRootIndex", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "denomination", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_commitment", + type: "bytes32" + } + ], + name: "deposit", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "filledSubtrees", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getLastRoot", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IHasher", + name: "_hasher", + type: "address" + }, + { + internalType: "bytes32", + name: "_left", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "_right", + type: "bytes32" + } + ], + name: "hashLeftRight", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "pure", + type: "function" + }, + { + inputs: [], + name: "hasher", + outputs: [ + { + internalType: "contract IHasher", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_root", + type: "bytes32" + } + ], + name: "isKnownRoot", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_nullifierHash", + type: "bytes32" + } + ], + name: "isSpent", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32[]", + name: "_nullifierHashes", + type: "bytes32[]" + } + ], + name: "isSpentArray", + outputs: [ + { + internalType: "bool[]", + name: "spent", + type: "bool[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "levels", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "nextIndex", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + name: "nullifierHashes", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "roots", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "verifier", + outputs: [ + { + internalType: "contract IVerifier", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes", + name: "_proof", + type: "bytes" + }, + { + internalType: "bytes32", + name: "_root", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "_nullifierHash", + type: "bytes32" + }, + { + internalType: "address payable", + name: "_recipient", + type: "address" + }, + { + internalType: "address payable", + name: "_relayer", + type: "address" + }, + { + internalType: "uint256", + name: "_fee", + type: "uint256" + }, + { + internalType: "uint256", + name: "_refund", + type: "uint256" + } + ], + name: "withdraw", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "zeros", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$M = "0x610100604052600380546001600160401b031916905534801561002157600080fd5b50604051611b68380380611b688339810160408190526100409161041b565b83838383808360008263ffffffff16116100ad5760405162461bcd60e51b815260206004820152602360248201527f5f6c6576656c732073686f756c642062652067726561746572207468616e207a60448201526265726f60e81b60648201526084015b60405180910390fd5b60208263ffffffff16106101035760405162461bcd60e51b815260206004820152601e60248201527f5f6c6576656c732073686f756c64206265206c657373207468616e203332000060448201526064016100a4565b63ffffffff821660a0526001600160a01b0381166080527f2fe54c60d3acabf3343a35b6eba15db4821b340f76e741e2249685ed4899af6c60005b8363ffffffff168163ffffffff16101561018b5763ffffffff81166000908152600160209081526040808320859055908290529020829055610181838380610236565b915060010161013e565b506000805260026020527fac33ff75c19e70fe83507db0d683fd3465c996598dc972688b7ace676c89077b5550506001600455816102195760405162461bcd60e51b815260206004820152602560248201527f64656e6f6d696e6174696f6e2073686f756c6420626520677265617465722074604482015264068616e20360dc1b60648201526084016100a4565b506001600160a01b0390921660c0525060e0525061049d92505050565b6000600080516020611b4883398151915283106102955760405162461bcd60e51b815260206004820181905260248201527f5f6c6566742073686f756c6420626520696e7369646520746865206669656c6460448201526064016100a4565b600080516020611b4883398151915282106102fc5760405162461bcd60e51b815260206004820152602160248201527f5f72696768742073686f756c6420626520696e7369646520746865206669656c6044820152601960fa1b60648201526084016100a4565b60405163f47d33b560e01b81526004810184905260006024820181905284916001600160a01b0387169063f47d33b5906044016040805180830381865afa15801561034b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036f9190610479565b9092509050600080516020611b4883398151915284830860405163f47d33b560e01b815260048101829052602481018390529092506001600160a01b0387169063f47d33b5906044016040805180830381865afa1580156103d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103f89190610479565b509695505050505050565b6001600160a01b038116811461041857600080fd5b50565b6000806000806080858703121561043157600080fd5b845161043c81610403565b602086015190945061044d81610403565b60408601516060870151919450925063ffffffff8116811461046e57600080fd5b939692955090935050565b6000806040838503121561048c57600080fd5b505080516020909101519092909150565b60805160a05160c05160e051611641610507600039600081816102b00152818161053001528181610d0401526110a201526000818161019b015261069901526000818161021701528181610e9b0152610f3d01526000818161045e0152610fd501526116416000f3fe60806040526004361061012a5760003560e01c80639fa12d0b116100ab578063e5285dcc1161006f578063e5285dcc146103bb578063e8295588146103eb578063ec73295914610418578063ed33639f1461044c578063f178e47c14610480578063fc7e9c6f146104ad57600080fd5b80639fa12d0b1461030f578063b214faa51461033c578063ba70f7571461034f578063c2b40ae414610379578063cd87a3b4146103a657600080fd5b80636d9833e3116100f25780636d9833e31461024e578063839df9451461026e5780638bca6d161461029e5780638ea3099e146102d257806390eeb02b146102f257600080fd5b806317cc915c1461012f57806321a0adb6146101745780632b7ac3f314610189578063414a37ba146101d55780634ecf518b14610205575b600080fd5b34801561013b57600080fd5b5061015f61014a366004611137565b60056020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b610187610182366004611178565b6104d2565b005b34801561019557600080fd5b506101bd7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161016b565b3480156101e157600080fd5b506101f76000805160206115ec83398151915281565b60405190815260200161016b565b34801561021157600080fd5b506102397f000000000000000000000000000000000000000000000000000000000000000081565b60405163ffffffff909116815260200161016b565b34801561025a57600080fd5b5061015f610269366004611137565b6107dd565b34801561027a57600080fd5b5061015f610289366004611137565b60066020526000908152604090205460ff1681565b3480156102aa57600080fd5b506101f77f000000000000000000000000000000000000000000000000000000000000000081565b3480156102de57600080fd5b506101f76102ed36600461122e565b61085b565b3480156102fe57600080fd5b506003546102399063ffffffff1681565b34801561031b57600080fd5b5061032f61032a366004611263565b610a28565b60405161016b91906112d8565b61018761034a366004611137565b610ae4565b34801561035b57600080fd5b5060035463ffffffff166000908152600260205260409020546101f7565b34801561038557600080fd5b506101f7610394366004611137565b60026020526000908152604090205481565b3480156103b257600080fd5b50610239601e81565b3480156103c757600080fd5b5061015f6103d6366004611137565b60009081526005602052604090205460ff1690565b3480156103f757600080fd5b506101f7610406366004611137565b60016020526000908152604090205481565b34801561042457600080fd5b506101f77f2fe54c60d3acabf3343a35b6eba15db4821b340f76e741e2249685ed4899af6c81565b34801561045857600080fd5b506101bd7f000000000000000000000000000000000000000000000000000000000000000081565b34801561048c57600080fd5b506101f761049b366004611137565b60006020819052908152604090205481565b3480156104b957600080fd5b5060035461023990640100000000900463ffffffff1681565b6002600454036105295760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b60026004557f000000000000000000000000000000000000000000000000000000000000000082111561059e5760405162461bcd60e51b815260206004820152601a60248201527f4665652065786365656473207472616e736665722076616c75650000000000006044820152606401610520565b60008581526005602052604090205460ff16156105fd5760405162461bcd60e51b815260206004820152601f60248201527f546865206e6f746520686173206265656e20616c7265616479207370656e74006044820152606401610520565b610606866107dd565b6106525760405162461bcd60e51b815260206004820152601c60248201527f43616e6e6f742066696e6420796f7572206d65726b6c6520726f6f74000000006044820152606401610520565b6040805160c081018252878152602081018790526001600160a01b038681168284015285811660608301526080820185905260a08201849052915163695ef6f960e01b81527f00000000000000000000000000000000000000000000000000000000000000009092169163695ef6f9916106d2918c918c9160040161131e565b6020604051808303816000875af11580156106f1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610715919061137c565b61075a5760405162461bcd60e51b815260206004820152601660248201527524b73b30b634b2103bb4ba34323930bb90383937b7b360511b6044820152606401610520565b6000858152600560205260409020805460ff1916600117905561077f84848484610c1b565b604080516001600160a01b03868116825260208201889052918101849052908416907fe9e508bad6d4c3227e881ca19068f099da81b5164dd6d62b2eaf1e8bc6c349319060600160405180910390a250506001600455505050505050565b60008181036107ee57506000919050565b60035463ffffffff16805b63ffffffff8116600090815260026020526040902054840361081f575060019392505050565b8063ffffffff166000036108315750601e5b8061083b816113bb565b9150508163ffffffff168163ffffffff16036107f9575060009392505050565b60006000805160206115ec83398151915283106108ba5760405162461bcd60e51b815260206004820181905260248201527f5f6c6566742073686f756c6420626520696e7369646520746865206669656c646044820152606401610520565b6000805160206115ec83398151915282106109215760405162461bcd60e51b815260206004820152602160248201527f5f72696768742073686f756c6420626520696e7369646520746865206669656c6044820152601960fa1b6064820152608401610520565b60405163f47d33b560e01b81526004810184905260006024820181905284916001600160a01b0387169063f47d33b5906044016040805180830381865afa158015610970573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099491906113db565b90925090506000805160206115ec83398151915284830860405163f47d33b560e01b815260048101829052602481018390529092506001600160a01b0387169063f47d33b5906044016040805180830381865afa1580156109f9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1d91906113db565b509695505050505050565b60608167ffffffffffffffff811115610a4357610a43611415565b604051908082528060200260200182016040528015610a6c578160200160208202803683370190505b50905060005b82811015610add57610aab848483818110610a8f57610a8f61142b565b9050602002013560009081526005602052604090205460ff1690565b15610ad5576001828281518110610ac457610ac461142b565b911515602092830291909101909101525b600101610a72565b5092915050565b600260045403610b365760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610520565b600260045560008181526006602052604090205460ff1615610ba45760405162461bcd60e51b815260206004820152602160248201527f54686520636f6d6d69746d656e7420686173206265656e207375626d697474656044820152601960fa1b6064820152608401610520565b6000610baf82610e82565b6000838152600660205260409020805460ff191660011790559050610bd26110a0565b6040805163ffffffff8316815242602082015283917fa945e51eec50ab98c161376f0db4cf2aeba3ec92755fe2fcd388bdbbb80ff196910160405180910390a250506001600455565b3415610c875760405162461bcd60e51b815260206004820152603560248201527f4d6573736167652076616c756520697320737570706f73656420746f206265206044820152747a65726f20666f722045544820696e7374616e636560581b6064820152608401610520565b8015610cf25760405162461bcd60e51b815260206004820152603460248201527f526566756e642076616c756520697320737570706f73656420746f206265207a60448201527365726f20666f722045544820696e7374616e636560601b6064820152608401610520565b60006001600160a01b038516610d28847f0000000000000000000000000000000000000000000000000000000000000000611441565b604051600081818185875af1925050503d8060008114610d64576040519150601f19603f3d011682016040523d82523d6000602084013e610d69565b606091505b5050905080610dc85760405162461bcd60e51b815260206004820152602560248201527f7061796d656e7420746f205f726563697069656e7420646964206e6f7420676f604482015264207468727560d81b6064820152608401610520565b8215610e7b576040516001600160a01b038516908490600081818185875af1925050503d8060008114610e17576040519150601f19603f3d011682016040523d82523d6000602084013e610e1c565b606091505b50508091505080610e7b5760405162461bcd60e51b815260206004820152602360248201527f7061796d656e7420746f205f72656c6179657220646964206e6f7420676f207460448201526268727560e81b6064820152608401610520565b5050505050565b600354600090640100000000900463ffffffff16610ec17f0000000000000000000000000000000000000000000000000000000000000000600261156b565b63ffffffff168163ffffffff1603610f345760405162461bcd60e51b815260206004820152603060248201527f4d65726b6c6520747265652069732066756c6c2e204e6f206d6f7265206c656160448201526f1d995cc818d85b88189948185919195960821b6064820152608401610520565b8083600080805b7f000000000000000000000000000000000000000000000000000000000000000063ffffffff168163ffffffff16101561101257610f7a600286611588565b63ffffffff16600003610fb45763ffffffff8116600090815260016020908152604080832054918390529091208590558493509150610fd0565b63ffffffff811660009081526020819052604090205492508391505b610ffb7f0000000000000000000000000000000000000000000000000000000000000000848461085b565b93506110086002866115ab565b9450600101610f3b565b50600354600090601e9061102d9063ffffffff1660016115ce565b6110379190611588565b6003805463ffffffff191663ffffffff83169081179091556000908152600260205260409020859055905061106d8660016115ce565b6003805463ffffffff929092166401000000000267ffffffff000000001990921691909117905550939695505050505050565b7f000000000000000000000000000000000000000000000000000000000000000034146111355760405162461bcd60e51b815260206004820152603860248201527f506c656173652073656e6420606d697844656e6f6d696e6174696f6e6020455460448201527f4820616c6f6e672077697468207472616e73616374696f6e00000000000000006064820152608401610520565b565b60006020828403121561114957600080fd5b5035919050565b6001600160a01b038116811461116557600080fd5b50565b803561117381611150565b919050565b60008060008060008060008060e0898b03121561119457600080fd5b883567ffffffffffffffff808211156111ac57600080fd5b818b0191508b601f8301126111c057600080fd5b8135818111156111cf57600080fd5b8c60208285010111156111e157600080fd5b60209283019a5098505089013595506040890135945061120360608a01611168565b935061121160808a01611168565b925060a0890135915060c089013590509295985092959890939650565b60008060006060848603121561124357600080fd5b833561124e81611150565b95602085013595506040909401359392505050565b6000806020838503121561127657600080fd5b823567ffffffffffffffff8082111561128e57600080fd5b818501915085601f8301126112a257600080fd5b8135818111156112b157600080fd5b8660208260051b85010111156112c657600080fd5b60209290920196919550909350505050565b6020808252825182820181905260009190848201906040850190845b818110156113125783511515835292840192918401916001016112f4565b50909695505050505050565b60e081528260e08201526000610100848682850137600081868501015280601f19601f87011684010191505060208083018460005b600681101561137057815183529183019190830190600101611353565b50505050949350505050565b60006020828403121561138e57600080fd5b8151801515811461139e57600080fd5b9392505050565b634e487b7160e01b600052601160045260246000fd5b600063ffffffff8216806113d1576113d16113a5565b6000190192915050565b600080604083850312156113ee57600080fd5b505080516020909101519092909150565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b81810381811115611454576114546113a5565b92915050565b600181815b80851115611497578163ffffffff0482111561147d5761147d6113a5565b8085161561148a57918102915b93841c939080029061145f565b509250929050565b6000826114ae57506001611454565b816114bb57506000611454565b81600181146114d157600281146114db5761150c565b6001915050611454565b60ff8411156114ec576114ec6113a5565b6001841b915063ffffffff821115611506576115066113a5565b50611454565b5060208310610133831016604e8410600b8410161715611543575081810a63ffffffff81111561153e5761153e6113a5565b611454565b61154d838361145a565b8063ffffffff04821115611563576115636113a5565b029392505050565b600063ffffffff61158081851682851661149f565b949350505050565b600063ffffffff8084168061159f5761159f6113ff565b92169190910692915050565b600063ffffffff808416806115c2576115c26113ff565b92169190910492915050565b63ffffffff818116838216019080821115610add57610add6113a556fe30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001a2646970667358221220267f40202364f981d5a2318bca43d1a8beff64b8785905fc2621de01f8449b3964736f6c6343000819003330644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001"; +const isSuperArgs$M = (xs) => xs.length > 1; +class ETHTornado__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$M(args)) { + super(...args); + } else { + super(_abi$1f, _bytecode$M, args[0]); + } + } + getDeployTransaction(_verifier, _hasher, _denomination, _merkleTreeHeight, overrides) { + return super.getDeployTransaction( + _verifier, + _hasher, + _denomination, + _merkleTreeHeight, + overrides || {} + ); + } + deploy(_verifier, _hasher, _denomination, _merkleTreeHeight, overrides) { + return super.deploy( + _verifier, + _hasher, + _denomination, + _merkleTreeHeight, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$1f); + } + static connect(address, runner) { + return new Contract(address, _abi$1f, runner); + } +} +ETHTornado__factory.bytecode = _bytecode$M; +ETHTornado__factory.abi = _abi$1f; + +const _abi$1e = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "who", + type: "address" + }, + { + indexed: false, + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "Echo", + type: "event" + }, + { + inputs: [ + { + internalType: "bytes", + name: "_data", + type: "bytes" + } + ], + name: "echo", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$L = "0x6080604052348015600f57600080fd5b506101638061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063624fbfdc14610030575b600080fd5b61004361003e36600461008c565b610045565b005b336001600160a01b03167f50d6f3fc915efd1695d8a4cb50da185984f50d256834b9cb308295eb3c872c9c83836040516100809291906100fe565b60405180910390a25050565b6000806020838503121561009f57600080fd5b823567ffffffffffffffff808211156100b757600080fd5b818501915085601f8301126100cb57600080fd5b8135818111156100da57600080fd5b8660208285010111156100ec57600080fd5b60209290920196919550909350505050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f1916010191905056fea2646970667358221220cadc2288aafcfeb373ae536503c025419ca51a0b1642ad003ff215a6bff8658464736f6c63430008190033"; +const isSuperArgs$L = (xs) => xs.length > 1; +class Echoer__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$L(args)) { + super(...args); + } else { + super(_abi$1e, _bytecode$L, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$1e); + } + static connect(address, runner) { + return new Contract(address, _abi$1e, runner); + } +} +Echoer__factory.bytecode = _bytecode$L; +Echoer__factory.abi = _abi$1e; + +const _abi$1d = [ + { + inputs: [ + { + internalType: "bytes", + name: "proof", + type: "bytes" + }, + { + internalType: "uint256[6]", + name: "input", + type: "uint256[6]" + } + ], + name: "verifyProof", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$K = "0x6080604052348015600f57600080fd5b506110d08061001f6000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063695ef6f914610030575b600080fd5b61004361003e366004610eca565b610057565b604051901515815260200160405180910390f35b6000808380602001905181019061006e9190610f71565b905060005b60088160ff161015610129577f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47828260ff16600881106100b5576100b5610ff0565b6020020151106101175760405162461bcd60e51b815260206004820152602260248201527f76657269666965722d70726f6f662d656c656d656e742d6774652d7072696d656044820152612d7160f01b60648201526084015b60405180910390fd5b806101218161101c565b915050610073565b50610132610ca2565b6040805180820182528351815260208085015181830152908352815160808082018452858401518285019081526060808801519084015282528351808501855290860151815260a08601518184015281830152838201528151808301835260c0850151815260e0850151918101919091529082015260006101b1610321565b90506000604051806040016040528060008152602001600081525090506101f38183608001516000600781106101e9576101e9610ff0565b60200201516107ec565b905060005b60068110156102df577f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f000000187826006811061023457610234610ff0565b6020020151106102865760405162461bcd60e51b815260206004820152601f60248201527f76657269666965722d6774652d736e61726b2d7363616c61722d6669656c6400604482015260640161010e565b6102d5826102d0856080015184600161029f919061103b565b600781106102af576102af610ff0565b60200201518a85600681106102c6576102c6610ff0565b602002015161088d565b6107ec565b91506001016101f8565b506103146102f0846000015161091b565b846020015184600001518560200151858760400151896040015189606001516109d5565b9450505050505b92915050565b610329610cf3565b6040805180820182527f2dbfc3ec62a3eee5a3b4b464bcf1f8527bbca12adea0f1f12033cd4f61b0e09181527f19e55bd0b72c126da18665039556776642ff82e2f347f24fcea2475f4db087df6020808301919091529083528151608080820184527f1ae724ab134e5a7c6bd8a116fa5505b259522c0f164a5e8126e3ec7d34465f6e8285019081527e9f1bcdc853f8e3531756bb625b0d1dc014f4ab57c3f79f4f4e2e7ef7e0ead6606080850191909152908352845180860186527f23a8ca5760457e726365b92fd0ceb486665797cd68c35dcffd8e4ae8066691e981527f13ec7182c9fd68331a10f8be0fe885d730de5c7f89aa7d0b7bafaa009bbc9e3e818601528385015285840192909252835180820185527f198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c28186019081527f1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed828501528152845180860186527f090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b81527f12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa818601528185015285850152835180820185527f2f0c63d0c53b3dfbca27b6b43ae7fbf55a38d78a21470996485b03128accc2088186019081527e556502356e37ed150db2e36531b0f275fd6835c0fc1945922e270b48c48a86828501528152845180860186527f02644c27b5dbd793592a70b735e22c798a5e309fa17a992a7dc2a050e01b298f81527f194776b6a53439d7336f389d2a8f6651e40885f5ca2538b0dc9cb534fb23f7fa818601528185015282860152835180850185527f23df1bc9165e9c1c9b2bc036d8ebdd10e7aeae7e5e8019fde68aec7c818bb23e81527f0b6c92080d37c5fb2ddf30892a33665e5478432ef3f71ac8768ecbbe62c7789281850152818601805191909152845180860186527f1c7b2adf45e046caea000956b2ecb2d8617e710d2a7bb201a95ea276f92307b481527f2b15f07536f45948cf4abe6596637d902ffabb18c8c2f5c151544c294ce4a672818601528151850152845180860186527f1cecfe92882a8c835a47bf01bfa655cf628cbba7f81cf4042179fd13edcd6a3981527f0154bfbb2cb786ca247d4b69183d1751f267bbc7656be8d0f0e7a5a47e2c1101818601528151860152845180860186527f1584616a7423efcc72f69ea84fa0b2bc01433677297f4e8351bebfc15bcd0cda81527f0623755b1488526daa9fecf0e11b110dd6df12c461579d792e1db65af523c8be81860152815190930192909252835180850185527f12fbb5bfca9d61357ba2d641604cf4852e21ef54faa180fe539c18994dc1da5a81527f2f09dd9972a1af5f7bcfccf3d7ab600c9d898ea6d6933150ba0ae228ece17e5f81850152825190910152825180840184527f0adb513796fdf2103022c64151ce05f7c7a6d9200e8d819fa59e654fc4bfe83c81527f2d64f72ef4eddf9ca032058ed2bf691758387e913a77cf99d6a3cfb37c8ba7ee81840152815160a0015282518084019093527f21e7c9bffda74bfd2c4393b6803d775545de6fa89145f4a23476241d9881b66183527f0bbe41e52237ac13eb7b01f3cb999b7394d08734e71b1c3ada62713e17eb560c918301919091525160c0015290565b6040805180820190915260008082526020820152610808610d44565b8351815260208085015181830152835160408301528301516060808301919091526000908360c08460066107d05a03fa9050808061084257fe5b50806108855760405162461bcd60e51b81526020600482015260126024820152711c185a5c9a5b99cb5859190b59985a5b195960721b604482015260640161010e565b505092915050565b60408051808201909152600080825260208201526108a9610d62565b835181526020808501519082015260408101839052600060608360808460076107d05a03fa905080806108d857fe5b50806108855760405162461bcd60e51b81526020600482015260126024820152711c185a5c9a5b99cb5b5d5b0b59985a5b195960721b604482015260640161010e565b6040805180820190915260008082526020820152815115801561094057506020820151155b1561095e575050604080518082019091526000808252602082015290565b6040518060400160405280836000015181526020017f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd4784602001516109a3919061104e565b6109cd907f30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47611070565b905292915050565b60408051608080820183528a825260208083018a90528284018890526060808401879052845192830185528b83528282018a9052828501889052820185905283516018808252610320820190955260009491859190839082016103008036833701905050905060005b6004811015610c1f576000610a54826006611083565b9050858260048110610a6857610a68610ff0565b60200201515183610a7a83600061103b565b81518110610a8a57610a8a610ff0565b602002602001018181525050858260048110610aa857610aa8610ff0565b60200201516020015183826001610abf919061103b565b81518110610acf57610acf610ff0565b602002602001018181525050848260048110610aed57610aed610ff0565b6020020151515183610b0083600261103b565b81518110610b1057610b10610ff0565b602002602001018181525050848260048110610b2e57610b2e610ff0565b6020020151516001602002015183610b4783600361103b565b81518110610b5757610b57610ff0565b602002602001018181525050848260048110610b7557610b75610ff0565b602002015160200151600060028110610b9057610b90610ff0565b602002015183610ba183600461103b565b81518110610bb157610bb1610ff0565b602002602001018181525050848260048110610bcf57610bcf610ff0565b602002015160200151600160028110610bea57610bea610ff0565b602002015183610bfb83600561103b565b81518110610c0b57610c0b610ff0565b602090810291909101015250600101610a3e565b50610c28610d80565b6000602082602086026020860160086107d05a03fa90508080610c4757fe5b5080610c8d5760405162461bcd60e51b81526020600482015260156024820152741c185a5c9a5b99cb5bdc18dbd9194b59985a5b1959605a1b604482015260640161010e565b505115159d9c50505050505050505050505050565b6040805160a081019091526000606082018181526080830191909152815260208101610ccc610d9e565b8152602001610cee604051806040016040528060008152602001600081525090565b905290565b6040805160e08101909152600060a0820181815260c0830191909152815260208101610d1d610d9e565b8152602001610d2a610d9e565b8152602001610d37610d9e565b8152602001610cee610dbe565b60405180608001604052806004906020820280368337509192915050565b60405180606001604052806003906020820280368337509192915050565b60405180602001604052806001906020820280368337509192915050565b6040518060400160405280610db1610df7565b8152602001610cee610df7565b6040518060e001604052806007905b6040805180820190915260008082526020820152815260200190600190039081610dcd5790505090565b60405180604001604052806002906020820280368337509192915050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610e5457610e54610e15565b604052919050565b600082601f830112610e6d57600080fd5b60405160c0810181811067ffffffffffffffff82111715610e9057610e90610e15565b6040528060c0840185811115610ea557600080fd5b845b81811015610ebf578035835260209283019201610ea7565b509195945050505050565b60008060e08385031215610edd57600080fd5b823567ffffffffffffffff80821115610ef557600080fd5b818501915085601f830112610f0957600080fd5b8135602082821115610f1d57610f1d610e15565b610f2f601f8301601f19168201610e2b565b92508183528781838601011115610f4557600080fd5b81818501828501376000818385010152829550610f6488828901610e5c565b9450505050509250929050565b6000610100808385031215610f8557600080fd5b83601f840112610f9457600080fd5b60405181810181811067ffffffffffffffff82111715610fb657610fb6610e15565b604052908301908085831115610fcb57600080fd5b845b83811015610fe5578051825260209182019101610fcd565b509095945050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060ff821660ff810361103257611032611006565b60010192915050565b8082018082111561031b5761031b611006565b60008261106b57634e487b7160e01b600052601260045260246000fd5b500690565b8181038181111561031b5761031b611006565b808202811582820484141761031b5761031b61100656fea2646970667358221220563d0fbee4e0552a525beba0066d9fa4a4a5e087a3b9c480756c9e2adf284bce64736f6c63430008190033"; +const isSuperArgs$K = (xs) => xs.length > 1; +class Verifier__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$K(args)) { + super(...args); + } else { + super(_abi$1d, _bytecode$K, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$1d); + } + static connect(address, runner) { + return new Contract(address, _abi$1d, runner); + } +} +Verifier__factory.bytecode = _bytecode$K; +Verifier__factory.abi = _abi$1d; + +const _abi$1c = [ + { + inputs: [ + { + internalType: "address", + name: "_governance", + type: "address" + }, + { + internalType: "contract IERC20", + name: "_comp", + type: "address" + }, + { + internalType: "contract IVerifier", + name: "_verifier", + type: "address" + }, + { + internalType: "contract IHasher", + name: "_hasher", + type: "address" + }, + { + internalType: "uint256", + name: "_denomination", + type: "uint256" + }, + { + internalType: "uint32", + name: "_merkleTreeHeight", + type: "uint32" + }, + { + internalType: "contract IERC20", + name: "_token", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "commitment", + type: "bytes32" + }, + { + indexed: false, + internalType: "uint32", + name: "leafIndex", + type: "uint32" + }, + { + indexed: false, + internalType: "uint256", + name: "timestamp", + type: "uint256" + } + ], + name: "Deposit", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "bytes32", + name: "nullifierHash", + type: "bytes32" + }, + { + indexed: true, + internalType: "address", + name: "relayer", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "fee", + type: "uint256" + } + ], + name: "Withdrawal", + type: "event" + }, + { + inputs: [], + name: "FIELD_SIZE", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "ROOT_HISTORY_SIZE", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "ZERO_VALUE", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "claimComp", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + name: "commitments", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "comp", + outputs: [ + { + internalType: "contract IERC20", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "currentRootIndex", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "denomination", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_commitment", + type: "bytes32" + } + ], + name: "deposit", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "filledSubtrees", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getLastRoot", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "governance", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IHasher", + name: "_hasher", + type: "address" + }, + { + internalType: "bytes32", + name: "_left", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "_right", + type: "bytes32" + } + ], + name: "hashLeftRight", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "pure", + type: "function" + }, + { + inputs: [], + name: "hasher", + outputs: [ + { + internalType: "contract IHasher", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_root", + type: "bytes32" + } + ], + name: "isKnownRoot", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_nullifierHash", + type: "bytes32" + } + ], + name: "isSpent", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32[]", + name: "_nullifierHashes", + type: "bytes32[]" + } + ], + name: "isSpentArray", + outputs: [ + { + internalType: "bool[]", + name: "spent", + type: "bool[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "levels", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "nextIndex", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + name: "nullifierHashes", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "roots", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "token", + outputs: [ + { + internalType: "contract IERC20", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "verifier", + outputs: [ + { + internalType: "contract IVerifier", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes", + name: "_proof", + type: "bytes" + }, + { + internalType: "bytes32", + name: "_root", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "_nullifierHash", + type: "bytes32" + }, + { + internalType: "address payable", + name: "_recipient", + type: "address" + }, + { + internalType: "address payable", + name: "_relayer", + type: "address" + }, + { + internalType: "uint256", + name: "_fee", + type: "uint256" + }, + { + internalType: "uint256", + name: "_refund", + type: "uint256" + } + ], + name: "withdraw", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "zeros", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$J = "0x610160604052600380546001600160401b031916905534801561002157600080fd5b5060405161205a38038061205a8339810160408190526100409161048f565b848484848484848484808360008263ffffffff16116100b25760405162461bcd60e51b815260206004820152602360248201527f5f6c6576656c732073686f756c642062652067726561746572207468616e207a60448201526265726f60e81b60648201526084015b60405180910390fd5b60208263ffffffff16106101085760405162461bcd60e51b815260206004820152601e60248201527f5f6c6576656c732073686f756c64206265206c657373207468616e203332000060448201526064016100a9565b63ffffffff821660a0526001600160a01b0381166080527f2fe54c60d3acabf3343a35b6eba15db4821b340f76e741e2249685ed4899af6c60005b8363ffffffff168163ffffffff1610156101905763ffffffff811660009081526001602090815260408083208590559082905290208290556101868383806102aa565b9150600101610143565b506000805260026020527fac33ff75c19e70fe83507db0d683fd3465c996598dc972688b7ace676c89077b55505060016004558161021e5760405162461bcd60e51b815260206004820152602560248201527f64656e6f6d696e6174696f6e2073686f756c6420626520677265617465722074604482015264068616e20360dc1b60648201526084016100a9565b506001600160a01b0392831660c05260e05250908116610100528a16935061028c925050505760405162461bcd60e51b815260206004820152601a60248201527f496e76616c696420434f4d5020746f6b656e206164647265737300000000000060448201526064016100a9565b5050506001600160a01b03938416610120525050166101405261054e565b600060008051602061203a83398151915283106103095760405162461bcd60e51b815260206004820181905260248201527f5f6c6566742073686f756c6420626520696e7369646520746865206669656c6460448201526064016100a9565b60008051602061203a83398151915282106103705760405162461bcd60e51b815260206004820152602160248201527f5f72696768742073686f756c6420626520696e7369646520746865206669656c6044820152601960fa1b60648201526084016100a9565b60405163f47d33b560e01b81526004810184905260006024820181905284916001600160a01b0387169063f47d33b5906044016040805180830381865afa1580156103bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103e3919061052a565b909250905060008051602061203a83398151915284830860405163f47d33b560e01b815260048101829052602481018390529092506001600160a01b0387169063f47d33b5906044016040805180830381865afa158015610448573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061046c919061052a565b509695505050505050565b6001600160a01b038116811461048c57600080fd5b50565b600080600080600080600060e0888a0312156104aa57600080fd5b87516104b581610477565b60208901519097506104c681610477565b60408901519096506104d781610477565b60608901519095506104e881610477565b608089015160a08a0151919550935063ffffffff8116811461050957600080fd5b60c089015190925061051a81610477565b8091505092959891949750929550565b6000806040838503121561053d57600080fd5b505080516020909101519092909150565b60805160a05160c05160e051610100516101205161014051611a3e6105fc6000396000818161017d01526105d40152600081816102e5015261060501526000818161057801528181610ecc01528181610f0601526112600152600081816103690152818161074101528181610e9e015261128401526000818161023801526108aa01526000818161029c01528181610fe7015261108901526000818161051701526111210152611a3e6000f3fe6080604052600436106101665760003560e01c806390eeb02b116100d1578063e5285dcc1161008a578063ed33639f11610064578063ed33639f14610505578063f178e47c14610539578063fc0c546a14610566578063fc7e9c6f1461059a57600080fd5b8063e5285dcc14610474578063e8295588146104a4578063ec732959146104d157600080fd5b806390eeb02b146103ab5780639fa12d0b146103c8578063b214faa5146103f5578063ba70f75714610408578063c2b40ae414610432578063cd87a3b41461045f57600080fd5b80634ecf518b116101235780634ecf518b1461028a5780635aa6e675146102d35780636d9833e314610307578063839df945146103275780638bca6d16146103575780638ea3099e1461038b57600080fd5b8063109d0af81461016b57806317cc915c146101bc5780631bd85bdb146101fc57806321a0adb6146102135780632b7ac3f314610226578063414a37ba1461025a575b600080fd5b34801561017757600080fd5b5061019f7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156101c857600080fd5b506101ec6101d73660046114ef565b60056020526000908152604090205460ff1681565b60405190151581526020016101b3565b34801561020857600080fd5b506102116105bf565b005b61021161022136600461152d565b6106e3565b34801561023257600080fd5b5061019f7f000000000000000000000000000000000000000000000000000000000000000081565b34801561026657600080fd5b5061027c6000805160206119e983398151915281565b6040519081526020016101b3565b34801561029657600080fd5b506102be7f000000000000000000000000000000000000000000000000000000000000000081565b60405163ffffffff90911681526020016101b3565b3480156102df57600080fd5b5061019f7f000000000000000000000000000000000000000000000000000000000000000081565b34801561031357600080fd5b506101ec6103223660046114ef565b6109ee565b34801561033357600080fd5b506101ec6103423660046114ef565b60066020526000908152604090205460ff1681565b34801561036357600080fd5b5061027c7f000000000000000000000000000000000000000000000000000000000000000081565b34801561039757600080fd5b5061027c6103a63660046115e3565b610a6c565b3480156103b757600080fd5b506003546102be9063ffffffff1681565b3480156103d457600080fd5b506103e86103e3366004611618565b610c39565b6040516101b3919061168d565b6102116104033660046114ef565b610cf5565b34801561041457600080fd5b5060035463ffffffff1660009081526002602052604090205461027c565b34801561043e57600080fd5b5061027c61044d3660046114ef565b60026020526000908152604090205481565b34801561046b57600080fd5b506102be601e81565b34801561048057600080fd5b506101ec61048f3660046114ef565b60009081526005602052604090205460ff1690565b3480156104b057600080fd5b5061027c6104bf3660046114ef565b60016020526000908152604090205481565b3480156104dd57600080fd5b5061027c7f2fe54c60d3acabf3343a35b6eba15db4821b340f76e741e2249685ed4899af6c81565b34801561051157600080fd5b5061019f7f000000000000000000000000000000000000000000000000000000000000000081565b34801561054557600080fd5b5061027c6105543660046114ef565b60006020819052908152604090205481565b34801561057257600080fd5b5061019f7f000000000000000000000000000000000000000000000000000000000000000081565b3480156105a657600080fd5b506003546102be90640100000000900463ffffffff1681565b6040516370a0823160e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a9059cbb907f00000000000000000000000000000000000000000000000000000000000000009083906370a0823190602401602060405180830381865afa15801561064d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067191906116d3565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af11580156106bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e091906116ec565b50565b60026004540361073a5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b60026004557f00000000000000000000000000000000000000000000000000000000000000008211156107af5760405162461bcd60e51b815260206004820152601a60248201527f4665652065786365656473207472616e736665722076616c75650000000000006044820152606401610731565b60008581526005602052604090205460ff161561080e5760405162461bcd60e51b815260206004820152601f60248201527f546865206e6f746520686173206265656e20616c7265616479207370656e74006044820152606401610731565b610817866109ee565b6108635760405162461bcd60e51b815260206004820152601c60248201527f43616e6e6f742066696e6420796f7572206d65726b6c6520726f6f74000000006044820152606401610731565b6040805160c081018252878152602081018790526001600160a01b038681168284015285811660608301526080820185905260a08201849052915163695ef6f960e01b81527f00000000000000000000000000000000000000000000000000000000000000009092169163695ef6f9916108e3918c918c91600401611715565b6020604051808303816000875af1158015610902573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061092691906116ec565b61096b5760405162461bcd60e51b815260206004820152601660248201527524b73b30b634b2103bb4ba34323930bb90383937b7b360511b6044820152606401610731565b6000858152600560205260409020805460ff1916600117905561099084848484610e2c565b604080516001600160a01b03868116825260208201889052918101849052908416907fe9e508bad6d4c3227e881ca19068f099da81b5164dd6d62b2eaf1e8bc6c349319060600160405180910390a250506001600455505050505050565b60008181036109ff57506000919050565b60035463ffffffff16805b63ffffffff81166000908152600260205260409020548403610a30575060019392505050565b8063ffffffff16600003610a425750601e5b80610a4c81611789565b9150508163ffffffff168163ffffffff1603610a0a575060009392505050565b60006000805160206119e98339815191528310610acb5760405162461bcd60e51b815260206004820181905260248201527f5f6c6566742073686f756c6420626520696e7369646520746865206669656c646044820152606401610731565b6000805160206119e98339815191528210610b325760405162461bcd60e51b815260206004820152602160248201527f5f72696768742073686f756c6420626520696e7369646520746865206669656c6044820152601960fa1b6064820152608401610731565b60405163f47d33b560e01b81526004810184905260006024820181905284916001600160a01b0387169063f47d33b5906044016040805180830381865afa158015610b81573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba591906117a9565b90925090506000805160206119e983398151915284830860405163f47d33b560e01b815260048101829052602481018390529092506001600160a01b0387169063f47d33b5906044016040805180830381865afa158015610c0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2e91906117a9565b509695505050505050565b60608167ffffffffffffffff811115610c5457610c546117e3565b604051908082528060200260200182016040528015610c7d578160200160208202803683370190505b50905060005b82811015610cee57610cbc848483818110610ca057610ca06117f9565b9050602002013560009081526005602052604090205460ff1690565b15610ce6576001828281518110610cd557610cd56117f9565b911515602092830291909101909101525b600101610c83565b5092915050565b600260045403610d475760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610731565b600260045560008181526006602052604090205460ff1615610db55760405162461bcd60e51b815260206004820152602160248201527f54686520636f6d6d69746d656e7420686173206265656e207375626d697474656044820152601960fa1b6064820152608401610731565b6000610dc082610fce565b6000838152600660205260409020805460ff191660011790559050610de36111ec565b6040805163ffffffff8316815242602082015283917fa945e51eec50ab98c161376f0db4cf2aeba3ec92755fe2fcd388bdbbb80ff196910160405180910390a250506001600455565b803414610e945760405162461bcd60e51b815260206004820152603060248201527f496e636f727265637420726566756e6420616d6f756e7420726563656976656460448201526f08189e481d1a194818dbdb9d1c9858dd60821b6064820152608401610731565b610ef384610ec2847f000000000000000000000000000000000000000000000000000000000000000061180f565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691906112aa565b8115610f2d57610f2d6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001684846112aa565b8015610fc8576000846001600160a01b03168260405160006040518083038185875af1925050503d8060008114610f80576040519150601f19603f3d011682016040523d82523d6000602084013e610f85565b606091505b5050905080610fc6576040516001600160a01b0385169083156108fc029084906000818181858888f19350505050158015610fc4573d6000803e3d6000fd5b505b505b50505050565b600354600090640100000000900463ffffffff1661100d7f00000000000000000000000000000000000000000000000000000000000000006002611939565b63ffffffff168163ffffffff16036110805760405162461bcd60e51b815260206004820152603060248201527f4d65726b6c6520747265652069732066756c6c2e204e6f206d6f7265206c656160448201526f1d995cc818d85b88189948185919195960821b6064820152608401610731565b8083600080805b7f000000000000000000000000000000000000000000000000000000000000000063ffffffff168163ffffffff16101561115e576110c6600286611956565b63ffffffff166000036111005763ffffffff811660009081526001602090815260408083205491839052909120859055849350915061111c565b63ffffffff811660009081526020819052604090205492508391505b6111477f00000000000000000000000000000000000000000000000000000000000000008484610a6c565b9350611154600286611979565b9450600101611087565b50600354600090601e906111799063ffffffff16600161199c565b6111839190611956565b6003805463ffffffff191663ffffffff8316908117909155600090815260026020526040902085905590506111b986600161199c565b6003805463ffffffff929092166401000000000267ffffffff000000001990921691909117905550939695505050505050565b34156112535760405162461bcd60e51b815260206004820152603060248201527f4554482076616c756520697320737570706f73656420746f206265203020666f60448201526f7220455243323020696e7374616e636560801b6064820152608401610731565b6112a86001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633307f00000000000000000000000000000000000000000000000000000000000000006113c3565b565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b179052915160009283929087169161130691906119b9565b6000604051808303816000865af19150503d8060008114611343576040519150601f19603f3d011682016040523d82523d6000602084013e611348565b606091505b50915091508161135a57805181602001fd5b8051158061137757508080602001905181019061137791906116ec565b610fc65760405162461bcd60e51b815260206004820152601e60248201527f5361666545524332303a20736166655472616e73666572206661696c656400006044820152606401610731565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b179052915160009283929088169161142791906119b9565b6000604051808303816000865af19150503d8060008114611464576040519150601f19603f3d011682016040523d82523d6000602084013e611469565b606091505b50915091508161147b57805181602001fd5b8051158061149857508080602001905181019061149891906116ec565b610fc45760405162461bcd60e51b815260206004820152602260248201527f5361666545524332303a20736166655472616e7366657246726f6d206661696c604482015261195960f21b6064820152608401610731565b60006020828403121561150157600080fd5b5035919050565b6001600160a01b03811681146106e057600080fd5b803561152881611508565b919050565b60008060008060008060008060e0898b03121561154957600080fd5b883567ffffffffffffffff8082111561156157600080fd5b818b0191508b601f83011261157557600080fd5b81358181111561158457600080fd5b8c602082850101111561159657600080fd5b60209283019a509850508901359550604089013594506115b860608a0161151d565b93506115c660808a0161151d565b925060a0890135915060c089013590509295985092959890939650565b6000806000606084860312156115f857600080fd5b833561160381611508565b95602085013595506040909401359392505050565b6000806020838503121561162b57600080fd5b823567ffffffffffffffff8082111561164357600080fd5b818501915085601f83011261165757600080fd5b81358181111561166657600080fd5b8660208260051b850101111561167b57600080fd5b60209290920196919550909350505050565b6020808252825182820181905260009190848201906040850190845b818110156116c75783511515835292840192918401916001016116a9565b50909695505050505050565b6000602082840312156116e557600080fd5b5051919050565b6000602082840312156116fe57600080fd5b8151801515811461170e57600080fd5b9392505050565b60e081528260e08201526000610100848682850137600081868501015280601f19601f87011684010191505060208083018460005b60068110156117675781518352918301919083019060010161174a565b50505050949350505050565b634e487b7160e01b600052601160045260246000fd5b600063ffffffff82168061179f5761179f611773565b6000190192915050565b600080604083850312156117bc57600080fd5b505080516020909101519092909150565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b8181038181111561182257611822611773565b92915050565b600181815b80851115611865578163ffffffff0482111561184b5761184b611773565b8085161561185857918102915b93841c939080029061182d565b509250929050565b60008261187c57506001611822565b8161188957506000611822565b816001811461189f57600281146118a9576118da565b6001915050611822565b60ff8411156118ba576118ba611773565b6001841b915063ffffffff8211156118d4576118d4611773565b50611822565b5060208310610133831016604e8410600b8410161715611911575081810a63ffffffff81111561190c5761190c611773565b611822565b61191b8383611828565b8063ffffffff0482111561193157611931611773565b029392505050565b600063ffffffff61194e81851682851661186d565b949350505050565b600063ffffffff8084168061196d5761196d6117cd565b92169190910692915050565b600063ffffffff80841680611990576119906117cd565b92169190910492915050565b63ffffffff818116838216019080821115610cee57610cee611773565b6000825160005b818110156119da57602081860181015185830152016119c0565b50600092019182525091905056fe30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001a26469706673582212202fd93128e9fd6b3843a3df70f2fb8c1a7a326556fae702731ec0c55aa4921a8364736f6c6343000819003330644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001"; +const isSuperArgs$J = (xs) => xs.length > 1; +class CTornado__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$J(args)) { + super(...args); + } else { + super(_abi$1c, _bytecode$J, args[0]); + } + } + getDeployTransaction(_governance, _comp, _verifier, _hasher, _denomination, _merkleTreeHeight, _token, overrides) { + return super.getDeployTransaction( + _governance, + _comp, + _verifier, + _hasher, + _denomination, + _merkleTreeHeight, + _token, + overrides || {} + ); + } + deploy(_governance, _comp, _verifier, _hasher, _denomination, _merkleTreeHeight, _token, overrides) { + return super.deploy( + _governance, + _comp, + _verifier, + _hasher, + _denomination, + _merkleTreeHeight, + _token, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$1c); + } + static connect(address, runner) { + return new Contract(address, _abi$1c, runner); + } +} +CTornado__factory.bytecode = _bytecode$J; +CTornado__factory.abi = _abi$1c; + +const _abi$1b = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "operator", + type: "address" + }, + { + indexed: false, + internalType: "bool", + name: "approved", + type: "bool" + } + ], + name: "ApprovalForAll", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: true, + internalType: "bytes32", + name: "label", + type: "bytes32" + }, + { + indexed: false, + internalType: "address", + name: "owner", + type: "address" + } + ], + name: "NewOwner", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: false, + internalType: "address", + name: "resolver", + type: "address" + } + ], + name: "NewResolver", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: false, + internalType: "uint64", + name: "ttl", + type: "uint64" + } + ], + name: "NewTTL", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: false, + internalType: "address", + name: "owner", + type: "address" + } + ], + name: "Transfer", + type: "event" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "operator", + type: "address" + } + ], + name: "isApprovedForAll", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "recordExists", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "resolver", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "operator", + type: "address" + }, + { + internalType: "bool", + name: "approved", + type: "bool" + } + ], + name: "setApprovalForAll", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "address", + name: "owner", + type: "address" + } + ], + name: "setOwner", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "resolver", + type: "address" + }, + { + internalType: "uint64", + name: "ttl", + type: "uint64" + } + ], + name: "setRecord", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "address", + name: "resolver", + type: "address" + } + ], + name: "setResolver", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "label", + type: "bytes32" + }, + { + internalType: "address", + name: "owner", + type: "address" + } + ], + name: "setSubnodeOwner", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "label", + type: "bytes32" + }, + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "resolver", + type: "address" + }, + { + internalType: "uint64", + name: "ttl", + type: "uint64" + } + ], + name: "setSubnodeRecord", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "uint64", + name: "ttl", + type: "uint64" + } + ], + name: "setTTL", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "ttl", + outputs: [ + { + internalType: "uint64", + name: "", + type: "uint64" + } + ], + stateMutability: "view", + type: "function" + } +]; +class IENSRegistry__factory { + static createInterface() { + return new Interface(_abi$1b); + } + static connect(address, runner) { + return new Contract(address, _abi$1b, runner); + } +} +IENSRegistry__factory.abi = _abi$1b; + +const _abi$1a = [ + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "addr", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "string", + name: "key", + type: "string" + } + ], + name: "text", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + } +]; +class IENSResolver__factory { + static createInterface() { + return new Interface(_abi$1a); + } + static connect(address, runner) { + return new Contract(address, _abi$1a, runner); + } +} +IENSResolver__factory.abi = _abi$1a; + +const _abi$19 = [ + { + inputs: [ + { + internalType: "address", + name: "relayer", + type: "address" + } + ], + name: "getRelayerBalance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "relayer", + type: "address" + }, + { + internalType: "address", + name: "toResolve", + type: "address" + } + ], + name: "isRelayerRegistered", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + } +]; +class IRelayerRegistry__factory { + static createInterface() { + return new Interface(_abi$19); + } + static connect(address, runner) { + return new Contract(address, _abi$19, runner); + } +} +IRelayerRegistry__factory.abi = _abi$19; + +const _abi$18 = [ + { + inputs: [ + { + internalType: "address", + name: "_IENSRegistry", + type: "address" + }, + { + internalType: "address", + name: "_IRelayerRegistry", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [], + name: "ENSRegistry", + outputs: [ + { + internalType: "contract IENSRegistry", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "RelayerRegistry", + outputs: [ + { + internalType: "contract IRelayerRegistry", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32[]", + name: "_relayers", + type: "bytes32[]" + }, + { + internalType: "string[]", + name: "_subdomains", + type: "string[]" + } + ], + name: "relayersData", + outputs: [ + { + components: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "uint256", + name: "balance", + type: "uint256" + }, + { + internalType: "bool", + name: "isRegistered", + type: "bool" + }, + { + internalType: "string[20]", + name: "records", + type: "string[20]" + } + ], + internalType: "struct Relayer[]", + name: "", + type: "tuple[]" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$I = "0x60c060405234801561001057600080fd5b50604051610b74380380610b7483398101604081905261002f9161004d565b6001600160601b0319606092831b8116608052911b1660a05261009e565b6000806040838503121561005f578182fd5b825161006a81610086565b602084015190925061007b81610086565b809150509250929050565b6001600160a01b038116811461009b57600080fd5b50565b60805160601c60a05160601c610a9b6100d96000398060b2528061040352806104f1525080608e528061013a528061021b5250610a9b6000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80631cb120d61461004657806339c16356146100645780634d47d7751461006c575b600080fd5b61004e61008c565b60405161005b9190610891565b60405180910390f35b61004e6100b0565b61007f61007a366004610702565b6100d4565b60405161005b91906108bf565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b606080835167ffffffffffffffff811180156100ef57600080fd5b5060405190808252806020026020018201604052801561012957816020015b6101166105cd565b81526020019060019003908161010e5790505b50905060005b84518110156105c5577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166302571be386838151811061017357fe5b60200260200101516040518263ffffffff1660e01b8152600401610197919061099d565b60206040518083038186803b1580156101af57600080fd5b505afa1580156101c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101e791906106d4565b8282815181106101f357fe5b6020026020010151600001906001600160a01b031690816001600160a01b03168152505060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630178b8bf87848151811061025457fe5b60200260200101516040518263ffffffff1660e01b8152600401610278919061099d565b60206040518083038186803b15801561029057600080fd5b505afa1580156102a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c891906106d4565b905060005b85518110156104005760008784815181106102e457fe5b60200260200101518783815181106102f857fe5b60200260200101516040516020016103109190610875565b60405160208183030381529060405280519060200120604051602001610337929190610867565b60408051601f19818403018152908290528051602090910120631674750f60e21b825291506001600160a01b038416906359d1d43c9061037b9084906004016109a6565b60006040518083038186803b15801561039357600080fd5b505afa1580156103a7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526103cf91908101906107dc565b8585815181106103db57fe5b60200260200101516060015183601481106103f257fe5b6020020152506001016102cd565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b69fd4ab84848151811061043c57fe5b60200260200101516000015185858151811061045457fe5b6020026020010151600001516040518363ffffffff1660e01b815260040161047d9291906108a5565b60206040518083038186803b15801561049557600080fd5b505afa1580156104a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104cd91906107bc565b8383815181106104d957fe5b602002602001015160400190151590811515815250507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b971a6bf84848151811061052a57fe5b6020026020010151600001516040518263ffffffff1660e01b81526004016105529190610891565b60206040518083038186803b15801561056a57600080fd5b505afa15801561057e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a2919061084f565b8383815181106105ae57fe5b60209081029190910181015101525060010161012f565b509392505050565b604051806080016040528060006001600160a01b0316815260200160008152602001600015158152602001610600610605565b905290565b6040518061028001604052806014905b60608152602001906001900390816106155790505090565b600082601f83011261063d578081fd5b813561065061064b826109f1565b6109ca565b818152915060208083019084810160005b848110156106c9578135870188603f82011261067c57600080fd5b8381013561068c61064b82610a11565b81815260408b818486010111156106a257600080fd5b82818501888401375060009181018601919091528552509282019290820190600101610661565b505050505092915050565b6000602082840312156106e5578081fd5b81516001600160a01b03811681146106fb578182fd5b9392505050565b60008060408385031215610714578081fd5b823567ffffffffffffffff8082111561072b578283fd5b818501915085601f83011261073e578283fd5b813561074c61064b826109f1565b80828252602080830192508086018a82838702890101111561076c578788fd5b8796505b8487101561078e578035845260019690960195928101928101610770565b5090965087013593505050808211156107a5578283fd5b506107b28582860161062d565b9150509250929050565b6000602082840312156107cd578081fd5b815180151581146106fb578182fd5b6000602082840312156107ed578081fd5b815167ffffffffffffffff811115610803578182fd5b8201601f81018413610813578182fd5b805161082161064b82610a11565b818152856020838501011115610835578384fd5b610846826020830160208601610a35565b95945050505050565b600060208284031215610860578081fd5b5051919050565b918252602082015260400190565b60008251610887818460208701610a35565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6000602080830181845280855180835260408601915060408482028701019250838701855b8281101561099057878503603f19018452815180516001600160a01b03168652868101518787015260408082015115159087015260609081015160809187018290529086016103008701895b601481101561097b57888203607f1901835283518051610950818561099d565b61095d82828f8601610a35565b958c0195948c0194601f91909101601f191601925050600101610930565b509650505092850192908501906001016108e4565b5092979650505050505050565b90815260200190565b908152604060208201819052600390820152621d5c9b60ea1b606082015260800190565b60405181810167ffffffffffffffff811182821017156109e957600080fd5b604052919050565b600067ffffffffffffffff821115610a07578081fd5b5060209081020190565b600067ffffffffffffffff821115610a27578081fd5b50601f01601f191660200190565b60005b83811015610a50578181015183820152602001610a38565b83811115610a5f576000848401525b5050505056fea2646970667358221220628a366714cdda82fe91d785ad928e44e4b9f7976ed987e5fef72d207582dbaf64736f6c634300060c0033"; +const isSuperArgs$I = (xs) => xs.length > 1; +class RelayerAggregator__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$I(args)) { + super(...args); + } else { + super(_abi$18, _bytecode$I, args[0]); + } + } + getDeployTransaction(_IENSRegistry, _IRelayerRegistry, overrides) { + return super.getDeployTransaction( + _IENSRegistry, + _IRelayerRegistry, + overrides || {} + ); + } + deploy(_IENSRegistry, _IRelayerRegistry, overrides) { + return super.deploy( + _IENSRegistry, + _IRelayerRegistry, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$18); + } + static connect(address, runner) { + return new Contract(address, _abi$18, runner); + } +} +RelayerAggregator__factory.bytecode = _bytecode$I; +RelayerAggregator__factory.abi = _abi$18; + +const _abi$17 = [ + { + inputs: [ + { + internalType: "address", + name: "_ensRegistry", + type: "address" + }, + { + internalType: "address", + name: "_relayerRegistry", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [], + name: "ENSRegistry", + outputs: [ + { + internalType: "contract IENSRegistry", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "RelayerRegistry", + outputs: [ + { + internalType: "contract IRelayerRegistry", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract Governance", + name: "governance", + type: "address" + } + ], + name: "getAllProposals", + outputs: [ + { + components: [ + { + internalType: "address", + name: "proposer", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "forVotes", + type: "uint256" + }, + { + internalType: "uint256", + name: "againstVotes", + type: "uint256" + }, + { + internalType: "bool", + name: "executed", + type: "bool" + }, + { + internalType: "bool", + name: "extended", + type: "bool" + }, + { + internalType: "enum Governance.ProposalState", + name: "state", + type: "uint8" + } + ], + internalType: "struct GovernanceAggregator.Proposal[]", + name: "proposals", + type: "tuple[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract Governance", + name: "governance", + type: "address" + }, + { + internalType: "address[]", + name: "accs", + type: "address[]" + } + ], + name: "getGovernanceBalances", + outputs: [ + { + internalType: "uint256[]", + name: "amounts", + type: "uint256[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract Governance", + name: "governance", + type: "address" + }, + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "getUserData", + outputs: [ + { + internalType: "uint256", + name: "balance", + type: "uint256" + }, + { + internalType: "uint256", + name: "latestProposalId", + type: "uint256" + }, + { + internalType: "uint256", + name: "latestProposalIdState", + type: "uint256" + }, + { + internalType: "uint256", + name: "timelock", + type: "uint256" + }, + { + internalType: "address", + name: "delegatee", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32[]", + name: "_relayers", + type: "bytes32[]" + }, + { + internalType: "string[]", + name: "_subdomains", + type: "string[]" + } + ], + name: "relayersData", + outputs: [ + { + components: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "uint256", + name: "balance", + type: "uint256" + }, + { + internalType: "bool", + name: "isRegistered", + type: "bool" + }, + { + internalType: "string[20]", + name: "records", + type: "string[20]" + } + ], + internalType: "struct Relayer[]", + name: "", + type: "tuple[]" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$H = "0x60c060405234801561001057600080fd5b5060405161155d38038061155d83398101604081905261002f9161004d565b6001600160601b0319606092831b8116608052911b1660a05261009e565b6000806040838503121561005f578182fd5b825161006a81610086565b602084015190925061007b81610086565b809150509250929050565b6001600160a01b038116811461009b57600080fd5b50565b60805160601c60a05160601c6114826100db6000398061024b528061059c528061068a52508061022752806102d352806103b452506114826000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c8063029fcae7146100675780631cb120d61461009057806339c16356146100a55780634d47d775146100ad5780639853d922146100cd578063f4eeefe9146100ed575b600080fd5b61007a610075366004610fa1565b610111565b60405161008791906112ee565b60405180910390f35b610098610225565b6040516100879190611118565b610098610249565b6100c06100bb366004610e93565b61026d565b6040516100879190611210565b6100e06100db366004610dcc565b61075e565b6040516100879190611146565b6101006100fb366004610f69565b6109dd565b60405161008795949392919061135f565b60608167ffffffffffffffff8111801561012a57600080fd5b50604051908082528060200260200182016040528015610154578160200160208202803683370190505b50905060005b8281101561021d57846001600160a01b0316639ae697bf85858481811061017d57fe5b90506020020160208101906101929190610dcc565b6040518263ffffffff1660e01b81526004016101ae9190611118565b60206040518083038186803b1580156101c657600080fd5b505afa1580156101da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101fe91906110b5565b82828151811061020a57fe5b602090810291909101015260010161015a565b509392505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b606080835167ffffffffffffffff8111801561028857600080fd5b506040519080825280602002602001820160405280156102c257816020015b6102af610c79565b8152602001906001900390816102a75790505b50905060005b845181101561021d577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166302571be386838151811061030c57fe5b60200260200101516040518263ffffffff1660e01b81526004016103309190611332565b60206040518083038186803b15801561034857600080fd5b505afa15801561035c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103809190610def565b82828151811061038c57fe5b6020026020010151600001906001600160a01b031690816001600160a01b03168152505060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630178b8bf8784815181106103ed57fe5b60200260200101516040518263ffffffff1660e01b81526004016104119190611332565b60206040518083038186803b15801561042957600080fd5b505afa15801561043d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104619190610def565b905060005b855181101561059957600087848151811061047d57fe5b602002602001015187838151811061049157fe5b60200260200101516040516020016104a991906110fc565b604051602081830303815290604052805190602001206040516020016104d09291906110ee565b60408051601f19818403018152908290528051602090910120631674750f60e21b825291506001600160a01b038416906359d1d43c9061051490849060040161133b565b60006040518083038186803b15801561052c57600080fd5b505afa158015610540573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526105689190810190611042565b85858151811061057457fe5b602002602001015160600151836014811061058b57fe5b602002015250600101610466565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b69fd4ab8484815181106105d557fe5b6020026020010151600001518585815181106105ed57fe5b6020026020010151600001516040518363ffffffff1660e01b815260040161061692919061112c565b60206040518083038186803b15801561062e57600080fd5b505afa158015610642573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106669190610f4d565b83838151811061067257fe5b602002602001015160400190151590811515815250507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663b971a6bf8484815181106106c357fe5b6020026020010151600001516040518263ffffffff1660e01b81526004016106eb9190611118565b60206040518083038186803b15801561070357600080fd5b505afa158015610717573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073b91906110b5565b83838151811061074757fe5b6020908102919091018101510152506001016102c8565b6060816001600160a01b031663da35c6646040518163ffffffff1660e01b815260040160206040518083038186803b15801561079957600080fd5b505afa1580156107ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107d191906110b5565b67ffffffffffffffff811180156107e757600080fd5b5060405190808252806020026020018201604052801561082157816020015b61080e610cb1565b8152602001906001900390816108065790505b50905060005b81518110156109d7576000806000806000806000808a6001600160a01b031663013cf08b8a6001016040518263ffffffff1660e01b815260040161086b9190611332565b6101006040518083038186803b15801561088457600080fd5b505afa158015610898573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108bc9190610e0b565b97509750975097509750975097509750604051806101200160405280896001600160a01b03168152602001886001600160a01b03168152602001878152602001868152602001858152602001848152602001831515815260200182151581526020018c6001600160a01b0316633e4f49e68c6001016040518263ffffffff1660e01b815260040161094d9190611332565b60206040518083038186803b15801561096557600080fd5b505afa158015610979573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099d9190611023565b60068111156109a857fe5b8152508a8a815181106109b757fe5b602002602001018190525050505050505050508080600101915050610827565b50919050565b6000806000806000866001600160a01b0316639ae697bf876040518263ffffffff1660e01b8152600401610a119190611118565b60206040518083038186803b158015610a2957600080fd5b505afa158015610a3d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a6191906110b5565b6040516317977c6160e01b81529095506001600160a01b038816906317977c6190610a90908990600401611118565b60206040518083038186803b158015610aa857600080fd5b505afa158015610abc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae091906110b5565b93508315610b7257604051631f27a4f360e11b81526001600160a01b03881690633e4f49e690610b14908790600401611332565b60206040518083038186803b158015610b2c57600080fd5b505afa158015610b40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b649190611023565b6006811115610b6f57fe5b92505b60405163a72edda360e01b81526001600160a01b0388169063a72edda390610b9e908990600401611118565b60206040518083038186803b158015610bb657600080fd5b505afa158015610bca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bee91906110b5565b604051631976849960e21b81529092506001600160a01b038816906365da126490610c1d908990600401611118565b60206040518083038186803b158015610c3557600080fd5b505afa158015610c49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c6d9190610def565b90509295509295909350565b604051806080016040528060006001600160a01b0316815260200160008152602001600015158152602001610cac610cfd565b905290565b6040805161012081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905290610100820190610cac565b6040518061028001604052806014905b6060815260200190600190039081610d0d5790505090565b600082601f830112610d35578081fd5b8135610d48610d43826113b2565b61138b565b818152915060208083019084810160005b84811015610dc1578135870188603f820112610d7457600080fd5b83810135610d84610d43826113d2565b81815260408b81848601011115610d9a57600080fd5b82818501888401375060009181018601919091528552509282019290820190600101610d59565b505050505092915050565b600060208284031215610ddd578081fd5b8135610de881611426565b9392505050565b600060208284031215610e00578081fd5b8151610de881611426565b600080600080600080600080610100898b031215610e27578384fd5b8851610e3281611426565b60208a0151909850610e4381611426565b8097505060408901519550606089015194506080890151935060a0890151925060c0890151610e718161143e565b60e08a0151909250610e828161143e565b809150509295985092959890939650565b60008060408385031215610ea5578182fd5b823567ffffffffffffffff80821115610ebc578384fd5b818501915085601f830112610ecf578384fd5b8135610edd610d43826113b2565b80828252602080830192508086018a828387028901011115610efd578889fd5b8896505b84871015610f1f578035845260019690960195928101928101610f01565b509096508701359350505080821115610f36578283fd5b50610f4385828601610d25565b9150509250929050565b600060208284031215610f5e578081fd5b8151610de88161143e565b60008060408385031215610f7b578182fd5b8235610f8681611426565b91506020830135610f9681611426565b809150509250929050565b600080600060408486031215610fb5578283fd5b8335610fc081611426565b9250602084013567ffffffffffffffff80821115610fdc578384fd5b818601915086601f830112610fef578384fd5b813581811115610ffd578485fd5b8760208083028501011115611010578485fd5b6020830194508093505050509250925092565b600060208284031215611034578081fd5b815160078110610de8578182fd5b600060208284031215611053578081fd5b815167ffffffffffffffff811115611069578182fd5b8201601f81018413611079578182fd5b8051611087610d43826113d2565b81815285602083850101111561109b578384fd5b6110ac8260208301602086016113f6565b95945050505050565b6000602082840312156110c6578081fd5b5051919050565b6001600160a01b03169052565b15159052565b600781106110ea57fe5b9052565b918252602082015260400190565b6000825161110e8184602087016113f6565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b602080825282518282018190526000919060409081850190868401855b8281101561120357815180516001600160a01b031685528681015161118a888701826110cd565b508086015185870152606080820151908601526080808201519086015260a0808201519086015260c0808201516111c3828801826110da565b505060e0808201516111d7828801826110da565b505061010090810151906111ed868201836110e0565b5050610120939093019290850190600101611163565b5091979650505050505050565b6000602080830181845280855180835260408601915060408482028701019250838701855b828110156112e157878503603f19018452815180516001600160a01b03168652868101518787015260408082015115159087015260609081015160809187018290529086016103008701895b60148110156112cc57888203607f19018352835180516112a18185611332565b6112ae82828f86016113f6565b958c0195948c0194601f91909101601f191601925050600101611281565b50965050509285019290850190600101611235565b5092979650505050505050565b6020808252825182820181905260009190848201906040850190845b818110156113265783518352928401929184019160010161130a565b50909695505050505050565b90815260200190565b908152604060208201819052600390820152621d5c9b60ea1b606082015260800190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b60405181810167ffffffffffffffff811182821017156113aa57600080fd5b604052919050565b600067ffffffffffffffff8211156113c8578081fd5b5060209081020190565b600067ffffffffffffffff8211156113e8578081fd5b50601f01601f191660200190565b60005b838110156114115781810151838201526020016113f9565b83811115611420576000848401525b50505050565b6001600160a01b038116811461143b57600080fd5b50565b801515811461143b57600080fdfea26469706673582212209edead2cf5d16a9f09d7d75c5aa042cb00130c9febd0bf0e908fbf9c3f34f1a164736f6c634300060c0033"; +const isSuperArgs$H = (xs) => xs.length > 1; +class Aggregator__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$H(args)) { + super(...args); + } else { + super(_abi$17, _bytecode$H, args[0]); + } + } + getDeployTransaction(_ensRegistry, _relayerRegistry, overrides) { + return super.getDeployTransaction( + _ensRegistry, + _relayerRegistry, + overrides || {} + ); + } + deploy(_ensRegistry, _relayerRegistry, overrides) { + return super.deploy( + _ensRegistry, + _relayerRegistry, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$17); + } + static connect(address, runner) { + return new Contract(address, _abi$17, runner); + } +} +Aggregator__factory.bytecode = _bytecode$H; +Aggregator__factory.abi = _abi$17; + +const _abi$16 = [ + { + inputs: [ + { + internalType: "contract Governance", + name: "governance", + type: "address" + } + ], + name: "getAllProposals", + outputs: [ + { + components: [ + { + internalType: "address", + name: "proposer", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "forVotes", + type: "uint256" + }, + { + internalType: "uint256", + name: "againstVotes", + type: "uint256" + }, + { + internalType: "bool", + name: "executed", + type: "bool" + }, + { + internalType: "bool", + name: "extended", + type: "bool" + }, + { + internalType: "enum Governance.ProposalState", + name: "state", + type: "uint8" + } + ], + internalType: "struct GovernanceAggregator.Proposal[]", + name: "proposals", + type: "tuple[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract Governance", + name: "governance", + type: "address" + }, + { + internalType: "address[]", + name: "accs", + type: "address[]" + } + ], + name: "getGovernanceBalances", + outputs: [ + { + internalType: "uint256[]", + name: "amounts", + type: "uint256[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract Governance", + name: "governance", + type: "address" + }, + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "getUserData", + outputs: [ + { + internalType: "uint256", + name: "balance", + type: "uint256" + }, + { + internalType: "uint256", + name: "latestProposalId", + type: "uint256" + }, + { + internalType: "uint256", + name: "latestProposalIdState", + type: "uint256" + }, + { + internalType: "uint256", + name: "timelock", + type: "uint256" + }, + { + internalType: "address", + name: "delegatee", + type: "address" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$G = "0x608060405234801561001057600080fd5b50610ab8806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063029fcae7146100465780639853d9221461006f578063f4eeefe91461008f575b600080fd5b61005961005436600461082b565b6100b3565b60405161006691906109e3565b60405180910390f35b61008261007d36600461072c565b6101c7565b6040516100669190610919565b6100a261009d3660046107f3565b610446565b604051610066959493929190610a30565b60608167ffffffffffffffff811180156100cc57600080fd5b506040519080825280602002602001820160405280156100f6578160200160208202803683370190505b50905060005b828110156101bf57846001600160a01b0316639ae697bf85858481811061011f57fe5b9050602002016020810190610134919061072c565b6040518263ffffffff1660e01b81526004016101509190610905565b60206040518083038186803b15801561016857600080fd5b505afa15801561017c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101a091906108cc565b8282815181106101ac57fe5b60209081029190910101526001016100fc565b509392505050565b6060816001600160a01b031663da35c6646040518163ffffffff1660e01b815260040160206040518083038186803b15801561020257600080fd5b505afa158015610216573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061023a91906108cc565b67ffffffffffffffff8111801561025057600080fd5b5060405190808252806020026020018201604052801561028a57816020015b6102776106e2565b81526020019060019003908161026f5790505b50905060005b8151811015610440576000806000806000806000808a6001600160a01b031663013cf08b8a6001016040518263ffffffff1660e01b81526004016102d49190610a27565b6101006040518083038186803b1580156102ed57600080fd5b505afa158015610301573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610325919061076b565b97509750975097509750975097509750604051806101200160405280896001600160a01b03168152602001886001600160a01b03168152602001878152602001868152602001858152602001848152602001831515815260200182151581526020018c6001600160a01b0316633e4f49e68c6001016040518263ffffffff1660e01b81526004016103b69190610a27565b60206040518083038186803b1580156103ce57600080fd5b505afa1580156103e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061040691906108ad565b600681111561041157fe5b8152508a8a8151811061042057fe5b602002602001018190525050505050505050508080600101915050610290565b50919050565b6000806000806000866001600160a01b0316639ae697bf876040518263ffffffff1660e01b815260040161047a9190610905565b60206040518083038186803b15801561049257600080fd5b505afa1580156104a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104ca91906108cc565b6040516317977c6160e01b81529095506001600160a01b038816906317977c61906104f9908990600401610905565b60206040518083038186803b15801561051157600080fd5b505afa158015610525573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061054991906108cc565b935083156105db57604051631f27a4f360e11b81526001600160a01b03881690633e4f49e69061057d908790600401610a27565b60206040518083038186803b15801561059557600080fd5b505afa1580156105a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105cd91906108ad565b60068111156105d857fe5b92505b60405163a72edda360e01b81526001600160a01b0388169063a72edda390610607908990600401610905565b60206040518083038186803b15801561061f57600080fd5b505afa158015610633573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065791906108cc565b604051631976849960e21b81529092506001600160a01b038816906365da126490610686908990600401610905565b60206040518083038186803b15801561069e57600080fd5b505afa1580156106b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d6919061074f565b90509295509295909350565b6040805161012081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e081018290529061010082015290565b60006020828403121561073d578081fd5b813561074881610a5c565b9392505050565b600060208284031215610760578081fd5b815161074881610a5c565b600080600080600080600080610100898b031215610787578384fd5b885161079281610a5c565b60208a01519098506107a381610a5c565b8097505060408901519550606089015194506080890151935060a0890151925060c08901516107d181610a74565b60e08a01519092506107e281610a74565b809150509295985092959890939650565b60008060408385031215610805578182fd5b823561081081610a5c565b9150602083013561082081610a5c565b809150509250929050565b60008060006040848603121561083f578283fd5b833561084a81610a5c565b9250602084013567ffffffffffffffff80821115610866578384fd5b818601915086601f830112610879578384fd5b813581811115610887578485fd5b876020808302850101111561089a578485fd5b6020830194508093505050509250925092565b6000602082840312156108be578081fd5b815160078110610748578182fd5b6000602082840312156108dd578081fd5b5051919050565b6001600160a01b03169052565b15159052565b6007811061090157fe5b9052565b6001600160a01b0391909116815260200190565b602080825282518282018190526000919060409081850190868401855b828110156109d657815180516001600160a01b031685528681015161095d888701826108e4565b508086015185870152606080820151908601526080808201519086015260a0808201519086015260c080820151610996828801826108f1565b505060e0808201516109aa828801826108f1565b505061010090810151906109c0868201836108f7565b5050610120939093019290850190600101610936565b5091979650505050505050565b6020808252825182820181905260009190848201906040850190845b81811015610a1b578351835292840192918401916001016109ff565b50909695505050505050565b90815260200190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b6001600160a01b0381168114610a7157600080fd5b50565b8015158114610a7157600080fdfea2646970667358221220c68e065ff95a2c91c1e5904ff4ba8c709291d5227b10049b437e89d35c33af4d64736f6c634300060c0033"; +const isSuperArgs$G = (xs) => xs.length > 1; +class GovernanceAggregator__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$G(args)) { + super(...args); + } else { + super(_abi$16, _bytecode$G, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$16); + } + static connect(address, runner) { + return new Contract( + address, + _abi$16, + runner + ); + } +} +GovernanceAggregator__factory.bytecode = _bytecode$G; +GovernanceAggregator__factory.abi = _abi$16; + +const _abi$15 = [ + { + inputs: [ + { + internalType: "contract IDeployer", + name: "_deployer", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "addr", + type: "address" + } + ], + name: "Deployed", + type: "event" + }, + { + inputs: [ + { + internalType: "bytes", + name: "_initCode", + type: "bytes" + }, + { + internalType: "bytes32", + name: "_salt", + type: "bytes32" + } + ], + name: "deploy", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "deployer", + outputs: [ + { + internalType: "contract IDeployer", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$F = "0x60a060405234801561001057600080fd5b506040516103a93803806103a98339818101604052602081101561003357600080fd5b50516001600160a01b0381161561004a5780610060565b73ce0042b868300000d44a59004da54a005ffdcf9f5b60601b6001600160601b031916608052604051309032907f09e48df7857bd0c1e0d31bb8a85d42cf1874817895f171c917f6ee2cea73ec2090600090a35060805160601c6102e96100c06000398061010d528061029152506102e96000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80634af63f021461003b578063d5f39488146100e5575b600080fd5b6100e36004803603604081101561005157600080fd5b81019060208101813564010000000081111561006c57600080fd5b82018360208201111561007e57600080fd5b803590602001918460018302840111640100000000831117156100a057600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505091359250610109915050565b005b6100ed61028f565b604080516001600160a01b039092168252519081900360200190f35b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316634af63f0284846040518363ffffffff1660e01b81526004018080602001838152602001828103825284818151815260200191508051906020019080838360005b8381101561018e578181015183820152602001610176565b50505050905090810190601f1680156101bb5780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b1580156101db57600080fd5b505af11580156101ef573d6000803e3d6000fd5b505050506040513d602081101561020557600080fd5b505190506001600160a01b038116610254576040805162461bcd60e51b815260206004820152600d60248201526c11195c1b1bde4819985a5b1959609a1b604482015290519081900360640190fd5b6040516001600160a01b0382169033907f09e48df7857bd0c1e0d31bb8a85d42cf1874817895f171c917f6ee2cea73ec2090600090a3505050565b7f00000000000000000000000000000000000000000000000000000000000000008156fea26469706673582212209824ac82969e56106968b899123a2ecac48f942b4ed3dcae2ced58022879d32364736f6c634300060c0033"; +const isSuperArgs$F = (xs) => xs.length > 1; +class Deployer__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$F(args)) { + super(...args); + } else { + super(_abi$15, _bytecode$F, args[0]); + } + } + getDeployTransaction(_deployer, overrides) { + return super.getDeployTransaction(_deployer, overrides || {}); + } + deploy(_deployer, overrides) { + return super.deploy(_deployer, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$15); + } + static connect(address, runner) { + return new Contract(address, _abi$15, runner); + } +} +Deployer__factory.bytecode = _bytecode$F; +Deployer__factory.abi = _abi$15; + +const _abi$14 = [ + { + inputs: [ + { + internalType: "bytes", + name: "_initCode", + type: "bytes" + }, + { + internalType: "bytes32", + name: "_salt", + type: "bytes32" + } + ], + name: "deploy", + outputs: [ + { + internalType: "address payable", + name: "createdContract", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +class IDeployer__factory { + static createInterface() { + return new Interface(_abi$14); + } + static connect(address, runner) { + return new Contract(address, _abi$14, runner); + } +} +IDeployer__factory.abi = _abi$14; + +const _abi$13 = [ + { + inputs: [ + { + internalType: "contract IERC20", + name: "_token", + type: "address" + }, + { + internalType: "address", + name: "_spender", + type: "address" + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256" + } + ], + name: "approveExactToken", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class ITornadoRouter__factory { + static createInterface() { + return new Interface(_abi$13); + } + static connect(address, runner) { + return new Contract(address, _abi$13, runner); + } +} +ITornadoRouter__factory.abi = _abi$13; + +const _abi$12 = [ + { + inputs: [ + { + internalType: "address", + name: "_governance", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "contract ITornadoInstance", + name: "instance", + type: "address" + }, + { + indexed: false, + internalType: "enum InstanceRegistry.InstanceState", + name: "state", + type: "uint8" + } + ], + name: "InstanceStateUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "tornadoRouter", + type: "address" + } + ], + name: "RouterRegistered", + type: "event" + }, + { + inputs: [], + name: "getAllInstanceAddresses", + outputs: [ + { + internalType: "contract ITornadoInstance[]", + name: "result", + type: "address[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getAllInstances", + outputs: [ + { + components: [ + { + internalType: "contract ITornadoInstance", + name: "addr", + type: "address" + }, + { + components: [ + { + internalType: "bool", + name: "isERC20", + type: "bool" + }, + { + internalType: "contract IERC20", + name: "token", + type: "address" + }, + { + internalType: "enum InstanceRegistry.InstanceState", + name: "state", + type: "uint8" + }, + { + internalType: "uint24", + name: "uniswapPoolSwappingFee", + type: "uint24" + }, + { + internalType: "uint32", + name: "protocolFeePercentage", + type: "uint32" + } + ], + internalType: "struct InstanceRegistry.Instance", + name: "instance", + type: "tuple" + } + ], + internalType: "struct InstanceRegistry.Tornado[]", + name: "result", + type: "tuple[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "instance", + type: "address" + } + ], + name: "getPoolToken", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "governance", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + components: [ + { + internalType: "contract ITornadoInstance", + name: "addr", + type: "address" + }, + { + components: [ + { + internalType: "bool", + name: "isERC20", + type: "bool" + }, + { + internalType: "contract IERC20", + name: "token", + type: "address" + }, + { + internalType: "enum InstanceRegistry.InstanceState", + name: "state", + type: "uint8" + }, + { + internalType: "uint24", + name: "uniswapPoolSwappingFee", + type: "uint24" + }, + { + internalType: "uint32", + name: "protocolFeePercentage", + type: "uint32" + } + ], + internalType: "struct InstanceRegistry.Instance", + name: "instance", + type: "tuple" + } + ], + internalType: "struct InstanceRegistry.Tornado[]", + name: "_instances", + type: "tuple[]" + }, + { + internalType: "address", + name: "_router", + type: "address" + } + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "instanceIds", + outputs: [ + { + internalType: "contract ITornadoInstance", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "", + type: "address" + } + ], + name: "instances", + outputs: [ + { + internalType: "bool", + name: "isERC20", + type: "bool" + }, + { + internalType: "contract IERC20", + name: "token", + type: "address" + }, + { + internalType: "enum InstanceRegistry.InstanceState", + name: "state", + type: "uint8" + }, + { + internalType: "uint24", + name: "uniswapPoolSwappingFee", + type: "uint24" + }, + { + internalType: "uint32", + name: "protocolFeePercentage", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_instanceId", + type: "uint256" + } + ], + name: "removeInstance", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "router", + outputs: [ + { + internalType: "contract ITornadoRouter", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "instance", + type: "address" + }, + { + internalType: "uint32", + name: "newFee", + type: "uint32" + } + ], + name: "setProtocolFee", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "routerAddress", + type: "address" + } + ], + name: "setTornadoRouter", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + components: [ + { + internalType: "contract ITornadoInstance", + name: "addr", + type: "address" + }, + { + components: [ + { + internalType: "bool", + name: "isERC20", + type: "bool" + }, + { + internalType: "contract IERC20", + name: "token", + type: "address" + }, + { + internalType: "enum InstanceRegistry.InstanceState", + name: "state", + type: "uint8" + }, + { + internalType: "uint24", + name: "uniswapPoolSwappingFee", + type: "uint24" + }, + { + internalType: "uint32", + name: "protocolFeePercentage", + type: "uint32" + } + ], + internalType: "struct InstanceRegistry.Instance", + name: "instance", + type: "tuple" + } + ], + internalType: "struct InstanceRegistry.Tornado", + name: "_tornado", + type: "tuple" + } + ], + name: "updateInstance", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$E = "0x60a060405234801561001057600080fd5b5060405161146f38038061146f83398101604081905261002f91610044565b60601b6001600160601b031916608052610072565b600060208284031215610055578081fd5b81516001600160a01b038116811461006b578182fd5b9392505050565b60805160601c6113cc6100a3600039806103e552806105c052806105ed528061073a52806107e652506113cc6000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c80636c9be937116100715780636c9be9371461014d578063908e3b371461016057806392b65a4114610173578063b5b899b714610186578063cf552c8914610199578063f887ea40146101ac576100b4565b8063032bb443146100b957806310c13ac3146100e65780631ad058a9146100fb5780634ba16d9d1461011057806352c228e3146101235780635aa6e67514610138575b600080fd5b6100cc6100c7366004610e89565b6101b4565b6040516100dd95949392919061119c565b60405180910390f35b6100ee6101fe565b6040516100dd919061109f565b61010e610109366004610ec8565b6102af565b005b61010e61011e366004610e89565b6103da565b61012b61047f565b6040516100dd91906110ec565b6101406105be565b6040516100dd9190611071565b61010e61015b366004610fdb565b6105e2565b61014061016e366004610e89565b610709565b61010e610181366004610f80565b61072f565b61014061019436600461100d565b6107b4565b61010e6101a736600461100d565b6107db565b610140610a77565b60016020526000908152604090205460ff8082169161010081046001600160a01b031691600160a81b82041690600160b01b810462ffffff1690600160c81b900463ffffffff1685565b60025460609067ffffffffffffffff8111801561021a57600080fd5b50604051908082528060200260200182016040528015610244578160200160208202803683370190505b50905060005b6002548110156102ab576002818154811061026157fe5b9060005260206000200160009054906101000a90046001600160a01b031682828151811061028b57fe5b6001600160a01b039092166020928302919091019091015260010161024a565b5090565b600054610100900460ff16806102c857506102c8610a8c565b806102d6575060005460ff16155b6102fb5760405162461bcd60e51b81526004016102f29061121c565b60405180910390fd5b600054610100900460ff16158015610326576000805460ff1961ff0019909116610100171660011790555b6000805462010000600160b01b031916620100006001600160a01b038516021781555b83518110156103c25761036e84828151811061036157fe5b6020026020010151610a92565b600284828151811061037c57fe5b6020908102919091018101515182546001808201855560009485529290932090920180546001600160a01b0319166001600160a01b039093169290921790915501610349565b5080156103d5576000805461ff00191690555b505050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146104225760405162461bcd60e51b81526004016102f2906112ca565b6000805462010000600160b01b031916620100006001600160a01b038416021790556040517f94df8c3a8087dce110e5fbc5acf380c83c94bbd31b2c8ed4c08e1396a696e1a890610474908390611071565b60405180910390a150565b60025460609067ffffffffffffffff8111801561049b57600080fd5b506040519080825280602002602001820160405280156104d557816020015b6104c2610d64565b8152602001906001900390816104ba5790505b50905060005b6002548110156102ab576000600282815481106104f457fe5b60009182526020808320909101546040805180820182526001600160a01b03928316808252808652600180865295839020835160a081018552815460ff8082161515835261010082049097168289015292985092969587019592949093850192600160a81b909204169081111561056757fe5b600181111561057257fe5b81529054600160b01b810462ffffff166020830152600160c81b900463ffffffff16604090910152905283518490849081106105aa57fe5b6020908102919091010152506001016104db565b7f000000000000000000000000000000000000000000000000000000000000000081565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461062a5760405162461bcd60e51b81526004016102f2906112ca565b600061063c6080830160608401610fc0565b600181111561064757fe5b14156106655760405162461bcd60e51b81526004016102f290611293565b6000600160006106786020850185610e89565b6001600160a01b03168152602081019190915260400160002054600160a81b900460ff1660018111156106a757fe5b14156106ef5760026106bc6020830183610e89565b81546001810183556000928352602090922090910180546001600160a01b0319166001600160a01b039092169190911790555b61070661070136839003830183610ff2565b610a92565b50565b6001600160a01b038082166000908152600160205260409020546101009004165b919050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146107775760405162461bcd60e51b81526004016102f2906112ca565b6001600160a01b039091166000908152600160205260409020805463ffffffff909216600160c81b0263ffffffff60c81b19909216919091179055565b600281815481106107c157fe5b6000918252602090912001546001600160a01b0316905081565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146108235760405162461bcd60e51b81526004016102f2906112ca565b60006002828154811061083257fe5b60009182526020808320909101546001600160a01b03908116808452600190925260409092205490925060ff8116916101009091041681156109705760008054604051636eb1769f60e11b81526001600160a01b038085169263dd62ed3e926108aa9262010000909204909116908890600401611085565b60206040518083038186803b1580156108c257600080fd5b505afa1580156108d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fa9190611025565b9050801561096e5760008054604051633ef1078360e01b8152620100009091046001600160a01b031691633ef107839161093b9186918991906004016111e3565b600060405180830381600087803b15801561095557600080fd5b505af1158015610969573d6000803e3d6000fd5b505050505b505b6001600160a01b038316600090815260016020526040902080546001600160e81b03191690556002805460001981019081106109a857fe5b600091825260209091200154600280546001600160a01b0390921691869081106109ce57fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506002805480610a0757fe5b6001900381819060005260206000200160006101000a8154906001600160a01b0302191690559055826001600160a01b03167f02826f62d88a4d9f1978eb9c06f8663f642d032908e65a915d5898f3585421c06000604051610a699190611207565b60405180910390a250505050565b6000546201000090046001600160a01b031681565b303b1590565b60208181015182516001600160a01b0390811660009081526001808552604091829020845181549686015160ff1990971690151517610100600160a81b0319166101009690941695909502929092178085559083015192939291839160ff60a81b191690600160a81b908490811115610b0757fe5b02179055506060820151815460809093015163ffffffff16600160c81b0263ffffffff60c81b1962ffffff909216600160b01b0262ffffff60b01b19909416939093171691909117905560208101515115610d1457600081600001516001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b9b57600080fd5b505afa158015610baf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bd39190610eac565b90508160200151602001516001600160a01b0316816001600160a01b031614610c0e5760405162461bcd60e51b81526004016102f29061126a565b600080548351604051636eb1769f60e11b81526001600160a01b038086169363dd62ed3e93610c4b93620100009092049092169190600401611085565b60206040518083038186803b158015610c6357600080fd5b505afa158015610c77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c9b9190611025565b905080610d11576000548351604051633ef1078360e01b8152620100009092046001600160a01b031691633ef1078391610cde91869190600019906004016111e3565b600060405180830381600087803b158015610cf857600080fd5b505af1158015610d0c573d6000803e3d6000fd5b505050505b50505b80600001516001600160a01b03167f02826f62d88a4d9f1978eb9c06f8663f642d032908e65a915d5898f3585421c0826020015160400151604051610d599190611207565b60405180910390a250565b604051806040016040528060006001600160a01b03168152602001610d87610d8c565b905290565b6040805160a0810182526000808252602082018190529091820190815260006020820181905260409091015290565b8035610dc681611350565b92915050565b803560028110610dc657600080fd5b600081830360c0811215610ded578182fd5b610df760406112f2565b91508235610e0481611350565b825260a0601f1982011215610e1857600080fd5b50610e2360a06112f2565b6020830135610e3181611365565b81526040830135610e4181611350565b6020820152610e538460608501610dcc565b60408201526080830135610e6681611373565b606082015260a0830135610e7981611384565b6080820152602082015292915050565b600060208284031215610e9a578081fd5b8135610ea581611350565b9392505050565b600060208284031215610ebd578081fd5b8151610ea581611350565b60008060408385031215610eda578081fd5b823567ffffffffffffffff811115610ef0578182fd5b8301601f81018513610f00578182fd5b8035610f13610f0e82611319565b6112f2565b808282526020808301925080850160c08a838288028901011115610f35578788fd5b8796505b85871015610f6157610f4b8b83610ddb565b8552600196909601959382019390810190610f39565b5050819650610f7289828a01610dbb565b955050505050509250929050565b60008060408385031215610f92578182fd5b8235610f9d81611350565b9150602083013563ffffffff81168114610fb5578182fd5b809150509250929050565b600060208284031215610fd1578081fd5b610ea58383610dcc565b600060c08284031215610fec578081fd5b50919050565b600060c08284031215611003578081fd5b610ea58383610ddb565b60006020828403121561101e578081fd5b5035919050565b600060208284031215611036578081fd5b5051919050565b15159052565b6001600160a01b03169052565b6002811061105a57fe5b9052565b62ffffff169052565b63ffffffff169052565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6020808252825182820181905260009190848201906040850190845b818110156110e05783516001600160a01b0316835292840192918401916001016110bb565b50909695505050505050565b602080825282518282018190526000919060409081850190868401855b8281101561118f57815161111d8151611339565b85528601518051611131908887019061103d565b8681015161114187870182611043565b5085810151606061115481880183611050565b820151905060806111678782018361105e565b9190910151905061117b60a0860182611067565b5060c0939093019290850190600101611109565b5091979650505050505050565b85151581526001600160a01b038516602082015260a081016111bd85611345565b604083015262ffffff8416606083015263ffffffff831660808301529695505050505050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6020810161121483611345565b825292915050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252600f908201526e24b731b7b93932b1ba103a37b5b2b760891b604082015260600190565b6020808252601f908201527f5573652072656d6f7665496e7374616e6365282920666f722072656d6f766500604082015260600190565b6020808252600e908201526d139bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60405181810167ffffffffffffffff8111828210171561131157600080fd5b604052919050565b600067ffffffffffffffff82111561132f578081fd5b5060209081020190565b6001600160a01b031690565b806002811061072a57fe5b6001600160a01b038116811461070657600080fd5b801515811461070657600080fd5b62ffffff8116811461070657600080fd5b63ffffffff8116811461070657600080fdfea26469706673582212207c46c875176b62100d16a46c273e615cd9eb5336dbcd238b33b227f39ff9106564736f6c634300060c0033"; +const isSuperArgs$E = (xs) => xs.length > 1; +class InstanceRegistry__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$E(args)) { + super(...args); + } else { + super(_abi$12, _bytecode$E, args[0]); + } + } + getDeployTransaction(_governance, overrides) { + return super.getDeployTransaction(_governance, overrides || {}); + } + deploy(_governance, overrides) { + return super.deploy(_governance, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$12); + } + static connect(address, runner) { + return new Contract(address, _abi$12, runner); + } +} +InstanceRegistry__factory.bytecode = _bytecode$E; +InstanceRegistry__factory.abi = _abi$12; + +const _abi$11 = [ + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + } +]; +class IENS__factory { + static createInterface() { + return new Interface(_abi$11); + } + static connect(address, runner) { + return new Contract(address, _abi$11, runner); + } +} +IENS__factory.abi = _abi$11; + +const _abi$10 = [ + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "_instance", + type: "address" + } + ], + name: "instanceFeeWithUpdate", + outputs: [ + { + internalType: "uint160", + name: "", + type: "uint160" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +class IFeeManager__factory { + static createInterface() { + return new Interface(_abi$10); + } + static connect(address, runner) { + return new Contract(address, _abi$10, runner); + } +} +IFeeManager__factory.abi = _abi$10; + +const _abi$$ = [ + { + inputs: [ + { + internalType: "address", + name: "_torn", + type: "address" + }, + { + internalType: "address", + name: "_governance", + type: "address" + }, + { + internalType: "address", + name: "_ens", + type: "address" + }, + { + internalType: "address", + name: "_staking", + type: "address" + }, + { + internalType: "address", + name: "_feeManager", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "minStakeAmount", + type: "uint256" + } + ], + name: "MinimumStakeAmount", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "relayer", + type: "address" + } + ], + name: "RelayerBalanceNullified", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "bytes32", + name: "relayer", + type: "bytes32" + }, + { + indexed: false, + internalType: "string", + name: "ensName", + type: "string" + }, + { + indexed: false, + internalType: "address", + name: "relayerAddress", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "stakedAmount", + type: "uint256" + } + ], + name: "RelayerRegistered", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "tornadoRouter", + type: "address" + } + ], + name: "RouterRegistered", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "relayer", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "amountStakeAdded", + type: "uint256" + } + ], + name: "StakeAddedToRelayer", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "relayer", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "amountBurned", + type: "uint256" + } + ], + name: "StakeBurned", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "relayer", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "worker", + type: "address" + } + ], + name: "WorkerRegistered", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "relayer", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "worker", + type: "address" + } + ], + name: "WorkerUnregistered", + type: "event" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + }, + { + internalType: "address", + name: "relayer", + type: "address" + }, + { + internalType: "contract ITornadoInstance", + name: "pool", + type: "address" + } + ], + name: "burn", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "ens", + outputs: [ + { + internalType: "contract IENS", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "feeManager", + outputs: [ + { + internalType: "contract IFeeManager", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "relayer", + type: "address" + } + ], + name: "getRelayerBalance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "relayer", + type: "address" + } + ], + name: "getRelayerEnsHash", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "governance", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "_tornadoRouter", + type: "address" + } + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "toResolve", + type: "address" + } + ], + name: "isRelayer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "relayer", + type: "address" + }, + { + internalType: "address", + name: "toResolve", + type: "address" + } + ], + name: "isRelayerRegistered", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "minStakeAmount", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "relayer", + type: "address" + } + ], + name: "nullifyBalance", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "string", + name: "ensName", + type: "string" + }, + { + internalType: "uint256", + name: "stake", + type: "uint256" + }, + { + internalType: "address[]", + name: "workersToRegister", + type: "address[]" + } + ], + name: "register", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "string", + name: "ensName", + type: "string" + }, + { + internalType: "uint256", + name: "stake", + type: "uint256" + }, + { + internalType: "address[]", + name: "workersToRegister", + type: "address[]" + }, + { + internalType: "address", + name: "relayer", + type: "address" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "registerPermit", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "relayer", + type: "address" + }, + { + internalType: "address", + name: "worker", + type: "address" + } + ], + name: "registerWorker", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "relayers", + outputs: [ + { + internalType: "uint256", + name: "balance", + type: "uint256" + }, + { + internalType: "bytes32", + name: "ensHash", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "minAmount", + type: "uint256" + } + ], + name: "setMinStakeAmount", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "tornadoRouterAddress", + type: "address" + } + ], + name: "setTornadoRouter", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "relayer", + type: "address" + }, + { + internalType: "uint256", + name: "stake", + type: "uint256" + } + ], + name: "stakeToRelayer", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "relayer", + type: "address" + }, + { + internalType: "uint256", + name: "stake", + type: "uint256" + }, + { + internalType: "address", + name: "staker", + type: "address" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "stakeToRelayerPermit", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "staking", + outputs: [ + { + internalType: "contract TornadoStakingRewards", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "torn", + outputs: [ + { + internalType: "contract TORN", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "tornadoRouter", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "worker", + type: "address" + } + ], + name: "unregisterWorker", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "workers", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$D = "0x6101206040523480156200001257600080fd5b5060405162001e3c38038062001e3c83398101604081905262000035916200006d565b6001600160601b0319606095861b811660805293851b841660a05291841b831660c052831b821660e05290911b166101005262000105565b600080600080600060a0868803121562000085578081fd5b85516200009281620000ec565b6020870151909550620000a581620000ec565b6040870151909450620000b881620000ec565b6060870151909350620000cb81620000ec565b6080870151909250620000de81620000ec565b809150509295509295909350565b6001600160a01b03811681146200010257600080fd5b50565b60805160601c60a05160601c60c05160601c60e05160601c6101005160601c611cac62000190600039806105855280610b0b52508061066152806107c75280610dc0528061103e52508061046f5280610ec552508061071652806107f452806108ff5280610bfc52508061093852806109c15280610b4f5280610d9d528061101b5250611cac6000f3fe608060405234801561001057600080fd5b50600436106101585760003560e01c806385a29683116100c3578063d0fb02031161007c578063d0fb0203146102bc578063d990231d146102c4578063e37e8bcc146102d7578063e43fdb3c146102ea578063eb4af045146102fd578063f18876841461031057610158565b806385a2968314610248578063adf898a41461025b578063ae53941c14610263578063b69fd4ab14610283578063b971a6bf14610296578063c4d66de8146102a957610158565b80634cb16c2e116101155780634cb16c2e146101dc5780634cf088d9146101e45780634d4efd04146101ec5780635300f841146101ff578063541d5548146102205780635aa6e6751461024057610158565b80632e6506491461015d5780633523dc85146101725780633f15457f146101855780634048a257146101a357806345a11cec146101b65780634ba16d9d146101c9575b600080fd5b61017061016b36600461151e565b610318565b005b6101706101803660046114e6565b61036d565b61018d61046d565b60405161019a91906117c9565b60405180910390f35b61018d6101b13660046114e6565b610491565b6101706101c4366004611556565b6104ac565b6101706101d73660046114e6565b61070b565b61018d6107b0565b61018d6107c5565b6101706101fa3660046114e6565b6107e9565b61021261020d3660046114e6565b6108c4565b60405161019a92919061179f565b61023361022e3660046114e6565b6108dd565b60405161019a9190611875565b61018d6108fd565b6101706102563660046115cb565b610921565b61018d6109bf565b6102766102713660046114e6565b6109e3565b60405161019a9190611880565b61023361029136600461151e565b610a11565b6102766102a43660046114e6565b610a38565b6101706102b73660046114e6565b610a63565b61018d610b09565b6101706102d23660046115a0565b610b2d565b6101706102e53660046116d0565b610b38565b6101706102f8366004611659565b610bdc565b61017061030b366004611787565b610bf1565b610276610c6e565b3360008181526003602052604090205483906001600160a01b0380831691161461035d5760405162461bcd60e51b815260040161035490611b20565b60405180910390fd5b6103678484610c74565b50505050565b6001600160a01b03811633146103b6576001600160a01b038181166000908152600360205260409020541633146103b65760405162461bcd60e51b815260040161035490611b46565b6001600160a01b0380821660008181526003602052604090205490911614156103f15760405162461bcd60e51b815260040161035490611a5f565b6001600160a01b03808216600090815260036020526040908190205490517fb2a8e18b9e887f502d65c1683e60b723fa582a6903ea4e8eb23907a19c1ce8a09261043e92169084906117dd565b60405180910390a16001600160a01b0316600090815260036020526040902080546001600160a01b0319169055565b7f000000000000000000000000000000000000000000000000000000000000000081565b6003602052600090815260409020546001600160a01b031681565b6000546201000090046001600160a01b031633146104dc5760405162461bcd60e51b815260040161035490611938565b6001600160a01b03808416600090815260036020526040902054168061053a576001600160a01b0383811660009081526003602052604090205416156105345760405162461bcd60e51b815260040161035490611abc565b50610706565b826001600160a01b0316816001600160a01b03161461056b5760405162461bcd60e51b815260040161035490611b20565b604051630bbefce160e21b81526000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690632efbf384906105ba9086906004016117c9565b602060405180830381600087803b1580156105d457600080fd5b505af11580156105e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060c9190611502565b6001600160a01b03858116600090815260026020526040902054911691506106349082610d0d565b6001600160a01b038086166000908152600260205260409081902092909255905163338610af60e01b81527f00000000000000000000000000000000000000000000000000000000000000009091169063338610af90610698908490600401611880565b600060405180830381600087803b1580156106b257600080fd5b505af11580156106c6573d6000803e3d6000fd5b505050507f659f33fc6677bebf3a9bf3101092792e31f35766d0358e54577bdd91a655f6a084826040516106fb92919061185c565b60405180910390a150505b505050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146107535760405162461bcd60e51b8152600401610354906119b8565b6000805462010000600160b01b031916620100006001600160a01b038416021790556040517f94df8c3a8087dce110e5fbc5acf380c83c94bbd31b2c8ed4c08e1396a696e1a8906107a59083906117c9565b60405180910390a150565b6000546201000090046001600160a01b031681565b7f000000000000000000000000000000000000000000000000000000000000000081565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146108315760405162461bcd60e51b8152600401610354906119b8565b6001600160a01b0380821660008181526003602052604090205490911690811461086d5760405162461bcd60e51b815260040161035490611c0a565b6001600160a01b03811660009081526002602052604080822091909155517fafa759fb3c68e89eaaba359f0930ab40c24875b73cc9e2f6a38b0180019eb8f3906108b89084906117c9565b60405180910390a15050565b6002602052600090815260409020805460019091015482565b6001600160a01b0390811660009081526003602052604090205416151590565b7f000000000000000000000000000000000000000000000000000000000000000081565b60405163d505accf60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063d505accf9061097990889030908b908a908a908a908a9060040161181b565b600060405180830381600087803b15801561099357600080fd5b505af11580156109a7573d6000803e3d6000fd5b505050506109b6858888610d56565b50505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6001600160a01b03908116600090815260036020908152604080832054909316825260029052206001015490565b6001600160a01b038181166000908152600360205260409020548116908316145b92915050565b6001600160a01b03908116600090815260036020908152604080832054909316825260029052205490565b600054610100900460ff1680610a7c5750610a7c610e64565b80610a8a575060005460ff16155b610aa65760405162461bcd60e51b815260040161035490611a11565b600054610100900460ff16158015610ad1576000805460ff1961ff0019909116610100171660011790555b6000805462010000600160b01b031916620100006001600160a01b038516021790558015610b05576000805461ff00191690555b5050565b7f000000000000000000000000000000000000000000000000000000000000000081565b610b05338383610d56565b60405163d505accf60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063d505accf90610b9090889030908d908a908a908a908a9060040161181b565b600060405180830381600087803b158015610baa57600080fd5b505af1158015610bbe573d6000803e3d6000fd5b50505050610bd0858b8b8b8b8b610e6a565b50505050505050505050565b610bea338686868686610e6a565b5050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610c395760405162461bcd60e51b8152600401610354906119b8565b60018190556040517f404663163d528ec45288abc4389b81bd96fabf858ff57577ebd4ee7f15d7b0a6906107a5908390611880565b60015481565b6001600160a01b038181166000908152600360205260409020541615610cac5760405162461bcd60e51b8152600401610354906119e1565b6001600160a01b038181166000908152600360205260409081902080546001600160a01b03191692851692909217909155517fcde75bd02c5f739608c891bcd9aa6809e6c4a7035ac7b9f3fd5fea756db74724906108b890849084906117dd565b6000610d4f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061115b565b9392505050565b6001600160a01b0380831660008181526003602052604090205490911614610d905760405162461bcd60e51b815260040161035490611993565b610de56001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016847f000000000000000000000000000000000000000000000000000000000000000084611187565b6001600160a01b038216600090815260026020526040902054610e099082906111df565b6001600160a01b0383166000908152600260205260409081902091909155517f1275dbe2a271b2b822e60f1d44894fa5fb337e7e2dc6a200205b1a5b17c07d6490610e57908490849061185c565b60405180910390a1505050565b303b1590565b6000610eab86868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061120492505050565b6040516302571be360e01b81529091506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906302571be390610efa908490600401611880565b60206040518083038186803b158015610f1257600080fd5b505afa158015610f26573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f4a9190611502565b6001600160a01b0316876001600160a01b031614610f7a5760405162461bcd60e51b815260040161035490611be2565b6001600160a01b038781166000908152600360205260409020541615610fb25760405162461bcd60e51b815260040161035490611a8f565b6001600160a01b0387166000908152600260205260409020600181015415610fec5760405162461bcd60e51b81526004016103549061190c565b60015485101561100e5760405162461bcd60e51b815260040161035490611bbe565b6110636001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016897f000000000000000000000000000000000000000000000000000000000000000088611187565b7f1275dbe2a271b2b822e60f1d44894fa5fb337e7e2dc6a200205b1a5b17c07d64888660405161109492919061185c565b60405180910390a1848155600181018290556001600160a01b038816600081815260036020526040812080546001600160a01b0319169092179091555b838110156111115760008585838181106110e757fe5b90506020020160208101906110fc91906114e6565b90506111088a82610c74565b506001016110d1565b507f9ca7c9c762eff27b021608f232b4c4b8f9b8bf9a3d322297e47cc4209a67d5e28288888b89604051611149959493929190611889565b60405180910390a15050505050505050565b6000818484111561117f5760405162461bcd60e51b815260040161035491906118d9565b505050900390565b610367846323b872dd60e01b8585856040516024016111a8939291906117f7565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611211565b600082820183811015610d4f5760405162461bcd60e51b81526004016103549061195c565b6000610a328260006112a0565b6060611266826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661130a9092919063ffffffff16565b80519091501561070657808060200190518101906112849190611639565b6107065760405162461bcd60e51b815260040161035490611b74565b6000818351116112b257506000610a32565b60006112be8484611321565b90506112cf848285016001016112a0565b6112da858584611366565b6040516020016112eb92919061179f565b6040516020818303038152906040528051906020012091505092915050565b60606113198484600085611382565b949350505050565b6000805b8351818401141580156113595750838184018151811061134157fe5b6020910101516001600160f81b031916601760f91b14155b15610d4f57600101611325565b60008351828401111561137857600080fd5b5091016020012090565b606061138d85611446565b6113a95760405162461bcd60e51b815260040161035490611ae9565b60006060866001600160a01b031685876040516113c691906117ad565b60006040518083038185875af1925050503d8060008114611403576040519150601f19603f3d011682016040523d82523d6000602084013e611408565b606091505b5091509150811561141c5791506113199050565b80511561142c5780518082602001fd5b8360405162461bcd60e51b815260040161035491906118d9565b3b151590565b60008083601f84011261145d578182fd5b50813567ffffffffffffffff811115611474578182fd5b602083019150836020808302850101111561148e57600080fd5b9250929050565b60008083601f8401126114a6578182fd5b50813567ffffffffffffffff8111156114bd578182fd5b60208301915083602082850101111561148e57600080fd5b803560ff81168114610a3257600080fd5b6000602082840312156114f7578081fd5b8135610d4f81611c5e565b600060208284031215611513578081fd5b8151610d4f81611c5e565b60008060408385031215611530578081fd5b823561153b81611c5e565b9150602083013561154b81611c5e565b809150509250929050565b60008060006060848603121561156a578081fd5b833561157581611c5e565b9250602084013561158581611c5e565b9150604084013561159581611c5e565b809150509250925092565b600080604083850312156115b2578182fd5b82356115bd81611c5e565b946020939093013593505050565b600080600080600080600060e0888a0312156115e5578283fd5b87356115f081611c5e565b965060208801359550604088013561160781611c5e565b94506060880135935061161d8960808a016114d5565b925060a0880135915060c0880135905092959891949750929550565b60006020828403121561164a578081fd5b81518015158114610d4f578182fd5b600080600080600060608688031215611670578081fd5b853567ffffffffffffffff80821115611687578283fd5b61169389838a01611495565b90975095506020880135945060408801359150808211156116b2578283fd5b506116bf8882890161144c565b969995985093965092949392505050565b6000806000806000806000806000806101008b8d0312156116ef578283fd5b8a3567ffffffffffffffff80821115611706578485fd5b6117128e838f01611495565b909c509a5060208d0135995060408d0135915080821115611731578485fd5b5061173e8d828e0161144c565b90985096505060608b013561175281611c5e565b945060808b013593506117688c60a08d016114d5565b925060c08b0135915060e08b013590509295989b9194979a5092959850565b600060208284031215611798578081fd5b5035919050565b918252602082015260400190565b600082516117bf818460208701611c32565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b90815260200190565b600086825260806020830152846080830152848660a084013760a08583018101919091526001600160a01b039390931660408201526060810191909152601f909201601f19169091010192915050565b60006020825282518060208401526118f8816040850160208701611c32565b601f01601f19169190910160400192915050565b6020808252601290820152717265676973746572656420616c726561647960701b604082015260600190565b6020808252600a90820152696f6e6c792070726f787960b01b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252600b908201526a085c9959da5cdd195c995960aa1b604082015260600190565b6020808252600f908201526e6f6e6c7920676f7665726e616e636560881b604082015260600190565b60208082526016908201527563616e277420737465616c20616e206164647265737360501b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526016908201527531b0b73a103ab73932b3b4b9ba32b91036b0b9ba32b960511b604082015260600190565b60208082526013908201527231b0b73a103932b3b4b9ba32b91030b3b0b4b760691b604082015260600190565b60208082526013908201527227b7363c9031bab9ba37b6903932b630bcb2b960691b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252600c908201526b37b7363c903932b630bcb2b960a11b604082015260600190565b60208082526014908201527337b7363c9037bbb732b91037b3103bb7b935b2b960611b604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252600a9082015269216d696e5f7374616b6560b01b604082015260600190565b6020808252600e908201526d37b7363c9032b7399037bbb732b960911b604082015260600190565b6020808252600e908201526d36bab9ba1031329036b0b9ba32b960911b604082015260600190565b60005b83811015611c4d578181015183820152602001611c35565b838111156103675750506000910152565b6001600160a01b0381168114611c7357600080fd5b5056fea2646970667358221220af9b060307b803c3e85be3c7887780626ba06e3ccb6888222cb230fd87c11d5664736f6c634300060c0033"; +const isSuperArgs$D = (xs) => xs.length > 1; +class RelayerRegistry__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$D(args)) { + super(...args); + } else { + super(_abi$$, _bytecode$D, args[0]); + } + } + getDeployTransaction(_torn, _governance, _ens, _staking, _feeManager, overrides) { + return super.getDeployTransaction( + _torn, + _governance, + _ens, + _staking, + _feeManager, + overrides || {} + ); + } + deploy(_torn, _governance, _ens, _staking, _feeManager, overrides) { + return super.deploy( + _torn, + _governance, + _ens, + _staking, + _feeManager, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$$); + } + static connect(address, runner) { + return new Contract(address, _abi$$, runner); + } +} +RelayerRegistry__factory.bytecode = _bytecode$D; +RelayerRegistry__factory.abi = _abi$$; + +const _abi$_ = [ + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "resolver", + outputs: [ + { + internalType: "contract Resolver", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + } +]; +class ENS__factory { + static createInterface() { + return new Interface(_abi$_); + } + static connect(address, runner) { + return new Contract(address, _abi$_, runner); + } +} +ENS__factory.abi = _abi$_; + +const _abi$Z = [ + { + inputs: [ + { + internalType: "bytes32[]", + name: "domains", + type: "bytes32[]" + } + ], + name: "bulkResolve", + outputs: [ + { + internalType: "address[]", + name: "result", + type: "address[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "resolve", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$C = "0x608060405234801561001057600080fd5b5061036d806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80635c23bdf51461003b578063f9e5423414610074575b600080fd5b6100586004803603602081101561005157600080fd5b5035610167565b604080516001600160a01b039092168252519081900360200190f35b6101176004803603602081101561008a57600080fd5b8101906020810181356401000000008111156100a557600080fd5b8201836020820111156100b757600080fd5b803590602001918460208302840111640100000000831117156100d957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550610292945050505050565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561015357818101518382015260200161013b565b505050509050019250505060405180910390f35b600080610172610333565b60011461019357738595bfb0d940dfedc98943fa8a907091203f25ee6101a4565b6e0c2e074ec69a0dfb2997ba6c7d2e1e5b9050806001600160a01b0316630178b8bf846040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156101ea57600080fd5b505afa1580156101fe573d6000803e3d6000fd5b505050506040513d602081101561021457600080fd5b505160408051631d9dabef60e11b81526004810186905290516001600160a01b0390921691633b3b57de91602480820192602092909190829003018186803b15801561025f57600080fd5b505afa158015610273573d6000803e3d6000fd5b505050506040513d602081101561028957600080fd5b50519392505050565b6060815167ffffffffffffffff811180156102ac57600080fd5b506040519080825280602002602001820160405280156102d6578160200160208202803683370190505b50905060005b825181101561032d576103018382815181106102f457fe5b6020026020010151610167565b82828151811061030d57fe5b6001600160a01b03909216602092830291909101909101526001016102dc565b50919050565b469056fea26469706673582212201849a5e31df8347ec61f3d54e8cef603101becea24443df7d4e43cc42ff12a7564736f6c634300060c0033"; +const isSuperArgs$C = (xs) => xs.length > 1; +class EnsResolve__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$C(args)) { + super(...args); + } else { + super(_abi$Z, _bytecode$C, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$Z); + } + static connect(address, runner) { + return new Contract(address, _abi$Z, runner); + } +} +EnsResolve__factory.bytecode = _bytecode$C; +EnsResolve__factory.abi = _abi$Z; + +const _abi$Y = [ + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "addr", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + } +]; +class Resolver__factory { + static createInterface() { + return new Interface(_abi$Y); + } + static connect(address, runner) { + return new Contract(address, _abi$Y, runner); + } +} +Resolver__factory.abi = _abi$Y; + +const _abi$X = [ + { + inputs: [ + { + internalType: "bytes32", + name: "tokenAddress", + type: "bytes32" + }, + { + components: [ + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + internalType: "struct Airdrop.Recipient[]", + name: "targets", + type: "tuple[]" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [ + { + internalType: "bytes32[]", + name: "domains", + type: "bytes32[]" + } + ], + name: "bulkResolve", + outputs: [ + { + internalType: "address[]", + name: "result", + type: "address[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "addr", + type: "bytes32" + } + ], + name: "resolve", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$B = "0x608060405234801561001057600080fd5b5060405161039938038061039983398101604081905261002f91610220565b8181600061003c836101aa565b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161006c91906102e4565b60206040518083038186803b15801561008457600080fd5b505afa158015610098573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100bc91906102cc565b116100e25760405162461bcd60e51b81526004016100d990610311565b60405180910390fd5b60005b82518110156101a557816001600160a01b031663a9059cbb84838151811061010957fe5b60200260200101516000015185848151811061012157fe5b6020026020010151602001516040518363ffffffff1660e01b815260040161014a9291906102f8565b602060405180830381600087803b15801561016457600080fd5b505af1158015610178573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061019c91906101f9565b506001016100e5565b506000ff5b60601c90565b6000604082840312156101c1578081fd5b6101cb6040610353565b82519091506001600160a01b03811681146101e557600080fd5b808252506020820151602082015292915050565b60006020828403121561020a578081fd5b81518015158114610219578182fd5b9392505050565b6000806040808486031215610233578182fd5b8351602080860151919450906001600160401b03811115610252578384fd5b8501601f81018713610262578384fd5b805161027561027082610379565b610353565b81815283810190838501868402850186018b1015610291578788fd5b8794505b838510156102bb576102a78b826101b0565b835260019490940193918501918601610295565b508096505050505050509250929050565b6000602082840312156102dd578081fd5b5051919050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b60208082526022908201527f42616c616e636520697320302c2061697264726f7020616c726561647920646f6040820152616e6560f01b606082015260800190565b6040518181016001600160401b038111828210171561037157600080fd5b604052919050565b60006001600160401b0382111561038e578081fd5b506020908102019056fe"; +const isSuperArgs$B = (xs) => xs.length > 1; +class AirdropMock__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$B(args)) { + super(...args); + } else { + super(_abi$X, _bytecode$B, args[0]); + } + } + getDeployTransaction(tokenAddress, targets, overrides) { + return super.getDeployTransaction(tokenAddress, targets, overrides || {}); + } + deploy(tokenAddress, targets, overrides) { + return super.deploy(tokenAddress, targets, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$X); + } + static connect(address, runner) { + return new Contract(address, _abi$X, runner); + } +} +AirdropMock__factory.bytecode = _bytecode$B; +AirdropMock__factory.abi = _abi$X; + +const _abi$W = [ + { + inputs: [ + { + internalType: "bytes32", + name: "_node", + type: "bytes32" + } + ], + name: "addr", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes[]", + name: "data", + type: "bytes[]" + } + ], + name: "multicall", + outputs: [ + { + internalType: "bytes[]", + name: "results", + type: "bytes[]" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + name: "registry", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + name: "resolver", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "_node", + type: "bytes32" + }, + { + internalType: "address", + name: "_addr", + type: "address" + } + ], + name: "setAddr", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$A = "0x608060405234801561001057600080fd5b5061044b806100206000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80630178b8bf1461005c5780633b3b57de146100855780637ef5029814610098578063ac9650d8146100ab578063d5fa2b00146100cb575b600080fd5b61006f61006a3660046102bc565b6100e0565b60405161007c919061031e565b60405180910390f35b61006f6100933660046102bc565b6100e5565b61006f6100a63660046102bc565b610100565b6100be6100b936600461024d565b61011b565b60405161007c9190610332565b6100de6100d93660046102d4565b61021f565b005b503090565b6000908152602081905260409020546001600160a01b031690565b6000602081905290815260409020546001600160a01b031681565b60608167ffffffffffffffff8111801561013457600080fd5b5060405190808252806020026020018201604052801561016857816020015b60608152602001906001900390816101535790505b50905060005b8281101561021857600060603086868581811061018757fe5b905060200281019061019991906103c9565b6040516101a792919061030e565b600060405180830381855af49150503d80600081146101e2576040519150601f19603f3d011682016040523d82523d6000602084013e6101e7565b606091505b5091509150816101f657600080fd5b8084848151811061020357fe5b6020908102919091010152505060010161016e565b5092915050565b60009182526020829052604090912080546001600160a01b0319166001600160a01b03909216919091179055565b6000806020838503121561025f578182fd5b823567ffffffffffffffff80821115610276578384fd5b818501915085601f830112610289578384fd5b813581811115610297578485fd5b86602080830285010111156102aa578485fd5b60209290920196919550909350505050565b6000602082840312156102cd578081fd5b5035919050565b600080604083850312156102e6578182fd5b8235915060208301356001600160a01b0381168114610303578182fd5b809150509250929050565b6000828483379101908152919050565b6001600160a01b0391909116815260200190565b6000602080830181845280855180835260408601915060408482028701019250838701855b828110156103bc57878503603f1901845281518051808752885b8181101561038c578281018901518882018a01528801610371565b8181111561039c578989838a0101525b50601f01601f191695909501860194509285019290850190600101610357565b5092979650505050505050565b6000808335601e198436030181126103df578283fd5b83018035915067ffffffffffffffff8211156103f9578283fd5b60200191503681900382131561040e57600080fd5b925092905056fea26469706673582212202e44de42b72aec6265acc191876b290bc887c846ffca216ac5d28a16fd49092564736f6c634300060c0033"; +const isSuperArgs$A = (xs) => xs.length > 1; +class ENSMock__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$A(args)) { + super(...args); + } else { + super(_abi$W, _bytecode$A, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$W); + } + static connect(address, runner) { + return new Contract(address, _abi$W, runner); + } +} +ENSMock__factory.bytecode = _bytecode$A; +ENSMock__factory.abi = _abi$W; + +const _abi$V = [ + { + inputs: [ + { + internalType: "address", + name: "_governance", + type: "address" + }, + { + internalType: "uint256", + name: "_pausePeriod", + type: "uint256" + }, + { + components: [ + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + internalType: "struct TORN.Recipient[]", + name: "_vesting", + type: "tuple[]" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "target", + type: "address" + } + ], + name: "Allowed", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "target", + type: "address" + } + ], + name: "Disallowed", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "account", + type: "address" + } + ], + name: "Paused", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "account", + type: "address" + } + ], + name: "Unpaused", + type: "event" + }, + { + inputs: [ + { + internalType: "address[]", + name: "target", + type: "address[]" + } + ], + name: "addToAllowedList", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "allowedTransferee", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "blockTimestamp", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "burn", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "burnFrom", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "canUnpauseAfter", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "chainID", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "chainId", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bool", + name: "decision", + type: "bool" + } + ], + name: "changeTransferability", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "subtractedValue", + type: "uint256" + } + ], + name: "decreaseAllowance", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "fakeTimestamp", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "governance", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "addedValue", + type: "uint256" + } + ], + name: "increaseAllowance", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + } + ], + name: "nonces", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "paused", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "permit", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address[]", + name: "target", + type: "address[]" + } + ], + name: "removeFromAllowedList", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "_token", + type: "address" + }, + { + internalType: "address payable", + name: "_to", + type: "address" + }, + { + internalType: "uint256", + name: "_balance", + type: "uint256" + } + ], + name: "rescueTokens", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_chainId", + type: "uint256" + } + ], + name: "setChainId", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_fakeTimestamp", + type: "uint256" + } + ], + name: "setFakeTimestamp", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + }, + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$z = "0x60c06040523480156200001157600080fd5b506040516200298e3803806200298e8339810160408190526200003491620006d6565b604080518082018252600b81526a0a8dee4dcc2c8de86c2e6d60ab1b6020808301918252835180850190945260048452632a27a92760e11b90840152815186938693869390926200008891600391620005e4565b5080516200009e906004906020840190620005e4565b50506005805460ff1916601217905550620000b8620001f8565b506008805460ff199081169091556001600160601b0319606085901b1660a0526001600160a01b0384166000908152600960205260408120805490921660011790915583905b82518110156200017b5760008382815181106200011757fe5b60200260200101516000015190506200014f818584815181106200013757fe5b602002602001015160200151620002b460201b60201c565b6001600160a01b03166000908152600960205260409020805460ff1916600190811790915501620000fe565b506200019f836200018b62000397565b620003b360201b62000d721790919060201c565b608052620001ac620003e4565b620001b66200045b565b6a084595161401484a00000014620001eb5760405162461bcd60e51b8152600401620001e290620008a8565b60405180910390fd5b5050505050505062000946565b6000806200020562000461565b905060007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6200023462000467565b805160209182012060408051808201825260018152603160f81b90840152516200028693927fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6918791309101620007be565b60408051601f1981840301815291815281516020928301206000948552600790925290922082905550905090565b6001600160a01b038216620002dd5760405162461bcd60e51b8152600401620001e290620008df565b620002eb6000838362000501565b6200030781600254620003b360201b62000d721790919060201c565b6002556001600160a01b038216600090815260208181526040909120546200033a91839062000d72620003b3821b17901c565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906200038b90859062000916565b60405180910390a35050565b6000620003ae620005bc60201b62000d9e1760201c565b905090565b600082820183811015620003db5760405162461bcd60e51b8152600401620001e290620007ea565b90505b92915050565b60085460ff16156200040a5760405162461bcd60e51b8152600401620001e2906200087e565b6008805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25862000442620005d7565b604051620004519190620007aa565b60405180910390a1565b60025490565b600b5490565b60038054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015620004f75780601f10620004cb57610100808354040283529160200191620004f7565b820191906000526020600020905b815481529060010190602001808311620004d957829003601f168201915b5050505050905090565b62000519838383620005b760201b620007421760201c565b62000523620005db565b15806200054857506001600160a01b03831660009081526009602052604090205460ff165b806200056c57506001600160a01b03821660009081526009602052604090205460ff165b6200058b5760405162461bcd60e51b8152600401620001e29062000858565b6001600160a01b038216301415620005b75760405162461bcd60e51b8152600401620001e29062000821565b505050565b6000600a54600014620005d257600a54620003ae565b504290565b3390565b60085460ff1690565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200062757805160ff191683800117855562000657565b8280016001018555821562000657579182015b82811115620006575782518255916020019190600101906200063a565b506200066592915062000669565b5090565b5b808211156200066557600081556001016200066a565b80516001600160a01b0381168114620003de57600080fd5b600060408284031215620006aa578081fd5b620006b660406200091f565b9050620006c4838362000680565b81526020820151602082015292915050565b600080600060608486031215620006eb578283fd5b620006f7858562000680565b9250602080850151925060408086015160018060401b03808211156200071b578485fd5b818801915088601f8301126200072f578485fd5b8151818111156200073e578586fd5b6200074d85868302016200091f565b8181528581019250838601858302850187018c10156200076b578788fd5b8794505b828510156200079957620007848c8262000698565b8452600194909401939286019285016200076f565b508096505050505050509250925092565b6001600160a01b0391909116815260200190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526017908201527f544f524e3a20696e76616c696420726563697069656e74000000000000000000604082015260600190565b6020808252600c908201526b1513d4938e881c185d5cd95960a21b604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252601c908201527f544f524e3a20696e636f727265637420646973747269627574696f6e00000000604082015260600190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b90815260200190565b6040518181016001600160401b03811182821017156200093e57600080fd5b604052919050565b60805160a05160601c612008620009866000398061056f52806106975280610764528061081d5280610a215250806107bc5280610d2052506120086000f3fe608060405234801561001057600080fd5b50600436106101cf5760003560e01c80637ecebe0011610104578063adb61832116100a2578063d505accf11610071578063d505accf1461038d578063dc0f0d12146103a0578063dd62ed3e146103a8578063ef0e2ff4146103bb576101cf565b8063adb6183214610357578063adc879e91461035f578063c565882714610367578063cea9d26f1461037a576101cf565b806395d89b41116100de57806395d89b41146103215780639a8a059214610329578063a457c2d714610331578063a9059cbb14610344576101cf565b80637ecebe00146102e857806381893c7c146102fb578063885ad0cf1461030e576101cf565b80633c8d76d1116101715780635c975abb1161014b5780635c975abb146102a75780635d4545a0146102af57806370a08231146102c257806379cc6790146102d5576101cf565b80633c8d76d11461026a57806342966c681461027f5780635aa6e67514610292576101cf565b806318160ddd116101ad57806318160ddd1461022757806323b872dd1461022f578063313ce567146102425780633950935114610257576101cf565b806301ec0fab146101d457806306fdde03146101f2578063095ea7b314610207575b600080fd5b6101dc6103ce565b6040516101e99190611e68565b60405180910390f35b6101fa6103d4565b6040516101e99190611943565b61021a610215366004611708565b61046b565b6040516101e991906118ba565b6101dc610489565b61021a61023d366004611653565b61048f565b61024a610516565b6040516101e99190611e71565b61021a610265366004611708565b61051f565b61027d610278366004611733565b61056d565b005b61027d61028d36600461181c565b610681565b61029a610695565b6040516101e9919061188d565b61021a6106b9565b61021a6102bd3660046115ff565b6106c2565b6101dc6102d03660046115ff565b6106d7565b61027d6102e3366004611708565b6106f2565b6101dc6102f63660046115ff565b610747565b61027d6103093660046117d0565b610762565b61027d61031c366004611733565b61081b565b6101fa610922565b6101dc610983565b61021a61033f366004611708565b610989565b61021a610352366004611708565b6109f1565b6101dc610a05565b6101dc610a14565b61027d61037536600461181c565b610a1a565b61027d610388366004611808565b610a1f565b61027d61039b366004611693565b610bdd565b6101dc610d1e565b6101dc6103b636600461161b565b610d42565b61027d6103c936600461181c565b610d6d565b600a5481565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104605780601f1061043557610100808354040283529160200191610460565b820191906000526020600020905b81548152906001019060200180831161044357829003601f168201915b505050505090505b90565b600061047f610478610db7565b8484610dbb565b5060015b92915050565b60025490565b600061049c848484610e6f565b61050c846104a8610db7565b61050785604051806060016040528060288152602001611f62602891396001600160a01b038a166000908152600160205260408120906104e6610db7565b6001600160a01b031681526020810191909152604001600020549190610f84565b610dbb565b5060019392505050565b60055460ff1690565b600061047f61052c610db7565b84610507856001600061053d610db7565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610d72565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661059f610db7565b6001600160a01b0316146105ce5760405162461bcd60e51b81526004016105c590611de4565b60405180910390fd5b60005b815181101561067d576000600960008484815181106105ec57fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055507f9ef90a89b00db1a1891a357dc96b2a273add9d883e378c350d22bad87a9d7d3082828151811061065857fe5b602002602001015160405161066d919061188d565b60405180910390a16001016105d1565b5050565b61069261068c610db7565b82610fb0565b50565b7f000000000000000000000000000000000000000000000000000000000000000081565b60085460ff1690565b60096020526000908152604090205460ff1681565b6001600160a01b031660009081526020819052604090205490565b600061072482604051806060016040528060248152602001611f8a6024913961071d866103b6610db7565b9190610f84565b905061073883610732610db7565b83610dbb565b6107428383610fb0565b505050565b6001600160a01b031660009081526006602052604090205490565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610794610db7565b6001600160a01b0316146107ba5760405162461bcd60e51b81526004016105c590611de4565b7f00000000000000000000000000000000000000000000000000000000000000006107e3610a05565b116108005760405162461bcd60e51b81526004016105c590611bd9565b80156108135761080e611092565b610692565b6106926110fe565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661084d610db7565b6001600160a01b0316146108735760405162461bcd60e51b81526004016105c590611de4565b60005b815181101561067d5760016009600084848151811061089157fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055507f77a7dbc6ad97703ad411a8d5edfcd1df382fb34b076a90898b11884f7ebdcc058282815181106108fd57fe5b6020026020010151604051610912919061188d565b60405180910390a1600101610876565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156104605780601f1061043557610100808354040283529160200191610460565b600b5481565b600061047f610996610db7565b8461050785604051806060016040528060258152602001611fae60259139600160006109c0610db7565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190610f84565b600061047f6109fe610db7565b8484610e6f565b6000610a0f610d9e565b905090565b600b5490565b600a55565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610a51610db7565b6001600160a01b031614610a775760405162461bcd60e51b81526004016105c590611de4565b6001600160a01b038216610a9d5760405162461bcd60e51b81526004016105c590611d58565b6001600160a01b038316610b06574760008215610ac357610abe8284611157565b610ac5565b815b6040519091506001600160a01b0385169082156108fc029083906000818181858888f19350505050158015610afe573d6000803e3d6000fd5b505050610742565b6040516370a0823160e01b81526000906001600160a01b038516906370a0823190610b3590309060040161188d565b60206040518083038186803b158015610b4d57600080fd5b505afa158015610b61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b859190611834565b905060008215610b9e57610b998284611157565b610ba0565b815b905060008111610bc25760405162461bcd60e51b81526004016105c590611e31565b610bd66001600160a01b038616858361116d565b5050505050565b83610be6610a05565b1115610c045760405162461bcd60e51b81526004016105c590611ace565b6001600160a01b0387166000908152600660209081526040808320549051610c57927f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9928c928c928c92918c91016118c5565b6040516020818303038152906040528051906020012090506000611901610c7c6111c3565b83604051602001610c8f93929190611868565b6040516020818303038152906040528051906020012090506000610cb582878787611202565b9050896001600160a01b0316816001600160a01b031614610ce85760405162461bcd60e51b81526004016105c590611c20565b6001600160a01b038a16600090815260066020526040902080546001019055610d128a8a8a610dbb565b50505050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600b55565b600082820183811015610d975760405162461bcd60e51b81526004016105c590611a60565b9392505050565b6000600a54600014610db257600a54610a0f565b504290565b3390565b6001600160a01b038316610de15760405162461bcd60e51b81526004016105c590611cdd565b6001600160a01b038216610e075760405162461bcd60e51b81526004016105c590611a1e565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610e62908590611e68565b60405180910390a3505050565b6001600160a01b038316610e955760405162461bcd60e51b81526004016105c590611c98565b6001600160a01b038216610ebb5760405162461bcd60e51b81526004016105c5906119ad565b610ec68383836112fa565b610f0381604051806060016040528060268152602001611f3c602691396001600160a01b0386166000908152602081905260409020549190610f84565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610f329082610d72565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610e62908590611e68565b60008184841115610fa85760405162461bcd60e51b81526004016105c59190611943565b505050900390565b6001600160a01b038216610fd65760405162461bcd60e51b81526004016105c590611c57565b610fe2826000836112fa565b61101f81604051806060016040528060228152602001611f1a602291396001600160a01b0385166000908152602081905260409020549190610f84565b6001600160a01b0383166000908152602081905260409020556002546110459082611399565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611086908590611e68565b60405180910390a35050565b60085460ff166110b45760405162461bcd60e51b81526004016105c5906119f0565b6008805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6110e7610db7565b6040516110f4919061188d565b60405180910390a1565b60085460ff16156111215760405162461bcd60e51b81526004016105c590611b6d565b6008805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586110e7610db7565b60008183106111665781610d97565b5090919050565b6107428363a9059cbb60e01b848460405160240161118c9291906118a1565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526113db565b600080600760006111d2610a14565b8152602081019190915260400160002054905080156111f2579050610468565b6111fa61146a565b915050610468565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08211156112445760405162461bcd60e51b81526004016105c590611b2b565b8360ff16601b148061125957508360ff16601c145b6112755760405162461bcd60e51b81526004016105c590611b97565b60006001868686866040516000815260200160405260405161129a9493929190611925565b6020604051602081039080840390855afa1580156112bc573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166112ef5760405162461bcd60e51b81526004016105c590611976565b90505b949350505050565b611305838383610742565b61130d6106b9565b158061133157506001600160a01b03831660009081526009602052604090205460ff165b8061135457506001600160a01b03821660009081526009602052604090205460ff165b6113705760405162461bcd60e51b81526004016105c590611b05565b6001600160a01b0382163014156107425760405162461bcd60e51b81526004016105c590611a97565b6000610d9783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610f84565b6060611430826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166115209092919063ffffffff16565b805190915015610742578080602001905181019061144e91906117ec565b6107425760405162461bcd60e51b81526004016105c590611d9a565b600080611475610a14565b905060007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6114a26103d4565b805160209182012060408051808201825260018152603160f81b90840152516114f293927fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc69187913091016118f9565b60408051601f1981840301815291815281516020928301206000948552600790925290922082905550905090565b60606112f284846000856060611535856115ee565b6115515760405162461bcd60e51b81526004016105c590611d21565b60006060866001600160a01b0316858760405161156e919061184c565b60006040518083038185875af1925050503d80600081146115ab576040519150601f19603f3d011682016040523d82523d6000602084013e6115b0565b606091505b509150915081156115c45791506112f29050565b8051156115d45780518082602001fd5b8360405162461bcd60e51b81526004016105c59190611943565b3b151590565b803561048381611ef6565b600060208284031215611610578081fd5b8135610d9781611ef6565b6000806040838503121561162d578081fd5b823561163881611ef6565b9150602083013561164881611ef6565b809150509250929050565b600080600060608486031215611667578081fd5b833561167281611ef6565b9250602084013561168281611ef6565b929592945050506040919091013590565b600080600080600080600060e0888a0312156116ad578283fd5b87356116b881611ef6565b965060208801356116c881611ef6565b95506040880135945060608801359350608088013560ff811681146116eb578384fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561171a578182fd5b823561172581611ef6565b946020939093013593505050565b60006020808385031215611745578182fd5b823567ffffffffffffffff81111561175b578283fd5b8301601f8101851361176b578283fd5b803561177e61177982611ea6565b611e7f565b818152838101908385018584028501860189101561179a578687fd5b8694505b838510156117c4576117b089826115f4565b83526001949094019391850191850161179e565b50979650505050505050565b6000602082840312156117e1578081fd5b8135610d9781611f0b565b6000602082840312156117fd578081fd5b8151610d9781611f0b565b600080600060608486031215611667578283fd5b60006020828403121561182d578081fd5b5035919050565b600060208284031215611845578081fd5b5051919050565b6000825161185e818460208701611ec6565b9190910192915050565b60f09390931b6001600160f01b03191683526002830191909152602282015260420190565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b93845260ff9290921660208401526040830152606082015260800190565b6000602082528251806020840152611962816040850160208701611ec6565b601f01601f19169190910160400192915050565b60208082526018908201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604082015260600190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526017908201527f544f524e3a20696e76616c696420726563697069656e74000000000000000000604082015260600190565b6020808252601d908201527f45524332305065726d69743a206578706972656420646561646c696e65000000604082015260600190565b6020808252600c908201526b1513d4938e881c185d5cd95960a21b604082015260600190565b60208082526022908201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604082015261756560f01b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b60208082526022908201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604082015261756560f01b606082015260800190565b60208082526027908201527f544f524e3a2063616e6e6f74206368616e6765207472616e736665726162696c6040820152661a5d1e481e595d60ca1b606082015260800190565b6020808252601e908201527f45524332305065726d69743a20696e76616c6964207369676e61747572650000604082015260600190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b60208082526022908201527f544f524e3a2063616e206e6f742073656e6420746f207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252602d908201527f544f524e3a206f6e6c7920676f7665726e616e63652063616e20706572666f7260408201526c36903a3434b99030b1ba34b7b760991b606082015260800190565b6020808252601e908201527f544f524e3a20747279696e6720746f2073656e6420302062616c616e63650000604082015260600190565b90815260200190565b60ff91909116815260200190565b60405181810167ffffffffffffffff81118282101715611e9e57600080fd5b604052919050565b600067ffffffffffffffff821115611ebc578081fd5b5060209081020190565b60005b83811015611ee1578181015183820152602001611ec9565b83811115611ef0576000848401525b50505050565b6001600160a01b038116811461069257600080fd5b801515811461069257600080fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220c25cb2cef98080abbebec9b5719a4f46d638fbe559a3ab7a9de64272855c3c1064736f6c634300060c0033"; +const isSuperArgs$z = (xs) => xs.length > 1; +class TORNMock__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$z(args)) { + super(...args); + } else { + super(_abi$V, _bytecode$z, args[0]); + } + } + getDeployTransaction(_governance, _pausePeriod, _vesting, overrides) { + return super.getDeployTransaction( + _governance, + _pausePeriod, + _vesting, + overrides || {} + ); + } + deploy(_governance, _pausePeriod, _vesting, overrides) { + return super.deploy( + _governance, + _pausePeriod, + _vesting, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$V); + } + static connect(address, runner) { + return new Contract(address, _abi$V, runner); + } +} +TORNMock__factory.bytecode = _bytecode$z; +TORNMock__factory.abi = _abi$V; + +const _abi$U = [ + { + inputs: [], + name: "blockTimestamp", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "fakeTimestamp", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_fakeTimestamp", + type: "uint256" + } + ], + name: "setFakeTimestamp", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$y = "0x608060405234801561001057600080fd5b5060d28061001f6000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c806301ec0fab146041578063adb61832146059578063c565882714605f575b600080fd5b6047607b565b60408051918252519081900360200190f35b60476081565b607960048036036020811015607357600080fd5b50356097565b005b60005481565b60008054156090576000546092565b425b905090565b60005556fea2646970667358221220b2410460a5b24aec9983bcf8349aa3b589a0dff9120af5b704feae536a65813064736f6c634300060c0033"; +const isSuperArgs$y = (xs) => xs.length > 1; +class Timestamp__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$y(args)) { + super(...args); + } else { + super(_abi$U, _bytecode$y, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$U); + } + static connect(address, runner) { + return new Contract(address, _abi$U, runner); + } +} +Timestamp__factory.bytecode = _bytecode$y; +Timestamp__factory.abi = _abi$U; + +const _abi$T = [ + { + inputs: [ + { + internalType: "address", + name: "_token", + type: "address" + }, + { + internalType: "address", + name: "_beneficiary", + type: "address" + }, + { + internalType: "uint256", + name: "_startTimestamp", + type: "uint256" + }, + { + internalType: "uint256", + name: "_cliffInMonths", + type: "uint256" + }, + { + internalType: "uint256", + name: "_durationInMonths", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "Released", + type: "event" + }, + { + inputs: [], + name: "SECONDS_PER_MONTH", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "beneficiary", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "blockTimestamp", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "cliffInMonths", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "durationInMonths", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "fakeTimestamp", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "release", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "released", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_fakeTimestamp", + type: "uint256" + } + ], + name: "setFakeTimestamp", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "startTimestamp", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "token", + outputs: [ + { + internalType: "contract IERC20", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "vestedAmount", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$x = "0x61012060405234801561001157600080fd5b50604051610d2e380380610d2e833981810160405260a081101561003457600080fd5b5080516020820151604083015160608401516080909401519293919290919084848484846001600160a01b0384166100b3576040805162461bcd60e51b815260206004820152601b60248201527f42656e65666963696172792063616e6e6f7420626520656d7074790000000000604482015290519081900360640190fd5b80821115610108576040805162461bcd60e51b815260206004820152601e60248201527f436c6966662069732067726561746572207468616e206475726174696f6e0000604482015290519081900360640190fd5b6001600160601b0319606086811b821660a05285901b1660805261010081905260c082905282156101395782610141565b610141610154565b60e0525061018698505050505050505050565b600061016861016d60201b6105b81760201c565b905090565b600060015460001461018157600154610168565b504290565b60805160601c60a05160601c60c05160e05161010051610b366101f86000398061024452806103bc528061041e52508061019352806101cf52806105725250806102115280610534525080610289528061030952806104b5528061059652508061016d52806104d75250610b366000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c8063928d89ae11610071578063928d89ae146101195780639613252114610121578063adb6183214610129578063c565882714610131578063e6fd48bc1461014e578063fc0c546a14610156576100b4565b806301ec0fab146100b957806310786deb146100d357806338af3eed146100db57806344b1231f146100ff57806367097a4b1461010757806386d1a69f1461010f575b600080fd5b6100c161015e565b60408051918252519081900360200190f35b6100c1610164565b6100e361016b565b604080516001600160a01b039092168252519081900360200190f35b6100c161018f565b6100c161041c565b610117610440565b005b6100c1610532565b6100c1610556565b6100c161055c565b6101176004803603602081101561014757600080fd5b503561056b565b6100c1610570565b6100e3610594565b60015481565b62278d0081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60007f00000000000000000000000000000000000000000000000000000000000000006101ba61055c565b10156101c857506000610419565b60006101fc7f00000000000000000000000000000000000000000000000000000000000000006101f661055c565b906105d1565b9050600061020d8262278d0061061c565b90507f000000000000000000000000000000000000000000000000000000000000000081101561024257600092505050610419565b7f0000000000000000000000000000000000000000000000000000000000000000811061030557604080516370a0823160e01b815230600482015290516001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916370a08231916024808301926020929190829003018186803b1580156102cf57600080fd5b505afa1580156102e3573d6000803e3d6000fd5b505050506040513d60208110156102f957600080fd5b50519250610419915050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561037457600080fd5b505afa158015610388573d6000803e3d6000fd5b505050506040513d602081101561039e57600080fd5b505160008054919250906103b390839061065e565b905060006103eb7f00000000000000000000000000000000000000000000000000000000000000006103e584876106b8565b9061061c565b90506000610404600054836105d190919063ffffffff16565b90506104108482610711565b96505050505050505b90565b7f000000000000000000000000000000000000000000000000000000000000000081565b600061044a61018f565b905060008111610498576040805162461bcd60e51b81526020600482015260146024820152734e6f20746f6b656e7320746f2072656c6561736560601b604482015290519081900360640190fd5b6000546104a5908261065e565b6000556104fc6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f000000000000000000000000000000000000000000000000000000000000000083610727565b6040805182815290517ffb81f9b30d73d830c3544b34d827c08142579ee75710b490bab0b3995468c5659181900360200190a150565b7f000000000000000000000000000000000000000000000000000000000000000081565b60005481565b60006105666105b8565b905090565b600155565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006001546000146105cc57600154610566565b504290565b600061061383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061077e565b90505b92915050565b600061061383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610815565b600082820183811015610613576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000826106c757506000610616565b828202828482816106d457fe5b04146106135760405162461bcd60e51b8152600401808060200182810382526021815260200180610ab66021913960400191505060405180910390fd5b60008183106107205781610613565b5090919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261077990849061087a565b505050565b6000818484111561080d5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156107d25781810151838201526020016107ba565b50505050905090810190601f1680156107ff5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600081836108645760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156107d25781810151838201526020016107ba565b50600083858161087057fe5b0495945050505050565b60606108cf826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661092b9092919063ffffffff16565b805190915015610779578080602001905160208110156108ee57600080fd5b50516107795760405162461bcd60e51b815260040180806020018281038252602a815260200180610ad7602a913960400191505060405180910390fd5b606061093a8484600085610942565b949350505050565b606061094d85610aaf565b61099e576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106109dd5780518252601f1990920191602091820191016109be565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114610a3f576040519150601f19603f3d011682016040523d82523d6000602084013e610a44565b606091505b50915091508115610a5857915061093a9050565b805115610a685780518082602001fd5b60405162461bcd60e51b81526020600482018181528651602484015286518793919283926044019190850190808383600083156107d25781810151838201526020016107ba565b3b15159056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a2646970667358221220852e02606e74d747094138d7e10fc9f005278a953559d85ca961b67f95c9fa8f64736f6c634300060c0033"; +const isSuperArgs$x = (xs) => xs.length > 1; +class VestingMock__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$x(args)) { + super(...args); + } else { + super(_abi$T, _bytecode$x, args[0]); + } + } + getDeployTransaction(_token, _beneficiary, _startTimestamp, _cliffInMonths, _durationInMonths, overrides) { + return super.getDeployTransaction( + _token, + _beneficiary, + _startTimestamp, + _cliffInMonths, + _durationInMonths, + overrides || {} + ); + } + deploy(_token, _beneficiary, _startTimestamp, _cliffInMonths, _durationInMonths, overrides) { + return super.deploy( + _token, + _beneficiary, + _startTimestamp, + _cliffInMonths, + _durationInMonths, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$T); + } + static connect(address, runner) { + return new Contract(address, _abi$T, runner); + } +} +VestingMock__factory.bytecode = _bytecode$x; +VestingMock__factory.abi = _abi$T; + +const _abi$S = [ + { + inputs: [ + { + internalType: "bytes32", + name: "_torn", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "_governance", + type: "bytes32" + }, + { + internalType: "uint256", + name: "_duration", + type: "uint256" + }, + { + components: [ + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + internalType: "struct Voucher.Recipient[]", + name: "_airdrops", + type: "tuple[]" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "allowedTransferee", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "blockTimestamp", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32[]", + name: "domains", + type: "bytes32[]" + } + ], + name: "bulkResolve", + outputs: [ + { + internalType: "address[]", + name: "result", + type: "address[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "subtractedValue", + type: "uint256" + } + ], + name: "decreaseAllowance", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "expiresAt", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "fakeTimestamp", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "governance", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "addedValue", + type: "uint256" + } + ], + name: "increaseAllowance", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "redeem", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "rescueExpiredTokens", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "addr", + type: "bytes32" + } + ], + name: "resolve", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_fakeTimestamp", + type: "uint256" + } + ], + name: "setFakeTimestamp", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "torn", + outputs: [ + { + internalType: "contract IERC20", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + }, + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$w = "0x60e06040523480156200001157600080fd5b5060405162001b7838038062001b78833981016040819052620000349162000476565b8383838360405180606001604052806026815260200162001b5260269139604051806040016040528060058152602001643b2a27a92760d91b8152508160039080519060200190620000889291906200038d565b5080516200009e9060049060208401906200038d565b50506005805460ff1916601217905550620000b984620001b7565b60601b6001600160601b031916608052620000d483620001b7565b60601b6001600160601b03191660c0526200010782620000f3620001bd565b620001d960201b6200089d1790919060201c565b60a05260005b8151811015620001a857620001598282815181106200012857fe5b6020026020010151600001518383815181106200014157fe5b6020026020010151602001516200021160201b60201c565b6001600660008484815181106200016c57fe5b602090810291909101810151516001600160a01b03168252810191909152604001600020805460ff19169115159190911790556001016200010d565b5050505050505050506200061d565b60601c90565b6000620001d4620002f460201b620008c91760201c565b905090565b6000828201838110156200020a5760405162461bcd60e51b8152600401620002019062000548565b60405180910390fd5b9392505050565b6001600160a01b0382166200023a5760405162461bcd60e51b81526004016200020190620005b6565b62000248600083836200030f565b6200026481600254620001d960201b6200089d1790919060201c565b6002556001600160a01b03821660009081526020818152604090912054620002979183906200089d620001d9821b17901c565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90620002e8908590620005ed565b60405180910390a35050565b60006007546000146200030a57600754620001d4565b504290565b620003278383836200038860201b620008e21760201c565b6001600160a01b03821615806200034557506001600160a01b038316155b806200036957506001600160a01b03831660009081526006602052604090205460ff165b620003885760405162461bcd60e51b815260040162000201906200057f565b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620003d057805160ff191683800117855562000400565b8280016001018555821562000400579182015b8281111562000400578251825591602001919060010190620003e3565b506200040e92915062000412565b5090565b5b808211156200040e576000815560010162000413565b6000604082840312156200043b578081fd5b620004476040620005f6565b82519091506001600160a01b03811681146200046257600080fd5b808252506020820151602082015292915050565b600080600080608085870312156200048c578384fd5b8451935060208086015193506040808701519350606087015160018060401b0380821115620004b9578485fd5b818901915089601f830112620004cd578485fd5b815181811115620004dc578586fd5b620004eb8586830201620005f6565b8181528581019250838601858302850187018d101562000509578788fd5b8794505b828510156200053757620005228d8262000429565b8452600194909401939286019285016200050d565b50989b979a50959850505050505050565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601e908201527f45524332303a207472616e73666572206973206e6f7420616c6c6f7765640000604082015260600190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b90815260200190565b6040518181016001600160401b03811182821017156200061557600080fd5b604052919050565b60805160601c60a05160c05160601c6114e46200066e6000398061046952806106de5250806104c352806105f752806106945250806105d3528061066852806106ff52806107a352506114e46000f3fe608060405234801561001057600080fd5b50600436106101425760003560e01c80638622a689116100b8578063adf898a41161007c578063adf898a414610269578063be040fb014610271578063c39ef8551461027b578063c565882714610283578063dd62ed3e14610296578063f9e54234146102a957610142565b80638622a6891461022b57806395d89b4114610233578063a457c2d71461023b578063a9059cbb1461024e578063adb618321461026157610142565b8063313ce5671161010a578063313ce567146101b557806339509351146101ca5780635aa6e675146101dd5780635c23bdf5146101f25780635d4545a01461020557806370a082311461021857610142565b806301ec0fab1461014757806306fdde0314610165578063095ea7b31461017a57806318160ddd1461019a57806323b872dd146101a2575b600080fd5b61014f6102c9565b60405161015c9190611376565b60405180910390f35b61016d6102cf565b60405161015c9190611087565b61018d610188366004610ed7565b610365565b60405161015c919061107c565b61014f610383565b61018d6101b0366004610e97565b610389565b6101bd610410565b60405161015c919061137f565b61018d6101d8366004610ed7565b610419565b6101e5610467565b60405161015c9190611002565b6101e5610200366004610fb6565b61048b565b61018d610213366004610e48565b610491565b61014f610226366004610e48565b6104a6565b61014f6104c1565b61016d6104e5565b61018d610249366004610ed7565b610546565b61018d61025c366004610ed7565b6105ae565b61014f6105c2565b6101e56105d1565b6102796105f5565b005b610279610692565b610279610291366004610fb6565b6107cc565b61014f6102a4366004610e63565b6107d1565b6102bc6102b7366004610f01565b6107fc565b60405161015c919061102f565b60075481565b60038054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561035b5780601f106103305761010080835404028352916020019161035b565b820191906000526020600020905b81548152906001019060200180831161033e57829003601f168201915b5050505050905090565b60006103796103726108e7565b84846108eb565b5060015b92915050565b60025490565b600061039684848461099f565b610406846103a26108e7565b61040185604051806060016040528060288152602001611462602891396001600160a01b038a166000908152600160205260408120906103e06108e7565b6001600160a01b031681526020810191909152604001600020549190610ab4565b6108eb565b5060019392505050565b60055460ff1690565b60006103796104266108e7565b8461040185600160006104376108e7565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549061089d565b7f000000000000000000000000000000000000000000000000000000000000000081565b60601c90565b60066020526000908152604090205460ff1681565b6001600160a01b031660009081526020819052604090205490565b7f000000000000000000000000000000000000000000000000000000000000000081565b60048054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561035b5780601f106103305761010080835404028352916020019161035b565b60006103796105536108e7565b846104018560405180606001604052806025815260200161148a602591396001600061057d6108e7565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190610ab4565b60006103796105bb6108e7565b848461099f565b60006105cc6108c9565b905090565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000061061e6105c2565b106106445760405162461bcd60e51b815260040161063b90611176565b60405180910390fd5b600061064f336104a6565b905061065b3382610ae0565b61068f6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163383610bc2565b50565b7f00000000000000000000000000000000000000000000000000000000000000006106bb6105c2565b10156106d95760405162461bcd60e51b815260040161063b906111ad565b6107ca7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016107499190611002565b60206040518083038186803b15801561076157600080fd5b505afa158015610775573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107999190610fce565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169190610bc2565b565b600755565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6060815167ffffffffffffffff8111801561081657600080fd5b50604051908082528060200260200182016040528015610840578160200160208202803683370190505b50905060005b82518110156108975761086b83828151811061085e57fe5b602002602001015161048b565b82828151811061087757fe5b6001600160a01b0390921660209283029190910190910152600101610846565b50919050565b6000828201838110156108c25760405162461bcd60e51b815260040161063b9061113f565b9392505050565b60006007546000146108dd576007546105cc565b504290565b505050565b3390565b6001600160a01b0383166109115760405162461bcd60e51b815260040161063b906112b1565b6001600160a01b0382166109375760405162461bcd60e51b815260040161063b906110fd565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610992908590611376565b60405180910390a3505050565b6001600160a01b0383166109c55760405162461bcd60e51b815260040161063b9061126c565b6001600160a01b0382166109eb5760405162461bcd60e51b815260040161063b906110ba565b6109f6838383610c18565b610a338160405180606001604052806026815260200161143c602691396001600160a01b0386166000908152602081905260409020549190610ab4565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610a62908261089d565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610992908590611376565b60008184841115610ad85760405162461bcd60e51b815260040161063b9190611087565b505050900390565b6001600160a01b038216610b065760405162461bcd60e51b815260040161063b9061122b565b610b1282600083610c18565b610b4f8160405180606001604052806022815260200161141a602291396001600160a01b0385166000908152602081905260409020549190610ab4565b6001600160a01b038316600090815260208190526040902055600254610b759082610c7f565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610bb6908590611376565b60405180910390a35050565b6108e28363a9059cbb60e01b8484604051602401610be1929190611016565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610cc1565b610c238383836108e2565b6001600160a01b0382161580610c4057506001600160a01b038316155b80610c6357506001600160a01b03831660009081526006602052604090205460ff165b6108e25760405162461bcd60e51b815260040161063b906111f4565b60006108c283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610ab4565b6060610d16826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610d509092919063ffffffff16565b8051909150156108e25780806020019051810190610d349190610f96565b6108e25760405162461bcd60e51b815260040161063b9061132c565b6060610d5f8484600085610d67565b949350505050565b6060610d7285610e2b565b610d8e5760405162461bcd60e51b815260040161063b906112f5565b60006060866001600160a01b03168587604051610dab9190610fe6565b60006040518083038185875af1925050503d8060008114610de8576040519150601f19603f3d011682016040523d82523d6000602084013e610ded565b606091505b50915091508115610e01579150610d5f9050565b805115610e115780518082602001fd5b8360405162461bcd60e51b815260040161063b9190611087565b3b151590565b80356001600160a01b038116811461037d57600080fd5b600060208284031215610e59578081fd5b6108c28383610e31565b60008060408385031215610e75578081fd5b610e7f8484610e31565b9150610e8e8460208501610e31565b90509250929050565b600080600060608486031215610eab578081fd5b8335610eb681611404565b92506020840135610ec681611404565b929592945050506040919091013590565b60008060408385031215610ee9578182fd5b610ef38484610e31565b946020939093013593505050565b60006020808385031215610f13578182fd5b823567ffffffffffffffff811115610f29578283fd5b8301601f81018513610f39578283fd5b8035610f4c610f47826113b4565b61138d565b8181528381019083850185840285018601891015610f68578687fd5b8694505b83851015610f8a578035835260019490940193918501918501610f6c565b50979650505050505050565b600060208284031215610fa7578081fd5b815180151581146108c2578182fd5b600060208284031215610fc7578081fd5b5035919050565b600060208284031215610fdf578081fd5b5051919050565b60008251610ff88184602087016113d4565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b818110156110705783516001600160a01b03168352928401929184019160010161104b565b50909695505050505050565b901515815260200190565b60006020825282518060208401526110a68160408501602087016113d4565b601f01601f19169190910160400192915050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601f908201527f41697264726f702072656465656d20706572696f642068617320656e64656400604082015260600190565b60208082526027908201527f41697264726f702072656465656d20706572696f6420686173206e6f7420656e604082015266191959081e595d60ca1b606082015260800190565b6020808252601e908201527f45524332303a207472616e73666572206973206e6f7420616c6c6f7765640000604082015260600190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b90815260200190565b60ff91909116815260200190565b60405181810167ffffffffffffffff811182821017156113ac57600080fd5b604052919050565b600067ffffffffffffffff8211156113ca578081fd5b5060209081020190565b60005b838110156113ef5781810151838201526020016113d7565b838111156113fe576000848401525b50505050565b6001600160a01b038116811461068f57600080fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220794126baf4ea3c44b9afb84b4d8a20535aca899e75471e5d9bb4c8e671aabde664736f6c634300060c0033546f726e61646f4361736820766f756368657220666f72206561726c792061646f7074657273"; +const isSuperArgs$w = (xs) => xs.length > 1; +class VoucherMock__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$w(args)) { + super(...args); + } else { + super(_abi$S, _bytecode$w, args[0]); + } + } + getDeployTransaction(_torn, _governance, _duration, _airdrops, overrides) { + return super.getDeployTransaction( + _torn, + _governance, + _duration, + _airdrops, + overrides || {} + ); + } + deploy(_torn, _governance, _duration, _airdrops, overrides) { + return super.deploy( + _torn, + _governance, + _duration, + _airdrops, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$S); + } + static connect(address, runner) { + return new Contract(address, _abi$S, runner); + } +} +VoucherMock__factory.bytecode = _bytecode$w; +VoucherMock__factory.abi = _abi$S; + +const _abi$R = [ + { + inputs: [ + { + internalType: "bytes32", + name: "tokenAddress", + type: "bytes32" + }, + { + components: [ + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + internalType: "struct Airdrop.Recipient[]", + name: "targets", + type: "tuple[]" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [ + { + internalType: "bytes32[]", + name: "domains", + type: "bytes32[]" + } + ], + name: "bulkResolve", + outputs: [ + { + internalType: "address[]", + name: "result", + type: "address[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "resolve", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$v = "0x60806040523480156200001157600080fd5b506040516200054038038062000540833981016040819052620000349162000396565b60006200004183620001c2565b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040162000073919062000467565b60206040518083038186803b1580156200008c57600080fd5b505afa158015620000a1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000c791906200044e565b11620000f05760405162461bcd60e51b8152600401620000e7906200049d565b60405180910390fd5b60005b8251811015620001bd57816001600160a01b031663a9059cbb8483815181106200011957fe5b6020026020010151600001518584815181106200013257fe5b6020026020010151602001516040518363ffffffff1660e01b81526004016200015d9291906200047b565b602060405180830381600087803b1580156200017857600080fd5b505af11580156200018d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001b3919062000374565b50600101620000f3565b506000ff5b600080620001cf62000310565b600114620001f257738595bfb0d940dfedc98943fa8a907091203f25ee62000203565b6e0c2e074ec69a0dfb2997ba6c7d2e1e5b604051630178b8bf60e01b81529091506001600160a01b03821690630178b8bf906200023490869060040162000494565b60206040518083038186803b1580156200024d57600080fd5b505afa15801562000262573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000288919062000355565b6001600160a01b0316633b3b57de846040518263ffffffff1660e01b8152600401620002b5919062000494565b60206040518083038186803b158015620002ce57600080fd5b505afa158015620002e3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000309919062000355565b9392505050565b4690565b60006040828403121562000326578081fd5b620003326040620004df565b90508151620003418162000526565b808252506020820151602082015292915050565b60006020828403121562000367578081fd5b8151620003098162000526565b60006020828403121562000386578081fd5b8151801515811462000309578182fd5b6000806040808486031215620003aa578182fd5b8351602080860151919450906001600160401b03811115620003ca578384fd5b8501601f81018713620003db578384fd5b8051620003f2620003ec8262000506565b620004df565b81815283810190838501868402850186018b10156200040f578788fd5b8794505b838510156200043d57620004288b8262000314565b83526001949094019391850191860162000413565b508096505050505050509250929050565b60006020828403121562000460578081fd5b5051919050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b90815260200190565b60208082526022908201527f42616c616e636520697320302c2061697264726f7020616c726561647920646f6040820152616e6560f01b606082015260800190565b6040518181016001600160401b0381118282101715620004fe57600080fd5b604052919050565b60006001600160401b038211156200051c578081fd5b5060209081020190565b6001600160a01b03811681146200053c57600080fd5b5056fe"; +const isSuperArgs$v = (xs) => xs.length > 1; +class Airdrop__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$v(args)) { + super(...args); + } else { + super(_abi$R, _bytecode$v, args[0]); + } + } + getDeployTransaction(tokenAddress, targets, overrides) { + return super.getDeployTransaction(tokenAddress, targets, overrides || {}); + } + deploy(tokenAddress, targets, overrides) { + return super.deploy(tokenAddress, targets, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$R); + } + static connect(address, runner) { + return new Contract(address, _abi$R, runner); + } +} +Airdrop__factory.bytecode = _bytecode$v; +Airdrop__factory.abi = _abi$R; + +const _abi$Q = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "blockTimestamp", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "chainID", + outputs: [ + { + internalType: "uint256", + name: "_chainID", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "subtractedValue", + type: "uint256" + } + ], + name: "decreaseAllowance", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "addedValue", + type: "uint256" + } + ], + name: "increaseAllowance", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + } + ], + name: "nonces", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "permit", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + }, + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +class ERC20Permit__factory { + static createInterface() { + return new Interface(_abi$Q); + } + static connect(address, runner) { + return new Contract(address, _abi$Q, runner); + } +} +ERC20Permit__factory.abi = _abi$Q; + +const _abi$P = [ + { + inputs: [ + { + internalType: "address", + name: "_governance", + type: "address" + }, + { + internalType: "uint256", + name: "_pausePeriod", + type: "uint256" + }, + { + components: [ + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + internalType: "struct TORN.Recipient[]", + name: "_vestings", + type: "tuple[]" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "target", + type: "address" + } + ], + name: "Allowed", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "target", + type: "address" + } + ], + name: "Disallowed", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "account", + type: "address" + } + ], + name: "Paused", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "account", + type: "address" + } + ], + name: "Unpaused", + type: "event" + }, + { + inputs: [ + { + internalType: "address[]", + name: "target", + type: "address[]" + } + ], + name: "addToAllowedList", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "allowedTransferee", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "blockTimestamp", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "burn", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "burnFrom", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "canUnpauseAfter", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "chainID", + outputs: [ + { + internalType: "uint256", + name: "_chainID", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bool", + name: "decision", + type: "bool" + } + ], + name: "changeTransferability", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "subtractedValue", + type: "uint256" + } + ], + name: "decreaseAllowance", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "governance", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "addedValue", + type: "uint256" + } + ], + name: "increaseAllowance", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + } + ], + name: "nonces", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "paused", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "permit", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address[]", + name: "target", + type: "address[]" + } + ], + name: "removeFromAllowedList", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "_token", + type: "address" + }, + { + internalType: "address payable", + name: "_to", + type: "address" + }, + { + internalType: "uint256", + name: "_balance", + type: "uint256" + } + ], + name: "rescueTokens", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + }, + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$u = "0x60c06040523480156200001157600080fd5b506040516200288338038062002883833981016040819052620000349162000699565b604080518082018252600b81526a0a8dee4dcc2c8de86c2e6d60ab1b6020808301918252835180850190945260048452632a27a92760e11b9084015281519192916200008391600391620005a7565b50805162000099906004906020840190620005a7565b50506005805460ff1916601217905550620000b3620001f0565b506008805460ff199081169091556001600160601b0319606085901b1660a0526001600160a01b0384166000908152600960205260408120805490921660011790915583905b8251811015620001765760008382815181106200011257fe5b60200260200101516000015190506200014a818584815181106200013257fe5b602002602001015160200151620002ac60201b60201c565b6001600160a01b03166000908152600960205260409020805460ff1916600190811790915501620000f9565b506200019a83620001866200038f565b6200039360201b62000cbd1790919060201c565b608052620001a7620003c4565b620001b16200043b565b6a084595161401484a00000014620001e65760405162461bcd60e51b8152600401620001dd906200086b565b60405180910390fd5b5050505062000909565b600080620001fd62000441565b905060007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6200022c62000445565b805160209182012060408051808201825260018152603160f81b90840152516200027e93927fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc691879130910162000781565b60408051601f1981840301815291815281516020928301206000948552600790925290922082905550905090565b6001600160a01b038216620002d55760405162461bcd60e51b8152600401620001dd90620008a2565b620002e360008383620004df565b620002ff816002546200039360201b62000cbd1790919060201c565b6002556001600160a01b038216600090815260208181526040909120546200033291839062000cbd62000393821b17901c565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9062000383908590620008d9565b60405180910390a35050565b4290565b600082820183811015620003bb5760405162461bcd60e51b8152600401620001dd90620007ad565b90505b92915050565b60085460ff1615620003ea5760405162461bcd60e51b8152600401620001dd9062000841565b6008805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258620004226200059a565b6040516200043191906200076d565b60405180910390a1565b60025490565b4690565b60038054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015620004d55780601f10620004a957610100808354040283529160200191620004d5565b820191906000526020600020905b815481529060010190602001808311620004b757829003601f168201915b5050505050905090565b620004f78383836200059560201b620006aa1760201c565b620005016200059e565b15806200052657506001600160a01b03831660009081526009602052604090205460ff165b806200054a57506001600160a01b03821660009081526009602052604090205460ff165b620005695760405162461bcd60e51b8152600401620001dd906200081b565b6001600160a01b038216301415620005955760405162461bcd60e51b8152600401620001dd90620007e4565b505050565b3390565b60085460ff1690565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620005ea57805160ff19168380011785556200061a565b828001600101855582156200061a579182015b828111156200061a578251825591602001919060010190620005fd565b50620006289291506200062c565b5090565b5b808211156200062857600081556001016200062d565b80516001600160a01b0381168114620003be57600080fd5b6000604082840312156200066d578081fd5b620006796040620008e2565b905062000687838362000643565b81526020820151602082015292915050565b600080600060608486031215620006ae578283fd5b620006ba858562000643565b9250602080850151925060408086015160018060401b0380821115620006de578485fd5b818801915088601f830112620006f2578485fd5b81518181111562000701578586fd5b620007108586830201620008e2565b8181528581019250838601858302850187018c10156200072e578788fd5b8794505b828510156200075c57620007478c826200065b565b84526001949094019392860192850162000732565b508096505050505050509250925092565b6001600160a01b0391909116815260200190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526017908201527f544f524e3a20696e76616c696420726563697069656e74000000000000000000604082015260600190565b6020808252600c908201526b1513d4938e881c185d5cd95960a21b604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252601c908201527f544f524e3a20696e636f727265637420646973747269627574696f6e00000000604082015260600190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b90815260200190565b6040518181016001600160401b03811182821017156200090157600080fd5b604052919050565b60805160a05160601c611f3a62000949600039806104d752806105ff52806106cc528061078552806109715250806107245280610c705250611f3a6000f3fe608060405234801561001057600080fd5b50600436106101735760003560e01c806379cc6790116100de578063a9059cbb11610097578063cea9d26f11610071578063cea9d26f146102fb578063d505accf1461030e578063dc0f0d1214610321578063dd62ed3e1461032957610173565b8063a9059cbb146102d8578063adb61832146102eb578063adc879e9146102f357610173565b806379cc6790146102715780637ecebe001461028457806381893c7c14610297578063885ad0cf146102aa57806395d89b41146102bd578063a457c2d7146102c557610173565b80633c8d76d1116101305780633c8d76d11461020657806342966c681461021b5780635aa6e6751461022e5780635c975abb146102435780635d4545a01461024b57806370a082311461025e57610173565b806306fdde0314610178578063095ea7b31461019657806318160ddd146101b657806323b872dd146101cb578063313ce567146101de57806339509351146101f3575b600080fd5b61018061033c565b60405161018d9190611875565b60405180910390f35b6101a96101a436600461163a565b6103d3565b60405161018d91906117ec565b6101be6103f1565b60405161018d9190611d9a565b6101a96101d9366004611585565b6103f7565b6101e661047e565b60405161018d9190611da3565b6101a961020136600461163a565b610487565b610219610214366004611665565b6104d5565b005b61021961022936600461174e565b6105e9565b6102366105fd565b60405161018d91906117bf565b6101a9610621565b6101a9610259366004611531565b61062a565b6101be61026c366004611531565b61063f565b61021961027f36600461163a565b61065a565b6101be610292366004611531565b6106af565b6102196102a5366004611702565b6106ca565b6102196102b8366004611665565b610783565b61018061088a565b6101a96102d336600461163a565b6108eb565b6101a96102e636600461163a565b610953565b6101be610967565b6101be61096b565b61021961030936600461173a565b61096f565b61021961031c3660046115c5565b610b2d565b6101be610c6e565b6101be61033736600461154d565b610c92565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156103c85780601f1061039d576101008083540402835291602001916103c8565b820191906000526020600020905b8154815290600101906020018083116103ab57829003601f168201915b505050505090505b90565b60006103e76103e0610ce9565b8484610ced565b5060015b92915050565b60025490565b6000610404848484610da1565b61047484610410610ce9565b61046f85604051806060016040528060288152602001611e94602891396001600160a01b038a1660009081526001602052604081209061044e610ce9565b6001600160a01b031681526020810191909152604001600020549190610eb6565b610ced565b5060019392505050565b60055460ff1690565b60006103e7610494610ce9565b8461046f85600160006104a5610ce9565b6001600160a01b03908116825260208083019390935260409182016000908120918c168152925290205490610cbd565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610507610ce9565b6001600160a01b0316146105365760405162461bcd60e51b815260040161052d90611d16565b60405180910390fd5b60005b81518110156105e55760006009600084848151811061055457fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055507f9ef90a89b00db1a1891a357dc96b2a273add9d883e378c350d22bad87a9d7d308282815181106105c057fe5b60200260200101516040516105d591906117bf565b60405180910390a1600101610539565b5050565b6105fa6105f4610ce9565b82610ee2565b50565b7f000000000000000000000000000000000000000000000000000000000000000081565b60085460ff1690565b60096020526000908152604090205460ff1681565b6001600160a01b031660009081526020819052604090205490565b600061068c82604051806060016040528060248152602001611ebc6024913961068586610337610ce9565b9190610eb6565b90506106a08361069a610ce9565b83610ced565b6106aa8383610ee2565b505050565b6001600160a01b031660009081526006602052604090205490565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166106fc610ce9565b6001600160a01b0316146107225760405162461bcd60e51b815260040161052d90611d16565b7f000000000000000000000000000000000000000000000000000000000000000061074b610967565b116107685760405162461bcd60e51b815260040161052d90611b0b565b801561077b57610776610fc4565b6105fa565b6105fa611030565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166107b5610ce9565b6001600160a01b0316146107db5760405162461bcd60e51b815260040161052d90611d16565b60005b81518110156105e5576001600960008484815181106107f957fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055507f77a7dbc6ad97703ad411a8d5edfcd1df382fb34b076a90898b11884f7ebdcc0582828151811061086557fe5b602002602001015160405161087a91906117bf565b60405180910390a16001016107de565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156103c85780601f1061039d576101008083540402835291602001916103c8565b60006103e76108f8610ce9565b8461046f85604051806060016040528060258152602001611ee06025913960016000610922610ce9565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190610eb6565b60006103e7610960610ce9565b8484610da1565b4290565b4690565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166109a1610ce9565b6001600160a01b0316146109c75760405162461bcd60e51b815260040161052d90611d16565b6001600160a01b0382166109ed5760405162461bcd60e51b815260040161052d90611c8a565b6001600160a01b038316610a56574760008215610a1357610a0e8284611089565b610a15565b815b6040519091506001600160a01b0385169082156108fc029083906000818181858888f19350505050158015610a4e573d6000803e3d6000fd5b5050506106aa565b6040516370a0823160e01b81526000906001600160a01b038516906370a0823190610a859030906004016117bf565b60206040518083038186803b158015610a9d57600080fd5b505afa158015610ab1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ad59190611766565b905060008215610aee57610ae98284611089565b610af0565b815b905060008111610b125760405162461bcd60e51b815260040161052d90611d63565b610b266001600160a01b038616858361109f565b5050505050565b83610b36610967565b1115610b545760405162461bcd60e51b815260040161052d90611a00565b6001600160a01b0387166000908152600660209081526040808320549051610ba7927f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9928c928c928c92918c91016117f7565b6040516020818303038152906040528051906020012090506000611901610bcc6110f5565b83604051602001610bdf9392919061179a565b6040516020818303038152906040528051906020012090506000610c0582878787611134565b9050896001600160a01b0316816001600160a01b031614610c385760405162461bcd60e51b815260040161052d90611b52565b6001600160a01b038a16600090815260066020526040902080546001019055610c628a8a8a610ced565b50505050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b600082820183811015610ce25760405162461bcd60e51b815260040161052d90611992565b9392505050565b3390565b6001600160a01b038316610d135760405162461bcd60e51b815260040161052d90611c0f565b6001600160a01b038216610d395760405162461bcd60e51b815260040161052d90611950565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610d94908590611d9a565b60405180910390a3505050565b6001600160a01b038316610dc75760405162461bcd60e51b815260040161052d90611bca565b6001600160a01b038216610ded5760405162461bcd60e51b815260040161052d906118df565b610df883838361122c565b610e3581604051806060016040528060268152602001611e6e602691396001600160a01b0386166000908152602081905260409020549190610eb6565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610e649082610cbd565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610d94908590611d9a565b60008184841115610eda5760405162461bcd60e51b815260040161052d9190611875565b505050900390565b6001600160a01b038216610f085760405162461bcd60e51b815260040161052d90611b89565b610f148260008361122c565b610f5181604051806060016040528060228152602001611e4c602291396001600160a01b0385166000908152602081905260409020549190610eb6565b6001600160a01b038316600090815260208190526040902055600254610f7790826112cb565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610fb8908590611d9a565b60405180910390a35050565b60085460ff16610fe65760405162461bcd60e51b815260040161052d90611922565b6008805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa611019610ce9565b60405161102691906117bf565b60405180910390a1565b60085460ff16156110535760405162461bcd60e51b815260040161052d90611a9f565b6008805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611019610ce9565b60008183106110985781610ce2565b5090919050565b6106aa8363a9059cbb60e01b84846040516024016110be9291906117d3565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261130d565b6000806007600061110461096b565b8152602081019190915260400160002054905080156111245790506103d0565b61112c61139c565b9150506103d0565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08211156111765760405162461bcd60e51b815260040161052d90611a5d565b8360ff16601b148061118b57508360ff16601c145b6111a75760405162461bcd60e51b815260040161052d90611ac9565b6000600186868686604051600081526020016040526040516111cc9493929190611857565b6020604051602081039080840390855afa1580156111ee573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166112215760405162461bcd60e51b815260040161052d906118a8565b90505b949350505050565b6112378383836106aa565b61123f610621565b158061126357506001600160a01b03831660009081526009602052604090205460ff165b8061128657506001600160a01b03821660009081526009602052604090205460ff165b6112a25760405162461bcd60e51b815260040161052d90611a37565b6001600160a01b0382163014156106aa5760405162461bcd60e51b815260040161052d906119c9565b6000610ce283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610eb6565b6060611362826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166114529092919063ffffffff16565b8051909150156106aa5780806020019051810190611380919061171e565b6106aa5760405162461bcd60e51b815260040161052d90611ccc565b6000806113a761096b565b905060007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6113d461033c565b805160209182012060408051808201825260018152603160f81b908401525161142493927fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc691879130910161182b565b60408051601f1981840301815291815281516020928301206000948552600790925290922082905550905090565b60606112248484600085606061146785611520565b6114835760405162461bcd60e51b815260040161052d90611c53565b60006060866001600160a01b031685876040516114a0919061177e565b60006040518083038185875af1925050503d80600081146114dd576040519150601f19603f3d011682016040523d82523d6000602084013e6114e2565b606091505b509150915081156114f65791506112249050565b8051156115065780518082602001fd5b8360405162461bcd60e51b815260040161052d9190611875565b3b151590565b80356103eb81611e28565b600060208284031215611542578081fd5b8135610ce281611e28565b6000806040838503121561155f578081fd5b823561156a81611e28565b9150602083013561157a81611e28565b809150509250929050565b600080600060608486031215611599578081fd5b83356115a481611e28565b925060208401356115b481611e28565b929592945050506040919091013590565b600080600080600080600060e0888a0312156115df578283fd5b87356115ea81611e28565b965060208801356115fa81611e28565b95506040880135945060608801359350608088013560ff8116811461161d578384fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561164c578182fd5b823561165781611e28565b946020939093013593505050565b60006020808385031215611677578182fd5b823567ffffffffffffffff81111561168d578283fd5b8301601f8101851361169d578283fd5b80356116b06116ab82611dd8565b611db1565b81815283810190838501858402850186018910156116cc578687fd5b8694505b838510156116f6576116e28982611526565b8352600194909401939185019185016116d0565b50979650505050505050565b600060208284031215611713578081fd5b8135610ce281611e3d565b60006020828403121561172f578081fd5b8151610ce281611e3d565b600080600060608486031215611599578283fd5b60006020828403121561175f578081fd5b5035919050565b600060208284031215611777578081fd5b5051919050565b60008251611790818460208701611df8565b9190910192915050565b60f09390931b6001600160f01b03191683526002830191909152602282015260420190565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b901515815260200190565b9586526001600160a01b0394851660208701529290931660408501526060840152608083019190915260a082015260c00190565b9485526020850193909352604084019190915260608301526001600160a01b0316608082015260a00190565b93845260ff9290921660208401526040830152606082015260800190565b6000602082528251806020840152611894816040850160208701611df8565b601f01601f19169190910160400192915050565b60208082526018908201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604082015260600190565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526014908201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604082015260600190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526017908201527f544f524e3a20696e76616c696420726563697069656e74000000000000000000604082015260600190565b6020808252601d908201527f45524332305065726d69743a206578706972656420646561646c696e65000000604082015260600190565b6020808252600c908201526b1513d4938e881c185d5cd95960a21b604082015260600190565b60208082526022908201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604082015261756560f01b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b60208082526022908201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604082015261756560f01b606082015260800190565b60208082526027908201527f544f524e3a2063616e6e6f74206368616e6765207472616e736665726162696c6040820152661a5d1e481e595d60ca1b606082015260800190565b6020808252601e908201527f45524332305065726d69743a20696e76616c6964207369676e61747572650000604082015260600190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b60208082526022908201527f544f524e3a2063616e206e6f742073656e6420746f207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252602d908201527f544f524e3a206f6e6c7920676f7665726e616e63652063616e20706572666f7260408201526c36903a3434b99030b1ba34b7b760991b606082015260800190565b6020808252601e908201527f544f524e3a20747279696e6720746f2073656e6420302062616c616e63650000604082015260600190565b90815260200190565b60ff91909116815260200190565b60405181810167ffffffffffffffff81118282101715611dd057600080fd5b604052919050565b600067ffffffffffffffff821115611dee578081fd5b5060209081020190565b60005b83811015611e13578181015183820152602001611dfb565b83811115611e22576000848401525b50505050565b6001600160a01b03811681146105fa57600080fd5b80151581146105fa57600080fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a206275726e20616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220fd515804eca384cb14c99861e60dc5364ae65ba9ddfdfe00d195788ee631d01064736f6c634300060c0033"; +const isSuperArgs$u = (xs) => xs.length > 1; +class TORN__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$u(args)) { + super(...args); + } else { + super(_abi$P, _bytecode$u, args[0]); + } + } + getDeployTransaction(_governance, _pausePeriod, _vestings, overrides) { + return super.getDeployTransaction( + _governance, + _pausePeriod, + _vestings, + overrides || {} + ); + } + deploy(_governance, _pausePeriod, _vestings, overrides) { + return super.deploy( + _governance, + _pausePeriod, + _vestings, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$P); + } + static connect(address, runner) { + return new Contract(address, _abi$P, runner); + } +} +TORN__factory.bytecode = _bytecode$u; +TORN__factory.abi = _abi$P; + +const _abi$O = [ + { + inputs: [ + { + internalType: "address", + name: "_token", + type: "address" + }, + { + internalType: "address", + name: "_beneficiary", + type: "address" + }, + { + internalType: "uint256", + name: "_startTimestamp", + type: "uint256" + }, + { + internalType: "uint256", + name: "_cliffInMonths", + type: "uint256" + }, + { + internalType: "uint256", + name: "_durationInMonths", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "Released", + type: "event" + }, + { + inputs: [], + name: "SECONDS_PER_MONTH", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "beneficiary", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "blockTimestamp", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "cliffInMonths", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "durationInMonths", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "release", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "released", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "startTimestamp", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "token", + outputs: [ + { + internalType: "contract IERC20", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "vestedAmount", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$t = "0x61012060405234801561001157600080fd5b50604051610c8c380380610c8c833981810160405260a081101561003457600080fd5b508051602082015160408301516060840151608090940151929391929091906001600160a01b0384166100ae576040805162461bcd60e51b815260206004820152601b60248201527f42656e65666963696172792063616e6e6f7420626520656d7074790000000000604482015290519081900360640190fd5b80821115610103576040805162461bcd60e51b815260206004820152601e60248201527f436c6966662069732067726561746572207468616e206475726174696f6e0000604482015290519081900360640190fd5b6001600160601b0319606086811b821660a05285901b1660805261010081905260c08290528215610134578261013c565b61013c61014a565b60e0525061014e9350505050565b4290565b60805160601c60a05160601c60c05160e05161010051610acc6101c060003980610203528061037b52806103dd525080610152528061018e52806105215250806101d052806104f352508061024852806102c85280610474528061054552508061012c52806104965250610acc6000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c8063928d89ae11610066578063928d89ae146100fb5780639613252114610103578063adb618321461010b578063e6fd48bc14610113578063fc0c546a1461011b5761009e565b806310786deb146100a357806338af3eed146100bd57806344b1231f146100e157806367097a4b146100e957806386d1a69f146100f1575b600080fd5b6100ab610123565b60408051918252519081900360200190f35b6100c561012a565b604080516001600160a01b039092168252519081900360200190f35b6100ab61014e565b6100ab6103db565b6100f96103ff565b005b6100ab6104f1565b6100ab610515565b6100ab61051b565b6100ab61051f565b6100c5610543565b62278d0081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60007f000000000000000000000000000000000000000000000000000000000000000061017961051b565b1015610187575060006103d8565b60006101bb7f00000000000000000000000000000000000000000000000000000000000000006101b561051b565b90610567565b905060006101cc8262278d006105b2565b90507f0000000000000000000000000000000000000000000000000000000000000000811015610201576000925050506103d8565b7f000000000000000000000000000000000000000000000000000000000000000081106102c457604080516370a0823160e01b815230600482015290516001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916370a08231916024808301926020929190829003018186803b15801561028e57600080fd5b505afa1580156102a2573d6000803e3d6000fd5b505050506040513d60208110156102b857600080fd5b505192506103d8915050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561033357600080fd5b505afa158015610347573d6000803e3d6000fd5b505050506040513d602081101561035d57600080fd5b505160008054919250906103729083906105f4565b905060006103aa7f00000000000000000000000000000000000000000000000000000000000000006103a4848761064e565b906105b2565b905060006103c36000548361056790919063ffffffff16565b90506103cf84826106a7565b96505050505050505b90565b7f000000000000000000000000000000000000000000000000000000000000000081565b600061040961014e565b905060008111610457576040805162461bcd60e51b81526020600482015260146024820152734e6f20746f6b656e7320746f2072656c6561736560601b604482015290519081900360640190fd5b60005461046490826105f4565b6000556104bb6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f0000000000000000000000000000000000000000000000000000000000000000836106bd565b6040805182815290517ffb81f9b30d73d830c3544b34d827c08142579ee75710b490bab0b3995468c5659181900360200190a150565b7f000000000000000000000000000000000000000000000000000000000000000081565b60005481565b4290565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60006105a983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610714565b90505b92915050565b60006105a983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506107ab565b6000828201838110156105a9576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60008261065d575060006105ac565b8282028284828161066a57fe5b04146105a95760405162461bcd60e51b8152600401808060200182810382526021815260200180610a4c6021913960400191505060405180910390fd5b60008183106106b657816105a9565b5090919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261070f908490610810565b505050565b600081848411156107a35760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610768578181015183820152602001610750565b50505050905090810190601f1680156107955780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600081836107fa5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315610768578181015183820152602001610750565b50600083858161080657fe5b0495945050505050565b6060610865826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166108c19092919063ffffffff16565b80519091501561070f5780806020019051602081101561088457600080fd5b505161070f5760405162461bcd60e51b815260040180806020018281038252602a815260200180610a6d602a913960400191505060405180910390fd5b60606108d084846000856108d8565b949350505050565b60606108e385610a45565b610934576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106109735780518252601f199092019160209182019101610954565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146109d5576040519150601f19603f3d011682016040523d82523d6000602084013e6109da565b606091505b509150915081156109ee5791506108d09050565b8051156109fe5780518082602001fd5b60405162461bcd60e51b8152602060048201818152865160248401528651879391928392604401919085019080838360008315610768578181015183820152602001610750565b3b15159056fe536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212203b3e8370e345374172efb9e3693b20807c318ecfcc569df94f28df8a94f2727a64736f6c634300060c0033"; +const isSuperArgs$t = (xs) => xs.length > 1; +class Vesting__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$t(args)) { + super(...args); + } else { + super(_abi$O, _bytecode$t, args[0]); + } + } + getDeployTransaction(_token, _beneficiary, _startTimestamp, _cliffInMonths, _durationInMonths, overrides) { + return super.getDeployTransaction( + _token, + _beneficiary, + _startTimestamp, + _cliffInMonths, + _durationInMonths, + overrides || {} + ); + } + deploy(_token, _beneficiary, _startTimestamp, _cliffInMonths, _durationInMonths, overrides) { + return super.deploy( + _token, + _beneficiary, + _startTimestamp, + _cliffInMonths, + _durationInMonths, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$O); + } + static connect(address, runner) { + return new Contract(address, _abi$O, runner); + } +} +Vesting__factory.bytecode = _bytecode$t; +Vesting__factory.abi = _abi$O; + +const _abi$N = [ + { + inputs: [ + { + internalType: "bytes32", + name: "_torn", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "_governance", + type: "bytes32" + }, + { + internalType: "uint256", + name: "_duration", + type: "uint256" + }, + { + components: [ + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + internalType: "struct Voucher.Recipient[]", + name: "_airdrops", + type: "tuple[]" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "allowedTransferee", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "approve", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "blockTimestamp", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32[]", + name: "domains", + type: "bytes32[]" + } + ], + name: "bulkResolve", + outputs: [ + { + internalType: "address[]", + name: "result", + type: "address[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "subtractedValue", + type: "uint256" + } + ], + name: "decreaseAllowance", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "expiresAt", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "governance", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "addedValue", + type: "uint256" + } + ], + name: "increaseAllowance", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "redeem", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "rescueExpiredTokens", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "resolve", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "torn", + outputs: [ + { + internalType: "contract IERC20", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transfer", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "sender", + type: "address" + }, + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$s = "0x60e06040523480156200001157600080fd5b5060405162001d8d38038062001d8d833981016040819052620000349162000593565b60405180606001604052806026815260200162001d6760269139604051806040016040528060058152602001643b2a27a92760d91b81525081600390805190602001906200008492919062000497565b5080516200009a90600490602084019062000497565b50506005805460ff1916601217905550620000b584620001af565b60601b6001600160601b031916608052620000d083620001af565b60601b6001600160601b03191660c0526200010382620000ef620002fd565b6200030160201b6200098d1790919060201c565b60a05260005b8151811015620001a457620001558282815181106200012457fe5b6020026020010151600001518383815181106200013d57fe5b6020026020010151602001516200033260201b60201c565b6001600660008484815181106200016857fe5b602090810291909101810151516001600160a01b03168252810191909152604001600020805460ff191691151591909117905560010162000109565b505050505062000753565b600080620001bc62000415565b600114620001df57738595bfb0d940dfedc98943fa8a907091203f25ee620001f0565b6e0c2e074ec69a0dfb2997ba6c7d2e1e5b604051630178b8bf60e01b81529091506001600160a01b03821690630178b8bf906200022190869060040162000665565b60206040518083038186803b1580156200023a57600080fd5b505afa1580156200024f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000275919062000574565b6001600160a01b0316633b3b57de846040518263ffffffff1660e01b8152600401620002a2919062000665565b60206040518083038186803b158015620002bb57600080fd5b505afa158015620002d0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002f6919062000574565b9392505050565b4290565b600082820183811015620002f65760405162461bcd60e51b815260040162000329906200066e565b60405180910390fd5b6001600160a01b0382166200035b5760405162461bcd60e51b81526004016200032990620006dc565b620003696000838362000419565b62000385816002546200030160201b6200098d1790919060201c565b6002556001600160a01b03821660009081526020818152604090912054620003b89183906200098d62000301821b17901c565b6001600160a01b0383166000818152602081905260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906200040990859062000665565b60405180910390a35050565b4690565b620004318383836200049260201b620009b21760201c565b6001600160a01b03821615806200044f57506001600160a01b038316155b806200047357506001600160a01b03831660009081526006602052604090205460ff165b620004925760405162461bcd60e51b81526004016200032990620006a5565b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620004da57805160ff19168380011785556200050a565b828001600101855582156200050a579182015b828111156200050a578251825591602001919060010190620004ed565b50620005189291506200051c565b5090565b5b808211156200051857600081556001016200051d565b60006040828403121562000545578081fd5b62000551604062000713565b9050815162000560816200073a565b808252506020820151602082015292915050565b60006020828403121562000586578081fd5b8151620002f6816200073a565b60008060008060808587031215620005a9578283fd5b8451935060208086015193506040808701519350606087015160018060401b0380821115620005d6578485fd5b818901915089601f830112620005ea578485fd5b815181811115620005f9578586fd5b62000608858683020162000713565b8181528581019250838601858302850187018d101562000626578788fd5b8794505b8285101562000654576200063f8d8262000533565b8452600194909401939286019285016200062a565b50989b979a50959850505050505050565b90815260200190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601e908201527f45524332303a207472616e73666572206973206e6f7420616c6c6f7765640000604082015260600190565b6020808252601f908201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604082015260600190565b6040518181016001600160401b03811182821017156200073257600080fd5b604052919050565b6001600160a01b03811681146200075057600080fd5b50565b60805160601c60a05160c05160601c6115c3620007a46000398061043152806107d35250806105c352806106ec52806107895250806106c8528061075d52806107f4528061089852506115c36000f3fe608060405234801561001057600080fd5b506004361061012c5760003560e01c80638622a689116100ad578063adf898a411610071578063adf898a41461024b578063be040fb014610253578063c39ef8551461025d578063dd62ed3e14610265578063f9e54234146102785761012c565b80638622a6891461020d57806395d89b4114610215578063a457c2d71461021d578063a9059cbb14610230578063adb61832146102435761012c565b806339509351116100f457806339509351146101ac5780635aa6e675146101bf5780635c23bdf5146101d45780635d4545a0146101e757806370a08231146101fa5761012c565b806306fdde0314610131578063095ea7b31461014f57806318160ddd1461016f57806323b872dd14610184578063313ce56714610197575b600080fd5b610139610298565b604051610146919061116f565b60405180910390f35b61016261015d366004610fb5565b61032e565b604051610146919061115b565b61017761034b565b6040516101469190611166565b610162610192366004610f75565b610351565b61019f6103d8565b604051610146919061145e565b6101626101ba366004610fb5565b6103e1565b6101c761042f565b60405161014691906110e1565b6101c76101e2366004611095565b610453565b6101626101f5366004610f05565b610591565b610177610208366004610f05565b6105a6565b6101776105c1565b6101396105e5565b61016261022b366004610fb5565b610646565b61016261023e366004610fb5565b6106ae565b6101776106c2565b6101c76106c6565b61025b6106ea565b005b61025b610787565b610177610273366004610f3d565b6108c1565b61028b610286366004610fe0565b6108ec565b604051610146919061110e565b60038054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156103245780601f106102f957610100808354040283529160200191610324565b820191906000526020600020905b81548152906001019060200180831161030757829003601f168201915b5050505050905090565b600061034261033b6109b7565b84846109bb565b50600192915050565b60025490565b600061035e848484610a6f565b6103ce8461036a6109b7565b6103c985604051806060016040528060288152602001611541602891396001600160a01b038a166000908152600160205260408120906103a86109b7565b6001600160a01b031681526020810191909152604001600020549190610b84565b6109bb565b5060019392505050565b60055460ff1690565b60006103426103ee6109b7565b846103c985600160006103ff6109b7565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549061098d565b7f000000000000000000000000000000000000000000000000000000000000000081565b60008061045e610bb0565b60011461047f57738595bfb0d940dfedc98943fa8a907091203f25ee610490565b6e0c2e074ec69a0dfb2997ba6c7d2e1e5b604051630178b8bf60e01b81529091506001600160a01b03821690630178b8bf906104bf908690600401611166565b60206040518083038186803b1580156104d757600080fd5b505afa1580156104eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050f9190610f21565b6001600160a01b0316633b3b57de846040518263ffffffff1660e01b815260040161053a9190611166565b60206040518083038186803b15801561055257600080fd5b505afa158015610566573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061058a9190610f21565b9392505050565b60066020526000908152604090205460ff1681565b6001600160a01b031660009081526020819052604090205490565b7f000000000000000000000000000000000000000000000000000000000000000081565b60048054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156103245780601f106102f957610100808354040283529160200191610324565b60006103426106536109b7565b846103c985604051806060016040528060258152602001611569602591396001600061067d6109b7565b6001600160a01b03908116825260208083019390935260409182016000908120918d16815292529020549190610b84565b60006103426106bb6109b7565b8484610a6f565b4290565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f00000000000000000000000000000000000000000000000000000000000000006107136106c2565b106107395760405162461bcd60e51b81526004016107309061125e565b60405180910390fd5b6000610744336105a6565b90506107503382610bb4565b6107846001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163383610c96565b50565b7f00000000000000000000000000000000000000000000000000000000000000006107b06106c2565b10156107ce5760405162461bcd60e51b815260040161073090611295565b6108bf7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161083e91906110e1565b60206040518083038186803b15801561085657600080fd5b505afa15801561086a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088e91906110ad565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169190610c96565b565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6060815167ffffffffffffffff8111801561090657600080fd5b50604051908082528060200260200182016040528015610930578160200160208202803683370190505b50905060005b82518110156109875761095b83828151811061094e57fe5b6020026020010151610453565b82828151811061096757fe5b6001600160a01b0390921660209283029190910190910152600101610936565b50919050565b60008282018381101561058a5760405162461bcd60e51b815260040161073090611227565b505050565b3390565b6001600160a01b0383166109e15760405162461bcd60e51b815260040161073090611399565b6001600160a01b038216610a075760405162461bcd60e51b8152600401610730906111e5565b6001600160a01b0380841660008181526001602090815260408083209487168084529490915290819020849055517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610a62908590611166565b60405180910390a3505050565b6001600160a01b038316610a955760405162461bcd60e51b815260040161073090611354565b6001600160a01b038216610abb5760405162461bcd60e51b8152600401610730906111a2565b610ac6838383610cec565b610b038160405180606001604052806026815260200161151b602691396001600160a01b0386166000908152602081905260409020549190610b84565b6001600160a01b038085166000908152602081905260408082209390935590841681522054610b32908261098d565b6001600160a01b0380841660008181526020819052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610a62908590611166565b60008184841115610ba85760405162461bcd60e51b8152600401610730919061116f565b505050900390565b4690565b6001600160a01b038216610bda5760405162461bcd60e51b815260040161073090611313565b610be682600083610cec565b610c23816040518060600160405280602281526020016114f9602291396001600160a01b0385166000908152602081905260409020549190610b84565b6001600160a01b038316600090815260208190526040902055600254610c499082610d53565b6002556040516000906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90610c8a908590611166565b60405180910390a35050565b6109b28363a9059cbb60e01b8484604051602401610cb59291906110f5565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610d95565b610cf78383836109b2565b6001600160a01b0382161580610d1457506001600160a01b038316155b80610d3757506001600160a01b03831660009081526006602052604090205460ff165b6109b25760405162461bcd60e51b8152600401610730906112dc565b600061058a83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610b84565b6060610dea826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610e249092919063ffffffff16565b8051909150156109b25780806020019051810190610e089190611075565b6109b25760405162461bcd60e51b815260040161073090611414565b6060610e338484600085610e3b565b949350505050565b6060610e4685610eff565b610e625760405162461bcd60e51b8152600401610730906113dd565b60006060866001600160a01b03168587604051610e7f91906110c5565b60006040518083038185875af1925050503d8060008114610ebc576040519150601f19603f3d011682016040523d82523d6000602084013e610ec1565b606091505b50915091508115610ed5579150610e339050565b805115610ee55780518082602001fd5b8360405162461bcd60e51b8152600401610730919061116f565b3b151590565b600060208284031215610f16578081fd5b813561058a816114e3565b600060208284031215610f32578081fd5b815161058a816114e3565b60008060408385031215610f4f578081fd5b8235610f5a816114e3565b91506020830135610f6a816114e3565b809150509250929050565b600080600060608486031215610f89578081fd5b8335610f94816114e3565b92506020840135610fa4816114e3565b929592945050506040919091013590565b60008060408385031215610fc7578182fd5b8235610fd2816114e3565b946020939093013593505050565b60006020808385031215610ff2578182fd5b823567ffffffffffffffff811115611008578283fd5b8301601f81018513611018578283fd5b803561102b61102682611493565b61146c565b8181528381019083850185840285018601891015611047578687fd5b8694505b8385101561106957803583526001949094019391850191850161104b565b50979650505050505050565b600060208284031215611086578081fd5b8151801515811461058a578182fd5b6000602082840312156110a6578081fd5b5035919050565b6000602082840312156110be578081fd5b5051919050565b600082516110d78184602087016114b3565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b8181101561114f5783516001600160a01b03168352928401929184019160010161112a565b50909695505050505050565b901515815260200190565b90815260200190565b600060208252825180602084015261118e8160408501602087016114b3565b601f01601f19169190910160400192915050565b60208082526023908201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526022908201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252601f908201527f41697264726f702072656465656d20706572696f642068617320656e64656400604082015260600190565b60208082526027908201527f41697264726f702072656465656d20706572696f6420686173206e6f7420656e604082015266191959081e595d60ca1b606082015260800190565b6020808252601e908201527f45524332303a207472616e73666572206973206e6f7420616c6c6f7765640000604082015260600190565b60208082526021908201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736040820152607360f81b606082015260800190565b60208082526025908201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526024908201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646040820152637265737360e01b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b60ff91909116815260200190565b60405181810167ffffffffffffffff8111828210171561148b57600080fd5b604052919050565b600067ffffffffffffffff8211156114a9578081fd5b5060209081020190565b60005b838110156114ce5781810151838201526020016114b6565b838111156114dd576000848401525b50505050565b6001600160a01b038116811461078457600080fdfe45524332303a206275726e20616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa26469706673582212209b2d6f14167bc062b61418b8fca6b7946d243420e3df874c9632acb30079c69b64736f6c634300060c0033546f726e61646f4361736820766f756368657220666f72206561726c792061646f7074657273"; +const isSuperArgs$s = (xs) => xs.length > 1; +class Voucher__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$s(args)) { + super(...args); + } else { + super(_abi$N, _bytecode$s, args[0]); + } + } + getDeployTransaction(_torn, _governance, _duration, _airdrops, overrides) { + return super.getDeployTransaction( + _torn, + _governance, + _duration, + _airdrops, + overrides || {} + ); + } + deploy(_torn, _governance, _duration, _airdrops, overrides) { + return super.deploy( + _torn, + _governance, + _duration, + _airdrops, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$N); + } + static connect(address, runner) { + return new Contract(address, _abi$N, runner); + } +} +Voucher__factory.bytecode = _bytecode$s; +Voucher__factory.abi = _abi$N; + +const _abi$M = [ + { + inputs: [ + { + internalType: "address", + name: "_logic", + type: "address" + }, + { + internalType: "address", + name: "_admin", + type: "address" + }, + { + internalType: "bytes", + name: "_data", + type: "bytes" + } + ], + stateMutability: "payable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "previousAdmin", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "newAdmin", + type: "address" + } + ], + name: "AdminChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "implementation", + type: "address" + } + ], + name: "Upgraded", + type: "event" + }, + { + stateMutability: "payable", + type: "fallback" + }, + { + inputs: [], + name: "admin", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "callToOwner", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newAdmin", + type: "address" + } + ], + name: "changeAdmin", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "changeOwner", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "delegateToOwner", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [], + name: "getCurrentOwner", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "implementation", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address" + } + ], + name: "upgradeTo", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address" + } + ], + name: "upgradeToOwner", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + stateMutability: "payable", + type: "receive" + } +]; +const _bytecode$r = "0x608060405260405162000e6738038062000e67833981810160405260608110156200002957600080fd5b815160208301516040808501805191519395929483019291846401000000008211156200005557600080fd5b9083019060208201858111156200006b57600080fd5b82516401000000008111828201881017156200008657600080fd5b82525081516020918201929091019080838360005b83811015620000b55781810151838201526020016200009b565b50505050905090810190601f168015620000e35780820380516001836020036101000a031916815260200191505b5060405250849150839050828282828281620000ff82620001f6565b805115620001bd576000826001600160a01b0316826040518082805190602001908083835b60208310620001455780518252601f19909201916020918201910162000124565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114620001a7576040519150601f19603f3d011682016040523d82523d6000602084013e620001ac565b606091505b5050905080620001bb57600080fd5b505b50620001c69050565b620001d1826200026d565b505050505050620001ed336200029160201b620008ab1760201c565b50505062000308565b6200020c81620002bd60201b620008d51760201c565b620002495760405162461bcd60e51b815260040180806020018281038252603681526020018062000e316036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b806200029c620002c3565b80546001600160a01b0319166001600160a01b039290921691909117905550565b3b151590565b604080517fb4d03667d60278cc15e9a68fa7679dc39ebe71350c4566a2c23c26580da4e0b3602080830191909152825180830382018152918301909252805191012090565b610b1980620003186000396000f3fe6080604052600436106100955760003560e01c80635c60da1b116100595780635c60da1b146102fe5780638f2839701461032f578063a18a186b14610362578063a6f9dae114610377578063f851a440146103aa576100a4565b806323711ab1146100ac57806323c735f1146101625780632e44e0e0146101955780633659cfe61461024b5780634f1ef2861461027e576100a4565b366100a4576100a26103bf565b005b6100a26103bf565b6100a2600480360360408110156100c257600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100ed57600080fd5b8201836020820111156100ff57600080fd5b8035906020019184600183028401116401000000008311171561012157600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506103d9945050505050565b34801561016e57600080fd5b506100a26004803603602081101561018557600080fd5b50356001600160a01b03166104e7565b6100a2600480360360408110156101ab57600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156101d657600080fd5b8201836020820111156101e857600080fd5b8035906020019184600183028401116401000000008311171561020a57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610546945050505050565b34801561025757600080fd5b506100a26004803603602081101561026e57600080fd5b50356001600160a01b031661063a565b6100a26004803603604081101561029457600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156102bf57600080fd5b8201836020820111156102d157600080fd5b803590602001918460018302840111640100000000831117156102f357600080fd5b509092509050610671565b34801561030a57600080fd5b5061031361071e565b604080516001600160a01b039092168252519081900360200190f35b34801561033b57600080fd5b506100a26004803603602081101561035257600080fd5b50356001600160a01b031661075b565b34801561036e57600080fd5b50610313610815565b34801561038357600080fd5b506100a26004803603602081101561039a57600080fd5b50356001600160a01b0316610824565b3480156103b657600080fd5b50610313610880565b6103c76103d7565b6103d76103d26108db565b610900565b565b336103e2610924565b6001600160a01b03161461042c576040805162461bcd60e51b815260206004820152600c60248201526b2737ba1030b71037bbb732b960a11b604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b6020831061046a5780518252601f19909201916020918201910161044b565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d80600081146104ca576040519150601f19603f3d011682016040523d82523d6000602084013e6104cf565b606091505b5091509150816104e157805181602001fd5b50505050565b336104f0610924565b6001600160a01b03161461053a576040805162461bcd60e51b815260206004820152600c60248201526b2737ba1030b71037bbb732b960a11b604482015290519081900360640190fd5b6105438161093d565b50565b3361054f610924565b6001600160a01b031614610599576040805162461bcd60e51b815260206004820152600c60248201526b2737ba1030b71037bbb732b960a11b604482015290519081900360640190fd5b60006060836001600160a01b031634846040518082805190602001908083835b602083106105d85780518252601f1990920191602091820191016105b9565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146104ca576040519150601f19603f3d011682016040523d82523d6000602084013e6104cf565b61064261097d565b6001600160a01b0316336001600160a01b03161415610669576106648161093d565b610543565b6105436103bf565b61067961097d565b6001600160a01b0316336001600160a01b031614156107115761069b8361093d565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d80600081146106f8576040519150601f19603f3d011682016040523d82523d6000602084013e6106fd565b606091505b505090508061070b57600080fd5b50610719565b6107196103bf565b505050565b600061072861097d565b6001600160a01b0316336001600160a01b03161415610750576107496108db565b9050610758565b6107586103bf565b90565b61076361097d565b6001600160a01b0316336001600160a01b03161415610669576001600160a01b0381166107c15760405162461bcd60e51b815260040180806020018281038252603a815260200180610a74603a913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6107ea61097d565b604080516001600160a01b03928316815291841660208301528051918290030190a1610664816109a2565b600061081f610924565b905090565b3361082d610924565b6001600160a01b031614610877576040805162461bcd60e51b815260206004820152600c60248201526b2737ba1030b71037bbb732b960a11b604482015290519081900360640190fd5b610543816108ab565b600061088a61097d565b6001600160a01b0316336001600160a01b031614156107505761074961097d565b806108b46109c6565b80546001600160a01b0319166001600160a01b039290921691909117905550565b3b151590565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e80801561091f573d6000f35b3d6000fd5b600061092e6109c6565b546001600160a01b0316919050565b61094681610a0b565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b604080517fb4d03667d60278cc15e9a68fa7679dc39ebe71350c4566a2c23c26580da4e0b3602080830191909152825180830382018152918301909252805191012090565b610a14816108d5565b610a4f5760405162461bcd60e51b8152600401808060200182810382526036815260200180610aae6036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5556fe5472616e73706172656e745570677261646561626c6550726f78793a206e65772061646d696e20697320746865207a65726f20616464726573735570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374a264697066735822122001f07e10d1eeadbd61da070e50227b529a3ec4b8f2e780a0e6bc1dc6028ba95764736f6c634300060c00335570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374"; +const isSuperArgs$r = (xs) => xs.length > 1; +class TestnetAdminProxy__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$r(args)) { + super(...args); + } else { + super(_abi$M, _bytecode$r, args[0]); + } + } + getDeployTransaction(_logic, _admin, _data, overrides) { + return super.getDeployTransaction(_logic, _admin, _data, overrides || {}); + } + deploy(_logic, _admin, _data, overrides) { + return super.deploy(_logic, _admin, _data, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$M); + } + static connect(address, runner) { + return new Contract(address, _abi$M, runner); + } +} +TestnetAdminProxy__factory.bytecode = _bytecode$r; +TestnetAdminProxy__factory.abi = _abi$M; + +const _abi$L = [ + { + inputs: [ + { + internalType: "address", + name: "_torn", + type: "address" + }, + { + internalType: "address", + name: "_governance", + type: "address" + }, + { + internalType: "address", + name: "_registry", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "instance", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "newFee", + type: "uint256" + } + ], + name: "FeeUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint24", + name: "newFee", + type: "uint24" + } + ], + name: "UniswapTornPoolSwappingFeeChanged", + type: "event" + }, + { + inputs: [], + name: "PROTOCOL_FEE_DIVIDER", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "_instance", + type: "address" + } + ], + name: "calculatePoolFee", + outputs: [ + { + internalType: "uint160", + name: "", + type: "uint160" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "feeDeviations", + outputs: [ + { + components: [ + { + internalType: "address", + name: "instance", + type: "address" + }, + { + internalType: "int256", + name: "deviation", + type: "int256" + } + ], + internalType: "struct FeeManager.Deviation[]", + name: "results", + type: "tuple[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "_token", + type: "address" + }, + { + internalType: "uint24", + name: "_uniswapPoolSwappingFee", + type: "uint24" + } + ], + name: "getTokenPriceRatio", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "governance", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "", + type: "address" + } + ], + name: "instanceFee", + outputs: [ + { + internalType: "uint160", + name: "", + type: "uint160" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "", + type: "address" + } + ], + name: "instanceFeeUpdated", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "_instance", + type: "address" + } + ], + name: "instanceFeeWithUpdate", + outputs: [ + { + internalType: "uint160", + name: "", + type: "uint160" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "registry", + outputs: [ + { + internalType: "contract InstanceRegistry", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint32", + name: "newPeriod", + type: "uint32" + } + ], + name: "setPeriodForTWAPOracle", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "_token", + type: "address" + }, + { + internalType: "uint256", + name: "_price", + type: "uint256" + } + ], + name: "setTokenPrice", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint24", + name: "_uniswapTornPoolSwappingFee", + type: "uint24" + } + ], + name: "setUniswapTornPoolSwappingFee", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint24", + name: "newLimit", + type: "uint24" + } + ], + name: "setUpdateFeeTimeLimit", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "torn", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "uniswapTimePeriod", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "uniswapTornPoolSwappingFee", + outputs: [ + { + internalType: "uint24", + name: "", + type: "uint24" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "updateAllFees", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "_instance", + type: "address" + } + ], + name: "updateFee", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "updateFeeTimeLimit", + outputs: [ + { + internalType: "uint24", + name: "", + type: "uint24" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance[]", + name: "_instances", + type: "address[]" + } + ], + name: "updateFees", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$q = "0x60e06040523480156200001157600080fd5b5060405162001c9d38038062001c9d83398101604081905262000034916200005c565b6001600160601b0319606093841b811660805291831b821660a05290911b1660c052620000c8565b60008060006060848603121562000071578283fd5b83516200007e81620000af565b60208501519093506200009181620000af565b6040850151909250620000a481620000af565b809150509250925092565b6001600160a01b0381168114620000c557600080fd5b50565b60805160601c60a05160601c60c05160601c611b7c6200012160003980610350528061061452806108915280610a42525080610539528061064c528061072d528061082252508061059852806107ad5250611b7c6000f3fe608060405234801561001057600080fd5b506004361061012c5760003560e01c806380eb7bf0116100ad578063bcc5ee6411610071578063bcc5ee641461024b578063c51c229714610253578063d8718fb114610266578063e1f121561461027b578063f522d6d61461028e5761012c565b806380eb7bf014610202578063a028752014610215578063adf898a414610228578063aeb3077a14610230578063b19a2972146102385761012c565b8063603a54fe116100f4578063603a54fe146101ac57806369574fef146101bf5780637b103999146101d25780637ccd2f48146101da57806380679eb3146101ef5761012c565b806305e34364146101315780632efbf3841461015a578063431f63c91461017a5780634bf0a5421461018f5780635aa6e675146101a4575b600080fd5b61014461013f36600461183e565b610296565b6040516101519190611aaa565b60405180910390f35b61016d61016836600461183e565b6102a8565b60405161015191906118cb565b61018d6101883660046115b1565b610305565b005b61019761034b565b6040516101519190611907565b61016d610537565b61016d6101ba36600461183e565b61055b565b6101446101cd366004611579565b610576565b61016d610612565b6101e2610636565b6040516101519190611a9a565b61018d6101fd36600461188e565b610641565b61018d61021036600461183e565b61069c565b61018d61022336600461185a565b610722565b61016d6107ab565b6101446107cf565b61018d6102463660046115dc565b6107d5565b6101e2610805565b61018d61026136600461185a565b610817565b61026e610874565b6040516101519190611ab3565b61016d61028936600461183e565b610887565b61018d610a3d565b60026020526000908152604090205481565b600080546001600160a01b038316825260026020526040822054600160381b90910462ffffff16429190910311156102e3576102e38261069c565b506001600160a01b03808216600090815260016020526040902054165b919050565b3361030e610ad7565b6001600160a01b03161461033d5760405162461bcd60e51b8152600401610334906119fc565b60405180910390fd5b6103478282610af0565b5050565b6060807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166310c13ac36040518163ffffffff1660e01b815260040160006040518083038186803b1580156103a757600080fd5b505afa1580156103bb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526103e39190810190611675565b9050805167ffffffffffffffff811180156103fd57600080fd5b5060405190808252806020026020018201604052801561043757816020015b6104246114b2565b81526020019060019003908161041c5790505b50915060005b815181101561053257600061046483838151811061045757fe5b6020026020010151610887565b6001600160a01b03169050600081156104e0576103e8826001600087878151811061048b57fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060009054906101000a90046001600160a01b03166103e8026001600160a01b0316816104db57fe5b040390505b60405180604001604052808585815181106104f757fe5b60200260200101516001600160a01b031681526020018281525085848151811061051d57fe5b6020908102919091010152505060010161043d565b505090565b7f000000000000000000000000000000000000000000000000000000000000000081565b6001602052600090815260409020546001600160a01b031681565b600061058183610b19565b610600576040805180820182526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811682528516602080830191909152825180840190935260005462ffffff80821685528616918401919091526105fb929063ffffffff630100000090910416610b44565b610609565b61060983610b19565b90505b92915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60005462ffffff1681565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461067657600080fd5b6000805463ffffffff90921663010000000266ffffffff00000019909216919091179055565b60006106a782610887565b6001600160a01b03838116600081815260016020908152604080832080546001600160a01b03191695871695909517909455600290528290204290559051919250907f6f0eaf2c2f89fb4cfe96a1dee5e764d60b52c7f48aaa590f0850e308aa1b953a906107169084906118cb565b60405180910390a25050565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461075757600080fd5b6000805462ffffff191662ffffff83811691909117918290556040517fbfe65cfc2359076c4468c9b895156c309c78f94fb09f6d2fc0463c4ca9a71ac2926107a0921690611a9a565b60405180910390a150565b7f000000000000000000000000000000000000000000000000000000000000000081565b61271081565b60005b8151811015610347576107fd8282815181106107f057fe5b602002602001015161069c565b6001016107d8565b600054600160381b900462ffffff1681565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461084c57600080fd5b6000805462ffffff909216600160381b0269ffffff0000000000000019909216919091179055565b6000546301000000900463ffffffff1681565b60008060008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663032bb443876040518263ffffffff1660e01b81526004016108db91906118cb565b60a06040518083038186803b1580156108f357600080fd5b505afa158015610907573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061092b91906117c3565b9450945050935093508063ffffffff1660001415610950576000945050505050610300565b6001600160a01b038316158015610965575083155b61096f5782610985565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc25b925060006109938484610576565b9050610a32612710610a2c8463ffffffff16610a2685610a2c670de0b6b3a76400008e6001600160a01b0316638bca6d166040518163ffffffff1660e01b815260040160206040518083038186803b1580156109ee57600080fd5b505afa158015610a02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a269190611876565b90610b90565b90610bca565b979650505050505050565b610ad57f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166310c13ac36040518163ffffffff1660e01b815260040160006040518083038186803b158015610a9957600080fd5b505afa158015610aad573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526102469190810190611675565b565b6000610ae1610c0c565b546001600160a01b0316919050565b6000610afa610c61565b6001600160a01b03909316600090815260209390935250604090912055565b600080610b24610c61565b6001600160a01b0390931660009081526020939093525050604090205490565b60208084015190830151600091610b5b9184610c98565b84518451610b7e91670de0b6b3a764000091610b78919087610c98565b90610cc2565b81610b8557fe5b0490505b9392505050565b600082610b9f5750600061060c565b82820282848281610bac57fe5b04146106095760405162461bcd60e51b815260040161033490611a59565b600061060983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610ce6565b6000807fb4d03667d60278cc15e9a68fa7679dc39ebe71350c4566a2c23c26580da4e0b360001c604051602001610c439190611aaa565b60408051601f19818403018152919052805160209091012092915050565b6000807f6521c13ddfc30471ec629848a30b01f73c36737d417c11843e7a9afa6985e84860001c604051602001610c439190611aaa565b6000610cba8473c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28585610d1d565b949350505050565b6000821580610cdd57505081810281838281610cda57fe5b04145b61060c57600080fd5b60008183610d075760405162461bcd60e51b815260040161033491906119a9565b506000838581610d1357fe5b0495945050505050565b600080846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610d5957600080fd5b505afa158015610d6d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9191906118aa565b60ff16600a0a90506001600160a01b038681169086161415610dbd576001600160801b03169050610cba565b604051630b4c774160e11b8152610e5e90610e5690731f98431c8ad98523631ae4a59f267346ea31f98490631698ee8290610e00908b908b908b906004016118df565b60206040518083038186803b158015610e1857600080fd5b505afa158015610e2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e50919061155d565b85610e6f565b828888611004565b915050610cba565b50949350505050565b600063ffffffff8216610e945760405162461bcd60e51b815260040161033490611a22565b60408051600280825260608083018452926020830190803683370190505090508281600081518110610ec257fe5b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110610eeb57fe5b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526060906001600160a01b0386169063883bdbfd90610f2f90859060040161195f565b60006040518083038186803b158015610f4757600080fd5b505afa158015610f5b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f839190810190611701565b509050600081600081518110610f9557fe5b602002602001015182600181518110610faa57fe5b60200260200101510390508463ffffffff168160060b81610fc757fe5b05935060008160060b128015610fee57508463ffffffff168160060b81610fea57fe5b0715155b15610ffb57600019909301925b50505092915050565b600080611010866110ee565b90506001600160801b036001600160a01b0382161161107f576001600160a01b038082168002908481169086161061105f5761105a600160c01b876001600160801b031683611407565b611077565b61107781876001600160801b0316600160c01b611407565b925050610e66565b600061109e6001600160a01b0383168068010000000000000000611407565b9050836001600160a01b0316856001600160a01b0316106110d6576110d1600160801b876001600160801b031683611407565b610a32565b610a3281876001600160801b0316600160801b611407565b60008060008360020b12611105578260020b61110d565b8260020b6000035b9050620d89e88111156111325760405162461bcd60e51b815260040161033490611a3e565b60006001821661114657600160801b611158565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff169050600282161561118c576ffff97272373d413259a46990580e213a0260801c5b60048216156111ab576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b60088216156111ca576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b60108216156111e9576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615611208576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615611227576fff2ea16466c96a3843ec78b326b528610260801c5b6080821615611246576ffe5dee046a99a2a811c461f1969c30530260801c5b610100821615611266576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b610200821615611286576ff987a7253ac413176f2b074cf7815e540260801c5b6104008216156112a6576ff3392b0822b70005940c7a398e4b70f30260801c5b6108008216156112c6576fe7159475a2c29b7443b29c7fa6e889d90260801c5b6110008216156112e6576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615611306576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615611326576f70d869a156d2a1b890bb3df62baf32f70260801c5b618000821615611346576f31be135f97d08fd981231505542fcfa60260801c5b62010000821615611367576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b62020000821615611387576e5d6af8dedb81196699c329225ee6040260801c5b620400008216156113a6576d2216e584f5fa1ea926041bedfe980260801c5b620800008216156113c3576b048a170391f7dc42444e8fa20260801c5b60008460020b13156113de5780600019816113da57fe5b0490505b6401000000008106156113f25760016113f5565b60005b60ff16602082901c0192505050919050565b600080806000198587098686029250828110908390030390508061143d576000841161143257600080fd5b508290049050610b89565b80841161144957600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b604080518082019091526000808252602082015290565b600082601f8301126114d9578081fd5b81516114ec6114e782611aeb565b611ac4565b81815291506020808301908481018184028601820187101561150d57600080fd5b60005b8481101561153557815161152381611b0b565b84529282019290820190600101611510565b505050505092915050565b805161060c81611b0b565b8051600681900b811461060c57600080fd5b60006020828403121561156e578081fd5b815161060981611b0b565b6000806040838503121561158b578081fd5b823561159681611b0b565b915060208301356115a681611b23565b809150509250929050565b600080604083850312156115c3578182fd5b82356115ce81611b0b565b946020939093013593505050565b600060208083850312156115ee578182fd5b823567ffffffffffffffff811115611604578283fd5b8301601f81018513611614578283fd5b80356116226114e782611aeb565b818152838101908385018584028501860189101561163e578687fd5b8694505b8385101561166957803561165581611b0b565b835260019490940193918501918501611642565b50979650505050505050565b60006020808385031215611687578182fd5b825167ffffffffffffffff81111561169d578283fd5b8301601f810185136116ad578283fd5b80516116bb6114e782611aeb565b81815283810190838501858402850186018910156116d7578687fd5b8694505b83851015611669576116ed8982611540565b8352600194909401939185019185016116db565b60008060408385031215611713578182fd5b825167ffffffffffffffff8082111561172a578384fd5b818501915085601f83011261173d578384fd5b815161174b6114e782611aeb565b80828252602080830192508086018a82838702890101111561176b578889fd5b8896505b84871015611795576117818b8261154b565b84526001969096019592810192810161176f565b5088015190965093505050808211156117ac578283fd5b506117b9858286016114c9565b9150509250929050565b600080600080600060a086880312156117da578081fd5b855180151581146117e9578182fd5b60208701519095506117fa81611b0b565b60408701519094506002811061180e578182fd5b606087015190935061181f81611b23565b608087015190925061183081611b34565b809150509295509295909350565b60006020828403121561184f578081fd5b813561060981611b0b565b60006020828403121561186b578081fd5b813561060981611b23565b600060208284031215611887578081fd5b5051919050565b60006020828403121561189f578081fd5b813561060981611b34565b6000602082840312156118bb578081fd5b815160ff81168114610609578182fd5b6001600160a01b0391909116815260200190565b6001600160a01b03938416815291909216602082015262ffffff909116604082015260600190565b602080825282518282018190526000919060409081850190868401855b8281101561195257815180516001600160a01b03168552860151868501529284019290850190600101611924565b5091979650505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561199d57835163ffffffff168352928401929184019160010161197b565b50909695505050505050565b6000602080835283518082850152825b818110156119d5578581018301518582016040015282016119b9565b818111156119e65783604083870101525b50601f01601f1916929092016040019392505050565b6020808252600c908201526b2737ba1030b71037bbb732b960a11b604082015260600190565b602080825260029082015261042560f41b604082015260600190565b6020808252600190820152601560fa1b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b62ffffff91909116815260200190565b90815260200190565b63ffffffff91909116815260200190565b60405181810167ffffffffffffffff81118282101715611ae357600080fd5b604052919050565b600067ffffffffffffffff821115611b01578081fd5b5060209081020190565b6001600160a01b0381168114611b2057600080fd5b50565b62ffffff81168114611b2057600080fd5b63ffffffff81168114611b2057600080fdfea2646970667358221220e716ce7751ca9331e897d31f3744c6916e2f742be6df42551b069b566751df4c64736f6c634300060c0033"; +const isSuperArgs$q = (xs) => xs.length > 1; +class TestnetFeeManager__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$q(args)) { + super(...args); + } else { + super(_abi$L, _bytecode$q, args[0]); + } + } + getDeployTransaction(_torn, _governance, _registry, overrides) { + return super.getDeployTransaction( + _torn, + _governance, + _registry, + overrides || {} + ); + } + deploy(_torn, _governance, _registry, overrides) { + return super.deploy( + _torn, + _governance, + _registry, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$L); + } + static connect(address, runner) { + return new Contract(address, _abi$L, runner); + } +} +TestnetFeeManager__factory.bytecode = _bytecode$q; +TestnetFeeManager__factory.abi = _abi$L; + +const _abi$K = [ + { + inputs: [ + { + internalType: "address", + name: "_logic", + type: "address" + }, + { + internalType: "bytes", + name: "_data", + type: "bytes" + } + ], + stateMutability: "payable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "previousAdmin", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "newAdmin", + type: "address" + } + ], + name: "AdminChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "implementation", + type: "address" + } + ], + name: "Upgraded", + type: "event" + }, + { + stateMutability: "payable", + type: "fallback" + }, + { + inputs: [], + name: "admin", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "callToOwner", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newAdmin", + type: "address" + } + ], + name: "changeAdmin", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "changeOwner", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "delegateToOwner", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [], + name: "getCurrentOwner", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "implementation", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address" + } + ], + name: "upgradeTo", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address" + } + ], + name: "upgradeToOwner", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + stateMutability: "payable", + type: "receive" + } +]; +const _bytecode$p = "0x608060405260405162000e6038038062000e60833981810160405260408110156200002957600080fd5b8151602083018051604051929492938301929190846401000000008211156200005157600080fd5b9083019060208201858111156200006757600080fd5b82516401000000008111828201881017156200008257600080fd5b82525081516020918201929091019080838360005b83811015620000b157818101518382015260200162000097565b50505050905090810190601f168015620000df5780820380516001836020036101000a031916815260200191505b50604052508391508290508130828281620000fa82620001ef565b805115620001b8576000826001600160a01b0316826040518082805190602001908083835b60208310620001405780518252601f1990920191602091820191016200011f565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114620001a2576040519150601f19603f3d011682016040523d82523d6000602084013e620001a7565b606091505b5050905080620001b657600080fd5b505b50620001c19050565b620001cc8262000266565b5050505050620001e7336200028a60201b620008ab1760201c565b505062000301565b6200020581620002b660201b620008d51760201c565b620002425760405162461bcd60e51b815260040180806020018281038252603681526020018062000e2a6036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b8062000295620002bc565b80546001600160a01b0319166001600160a01b039290921691909117905550565b3b151590565b604080517fb4d03667d60278cc15e9a68fa7679dc39ebe71350c4566a2c23c26580da4e0b3602080830191909152825180830382018152918301909252805191012090565b610b1980620003116000396000f3fe6080604052600436106100955760003560e01c80635c60da1b116100595780635c60da1b146102fe5780638f2839701461032f578063a18a186b14610362578063a6f9dae114610377578063f851a440146103aa576100a4565b806323711ab1146100ac57806323c735f1146101625780632e44e0e0146101955780633659cfe61461024b5780634f1ef2861461027e576100a4565b366100a4576100a26103bf565b005b6100a26103bf565b6100a2600480360360408110156100c257600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100ed57600080fd5b8201836020820111156100ff57600080fd5b8035906020019184600183028401116401000000008311171561012157600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506103d9945050505050565b34801561016e57600080fd5b506100a26004803603602081101561018557600080fd5b50356001600160a01b03166104e7565b6100a2600480360360408110156101ab57600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156101d657600080fd5b8201836020820111156101e857600080fd5b8035906020019184600183028401116401000000008311171561020a57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610546945050505050565b34801561025757600080fd5b506100a26004803603602081101561026e57600080fd5b50356001600160a01b031661063a565b6100a26004803603604081101561029457600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156102bf57600080fd5b8201836020820111156102d157600080fd5b803590602001918460018302840111640100000000831117156102f357600080fd5b509092509050610671565b34801561030a57600080fd5b5061031361071e565b604080516001600160a01b039092168252519081900360200190f35b34801561033b57600080fd5b506100a26004803603602081101561035257600080fd5b50356001600160a01b031661075b565b34801561036e57600080fd5b50610313610815565b34801561038357600080fd5b506100a26004803603602081101561039a57600080fd5b50356001600160a01b0316610824565b3480156103b657600080fd5b50610313610880565b6103c76103d7565b6103d76103d26108db565b610900565b565b336103e2610924565b6001600160a01b03161461042c576040805162461bcd60e51b815260206004820152600c60248201526b2737ba1030b71037bbb732b960a11b604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b6020831061046a5780518252601f19909201916020918201910161044b565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d80600081146104ca576040519150601f19603f3d011682016040523d82523d6000602084013e6104cf565b606091505b5091509150816104e157805181602001fd5b50505050565b336104f0610924565b6001600160a01b03161461053a576040805162461bcd60e51b815260206004820152600c60248201526b2737ba1030b71037bbb732b960a11b604482015290519081900360640190fd5b6105438161093d565b50565b3361054f610924565b6001600160a01b031614610599576040805162461bcd60e51b815260206004820152600c60248201526b2737ba1030b71037bbb732b960a11b604482015290519081900360640190fd5b60006060836001600160a01b031634846040518082805190602001908083835b602083106105d85780518252601f1990920191602091820191016105b9565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146104ca576040519150601f19603f3d011682016040523d82523d6000602084013e6104cf565b61064261097d565b6001600160a01b0316336001600160a01b03161415610669576106648161093d565b610543565b6105436103bf565b61067961097d565b6001600160a01b0316336001600160a01b031614156107115761069b8361093d565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d80600081146106f8576040519150601f19603f3d011682016040523d82523d6000602084013e6106fd565b606091505b505090508061070b57600080fd5b50610719565b6107196103bf565b505050565b600061072861097d565b6001600160a01b0316336001600160a01b03161415610750576107496108db565b9050610758565b6107586103bf565b90565b61076361097d565b6001600160a01b0316336001600160a01b03161415610669576001600160a01b0381166107c15760405162461bcd60e51b815260040180806020018281038252603a815260200180610a74603a913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6107ea61097d565b604080516001600160a01b03928316815291841660208301528051918290030190a1610664816109a2565b600061081f610924565b905090565b3361082d610924565b6001600160a01b031614610877576040805162461bcd60e51b815260206004820152600c60248201526b2737ba1030b71037bbb732b960a11b604482015290519081900360640190fd5b610543816108ab565b600061088a61097d565b6001600160a01b0316336001600160a01b031614156107505761074961097d565b806108b46109c6565b80546001600160a01b0319166001600160a01b039290921691909117905550565b3b151590565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e80801561091f573d6000f35b3d6000fd5b600061092e6109c6565b546001600160a01b0316919050565b61094681610a0b565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b604080517fb4d03667d60278cc15e9a68fa7679dc39ebe71350c4566a2c23c26580da4e0b3602080830191909152825180830382018152918301909252805191012090565b610a14816108d5565b610a4f5760405162461bcd60e51b8152600401808060200182810382526036815260200180610aae6036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5556fe5472616e73706172656e745570677261646561626c6550726f78793a206e65772061646d696e20697320746865207a65726f20616464726573735570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374a2646970667358221220486b8f46c84e133fdcdf09d6e85ae28603a923477471dc965d4d7f5f3634234c64736f6c634300060c00335570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374"; +const isSuperArgs$p = (xs) => xs.length > 1; +class TestnetGovernanceProxy__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$p(args)) { + super(...args); + } else { + super(_abi$K, _bytecode$p, args[0]); + } + } + getDeployTransaction(_logic, _data, overrides) { + return super.getDeployTransaction(_logic, _data, overrides || {}); + } + deploy(_logic, _data, overrides) { + return super.deploy(_logic, _data, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$K); + } + static connect(address, runner) { + return new Contract( + address, + _abi$K, + runner + ); + } +} +TestnetGovernanceProxy__factory.bytecode = _bytecode$p; +TestnetGovernanceProxy__factory.abi = _abi$K; + +const _abi$J = [ + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "lockedBalance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "userVault", + outputs: [ + { + internalType: "contract ITornadoVault", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + } +]; +class ITornadoGovernance__factory { + static createInterface() { + return new Interface(_abi$J); + } + static connect(address, runner) { + return new Contract(address, _abi$J, runner); + } +} +ITornadoGovernance__factory.abi = _abi$J; + +const _abi$I = [ + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "withdrawTorn", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +let ITornadoVault__factory$1 = class ITornadoVault__factory { + static createInterface() { + return new Interface(_abi$I); + } + static connect(address, runner) { + return new Contract(address, _abi$I, runner); + } +}; +ITornadoVault__factory$1.abi = _abi$I; + +const _abi$H = [ + { + inputs: [ + { + internalType: "address", + name: "governanceAddress", + type: "address" + }, + { + internalType: "address", + name: "tornAddress", + type: "address" + }, + { + internalType: "address", + name: "_relayerRegistry", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "rewardsClaimed", + type: "uint256" + } + ], + name: "RewardsClaimed", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "rewards", + type: "uint256" + } + ], + name: "RewardsUpdated", + type: "event" + }, + { + inputs: [], + name: "Governance", + outputs: [ + { + internalType: "contract ITornadoGovernance", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "accumulatedRewardPerTorn", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "accumulatedRewardRateOnLastUpdate", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "accumulatedRewards", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "addBurnRewards", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "checkReward", + outputs: [ + { + internalType: "uint256", + name: "rewards", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getReward", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "ratioConstant", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "relayerRegistry", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "torn", + outputs: [ + { + internalType: "contract IERC20", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + }, + { + internalType: "uint256", + name: "amountLockedBeforehand", + type: "uint256" + } + ], + name: "updateRewardsOnLockedBalanceChange", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "withdrawTorn", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$o = "0x6101006040523480156200001257600080fd5b506040516200114d3803806200114d8339810160408190526200003591620000e0565b6001600160601b0319606084811b821660a05283811b821660c05282901b1660e052604080516318160ddd60e01b815290516001600160a01b038416916318160ddd916004808301926020929190829003018186803b1580156200009857600080fd5b505afa158015620000ad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000d3919062000133565b6080525062000165915050565b600080600060608486031215620000f5578283fd5b835162000102816200014c565b602085015190935062000115816200014c565b604085015190925062000128816200014c565b809150509250925092565b60006020828403121562000145578081fd5b5051919050565b6001600160a01b03811681146200016257600080fd5b50565b60805160a05160601c60c05160601c60e05160601c610f5e620001ef600039806101bd52806104c852508061020c5280610453528061054652806107b0528061084552508061018b528061023b528061037d5280610522528061056d52806106b75280610752528061086752508061033c52806104fe528061063152806109635250610f5e6000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c8063adf898a411610071578063adf898a414610124578063c3c90e641461012c578063d7ada20d1461013f578063e0d3265214610152578063e113335f1461015a578063f58073b11461016d576100b4565b8063338610af146100b95780633d18b912146100ce57806347ff589d146100d657806373f273fc146100f457806380a1204114610114578063945391121461011c575b600080fd5b6100cc6100c7366004610ce6565b610180565b005b6100cc610375565b6100de6104c6565b6040516100eb9190610d32565b60405180910390f35b610107610102366004610c63565b6104ea565b6040516100eb9190610eda565b6101076104fc565b6100de610520565b6100de610544565b61010761013a366004610c63565b610568565b61010761014d366004610c63565b610694565b6101076106a6565b6100cc610168366004610c7f565b6106ac565b6100cc61017b366004610ce6565b610747565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614806101df5750336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016145b6102045760405162461bcd60e51b81526004016101fb90610e33565b60405180910390fd5b61036f6103667f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166370a082317f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639daafec76040518163ffffffff1660e01b815260040160206040518083038186803b15801561029257600080fd5b505afa1580156102a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ca9190610cca565b6040518263ffffffff1660e01b81526004016102e69190610d32565b60206040518083038186803b1580156102fe57600080fd5b505afa158015610312573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103369190610cfe565b610360847f000000000000000000000000000000000000000000000000000000000000000061088f565b906108d2565b60015490610914565b60015550565b600061041c337f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639ae697bf336040518263ffffffff1660e01b81526004016103c79190610d32565b60206040518083038186803b1580156103df57600080fd5b505afa1580156103f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104179190610cfe565b610939565b3360009081526003602052604090205490915061043a908290610914565b33600081815260036020526040812055909150610482907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690836109f3565b336001600160a01b03167ffc30cddea38e2bf4d6ea7d3f9ed3b6ad7f176419f4963bd81318067a4aee73fe826040516104bb9190610eda565b60405180910390a250565b7f000000000000000000000000000000000000000000000000000000000000000081565b60036020526000908152604090205481565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639ae697bf846040518263ffffffff1660e01b81526004016105b79190610d32565b60206040518083038186803b1580156105cf57600080fd5b505afa1580156105e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106079190610cfe565b90508015610669576001600160a01b038316600090815260026020526040902054600154610666917f00000000000000000000000000000000000000000000000000000000000000009161036091859161066091610a4e565b9061088f565b91505b6001600160a01b03831660009081526003602052604090205461068d908390610914565b9392505050565b60026020526000908152604090205481565b60015481565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146106f45760405162461bcd60e51b81526004016101fb90610dc9565b60006107008383610939565b6001600160a01b0384166000908152600360205260409020549091506107269082610914565b6001600160a01b039093166000908152600360205260409020929092555050565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461078f5760405162461bcd60e51b81526004016101fb90610dc9565b600019811415610838576040516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a08231906107e5903090600401610d32565b60206040518083038186803b1580156107fd57600080fd5b505afa158015610811573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108359190610cfe565b90505b61088c6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f0000000000000000000000000000000000000000000000000000000000000000836109f3565b50565b60008261089e575060006108cc565b828202828482816108ab57fe5b04146108c95760405162461bcd60e51b81526004016101fb90610df2565b90505b92915050565b60006108c983836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610a90565b6000828201838110156108c95760405162461bcd60e51b81526004016101fb90610d92565b60008115610995576001600160a01b038316600090815260026020526040902054600154610992917f00000000000000000000000000000000000000000000000000000000000000009161036091869161066091610a4e565b90505b6001546001600160a01b038416600081815260026020526040908190209290925590517f39fe62076cf7adf3c60e355a2da5a4f17a958ca319e8eba385a6c09a8b649016906109e5908490610eda565b60405180910390a292915050565b610a498363a9059cbb60e01b8484604051602401610a12929190610d46565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610ac7565b505050565b60006108c983836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610b56565b60008183610ab15760405162461bcd60e51b81526004016101fb9190610d5f565b506000838581610abd57fe5b0495945050505050565b6060610b1c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610b829092919063ffffffff16565b805190915015610a495780806020019051810190610b3a9190610caa565b610a495760405162461bcd60e51b81526004016101fb90610e90565b60008184841115610b7a5760405162461bcd60e51b81526004016101fb9190610d5f565b505050900390565b6060610b918484600085610b99565b949350505050565b6060610ba485610c5d565b610bc05760405162461bcd60e51b81526004016101fb90610e59565b60006060866001600160a01b03168587604051610bdd9190610d16565b60006040518083038185875af1925050503d8060008114610c1a576040519150601f19603f3d011682016040523d82523d6000602084013e610c1f565b606091505b50915091508115610c33579150610b919050565b805115610c435780518082602001fd5b8360405162461bcd60e51b81526004016101fb9190610d5f565b3b151590565b600060208284031215610c74578081fd5b81356108c981610f13565b60008060408385031215610c91578081fd5b8235610c9c81610f13565b946020939093013593505050565b600060208284031215610cbb578081fd5b815180151581146108c9578182fd5b600060208284031215610cdb578081fd5b81516108c981610f13565b600060208284031215610cf7578081fd5b5035919050565b600060208284031215610d0f578081fd5b5051919050565b60008251610d28818460208701610ee3565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6000602082528251806020840152610d7e816040850160208701610ee3565b601f01601f19169190910160400192915050565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252600f908201526e6f6e6c7920676f7665726e616e636560881b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252600c908201526b1d5b985d5d1a1bdc9a5e995960a21b604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b90815260200190565b60005b83811015610efe578181015183820152602001610ee6565b83811115610f0d576000848401525b50505050565b6001600160a01b038116811461088c57600080fdfea26469706673582212205243f8df41704c99bb0876cbda927f702de9dce11a8394f252f0e4abd7d2778364736f6c634300060c0033"; +const isSuperArgs$o = (xs) => xs.length > 1; +class TornadoStakingRewards__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$o(args)) { + super(...args); + } else { + super(_abi$H, _bytecode$o, args[0]); + } + } + getDeployTransaction(governanceAddress, tornAddress, _relayerRegistry, overrides) { + return super.getDeployTransaction( + governanceAddress, + tornAddress, + _relayerRegistry, + overrides || {} + ); + } + deploy(governanceAddress, tornAddress, _relayerRegistry, overrides) { + return super.deploy( + governanceAddress, + tornAddress, + _relayerRegistry, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$H); + } + static connect(address, runner) { + return new Contract( + address, + _abi$H, + runner + ); + } +} +TornadoStakingRewards__factory.bytecode = _bytecode$o; +TornadoStakingRewards__factory.abi = _abi$H; + +const _abi$G = [ + { + inputs: [ + { + internalType: "int24", + name: "tickLower", + type: "int24" + }, + { + internalType: "int24", + name: "tickUpper", + type: "int24" + }, + { + internalType: "uint128", + name: "amount", + type: "uint128" + } + ], + name: "burn", + outputs: [ + { + internalType: "uint256", + name: "amount0", + type: "uint256" + }, + { + internalType: "uint256", + name: "amount1", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "int24", + name: "tickLower", + type: "int24" + }, + { + internalType: "int24", + name: "tickUpper", + type: "int24" + }, + { + internalType: "uint128", + name: "amount0Requested", + type: "uint128" + }, + { + internalType: "uint128", + name: "amount1Requested", + type: "uint128" + } + ], + name: "collect", + outputs: [ + { + internalType: "uint128", + name: "amount0", + type: "uint128" + }, + { + internalType: "uint128", + name: "amount1", + type: "uint128" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount0", + type: "uint256" + }, + { + internalType: "uint256", + name: "amount1", + type: "uint256" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "flash", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint16", + name: "observationCardinalityNext", + type: "uint16" + } + ], + name: "increaseObservationCardinalityNext", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint160", + name: "sqrtPriceX96", + type: "uint160" + } + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "int24", + name: "tickLower", + type: "int24" + }, + { + internalType: "int24", + name: "tickUpper", + type: "int24" + }, + { + internalType: "uint128", + name: "amount", + type: "uint128" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "mint", + outputs: [ + { + internalType: "uint256", + name: "amount0", + type: "uint256" + }, + { + internalType: "uint256", + name: "amount1", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "bool", + name: "zeroForOne", + type: "bool" + }, + { + internalType: "int256", + name: "amountSpecified", + type: "int256" + }, + { + internalType: "uint160", + name: "sqrtPriceLimitX96", + type: "uint160" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "swap", + outputs: [ + { + internalType: "int256", + name: "amount0", + type: "int256" + }, + { + internalType: "int256", + name: "amount1", + type: "int256" + } + ], + stateMutability: "nonpayable", + type: "function" + } +]; +class IUniswapV3PoolActions__factory { + static createInterface() { + return new Interface(_abi$G); + } + static connect(address, runner) { + return new Contract( + address, + _abi$G, + runner + ); + } +} +IUniswapV3PoolActions__factory.abi = _abi$G; + +const _abi$F = [ + { + inputs: [ + { + internalType: "uint32[]", + name: "secondsAgos", + type: "uint32[]" + } + ], + name: "observe", + outputs: [ + { + internalType: "int56[]", + name: "tickCumulatives", + type: "int56[]" + }, + { + internalType: "uint160[]", + name: "secondsPerLiquidityCumulativeX128s", + type: "uint160[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "int24", + name: "tickLower", + type: "int24" + }, + { + internalType: "int24", + name: "tickUpper", + type: "int24" + } + ], + name: "snapshotCumulativesInside", + outputs: [ + { + internalType: "int56", + name: "tickCumulativeInside", + type: "int56" + }, + { + internalType: "uint160", + name: "secondsPerLiquidityInsideX128", + type: "uint160" + }, + { + internalType: "uint32", + name: "secondsInside", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + } +]; +class IUniswapV3PoolDerivedState__factory { + static createInterface() { + return new Interface(_abi$F); + } + static connect(address, runner) { + return new Contract( + address, + _abi$F, + runner + ); + } +} +IUniswapV3PoolDerivedState__factory.abi = _abi$F; + +const _abi$E = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "int24", + name: "tickLower", + type: "int24" + }, + { + indexed: true, + internalType: "int24", + name: "tickUpper", + type: "int24" + }, + { + indexed: false, + internalType: "uint128", + name: "amount", + type: "uint128" + }, + { + indexed: false, + internalType: "uint256", + name: "amount0", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "amount1", + type: "uint256" + } + ], + name: "Burn", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "recipient", + type: "address" + }, + { + indexed: true, + internalType: "int24", + name: "tickLower", + type: "int24" + }, + { + indexed: true, + internalType: "int24", + name: "tickUpper", + type: "int24" + }, + { + indexed: false, + internalType: "uint128", + name: "amount0", + type: "uint128" + }, + { + indexed: false, + internalType: "uint128", + name: "amount1", + type: "uint128" + } + ], + name: "Collect", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "recipient", + type: "address" + }, + { + indexed: false, + internalType: "uint128", + name: "amount0", + type: "uint128" + }, + { + indexed: false, + internalType: "uint128", + name: "amount1", + type: "uint128" + } + ], + name: "CollectProtocol", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "recipient", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "amount0", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "amount1", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "paid0", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "paid1", + type: "uint256" + } + ], + name: "Flash", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint16", + name: "observationCardinalityNextOld", + type: "uint16" + }, + { + indexed: false, + internalType: "uint16", + name: "observationCardinalityNextNew", + type: "uint16" + } + ], + name: "IncreaseObservationCardinalityNext", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint160", + name: "sqrtPriceX96", + type: "uint160" + }, + { + indexed: false, + internalType: "int24", + name: "tick", + type: "int24" + } + ], + name: "Initialize", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "sender", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "int24", + name: "tickLower", + type: "int24" + }, + { + indexed: true, + internalType: "int24", + name: "tickUpper", + type: "int24" + }, + { + indexed: false, + internalType: "uint128", + name: "amount", + type: "uint128" + }, + { + indexed: false, + internalType: "uint256", + name: "amount0", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "amount1", + type: "uint256" + } + ], + name: "Mint", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint8", + name: "feeProtocol0Old", + type: "uint8" + }, + { + indexed: false, + internalType: "uint8", + name: "feeProtocol1Old", + type: "uint8" + }, + { + indexed: false, + internalType: "uint8", + name: "feeProtocol0New", + type: "uint8" + }, + { + indexed: false, + internalType: "uint8", + name: "feeProtocol1New", + type: "uint8" + } + ], + name: "SetFeeProtocol", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "recipient", + type: "address" + }, + { + indexed: false, + internalType: "int256", + name: "amount0", + type: "int256" + }, + { + indexed: false, + internalType: "int256", + name: "amount1", + type: "int256" + }, + { + indexed: false, + internalType: "uint160", + name: "sqrtPriceX96", + type: "uint160" + }, + { + indexed: false, + internalType: "uint128", + name: "liquidity", + type: "uint128" + }, + { + indexed: false, + internalType: "int24", + name: "tick", + type: "int24" + } + ], + name: "Swap", + type: "event" + } +]; +class IUniswapV3PoolEvents__factory { + static createInterface() { + return new Interface(_abi$E); + } + static connect(address, runner) { + return new Contract( + address, + _abi$E, + runner + ); + } +} +IUniswapV3PoolEvents__factory.abi = _abi$E; + +const _abi$D = [ + { + inputs: [], + name: "factory", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "fee", + outputs: [ + { + internalType: "uint24", + name: "", + type: "uint24" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "maxLiquidityPerTick", + outputs: [ + { + internalType: "uint128", + name: "", + type: "uint128" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "tickSpacing", + outputs: [ + { + internalType: "int24", + name: "", + type: "int24" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "token0", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "token1", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + } +]; +class IUniswapV3PoolImmutables__factory { + static createInterface() { + return new Interface(_abi$D); + } + static connect(address, runner) { + return new Contract( + address, + _abi$D, + runner + ); + } +} +IUniswapV3PoolImmutables__factory.abi = _abi$D; + +const _abi$C = [ + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint128", + name: "amount0Requested", + type: "uint128" + }, + { + internalType: "uint128", + name: "amount1Requested", + type: "uint128" + } + ], + name: "collectProtocol", + outputs: [ + { + internalType: "uint128", + name: "amount0", + type: "uint128" + }, + { + internalType: "uint128", + name: "amount1", + type: "uint128" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint8", + name: "feeProtocol0", + type: "uint8" + }, + { + internalType: "uint8", + name: "feeProtocol1", + type: "uint8" + } + ], + name: "setFeeProtocol", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class IUniswapV3PoolOwnerActions__factory { + static createInterface() { + return new Interface(_abi$C); + } + static connect(address, runner) { + return new Contract( + address, + _abi$C, + runner + ); + } +} +IUniswapV3PoolOwnerActions__factory.abi = _abi$C; + +const _abi$B = [ + { + inputs: [], + name: "feeGrowthGlobal0X128", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "feeGrowthGlobal1X128", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "liquidity", + outputs: [ + { + internalType: "uint128", + name: "", + type: "uint128" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "index", + type: "uint256" + } + ], + name: "observations", + outputs: [ + { + internalType: "uint32", + name: "blockTimestamp", + type: "uint32" + }, + { + internalType: "int56", + name: "tickCumulative", + type: "int56" + }, + { + internalType: "uint160", + name: "secondsPerLiquidityCumulativeX128", + type: "uint160" + }, + { + internalType: "bool", + name: "initialized", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "key", + type: "bytes32" + } + ], + name: "positions", + outputs: [ + { + internalType: "uint128", + name: "_liquidity", + type: "uint128" + }, + { + internalType: "uint256", + name: "feeGrowthInside0LastX128", + type: "uint256" + }, + { + internalType: "uint256", + name: "feeGrowthInside1LastX128", + type: "uint256" + }, + { + internalType: "uint128", + name: "tokensOwed0", + type: "uint128" + }, + { + internalType: "uint128", + name: "tokensOwed1", + type: "uint128" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "protocolFees", + outputs: [ + { + internalType: "uint128", + name: "token0", + type: "uint128" + }, + { + internalType: "uint128", + name: "token1", + type: "uint128" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "slot0", + outputs: [ + { + internalType: "uint160", + name: "sqrtPriceX96", + type: "uint160" + }, + { + internalType: "int24", + name: "tick", + type: "int24" + }, + { + internalType: "uint16", + name: "observationIndex", + type: "uint16" + }, + { + internalType: "uint16", + name: "observationCardinality", + type: "uint16" + }, + { + internalType: "uint16", + name: "observationCardinalityNext", + type: "uint16" + }, + { + internalType: "uint8", + name: "feeProtocol", + type: "uint8" + }, + { + internalType: "bool", + name: "unlocked", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "int16", + name: "wordPosition", + type: "int16" + } + ], + name: "tickBitmap", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "int24", + name: "tick", + type: "int24" + } + ], + name: "ticks", + outputs: [ + { + internalType: "uint128", + name: "liquidityGross", + type: "uint128" + }, + { + internalType: "int128", + name: "liquidityNet", + type: "int128" + }, + { + internalType: "uint256", + name: "feeGrowthOutside0X128", + type: "uint256" + }, + { + internalType: "uint256", + name: "feeGrowthOutside1X128", + type: "uint256" + }, + { + internalType: "int56", + name: "tickCumulativeOutside", + type: "int56" + }, + { + internalType: "uint160", + name: "secondsPerLiquidityOutsideX128", + type: "uint160" + }, + { + internalType: "uint32", + name: "secondsOutside", + type: "uint32" + }, + { + internalType: "bool", + name: "initialized", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + } +]; +class IUniswapV3PoolState__factory { + static createInterface() { + return new Interface(_abi$B); + } + static connect(address, runner) { + return new Contract( + address, + _abi$B, + runner + ); + } +} +IUniswapV3PoolState__factory.abi = _abi$B; + +const _abi$A = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint24", + name: "fee", + type: "uint24" + }, + { + indexed: true, + internalType: "int24", + name: "tickSpacing", + type: "int24" + } + ], + name: "FeeAmountEnabled", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "oldOwner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "OwnerChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "token0", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "token1", + type: "address" + }, + { + indexed: true, + internalType: "uint24", + name: "fee", + type: "uint24" + }, + { + indexed: false, + internalType: "int24", + name: "tickSpacing", + type: "int24" + }, + { + indexed: false, + internalType: "address", + name: "pool", + type: "address" + } + ], + name: "PoolCreated", + type: "event" + }, + { + inputs: [ + { + internalType: "address", + name: "tokenA", + type: "address" + }, + { + internalType: "address", + name: "tokenB", + type: "address" + }, + { + internalType: "uint24", + name: "fee", + type: "uint24" + } + ], + name: "createPool", + outputs: [ + { + internalType: "address", + name: "pool", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint24", + name: "fee", + type: "uint24" + }, + { + internalType: "int24", + name: "tickSpacing", + type: "int24" + } + ], + name: "enableFeeAmount", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint24", + name: "fee", + type: "uint24" + } + ], + name: "feeAmountTickSpacing", + outputs: [ + { + internalType: "int24", + name: "", + type: "int24" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "tokenA", + type: "address" + }, + { + internalType: "address", + name: "tokenB", + type: "address" + }, + { + internalType: "uint24", + name: "fee", + type: "uint24" + } + ], + name: "getPool", + outputs: [ + { + internalType: "address", + name: "pool", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address" + } + ], + name: "setOwner", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class IUniswapV3Factory__factory { + static createInterface() { + return new Interface(_abi$A); + } + static connect(address, runner) { + return new Contract(address, _abi$A, runner); + } +} +IUniswapV3Factory__factory.abi = _abi$A; + +const _abi$z = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "int24", + name: "tickLower", + type: "int24" + }, + { + indexed: true, + internalType: "int24", + name: "tickUpper", + type: "int24" + }, + { + indexed: false, + internalType: "uint128", + name: "amount", + type: "uint128" + }, + { + indexed: false, + internalType: "uint256", + name: "amount0", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "amount1", + type: "uint256" + } + ], + name: "Burn", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "recipient", + type: "address" + }, + { + indexed: true, + internalType: "int24", + name: "tickLower", + type: "int24" + }, + { + indexed: true, + internalType: "int24", + name: "tickUpper", + type: "int24" + }, + { + indexed: false, + internalType: "uint128", + name: "amount0", + type: "uint128" + }, + { + indexed: false, + internalType: "uint128", + name: "amount1", + type: "uint128" + } + ], + name: "Collect", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "recipient", + type: "address" + }, + { + indexed: false, + internalType: "uint128", + name: "amount0", + type: "uint128" + }, + { + indexed: false, + internalType: "uint128", + name: "amount1", + type: "uint128" + } + ], + name: "CollectProtocol", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "recipient", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "amount0", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "amount1", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "paid0", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "paid1", + type: "uint256" + } + ], + name: "Flash", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint16", + name: "observationCardinalityNextOld", + type: "uint16" + }, + { + indexed: false, + internalType: "uint16", + name: "observationCardinalityNextNew", + type: "uint16" + } + ], + name: "IncreaseObservationCardinalityNext", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint160", + name: "sqrtPriceX96", + type: "uint160" + }, + { + indexed: false, + internalType: "int24", + name: "tick", + type: "int24" + } + ], + name: "Initialize", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "sender", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "int24", + name: "tickLower", + type: "int24" + }, + { + indexed: true, + internalType: "int24", + name: "tickUpper", + type: "int24" + }, + { + indexed: false, + internalType: "uint128", + name: "amount", + type: "uint128" + }, + { + indexed: false, + internalType: "uint256", + name: "amount0", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "amount1", + type: "uint256" + } + ], + name: "Mint", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint8", + name: "feeProtocol0Old", + type: "uint8" + }, + { + indexed: false, + internalType: "uint8", + name: "feeProtocol1Old", + type: "uint8" + }, + { + indexed: false, + internalType: "uint8", + name: "feeProtocol0New", + type: "uint8" + }, + { + indexed: false, + internalType: "uint8", + name: "feeProtocol1New", + type: "uint8" + } + ], + name: "SetFeeProtocol", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "recipient", + type: "address" + }, + { + indexed: false, + internalType: "int256", + name: "amount0", + type: "int256" + }, + { + indexed: false, + internalType: "int256", + name: "amount1", + type: "int256" + }, + { + indexed: false, + internalType: "uint160", + name: "sqrtPriceX96", + type: "uint160" + }, + { + indexed: false, + internalType: "uint128", + name: "liquidity", + type: "uint128" + }, + { + indexed: false, + internalType: "int24", + name: "tick", + type: "int24" + } + ], + name: "Swap", + type: "event" + }, + { + inputs: [ + { + internalType: "int24", + name: "tickLower", + type: "int24" + }, + { + internalType: "int24", + name: "tickUpper", + type: "int24" + }, + { + internalType: "uint128", + name: "amount", + type: "uint128" + } + ], + name: "burn", + outputs: [ + { + internalType: "uint256", + name: "amount0", + type: "uint256" + }, + { + internalType: "uint256", + name: "amount1", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "int24", + name: "tickLower", + type: "int24" + }, + { + internalType: "int24", + name: "tickUpper", + type: "int24" + }, + { + internalType: "uint128", + name: "amount0Requested", + type: "uint128" + }, + { + internalType: "uint128", + name: "amount1Requested", + type: "uint128" + } + ], + name: "collect", + outputs: [ + { + internalType: "uint128", + name: "amount0", + type: "uint128" + }, + { + internalType: "uint128", + name: "amount1", + type: "uint128" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint128", + name: "amount0Requested", + type: "uint128" + }, + { + internalType: "uint128", + name: "amount1Requested", + type: "uint128" + } + ], + name: "collectProtocol", + outputs: [ + { + internalType: "uint128", + name: "amount0", + type: "uint128" + }, + { + internalType: "uint128", + name: "amount1", + type: "uint128" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "factory", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "fee", + outputs: [ + { + internalType: "uint24", + name: "", + type: "uint24" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "feeGrowthGlobal0X128", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "feeGrowthGlobal1X128", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount0", + type: "uint256" + }, + { + internalType: "uint256", + name: "amount1", + type: "uint256" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "flash", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint16", + name: "observationCardinalityNext", + type: "uint16" + } + ], + name: "increaseObservationCardinalityNext", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint160", + name: "sqrtPriceX96", + type: "uint160" + } + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "liquidity", + outputs: [ + { + internalType: "uint128", + name: "", + type: "uint128" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "maxLiquidityPerTick", + outputs: [ + { + internalType: "uint128", + name: "", + type: "uint128" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "int24", + name: "tickLower", + type: "int24" + }, + { + internalType: "int24", + name: "tickUpper", + type: "int24" + }, + { + internalType: "uint128", + name: "amount", + type: "uint128" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "mint", + outputs: [ + { + internalType: "uint256", + name: "amount0", + type: "uint256" + }, + { + internalType: "uint256", + name: "amount1", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "index", + type: "uint256" + } + ], + name: "observations", + outputs: [ + { + internalType: "uint32", + name: "blockTimestamp", + type: "uint32" + }, + { + internalType: "int56", + name: "tickCumulative", + type: "int56" + }, + { + internalType: "uint160", + name: "secondsPerLiquidityCumulativeX128", + type: "uint160" + }, + { + internalType: "bool", + name: "initialized", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint32[]", + name: "secondsAgos", + type: "uint32[]" + } + ], + name: "observe", + outputs: [ + { + internalType: "int56[]", + name: "tickCumulatives", + type: "int56[]" + }, + { + internalType: "uint160[]", + name: "secondsPerLiquidityCumulativeX128s", + type: "uint160[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "key", + type: "bytes32" + } + ], + name: "positions", + outputs: [ + { + internalType: "uint128", + name: "_liquidity", + type: "uint128" + }, + { + internalType: "uint256", + name: "feeGrowthInside0LastX128", + type: "uint256" + }, + { + internalType: "uint256", + name: "feeGrowthInside1LastX128", + type: "uint256" + }, + { + internalType: "uint128", + name: "tokensOwed0", + type: "uint128" + }, + { + internalType: "uint128", + name: "tokensOwed1", + type: "uint128" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "protocolFees", + outputs: [ + { + internalType: "uint128", + name: "token0", + type: "uint128" + }, + { + internalType: "uint128", + name: "token1", + type: "uint128" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint8", + name: "feeProtocol0", + type: "uint8" + }, + { + internalType: "uint8", + name: "feeProtocol1", + type: "uint8" + } + ], + name: "setFeeProtocol", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "slot0", + outputs: [ + { + internalType: "uint160", + name: "sqrtPriceX96", + type: "uint160" + }, + { + internalType: "int24", + name: "tick", + type: "int24" + }, + { + internalType: "uint16", + name: "observationIndex", + type: "uint16" + }, + { + internalType: "uint16", + name: "observationCardinality", + type: "uint16" + }, + { + internalType: "uint16", + name: "observationCardinalityNext", + type: "uint16" + }, + { + internalType: "uint8", + name: "feeProtocol", + type: "uint8" + }, + { + internalType: "bool", + name: "unlocked", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "int24", + name: "tickLower", + type: "int24" + }, + { + internalType: "int24", + name: "tickUpper", + type: "int24" + } + ], + name: "snapshotCumulativesInside", + outputs: [ + { + internalType: "int56", + name: "tickCumulativeInside", + type: "int56" + }, + { + internalType: "uint160", + name: "secondsPerLiquidityInsideX128", + type: "uint160" + }, + { + internalType: "uint32", + name: "secondsInside", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "bool", + name: "zeroForOne", + type: "bool" + }, + { + internalType: "int256", + name: "amountSpecified", + type: "int256" + }, + { + internalType: "uint160", + name: "sqrtPriceLimitX96", + type: "uint160" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "swap", + outputs: [ + { + internalType: "int256", + name: "amount0", + type: "int256" + }, + { + internalType: "int256", + name: "amount1", + type: "int256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "int16", + name: "wordPosition", + type: "int16" + } + ], + name: "tickBitmap", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "tickSpacing", + outputs: [ + { + internalType: "int24", + name: "", + type: "int24" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "int24", + name: "tick", + type: "int24" + } + ], + name: "ticks", + outputs: [ + { + internalType: "uint128", + name: "liquidityGross", + type: "uint128" + }, + { + internalType: "int128", + name: "liquidityNet", + type: "int128" + }, + { + internalType: "uint256", + name: "feeGrowthOutside0X128", + type: "uint256" + }, + { + internalType: "uint256", + name: "feeGrowthOutside1X128", + type: "uint256" + }, + { + internalType: "int56", + name: "tickCumulativeOutside", + type: "int56" + }, + { + internalType: "uint160", + name: "secondsPerLiquidityOutsideX128", + type: "uint160" + }, + { + internalType: "uint32", + name: "secondsOutside", + type: "uint32" + }, + { + internalType: "bool", + name: "initialized", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "token0", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "token1", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + } +]; +class IUniswapV3Pool__factory { + static createInterface() { + return new Interface(_abi$z); + } + static connect(address, runner) { + return new Contract(address, _abi$z, runner); + } +} +IUniswapV3Pool__factory.abi = _abi$z; + +const _abi$y = [ + { + inputs: [], + name: "denomination", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "commitment", + type: "bytes32" + } + ], + name: "deposit", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [], + name: "token", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes", + name: "proof", + type: "bytes" + }, + { + internalType: "bytes32", + name: "root", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "nullifierHash", + type: "bytes32" + }, + { + internalType: "address payable", + name: "recipient", + type: "address" + }, + { + internalType: "address payable", + name: "relayer", + type: "address" + }, + { + internalType: "uint256", + name: "fee", + type: "uint256" + }, + { + internalType: "uint256", + name: "refund", + type: "uint256" + } + ], + name: "withdraw", + outputs: [], + stateMutability: "payable", + type: "function" + } +]; +class ITornadoInstance__factory { + static createInterface() { + return new Interface(_abi$y); + } + static connect(address, runner) { + return new Contract(address, _abi$y, runner); + } +} +ITornadoInstance__factory.abi = _abi$y; + +const _abi$x = [ + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + } +]; +class IERC20Decimals__factory { + static createInterface() { + return new Interface(_abi$x); + } + static connect(address, runner) { + return new Contract(address, _abi$x, runner); + } +} +IERC20Decimals__factory.abi = _abi$x; + +const _abi$w = [ + { + inputs: [], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "text", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "value", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$n = "0x608060405234801561001057600080fd5b50610278806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80631f1bd692146100465780633fa4f245146100c35780638129fc1c146100dd575b600080fd5b61004e6100e7565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610088578181015183820152602001610070565b50505050905090810190601f1680156100b55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100cb610174565b60408051918252519081900360200190f35b6100e561017a565b005b60018054604080516020600284861615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561016c5780601f106101415761010080835404028352916020019161016c565b820191906000526020600020905b81548152906001019060200180831161014f57829003601f168201915b505050505081565b60005481565b600160008190556040805180820190915260058082526464756d6d7960d81b60209092019182526101ac9291906101af565b50565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106101f057805160ff191683800117855561021d565b8280016001018555821561021d579182015b8281111561021d578251825591602001919060010190610202565b5061022992915061022d565b5090565b5b80821115610229576000815560010161022e56fea26469706673582212204b4d54284aeff9c7c570415da4a9efb9bf7115fe94a322210f9981c1c7ae107a64736f6c634300060c0033"; +const isSuperArgs$n = (xs) => xs.length > 1; +class Dummy__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$n(args)) { + super(...args); + } else { + super(_abi$w, _bytecode$n, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$w); + } + static connect(address, runner) { + return new Contract(address, _abi$w, runner); + } +} +Dummy__factory.bytecode = _bytecode$n; +Dummy__factory.abi = _abi$w; + +const _abi$v = [ + { + inputs: [], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "text", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "value", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$m = "0x608060405234801561001057600080fd5b50610278806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80631f1bd692146100465780633fa4f245146100c35780638129fc1c146100dd575b600080fd5b61004e6100e7565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610088578181015183820152602001610070565b50505050905090810190601f1680156100b55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100cb610174565b60408051918252519081900360200190f35b6100e561017a565b005b60018054604080516020600284861615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561016c5780601f106101415761010080835404028352916020019161016c565b820191906000526020600020905b81548152906001019060200180831161014f57829003601f168201915b505050505081565b60005481565b600260005560408051808201909152600680825265323ab6b6bc9960d11b60209092019182526101ac916001916101af565b50565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106101f057805160ff191683800117855561021d565b8280016001018555821561021d579182015b8281111561021d578251825591602001919060010190610202565b5061022992915061022d565b5090565b5b80821115610229576000815560010161022e56fea2646970667358221220056d994e19772e421a19f4bcf8cb09061d5645867c4c352106bf6b809fb5de3664736f6c634300060c0033"; +const isSuperArgs$m = (xs) => xs.length > 1; +class DummySecond__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$m(args)) { + super(...args); + } else { + super(_abi$v, _bytecode$m, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$v); + } + static connect(address, runner) { + return new Contract(address, _abi$v, runner); + } +} +DummySecond__factory.bytecode = _bytecode$m; +DummySecond__factory.abi = _abi$v; + +const _abi$u = [ + { + inputs: [ + { + internalType: "uint256", + name: "delay", + type: "uint256" + } + ], + name: "setExecutionDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class IGovernance__factory { + static createInterface() { + return new Interface(_abi$u); + } + static connect(address, runner) { + return new Contract(address, _abi$u, runner); + } +} +IGovernance__factory.abi = _abi$u; + +const _abi$t = [ + { + inputs: [], + name: "executeProposal", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$l = "0x608060405234801561001057600080fd5b5060c48061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063373058b814602d575b600080fd5b60336035565b005b6040805163e4917d9f60e01b81526203f48060048201529051309163e4917d9f91602480830192600092919082900301818387803b158015607557600080fd5b505af11580156088573d6000803e3d6000fd5b5050505056fea264697066735822122080cc4a797d58ff69ba6d6a0d2a3849574ef67da2d75c41e66a86d3f6e162209d64736f6c634300060c0033"; +const isSuperArgs$l = (xs) => xs.length > 1; +class ProposalStateChangeGovernance__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$l(args)) { + super(...args); + } else { + super(_abi$t, _bytecode$l, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$t); + } + static connect(address, runner) { + return new Contract( + address, + _abi$t, + runner + ); + } +} +ProposalStateChangeGovernance__factory.bytecode = _bytecode$l; +ProposalStateChangeGovernance__factory.abi = _abi$t; + +const _abi$s = [ + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address" + } + ], + name: "upgradeTo", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class IProxy__factory { + static createInterface() { + return new Interface(_abi$s); + } + static connect(address, runner) { + return new Contract(address, _abi$s, runner); + } +} +IProxy__factory.abi = _abi$s; + +const _abi$r = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + } + ], + name: "Delegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "x", + type: "uint256" + } + ], + name: "Overriden", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "id", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "proposer", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "target", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + indexed: false, + internalType: "string", + name: "description", + type: "string" + } + ], + name: "ProposalCreated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "ProposalExecuted", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + } + ], + name: "Undelegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "voter", + type: "address" + }, + { + indexed: true, + internalType: "bool", + name: "support", + type: "bool" + }, + { + indexed: false, + internalType: "uint256", + name: "votes", + type: "uint256" + } + ], + name: "Voted", + type: "event" + }, + { + inputs: [], + name: "CLOSING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_EXPIRATION", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "PROPOSAL_THRESHOLD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "QUORUM_VOTES", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTE_EXTEND_TIME", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "canWithdrawAfter", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address[]", + name: "from", + type: "address[]" + }, + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castDelegatedVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + } + ], + name: "delegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "delegatedTo", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "execute", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "address", + name: "voter", + type: "address" + } + ], + name: "getReceipt", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "hasVoted", + type: "bool" + }, + { + internalType: "bool", + name: "support", + type: "bool" + }, + { + internalType: "uint256", + name: "votes", + type: "uint256" + } + ], + internalType: "struct Governance.Receipt", + name: "", + type: "tuple" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "_torn", + type: "address" + } + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "latestProposalIds", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "lock", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "lockWithApproval", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "lockedBalance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "newVariable", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "proposalCount", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "proposals", + outputs: [ + { + internalType: "address", + name: "proposer", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "forVotes", + type: "uint256" + }, + { + internalType: "uint256", + name: "againstVotes", + type: "uint256" + }, + { + internalType: "bool", + name: "executed", + type: "bool" + }, + { + internalType: "bool", + name: "extended", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "propose", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "proposeByDelegate", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "closingPeriod", + type: "uint256" + } + ], + name: "setClosingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionDelay", + type: "uint256" + } + ], + name: "setExecutionDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionExpiration", + type: "uint256" + } + ], + name: "setExecutionExpiration", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalThreshold", + type: "uint256" + } + ], + name: "setProposalThreshold", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "quorumVotes", + type: "uint256" + } + ], + name: "setQuorumVotes", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "time_", + type: "uint256" + } + ], + name: "setTimestamp", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "torna", + type: "address" + } + ], + name: "setTorn", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "voteExtendTime", + type: "uint256" + } + ], + name: "setVoteExtendTime", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingDelay", + type: "uint256" + } + ], + name: "setVotingDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingPeriod", + type: "uint256" + } + ], + name: "setVotingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "state", + outputs: [ + { + internalType: "enum Governance.ProposalState", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "time", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "torn", + outputs: [ + { + internalType: "contract TORN", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "undelegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "unlock", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$k = "0x6080604052426041553480156200001557600080fd5b50600054610100900460ff168062000032575062000032620000cd565b8062000041575060005460ff16155b620000695760405162461bcd60e51b8152600401620000609062000114565b60405180910390fd5b600054610100900460ff1615801562000095576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b03191661dead179055620000b3620000d3565b8015620000c6576000805461ff00191690555b5062000162565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b6123ac80620001726000396000f3fe60806040526004361061023b5760003560e01c8063a0a2b5731161012e578063ce25d71c116100ab578063e4917d9f1161006f578063e4917d9f14610664578063ea0217cf14610684578063ece40cc1146106a4578063f0b76892146106c4578063fe0d94c1146106e45761023b565b8063ce25d71c146105d8578063d6159fe5146105ed578063d6f0948c14610602578063da35c66414610622578063e23a9a52146106375761023b565b8063b54426c8116100f2578063b54426c814610538578063b5f6a74314610558578063b859f11b14610578578063c0c0e82014610598578063c4d66de8146105b85761023b565b8063a0a2b573146104b9578063a6c26603146104d9578063a72edda3146104ee578063adf898a41461050e578063b1610d7e146105235761023b565b80636198e339116101bc57806370b0f6601161018057806370b0f6601461042f5780638d7a72f31461044f57806392ab89bb146104645780639a9e3b6e146104795780639ae697bf146104995761023b565b80636198e3391461039857806365da1264146103b8578063671dd275146103e55780636a661755146103fa5780636dc2dc6c1461040f5761023b565b806337f135d71161020357806337f135d7146103015780633e4f49e614610316578063587a6ecb1461034357806358e9fff0146103585780635c19a95c146103785761023b565b8063013cf08b1461024057806302ec8f9e1461027d57806315373e3d1461029f57806316ada547146102bf57806317977c61146102e1575b600080fd5b34801561024c57600080fd5b5061026061025b366004611cd6565b6106f7565b604051610274989796959493929190611de5565b60405180910390f35b34801561028957600080fd5b5061029d610298366004611cd6565b61075c565b005b3480156102ab57600080fd5b5061029d6102ba366004611d1a565b610789565b3480156102cb57600080fd5b506102d4610798565b6040516102749190612323565b3480156102ed57600080fd5b506102d46102fc366004611acd565b61079e565b34801561030d57600080fd5b506102d46107b0565b34801561032257600080fd5b50610336610331366004611cd6565b6107b6565b6040516102749190611ea3565b34801561034f57600080fd5b506102d46108f9565b34801561036457600080fd5b506102d4610373366004611ae8565b6108ff565b34801561038457600080fd5b5061029d610393366004611acd565b61094d565b3480156103a457600080fd5b5061029d6103b3366004611cd6565b610a6f565b3480156103c457600080fd5b506103d86103d3366004611acd565b610ba6565b6040516102749190611d94565b3480156103f157600080fd5b506102d4610bc1565b34801561040657600080fd5b506102d4610bc7565b34801561041b57600080fd5b5061029d61042a366004611cd6565b610bcd565b34801561043b57600080fd5b5061029d61044a366004611cd6565b610c12565b34801561045b57600080fd5b506102d4610c36565b34801561047057600080fd5b5061029d610c3c565b34801561048557600080fd5b5061029d610494366004611cd6565b610cc3565b3480156104a557600080fd5b506102d46104b4366004611acd565b610ce7565b3480156104c557600080fd5b5061029d6104d4366004611cd6565b610cf9565b3480156104e557600080fd5b506102d4610cfe565b3480156104fa57600080fd5b506102d4610509366004611acd565b610d04565b34801561051a57600080fd5b506103d8610d16565b34801561052f57600080fd5b506102d4610d25565b34801561054457600080fd5b5061029d610553366004611cd6565b610d2b565b34801561056457600080fd5b5061029d610573366004611acd565b610d35565b34801561058457600080fd5b5061029d610593366004611bf5565b610d57565b3480156105a457600080fd5b5061029d6105b3366004611cd6565b610e0e565b3480156105c457600080fd5b5061029d6105d3366004611acd565b610e32565b3480156105e457600080fd5b506102d4611075565b3480156105f957600080fd5b506102d461107b565b34801561060e57600080fd5b506102d461061d366004611b48565b611081565b34801561062e57600080fd5b506102d4611097565b34801561064357600080fd5b50610657610652366004611cee565b6110a1565b60405161027491906122fe565b34801561067057600080fd5b5061029d61067f366004611cd6565b611113565b34801561069057600080fd5b5061029d61069f366004611cd6565b611137565b3480156106b057600080fd5b5061029d6106bf366004611cd6565b61115b565b3480156106d057600080fd5b5061029d6106df366004611b96565b61117f565b61029d6106f2366004611cd6565b6111ff565b603d818154811061070457fe5b600091825260209091206008909102018054600182015460028301546003840154600485015460058601546006909601546001600160a01b039586169750949093169491939092919060ff8082169161010090041688565b3330146107845760405162461bcd60e51b815260040161077b90612101565b60405180910390fd5b603555565b610794338383611240565b5050565b60415481565b603e6020526000908152604090205481565b60335481565b60006107c0611097565b82111580156107cf5750600082115b6107eb5760405162461bcd60e51b815260040161077b90612237565b6000603d83815481106107fa57fe5b906000526020600020906008020190508060020154610817611471565b116108265760009150506108f4565b8060030154610833611471565b116108425760019150506108f4565b8060050154816004015411158061086457506035548160050154826004015401105b156108735760029150506108f4565b600681015460ff161561088a5760059150506108f4565b6108af6034546108a9603354846003015461147790919063ffffffff16565b90611477565b6108b7611471565b106108c65760069150506108f4565b60335460038201546108d791611477565b6108df611471565b106108ee5760049150506108f4565b60039150505b919050565b603a5481565b6001600160a01b038381166000908152603c6020526040812054909116331461093a5760405162461bcd60e51b815260040161077b906122c7565b61094584848461149c565b949350505050565b336000818152603c60205260409020546001600160a01b03908116919083161480159061098357506001600160a01b0382163014155b801561099757506001600160a01b03821615155b80156109b55750806001600160a01b0316826001600160a01b031614155b6109d15760405162461bcd60e51b815260040161077b90612138565b6001600160a01b03811615610a17576040516001600160a01b0382169033907f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7290600090a35b336000818152603c602052604080822080546001600160a01b0319166001600160a01b03871690811790915590519092917f4bc154dd35d6a5cb9206482ecb473cdbf2473006d6bce728b9cc0741bcc59ea291a35050565b336000908152603f6020526040902054610a87611471565b11610aa45760405162461bcd60e51b815260040161077b90612064565b60408051808201825260208082527f476f7665726e616e63653a20696e73756666696369656e742062616c616e636581830152336000908152603b9091529190912054610af29183906117ea565b336000818152603b602052604090819020929092558154915163a9059cbb60e01b81526001600160a01b039092169163a9059cbb91610b35918590600401611da8565b602060405180830381600087803b158015610b4f57600080fd5b505af1158015610b63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b879190611cba565b610ba35760405162461bcd60e51b815260040161077b9061209b565b50565b603c602052600090815260409020546001600160a01b031681565b60355481565b60345481565b333014610bec5760405162461bcd60e51b815260040161077b90612101565b6033548110610c0d5760405162461bcd60e51b815260040161077b90612020565b603a55565b333014610c315760405162461bcd60e51b815260040161077b90612101565b603755565b60425481565b336000908152603c60205260409020546001600160a01b031680610c725760405162461bcd60e51b815260040161077b9061227d565b336000818152603c602052604080822080546001600160a01b0319169055516001600160a01b03841692917f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7291a350565b333014610ce25760405162461bcd60e51b815260040161077b90612101565b603455565b603b6020526000908152604090205481565b604155565b60365481565b603f6020526000908152604090205481565b6040546001600160a01b031681565b60385481565b610ba33382611816565b604080546001600160a01b0319166001600160a01b0392909216919091179055565b60005b8351811015610de857336001600160a01b0316603c6000868481518110610d7d57fe5b6020908102919091018101516001600160a01b03908116835290820192909252604001600020541614610dc25760405162461bcd60e51b815260040161077b906122c7565b610de0848281518110610dd157fe5b60200260200101518484611240565b600101610d5a565b50336000908152603b602052604090205415610e0957610e09338383611240565b505050565b333014610e2d5760405162461bcd60e51b815260040161077b90612101565b603955565b600054610100900460ff1680610e4b5750610e4b6118fb565b80610e59575060005460ff16155b610e755760405162461bcd60e51b815260040161077b906121e9565b600054610100900460ff16158015610ea0576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b038085166001600160a01b03199283161783558251610100818101855230825261dead602083019081526000958301868152606084018781526080850188815260a08601898152600160c0880181815260e089018c8152603d80549384018155909c52975160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b16928c169290921790915594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc4860180549190991699169890981790965590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc5830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc682015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc784015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc8830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990910180549351151590920261ff001991151560ff199094169390931716919091179055611060611901565b8015610794576000805461ff00191690555050565b60395481565b60375481565b600061108e33848461149c565b90505b92915050565b603d546000190190565b6110a96119c7565b603d83815481106110b657fe5b600091825260208083206001600160a01b0395909516835260089190910290930160070183526040908190208151606081018352815460ff8082161515835261010090910416151594810194909452600101549083015250919050565b3330146111325760405162461bcd60e51b815260040161077b90612101565b603355565b3330146111565760405162461bcd60e51b815260040161077b90612101565b603855565b33301461117a5760405162461bcd60e51b815260040161077b90612101565b603655565b60408054905163d505accf60e01b81526001600160a01b039091169063d505accf906111bb90899030908a908a908a908a908a90600401611e2b565b600060405180830381600087803b1580156111d557600080fd5b505af11580156111e9573d6000803e3d6000fd5b505050506111f78686611816565b505050505050565b6103e76042556040517fc22c84ebcf25b30190d2b53474def7b552efd2018ef8acaf6bed1b67e8d2be7c90611235908390612323565b60405180910390a150565b600161124b836107b6565b600681111561125657fe5b146112735760405162461bcd60e51b815260040161077b90611f45565b6000603d838154811061128257fe5b600091825260208083206001600160a01b038816845260076008909302019182018152604080842060058401546004850154603b9094529190942054929450101590806112e15760405162461bcd60e51b815260040161077b9061216f565b825460ff1615611330578254610100900460ff1615611317576001830154600485015461130d91611942565b6004850155611330565b6001830154600585015461132a91611942565b60058501555b841561134f5760048401546113459082611477565b6004850155611364565b600584015461135e9082611477565b60058501555b6006840154610100900460ff161580156113945750603954611392611387611471565b600387015490611942565b105b156113d85760058401546004850154111582151581146113d65760068501805461ff001916610100179055603a5460038601546113d091611477565b60038601555b505b8254600160ff19909116811761ff001916610100871515021784558301819055603354603454603a546003870154611423938b9361141e9391926108a992839190611477565b611984565b841515876001600160a01b0316877f7c2de587c00d75474a0c6c6fa96fd3b45dc974cd4e8a75f712bb84c950dce1b5846040516114609190612323565b60405180910390a450505050505050565b60415490565b60008282018381101561108e5760405162461bcd60e51b815260040161077b90611fe9565b6001600160a01b0383166000908152603b60205260408120546036548110156114d75760405162461bcd60e51b815260040161077b90611f8c565b6114e0846119c1565b6114fc5760405162461bcd60e51b815260040161077b906121a6565b6001600160a01b0385166000908152603e6020526040902054801561156e576000611526826107b6565b9050600181600681111561153657fe5b141580156115505750600081600681111561154d57fe5b14155b61156c5760405162461bcd60e51b815260040161077b90611eca565b505b600061157e6037546108a9611471565b905060006115976038548361147790919063ffffffff16565b90506115a16119e7565b506040805161010080820183526001600160a01b03808c1683528a8116602084019081529383018681526060840186815260006080860181815260a0870182815260c0880183815260e08901848152603d80546001810182559086528a5160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b166001600160a01b03199384161790559b517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc48d01805491909a1691161790975594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc58a015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc6890155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc788015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc887015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990950180549251151590930261ff001995151560ff19909316929092179490941617905590611753611097565b82516001600160a01b03166000908152603e60205260409020819055603354603454603a54929350611795928d9261141e9290916108a9919082908a90611477565b896001600160a01b0316817f90ec05050aa23d54ba425e926fe646c318e85825bc400b13a46010abe86eb2f08b87878d6040516117d59493929190611e6c565b60405180910390a39998505050505050505050565b6000818484111561180e5760405162461bcd60e51b815260040161077b9190611eb7565b505050900390565b6040805490516323b872dd60e01b81526001600160a01b03909116906323b872dd9061184a90859030908690600401611dc1565b602060405180830381600087803b15801561186457600080fd5b505af1158015611878573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189c9190611cba565b6118b85760405162461bcd60e51b815260040161077b906120ca565b6001600160a01b0382166000908152603b60205260409020546118db9082611477565b6001600160a01b039092166000908152603b602052604090209190915550565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b600061108e83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506117ea565b6001600160a01b0382166000908152603f6020526040902054811115610794576001600160a01b03919091166000908152603f6020526040902055565b3b151590565b604080516060810182526000808252602082018190529181019190915290565b60405180610100016040528060006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b80356001600160a01b038116811461109157600080fd5b803561109181612368565b600082601f830112611a74578081fd5b813567ffffffffffffffff811115611a8a578182fd5b611a9d601f8201601f191660200161232c565b9150808252836020828501011115611ab457600080fd5b8060208401602084013760009082016020015292915050565b600060208284031215611ade578081fd5b61108e8383611a42565b600080600060608486031215611afc578182fd5b8335611b0781612353565b92506020840135611b1781612353565b9150604084013567ffffffffffffffff811115611b32578182fd5b611b3e86828701611a64565b9150509250925092565b60008060408385031215611b5a578182fd5b8235611b6581612353565b9150602083013567ffffffffffffffff811115611b80578182fd5b611b8c85828601611a64565b9150509250929050565b60008060008060008060c08789031215611bae578182fd5b611bb88888611a42565b95506020870135945060408701359350606087013560ff81168114611bdb578283fd5b9598949750929560808101359460a0909101359350915050565b600080600060608486031215611c09578283fd5b833567ffffffffffffffff80821115611c20578485fd5b818601915086601f830112611c33578485fd5b813581811115611c41578586fd5b60209150818102611c5383820161232c565b8281528381019085850183870186018c1015611c6d57898afd5b8996505b84871015611c9757611c838c82611a42565b835260019690960195918501918501611c71565b5097505050508501359250611cb190508560408601611a59565b90509250925092565b600060208284031215611ccb578081fd5b815161108e81612368565b600060208284031215611ce7578081fd5b5035919050565b60008060408385031215611d00578182fd5b82359150611d118460208501611a42565b90509250929050565b60008060408385031215611d2c578182fd5b823591506020830135611d3e81612368565b809150509250929050565b60008151808452815b81811015611d6e57602081850181015186830182015201611d52565b81811115611d7f5782602083870101525b50601f01601f19169290920160200192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03988916815296909716602087015260408601949094526060850192909252608084015260a0830152151560c082015290151560e08201526101000190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b600060018060a01b038616825284602083015283604083015260806060830152611e996080830184611d49565b9695505050505050565b6020810160078310611eb157fe5b91905290565b60006020825261108e6020830184611d49565b60208082526055908201527f476f7665726e616e63653a3a70726f706f73653a206f6e65206c69766520707260408201527f6f706f73616c207065722070726f706f7365722c20666f756e6420616e20616c6060820152741c9958591e481858dd1a5d99481c1c9bdc1bdcd85b605a1b608082015260a00190565b60208082526027908201527f476f7665726e616e63653a3a5f63617374566f74653a20766f74696e672069736040820152660818db1bdcd95960ca1b606082015260800190565b6020808252603c908201527f476f7665726e616e63653a3a70726f706f73653a2070726f706f73657220766f60408201527f7465732062656c6f772070726f706f73616c207468726573686f6c6400000000606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526024908201527f476f7665726e616e63653a20696e636f727265637420766f7465457874656e6460408201526354696d6560e01b606082015260800190565b6020808252601d908201527f476f7665726e616e63653a20746f6b656e7320617265206c6f636b6564000000604082015260600190565b6020808252601590820152741513d4938e881d1c985b9cd9995c8819985a5b1959605a1b604082015260600190565b60208082526019908201527f544f524e3a207472616e7366657246726f6d206661696c656400000000000000604082015260600190565b60208082526018908201527f476f7665726e616e63653a20756e617574686f72697a65640000000000000000604082015260600190565b6020808252601d908201527f476f7665726e616e63653a20696e76616c69642064656c656761746565000000604082015260600190565b60208082526018908201527f476f7665726e616e63653a2062616c616e636520697320300000000000000000604082015260600190565b60208082526023908201527f476f7665726e616e63653a3a70726f706f73653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526026908201527f476f7665726e616e63653a3a73746174653a20696e76616c69642070726f706f6040820152651cd85b081a5960d21b606082015260800190565b6020808252602a908201527f476f7665726e616e63653a20746f6b656e732061726520616c726561647920756040820152691b99195b1959d85d195960b21b606082015260800190565b6020808252601a908201527f476f7665726e616e63653a206e6f7420617574686f72697a6564000000000000604082015260600190565b8151151581526020808301511515908201526040918201519181019190915260600190565b90815260200190565b60405181810167ffffffffffffffff8111828210171561234b57600080fd5b604052919050565b6001600160a01b0381168114610ba357600080fd5b8015158114610ba357600080fdfea264697066735822122077147b2d24ffd383c4a2d0eb254eb72ba4274421278e284354c4848ff7c9df0164736f6c634300060c0033"; +const isSuperArgs$k = (xs) => xs.length > 1; +class NewImplementation__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$k(args)) { + super(...args); + } else { + super(_abi$r, _bytecode$k, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$r); + } + static connect(address, runner) { + return new Contract(address, _abi$r, runner); + } +} +NewImplementation__factory.bytecode = _bytecode$k; +NewImplementation__factory.abi = _abi$r; + +const _abi$q = [ + { + inputs: [ + { + internalType: "address", + name: "_newLogic", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [], + name: "executeProposal", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "newLogic", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$j = "0x60a060405234801561001057600080fd5b506040516101da3803806101da83398101604081905261002f91610044565b60601b6001600160601b031916608052610072565b600060208284031215610055578081fd5b81516001600160a01b038116811461006b578182fd5b9392505050565b60805160601c610148610092600039806065528060a252506101486000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806305ccb23e1461003b578063373058b814610059575b600080fd5b610043610063565b60405161005091906100fe565b60405180910390f35b610061610087565b005b7f000000000000000000000000000000000000000000000000000000000000000081565b604051631b2ce7f360e11b81523090633659cfe6906100ca907f0000000000000000000000000000000000000000000000000000000000000000906004016100fe565b600060405180830381600087803b1580156100e457600080fd5b505af11580156100f8573d6000803e3d6000fd5b50505050565b6001600160a01b039190911681526020019056fea26469706673582212207d2c2c988cd8f64fa7efb7ef33cfeee3b01f81a501e4a71ae8a63d6a5e269eb664736f6c634300060c0033"; +const isSuperArgs$j = (xs) => xs.length > 1; +class ProposalUpgrade__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$j(args)) { + super(...args); + } else { + super(_abi$q, _bytecode$j, args[0]); + } + } + getDeployTransaction(_newLogic, overrides) { + return super.getDeployTransaction(_newLogic, overrides || {}); + } + deploy(_newLogic, overrides) { + return super.deploy(_newLogic, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$q); + } + static connect(address, runner) { + return new Contract(address, _abi$q, runner); + } +} +ProposalUpgrade__factory.bytecode = _bytecode$j; +ProposalUpgrade__factory.abi = _abi$q; + +const _abi$p = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + } + ], + name: "Delegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "id", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "proposer", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "target", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + indexed: false, + internalType: "string", + name: "description", + type: "string" + } + ], + name: "ProposalCreated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "ProposalExecuted", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + } + ], + name: "Undelegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "voter", + type: "address" + }, + { + indexed: true, + internalType: "bool", + name: "support", + type: "bool" + }, + { + indexed: false, + internalType: "uint256", + name: "votes", + type: "uint256" + } + ], + name: "Voted", + type: "event" + }, + { + inputs: [], + name: "CLOSING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_EXPIRATION", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "PROPOSAL_THRESHOLD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "QUORUM_VOTES", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTE_EXTEND_TIME", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "canWithdrawAfter", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address[]", + name: "from", + type: "address[]" + }, + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castDelegatedVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + } + ], + name: "delegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "delegatedTo", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "execute", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "address", + name: "voter", + type: "address" + } + ], + name: "getReceipt", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "hasVoted", + type: "bool" + }, + { + internalType: "bool", + name: "support", + type: "bool" + }, + { + internalType: "uint256", + name: "votes", + type: "uint256" + } + ], + internalType: "struct Governance.Receipt", + name: "", + type: "tuple" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "_torn", + type: "address" + } + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "latestProposalIds", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "lock", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "lockWithApproval", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "lockedBalance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "proposalCount", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "proposals", + outputs: [ + { + internalType: "address", + name: "proposer", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "forVotes", + type: "uint256" + }, + { + internalType: "uint256", + name: "againstVotes", + type: "uint256" + }, + { + internalType: "bool", + name: "executed", + type: "bool" + }, + { + internalType: "bool", + name: "extended", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "propose", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "proposeByDelegate", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "closingPeriod", + type: "uint256" + } + ], + name: "setClosingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionDelay", + type: "uint256" + } + ], + name: "setExecutionDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionExpiration", + type: "uint256" + } + ], + name: "setExecutionExpiration", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalThreshold", + type: "uint256" + } + ], + name: "setProposalThreshold", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "quorumVotes", + type: "uint256" + } + ], + name: "setQuorumVotes", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "time_", + type: "uint256" + } + ], + name: "setTimestamp", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "torna", + type: "address" + } + ], + name: "setTorn", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "voteExtendTime", + type: "uint256" + } + ], + name: "setVoteExtendTime", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingDelay", + type: "uint256" + } + ], + name: "setVotingDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingPeriod", + type: "uint256" + } + ], + name: "setVotingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "state", + outputs: [ + { + internalType: "enum Governance.ProposalState", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "time", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "torn", + outputs: [ + { + internalType: "contract TORN", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "undelegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "unlock", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$i = "0x6080604052426041553480156200001557600080fd5b50600054610100900460ff168062000032575062000032620000cd565b8062000041575060005460ff16155b620000695760405162461bcd60e51b8152600401620000609062000114565b60405180910390fd5b600054610100900460ff1615801562000095576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b03191661dead179055620000b3620000d3565b8015620000c6576000805461ff00191690555b5062000162565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b6125c980620001726000396000f3fe6080604052600436106102305760003560e01c8063a0a2b5731161012e578063ce25d71c116100ab578063e4917d9f1161006f578063e4917d9f14610644578063ea0217cf14610664578063ece40cc114610684578063f0b76892146106a4578063fe0d94c1146106c457610230565b8063ce25d71c146105b8578063d6159fe5146105cd578063d6f0948c146105e2578063da35c66414610602578063e23a9a521461061757610230565b8063b54426c8116100f2578063b54426c814610518578063b5f6a74314610538578063b859f11b14610558578063c0c0e82014610578578063c4d66de81461059857610230565b8063a0a2b57314610499578063a6c26603146104b9578063a72edda3146104ce578063adf898a4146104ee578063b1610d7e1461050357610230565b80635c19a95c116101bc5780636dc2dc6c116101805780636dc2dc6c1461040457806370b0f6601461042457806392ab89bb146104445780639a9e3b6e146104595780639ae697bf1461047957610230565b80635c19a95c1461036d5780636198e3391461038d57806365da1264146103ad578063671dd275146103da5780636a661755146103ef57610230565b806317977c611161020357806317977c61146102d657806337f135d7146102f65780633e4f49e61461030b578063587a6ecb1461033857806358e9fff01461034d57610230565b8063013cf08b1461023557806302ec8f9e1461027257806315373e3d1461029457806316ada547146102b4575b600080fd5b34801561024157600080fd5b50610255610250366004611e01565b6106d7565b604051610269989796959493929190611f0d565b60405180910390f35b34801561027e57600080fd5b5061029261028d366004611e01565b61073c565b005b3480156102a057600080fd5b506102926102af366004611e45565b610769565b3480156102c057600080fd5b506102c9610778565b6040516102699190612510565b3480156102e257600080fd5b506102c96102f1366004611bf8565b61077e565b34801561030257600080fd5b506102c9610790565b34801561031757600080fd5b5061032b610326366004611e01565b610796565b6040516102699190611fcb565b34801561034457600080fd5b506102c96108d9565b34801561035957600080fd5b506102c9610368366004611c13565b6108df565b34801561037957600080fd5b50610292610388366004611bf8565b61092d565b34801561039957600080fd5b506102926103a8366004611e01565b610a4f565b3480156103b957600080fd5b506103cd6103c8366004611bf8565b610b86565b6040516102699190611ebc565b3480156103e657600080fd5b506102c9610ba1565b3480156103fb57600080fd5b506102c9610ba7565b34801561041057600080fd5b5061029261041f366004611e01565b610bad565b34801561043057600080fd5b5061029261043f366004611e01565b610bf2565b34801561045057600080fd5b50610292610c16565b34801561046557600080fd5b50610292610474366004611e01565b610c9d565b34801561048557600080fd5b506102c9610494366004611bf8565b610cc1565b3480156104a557600080fd5b506102926104b4366004611e01565b610cd3565b3480156104c557600080fd5b506102c9610cd8565b3480156104da57600080fd5b506102c96104e9366004611bf8565b610cde565b3480156104fa57600080fd5b506103cd610cf0565b34801561050f57600080fd5b506102c9610cff565b34801561052457600080fd5b50610292610533366004611e01565b610d05565b34801561054457600080fd5b50610292610553366004611bf8565b610d0f565b34801561056457600080fd5b50610292610573366004611d20565b610d31565b34801561058457600080fd5b50610292610593366004611e01565b610de8565b3480156105a457600080fd5b506102926105b3366004611bf8565b610e0c565b3480156105c457600080fd5b506102c961104f565b3480156105d957600080fd5b506102c9611055565b3480156105ee57600080fd5b506102c96105fd366004611c73565b61105b565b34801561060e57600080fd5b506102c9611071565b34801561062357600080fd5b50610637610632366004611e19565b61107b565b60405161026991906124eb565b34801561065057600080fd5b5061029261065f366004611e01565b6110ed565b34801561067057600080fd5b5061029261067f366004611e01565b611111565b34801561069057600080fd5b5061029261069f366004611e01565b611135565b3480156106b057600080fd5b506102926106bf366004611cc1565b611159565b6102926106d2366004611e01565b6111d9565b603d81815481106106e457fe5b600091825260209091206008909102018054600182015460028301546003840154600485015460058601546006909601546001600160a01b039586169750949093169491939092919060ff8082169161010090041688565b3330146107645760405162461bcd60e51b815260040161075b906122b7565b60405180910390fd5b603555565b61077433838361136b565b5050565b60415481565b603e6020526000908152604090205481565b60335481565b60006107a0611071565b82111580156107af5750600082115b6107cb5760405162461bcd60e51b815260040161075b906123ed565b6000603d83815481106107da57fe5b9060005260206000209060080201905080600201546107f761159c565b116108065760009150506108d4565b806003015461081361159c565b116108225760019150506108d4565b8060050154816004015411158061084457506035548160050154826004015401105b156108535760029150506108d4565b600681015460ff161561086a5760059150506108d4565b61088f60345461088960335484600301546115a290919063ffffffff16565b906115a2565b61089761159c565b106108a65760069150506108d4565b60335460038201546108b7916115a2565b6108bf61159c565b106108ce5760049150506108d4565b60039150505b919050565b603a5481565b6001600160a01b038381166000908152603c6020526040812054909116331461091a5760405162461bcd60e51b815260040161075b9061247d565b6109258484846115c7565b949350505050565b336000818152603c60205260409020546001600160a01b03908116919083161480159061096357506001600160a01b0382163014155b801561097757506001600160a01b03821615155b80156109955750806001600160a01b0316826001600160a01b031614155b6109b15760405162461bcd60e51b815260040161075b906122ee565b6001600160a01b038116156109f7576040516001600160a01b0382169033907f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7290600090a35b336000818152603c602052604080822080546001600160a01b0319166001600160a01b03871690811790915590519092917f4bc154dd35d6a5cb9206482ecb473cdbf2473006d6bce728b9cc0741bcc59ea291a35050565b336000908152603f6020526040902054610a6761159c565b11610a845760405162461bcd60e51b815260040161075b9061221a565b60408051808201825260208082527f476f7665726e616e63653a20696e73756666696369656e742062616c616e636581830152336000908152603b9091529190912054610ad2918390611915565b336000818152603b602052604090819020929092558154915163a9059cbb60e01b81526001600160a01b039092169163a9059cbb91610b15918590600401611ed0565b602060405180830381600087803b158015610b2f57600080fd5b505af1158015610b43573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b679190611de5565b610b835760405162461bcd60e51b815260040161075b90612251565b50565b603c602052600090815260409020546001600160a01b031681565b60355481565b60345481565b333014610bcc5760405162461bcd60e51b815260040161075b906122b7565b6033548110610bed5760405162461bcd60e51b815260040161075b906121d6565b603a55565b333014610c115760405162461bcd60e51b815260040161075b906122b7565b603755565b336000908152603c60205260409020546001600160a01b031680610c4c5760405162461bcd60e51b815260040161075b90612433565b336000818152603c602052604080822080546001600160a01b0319169055516001600160a01b03841692917f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7291a350565b333014610cbc5760405162461bcd60e51b815260040161075b906122b7565b603455565b603b6020526000908152604090205481565b604155565b60365481565b603f6020526000908152604090205481565b6040546001600160a01b031681565b60385481565b610b833382611941565b604080546001600160a01b0319166001600160a01b0392909216919091179055565b60005b8351811015610dc257336001600160a01b0316603c6000868481518110610d5757fe5b6020908102919091018101516001600160a01b03908116835290820192909252604001600020541614610d9c5760405162461bcd60e51b815260040161075b9061247d565b610dba848281518110610dab57fe5b6020026020010151848461136b565b600101610d34565b50336000908152603b602052604090205415610de357610de333838361136b565b505050565b333014610e075760405162461bcd60e51b815260040161075b906122b7565b603955565b600054610100900460ff1680610e255750610e25611a26565b80610e33575060005460ff16155b610e4f5760405162461bcd60e51b815260040161075b9061239f565b600054610100900460ff16158015610e7a576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b038085166001600160a01b03199283161783558251610100818101855230825261dead602083019081526000958301868152606084018781526080850188815260a08601898152600160c0880181815260e089018c8152603d80549384018155909c52975160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b16928c169290921790915594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc4860180549190991699169890981790965590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc5830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc682015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc784015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc8830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990910180549351151590920261ff001991151560ff19909416939093171691909117905561103a611a2c565b8015610774576000805461ff00191690555050565b60395481565b60375481565b60006110683384846115c7565b90505b92915050565b603d546000190190565b611083611af2565b603d838154811061109057fe5b600091825260208083206001600160a01b0395909516835260089190910290930160070183526040908190208151606081018352815460ff8082161515835261010090910416151594810194909452600101549083015250919050565b33301461110c5760405162461bcd60e51b815260040161075b906122b7565b603355565b3330146111305760405162461bcd60e51b815260040161075b906122b7565b603855565b3330146111545760405162461bcd60e51b815260040161075b906122b7565b603655565b60408054905163d505accf60e01b81526001600160a01b039091169063d505accf9061119590899030908a908a908a908a908a90600401611f53565b600060405180830381600087803b1580156111af57600080fd5b505af11580156111c3573d6000803e3d6000fd5b505050506111d18686611941565b505050505050565b60046111e482610796565b60068111156111ef57fe5b1461120c5760405162461bcd60e51b815260040161075b90612035565b6000603d828154811061121b57fe5b600091825260209091206006600890920201908101805460ff191660019081179091558101549091506001600160a01b031661125681611a6d565b6112725760405162461bcd60e51b815260040161075b90611ff2565b60408051600481526024810182526020810180516001600160e01b03166306e60b1760e31b17905290516000916060916001600160a01b038516916112b691611ea0565b600060405180830381855af49150503d80600081146112f1576040519150601f19603f3d011682016040523d82523d6000602084013e6112f6565b606091505b50915091508161133957805115611321578060405162461bcd60e51b815260040161075b9190611fdf565b60405162461bcd60e51b815260040161075b906124b4565b60405185907f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f90600090a25050505050565b600161137683610796565b600681111561138157fe5b1461139e5760405162461bcd60e51b815260040161075b906120fb565b6000603d83815481106113ad57fe5b600091825260208083206001600160a01b038816845260076008909302019182018152604080842060058401546004850154603b90945291909420549294501015908061140c5760405162461bcd60e51b815260040161075b90612325565b825460ff161561145b578254610100900460ff1615611442576001830154600485015461143891611a73565b600485015561145b565b6001830154600585015461145591611a73565b60058501555b841561147a57600484015461147090826115a2565b600485015561148f565b600584015461148990826115a2565b60058501555b6006840154610100900460ff161580156114bf57506039546114bd6114b261159c565b600387015490611a73565b105b156115035760058401546004850154111582151581146115015760068501805461ff001916610100179055603a5460038601546114fb916115a2565b60038601555b505b8254600160ff19909116811761ff001916610100871515021784558301819055603354603454603a54600387015461154e938b93611549939192610889928391906115a2565b611ab5565b841515876001600160a01b0316877f7c2de587c00d75474a0c6c6fa96fd3b45dc974cd4e8a75f712bb84c950dce1b58460405161158b9190612510565b60405180910390a450505050505050565b60415490565b6000828201838110156110685760405162461bcd60e51b815260040161075b9061219f565b6001600160a01b0383166000908152603b60205260408120546036548110156116025760405162461bcd60e51b815260040161075b90612142565b61160b84611a6d565b6116275760405162461bcd60e51b815260040161075b9061235c565b6001600160a01b0385166000908152603e6020526040902054801561169957600061165182610796565b9050600181600681111561166157fe5b1415801561167b5750600081600681111561167857fe5b14155b6116975760405162461bcd60e51b815260040161075b90612080565b505b60006116a960375461088961159c565b905060006116c2603854836115a290919063ffffffff16565b90506116cc611b12565b506040805161010080820183526001600160a01b03808c1683528a8116602084019081529383018681526060840186815260006080860181815260a0870182815260c0880183815260e08901848152603d80546001810182559086528a5160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b166001600160a01b03199384161790559b517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc48d01805491909a1691161790975594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc58a015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc6890155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc788015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc887015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990950180549251151590930261ff001995151560ff1990931692909217949094161790559061187e611071565b82516001600160a01b03166000908152603e60205260409020819055603354603454603a549293506118c0928d92611549929091610889919082908a906115a2565b896001600160a01b0316817f90ec05050aa23d54ba425e926fe646c318e85825bc400b13a46010abe86eb2f08b87878d6040516119009493929190611f94565b60405180910390a39998505050505050505050565b600081848411156119395760405162461bcd60e51b815260040161075b9190611fdf565b505050900390565b6040805490516323b872dd60e01b81526001600160a01b03909116906323b872dd9061197590859030908690600401611ee9565b602060405180830381600087803b15801561198f57600080fd5b505af11580156119a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c79190611de5565b6119e35760405162461bcd60e51b815260040161075b90612280565b6001600160a01b0382166000908152603b6020526040902054611a0690826115a2565b6001600160a01b039092166000908152603b602052604090209190915550565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b3b151590565b600061106883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611915565b6001600160a01b0382166000908152603f6020526040902054811115610774576001600160a01b03919091166000908152603f6020526040902055565b604080516060810182526000808252602082018190529181019190915290565b60405180610100016040528060006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b80356001600160a01b038116811461106b57600080fd5b803561106b81612585565b600082601f830112611b9f578081fd5b813567ffffffffffffffff811115611bb5578182fd5b611bc8601f8201601f1916602001612519565b9150808252836020828501011115611bdf57600080fd5b8060208401602084013760009082016020015292915050565b600060208284031215611c09578081fd5b6110688383611b6d565b600080600060608486031215611c27578182fd5b8335611c3281612570565b92506020840135611c4281612570565b9150604084013567ffffffffffffffff811115611c5d578182fd5b611c6986828701611b8f565b9150509250925092565b60008060408385031215611c85578182fd5b8235611c9081612570565b9150602083013567ffffffffffffffff811115611cab578182fd5b611cb785828601611b8f565b9150509250929050565b60008060008060008060c08789031215611cd9578182fd5b611ce38888611b6d565b95506020870135945060408701359350606087013560ff81168114611d06578283fd5b9598949750929560808101359460a0909101359350915050565b600080600060608486031215611d34578283fd5b833567ffffffffffffffff80821115611d4b578485fd5b818601915086601f830112611d5e578485fd5b813581811115611d6c578586fd5b60209150818102611d7e838201612519565b8281528381019085850183870186018c1015611d9857898afd5b8996505b84871015611dc257611dae8c82611b6d565b835260019690960195918501918501611d9c565b5097505050508501359250611ddc90508560408601611b84565b90509250925092565b600060208284031215611df6578081fd5b815161106881612585565b600060208284031215611e12578081fd5b5035919050565b60008060408385031215611e2b578182fd5b82359150611e3c8460208501611b6d565b90509250929050565b60008060408385031215611e57578182fd5b823591506020830135611e6981612585565b809150509250929050565b60008151808452611e8c816020860160208601612540565b601f01601f19169290920160200192915050565b60008251611eb2818460208701612540565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03988916815296909716602087015260408601949094526060850192909252608084015260a0830152151560c082015290151560e08201526101000190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b600060018060a01b038616825284602083015283604083015260806060830152611fc16080830184611e74565b9695505050505050565b6020810160078310611fd957fe5b91905290565b6000602082526110686020830184611e74565b60208082526023908201527f476f7665726e616e63653a3a657865637574653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602b908201527f476f7665726e616e63653a3a657865637574653a20696e76616c69642070726f60408201526a706f73616c20737461746560a81b606082015260800190565b60208082526055908201527f476f7665726e616e63653a3a70726f706f73653a206f6e65206c69766520707260408201527f6f706f73616c207065722070726f706f7365722c20666f756e6420616e20616c6060820152741c9958591e481858dd1a5d99481c1c9bdc1bdcd85b605a1b608082015260a00190565b60208082526027908201527f476f7665726e616e63653a3a5f63617374566f74653a20766f74696e672069736040820152660818db1bdcd95960ca1b606082015260800190565b6020808252603c908201527f476f7665726e616e63653a3a70726f706f73653a2070726f706f73657220766f60408201527f7465732062656c6f772070726f706f73616c207468726573686f6c6400000000606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526024908201527f476f7665726e616e63653a20696e636f727265637420766f7465457874656e6460408201526354696d6560e01b606082015260800190565b6020808252601d908201527f476f7665726e616e63653a20746f6b656e7320617265206c6f636b6564000000604082015260600190565b6020808252601590820152741513d4938e881d1c985b9cd9995c8819985a5b1959605a1b604082015260600190565b60208082526019908201527f544f524e3a207472616e7366657246726f6d206661696c656400000000000000604082015260600190565b60208082526018908201527f476f7665726e616e63653a20756e617574686f72697a65640000000000000000604082015260600190565b6020808252601d908201527f476f7665726e616e63653a20696e76616c69642064656c656761746565000000604082015260600190565b60208082526018908201527f476f7665726e616e63653a2062616c616e636520697320300000000000000000604082015260600190565b60208082526023908201527f476f7665726e616e63653a3a70726f706f73653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526026908201527f476f7665726e616e63653a3a73746174653a20696e76616c69642070726f706f6040820152651cd85b081a5960d21b606082015260800190565b6020808252602a908201527f476f7665726e616e63653a20746f6b656e732061726520616c726561647920756040820152691b99195b1959d85d195960b21b606082015260800190565b6020808252601a908201527f476f7665726e616e63653a206e6f7420617574686f72697a6564000000000000604082015260600190565b60208082526019908201527f50726f706f73616c20657865637574696f6e206661696c656400000000000000604082015260600190565b8151151581526020808301511515908201526040918201519181019190915260600190565b90815260200190565b60405181810167ffffffffffffffff8111828210171561253857600080fd5b604052919050565b60005b8381101561255b578181015183820152602001612543565b8381111561256a576000848401525b50505050565b6001600160a01b0381168114610b8357600080fd5b8015158114610b8357600080fdfea264697066735822122079a24ea0dc3d5ef34041a37a137cef69305763e031faa841e2db8f078345f2af64736f6c634300060c0033"; +const isSuperArgs$i = (xs) => xs.length > 1; +class MockGovernance__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$i(args)) { + super(...args); + } else { + super(_abi$p, _bytecode$i, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$p); + } + static connect(address, runner) { + return new Contract(address, _abi$p, runner); + } +} +MockGovernance__factory.bytecode = _bytecode$i; +MockGovernance__factory.abi = _abi$p; + +const _abi$o = [ + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "output", + type: "address" + } + ], + name: "Debug", + type: "event" + }, + { + inputs: [], + name: "executeProposal", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$h = "0x608060405234801561001057600080fd5b506103d5806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063373058b814610030575b600080fd5b61003861003a565b005b6000604051610048906100fa565b604051809103906000f080158015610064573d6000803e3d6000fd5b509050806001600160a01b0316638129fc1c6040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156100a257600080fd5b505af11580156100b6573d6000803e3d6000fd5b5050604080516001600160a01b038516815290517f330da4cde831ccab151372275307c2f0cce2bcce846635cd66e6908f10d203639350908190036020019150a150565b610298806101088339019056fe608060405234801561001057600080fd5b50610278806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80631f1bd692146100465780633fa4f245146100c35780638129fc1c146100dd575b600080fd5b61004e6100e7565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610088578181015183820152602001610070565b50505050905090810190601f1680156100b55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100cb610174565b60408051918252519081900360200190f35b6100e561017a565b005b60018054604080516020600284861615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561016c5780601f106101415761010080835404028352916020019161016c565b820191906000526020600020905b81548152906001019060200180831161014f57829003601f168201915b505050505081565b60005481565b600160008190556040805180820190915260058082526464756d6d7960d81b60209092019182526101ac9291906101af565b50565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106101f057805160ff191683800117855561021d565b8280016001018555821561021d579182015b8281111561021d578251825591602001919060010190610202565b5061022992915061022d565b5090565b5b80821115610229576000815560010161022e56fea26469706673582212204b4d54284aeff9c7c570415da4a9efb9bf7115fe94a322210f9981c1c7ae107a64736f6c634300060c0033a26469706673582212205967b156db23a5fd2372953049f5c366f68a9f95cfa116f9fbd6d0c8e7bdaa6364736f6c634300060c0033"; +const isSuperArgs$h = (xs) => xs.length > 1; +class Proposal__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$h(args)) { + super(...args); + } else { + super(_abi$o, _bytecode$h, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$o); + } + static connect(address, runner) { + return new Contract(address, _abi$o, runner); + } +} +Proposal__factory.bytecode = _bytecode$h; +Proposal__factory.abi = _abi$o; + +const _abi$n = [ + { + inputs: [], + name: "CLOSING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_EXPIRATION", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "PROPOSAL_THRESHOLD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "QUORUM_VOTES", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTE_EXTEND_TIME", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "closingPeriod", + type: "uint256" + } + ], + name: "setClosingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionDelay", + type: "uint256" + } + ], + name: "setExecutionDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionExpiration", + type: "uint256" + } + ], + name: "setExecutionExpiration", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalThreshold", + type: "uint256" + } + ], + name: "setProposalThreshold", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "quorumVotes", + type: "uint256" + } + ], + name: "setQuorumVotes", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "voteExtendTime", + type: "uint256" + } + ], + name: "setVoteExtendTime", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingDelay", + type: "uint256" + } + ], + name: "setVotingDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingPeriod", + type: "uint256" + } + ], + name: "setVotingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$g = "0x608060405234801561001057600080fd5b50610563806100206000396000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c8063a6c2660311610097578063d6159fe511610066578063d6159fe5146101e2578063e4917d9f146101ea578063ea0217cf14610207578063ece40cc11461022457610100565b8063a6c26603146101ad578063b1610d7e146101b5578063c0c0e820146101bd578063ce25d71c146101da57610100565b80636a661755116100d35780636a6617551461014e5780636dc2dc6c1461015657806370b0f660146101735780639a9e3b6e1461019057610100565b806302ec8f9e1461010557806337f135d714610124578063587a6ecb1461013e578063671dd27514610146575b600080fd5b6101226004803603602081101561011b57600080fd5b5035610241565b005b61012c610288565b60408051918252519081900360200190f35b61012c61028e565b61012c610294565b61012c61029a565b6101226004803603602081101561016c57600080fd5b50356102a0565b6101226004803603602081101561018957600080fd5b5035610327565b610122600480360360208110156101a657600080fd5b503561036e565b61012c6103b5565b61012c6103bb565b610122600480360360208110156101d357600080fd5b50356103c1565b61012c610408565b61012c61040e565b6101226004803603602081101561020057600080fd5b5035610414565b6101226004803603602081101561021d57600080fd5b503561045b565b6101226004803603602081101561023a57600080fd5b50356104a2565b333014610283576040805162461bcd60e51b8152602060048201526018602482015260008051602061050e833981519152604482015290519081900360640190fd5b600255565b60005481565b60075481565b60025481565b60015481565b3330146102e2576040805162461bcd60e51b8152602060048201526018602482015260008051602061050e833981519152604482015290519081900360640190fd5b60005481106103225760405162461bcd60e51b81526004018080602001828103825260248152602001806104ea6024913960400191505060405180910390fd5b600755565b333014610369576040805162461bcd60e51b8152602060048201526018602482015260008051602061050e833981519152604482015290519081900360640190fd5b600455565b3330146103b0576040805162461bcd60e51b8152602060048201526018602482015260008051602061050e833981519152604482015290519081900360640190fd5b600155565b60035481565b60055481565b333014610403576040805162461bcd60e51b8152602060048201526018602482015260008051602061050e833981519152604482015290519081900360640190fd5b600655565b60065481565b60045481565b333014610456576040805162461bcd60e51b8152602060048201526018602482015260008051602061050e833981519152604482015290519081900360640190fd5b600055565b33301461049d576040805162461bcd60e51b8152602060048201526018602482015260008051602061050e833981519152604482015290519081900360640190fd5b600555565b3330146104e4576040805162461bcd60e51b8152602060048201526018602482015260008051602061050e833981519152604482015290519081900360640190fd5b60035556fe476f7665726e616e63653a20696e636f727265637420766f7465457874656e6454696d65476f7665726e616e63653a20756e617574686f72697a65640000000000000000a26469706673582212208fff4d62d622acc801ece8b6a7cc281f67f5959bf09e0ca68afde2a0ab0bc83164736f6c634300060c0033"; +const isSuperArgs$g = (xs) => xs.length > 1; +class Configuration__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$g(args)) { + super(...args); + } else { + super(_abi$n, _bytecode$g, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$n); + } + static connect(address, runner) { + return new Contract(address, _abi$n, runner); + } +} +Configuration__factory.bytecode = _bytecode$g; +Configuration__factory.abi = _abi$n; + +const _abi$m = [ + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "lockedBalance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + } +]; +class Core__factory { + static createInterface() { + return new Interface(_abi$m); + } + static connect(address, runner) { + return new Contract(address, _abi$m, runner); + } +} +Core__factory.abi = _abi$m; + +const _abi$l = [ + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + } + ], + name: "Delegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + } + ], + name: "Undelegated", + type: "event" + }, + { + inputs: [ + { + internalType: "address[]", + name: "from", + type: "address[]" + }, + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castDelegatedVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + } + ], + name: "delegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "delegatedTo", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "lockedBalance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "proposeByDelegate", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "undelegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class Delegation__factory { + static createInterface() { + return new Interface(_abi$l); + } + static connect(address, runner) { + return new Contract(address, _abi$l, runner); + } +} +Delegation__factory.abi = _abi$l; + +const _abi$k = [ + { + inputs: [], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + } + ], + name: "Delegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "id", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "proposer", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "target", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + indexed: false, + internalType: "string", + name: "description", + type: "string" + } + ], + name: "ProposalCreated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "ProposalExecuted", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + } + ], + name: "Undelegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "voter", + type: "address" + }, + { + indexed: true, + internalType: "bool", + name: "support", + type: "bool" + }, + { + indexed: false, + internalType: "uint256", + name: "votes", + type: "uint256" + } + ], + name: "Voted", + type: "event" + }, + { + inputs: [], + name: "CLOSING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_EXPIRATION", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "PROPOSAL_THRESHOLD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "QUORUM_VOTES", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTE_EXTEND_TIME", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "canWithdrawAfter", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address[]", + name: "from", + type: "address[]" + }, + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castDelegatedVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + } + ], + name: "delegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "delegatedTo", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "execute", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "address", + name: "voter", + type: "address" + } + ], + name: "getReceipt", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "hasVoted", + type: "bool" + }, + { + internalType: "bool", + name: "support", + type: "bool" + }, + { + internalType: "uint256", + name: "votes", + type: "uint256" + } + ], + internalType: "struct Governance.Receipt", + name: "", + type: "tuple" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "_torn", + type: "address" + } + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "latestProposalIds", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "lock", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "lockWithApproval", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "lockedBalance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "proposalCount", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "proposals", + outputs: [ + { + internalType: "address", + name: "proposer", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "forVotes", + type: "uint256" + }, + { + internalType: "uint256", + name: "againstVotes", + type: "uint256" + }, + { + internalType: "bool", + name: "executed", + type: "bool" + }, + { + internalType: "bool", + name: "extended", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "propose", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "proposeByDelegate", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "closingPeriod", + type: "uint256" + } + ], + name: "setClosingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionDelay", + type: "uint256" + } + ], + name: "setExecutionDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionExpiration", + type: "uint256" + } + ], + name: "setExecutionExpiration", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalThreshold", + type: "uint256" + } + ], + name: "setProposalThreshold", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "quorumVotes", + type: "uint256" + } + ], + name: "setQuorumVotes", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "voteExtendTime", + type: "uint256" + } + ], + name: "setVoteExtendTime", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingDelay", + type: "uint256" + } + ], + name: "setVotingDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingPeriod", + type: "uint256" + } + ], + name: "setVotingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "state", + outputs: [ + { + internalType: "enum Governance.ProposalState", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "torn", + outputs: [ + { + internalType: "contract TORN", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "undelegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "unlock", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$f = "0x60806040523480156200001157600080fd5b50600054610100900460ff16806200002e57506200002e620000c9565b806200003d575060005460ff16155b620000655760405162461bcd60e51b81526004016200005c9062000110565b60405180910390fd5b600054610100900460ff1615801562000091576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b03191661dead179055620000af620000cf565b8015620000c2576000805461ff00191690555b506200015e565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b612524806200016e6000396000f3fe60806040526004361061020f5760003560e01c8063a6c2660311610118578063d6159fe5116100a0578063e4917d9f1161006f578063e4917d9f146105ce578063ea0217cf146105ee578063ece40cc11461060e578063f0b768921461062e578063fe0d94c11461064e5761020f565b8063d6159fe514610557578063d6f0948c1461056c578063da35c6641461058c578063e23a9a52146105a15761020f565b8063b54426c8116100e7578063b54426c8146104c2578063b859f11b146104e2578063c0c0e82014610502578063c4d66de814610522578063ce25d71c146105425761020f565b8063a6c2660314610463578063a72edda314610478578063adf898a414610498578063b1610d7e146104ad5761020f565b80636198e3391161019b5780636dc2dc6c1161016a5780636dc2dc6c146103ce57806370b0f660146103ee57806392ab89bb1461040e5780639a9e3b6e146104235780639ae697bf146104435761020f565b80636198e3391461035757806365da126414610377578063671dd275146103a45780636a661755146103b95761020f565b806337f135d7116101e257806337f135d7146102c05780633e4f49e6146102d5578063587a6ecb1461030257806358e9fff0146103175780635c19a95c146103375761020f565b8063013cf08b1461021457806302ec8f9e1461025157806315373e3d1461027357806317977c6114610293575b600080fd5b34801561022057600080fd5b5061023461022f366004611d5c565b610661565b604051610248989796959493929190611e68565b60405180910390f35b34801561025d57600080fd5b5061027161026c366004611d5c565b6106c6565b005b34801561027f57600080fd5b5061027161028e366004611da0565b6106f3565b34801561029f57600080fd5b506102b36102ae366004611b53565b610702565b604051610248919061246b565b3480156102cc57600080fd5b506102b3610714565b3480156102e157600080fd5b506102f56102f0366004611d5c565b61071a565b6040516102489190611f26565b34801561030e57600080fd5b506102b361085d565b34801561032357600080fd5b506102b3610332366004611b6e565b610863565b34801561034357600080fd5b50610271610352366004611b53565b6108b1565b34801561036357600080fd5b50610271610372366004611d5c565b6109d3565b34801561038357600080fd5b50610397610392366004611b53565b610b0a565b6040516102489190611e17565b3480156103b057600080fd5b506102b3610b25565b3480156103c557600080fd5b506102b3610b2b565b3480156103da57600080fd5b506102716103e9366004611d5c565b610b31565b3480156103fa57600080fd5b50610271610409366004611d5c565b610b76565b34801561041a57600080fd5b50610271610b9a565b34801561042f57600080fd5b5061027161043e366004611d5c565b610c21565b34801561044f57600080fd5b506102b361045e366004611b53565b610c45565b34801561046f57600080fd5b506102b3610c57565b34801561048457600080fd5b506102b3610493366004611b53565b610c5d565b3480156104a457600080fd5b50610397610c6f565b3480156104b957600080fd5b506102b3610c7e565b3480156104ce57600080fd5b506102716104dd366004611d5c565b610c84565b3480156104ee57600080fd5b506102716104fd366004611c7b565b610c8e565b34801561050e57600080fd5b5061027161051d366004611d5c565b610d45565b34801561052e57600080fd5b5061027161053d366004611b53565b610d69565b34801561054e57600080fd5b506102b3610fac565b34801561056357600080fd5b506102b3610fb2565b34801561057857600080fd5b506102b3610587366004611bce565b610fb8565b34801561059857600080fd5b506102b3610fce565b3480156105ad57600080fd5b506105c16105bc366004611d74565b610fd8565b6040516102489190612446565b3480156105da57600080fd5b506102716105e9366004611d5c565b61104a565b3480156105fa57600080fd5b50610271610609366004611d5c565b61106e565b34801561061a57600080fd5b50610271610629366004611d5c565b611092565b34801561063a57600080fd5b50610271610649366004611c1c565b6110b6565b61027161065c366004611d5c565b611136565b603d818154811061066e57fe5b600091825260209091206008909102018054600182015460028301546003840154600485015460058601546006909601546001600160a01b039586169750949093169491939092919060ff8082169161010090041688565b3330146106ee5760405162461bcd60e51b81526004016106e590612212565b60405180910390fd5b603555565b6106fe3383836112c8565b5050565b603e6020526000908152604090205481565b60335481565b6000610724610fce565b82111580156107335750600082115b61074f5760405162461bcd60e51b81526004016106e590612348565b6000603d838154811061075e57fe5b90600052602060002090600802019050806002015461077b6114f9565b1161078a576000915050610858565b80600301546107976114f9565b116107a6576001915050610858565b806005015481600401541115806107c857506035548160050154826004015401105b156107d7576002915050610858565b600681015460ff16156107ee576005915050610858565b61081360345461080d60335484600301546114fd90919063ffffffff16565b906114fd565b61081b6114f9565b1061082a576006915050610858565b603354600382015461083b916114fd565b6108436114f9565b10610852576004915050610858565b60039150505b919050565b603a5481565b6001600160a01b038381166000908152603c6020526040812054909116331461089e5760405162461bcd60e51b81526004016106e5906123d8565b6108a9848484611522565b949350505050565b336000818152603c60205260409020546001600160a01b0390811691908316148015906108e757506001600160a01b0382163014155b80156108fb57506001600160a01b03821615155b80156109195750806001600160a01b0316826001600160a01b031614155b6109355760405162461bcd60e51b81526004016106e590612249565b6001600160a01b0381161561097b576040516001600160a01b0382169033907f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7290600090a35b336000818152603c602052604080822080546001600160a01b0319166001600160a01b03871690811790915590519092917f4bc154dd35d6a5cb9206482ecb473cdbf2473006d6bce728b9cc0741bcc59ea291a35050565b336000908152603f60205260409020546109eb6114f9565b11610a085760405162461bcd60e51b81526004016106e590612175565b60408051808201825260208082527f476f7665726e616e63653a20696e73756666696369656e742062616c616e636581830152336000908152603b9091529190912054610a56918390611870565b336000818152603b602052604090819020929092558154915163a9059cbb60e01b81526001600160a01b039092169163a9059cbb91610a99918590600401611e2b565b602060405180830381600087803b158015610ab357600080fd5b505af1158015610ac7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aeb9190611d40565b610b075760405162461bcd60e51b81526004016106e5906121ac565b50565b603c602052600090815260409020546001600160a01b031681565b60355481565b60345481565b333014610b505760405162461bcd60e51b81526004016106e590612212565b6033548110610b715760405162461bcd60e51b81526004016106e590612131565b603a55565b333014610b955760405162461bcd60e51b81526004016106e590612212565b603755565b336000908152603c60205260409020546001600160a01b031680610bd05760405162461bcd60e51b81526004016106e59061238e565b336000818152603c602052604080822080546001600160a01b0319169055516001600160a01b03841692917f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7291a350565b333014610c405760405162461bcd60e51b81526004016106e590612212565b603455565b603b6020526000908152604090205481565b60365481565b603f6020526000908152604090205481565b6040546001600160a01b031681565b60385481565b610b07338261189c565b60005b8351811015610d1f57336001600160a01b0316603c6000868481518110610cb457fe5b6020908102919091018101516001600160a01b03908116835290820192909252604001600020541614610cf95760405162461bcd60e51b81526004016106e5906123d8565b610d17848281518110610d0857fe5b602002602001015184846112c8565b600101610c91565b50336000908152603b602052604090205415610d4057610d403383836112c8565b505050565b333014610d645760405162461bcd60e51b81526004016106e590612212565b603955565b600054610100900460ff1680610d825750610d82611981565b80610d90575060005460ff16155b610dac5760405162461bcd60e51b81526004016106e5906122fa565b600054610100900460ff16158015610dd7576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b038085166001600160a01b03199283161783558251610100818101855230825261dead602083019081526000958301868152606084018781526080850188815260a08601898152600160c0880181815260e089018c8152603d80549384018155909c52975160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b16928c169290921790915594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc4860180549190991699169890981790965590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc5830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc682015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc784015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc8830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990910180549351151590920261ff001991151560ff199094169390931716919091179055610f97611987565b80156106fe576000805461ff00191690555050565b60395481565b60375481565b6000610fc5338484611522565b90505b92915050565b603d546000190190565b610fe0611a4d565b603d8381548110610fed57fe5b600091825260208083206001600160a01b0395909516835260089190910290930160070183526040908190208151606081018352815460ff8082161515835261010090910416151594810194909452600101549083015250919050565b3330146110695760405162461bcd60e51b81526004016106e590612212565b603355565b33301461108d5760405162461bcd60e51b81526004016106e590612212565b603855565b3330146110b15760405162461bcd60e51b81526004016106e590612212565b603655565b60408054905163d505accf60e01b81526001600160a01b039091169063d505accf906110f290899030908a908a908a908a908a90600401611eae565b600060405180830381600087803b15801561110c57600080fd5b505af1158015611120573d6000803e3d6000fd5b5050505061112e868661189c565b505050505050565b60046111418261071a565b600681111561114c57fe5b146111695760405162461bcd60e51b81526004016106e590611f90565b6000603d828154811061117857fe5b600091825260209091206006600890920201908101805460ff191660019081179091558101549091506001600160a01b03166111b3816119c8565b6111cf5760405162461bcd60e51b81526004016106e590611f4d565b60408051600481526024810182526020810180516001600160e01b03166306e60b1760e31b17905290516000916060916001600160a01b0385169161121391611dfb565b600060405180830381855af49150503d806000811461124e576040519150601f19603f3d011682016040523d82523d6000602084013e611253565b606091505b5091509150816112965780511561127e578060405162461bcd60e51b81526004016106e59190611f3a565b60405162461bcd60e51b81526004016106e59061240f565b60405185907f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f90600090a25050505050565b60016112d38361071a565b60068111156112de57fe5b146112fb5760405162461bcd60e51b81526004016106e590612056565b6000603d838154811061130a57fe5b600091825260208083206001600160a01b038816845260076008909302019182018152604080842060058401546004850154603b9094529190942054929450101590806113695760405162461bcd60e51b81526004016106e590612280565b825460ff16156113b8578254610100900460ff161561139f5760018301546004850154611395916119ce565b60048501556113b8565b600183015460058501546113b2916119ce565b60058501555b84156113d75760048401546113cd90826114fd565b60048501556113ec565b60058401546113e690826114fd565b60058501555b6006840154610100900460ff1615801561141c575060395461141a61140f6114f9565b6003870154906119ce565b105b1561146057600584015460048501541115821515811461145e5760068501805461ff001916610100179055603a546003860154611458916114fd565b60038601555b505b8254600160ff19909116811761ff001916610100871515021784558301819055603354603454603a5460038701546114ab938b936114a693919261080d928391906114fd565b611a10565b841515876001600160a01b0316877f7c2de587c00d75474a0c6c6fa96fd3b45dc974cd4e8a75f712bb84c950dce1b5846040516114e8919061246b565b60405180910390a450505050505050565b4290565b600082820183811015610fc55760405162461bcd60e51b81526004016106e5906120fa565b6001600160a01b0383166000908152603b602052604081205460365481101561155d5760405162461bcd60e51b81526004016106e59061209d565b611566846119c8565b6115825760405162461bcd60e51b81526004016106e5906122b7565b6001600160a01b0385166000908152603e602052604090205480156115f45760006115ac8261071a565b905060018160068111156115bc57fe5b141580156115d6575060008160068111156115d357fe5b14155b6115f25760405162461bcd60e51b81526004016106e590611fdb565b505b600061160460375461080d6114f9565b9050600061161d603854836114fd90919063ffffffff16565b9050611627611a6d565b506040805161010080820183526001600160a01b03808c1683528a8116602084019081529383018681526060840186815260006080860181815260a0870182815260c0880183815260e08901848152603d80546001810182559086528a5160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b166001600160a01b03199384161790559b517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc48d01805491909a1691161790975594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc58a015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc6890155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc788015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc887015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990950180549251151590930261ff001995151560ff199093169290921794909416179055906117d9610fce565b82516001600160a01b03166000908152603e60205260409020819055603354603454603a5492935061181b928d926114a692909161080d919082908a906114fd565b896001600160a01b0316817f90ec05050aa23d54ba425e926fe646c318e85825bc400b13a46010abe86eb2f08b87878d60405161185b9493929190611eef565b60405180910390a39998505050505050505050565b600081848411156118945760405162461bcd60e51b81526004016106e59190611f3a565b505050900390565b6040805490516323b872dd60e01b81526001600160a01b03909116906323b872dd906118d090859030908690600401611e44565b602060405180830381600087803b1580156118ea57600080fd5b505af11580156118fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119229190611d40565b61193e5760405162461bcd60e51b81526004016106e5906121db565b6001600160a01b0382166000908152603b602052604090205461196190826114fd565b6001600160a01b039092166000908152603b602052604090209190915550565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b3b151590565b6000610fc583836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611870565b6001600160a01b0382166000908152603f60205260409020548111156106fe576001600160a01b03919091166000908152603f6020526040902055565b604080516060810182526000808252602082018190529181019190915290565b60405180610100016040528060006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b80356001600160a01b0381168114610fc857600080fd5b8035610fc8816124e0565b600082601f830112611afa578081fd5b813567ffffffffffffffff811115611b10578182fd5b611b23601f8201601f1916602001612474565b9150808252836020828501011115611b3a57600080fd5b8060208401602084013760009082016020015292915050565b600060208284031215611b64578081fd5b610fc58383611ac8565b600080600060608486031215611b82578182fd5b8335611b8d816124cb565b92506020840135611b9d816124cb565b9150604084013567ffffffffffffffff811115611bb8578182fd5b611bc486828701611aea565b9150509250925092565b60008060408385031215611be0578182fd5b8235611beb816124cb565b9150602083013567ffffffffffffffff811115611c06578182fd5b611c1285828601611aea565b9150509250929050565b60008060008060008060c08789031215611c34578182fd5b611c3e8888611ac8565b95506020870135945060408701359350606087013560ff81168114611c61578283fd5b9598949750929560808101359460a0909101359350915050565b600080600060608486031215611c8f578283fd5b833567ffffffffffffffff80821115611ca6578485fd5b818601915086601f830112611cb9578485fd5b813581811115611cc7578586fd5b60209150818102611cd9838201612474565b8281528381019085850183870186018c1015611cf357898afd5b8996505b84871015611d1d57611d098c82611ac8565b835260019690960195918501918501611cf7565b5097505050508501359250611d3790508560408601611adf565b90509250925092565b600060208284031215611d51578081fd5b8151610fc5816124e0565b600060208284031215611d6d578081fd5b5035919050565b60008060408385031215611d86578182fd5b82359150611d978460208501611ac8565b90509250929050565b60008060408385031215611db2578182fd5b823591506020830135611dc4816124e0565b809150509250929050565b60008151808452611de781602086016020860161249b565b601f01601f19169290920160200192915050565b60008251611e0d81846020870161249b565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03988916815296909716602087015260408601949094526060850192909252608084015260a0830152151560c082015290151560e08201526101000190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b600060018060a01b038616825284602083015283604083015260806060830152611f1c6080830184611dcf565b9695505050505050565b6020810160078310611f3457fe5b91905290565b600060208252610fc56020830184611dcf565b60208082526023908201527f476f7665726e616e63653a3a657865637574653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602b908201527f476f7665726e616e63653a3a657865637574653a20696e76616c69642070726f60408201526a706f73616c20737461746560a81b606082015260800190565b60208082526055908201527f476f7665726e616e63653a3a70726f706f73653a206f6e65206c69766520707260408201527f6f706f73616c207065722070726f706f7365722c20666f756e6420616e20616c6060820152741c9958591e481858dd1a5d99481c1c9bdc1bdcd85b605a1b608082015260a00190565b60208082526027908201527f476f7665726e616e63653a3a5f63617374566f74653a20766f74696e672069736040820152660818db1bdcd95960ca1b606082015260800190565b6020808252603c908201527f476f7665726e616e63653a3a70726f706f73653a2070726f706f73657220766f60408201527f7465732062656c6f772070726f706f73616c207468726573686f6c6400000000606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526024908201527f476f7665726e616e63653a20696e636f727265637420766f7465457874656e6460408201526354696d6560e01b606082015260800190565b6020808252601d908201527f476f7665726e616e63653a20746f6b656e7320617265206c6f636b6564000000604082015260600190565b6020808252601590820152741513d4938e881d1c985b9cd9995c8819985a5b1959605a1b604082015260600190565b60208082526019908201527f544f524e3a207472616e7366657246726f6d206661696c656400000000000000604082015260600190565b60208082526018908201527f476f7665726e616e63653a20756e617574686f72697a65640000000000000000604082015260600190565b6020808252601d908201527f476f7665726e616e63653a20696e76616c69642064656c656761746565000000604082015260600190565b60208082526018908201527f476f7665726e616e63653a2062616c616e636520697320300000000000000000604082015260600190565b60208082526023908201527f476f7665726e616e63653a3a70726f706f73653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526026908201527f476f7665726e616e63653a3a73746174653a20696e76616c69642070726f706f6040820152651cd85b081a5960d21b606082015260800190565b6020808252602a908201527f476f7665726e616e63653a20746f6b656e732061726520616c726561647920756040820152691b99195b1959d85d195960b21b606082015260800190565b6020808252601a908201527f476f7665726e616e63653a206e6f7420617574686f72697a6564000000000000604082015260600190565b60208082526019908201527f50726f706f73616c20657865637574696f6e206661696c656400000000000000604082015260600190565b8151151581526020808301511515908201526040918201519181019190915260600190565b90815260200190565b60405181810167ffffffffffffffff8111828210171561249357600080fd5b604052919050565b60005b838110156124b657818101518382015260200161249e565b838111156124c5576000848401525b50505050565b6001600160a01b0381168114610b0757600080fd5b8015158114610b0757600080fdfea26469706673582212208c8a57d0dd9da76417112ba79eab1d38dbdf5e0a8bc014651f10bebe82ce8f9b64736f6c634300060c0033"; +const isSuperArgs$f = (xs) => xs.length > 1; +class Governance__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$f(args)) { + super(...args); + } else { + super(_abi$k, _bytecode$f, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$k); + } + static connect(address, runner) { + return new Contract(address, _abi$k, runner); + } +} +Governance__factory.bytecode = _bytecode$f; +Governance__factory.abi = _abi$k; + +const _abi$j = [ + { + inputs: [ + { + internalType: "address", + name: "_gasCompensationVault", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [], + name: "gasCompensationVault", + outputs: [ + { + internalType: "contract IGasCompensationVault", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_gasCompensationsLimit", + type: "uint256" + } + ], + name: "setGasCompensations", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "withdrawFromHelper", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class GasCompensator__factory { + static createInterface() { + return new Interface(_abi$j); + } + static connect(address, runner) { + return new Contract(address, _abi$j, runner); + } +} +GasCompensator__factory.abi = _abi$j; + +const _abi$i = [ + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "gasAmount", + type: "uint256" + } + ], + name: "compensateGas", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "withdrawToGovernance", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class IGasCompensationVault__factory { + static createInterface() { + return new Interface(_abi$i); + } + static connect(address, runner) { + return new Contract( + address, + _abi$i, + runner + ); + } +} +IGasCompensationVault__factory.abi = _abi$i; + +const _abi$h = [ + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "withdrawTorn", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class ITornadoVault__factory { + static createInterface() { + return new Interface(_abi$h); + } + static connect(address, runner) { + return new Contract(address, _abi$h, runner); + } +} +ITornadoVault__factory.abi = _abi$h; + +const _abi$g = [ + { + inputs: [ + { + internalType: "address", + name: "_gasCompLogic", + type: "address" + }, + { + internalType: "address", + name: "_userVault", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + } + ], + name: "Delegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "id", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "proposer", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "target", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + indexed: false, + internalType: "string", + name: "description", + type: "string" + } + ], + name: "ProposalCreated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "ProposalExecuted", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + } + ], + name: "Undelegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "voter", + type: "address" + }, + { + indexed: true, + internalType: "bool", + name: "support", + type: "bool" + }, + { + indexed: false, + internalType: "uint256", + name: "votes", + type: "uint256" + } + ], + name: "Voted", + type: "event" + }, + { + inputs: [], + name: "CLOSING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_EXPIRATION", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "PROPOSAL_THRESHOLD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "QUORUM_VOTES", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTE_EXTEND_TIME", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "canWithdrawAfter", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address[]", + name: "from", + type: "address[]" + }, + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castDelegatedVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "checkIfQuorumReached", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + } + ], + name: "delegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "delegatedTo", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "execute", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [], + name: "gasCompensationVault", + outputs: [ + { + internalType: "contract IGasCompensationVault", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "address", + name: "voter", + type: "address" + } + ], + name: "getReceipt", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "hasVoted", + type: "bool" + }, + { + internalType: "bool", + name: "support", + type: "bool" + }, + { + internalType: "uint256", + name: "votes", + type: "uint256" + } + ], + internalType: "struct Governance.Receipt", + name: "", + type: "tuple" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "hasAccountVoted", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "_torn", + type: "address" + } + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "latestProposalIds", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "lock", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "lockWithApproval", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "lockedBalance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "proposalCount", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "proposals", + outputs: [ + { + internalType: "address", + name: "proposer", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "forVotes", + type: "uint256" + }, + { + internalType: "uint256", + name: "againstVotes", + type: "uint256" + }, + { + internalType: "bool", + name: "executed", + type: "bool" + }, + { + internalType: "bool", + name: "extended", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "propose", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "proposeByDelegate", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "returnMultisigAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "pure", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "closingPeriod", + type: "uint256" + } + ], + name: "setClosingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionDelay", + type: "uint256" + } + ], + name: "setExecutionDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionExpiration", + type: "uint256" + } + ], + name: "setExecutionExpiration", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "gasCompensationsLimit", + type: "uint256" + } + ], + name: "setGasCompensations", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalThreshold", + type: "uint256" + } + ], + name: "setProposalThreshold", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "quorumVotes", + type: "uint256" + } + ], + name: "setQuorumVotes", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "voteExtendTime", + type: "uint256" + } + ], + name: "setVoteExtendTime", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingDelay", + type: "uint256" + } + ], + name: "setVotingDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingPeriod", + type: "uint256" + } + ], + name: "setVotingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "state", + outputs: [ + { + internalType: "enum Governance.ProposalState", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "torn", + outputs: [ + { + internalType: "contract TORN", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "undelegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "unlock", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "userVault", + outputs: [ + { + internalType: "contract ITornadoVault", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "version", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "pure", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "withdrawFromHelper", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + stateMutability: "payable", + type: "receive" + } +]; +const _bytecode$e = "0x60c06040523480156200001157600080fd5b5060405162002e3138038062002e31833981016040819052620000349162000153565b60005482908290610100900460ff1680620000545750620000546200010c565b8062000063575060005460ff16155b6200008b5760405162461bcd60e51b8152600401620000829062000191565b60405180910390fd5b600054610100900460ff16158015620000b7576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b03191661dead179055620000d562000112565b8015620000e8576000805461ff00191690555b506001600160601b0319606091821b811660805291901b1660a05250620001f89050565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b6000806040838503121562000166578182fd5b82516200017381620001df565b60208401519092506200018681620001df565b809150509250929050565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b6001600160a01b0381168114620001f557600080fd5b50565b60805160601c60a05160601c612bf162000240600039806108c55280610e525280610f4a52806114505280611ee1525080610d545280610fb75280611cf75250612bf16000f3fe60806040526004361061026b5760003560e01c80639ae697bf11610144578063d6159fe5116100b6578063e525aa081161007a578063e525aa08146106ff578063ea0217cf1461071f578063ece40cc11461073f578063ef3f8bb11461075f578063f0b768921461077f578063fe0d94c11461079f57610272565b8063d6159fe514610668578063d6f0948c1461067d578063da35c6641461069d578063e23a9a52146106b2578063e4917d9f146106df57610272565b8063b1610d7e11610108578063b1610d7e146105be578063b54426c8146105d3578063b859f11b146105f3578063c0c0e82014610613578063c4d66de814610633578063ce25d71c1461065357610272565b80639ae697bf1461053f5780639daafec71461055f578063a6c2660314610574578063a72edda314610589578063adf898a4146105a957610272565b80635c19a95c116101dd5780636dc2dc6c116101a15780636dc2dc6c1461049557806370b0f660146104b55780638b34a960146104d557806392ab89bb146104ea578063932d5157146104ff5780639a9e3b6e1461051f57610272565b80635c19a95c1461040b5780636198e3391461042b57806365da12641461044b578063671dd2751461046b5780636a6617551461048057610272565b806332687ec11161022f57806332687ec11461034557806337f135d7146103725780633e4f49e61461038757806354fd4d50146103b4578063587a6ecb146103d657806358e9fff0146103eb57610272565b8063013cf08b1461027757806302ec8f9e146102b457806315373e3d146102d657806317977c61146102f657806324b0435f1461032357610272565b3661027257005b600080fd5b34801561028357600080fd5b506102976102923660046123c5565b6107b2565b6040516102ab9897969594939291906124d1565b60405180910390f35b3480156102c057600080fd5b506102d46102cf3660046123c5565b610817565b005b3480156102e257600080fd5b506102d46102f1366004612409565b610844565b34801561030257600080fd5b506103166103113660046121bc565b610947565b6040516102ab9190612b38565b34801561032f57600080fd5b50610338610959565b6040516102ab9190612480565b34801561035157600080fd5b506103656103603660046123c5565b610971565b6040516102ab919061258f565b34801561037e57600080fd5b506103166109bf565b34801561039357600080fd5b506103a76103a23660046123c5565b6109c5565b6040516102ab919061259a565b3480156103c057600080fd5b506103c9610b01565b6040516102ab91906125ae565b3480156103e257600080fd5b50610316610b38565b3480156103f757600080fd5b506103166104063660046121d7565b610b3e565b34801561041757600080fd5b506102d46104263660046121bc565b610b8c565b34801561043757600080fd5b506102d46104463660046123c5565b610cae565b34801561045757600080fd5b506103386104663660046121bc565b610dc0565b34801561047757600080fd5b50610316610ddb565b34801561048c57600080fd5b50610316610de1565b3480156104a157600080fd5b506102d46104b03660046123c5565b610de7565b3480156104c157600080fd5b506102d46104d03660046123c5565b610e2c565b3480156104e157600080fd5b50610338610e50565b3480156104f657600080fd5b506102d4610e74565b34801561050b57600080fd5b506102d461051a3660046123c5565b610efb565b34801561052b57600080fd5b506102d461053a3660046123c5565b610f7f565b34801561054b57600080fd5b5061031661055a3660046121bc565b610fa3565b34801561056b57600080fd5b50610338610fb5565b34801561058057600080fd5b50610316610fd9565b34801561059557600080fd5b506103166105a43660046121bc565b610fdf565b3480156105b557600080fd5b50610338610ff1565b3480156105ca57600080fd5b50610316611000565b3480156105df57600080fd5b506102d46105ee3660046123c5565b611006565b3480156105ff57600080fd5b506102d461060e3660046122e4565b611013565b34801561061f57600080fd5b506102d461062e3660046123c5565b611061565b34801561063f57600080fd5b506102d461064e3660046121bc565b611085565b34801561065f57600080fd5b506103166112c9565b34801561067457600080fd5b506103166112cf565b34801561068957600080fd5b50610316610698366004612237565b6112d5565b3480156106a957600080fd5b506103166112eb565b3480156106be57600080fd5b506106d26106cd3660046123dd565b6112f5565b6040516102ab9190612b13565b3480156106eb57600080fd5b506102d46106fa3660046123c5565b611367565b34801561070b57600080fd5b5061036561071a3660046123dd565b61138b565b34801561072b57600080fd5b506102d461073a3660046123c5565b6113ce565b34801561074b57600080fd5b506102d461075a3660046123c5565b6113f2565b34801561076b57600080fd5b506102d461077a3660046123c5565b611416565b34801561078b57600080fd5b506102d461079a366004612285565b6114a5565b6102d46107ad3660046123c5565b611525565b603d81815481106107bf57fe5b600091825260209091206008909102018054600182015460028301546003840154600485015460058601546006909601546001600160a01b039586169750949093169491939092919060ff8082169161010090041688565b33301461083f5760405162461bcd60e51b815260040161083690612881565b60405180910390fd5b603555565b3361084f833361138b565b158015610862575061086083610971565b155b333214610870576000610874565b6152085b61ffff1681156109355760005a905061088e3387876116b7565b60006108ab6127106108a5856108a55a87906118e8565b9061192a565b60405163a99ce80760e01b81529091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a99ce807906108fc9088908590600401612494565b600060405180830381600087803b15801561091657600080fd5b505af115801561092a573d6000803e3d6000fd5b505050505050610940565b6109403386866116b7565b5050505050565b603e6020526000908152604090205481565b73b04e030140b30c27bcdfaafffa98c57d80eda7b490565b6000603554603d838154811061098357fe5b906000526020600020906008020160050154603d84815481106109a257fe5b90600052602060002090600802016004015401101590505b919050565b60335481565b60006109cf6112eb565b82111580156109de5750600082115b6109fa5760405162461bcd60e51b8152600401610836906129de565b6000603d8381548110610a0957fe5b906000526020600020906008020190508060020154610a2661194f565b11610a355760009150506109ba565b8060030154610a4261194f565b11610a515760019150506109ba565b80600501548160040154111580610a7357506035548160050154826004015401105b15610a825760029150506109ba565b600681015460ff1615610a995760059150506109ba565b610ab86034546108a5603354846003015461192a90919063ffffffff16565b610ac061194f565b10610acf5760069150506109ba565b6033546003820154610ae09161192a565b610ae861194f565b10610af75760049150506109ba565b60039150506109ba565b60408051808201909152601981527f322e6c6f74746572792d616e642d6761732d7570677261646500000000000000602082015290565b603a5481565b6001600160a01b038381166000908152603c60205260408120549091163314610b795760405162461bcd60e51b815260040161083690612a6e565b610b84848484611953565b949350505050565b336000818152603c60205260409020546001600160a01b039081169190831614801590610bc257506001600160a01b0382163014155b8015610bd657506001600160a01b03821615155b8015610bf45750806001600160a01b0316826001600160a01b031614155b610c105760405162461bcd60e51b8152600401610836906128b8565b6001600160a01b03811615610c56576040516001600160a01b0382169033907f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7290600090a35b336000818152603c602052604080822080546001600160a01b0319166001600160a01b03871690811790915590519092917f4bc154dd35d6a5cb9206482ecb473cdbf2473006d6bce728b9cc0741bcc59ea291a35050565b336000908152603f6020526040902054610cc661194f565b11610ce35760405162461bcd60e51b8152600401610836906127e9565b60408051808201825260208082527f476f7665726e616e63653a20696e73756666696369656e742062616c616e636581830152336000908152603b9091529190912054610d31918390611ca1565b336000818152603b6020526040908190209290925590516391fe357360e01b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316916391fe357391610d9291908590600401612494565b600060405180830381600087803b158015610dac57600080fd5b505af1158015610940573d6000803e3d6000fd5b603c602052600090815260409020546001600160a01b031681565b60355481565b60345481565b333014610e065760405162461bcd60e51b815260040161083690612881565b6033548110610e275760405162461bcd60e51b8152600401610836906127a5565b603a55565b333014610e4b5760405162461bcd60e51b815260040161083690612881565b603755565b7f000000000000000000000000000000000000000000000000000000000000000081565b336000908152603c60205260409020546001600160a01b031680610eaa5760405162461bcd60e51b815260040161083690612a24565b336000818152603c602052604080822080546001600160a01b0319169055516001600160a01b03841692917f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7291a350565b610f03610959565b6001600160a01b0316336001600160a01b031614610f335760405162461bcd60e51b8152600401610836906129b7565b604051633a08bde160e21b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063e822f78490610d92908490600401612b38565b333014610f9e5760405162461bcd60e51b815260040161083690612881565b603455565b603b6020526000908152604090205481565b7f000000000000000000000000000000000000000000000000000000000000000081565b60365481565b603f6020526000908152604090205481565b6040546001600160a01b031681565b60385481565b6110103382611ccd565b50565b60008351116110345760405162461bcd60e51b815260040161083690612857565b61105c838383611044863361138b565b158015611057575061105586610971565b155b611dd2565b505050565b3330146110805760405162461bcd60e51b815260040161083690612881565b603955565b600054610100900460ff168061109e575061109e612016565b806110ac575060005460ff16155b6110c85760405162461bcd60e51b815260040161083690612969565b600054610100900460ff161580156110f3576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b038085166001600160a01b03199283161783558251610100818101855230825261dead602083019081526000958301868152606084018781526080850188815260a08601898152600160c0880181815260e089018c8152603d80549384018155909c52975160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b16928c169290921790915594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc4860180549190991699169890981790965590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc5830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc682015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc784015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc8830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990910180549351151590920261ff001991151560ff1990941693909317169190911790556112b361201c565b80156112c5576000805461ff00191690555b5050565b60395481565b60375481565b60006112e2338484611953565b90505b92915050565b603d546000190190565b6112fd6120b6565b603d838154811061130a57fe5b600091825260208083206001600160a01b0395909516835260089190910290930160070183526040908190208151606081018352815460ff8082161515835261010090910416151594810194909452600101549083015250919050565b3330146113865760405162461bcd60e51b815260040161083690612881565b603355565b6000603d838154811061139a57fe5b600091825260208083206001600160a01b03861684526007600890930201919091019052604090205460ff16905092915050565b3330146113ed5760405162461bcd60e51b815260040161083690612881565b603855565b3330146114115760405162461bcd60e51b815260040161083690612881565b603655565b61141e610959565b6001600160a01b0316336001600160a01b03161461144e5760405162461bcd60e51b8152600401610836906129b7565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166108fc611485834761205d565b6040518115909202916000818181858888f1935050505061101057600080fd5b60408054905163d505accf60e01b81526001600160a01b039091169063d505accf906114e190899030908a908a908a908a908a90600401612517565b600060405180830381600087803b1580156114fb57600080fd5b505af115801561150f573d6000803e3d6000fd5b5050505061151d8686611ccd565b505050505050565b6004611530826109c5565b600681111561153b57fe5b146115585760405162461bcd60e51b815260040161083690612604565b6000603d828154811061156757fe5b600091825260209091206006600890920201908101805460ff191660019081179091558101549091506001600160a01b03166115a281612073565b6115be5760405162461bcd60e51b8152600401610836906125c1565b60408051600481526024810182526020810180516001600160e01b03166306e60b1760e31b17905290516000916060916001600160a01b0385169161160291612464565b600060405180830381855af49150503d806000811461163d576040519150601f19603f3d011682016040523d82523d6000602084013e611642565b606091505b5091509150816116855780511561166d578060405162461bcd60e51b815260040161083691906125ae565b60405162461bcd60e51b815260040161083690612aa5565b60405185907f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f90600090a25050505050565b60016116c2836109c5565b60068111156116cd57fe5b146116ea5760405162461bcd60e51b8152600401610836906126ca565b6000603d83815481106116f957fe5b600091825260208083206001600160a01b038816845260076008909302019182018152604080842060058401546004850154603b9094529190942054929450101590806117585760405162461bcd60e51b8152600401610836906128ef565b825460ff16156117a7578254610100900460ff161561178e5760018301546004850154611784916118e8565b60048501556117a7565b600183015460058501546117a1916118e8565b60058501555b84156117c65760048401546117bc908261192a565b60048501556117db565b60058401546117d5908261192a565b60058501555b6006840154610100900460ff1615801561180b57506039546118096117fe61194f565b6003870154906118e8565b105b1561184f57600584015460048501541115821515811461184d5760068501805461ff001916610100179055603a5460038601546118479161192a565b60038601555b505b8254600160ff19909116811761ff001916610100871515021784558301819055603354603454603a54600387015461189a938b936118959391926108a59283919061192a565b612079565b841515876001600160a01b0316877f7c2de587c00d75474a0c6c6fa96fd3b45dc974cd4e8a75f712bb84c950dce1b5846040516118d79190612b38565b60405180910390a450505050505050565b60006112e283836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611ca1565b6000828201838110156112e25760405162461bcd60e51b81526004016108369061276e565b4290565b6001600160a01b0383166000908152603b602052604081205460365481101561198e5760405162461bcd60e51b815260040161083690612711565b61199784612073565b6119b35760405162461bcd60e51b815260040161083690612926565b6001600160a01b0385166000908152603e60205260409020548015611a255760006119dd826109c5565b905060018160068111156119ed57fe5b14158015611a0757506000816006811115611a0457fe5b14155b611a235760405162461bcd60e51b81526004016108369061264f565b505b6000611a356037546108a561194f565b90506000611a4e6038548361192a90919063ffffffff16565b9050611a586120d6565b506040805161010080820183526001600160a01b03808c1683528a8116602084019081529383018681526060840186815260006080860181815260a0870182815260c0880183815260e08901848152603d80546001810182559086528a5160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b166001600160a01b03199384161790559b517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc48d01805491909a1691161790975594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc58a015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc6890155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc788015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc887015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990950180549251151590930261ff001995151560ff19909316929092179490941617905590611c0a6112eb565b82516001600160a01b03166000908152603e60205260409020819055603354603454603a54929350611c4c928d926118959290916108a5919082908a9061192a565b896001600160a01b0316817f90ec05050aa23d54ba425e926fe646c318e85825bc400b13a46010abe86eb2f08b87878d604051611c8c9493929190612558565b60405180910390a39998505050505050505050565b60008184841115611cc55760405162461bcd60e51b815260040161083691906125ae565b505050900390565b6040805490516323b872dd60e01b81526001600160a01b03909116906323b872dd90611d219085907f00000000000000000000000000000000000000000000000000000000000000009086906004016124ad565b602060405180830381600087803b158015611d3b57600080fd5b505af1158015611d4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d7391906123a9565b611d8f5760405162461bcd60e51b815260040161083690612820565b6001600160a01b0382166000908152603b6020526040902054611db2908261192a565b6001600160a01b039092166000908152603b602052604090209190915550565b3381328214611de2576000611de6565b6152085b61ffff168115611f515760005a905060005b8851811015611eaf576000898281518110611e0f57fe5b6020908102919091018101516001600160a01b038082166000908152603c90935260409092205490925016331480611e4f57506001600160a01b03811633145b611e6b5760405162461bcd60e51b815260040161083690612a6e565b861580611e7f5750611e7d898261138b565b155b611e9b5760405162461bcd60e51b815260040161083690612adc565b611ea6818a8a6116b7565b50600101611df8565b506000611ec76127106108a5856108a55a87906118e8565b60405163a99ce80760e01b81529091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a99ce80790611f189088908590600401612494565b600060405180830381600087803b158015611f3257600080fd5b505af1158015611f46573d6000803e3d6000fd5b50505050505061200d565b60005b875181101561200b576000888281518110611f6b57fe5b6020908102919091018101516001600160a01b038082166000908152603c90935260409092205490925016331480611fab57506001600160a01b03811633145b611fc75760405162461bcd60e51b815260040161083690612a6e565b851580611fdb5750611fd9888261138b565b155b611ff75760405162461bcd60e51b815260040161083690612adc565b6120028189896116b7565b50600101611f54565b505b50505050505050565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b600081831061206c57816112e2565b5090919050565b3b151590565b6001600160a01b0382166000908152603f60205260409020548111156112c5576001600160a01b03919091166000908152603f6020526040902055565b604080516060810182526000808252602082018190529181019190915290565b60405180610100016040528060006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b80356001600160a01b03811681146112e557600080fd5b80356112e581612bad565b600082601f830112612163578081fd5b813567ffffffffffffffff811115612179578182fd5b61218c601f8201601f1916602001612b41565b91508082528360208285010111156121a357600080fd5b8060208401602084013760009082016020015292915050565b6000602082840312156121cd578081fd5b6112e28383612131565b6000806000606084860312156121eb578182fd5b83356121f681612b98565b9250602084013561220681612b98565b9150604084013567ffffffffffffffff811115612221578182fd5b61222d86828701612153565b9150509250925092565b60008060408385031215612249578182fd5b823561225481612b98565b9150602083013567ffffffffffffffff81111561226f578182fd5b61227b85828601612153565b9150509250929050565b60008060008060008060c0878903121561229d578182fd5b6122a78888612131565b95506020870135945060408701359350606087013560ff811681146122ca578283fd5b9598949750929560808101359460a0909101359350915050565b6000806000606084860312156122f8578283fd5b833567ffffffffffffffff8082111561230f578485fd5b818601915086601f830112612322578485fd5b813581811115612330578586fd5b60209150818102612342838201612b41565b8281528381019085850183870186018c101561235c57898afd5b8996505b84871015612386576123728c82612131565b835260019690960195918501918501612360565b50975050505085013592506123a090508560408601612148565b90509250925092565b6000602082840312156123ba578081fd5b81516112e281612bad565b6000602082840312156123d6578081fd5b5035919050565b600080604083850312156123ef578182fd5b823591506124008460208501612131565b90509250929050565b6000806040838503121561241b578182fd5b82359150602083013561242d81612bad565b809150509250929050565b60008151808452612450816020860160208601612b68565b601f01601f19169290920160200192915050565b60008251612476818460208701612b68565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03988916815296909716602087015260408601949094526060850192909252608084015260a0830152151560c082015290151560e08201526101000190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b600060018060a01b0386168252846020830152836040830152608060608301526125856080830184612438565b9695505050505050565b901515815260200190565b60208101600783106125a857fe5b91905290565b6000602082526112e26020830184612438565b60208082526023908201527f476f7665726e616e63653a3a657865637574653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602b908201527f476f7665726e616e63653a3a657865637574653a20696e76616c69642070726f60408201526a706f73616c20737461746560a81b606082015260800190565b60208082526055908201527f476f7665726e616e63653a3a70726f706f73653a206f6e65206c69766520707260408201527f6f706f73616c207065722070726f706f7365722c20666f756e6420616e20616c6060820152741c9958591e481858dd1a5d99481c1c9bdc1bdcd85b605a1b608082015260a00190565b60208082526027908201527f476f7665726e616e63653a3a5f63617374566f74653a20766f74696e672069736040820152660818db1bdcd95960ca1b606082015260800190565b6020808252603c908201527f476f7665726e616e63653a3a70726f706f73653a2070726f706f73657220766f60408201527f7465732062656c6f772070726f706f73616c207468726573686f6c6400000000606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526024908201527f476f7665726e616e63653a20696e636f727265637420766f7465457874656e6460408201526354696d6560e01b606082015260800190565b6020808252601d908201527f476f7665726e616e63653a20746f6b656e7320617265206c6f636b6564000000604082015260600190565b60208082526019908201527f544f524e3a207472616e7366657246726f6d206661696c656400000000000000604082015260600190565b60208082526010908201526f43616e206e6f7420626520656d70747960801b604082015260600190565b60208082526018908201527f476f7665726e616e63653a20756e617574686f72697a65640000000000000000604082015260600190565b6020808252601d908201527f476f7665726e616e63653a20696e76616c69642064656c656761746565000000604082015260600190565b60208082526018908201527f476f7665726e616e63653a2062616c616e636520697320300000000000000000604082015260600190565b60208082526023908201527f476f7665726e616e63653a3a70726f706f73653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252600d908201526c6f6e6c79206d756c746973696760981b604082015260600190565b60208082526026908201527f476f7665726e616e63653a3a73746174653a20696e76616c69642070726f706f6040820152651cd85b081a5960d21b606082015260800190565b6020808252602a908201527f476f7665726e616e63653a20746f6b656e732061726520616c726561647920756040820152691b99195b1959d85d195960b21b606082015260800190565b6020808252601a908201527f476f7665726e616e63653a206e6f7420617574686f72697a6564000000000000604082015260600190565b60208082526019908201527f50726f706f73616c20657865637574696f6e206661696c656400000000000000604082015260600190565b60208082526019908201527f476f7665726e616e63653a20766f74656420616c726561647900000000000000604082015260600190565b8151151581526020808301511515908201526040918201519181019190915260600190565b90815260200190565b60405181810167ffffffffffffffff81118282101715612b6057600080fd5b604052919050565b60005b83811015612b83578181015183820152602001612b6b565b83811115612b92576000848401525b50505050565b6001600160a01b038116811461101057600080fd5b801515811461101057600080fdfea2646970667358221220a9ae24380315e86f1632949f167f44c17322fe48a1385357edbfdf8bc543469764736f6c634300060c0033"; +const isSuperArgs$e = (xs) => xs.length > 1; +class GovernanceGasUpgrade__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$e(args)) { + super(...args); + } else { + super(_abi$g, _bytecode$e, args[0]); + } + } + getDeployTransaction(_gasCompLogic, _userVault, overrides) { + return super.getDeployTransaction( + _gasCompLogic, + _userVault, + overrides || {} + ); + } + deploy(_gasCompLogic, _userVault, overrides) { + return super.deploy(_gasCompLogic, _userVault, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$g); + } + static connect(address, runner) { + return new Contract( + address, + _abi$g, + runner + ); + } +} +GovernanceGasUpgrade__factory.bytecode = _bytecode$e; +GovernanceGasUpgrade__factory.abi = _abi$g; + +const _abi$f = [ + { + inputs: [ + { + internalType: "address", + name: "_userVault", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + } + ], + name: "Delegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "id", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "proposer", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "target", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + indexed: false, + internalType: "string", + name: "description", + type: "string" + } + ], + name: "ProposalCreated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "ProposalExecuted", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + } + ], + name: "Undelegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "voter", + type: "address" + }, + { + indexed: true, + internalType: "bool", + name: "support", + type: "bool" + }, + { + indexed: false, + internalType: "uint256", + name: "votes", + type: "uint256" + } + ], + name: "Voted", + type: "event" + }, + { + inputs: [], + name: "CLOSING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_EXPIRATION", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "PROPOSAL_THRESHOLD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "QUORUM_VOTES", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTE_EXTEND_TIME", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "canWithdrawAfter", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address[]", + name: "from", + type: "address[]" + }, + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castDelegatedVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + } + ], + name: "delegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "delegatedTo", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "execute", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "address", + name: "voter", + type: "address" + } + ], + name: "getReceipt", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "hasVoted", + type: "bool" + }, + { + internalType: "bool", + name: "support", + type: "bool" + }, + { + internalType: "uint256", + name: "votes", + type: "uint256" + } + ], + internalType: "struct Governance.Receipt", + name: "", + type: "tuple" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "_torn", + type: "address" + } + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "latestProposalIds", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "lock", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "lockWithApproval", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "lockedBalance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "proposalCount", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "proposals", + outputs: [ + { + internalType: "address", + name: "proposer", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "forVotes", + type: "uint256" + }, + { + internalType: "uint256", + name: "againstVotes", + type: "uint256" + }, + { + internalType: "bool", + name: "executed", + type: "bool" + }, + { + internalType: "bool", + name: "extended", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "propose", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "proposeByDelegate", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "closingPeriod", + type: "uint256" + } + ], + name: "setClosingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionDelay", + type: "uint256" + } + ], + name: "setExecutionDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionExpiration", + type: "uint256" + } + ], + name: "setExecutionExpiration", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalThreshold", + type: "uint256" + } + ], + name: "setProposalThreshold", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "quorumVotes", + type: "uint256" + } + ], + name: "setQuorumVotes", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "voteExtendTime", + type: "uint256" + } + ], + name: "setVoteExtendTime", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingDelay", + type: "uint256" + } + ], + name: "setVotingDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingPeriod", + type: "uint256" + } + ], + name: "setVotingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "state", + outputs: [ + { + internalType: "enum Governance.ProposalState", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "torn", + outputs: [ + { + internalType: "contract TORN", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "undelegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "unlock", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "userVault", + outputs: [ + { + internalType: "contract ITornadoVault", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "version", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "pure", + type: "function" + } +]; +const _bytecode$d = "0x60a06040523480156200001157600080fd5b506040516200277e3803806200277e833981016040819052620000349162000142565b600054610100900460ff168062000050575062000050620000fb565b806200005f575060005460ff16155b620000875760405162461bcd60e51b81526004016200007e9062000172565b60405180910390fd5b600054610100900460ff16158015620000b3576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b03191661dead179055620000d162000101565b8015620000e4576000805461ff00191690555b5060601b6001600160601b031916608052620001c0565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b60006020828403121562000154578081fd5b81516001600160a01b03811681146200016b578182fd5b9392505050565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b60805160601c612596620001e860003980610af15280610cb3528061194752506125966000f3fe6080604052600436106102255760003560e01c80639daafec711610123578063ce25d71c116100ab578063e4917d9f1161006f578063e4917d9f1461061b578063ea0217cf1461063b578063ece40cc11461065b578063f0b768921461067b578063fe0d94c11461069b57610225565b8063ce25d71c1461058f578063d6159fe5146105a4578063d6f0948c146105b9578063da35c664146105d9578063e23a9a52146105ee57610225565b8063b1610d7e116100f2578063b1610d7e146104fa578063b54426c81461050f578063b859f11b1461052f578063c0c0e8201461054f578063c4d66de81461056f57610225565b80639daafec71461049b578063a6c26603146104b0578063a72edda3146104c5578063adf898a4146104e557610225565b80635c19a95c116101b15780636dc2dc6c116101755780636dc2dc6c1461040657806370b0f6601461042657806392ab89bb146104465780639a9e3b6e1461045b5780639ae697bf1461047b57610225565b80635c19a95c1461036f5780636198e3391461038f57806365da1264146103af578063671dd275146103dc5780636a661755146103f157610225565b806337f135d7116101f857806337f135d7146102d65780633e4f49e6146102eb57806354fd4d5014610318578063587a6ecb1461033a57806358e9fff01461034f57610225565b8063013cf08b1461022a57806302ec8f9e1461026757806315373e3d1461028957806317977c61146102a9575b600080fd5b34801561023657600080fd5b5061024a610245366004611dfd565b6106ae565b60405161025e989796959493929190611f09565b60405180910390f35b34801561027357600080fd5b50610287610282366004611dfd565b610713565b005b34801561029557600080fd5b506102876102a4366004611e41565b610740565b3480156102b557600080fd5b506102c96102c4366004611bf4565b61074f565b60405161025e91906124dd565b3480156102e257600080fd5b506102c9610761565b3480156102f757600080fd5b5061030b610306366004611dfd565b610767565b60405161025e9190611fc7565b34801561032457600080fd5b5061032d6108aa565b60405161025e9190611fdb565b34801561034657600080fd5b506102c96108d5565b34801561035b57600080fd5b506102c961036a366004611c0f565b6108db565b34801561037b57600080fd5b5061028761038a366004611bf4565b610929565b34801561039b57600080fd5b506102876103aa366004611dfd565b610a4b565b3480156103bb57600080fd5b506103cf6103ca366004611bf4565b610b64565b60405161025e9190611eb8565b3480156103e857600080fd5b506102c9610b7f565b3480156103fd57600080fd5b506102c9610b85565b34801561041257600080fd5b50610287610421366004611dfd565b610b8b565b34801561043257600080fd5b50610287610441366004611dfd565b610bd0565b34801561045257600080fd5b50610287610bf4565b34801561046757600080fd5b50610287610476366004611dfd565b610c7b565b34801561048757600080fd5b506102c9610496366004611bf4565b610c9f565b3480156104a757600080fd5b506103cf610cb1565b3480156104bc57600080fd5b506102c9610cd5565b3480156104d157600080fd5b506102c96104e0366004611bf4565b610cdb565b3480156104f157600080fd5b506103cf610ced565b34801561050657600080fd5b506102c9610cfc565b34801561051b57600080fd5b5061028761052a366004611dfd565b610d02565b34801561053b57600080fd5b5061028761054a366004611d1c565b610d0f565b34801561055b57600080fd5b5061028761056a366004611dfd565b610dc6565b34801561057b57600080fd5b5061028761058a366004611bf4565b610dea565b34801561059b57600080fd5b506102c961102d565b3480156105b057600080fd5b506102c9611033565b3480156105c557600080fd5b506102c96105d4366004611c6f565b611039565b3480156105e557600080fd5b506102c961104f565b3480156105fa57600080fd5b5061060e610609366004611e15565b611059565b60405161025e91906124b8565b34801561062757600080fd5b50610287610636366004611dfd565b6110cb565b34801561064757600080fd5b50610287610656366004611dfd565b6110ef565b34801561066757600080fd5b50610287610676366004611dfd565b611113565b34801561068757600080fd5b50610287610696366004611cbd565b611137565b6102876106a9366004611dfd565b6111b7565b603d81815481106106bb57fe5b600091825260209091206008909102018054600182015460028301546003840154600485015460058601546006909601546001600160a01b039586169750949093169491939092919060ff8082169161010090041688565b33301461073b5760405162461bcd60e51b815260040161073290612284565b60405180910390fd5b603555565b61074b338383611349565b5050565b603e6020526000908152604090205481565b60335481565b600061077161104f565b82111580156107805750600082115b61079c5760405162461bcd60e51b8152600401610732906123ba565b6000603d83815481106107ab57fe5b9060005260206000209060080201905080600201546107c861157a565b116107d75760009150506108a5565b80600301546107e461157a565b116107f35760019150506108a5565b8060050154816004015411158061081557506035548160050154826004015401105b156108245760029150506108a5565b600681015460ff161561083b5760059150506108a5565b61086060345461085a603354846003015461157e90919063ffffffff16565b9061157e565b61086861157a565b106108775760069150506108a5565b60335460038201546108889161157e565b61089061157a565b1061089f5760049150506108a5565b60039150505b919050565b60408051808201909152601181527019173b30bab63a16b6b4b3b930ba34b7b760791b602082015290565b603a5481565b6001600160a01b038381166000908152603c602052604081205490911633146109165760405162461bcd60e51b81526004016107329061244a565b6109218484846115a3565b949350505050565b336000818152603c60205260409020546001600160a01b03908116919083161480159061095f57506001600160a01b0382163014155b801561097357506001600160a01b03821615155b80156109915750806001600160a01b0316826001600160a01b031614155b6109ad5760405162461bcd60e51b8152600401610732906122bb565b6001600160a01b038116156109f3576040516001600160a01b0382169033907f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7290600090a35b336000818152603c602052604080822080546001600160a01b0319166001600160a01b03871690811790915590519092917f4bc154dd35d6a5cb9206482ecb473cdbf2473006d6bce728b9cc0741bcc59ea291a35050565b336000908152603f6020526040902054610a6361157a565b11610a805760405162461bcd60e51b815260040161073290612216565b60408051808201825260208082527f476f7665726e616e63653a20696e73756666696369656e742062616c616e636581830152336000908152603b9091529190912054610ace9183906118f1565b336000818152603b6020526040908190209290925590516391fe357360e01b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316916391fe357391610b2f91908590600401611ecc565b600060405180830381600087803b158015610b4957600080fd5b505af1158015610b5d573d6000803e3d6000fd5b5050505050565b603c602052600090815260409020546001600160a01b031681565b60355481565b60345481565b333014610baa5760405162461bcd60e51b815260040161073290612284565b6033548110610bcb5760405162461bcd60e51b8152600401610732906121d2565b603a55565b333014610bef5760405162461bcd60e51b815260040161073290612284565b603755565b336000908152603c60205260409020546001600160a01b031680610c2a5760405162461bcd60e51b815260040161073290612400565b336000818152603c602052604080822080546001600160a01b0319169055516001600160a01b03841692917f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7291a350565b333014610c9a5760405162461bcd60e51b815260040161073290612284565b603455565b603b6020526000908152604090205481565b7f000000000000000000000000000000000000000000000000000000000000000081565b60365481565b603f6020526000908152604090205481565b6040546001600160a01b031681565b60385481565b610d0c338261191d565b50565b60005b8351811015610da057336001600160a01b0316603c6000868481518110610d3557fe5b6020908102919091018101516001600160a01b03908116835290820192909252604001600020541614610d7a5760405162461bcd60e51b81526004016107329061244a565b610d98848281518110610d8957fe5b60200260200101518484611349565b600101610d12565b50336000908152603b602052604090205415610dc157610dc1338383611349565b505050565b333014610de55760405162461bcd60e51b815260040161073290612284565b603955565b600054610100900460ff1680610e035750610e03611a22565b80610e11575060005460ff16155b610e2d5760405162461bcd60e51b81526004016107329061236c565b600054610100900460ff16158015610e58576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b038085166001600160a01b03199283161783558251610100818101855230825261dead602083019081526000958301868152606084018781526080850188815260a08601898152600160c0880181815260e089018c8152603d80549384018155909c52975160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b16928c169290921790915594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc4860180549190991699169890981790965590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc5830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc682015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc784015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc8830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990910180549351151590920261ff001991151560ff199094169390931716919091179055611018611a28565b801561074b576000805461ff00191690555050565b60395481565b60375481565b60006110463384846115a3565b90505b92915050565b603d546000190190565b611061611aee565b603d838154811061106e57fe5b600091825260208083206001600160a01b0395909516835260089190910290930160070183526040908190208151606081018352815460ff8082161515835261010090910416151594810194909452600101549083015250919050565b3330146110ea5760405162461bcd60e51b815260040161073290612284565b603355565b33301461110e5760405162461bcd60e51b815260040161073290612284565b603855565b3330146111325760405162461bcd60e51b815260040161073290612284565b603655565b60408054905163d505accf60e01b81526001600160a01b039091169063d505accf9061117390899030908a908a908a908a908a90600401611f4f565b600060405180830381600087803b15801561118d57600080fd5b505af11580156111a1573d6000803e3d6000fd5b505050506111af868661191d565b505050505050565b60046111c282610767565b60068111156111cd57fe5b146111ea5760405162461bcd60e51b815260040161073290612031565b6000603d82815481106111f957fe5b600091825260209091206006600890920201908101805460ff191660019081179091558101549091506001600160a01b031661123481611a69565b6112505760405162461bcd60e51b815260040161073290611fee565b60408051600481526024810182526020810180516001600160e01b03166306e60b1760e31b17905290516000916060916001600160a01b0385169161129491611e9c565b600060405180830381855af49150503d80600081146112cf576040519150601f19603f3d011682016040523d82523d6000602084013e6112d4565b606091505b509150915081611317578051156112ff578060405162461bcd60e51b81526004016107329190611fdb565b60405162461bcd60e51b815260040161073290612481565b60405185907f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f90600090a25050505050565b600161135483610767565b600681111561135f57fe5b1461137c5760405162461bcd60e51b8152600401610732906120f7565b6000603d838154811061138b57fe5b600091825260208083206001600160a01b038816845260076008909302019182018152604080842060058401546004850154603b9094529190942054929450101590806113ea5760405162461bcd60e51b8152600401610732906122f2565b825460ff1615611439578254610100900460ff1615611420576001830154600485015461141691611a6f565b6004850155611439565b6001830154600585015461143391611a6f565b60058501555b841561145857600484015461144e908261157e565b600485015561146d565b6005840154611467908261157e565b60058501555b6006840154610100900460ff1615801561149d575060395461149b61149061157a565b600387015490611a6f565b105b156114e15760058401546004850154111582151581146114df5760068501805461ff001916610100179055603a5460038601546114d99161157e565b60038601555b505b8254600160ff19909116811761ff001916610100871515021784558301819055603354603454603a54600387015461152c938b9361152793919261085a9283919061157e565b611ab1565b841515876001600160a01b0316877f7c2de587c00d75474a0c6c6fa96fd3b45dc974cd4e8a75f712bb84c950dce1b58460405161156991906124dd565b60405180910390a450505050505050565b4290565b6000828201838110156110465760405162461bcd60e51b81526004016107329061219b565b6001600160a01b0383166000908152603b60205260408120546036548110156115de5760405162461bcd60e51b81526004016107329061213e565b6115e784611a69565b6116035760405162461bcd60e51b815260040161073290612329565b6001600160a01b0385166000908152603e6020526040902054801561167557600061162d82610767565b9050600181600681111561163d57fe5b141580156116575750600081600681111561165457fe5b14155b6116735760405162461bcd60e51b81526004016107329061207c565b505b600061168560375461085a61157a565b9050600061169e6038548361157e90919063ffffffff16565b90506116a8611b0e565b506040805161010080820183526001600160a01b03808c1683528a8116602084019081529383018681526060840186815260006080860181815260a0870182815260c0880183815260e08901848152603d80546001810182559086528a5160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b166001600160a01b03199384161790559b517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc48d01805491909a1691161790975594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc58a015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc6890155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc788015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc887015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990950180549251151590930261ff001995151560ff1990931692909217949094161790559061185a61104f565b82516001600160a01b03166000908152603e60205260409020819055603354603454603a5492935061189c928d9261152792909161085a919082908a9061157e565b896001600160a01b0316817f90ec05050aa23d54ba425e926fe646c318e85825bc400b13a46010abe86eb2f08b87878d6040516118dc9493929190611f90565b60405180910390a39998505050505050505050565b600081848411156119155760405162461bcd60e51b81526004016107329190611fdb565b505050900390565b6040805490516323b872dd60e01b81526001600160a01b03909116906323b872dd906119719085907f0000000000000000000000000000000000000000000000000000000000000000908690600401611ee5565b602060405180830381600087803b15801561198b57600080fd5b505af115801561199f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c39190611de1565b6119df5760405162461bcd60e51b81526004016107329061224d565b6001600160a01b0382166000908152603b6020526040902054611a02908261157e565b6001600160a01b039092166000908152603b602052604090209190915550565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b3b151590565b600061104683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506118f1565b6001600160a01b0382166000908152603f602052604090205481111561074b576001600160a01b03919091166000908152603f6020526040902055565b604080516060810182526000808252602082018190529181019190915290565b60405180610100016040528060006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b80356001600160a01b038116811461104957600080fd5b803561104981612552565b600082601f830112611b9b578081fd5b813567ffffffffffffffff811115611bb1578182fd5b611bc4601f8201601f19166020016124e6565b9150808252836020828501011115611bdb57600080fd5b8060208401602084013760009082016020015292915050565b600060208284031215611c05578081fd5b6110468383611b69565b600080600060608486031215611c23578182fd5b8335611c2e8161253d565b92506020840135611c3e8161253d565b9150604084013567ffffffffffffffff811115611c59578182fd5b611c6586828701611b8b565b9150509250925092565b60008060408385031215611c81578182fd5b8235611c8c8161253d565b9150602083013567ffffffffffffffff811115611ca7578182fd5b611cb385828601611b8b565b9150509250929050565b60008060008060008060c08789031215611cd5578182fd5b611cdf8888611b69565b95506020870135945060408701359350606087013560ff81168114611d02578283fd5b9598949750929560808101359460a0909101359350915050565b600080600060608486031215611d30578283fd5b833567ffffffffffffffff80821115611d47578485fd5b818601915086601f830112611d5a578485fd5b813581811115611d68578586fd5b60209150818102611d7a8382016124e6565b8281528381019085850183870186018c1015611d9457898afd5b8996505b84871015611dbe57611daa8c82611b69565b835260019690960195918501918501611d98565b5097505050508501359250611dd890508560408601611b80565b90509250925092565b600060208284031215611df2578081fd5b815161104681612552565b600060208284031215611e0e578081fd5b5035919050565b60008060408385031215611e27578182fd5b82359150611e388460208501611b69565b90509250929050565b60008060408385031215611e53578182fd5b823591506020830135611e6581612552565b809150509250929050565b60008151808452611e8881602086016020860161250d565b601f01601f19169290920160200192915050565b60008251611eae81846020870161250d565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03988916815296909716602087015260408601949094526060850192909252608084015260a0830152151560c082015290151560e08201526101000190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b600060018060a01b038616825284602083015283604083015260806060830152611fbd6080830184611e70565b9695505050505050565b6020810160078310611fd557fe5b91905290565b6000602082526110466020830184611e70565b60208082526023908201527f476f7665726e616e63653a3a657865637574653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602b908201527f476f7665726e616e63653a3a657865637574653a20696e76616c69642070726f60408201526a706f73616c20737461746560a81b606082015260800190565b60208082526055908201527f476f7665726e616e63653a3a70726f706f73653a206f6e65206c69766520707260408201527f6f706f73616c207065722070726f706f7365722c20666f756e6420616e20616c6060820152741c9958591e481858dd1a5d99481c1c9bdc1bdcd85b605a1b608082015260a00190565b60208082526027908201527f476f7665726e616e63653a3a5f63617374566f74653a20766f74696e672069736040820152660818db1bdcd95960ca1b606082015260800190565b6020808252603c908201527f476f7665726e616e63653a3a70726f706f73653a2070726f706f73657220766f60408201527f7465732062656c6f772070726f706f73616c207468726573686f6c6400000000606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526024908201527f476f7665726e616e63653a20696e636f727265637420766f7465457874656e6460408201526354696d6560e01b606082015260800190565b6020808252601d908201527f476f7665726e616e63653a20746f6b656e7320617265206c6f636b6564000000604082015260600190565b60208082526019908201527f544f524e3a207472616e7366657246726f6d206661696c656400000000000000604082015260600190565b60208082526018908201527f476f7665726e616e63653a20756e617574686f72697a65640000000000000000604082015260600190565b6020808252601d908201527f476f7665726e616e63653a20696e76616c69642064656c656761746565000000604082015260600190565b60208082526018908201527f476f7665726e616e63653a2062616c616e636520697320300000000000000000604082015260600190565b60208082526023908201527f476f7665726e616e63653a3a70726f706f73653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526026908201527f476f7665726e616e63653a3a73746174653a20696e76616c69642070726f706f6040820152651cd85b081a5960d21b606082015260800190565b6020808252602a908201527f476f7665726e616e63653a20746f6b656e732061726520616c726561647920756040820152691b99195b1959d85d195960b21b606082015260800190565b6020808252601a908201527f476f7665726e616e63653a206e6f7420617574686f72697a6564000000000000604082015260600190565b60208082526019908201527f50726f706f73616c20657865637574696f6e206661696c656400000000000000604082015260600190565b8151151581526020808301511515908201526040918201519181019190915260600190565b90815260200190565b60405181810167ffffffffffffffff8111828210171561250557600080fd5b604052919050565b60005b83811015612528578181015183820152602001612510565b83811115612537576000848401525b50505050565b6001600160a01b0381168114610d0c57600080fd5b8015158114610d0c57600080fdfea26469706673582212204b0042571b6576e17c0708c8f251958898bb0e0a9f340387b1eed439d732af7264736f6c634300060c0033"; +const isSuperArgs$d = (xs) => xs.length > 1; +class GovernanceVaultUpgrade__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$d(args)) { + super(...args); + } else { + super(_abi$f, _bytecode$d, args[0]); + } + } + getDeployTransaction(_userVault, overrides) { + return super.getDeployTransaction(_userVault, overrides || {}); + } + deploy(_userVault, overrides) { + return super.deploy(_userVault, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$f); + } + static connect(address, runner) { + return new Contract( + address, + _abi$f, + runner + ); + } +} +GovernanceVaultUpgrade__factory.bytecode = _bytecode$d; +GovernanceVaultUpgrade__factory.abi = _abi$f; + +const _abi$e = [ + { + inputs: [ + { + internalType: "address", + name: "account", + type: "address" + }, + { + internalType: "uint256", + name: "amountLockedBeforehand", + type: "uint256" + } + ], + name: "updateRewardsOnLockedBalanceChange", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class ITornadoStakingRewards__factory { + static createInterface() { + return new Interface(_abi$e); + } + static connect(address, runner) { + return new Contract( + address, + _abi$e, + runner + ); + } +} +ITornadoStakingRewards__factory.abi = _abi$e; + +const _abi$d = [ + { + inputs: [ + { + internalType: "address", + name: "stakingRewardsAddress", + type: "address" + }, + { + internalType: "address", + name: "gasCompLogic", + type: "address" + }, + { + internalType: "address", + name: "userVaultAddress", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + } + ], + name: "Delegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "id", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "proposer", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "target", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + indexed: false, + internalType: "string", + name: "description", + type: "string" + } + ], + name: "ProposalCreated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "ProposalExecuted", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "bytes", + name: "errorData", + type: "bytes" + } + ], + name: "RewardUpdateFailed", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + } + ], + name: "RewardUpdateSuccessful", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + } + ], + name: "Undelegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "voter", + type: "address" + }, + { + indexed: true, + internalType: "bool", + name: "support", + type: "bool" + }, + { + indexed: false, + internalType: "uint256", + name: "votes", + type: "uint256" + } + ], + name: "Voted", + type: "event" + }, + { + inputs: [], + name: "CLOSING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_EXPIRATION", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "PROPOSAL_THRESHOLD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "QUORUM_VOTES", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "Staking", + outputs: [ + { + internalType: "contract ITornadoStakingRewards", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTE_EXTEND_TIME", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "canWithdrawAfter", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address[]", + name: "from", + type: "address[]" + }, + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castDelegatedVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "checkIfQuorumReached", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + } + ], + name: "delegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "delegatedTo", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "execute", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [], + name: "gasCompensationVault", + outputs: [ + { + internalType: "contract IGasCompensationVault", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "address", + name: "voter", + type: "address" + } + ], + name: "getReceipt", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "hasVoted", + type: "bool" + }, + { + internalType: "bool", + name: "support", + type: "bool" + }, + { + internalType: "uint256", + name: "votes", + type: "uint256" + } + ], + internalType: "struct Governance.Receipt", + name: "", + type: "tuple" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "hasAccountVoted", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "_torn", + type: "address" + } + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "latestProposalIds", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "lock", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "lockWithApproval", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "lockedBalance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "proposalCount", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "proposals", + outputs: [ + { + internalType: "address", + name: "proposer", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "forVotes", + type: "uint256" + }, + { + internalType: "uint256", + name: "againstVotes", + type: "uint256" + }, + { + internalType: "bool", + name: "executed", + type: "bool" + }, + { + internalType: "bool", + name: "extended", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "propose", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "proposeByDelegate", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "returnMultisigAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "pure", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "closingPeriod", + type: "uint256" + } + ], + name: "setClosingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionDelay", + type: "uint256" + } + ], + name: "setExecutionDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionExpiration", + type: "uint256" + } + ], + name: "setExecutionExpiration", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "gasCompensationsLimit", + type: "uint256" + } + ], + name: "setGasCompensations", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalThreshold", + type: "uint256" + } + ], + name: "setProposalThreshold", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "quorumVotes", + type: "uint256" + } + ], + name: "setQuorumVotes", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "voteExtendTime", + type: "uint256" + } + ], + name: "setVoteExtendTime", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingDelay", + type: "uint256" + } + ], + name: "setVotingDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingPeriod", + type: "uint256" + } + ], + name: "setVotingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "state", + outputs: [ + { + internalType: "enum Governance.ProposalState", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "torn", + outputs: [ + { + internalType: "contract TORN", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "undelegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "unlock", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "userVault", + outputs: [ + { + internalType: "contract ITornadoVault", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "version", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "pure", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "withdrawFromHelper", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + stateMutability: "payable", + type: "receive" + } +]; +const _bytecode$c = "0x60e06040523480156200001157600080fd5b50604051620032a6380380620032a6833981016040819052620000349162000165565b81818181600060019054906101000a900460ff1680620000595750620000596200011e565b8062000068575060005460ff16155b620000905760405162461bcd60e51b81526004016200008790620001b8565b60405180910390fd5b600054610100900460ff16158015620000bc576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b03191661dead179055620000da62000124565b8015620000ed576000805461ff00191690555b506001600160601b0319606091821b811660805291811b821660a0529590951b90941660c052506200021f92505050565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b6000806000606084860312156200017a578283fd5b8351620001878162000206565b60208501519093506200019a8162000206565b6040850151909250620001ad8162000206565b809150509250925092565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b6001600160a01b03811681146200021c57600080fd5b50565b60805160601c60a05160601c60c05160601c6130246200028260003980610cf652806110b7528061169852806117c95250806108e55280610ead5280610fa552806116145280612164525080611040528061200d528061240e52506130246000f3fe6080604052600436106102765760003560e01c80639ae697bf1161014f578063d6159fe5116100c1578063ea0217cf1161007a578063ea0217cf1461072a578063ece40cc11461074a578063ef3f8bb11461076a578063f0b768921461078a578063f57df22e146107aa578063fe0d94c1146107bf5761027d565b8063d6159fe514610673578063d6f0948c14610688578063da35c664146106a8578063e23a9a52146106bd578063e4917d9f146106ea578063e525aa081461070a5761027d565b8063b1610d7e11610113578063b1610d7e146105c9578063b54426c8146105de578063b859f11b146105fe578063c0c0e8201461061e578063c4d66de81461063e578063ce25d71c1461065e5761027d565b80639ae697bf1461054a5780639daafec71461056a578063a6c266031461057f578063a72edda314610594578063adf898a4146105b45761027d565b80635c19a95c116101e85780636dc2dc6c116101ac5780636dc2dc6c146104a057806370b0f660146104c05780638b34a960146104e057806392ab89bb146104f5578063932d51571461050a5780639a9e3b6e1461052a5761027d565b80635c19a95c146104165780636198e3391461043657806365da126414610456578063671dd275146104765780636a6617551461048b5761027d565b806332687ec11161023a57806332687ec11461035057806337f135d71461037d5780633e4f49e61461039257806354fd4d50146103bf578063587a6ecb146103e157806358e9fff0146103f65761027d565b8063013cf08b1461028257806302ec8f9e146102bf57806315373e3d146102e157806317977c611461030157806324b0435f1461032e5761027d565b3661027d57005b600080fd5b34801561028e57600080fd5b506102a261029d3660046127f8565b6107d2565b6040516102b6989796959493929190612904565b60405180910390f35b3480156102cb57600080fd5b506102df6102da3660046127f8565b610837565b005b3480156102ed57600080fd5b506102df6102fc36600461283c565b610864565b34801561030d57600080fd5b5061032161031c3660046125ef565b610967565b6040516102b69190612f6b565b34801561033a57600080fd5b50610343610979565b6040516102b691906128b3565b34801561035c57600080fd5b5061037061036b3660046127f8565b610991565b6040516102b691906129c2565b34801561038957600080fd5b506103216109df565b34801561039e57600080fd5b506103b26103ad3660046127f8565b6109e5565b6040516102b691906129cd565b3480156103cb57600080fd5b506103d4610b21565b6040516102b691906129e1565b3480156103ed57600080fd5b50610321610b58565b34801561040257600080fd5b5061032161041136600461260a565b610b5e565b34801561042257600080fd5b506102df6104313660046125ef565b610bac565b34801561044257600080fd5b506102df6104513660046127f8565b610cce565b34801561046257600080fd5b506103436104713660046125ef565b610e1b565b34801561048257600080fd5b50610321610e36565b34801561049757600080fd5b50610321610e3c565b3480156104ac57600080fd5b506102df6104bb3660046127f8565b610e42565b3480156104cc57600080fd5b506102df6104db3660046127f8565b610e87565b3480156104ec57600080fd5b50610343610eab565b34801561050157600080fd5b506102df610ecf565b34801561051657600080fd5b506102df6105253660046127f8565b610f56565b34801561053657600080fd5b506102df6105453660046127f8565b611008565b34801561055657600080fd5b506103216105653660046125ef565b61102c565b34801561057657600080fd5b5061034361103e565b34801561058b57600080fd5b50610321611062565b3480156105a057600080fd5b506103216105af3660046125ef565b611068565b3480156105c057600080fd5b5061034361107a565b3480156105d557600080fd5b50610321611089565b3480156105ea57600080fd5b506102df6105f93660046127f8565b61108f565b34801561060a57600080fd5b506102df610619366004612717565b6111d8565b34801561062a57600080fd5b506102df6106393660046127f8565b611226565b34801561064a57600080fd5b506102df6106593660046125ef565b61124a565b34801561066a57600080fd5b5061032161148d565b34801561067f57600080fd5b50610321611493565b34801561069457600080fd5b506103216106a336600461266a565b611499565b3480156106b457600080fd5b506103216114af565b3480156106c957600080fd5b506106dd6106d8366004612810565b6114b9565b6040516102b69190612f46565b3480156106f657600080fd5b506102df6107053660046127f8565b61152b565b34801561071657600080fd5b50610370610725366004612810565b61154f565b34801561073657600080fd5b506102df6107453660046127f8565b611592565b34801561075657600080fd5b506102df6107653660046127f8565b6115b6565b34801561077657600080fd5b506102df6107853660046127f8565b6115da565b34801561079657600080fd5b506102df6107a53660046126b8565b61166c565b3480156107b657600080fd5b506103436117c7565b6102df6107cd3660046127f8565b6117eb565b603d81815481106107df57fe5b600091825260209091206008909102018054600182015460028301546003840154600485015460058601546006909601546001600160a01b039586169750949093169491939092919060ff8082169161010090041688565b33301461085f5760405162461bcd60e51b815260040161085690612cb4565b60405180910390fd5b603555565b3361086f833361154f565b158015610882575061088083610991565b155b333214610890576000610894565b6152085b61ffff1681156109555760005a90506108ae33878761197d565b60006108cb6127106108c5856108c55a8790611bae565b90611bf0565b60405163a99ce80760e01b81529091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a99ce8079061091c90889085906004016128c7565b600060405180830381600087803b15801561093657600080fd5b505af115801561094a573d6000803e3d6000fd5b505050505050610960565b61096033868661197d565b5050505050565b603e6020526000908152604090205481565b73b04e030140b30c27bcdfaafffa98c57d80eda7b490565b6000603554603d83815481106109a357fe5b906000526020600020906008020160050154603d84815481106109c257fe5b90600052602060002090600802016004015401101590505b919050565b60335481565b60006109ef6114af565b82111580156109fe5750600082115b610a1a5760405162461bcd60e51b815260040161085690612e11565b6000603d8381548110610a2957fe5b906000526020600020906008020190508060020154610a46611c15565b11610a555760009150506109da565b8060030154610a62611c15565b11610a715760019150506109da565b80600501548160040154111580610a9357506035548160050154826004015401105b15610aa25760029150506109da565b600681015460ff1615610ab95760059150506109da565b610ad86034546108c56033548460030154611bf090919063ffffffff16565b610ae0611c15565b10610aef5760069150506109da565b6033546003820154610b0091611bf0565b610b08611c15565b10610b175760049150506109da565b60039150506109da565b60408051808201909152601981527f322e6c6f74746572792d616e642d6761732d7570677261646500000000000000602082015290565b603a5481565b6001600160a01b038381166000908152603c60205260408120549091163314610b995760405162461bcd60e51b815260040161085690612ea1565b610ba4848484611c19565b949350505050565b336000818152603c60205260409020546001600160a01b039081169190831614801590610be257506001600160a01b0382163014155b8015610bf657506001600160a01b03821615155b8015610c145750806001600160a01b0316826001600160a01b031614155b610c305760405162461bcd60e51b815260040161085690612ceb565b6001600160a01b03811615610c76576040516001600160a01b0382169033907f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7290600090a35b336000818152603c602052604080822080546001600160a01b0319166001600160a01b03871690811790915590519092917f4bc154dd35d6a5cb9206482ecb473cdbf2473006d6bce728b9cc0741bcc59ea291a35050565b336000818152603b60205260409081902054905163e113335f60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163e113335f91610d2b9185916004016128c7565b600060405180830381600087803b158015610d4557600080fd5b505af1925050508015610d56575060015b610dd9573d808015610d84576040519150601f19603f3d011682016040523d82523d6000602084013e610d89565b606091505b5080604051610d989190612897565b604051908190038120906001600160a01b038416907f5a6216e80d86159dc87dcebfe519205477a94005b7d9d6bd313606450a5344f690600090a350610e0e565b6040516001600160a01b038216907f9b227b0c1ae308b34f72d4fdf9a1943fa769ff4814933595e7bc5230a117698b90600090a25b610e1782611f67565b5050565b603c602052600090815260409020546001600160a01b031681565b60355481565b60345481565b333014610e615760405162461bcd60e51b815260040161085690612cb4565b6033548110610e825760405162461bcd60e51b815260040161085690612bd8565b603a55565b333014610ea65760405162461bcd60e51b815260040161085690612cb4565b603755565b7f000000000000000000000000000000000000000000000000000000000000000081565b336000908152603c60205260409020546001600160a01b031680610f055760405162461bcd60e51b815260040161085690612e57565b336000818152603c602052604080822080546001600160a01b0319169055516001600160a01b03841692917f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7291a350565b610f5e610979565b6001600160a01b0316336001600160a01b031614610f8e5760405162461bcd60e51b815260040161085690612dea565b604051633a08bde160e21b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063e822f78490610fda908490600401612f6b565b600060405180830381600087803b158015610ff457600080fd5b505af1158015610960573d6000803e3d6000fd5b3330146110275760405162461bcd60e51b815260040161085690612cb4565b603455565b603b6020526000908152604090205481565b7f000000000000000000000000000000000000000000000000000000000000000081565b60365481565b603f6020526000908152604090205481565b6040546001600160a01b031681565b60385481565b336000818152603b60205260409081902054905163e113335f60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163e113335f916110ec9185916004016128c7565b600060405180830381600087803b15801561110657600080fd5b505af1925050508015611117575060015b61119a573d808015611145576040519150601f19603f3d011682016040523d82523d6000602084013e61114a565b606091505b50806040516111599190612897565b604051908190038120906001600160a01b038416907f5a6216e80d86159dc87dcebfe519205477a94005b7d9d6bd313606450a5344f690600090a3506111cf565b6040516001600160a01b038216907f9b227b0c1ae308b34f72d4fdf9a1943fa769ff4814933595e7bc5230a117698b90600090a25b610e178261204b565b60008351116111f95760405162461bcd60e51b815260040161085690612c8a565b611221838383611209863361154f565b15801561121c575061121a86610991565b155b612055565b505050565b3330146112455760405162461bcd60e51b815260040161085690612cb4565b603955565b600054610100900460ff16806112635750611263612298565b80611271575060005460ff16155b61128d5760405162461bcd60e51b815260040161085690612d9c565b600054610100900460ff161580156112b8576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b038085166001600160a01b03199283161783558251610100818101855230825261dead602083019081526000958301868152606084018781526080850188815260a08601898152600160c0880181815260e089018c8152603d80549384018155909c52975160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b16928c169290921790915594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc4860180549190991699169890981790965590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc5830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc682015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc784015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc8830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990910180549351151590920261ff001991151560ff19909416939093171691909117905561147861229e565b8015610e17576000805461ff00191690555050565b60395481565b60375481565b60006114a6338484611c19565b90505b92915050565b603d546000190190565b6114c16124e9565b603d83815481106114ce57fe5b600091825260208083206001600160a01b0395909516835260089190910290930160070183526040908190208151606081018352815460ff8082161515835261010090910416151594810194909452600101549083015250919050565b33301461154a5760405162461bcd60e51b815260040161085690612cb4565b603355565b6000603d838154811061155e57fe5b600091825260208083206001600160a01b03861684526007600890930201919091019052604090205460ff16905092915050565b3330146115b15760405162461bcd60e51b815260040161085690612cb4565b603855565b3330146115d55760405162461bcd60e51b815260040161085690612cb4565b603655565b6115e2610979565b6001600160a01b0316336001600160a01b0316146116125760405162461bcd60e51b815260040161085690612dea565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166108fc61164983476122df565b6040518115909202916000818181858888f1935050505061166957600080fd5b50565b6001600160a01b038087166000908152603b60205260409081902054905163e113335f60e01b815288927f0000000000000000000000000000000000000000000000000000000000000000169163e113335f916116cd9185916004016128c7565b600060405180830381600087803b1580156116e757600080fd5b505af19250505080156116f8575060015b61177b573d808015611726576040519150601f19603f3d011682016040523d82523d6000602084013e61172b565b606091505b508060405161173a9190612897565b604051908190038120906001600160a01b038416907f5a6216e80d86159dc87dcebfe519205477a94005b7d9d6bd313606450a5344f690600090a3506117b0565b6040516001600160a01b038216907f9b227b0c1ae308b34f72d4fdf9a1943fa769ff4814933595e7bc5230a117698b90600090a25b6117be8787878787876122f5565b50505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60046117f6826109e5565b600681111561180157fe5b1461181e5760405162461bcd60e51b815260040161085690612a37565b6000603d828154811061182d57fe5b600091825260209091206006600890920201908101805460ff191660019081179091558101549091506001600160a01b031661186881612375565b6118845760405162461bcd60e51b8152600401610856906129f4565b60408051600481526024810182526020810180516001600160e01b03166306e60b1760e31b17905290516000916060916001600160a01b038516916118c891612897565b600060405180830381855af49150503d8060008114611903576040519150601f19603f3d011682016040523d82523d6000602084013e611908565b606091505b50915091508161194b57805115611933578060405162461bcd60e51b815260040161085691906129e1565b60405162461bcd60e51b815260040161085690612ed8565b60405185907f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f90600090a25050505050565b6001611988836109e5565b600681111561199357fe5b146119b05760405162461bcd60e51b815260040161085690612afd565b6000603d83815481106119bf57fe5b600091825260208083206001600160a01b038816845260076008909302019182018152604080842060058401546004850154603b909452919094205492945010159080611a1e5760405162461bcd60e51b815260040161085690612d22565b825460ff1615611a6d578254610100900460ff1615611a545760018301546004850154611a4a91611bae565b6004850155611a6d565b60018301546005850154611a6791611bae565b60058501555b8415611a8c576004840154611a829082611bf0565b6004850155611aa1565b6005840154611a9b9082611bf0565b60058501555b6006840154610100900460ff16158015611ad15750603954611acf611ac4611c15565b600387015490611bae565b105b15611b15576005840154600485015411158215158114611b135760068501805461ff001916610100179055603a546003860154611b0d91611bf0565b60038601555b505b8254600160ff19909116811761ff001916610100871515021784558301819055603354603454603a546003870154611b60938b93611b5b9391926108c592839190611bf0565b61237b565b841515876001600160a01b0316877f7c2de587c00d75474a0c6c6fa96fd3b45dc974cd4e8a75f712bb84c950dce1b584604051611b9d9190612f6b565b60405180910390a450505050505050565b60006114a683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506123b8565b6000828201838110156114a65760405162461bcd60e51b815260040161085690612ba1565b4290565b6001600160a01b0383166000908152603b6020526040812054603654811015611c545760405162461bcd60e51b815260040161085690612b44565b611c5d84612375565b611c795760405162461bcd60e51b815260040161085690612d59565b6001600160a01b0385166000908152603e60205260409020548015611ceb576000611ca3826109e5565b90506001816006811115611cb357fe5b14158015611ccd57506000816006811115611cca57fe5b14155b611ce95760405162461bcd60e51b815260040161085690612a82565b505b6000611cfb6037546108c5611c15565b90506000611d1460385483611bf090919063ffffffff16565b9050611d1e612509565b506040805161010080820183526001600160a01b03808c1683528a8116602084019081529383018681526060840186815260006080860181815260a0870182815260c0880183815260e08901848152603d80546001810182559086528a5160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b166001600160a01b03199384161790559b517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc48d01805491909a1691161790975594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc58a015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc6890155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc788015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc887015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990950180549251151590930261ff001995151560ff19909316929092179490941617905590611ed06114af565b82516001600160a01b03166000908152603e60205260409020819055603354603454603a54929350611f12928d92611b5b9290916108c5919082908a90611bf0565b896001600160a01b0316817f90ec05050aa23d54ba425e926fe646c318e85825bc400b13a46010abe86eb2f08b87878d604051611f52949392919061298b565b60405180910390a39998505050505050505050565b336000908152603f6020526040902054611f7f611c15565b11611f9c5760405162461bcd60e51b815260040161085690612c1c565b60408051808201825260208082527f476f7665726e616e63653a20696e73756666696369656e742062616c616e636581830152336000908152603b9091529190912054611fea9183906123b8565b336000818152603b6020526040908190209290925590516391fe357360e01b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316916391fe357391610fda919085906004016128c7565b61166933826123e4565b3381328214612065576000612069565b6152085b61ffff1681156121d45760005a905060005b885181101561213257600089828151811061209257fe5b6020908102919091018101516001600160a01b038082166000908152603c909352604090922054909250163314806120d257506001600160a01b03811633145b6120ee5760405162461bcd60e51b815260040161085690612ea1565b8615806121025750612100898261154f565b155b61211e5760405162461bcd60e51b815260040161085690612f0f565b612129818a8a61197d565b5060010161207b565b50600061214a6127106108c5856108c55a8790611bae565b60405163a99ce80760e01b81529091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a99ce8079061219b90889085906004016128c7565b600060405180830381600087803b1580156121b557600080fd5b505af11580156121c9573d6000803e3d6000fd5b5050505050506117be565b60005b875181101561228e5760008882815181106121ee57fe5b6020908102919091018101516001600160a01b038082166000908152603c9093526040909220549092501633148061222e57506001600160a01b03811633145b61224a5760405162461bcd60e51b815260040161085690612ea1565b85158061225e575061225c888261154f565b155b61227a5760405162461bcd60e51b815260040161085690612f0f565b61228581898961197d565b506001016121d7565b5050505050505050565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b60008183106122ee57816114a6565b5090919050565b60408054905163d505accf60e01b81526001600160a01b039091169063d505accf9061233190899030908a908a908a908a908a9060040161294a565b600060405180830381600087803b15801561234b57600080fd5b505af115801561235f573d6000803e3d6000fd5b5050505061236d86866123e4565b505050505050565b3b151590565b6001600160a01b0382166000908152603f6020526040902054811115610e17576001600160a01b03919091166000908152603f6020526040902055565b600081848411156123dc5760405162461bcd60e51b815260040161085691906129e1565b505050900390565b6040805490516323b872dd60e01b81526001600160a01b03909116906323b872dd906124389085907f00000000000000000000000000000000000000000000000000000000000000009086906004016128e0565b602060405180830381600087803b15801561245257600080fd5b505af1158015612466573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248a91906127dc565b6124a65760405162461bcd60e51b815260040161085690612c53565b6001600160a01b0382166000908152603b60205260409020546124c99082611bf0565b6001600160a01b039092166000908152603b602052604090209190915550565b604080516060810182526000808252602082018190529181019190915290565b60405180610100016040528060006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b80356001600160a01b03811681146114a957600080fd5b80356114a981612fe0565b600082601f830112612596578081fd5b813567ffffffffffffffff8111156125ac578182fd5b6125bf601f8201601f1916602001612f74565b91508082528360208285010111156125d657600080fd5b8060208401602084013760009082016020015292915050565b600060208284031215612600578081fd5b6114a68383612564565b60008060006060848603121561261e578182fd5b833561262981612fcb565b9250602084013561263981612fcb565b9150604084013567ffffffffffffffff811115612654578182fd5b61266086828701612586565b9150509250925092565b6000806040838503121561267c578182fd5b823561268781612fcb565b9150602083013567ffffffffffffffff8111156126a2578182fd5b6126ae85828601612586565b9150509250929050565b60008060008060008060c087890312156126d0578182fd5b6126da8888612564565b95506020870135945060408701359350606087013560ff811681146126fd578283fd5b9598949750929560808101359460a0909101359350915050565b60008060006060848603121561272b578283fd5b833567ffffffffffffffff80821115612742578485fd5b818601915086601f830112612755578485fd5b813581811115612763578586fd5b60209150818102612775838201612f74565b8281528381019085850183870186018c101561278f57898afd5b8996505b848710156127b9576127a58c82612564565b835260019690960195918501918501612793565b50975050505085013592506127d39050856040860161257b565b90509250925092565b6000602082840312156127ed578081fd5b81516114a681612fe0565b600060208284031215612809578081fd5b5035919050565b60008060408385031215612822578182fd5b823591506128338460208501612564565b90509250929050565b6000806040838503121561284e578182fd5b82359150602083013561286081612fe0565b809150509250929050565b60008151808452612883816020860160208601612f9b565b601f01601f19169290920160200192915050565b600082516128a9818460208701612f9b565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03988916815296909716602087015260408601949094526060850192909252608084015260a0830152151560c082015290151560e08201526101000190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b600060018060a01b0386168252846020830152836040830152608060608301526129b8608083018461286b565b9695505050505050565b901515815260200190565b60208101600783106129db57fe5b91905290565b6000602082526114a6602083018461286b565b60208082526023908201527f476f7665726e616e63653a3a657865637574653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602b908201527f476f7665726e616e63653a3a657865637574653a20696e76616c69642070726f60408201526a706f73616c20737461746560a81b606082015260800190565b60208082526055908201527f476f7665726e616e63653a3a70726f706f73653a206f6e65206c69766520707260408201527f6f706f73616c207065722070726f706f7365722c20666f756e6420616e20616c6060820152741c9958591e481858dd1a5d99481c1c9bdc1bdcd85b605a1b608082015260a00190565b60208082526027908201527f476f7665726e616e63653a3a5f63617374566f74653a20766f74696e672069736040820152660818db1bdcd95960ca1b606082015260800190565b6020808252603c908201527f476f7665726e616e63653a3a70726f706f73653a2070726f706f73657220766f60408201527f7465732062656c6f772070726f706f73616c207468726573686f6c6400000000606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526024908201527f476f7665726e616e63653a20696e636f727265637420766f7465457874656e6460408201526354696d6560e01b606082015260800190565b6020808252601d908201527f476f7665726e616e63653a20746f6b656e7320617265206c6f636b6564000000604082015260600190565b60208082526019908201527f544f524e3a207472616e7366657246726f6d206661696c656400000000000000604082015260600190565b60208082526010908201526f43616e206e6f7420626520656d70747960801b604082015260600190565b60208082526018908201527f476f7665726e616e63653a20756e617574686f72697a65640000000000000000604082015260600190565b6020808252601d908201527f476f7665726e616e63653a20696e76616c69642064656c656761746565000000604082015260600190565b60208082526018908201527f476f7665726e616e63653a2062616c616e636520697320300000000000000000604082015260600190565b60208082526023908201527f476f7665726e616e63653a3a70726f706f73653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252600d908201526c6f6e6c79206d756c746973696760981b604082015260600190565b60208082526026908201527f476f7665726e616e63653a3a73746174653a20696e76616c69642070726f706f6040820152651cd85b081a5960d21b606082015260800190565b6020808252602a908201527f476f7665726e616e63653a20746f6b656e732061726520616c726561647920756040820152691b99195b1959d85d195960b21b606082015260800190565b6020808252601a908201527f476f7665726e616e63653a206e6f7420617574686f72697a6564000000000000604082015260600190565b60208082526019908201527f50726f706f73616c20657865637574696f6e206661696c656400000000000000604082015260600190565b60208082526019908201527f476f7665726e616e63653a20766f74656420616c726561647900000000000000604082015260600190565b8151151581526020808301511515908201526040918201519181019190915260600190565b90815260200190565b60405181810167ffffffffffffffff81118282101715612f9357600080fd5b604052919050565b60005b83811015612fb6578181015183820152602001612f9e565b83811115612fc5576000848401525b50505050565b6001600160a01b038116811461166957600080fd5b801515811461166957600080fdfea2646970667358221220e1f35bea256ff1c0e43f98312094903f31941303df43a2edbe8b9bd0fa323c8864736f6c634300060c0033"; +const isSuperArgs$c = (xs) => xs.length > 1; +class GovernanceStakingUpgrade__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$c(args)) { + super(...args); + } else { + super(_abi$d, _bytecode$c, args[0]); + } + } + getDeployTransaction(stakingRewardsAddress, gasCompLogic, userVaultAddress, overrides) { + return super.getDeployTransaction( + stakingRewardsAddress, + gasCompLogic, + userVaultAddress, + overrides || {} + ); + } + deploy(stakingRewardsAddress, gasCompLogic, userVaultAddress, overrides) { + return super.deploy( + stakingRewardsAddress, + gasCompLogic, + userVaultAddress, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$d); + } + static connect(address, runner) { + return new Contract( + address, + _abi$d, + runner + ); + } +} +GovernanceStakingUpgrade__factory.bytecode = _bytecode$c; +GovernanceStakingUpgrade__factory.abi = _abi$d; + +const _abi$c = [ + { + inputs: [ + { + internalType: "bytes32", + name: "salt", + type: "bytes32" + }, + { + internalType: "address", + name: "implementationContract", + type: "address" + }, + { + internalType: "bytes", + name: "metamorphicContractInitializationCalldata", + type: "bytes" + } + ], + name: "deployMetamorphicContractFromExistingImplementation", + outputs: [ + { + internalType: "address", + name: "metamorphicContractAddress", + type: "address" + } + ], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes32", + name: "salt", + type: "bytes32" + } + ], + name: "findMetamorphicContractAddress", + outputs: [ + { + internalType: "address", + name: "metamorphicContractAddress", + type: "address" + } + ], + stateMutability: "view", + type: "function" + } +]; +class IMetamorphicContractFactory__factory { + static createInterface() { + return new Interface(_abi$c); + } + static connect(address, runner) { + return new Contract( + address, + _abi$c, + runner + ); + } +} +IMetamorphicContractFactory__factory.abi = _abi$c; + +const _abi$b = [ + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "num", + type: "uint256" + } + ], + name: "MockExecuted", + type: "event" + }, + { + inputs: [], + name: "emergencyStop", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "executeProposal", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$b = "0x608060405234801561001057600080fd5b5060c08061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c8063373058b814603757806363a599a414603f575b600080fd5b603d6045565b005b603d607d565b7f2ff532ec74fd1130db9b7b6800e0992b2363095b00331a891a27edfab97c45406001604051607391906081565b60405180910390a1565b6000ff5b9081526020019056fea264697066735822122018779fa63005d6573862657b4a5cd55f75b705b28a7ff69222461665b78f408a64736f6c634300060c0033"; +const isSuperArgs$b = (xs) => xs.length > 1; +class InitialProposal__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$b(args)) { + super(...args); + } else { + super(_abi$b, _bytecode$b, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$b); + } + static connect(address, runner) { + return new Contract(address, _abi$b, runner); + } +} +InitialProposal__factory.bytecode = _bytecode$b; +InitialProposal__factory.abi = _abi$b; + +const _abi$a = [ + { + inputs: [], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "num", + type: "uint256" + } + ], + name: "MockExecuted", + type: "event" + }, + { + inputs: [], + name: "deployer", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "emergencyStop", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "executeProposal", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$a = "0x60a060405234801561001057600080fd5b5033606081901b6080526102746100366000398061012952806101b052506102746000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063373058b81461004657806363a599a414610050578063d5f3948814610058575b600080fd5b61004e610076565b005b61004e6101aa565b6100606101ae565b60405161006d9190610211565b60405180910390f35b6040516370a0823160e01b81527377777feddddffc19ff86db637967013e6c6a116c9060009082906370a08231906100b2903090600401610211565b60206040518083038186803b1580156100ca57600080fd5b505afa1580156100de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061010291906101f9565b60405163a9059cbb60e01b81529091506001600160a01b0383169063a9059cbb90610153907f0000000000000000000000000000000000000000000000000000000000000000908590600401610225565b602060405180830381600087803b15801561016d57600080fd5b505af1158015610181573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101a591906101d2565b505050565b6000ff5b7f000000000000000000000000000000000000000000000000000000000000000081565b6000602082840312156101e3578081fd5b815180151581146101f2578182fd5b9392505050565b60006020828403121561020a578081fd5b5051919050565b6001600160a01b0391909116815260200190565b6001600160a01b0392909216825260208201526040019056fea2646970667358221220c120adf2a3856eb39e4d2305abf19175fb5f11d87cd96e5c70ce2a9f702ba53664736f6c634300060c0033"; +const isSuperArgs$a = (xs) => xs.length > 1; +class MaliciousProposal__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$a(args)) { + super(...args); + } else { + super(_abi$a, _bytecode$a, args[0]); + } + } + getDeployTransaction(overrides) { + return super.getDeployTransaction(overrides || {}); + } + deploy(overrides) { + return super.deploy(overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$a); + } + static connect(address, runner) { + return new Contract(address, _abi$a, runner); + } +} +MaliciousProposal__factory.bytecode = _bytecode$a; +MaliciousProposal__factory.abi = _abi$a; + +const _abi$9 = [ + { + inputs: [ + { + internalType: "address", + name: "_logic", + type: "address" + }, + { + internalType: "address", + name: "_admin", + type: "address" + }, + { + internalType: "bytes", + name: "_data", + type: "bytes" + } + ], + stateMutability: "payable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "previousAdmin", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "newAdmin", + type: "address" + } + ], + name: "AdminChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "implementation", + type: "address" + } + ], + name: "Upgraded", + type: "event" + }, + { + stateMutability: "payable", + type: "fallback" + }, + { + inputs: [], + name: "admin", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newAdmin", + type: "address" + } + ], + name: "changeAdmin", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "implementation", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address" + } + ], + name: "upgradeTo", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + stateMutability: "payable", + type: "receive" + } +]; +const _bytecode$9 = "0x60806040526040516108403803806108408339818101604052606081101561002657600080fd5b8151602083015160408085018051915193959294830192918464010000000082111561005157600080fd5b90830190602082018581111561006657600080fd5b825164010000000081118282018810171561008057600080fd5b82525081516020918201929091019080838360005b838110156100ad578181015183820152602001610095565b50505050905090810190601f1680156100da5780820380516001836020036101000a031916815260200191505b50604052508491508390508282816100f1826101c5565b8051156101a9576000826001600160a01b0316826040518082805190602001908083835b602083106101345780518252601f199092019160209182019101610115565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114610194576040519150601f19603f3d011682016040523d82523d6000602084013e610199565b606091505b50509050806101a757600080fd5b505b506101b19050565b6101ba82610237565b505050505050610261565b6101d88161025b60201b6103b41760201c565b6102135760405162461bcd60e51b815260040180806020018281038252603681526020018061080a6036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b3b151590565b61059a806102706000396000f3fe60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100985780635c60da1b146101185780638f28397014610149578063f851a4401461017c5761005d565b3661005d5761005b610191565b005b61005b610191565b34801561007157600080fd5b5061005b6004803603602081101561008857600080fd5b50356001600160a01b03166101ab565b61005b600480360360408110156100ae57600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100d957600080fd5b8201836020820111156100eb57600080fd5b8035906020019184600183028401116401000000008311171561010d57600080fd5b5090925090506101e5565b34801561012457600080fd5b5061012d610292565b604080516001600160a01b039092168252519081900360200190f35b34801561015557600080fd5b5061005b6004803603602081101561016c57600080fd5b50356001600160a01b03166102cf565b34801561018857600080fd5b5061012d610389565b6101996101a9565b6101a96101a46103ba565b6103df565b565b6101b3610403565b6001600160a01b0316336001600160a01b031614156101da576101d581610428565b6101e2565b6101e2610191565b50565b6101ed610403565b6001600160a01b0316336001600160a01b031614156102855761020f83610428565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d806000811461026c576040519150601f19603f3d011682016040523d82523d6000602084013e610271565b606091505b505090508061027f57600080fd5b5061028d565b61028d610191565b505050565b600061029c610403565b6001600160a01b0316336001600160a01b031614156102c4576102bd6103ba565b90506102cc565b6102cc610191565b90565b6102d7610403565b6001600160a01b0316336001600160a01b031614156101da576001600160a01b0381166103355760405162461bcd60e51b815260040180806020018281038252603a8152602001806104f5603a913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61035e610403565b604080516001600160a01b03928316815291841660208301528051918290030190a16101d581610468565b6000610393610403565b6001600160a01b0316336001600160a01b031614156102c4576102bd610403565b3b151590565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e8080156103fe573d6000f35b3d6000fd5b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b6104318161048c565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b610495816103b4565b6104d05760405162461bcd60e51b815260040180806020018281038252603681526020018061052f6036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5556fe5472616e73706172656e745570677261646561626c6550726f78793a206e65772061646d696e20697320746865207a65726f20616464726573735570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374a26469706673582212203c0c6456361fbff816ff53c5547d39ad0e807130f877d2661772f7bffc95b82764736f6c634300060c00335570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374"; +const isSuperArgs$9 = (xs) => xs.length > 1; +let AdminUpgradeableProxy__factory$1 = class AdminUpgradeableProxy__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$9(args)) { + super(...args); + } else { + super(_abi$9, _bytecode$9, args[0]); + } + } + getDeployTransaction(_logic, _admin, _data, overrides) { + return super.getDeployTransaction(_logic, _admin, _data, overrides || {}); + } + deploy(_logic, _admin, _data, overrides) { + return super.deploy(_logic, _admin, _data, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$9); + } + static connect(address, runner) { + return new Contract( + address, + _abi$9, + runner + ); + } +}; +AdminUpgradeableProxy__factory$1.bytecode = _bytecode$9; +AdminUpgradeableProxy__factory$1.abi = _abi$9; + +const _abi$8 = [ + { + inputs: [ + { + internalType: "address", + name: "stakingRewardsAddress", + type: "address" + }, + { + internalType: "address", + name: "gasCompLogic", + type: "address" + }, + { + internalType: "address", + name: "userVaultAddress", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + } + ], + name: "Delegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "id", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "proposer", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "target", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + indexed: false, + internalType: "string", + name: "description", + type: "string" + } + ], + name: "ProposalCreated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "ProposalExecuted", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "bytes", + name: "errorData", + type: "bytes" + } + ], + name: "RewardUpdateFailed", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + } + ], + name: "RewardUpdateSuccessful", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + } + ], + name: "Undelegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "voter", + type: "address" + }, + { + indexed: true, + internalType: "bool", + name: "support", + type: "bool" + }, + { + indexed: false, + internalType: "uint256", + name: "votes", + type: "uint256" + } + ], + name: "Voted", + type: "event" + }, + { + inputs: [], + name: "CLOSING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_EXPIRATION", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "PROPOSAL_THRESHOLD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "QUORUM_VOTES", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "Staking", + outputs: [ + { + internalType: "contract ITornadoStakingRewards", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTE_EXTEND_TIME", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "canWithdrawAfter", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address[]", + name: "from", + type: "address[]" + }, + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castDelegatedVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "checkIfQuorumReached", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + } + ], + name: "delegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "delegatedTo", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "execute", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [], + name: "gasCompensationVault", + outputs: [ + { + internalType: "contract IGasCompensationVault", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "address", + name: "voter", + type: "address" + } + ], + name: "getReceipt", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "hasVoted", + type: "bool" + }, + { + internalType: "bool", + name: "support", + type: "bool" + }, + { + internalType: "uint256", + name: "votes", + type: "uint256" + } + ], + internalType: "struct Governance.Receipt", + name: "", + type: "tuple" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "hasAccountVoted", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "_torn", + type: "address" + } + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "latestProposalIds", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "lock", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "lockWithApproval", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "lockedBalance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "proposalCodehashes", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "proposalCount", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "proposals", + outputs: [ + { + internalType: "address", + name: "proposer", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "forVotes", + type: "uint256" + }, + { + internalType: "uint256", + name: "againstVotes", + type: "uint256" + }, + { + internalType: "bool", + name: "executed", + type: "bool" + }, + { + internalType: "bool", + name: "extended", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "propose", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "proposeByDelegate", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "returnMultisigAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "pure", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "closingPeriod", + type: "uint256" + } + ], + name: "setClosingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionDelay", + type: "uint256" + } + ], + name: "setExecutionDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionExpiration", + type: "uint256" + } + ], + name: "setExecutionExpiration", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "gasCompensationsLimit", + type: "uint256" + } + ], + name: "setGasCompensations", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalThreshold", + type: "uint256" + } + ], + name: "setProposalThreshold", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "quorumVotes", + type: "uint256" + } + ], + name: "setQuorumVotes", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "voteExtendTime", + type: "uint256" + } + ], + name: "setVoteExtendTime", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingDelay", + type: "uint256" + } + ], + name: "setVotingDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingPeriod", + type: "uint256" + } + ], + name: "setVotingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "state", + outputs: [ + { + internalType: "enum Governance.ProposalState", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "torn", + outputs: [ + { + internalType: "contract TORN", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "undelegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "unlock", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "userVault", + outputs: [ + { + internalType: "contract ITornadoVault", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "version", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "pure", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "withdrawFromHelper", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + stateMutability: "payable", + type: "receive" + } +]; +const _bytecode$8 = "0x60e06040523480156200001157600080fd5b50604051620034343803806200343483398101604081905262000034916200016b565b82828281818181600060019054906101000a900460ff16806200005c57506200005c62000124565b806200006b575060005460ff16155b620000935760405162461bcd60e51b81526004016200008a90620001be565b60405180910390fd5b600054610100900460ff16158015620000bf576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b03191661dead179055620000dd6200012a565b8015620000f0576000805461ff00191690555b506001600160601b0319606091821b811660805291811b821660a0529590951b90941660c052506200022595505050505050565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b60008060006060848603121562000180578283fd5b83516200018d816200020c565b6020850151909350620001a0816200020c565b6040850151909250620001b3816200020c565b809150509250925092565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b6001600160a01b03811681146200022257600080fd5b50565b60805160601c60a05160601c60c05160601c6131ac6200028860003980610d1352806110d452806116c752806117f85250806109105280610eca5280610fc252806116435280611d6d52508061105d5280611c1652806124f152506131ac6000f3fe6080604052600436106102815760003560e01c80639daafec71161014f578063d6f0948c116100c1578063ea0217cf1161007a578063ea0217cf14610755578063ece40cc114610775578063ef3f8bb114610795578063f0b76892146107b5578063f57df22e146107d5578063fe0d94c1146107ea57610288565b8063d6f0948c14610693578063da35c664146106b3578063e01f5237146106c8578063e23a9a52146106e8578063e4917d9f14610715578063e525aa081461073557610288565b8063b54426c811610113578063b54426c8146105e9578063b859f11b14610609578063c0c0e82014610629578063c4d66de814610649578063ce25d71c14610669578063d6159fe51461067e57610288565b80639daafec714610575578063a6c266031461058a578063a72edda31461059f578063adf898a4146105bf578063b1610d7e146105d457610288565b80635c19a95c116101f357806370b0f660116101ac57806370b0f660146104cb5780638b34a960146104eb57806392ab89bb14610500578063932d5157146105155780639a9e3b6e146105355780639ae697bf1461055557610288565b80635c19a95c146104215780636198e3391461044157806365da126414610461578063671dd275146104815780636a661755146104965780636dc2dc6c146104ab57610288565b806332687ec11161024557806332687ec11461035b57806337f135d7146103885780633e4f49e61461039d57806354fd4d50146103ca578063587a6ecb146103ec57806358e9fff01461040157610288565b8063013cf08b1461028d57806302ec8f9e146102ca57806315373e3d146102ec57806317977c611461030c57806324b0435f1461033957610288565b3661028857005b600080fd5b34801561029957600080fd5b506102ad6102a83660046128e1565b6107fd565b6040516102c19897969594939291906129ed565b60405180910390f35b3480156102d657600080fd5b506102ea6102e53660046128e1565b610862565b005b3480156102f857600080fd5b506102ea610307366004612925565b61088f565b34801561031857600080fd5b5061032c6103273660046126d8565b610992565b6040516102c19190612ab6565b34801561034557600080fd5b5061034e6109a4565b6040516102c1919061299c565b34801561036757600080fd5b5061037b6103763660046128e1565b6109bc565b6040516102c19190612aab565b34801561039457600080fd5b5061032c610a0a565b3480156103a957600080fd5b506103bd6103b83660046128e1565b610a10565b6040516102c19190612abf565b3480156103d657600080fd5b506103df610b4c565b6040516102c19190612ad3565b3480156103f857600080fd5b5061032c610b75565b34801561040d57600080fd5b5061032c61041c3660046126f3565b610b7b565b34801561042d57600080fd5b506102ea61043c3660046126d8565b610bc9565b34801561044d57600080fd5b506102ea61045c3660046128e1565b610ceb565b34801561046d57600080fd5b5061034e61047c3660046126d8565b610e38565b34801561048d57600080fd5b5061032c610e53565b3480156104a257600080fd5b5061032c610e59565b3480156104b757600080fd5b506102ea6104c63660046128e1565b610e5f565b3480156104d757600080fd5b506102ea6104e63660046128e1565b610ea4565b3480156104f757600080fd5b5061034e610ec8565b34801561050c57600080fd5b506102ea610eec565b34801561052157600080fd5b506102ea6105303660046128e1565b610f73565b34801561054157600080fd5b506102ea6105503660046128e1565b611025565b34801561056157600080fd5b5061032c6105703660046126d8565b611049565b34801561058157600080fd5b5061034e61105b565b34801561059657600080fd5b5061032c61107f565b3480156105ab57600080fd5b5061032c6105ba3660046126d8565b611085565b3480156105cb57600080fd5b5061034e611097565b3480156105e057600080fd5b5061032c6110a6565b3480156105f557600080fd5b506102ea6106043660046128e1565b6110ac565b34801561061557600080fd5b506102ea610624366004612800565b6111f5565b34801561063557600080fd5b506102ea6106443660046128e1565b611243565b34801561065557600080fd5b506102ea6106643660046126d8565b611267565b34801561067557600080fd5b5061032c6114aa565b34801561068a57600080fd5b5061032c6114b0565b34801561069f57600080fd5b5061032c6106ae366004612753565b6114b6565b3480156106bf57600080fd5b5061032c6114cc565b3480156106d457600080fd5b5061032c6106e33660046128e1565b6114d6565b3480156106f457600080fd5b506107086107033660046128f9565b6114e8565b6040516102c191906130db565b34801561072157600080fd5b506102ea6107303660046128e1565b61155a565b34801561074157600080fd5b5061037b6107503660046128f9565b61157e565b34801561076157600080fd5b506102ea6107703660046128e1565b6115c1565b34801561078157600080fd5b506102ea6107903660046128e1565b6115e5565b3480156107a157600080fd5b506102ea6107b03660046128e1565b611609565b3480156107c157600080fd5b506102ea6107d03660046127a1565b61169b565b3480156107e157600080fd5b5061034e6117f6565b6102ea6107f83660046128e1565b61181a565b603d818154811061080a57fe5b600091825260209091206008909102018054600182015460028301546003840154600485015460058601546006909601546001600160a01b039586169750949093169491939092919060ff8082169161010090041688565b33301461088a5760405162461bcd60e51b815260040161088190612e49565b60405180910390fd5b603555565b3361089a833361157e565b1580156108ad57506108ab836109bc565b155b3332146108bb5760006108bf565b6152085b61ffff1681156109805760005a90506108d93387876118ac565b60006108f66127106108f0856108f05a8790611add565b90611b1f565b60405163a99ce80760e01b81529091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a99ce8079061094790889085906004016129b0565b600060405180830381600087803b15801561096157600080fd5b505af1158015610975573d6000803e3d6000fd5b50505050505061098b565b61098b3386866118ac565b5050505050565b603e6020526000908152604090205481565b73b04e030140b30c27bcdfaafffa98c57d80eda7b490565b6000603554603d83815481106109ce57fe5b906000526020600020906008020160050154603d84815481106109ed57fe5b90600052602060002090600802016004015401101590505b919050565b60335481565b6000610a1a6114cc565b8211158015610a295750600082115b610a455760405162461bcd60e51b815260040161088190612fa6565b6000603d8381548110610a5457fe5b906000526020600020906008020190508060020154610a71611b44565b11610a80576000915050610a05565b8060030154610a8d611b44565b11610a9c576001915050610a05565b80600501548160040154111580610abe57506035548160050154826004015401105b15610acd576002915050610a05565b600681015460ff1615610ae4576005915050610a05565b610b036034546108f06033548460030154611b1f90919063ffffffff16565b610b0b611b44565b10610b1a576006915050610a05565b6033546003820154610b2b91611b1f565b610b33611b44565b10610b42576004915050610a05565b6003915050610a05565b60408051808201909152600f81526e0d0b9c185d18da0b595e1c1b1bda5d608a1b602082015290565b603a5481565b6001600160a01b038381166000908152603c60205260408120549091163314610bb65760405162461bcd60e51b815260040161088190613036565b610bc1848484611b48565b949350505050565b336000818152603c60205260409020546001600160a01b039081169190831614801590610bff57506001600160a01b0382163014155b8015610c1357506001600160a01b03821615155b8015610c315750806001600160a01b0316826001600160a01b031614155b610c4d5760405162461bcd60e51b815260040161088190612e80565b6001600160a01b03811615610c93576040516001600160a01b0382169033907f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7290600090a35b336000818152603c602052604080822080546001600160a01b0319166001600160a01b03871690811790915590519092917f4bc154dd35d6a5cb9206482ecb473cdbf2473006d6bce728b9cc0741bcc59ea291a35050565b336000818152603b60205260409081902054905163e113335f60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163e113335f91610d489185916004016129b0565b600060405180830381600087803b158015610d6257600080fd5b505af1925050508015610d73575060015b610df6573d808015610da1576040519150601f19603f3d011682016040523d82523d6000602084013e610da6565b606091505b5080604051610db59190612980565b604051908190038120906001600160a01b038416907f5a6216e80d86159dc87dcebfe519205477a94005b7d9d6bd313606450a5344f690600090a350610e2b565b6040516001600160a01b038216907f9b227b0c1ae308b34f72d4fdf9a1943fa769ff4814933595e7bc5230a117698b90600090a25b610e3482611b70565b5050565b603c602052600090815260409020546001600160a01b031681565b60355481565b60345481565b333014610e7e5760405162461bcd60e51b815260040161088190612e49565b6033548110610e9f5760405162461bcd60e51b815260040161088190612d6d565b603a55565b333014610ec35760405162461bcd60e51b815260040161088190612e49565b603755565b7f000000000000000000000000000000000000000000000000000000000000000081565b336000908152603c60205260409020546001600160a01b031680610f225760405162461bcd60e51b815260040161088190612fec565b336000818152603c602052604080822080546001600160a01b0319169055516001600160a01b03841692917f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7291a350565b610f7b6109a4565b6001600160a01b0316336001600160a01b031614610fab5760405162461bcd60e51b815260040161088190612f7f565b604051633a08bde160e21b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063e822f78490610ff7908490600401612ab6565b600060405180830381600087803b15801561101157600080fd5b505af115801561098b573d6000803e3d6000fd5b3330146110445760405162461bcd60e51b815260040161088190612e49565b603455565b603b6020526000908152604090205481565b7f000000000000000000000000000000000000000000000000000000000000000081565b60365481565b603f6020526000908152604090205481565b6040546001600160a01b031681565b60385481565b336000818152603b60205260409081902054905163e113335f60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163e113335f916111099185916004016129b0565b600060405180830381600087803b15801561112357600080fd5b505af1925050508015611134575060015b6111b7573d808015611162576040519150601f19603f3d011682016040523d82523d6000602084013e611167565b606091505b50806040516111769190612980565b604051908190038120906001600160a01b038416907f5a6216e80d86159dc87dcebfe519205477a94005b7d9d6bd313606450a5344f690600090a3506111ec565b6040516001600160a01b038216907f9b227b0c1ae308b34f72d4fdf9a1943fa769ff4814933595e7bc5230a117698b90600090a25b610e3482611c54565b60008351116112165760405162461bcd60e51b815260040161088190612e1f565b61123e838383611226863361157e565b1580156112395750611237866109bc565b155b611c5e565b505050565b3330146112625760405162461bcd60e51b815260040161088190612e49565b603955565b600054610100900460ff16806112805750611280611ea1565b8061128e575060005460ff16155b6112aa5760405162461bcd60e51b815260040161088190612f31565b600054610100900460ff161580156112d5576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b038085166001600160a01b03199283161783558251610100818101855230825261dead602083019081526000958301868152606084018781526080850188815260a08601898152600160c0880181815260e089018c8152603d80549384018155909c52975160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b16928c169290921790915594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc4860180549190991699169890981790965590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc5830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc682015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc784015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc8830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990910180549351151590920261ff001991151560ff199094169390931716919091179055611495611ea7565b8015610e34576000805461ff00191690555050565b60395481565b60375481565b60006114c3338484611b48565b90505b92915050565b603d546000190190565b60416020526000908152604090205481565b6114f06125d2565b603d83815481106114fd57fe5b600091825260208083206001600160a01b0395909516835260089190910290930160070183526040908190208151606081018352815460ff8082161515835261010090910416151594810194909452600101549083015250919050565b3330146115795760405162461bcd60e51b815260040161088190612e49565b603355565b6000603d838154811061158d57fe5b600091825260208083206001600160a01b03861684526007600890930201919091019052604090205460ff16905092915050565b3330146115e05760405162461bcd60e51b815260040161088190612e49565b603855565b3330146116045760405162461bcd60e51b815260040161088190612e49565b603655565b6116116109a4565b6001600160a01b0316336001600160a01b0316146116415760405162461bcd60e51b815260040161088190612f7f565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166108fc6116788347611ee8565b6040518115909202916000818181858888f1935050505061169857600080fd5b50565b6001600160a01b038087166000908152603b60205260409081902054905163e113335f60e01b815288927f0000000000000000000000000000000000000000000000000000000000000000169163e113335f916116fc9185916004016129b0565b600060405180830381600087803b15801561171657600080fd5b505af1925050508015611727575060015b6117aa573d808015611755576040519150601f19603f3d011682016040523d82523d6000602084013e61175a565b606091505b50806040516117699190612980565b604051908190038120906001600160a01b038416907f5a6216e80d86159dc87dcebfe519205477a94005b7d9d6bd313606450a5344f690600090a3506117df565b6040516001600160a01b038216907f9b227b0c1ae308b34f72d4fdf9a1943fa769ff4814933595e7bc5230a117698b90600090a25b6117ed878787878787611efe565b50505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b3330141561183a5760405162461bcd60e51b815260040161088190612c36565b6000603d828154811061184957fe5b6000918252602080832060016008909302019182015485845260419091526040909220549092506001600160a01b0390911690813f90811461189d5760405162461bcd60e51b815260040161088190612d17565b6118a684611f7e565b50505050565b60016118b783610a10565b60068111156118c257fe5b146118df5760405162461bcd60e51b815260040161088190612bef565b6000603d83815481106118ee57fe5b600091825260208083206001600160a01b038816845260076008909302019182018152604080842060058401546004850154603b90945291909420549294501015908061194d5760405162461bcd60e51b815260040161088190612eb7565b825460ff161561199c578254610100900460ff1615611983576001830154600485015461197991611add565b600485015561199c565b6001830154600585015461199691611add565b60058501555b84156119bb5760048401546119b19082611b1f565b60048501556119d0565b60058401546119ca9082611b1f565b60058501555b6006840154610100900460ff16158015611a0057506039546119fe6119f3611b44565b600387015490611add565b105b15611a44576005840154600485015411158215158114611a425760068501805461ff001916610100179055603a546003860154611a3c91611b1f565b60038601555b505b8254600160ff19909116811761ff001916610100871515021784558301819055603354603454603a546003870154611a8f938b93611a8a9391926108f092839190611b1f565b612110565b841515876001600160a01b0316877f7c2de587c00d75474a0c6c6fa96fd3b45dc974cd4e8a75f712bb84c950dce1b584604051611acc9190612ab6565b60405180910390a450505050505050565b60006114c383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061214d565b6000828201838110156114c35760405162461bcd60e51b815260040161088190612ce0565b4290565b6000611b55848484612179565b6000818152604160205260409020933f909355509092915050565b336000908152603f6020526040902054611b88611b44565b11611ba55760405162461bcd60e51b815260040161088190612db1565b60408051808201825260208082527f476f7665726e616e63653a20696e73756666696369656e742062616c616e636581830152336000908152603b9091529190912054611bf391839061214d565b336000818152603b6020526040908190209290925590516391fe357360e01b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316916391fe357391610ff7919085906004016129b0565b61169833826124c7565b3381328214611c6e576000611c72565b6152085b61ffff168115611ddd5760005a905060005b8851811015611d3b576000898281518110611c9b57fe5b6020908102919091018101516001600160a01b038082166000908152603c90935260409092205490925016331480611cdb57506001600160a01b03811633145b611cf75760405162461bcd60e51b815260040161088190613036565b861580611d0b5750611d09898261157e565b155b611d275760405162461bcd60e51b8152600401610881906130a4565b611d32818a8a6118ac565b50600101611c84565b506000611d536127106108f0856108f05a8790611add565b60405163a99ce80760e01b81529091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a99ce80790611da490889085906004016129b0565b600060405180830381600087803b158015611dbe57600080fd5b505af1158015611dd2573d6000803e3d6000fd5b5050505050506117ed565b60005b8751811015611e97576000888281518110611df757fe5b6020908102919091018101516001600160a01b038082166000908152603c90935260409092205490925016331480611e3757506001600160a01b03811633145b611e535760405162461bcd60e51b815260040161088190613036565b851580611e675750611e65888261157e565b155b611e835760405162461bcd60e51b8152600401610881906130a4565b611e8e8189896118ac565b50600101611de0565b5050505050505050565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b6000818310611ef757816114c3565b5090919050565b60408054905163d505accf60e01b81526001600160a01b039091169063d505accf90611f3a90899030908a908a908a908a908a90600401612a33565b600060405180830381600087803b158015611f5457600080fd5b505af1158015611f68573d6000803e3d6000fd5b50505050611f7686866124c7565b505050505050565b6004611f8982610a10565b6006811115611f9457fe5b14611fb15760405162461bcd60e51b815260040161088190612b29565b6000603d8281548110611fc057fe5b600091825260209091206006600890920201908101805460ff191660019081179091558101549091506001600160a01b0316611ffb816125cc565b6120175760405162461bcd60e51b815260040161088190612ae6565b60408051600481526024810182526020810180516001600160e01b03166306e60b1760e31b17905290516000916060916001600160a01b0385169161205b91612980565b600060405180830381855af49150503d8060008114612096576040519150601f19603f3d011682016040523d82523d6000602084013e61209b565b606091505b5091509150816120de578051156120c6578060405162461bcd60e51b81526004016108819190612ad3565b60405162461bcd60e51b81526004016108819061306d565b60405185907f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f90600090a25050505050565b6001600160a01b0382166000908152603f6020526040902054811115610e34576001600160a01b03919091166000908152603f6020526040902055565b600081848411156121715760405162461bcd60e51b81526004016108819190612ad3565b505050900390565b6001600160a01b0383166000908152603b60205260408120546036548110156121b45760405162461bcd60e51b815260040161088190612c83565b6121bd846125cc565b6121d95760405162461bcd60e51b815260040161088190612eee565b6001600160a01b0385166000908152603e6020526040902054801561224b57600061220382610a10565b9050600181600681111561221357fe5b1415801561222d5750600081600681111561222a57fe5b14155b6122495760405162461bcd60e51b815260040161088190612b74565b505b600061225b6037546108f0611b44565b9050600061227460385483611b1f90919063ffffffff16565b905061227e6125f2565b506040805161010080820183526001600160a01b03808c1683528a8116602084019081529383018681526060840186815260006080860181815260a0870182815260c0880183815260e08901848152603d80546001810182559086528a5160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b166001600160a01b03199384161790559b517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc48d01805491909a1691161790975594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc58a015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc6890155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc788015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc887015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990950180549251151590930261ff001995151560ff199093169290921794909416179055906124306114cc565b82516001600160a01b03166000908152603e60205260409020819055603354603454603a54929350612472928d92611a8a9290916108f0919082908a90611b1f565b896001600160a01b0316817f90ec05050aa23d54ba425e926fe646c318e85825bc400b13a46010abe86eb2f08b87878d6040516124b29493929190612a74565b60405180910390a39998505050505050505050565b6040805490516323b872dd60e01b81526001600160a01b03909116906323b872dd9061251b9085907f00000000000000000000000000000000000000000000000000000000000000009086906004016129c9565b602060405180830381600087803b15801561253557600080fd5b505af1158015612549573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256d91906128c5565b6125895760405162461bcd60e51b815260040161088190612de8565b6001600160a01b0382166000908152603b60205260409020546125ac9082611b1f565b6001600160a01b039092166000908152603b602052604090209190915550565b3b151590565b604080516060810182526000808252602082018190529181019190915290565b60405180610100016040528060006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b80356001600160a01b03811681146114c657600080fd5b80356114c681613168565b600082601f83011261267f578081fd5b813567ffffffffffffffff811115612695578182fd5b6126a8601f8201601f1916602001613100565b91508082528360208285010111156126bf57600080fd5b8060208401602084013760009082016020015292915050565b6000602082840312156126e9578081fd5b6114c3838361264d565b600080600060608486031215612707578182fd5b833561271281613153565b9250602084013561272281613153565b9150604084013567ffffffffffffffff81111561273d578182fd5b6127498682870161266f565b9150509250925092565b60008060408385031215612765578182fd5b823561277081613153565b9150602083013567ffffffffffffffff81111561278b578182fd5b6127978582860161266f565b9150509250929050565b60008060008060008060c087890312156127b9578182fd5b6127c3888861264d565b95506020870135945060408701359350606087013560ff811681146127e6578283fd5b9598949750929560808101359460a0909101359350915050565b600080600060608486031215612814578283fd5b833567ffffffffffffffff8082111561282b578485fd5b818601915086601f83011261283e578485fd5b81358181111561284c578586fd5b6020915081810261285e838201613100565b8281528381019085850183870186018c101561287857898afd5b8996505b848710156128a25761288e8c8261264d565b83526001969096019591850191850161287c565b50975050505085013592506128bc90508560408601612664565b90509250925092565b6000602082840312156128d6578081fd5b81516114c381613168565b6000602082840312156128f2578081fd5b5035919050565b6000806040838503121561290b578182fd5b8235915061291c846020850161264d565b90509250929050565b60008060408385031215612937578182fd5b82359150602083013561294981613168565b809150509250929050565b6000815180845261296c816020860160208601613127565b601f01601f19169290920160200192915050565b60008251612992818460208701613127565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03988916815296909716602087015260408601949094526060850192909252608084015260a0830152151560c082015290151560e08201526101000190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b600060018060a01b038616825284602083015283604083015260806060830152612aa16080830184612954565b9695505050505050565b901515815260200190565b90815260200190565b6020810160078310612acd57fe5b91905290565b6000602082526114c36020830184612954565b60208082526023908201527f476f7665726e616e63653a3a657865637574653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602b908201527f476f7665726e616e63653a3a657865637574653a20696e76616c69642070726f60408201526a706f73616c20737461746560a81b606082015260800190565b60208082526055908201527f476f7665726e616e63653a3a70726f706f73653a206f6e65206c69766520707260408201527f6f706f73616c207065722070726f706f7365722c20666f756e6420616e20616c6060820152741c9958591e481858dd1a5d99481c1c9bdc1bdcd85b605a1b608082015260a00190565b60208082526027908201527f476f7665726e616e63653a3a5f63617374566f74653a20766f74696e672069736040820152660818db1bdcd95960ca1b606082015260800190565b6020808252602d908201527f476f7665726e616e63653a3a70726f706f73653a2070736575646f2d6578746560408201526c393730b610333ab731ba34b7b760991b606082015260800190565b6020808252603c908201527f476f7665726e616e63653a3a70726f706f73653a2070726f706f73657220766f60408201527f7465732062656c6f772070726f706f73616c207468726573686f6c6400000000606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526036908201527f476f7665726e616e63653a3a70726f706f73653a206d6574616d6f72706869636040820152750818dbdb9d1c9858dd1cc81b9bdd08185b1b1bddd95960521b606082015260800190565b60208082526024908201527f476f7665726e616e63653a20696e636f727265637420766f7465457874656e6460408201526354696d6560e01b606082015260800190565b6020808252601d908201527f476f7665726e616e63653a20746f6b656e7320617265206c6f636b6564000000604082015260600190565b60208082526019908201527f544f524e3a207472616e7366657246726f6d206661696c656400000000000000604082015260600190565b60208082526010908201526f43616e206e6f7420626520656d70747960801b604082015260600190565b60208082526018908201527f476f7665726e616e63653a20756e617574686f72697a65640000000000000000604082015260600190565b6020808252601d908201527f476f7665726e616e63653a20696e76616c69642064656c656761746565000000604082015260600190565b60208082526018908201527f476f7665726e616e63653a2062616c616e636520697320300000000000000000604082015260600190565b60208082526023908201527f476f7665726e616e63653a3a70726f706f73653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252600d908201526c6f6e6c79206d756c746973696760981b604082015260600190565b60208082526026908201527f476f7665726e616e63653a3a73746174653a20696e76616c69642070726f706f6040820152651cd85b081a5960d21b606082015260800190565b6020808252602a908201527f476f7665726e616e63653a20746f6b656e732061726520616c726561647920756040820152691b99195b1959d85d195960b21b606082015260800190565b6020808252601a908201527f476f7665726e616e63653a206e6f7420617574686f72697a6564000000000000604082015260600190565b60208082526019908201527f50726f706f73616c20657865637574696f6e206661696c656400000000000000604082015260600190565b60208082526019908201527f476f7665726e616e63653a20766f74656420616c726561647900000000000000604082015260600190565b8151151581526020808301511515908201526040918201519181019190915260600190565b60405181810167ffffffffffffffff8111828210171561311f57600080fd5b604052919050565b60005b8381101561314257818101518382015260200161312a565b838111156118a65750506000910152565b6001600160a01b038116811461169857600080fd5b801515811461169857600080fdfea2646970667358221220b75004153b6c8b4905c018daca78cb0fa6d3859298be55252bcf6ba75ea68d0e64736f6c634300060c0033"; +const isSuperArgs$8 = (xs) => xs.length > 1; +class GovernanceExploitPatchUpgrade__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$8(args)) { + super(...args); + } else { + super(_abi$8, _bytecode$8, args[0]); + } + } + getDeployTransaction(stakingRewardsAddress, gasCompLogic, userVaultAddress, overrides) { + return super.getDeployTransaction( + stakingRewardsAddress, + gasCompLogic, + userVaultAddress, + overrides || {} + ); + } + deploy(stakingRewardsAddress, gasCompLogic, userVaultAddress, overrides) { + return super.deploy( + stakingRewardsAddress, + gasCompLogic, + userVaultAddress, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$8); + } + static connect(address, runner) { + return new Contract( + address, + _abi$8, + runner + ); + } +} +GovernanceExploitPatchUpgrade__factory.bytecode = _bytecode$8; +GovernanceExploitPatchUpgrade__factory.abi = _abi$8; + +const _abi$7 = [ + { + inputs: [ + { + internalType: "address", + name: "_deployedStakingProxyContractAddress", + type: "address" + }, + { + internalType: "address", + name: "_deployedRelayerRegistryImplementationAddress", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [], + name: "TORN", + outputs: [ + { + internalType: "contract IERC20", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "deployedRelayerRegistryImplementationAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "deployedStakingProxyContractAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "executeProposal", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "gasCompensationVaultAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "governanceProxyAddress", + outputs: [ + { + internalType: "address payable", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "oldStakingProxyAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "registryProxyAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "userVaultAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + } +]; +const _bytecode$7 = "0x60c060405234801561001057600080fd5b50604051613adb380380613adb83398101604081905261002f9161004d565b6001600160601b0319606092831b8116608052911b1660a05261009e565b6000806040838503121561005f578182fd5b825161006a81610086565b602084015190925061007b81610086565b809150509250929050565b6001600160a01b038116811461009b57600080fd5b50565b60805160601c60a05160601c613a056100d66000398061027a52806104985250806102f952806103f452806104bc5250613a056000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c8063373058b811610066578063373058b8146100ce5780634655478f146100d857806361697d64146100e05780636fc6091d146100e85780639b49989a146100f057610093565b80630cc784761461009857806313f32237146100b657806324044543146100be57806332bf1039146100c6575b600080fd5b6100a06100f8565b6040516100ad9190610542565b60405180910390f35b6100a0610110565b6100a0610128565b6100a0610140565b6100d6610158565b005b6100a061047e565b6100a0610496565b6100a06104ba565b6100a06104de565b7358e8dcc13be9780fc42e8723d8ead4cf46943df281565b732fc93484614a34f26f7970cbb94615ba109bb4bf81565b73fa4c1f3f7d5dd7c12a9adb82cd7dda542e3d59ef81565b7377777feddddffc19ff86db637967013e6c6a116c81565b6040516370a0823160e01b8152732fc93484614a34f26f7970cbb94615ba109bb4bf90819063f58073b1907377777feddddffc19ff86db637967013e6c6a116c906370a08231906101ad908590600401610542565b60206040518083038186803b1580156101c557600080fd5b505afa1580156101d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101fd919061052a565b6040518263ffffffff1660e01b81526004016102199190610592565b600060405180830381600087803b15801561023357600080fd5b505af1158015610247573d6000803e3d6000fd5b5050604051631b2ce7f360e11b81527358e8dcc13be9780fc42e8723d8ead4cf46943df29250633659cfe691506102a2907f000000000000000000000000000000000000000000000000000000000000000090600401610542565b600060405180830381600087803b1580156102bc57600080fd5b505af11580156102d0573d6000803e3d6000fd5b50505050735efda50f22d34f262c29268506c5fa42cb56a1ce6001600160a01b0316633659cfe67f000000000000000000000000000000000000000000000000000000000000000073fa4c1f3f7d5dd7c12a9adb82cd7dda542e3d59ef732f50508a8a3d323b91336fa3ea6ae50e55f3218560405161034e906104f6565b61035a93929190610556565b604051809103906000f080158015610376573d6000803e3d6000fd5b506040518263ffffffff1660e01b81526004016103939190610542565b600060405180830381600087803b1580156103ad57600080fd5b505af11580156103c1573d6000803e3d6000fd5b505060405163a9059cbb60e01b81527377777feddddffc19ff86db637967013e6c6a116c925063a9059cbb9150610428907f0000000000000000000000000000000000000000000000000000000000000000906913ecbccf7737e6b0000090600401610579565b602060405180830381600087803b15801561044257600080fd5b505af1158015610456573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061047a9190610503565b5050565b735efda50f22d34f262c29268506c5fa42cb56a1ce81565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b732f50508a8a3d323b91336fa3ea6ae50e55f3218581565b6134348061059c83390190565b600060208284031215610514578081fd5b81518015158114610523578182fd5b9392505050565b60006020828403121561053b578081fd5b5051919050565b6001600160a01b0391909116815260200190565b6001600160a01b0393841681529183166020830152909116604082015260600190565b6001600160a01b03929092168252602082015260400190565b9081526020019056fe60e06040523480156200001157600080fd5b50604051620034343803806200343483398101604081905262000034916200016b565b82828281818181600060019054906101000a900460ff16806200005c57506200005c62000124565b806200006b575060005460ff16155b620000935760405162461bcd60e51b81526004016200008a90620001be565b60405180910390fd5b600054610100900460ff16158015620000bf576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b03191661dead179055620000dd6200012a565b8015620000f0576000805461ff00191690555b506001600160601b0319606091821b811660805291811b821660a0529590951b90941660c052506200022595505050505050565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b60008060006060848603121562000180578283fd5b83516200018d816200020c565b6020850151909350620001a0816200020c565b6040850151909250620001b3816200020c565b809150509250925092565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b6001600160a01b03811681146200022257600080fd5b50565b60805160601c60a05160601c60c05160601c6131ac6200028860003980610d1352806110d452806116c752806117f85250806109105280610eca5280610fc252806116435280611d6d52508061105d5280611c1652806124f152506131ac6000f3fe6080604052600436106102815760003560e01c80639daafec71161014f578063d6f0948c116100c1578063ea0217cf1161007a578063ea0217cf14610755578063ece40cc114610775578063ef3f8bb114610795578063f0b76892146107b5578063f57df22e146107d5578063fe0d94c1146107ea57610288565b8063d6f0948c14610693578063da35c664146106b3578063e01f5237146106c8578063e23a9a52146106e8578063e4917d9f14610715578063e525aa081461073557610288565b8063b54426c811610113578063b54426c8146105e9578063b859f11b14610609578063c0c0e82014610629578063c4d66de814610649578063ce25d71c14610669578063d6159fe51461067e57610288565b80639daafec714610575578063a6c266031461058a578063a72edda31461059f578063adf898a4146105bf578063b1610d7e146105d457610288565b80635c19a95c116101f357806370b0f660116101ac57806370b0f660146104cb5780638b34a960146104eb57806392ab89bb14610500578063932d5157146105155780639a9e3b6e146105355780639ae697bf1461055557610288565b80635c19a95c146104215780636198e3391461044157806365da126414610461578063671dd275146104815780636a661755146104965780636dc2dc6c146104ab57610288565b806332687ec11161024557806332687ec11461035b57806337f135d7146103885780633e4f49e61461039d57806354fd4d50146103ca578063587a6ecb146103ec57806358e9fff01461040157610288565b8063013cf08b1461028d57806302ec8f9e146102ca57806315373e3d146102ec57806317977c611461030c57806324b0435f1461033957610288565b3661028857005b600080fd5b34801561029957600080fd5b506102ad6102a83660046128e1565b6107fd565b6040516102c19897969594939291906129ed565b60405180910390f35b3480156102d657600080fd5b506102ea6102e53660046128e1565b610862565b005b3480156102f857600080fd5b506102ea610307366004612925565b61088f565b34801561031857600080fd5b5061032c6103273660046126d8565b610992565b6040516102c19190612ab6565b34801561034557600080fd5b5061034e6109a4565b6040516102c1919061299c565b34801561036757600080fd5b5061037b6103763660046128e1565b6109bc565b6040516102c19190612aab565b34801561039457600080fd5b5061032c610a0a565b3480156103a957600080fd5b506103bd6103b83660046128e1565b610a10565b6040516102c19190612abf565b3480156103d657600080fd5b506103df610b4c565b6040516102c19190612ad3565b3480156103f857600080fd5b5061032c610b75565b34801561040d57600080fd5b5061032c61041c3660046126f3565b610b7b565b34801561042d57600080fd5b506102ea61043c3660046126d8565b610bc9565b34801561044d57600080fd5b506102ea61045c3660046128e1565b610ceb565b34801561046d57600080fd5b5061034e61047c3660046126d8565b610e38565b34801561048d57600080fd5b5061032c610e53565b3480156104a257600080fd5b5061032c610e59565b3480156104b757600080fd5b506102ea6104c63660046128e1565b610e5f565b3480156104d757600080fd5b506102ea6104e63660046128e1565b610ea4565b3480156104f757600080fd5b5061034e610ec8565b34801561050c57600080fd5b506102ea610eec565b34801561052157600080fd5b506102ea6105303660046128e1565b610f73565b34801561054157600080fd5b506102ea6105503660046128e1565b611025565b34801561056157600080fd5b5061032c6105703660046126d8565b611049565b34801561058157600080fd5b5061034e61105b565b34801561059657600080fd5b5061032c61107f565b3480156105ab57600080fd5b5061032c6105ba3660046126d8565b611085565b3480156105cb57600080fd5b5061034e611097565b3480156105e057600080fd5b5061032c6110a6565b3480156105f557600080fd5b506102ea6106043660046128e1565b6110ac565b34801561061557600080fd5b506102ea610624366004612800565b6111f5565b34801561063557600080fd5b506102ea6106443660046128e1565b611243565b34801561065557600080fd5b506102ea6106643660046126d8565b611267565b34801561067557600080fd5b5061032c6114aa565b34801561068a57600080fd5b5061032c6114b0565b34801561069f57600080fd5b5061032c6106ae366004612753565b6114b6565b3480156106bf57600080fd5b5061032c6114cc565b3480156106d457600080fd5b5061032c6106e33660046128e1565b6114d6565b3480156106f457600080fd5b506107086107033660046128f9565b6114e8565b6040516102c191906130db565b34801561072157600080fd5b506102ea6107303660046128e1565b61155a565b34801561074157600080fd5b5061037b6107503660046128f9565b61157e565b34801561076157600080fd5b506102ea6107703660046128e1565b6115c1565b34801561078157600080fd5b506102ea6107903660046128e1565b6115e5565b3480156107a157600080fd5b506102ea6107b03660046128e1565b611609565b3480156107c157600080fd5b506102ea6107d03660046127a1565b61169b565b3480156107e157600080fd5b5061034e6117f6565b6102ea6107f83660046128e1565b61181a565b603d818154811061080a57fe5b600091825260209091206008909102018054600182015460028301546003840154600485015460058601546006909601546001600160a01b039586169750949093169491939092919060ff8082169161010090041688565b33301461088a5760405162461bcd60e51b815260040161088190612e49565b60405180910390fd5b603555565b3361089a833361157e565b1580156108ad57506108ab836109bc565b155b3332146108bb5760006108bf565b6152085b61ffff1681156109805760005a90506108d93387876118ac565b60006108f66127106108f0856108f05a8790611add565b90611b1f565b60405163a99ce80760e01b81529091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a99ce8079061094790889085906004016129b0565b600060405180830381600087803b15801561096157600080fd5b505af1158015610975573d6000803e3d6000fd5b50505050505061098b565b61098b3386866118ac565b5050505050565b603e6020526000908152604090205481565b73b04e030140b30c27bcdfaafffa98c57d80eda7b490565b6000603554603d83815481106109ce57fe5b906000526020600020906008020160050154603d84815481106109ed57fe5b90600052602060002090600802016004015401101590505b919050565b60335481565b6000610a1a6114cc565b8211158015610a295750600082115b610a455760405162461bcd60e51b815260040161088190612fa6565b6000603d8381548110610a5457fe5b906000526020600020906008020190508060020154610a71611b44565b11610a80576000915050610a05565b8060030154610a8d611b44565b11610a9c576001915050610a05565b80600501548160040154111580610abe57506035548160050154826004015401105b15610acd576002915050610a05565b600681015460ff1615610ae4576005915050610a05565b610b036034546108f06033548460030154611b1f90919063ffffffff16565b610b0b611b44565b10610b1a576006915050610a05565b6033546003820154610b2b91611b1f565b610b33611b44565b10610b42576004915050610a05565b6003915050610a05565b60408051808201909152600f81526e0d0b9c185d18da0b595e1c1b1bda5d608a1b602082015290565b603a5481565b6001600160a01b038381166000908152603c60205260408120549091163314610bb65760405162461bcd60e51b815260040161088190613036565b610bc1848484611b48565b949350505050565b336000818152603c60205260409020546001600160a01b039081169190831614801590610bff57506001600160a01b0382163014155b8015610c1357506001600160a01b03821615155b8015610c315750806001600160a01b0316826001600160a01b031614155b610c4d5760405162461bcd60e51b815260040161088190612e80565b6001600160a01b03811615610c93576040516001600160a01b0382169033907f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7290600090a35b336000818152603c602052604080822080546001600160a01b0319166001600160a01b03871690811790915590519092917f4bc154dd35d6a5cb9206482ecb473cdbf2473006d6bce728b9cc0741bcc59ea291a35050565b336000818152603b60205260409081902054905163e113335f60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163e113335f91610d489185916004016129b0565b600060405180830381600087803b158015610d6257600080fd5b505af1925050508015610d73575060015b610df6573d808015610da1576040519150601f19603f3d011682016040523d82523d6000602084013e610da6565b606091505b5080604051610db59190612980565b604051908190038120906001600160a01b038416907f5a6216e80d86159dc87dcebfe519205477a94005b7d9d6bd313606450a5344f690600090a350610e2b565b6040516001600160a01b038216907f9b227b0c1ae308b34f72d4fdf9a1943fa769ff4814933595e7bc5230a117698b90600090a25b610e3482611b70565b5050565b603c602052600090815260409020546001600160a01b031681565b60355481565b60345481565b333014610e7e5760405162461bcd60e51b815260040161088190612e49565b6033548110610e9f5760405162461bcd60e51b815260040161088190612d6d565b603a55565b333014610ec35760405162461bcd60e51b815260040161088190612e49565b603755565b7f000000000000000000000000000000000000000000000000000000000000000081565b336000908152603c60205260409020546001600160a01b031680610f225760405162461bcd60e51b815260040161088190612fec565b336000818152603c602052604080822080546001600160a01b0319169055516001600160a01b03841692917f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7291a350565b610f7b6109a4565b6001600160a01b0316336001600160a01b031614610fab5760405162461bcd60e51b815260040161088190612f7f565b604051633a08bde160e21b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063e822f78490610ff7908490600401612ab6565b600060405180830381600087803b15801561101157600080fd5b505af115801561098b573d6000803e3d6000fd5b3330146110445760405162461bcd60e51b815260040161088190612e49565b603455565b603b6020526000908152604090205481565b7f000000000000000000000000000000000000000000000000000000000000000081565b60365481565b603f6020526000908152604090205481565b6040546001600160a01b031681565b60385481565b336000818152603b60205260409081902054905163e113335f60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163e113335f916111099185916004016129b0565b600060405180830381600087803b15801561112357600080fd5b505af1925050508015611134575060015b6111b7573d808015611162576040519150601f19603f3d011682016040523d82523d6000602084013e611167565b606091505b50806040516111769190612980565b604051908190038120906001600160a01b038416907f5a6216e80d86159dc87dcebfe519205477a94005b7d9d6bd313606450a5344f690600090a3506111ec565b6040516001600160a01b038216907f9b227b0c1ae308b34f72d4fdf9a1943fa769ff4814933595e7bc5230a117698b90600090a25b610e3482611c54565b60008351116112165760405162461bcd60e51b815260040161088190612e1f565b61123e838383611226863361157e565b1580156112395750611237866109bc565b155b611c5e565b505050565b3330146112625760405162461bcd60e51b815260040161088190612e49565b603955565b600054610100900460ff16806112805750611280611ea1565b8061128e575060005460ff16155b6112aa5760405162461bcd60e51b815260040161088190612f31565b600054610100900460ff161580156112d5576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b038085166001600160a01b03199283161783558251610100818101855230825261dead602083019081526000958301868152606084018781526080850188815260a08601898152600160c0880181815260e089018c8152603d80549384018155909c52975160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b16928c169290921790915594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc4860180549190991699169890981790965590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc5830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc682015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc784015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc8830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990910180549351151590920261ff001991151560ff199094169390931716919091179055611495611ea7565b8015610e34576000805461ff00191690555050565b60395481565b60375481565b60006114c3338484611b48565b90505b92915050565b603d546000190190565b60416020526000908152604090205481565b6114f06125d2565b603d83815481106114fd57fe5b600091825260208083206001600160a01b0395909516835260089190910290930160070183526040908190208151606081018352815460ff8082161515835261010090910416151594810194909452600101549083015250919050565b3330146115795760405162461bcd60e51b815260040161088190612e49565b603355565b6000603d838154811061158d57fe5b600091825260208083206001600160a01b03861684526007600890930201919091019052604090205460ff16905092915050565b3330146115e05760405162461bcd60e51b815260040161088190612e49565b603855565b3330146116045760405162461bcd60e51b815260040161088190612e49565b603655565b6116116109a4565b6001600160a01b0316336001600160a01b0316146116415760405162461bcd60e51b815260040161088190612f7f565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166108fc6116788347611ee8565b6040518115909202916000818181858888f1935050505061169857600080fd5b50565b6001600160a01b038087166000908152603b60205260409081902054905163e113335f60e01b815288927f0000000000000000000000000000000000000000000000000000000000000000169163e113335f916116fc9185916004016129b0565b600060405180830381600087803b15801561171657600080fd5b505af1925050508015611727575060015b6117aa573d808015611755576040519150601f19603f3d011682016040523d82523d6000602084013e61175a565b606091505b50806040516117699190612980565b604051908190038120906001600160a01b038416907f5a6216e80d86159dc87dcebfe519205477a94005b7d9d6bd313606450a5344f690600090a3506117df565b6040516001600160a01b038216907f9b227b0c1ae308b34f72d4fdf9a1943fa769ff4814933595e7bc5230a117698b90600090a25b6117ed878787878787611efe565b50505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b3330141561183a5760405162461bcd60e51b815260040161088190612c36565b6000603d828154811061184957fe5b6000918252602080832060016008909302019182015485845260419091526040909220549092506001600160a01b0390911690813f90811461189d5760405162461bcd60e51b815260040161088190612d17565b6118a684611f7e565b50505050565b60016118b783610a10565b60068111156118c257fe5b146118df5760405162461bcd60e51b815260040161088190612bef565b6000603d83815481106118ee57fe5b600091825260208083206001600160a01b038816845260076008909302019182018152604080842060058401546004850154603b90945291909420549294501015908061194d5760405162461bcd60e51b815260040161088190612eb7565b825460ff161561199c578254610100900460ff1615611983576001830154600485015461197991611add565b600485015561199c565b6001830154600585015461199691611add565b60058501555b84156119bb5760048401546119b19082611b1f565b60048501556119d0565b60058401546119ca9082611b1f565b60058501555b6006840154610100900460ff16158015611a0057506039546119fe6119f3611b44565b600387015490611add565b105b15611a44576005840154600485015411158215158114611a425760068501805461ff001916610100179055603a546003860154611a3c91611b1f565b60038601555b505b8254600160ff19909116811761ff001916610100871515021784558301819055603354603454603a546003870154611a8f938b93611a8a9391926108f092839190611b1f565b612110565b841515876001600160a01b0316877f7c2de587c00d75474a0c6c6fa96fd3b45dc974cd4e8a75f712bb84c950dce1b584604051611acc9190612ab6565b60405180910390a450505050505050565b60006114c383836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f77000081525061214d565b6000828201838110156114c35760405162461bcd60e51b815260040161088190612ce0565b4290565b6000611b55848484612179565b6000818152604160205260409020933f909355509092915050565b336000908152603f6020526040902054611b88611b44565b11611ba55760405162461bcd60e51b815260040161088190612db1565b60408051808201825260208082527f476f7665726e616e63653a20696e73756666696369656e742062616c616e636581830152336000908152603b9091529190912054611bf391839061214d565b336000818152603b6020526040908190209290925590516391fe357360e01b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316916391fe357391610ff7919085906004016129b0565b61169833826124c7565b3381328214611c6e576000611c72565b6152085b61ffff168115611ddd5760005a905060005b8851811015611d3b576000898281518110611c9b57fe5b6020908102919091018101516001600160a01b038082166000908152603c90935260409092205490925016331480611cdb57506001600160a01b03811633145b611cf75760405162461bcd60e51b815260040161088190613036565b861580611d0b5750611d09898261157e565b155b611d275760405162461bcd60e51b8152600401610881906130a4565b611d32818a8a6118ac565b50600101611c84565b506000611d536127106108f0856108f05a8790611add565b60405163a99ce80760e01b81529091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a99ce80790611da490889085906004016129b0565b600060405180830381600087803b158015611dbe57600080fd5b505af1158015611dd2573d6000803e3d6000fd5b5050505050506117ed565b60005b8751811015611e97576000888281518110611df757fe5b6020908102919091018101516001600160a01b038082166000908152603c90935260409092205490925016331480611e3757506001600160a01b03811633145b611e535760405162461bcd60e51b815260040161088190613036565b851580611e675750611e65888261157e565b155b611e835760405162461bcd60e51b8152600401610881906130a4565b611e8e8189896118ac565b50600101611de0565b5050505050505050565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b6000818310611ef757816114c3565b5090919050565b60408054905163d505accf60e01b81526001600160a01b039091169063d505accf90611f3a90899030908a908a908a908a908a90600401612a33565b600060405180830381600087803b158015611f5457600080fd5b505af1158015611f68573d6000803e3d6000fd5b50505050611f7686866124c7565b505050505050565b6004611f8982610a10565b6006811115611f9457fe5b14611fb15760405162461bcd60e51b815260040161088190612b29565b6000603d8281548110611fc057fe5b600091825260209091206006600890920201908101805460ff191660019081179091558101549091506001600160a01b0316611ffb816125cc565b6120175760405162461bcd60e51b815260040161088190612ae6565b60408051600481526024810182526020810180516001600160e01b03166306e60b1760e31b17905290516000916060916001600160a01b0385169161205b91612980565b600060405180830381855af49150503d8060008114612096576040519150601f19603f3d011682016040523d82523d6000602084013e61209b565b606091505b5091509150816120de578051156120c6578060405162461bcd60e51b81526004016108819190612ad3565b60405162461bcd60e51b81526004016108819061306d565b60405185907f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f90600090a25050505050565b6001600160a01b0382166000908152603f6020526040902054811115610e34576001600160a01b03919091166000908152603f6020526040902055565b600081848411156121715760405162461bcd60e51b81526004016108819190612ad3565b505050900390565b6001600160a01b0383166000908152603b60205260408120546036548110156121b45760405162461bcd60e51b815260040161088190612c83565b6121bd846125cc565b6121d95760405162461bcd60e51b815260040161088190612eee565b6001600160a01b0385166000908152603e6020526040902054801561224b57600061220382610a10565b9050600181600681111561221357fe5b1415801561222d5750600081600681111561222a57fe5b14155b6122495760405162461bcd60e51b815260040161088190612b74565b505b600061225b6037546108f0611b44565b9050600061227460385483611b1f90919063ffffffff16565b905061227e6125f2565b506040805161010080820183526001600160a01b03808c1683528a8116602084019081529383018681526060840186815260006080860181815260a0870182815260c0880183815260e08901848152603d80546001810182559086528a5160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b166001600160a01b03199384161790559b517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc48d01805491909a1691161790975594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc58a015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc6890155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc788015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc887015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990950180549251151590930261ff001995151560ff199093169290921794909416179055906124306114cc565b82516001600160a01b03166000908152603e60205260409020819055603354603454603a54929350612472928d92611a8a9290916108f0919082908a90611b1f565b896001600160a01b0316817f90ec05050aa23d54ba425e926fe646c318e85825bc400b13a46010abe86eb2f08b87878d6040516124b29493929190612a74565b60405180910390a39998505050505050505050565b6040805490516323b872dd60e01b81526001600160a01b03909116906323b872dd9061251b9085907f00000000000000000000000000000000000000000000000000000000000000009086906004016129c9565b602060405180830381600087803b15801561253557600080fd5b505af1158015612549573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061256d91906128c5565b6125895760405162461bcd60e51b815260040161088190612de8565b6001600160a01b0382166000908152603b60205260409020546125ac9082611b1f565b6001600160a01b039092166000908152603b602052604090209190915550565b3b151590565b604080516060810182526000808252602082018190529181019190915290565b60405180610100016040528060006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b80356001600160a01b03811681146114c657600080fd5b80356114c681613168565b600082601f83011261267f578081fd5b813567ffffffffffffffff811115612695578182fd5b6126a8601f8201601f1916602001613100565b91508082528360208285010111156126bf57600080fd5b8060208401602084013760009082016020015292915050565b6000602082840312156126e9578081fd5b6114c3838361264d565b600080600060608486031215612707578182fd5b833561271281613153565b9250602084013561272281613153565b9150604084013567ffffffffffffffff81111561273d578182fd5b6127498682870161266f565b9150509250925092565b60008060408385031215612765578182fd5b823561277081613153565b9150602083013567ffffffffffffffff81111561278b578182fd5b6127978582860161266f565b9150509250929050565b60008060008060008060c087890312156127b9578182fd5b6127c3888861264d565b95506020870135945060408701359350606087013560ff811681146127e6578283fd5b9598949750929560808101359460a0909101359350915050565b600080600060608486031215612814578283fd5b833567ffffffffffffffff8082111561282b578485fd5b818601915086601f83011261283e578485fd5b81358181111561284c578586fd5b6020915081810261285e838201613100565b8281528381019085850183870186018c101561287857898afd5b8996505b848710156128a25761288e8c8261264d565b83526001969096019591850191850161287c565b50975050505085013592506128bc90508560408601612664565b90509250925092565b6000602082840312156128d6578081fd5b81516114c381613168565b6000602082840312156128f2578081fd5b5035919050565b6000806040838503121561290b578182fd5b8235915061291c846020850161264d565b90509250929050565b60008060408385031215612937578182fd5b82359150602083013561294981613168565b809150509250929050565b6000815180845261296c816020860160208601613127565b601f01601f19169290920160200192915050565b60008251612992818460208701613127565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03988916815296909716602087015260408601949094526060850192909252608084015260a0830152151560c082015290151560e08201526101000190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b600060018060a01b038616825284602083015283604083015260806060830152612aa16080830184612954565b9695505050505050565b901515815260200190565b90815260200190565b6020810160078310612acd57fe5b91905290565b6000602082526114c36020830184612954565b60208082526023908201527f476f7665726e616e63653a3a657865637574653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602b908201527f476f7665726e616e63653a3a657865637574653a20696e76616c69642070726f60408201526a706f73616c20737461746560a81b606082015260800190565b60208082526055908201527f476f7665726e616e63653a3a70726f706f73653a206f6e65206c69766520707260408201527f6f706f73616c207065722070726f706f7365722c20666f756e6420616e20616c6060820152741c9958591e481858dd1a5d99481c1c9bdc1bdcd85b605a1b608082015260a00190565b60208082526027908201527f476f7665726e616e63653a3a5f63617374566f74653a20766f74696e672069736040820152660818db1bdcd95960ca1b606082015260800190565b6020808252602d908201527f476f7665726e616e63653a3a70726f706f73653a2070736575646f2d6578746560408201526c393730b610333ab731ba34b7b760991b606082015260800190565b6020808252603c908201527f476f7665726e616e63653a3a70726f706f73653a2070726f706f73657220766f60408201527f7465732062656c6f772070726f706f73616c207468726573686f6c6400000000606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526036908201527f476f7665726e616e63653a3a70726f706f73653a206d6574616d6f72706869636040820152750818dbdb9d1c9858dd1cc81b9bdd08185b1b1bddd95960521b606082015260800190565b60208082526024908201527f476f7665726e616e63653a20696e636f727265637420766f7465457874656e6460408201526354696d6560e01b606082015260800190565b6020808252601d908201527f476f7665726e616e63653a20746f6b656e7320617265206c6f636b6564000000604082015260600190565b60208082526019908201527f544f524e3a207472616e7366657246726f6d206661696c656400000000000000604082015260600190565b60208082526010908201526f43616e206e6f7420626520656d70747960801b604082015260600190565b60208082526018908201527f476f7665726e616e63653a20756e617574686f72697a65640000000000000000604082015260600190565b6020808252601d908201527f476f7665726e616e63653a20696e76616c69642064656c656761746565000000604082015260600190565b60208082526018908201527f476f7665726e616e63653a2062616c616e636520697320300000000000000000604082015260600190565b60208082526023908201527f476f7665726e616e63653a3a70726f706f73653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252600d908201526c6f6e6c79206d756c746973696760981b604082015260600190565b60208082526026908201527f476f7665726e616e63653a3a73746174653a20696e76616c69642070726f706f6040820152651cd85b081a5960d21b606082015260800190565b6020808252602a908201527f476f7665726e616e63653a20746f6b656e732061726520616c726561647920756040820152691b99195b1959d85d195960b21b606082015260800190565b6020808252601a908201527f476f7665726e616e63653a206e6f7420617574686f72697a6564000000000000604082015260600190565b60208082526019908201527f50726f706f73616c20657865637574696f6e206661696c656400000000000000604082015260600190565b60208082526019908201527f476f7665726e616e63653a20766f74656420616c726561647900000000000000604082015260600190565b8151151581526020808301511515908201526040918201519181019190915260600190565b60405181810167ffffffffffffffff8111828210171561311f57600080fd5b604052919050565b60005b8381101561314257818101518382015260200161312a565b838111156118a65750506000910152565b6001600160a01b038116811461169857600080fd5b801515811461169857600080fdfea2646970667358221220b75004153b6c8b4905c018daca78cb0fa6d3859298be55252bcf6ba75ea68d0e64736f6c634300060c0033a26469706673582212204ba1758b9bff1354ea4f43c5374c01c2f89472a8eda340e802e2a467b5710b3764736f6c634300060c0033"; +const isSuperArgs$7 = (xs) => xs.length > 1; +class PatchProposal__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$7(args)) { + super(...args); + } else { + super(_abi$7, _bytecode$7, args[0]); + } + } + getDeployTransaction(_deployedStakingProxyContractAddress, _deployedRelayerRegistryImplementationAddress, overrides) { + return super.getDeployTransaction( + _deployedStakingProxyContractAddress, + _deployedRelayerRegistryImplementationAddress, + overrides || {} + ); + } + deploy(_deployedStakingProxyContractAddress, _deployedRelayerRegistryImplementationAddress, overrides) { + return super.deploy( + _deployedStakingProxyContractAddress, + _deployedRelayerRegistryImplementationAddress, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$7); + } + static connect(address, runner) { + return new Contract(address, _abi$7, runner); + } +} +PatchProposal__factory.bytecode = _bytecode$7; +PatchProposal__factory.abi = _abi$7; + +const _abi$6 = [ + { + inputs: [ + { + internalType: "address", + name: "stakingRewardsAddress", + type: "address" + }, + { + internalType: "address", + name: "gasCompLogic", + type: "address" + }, + { + internalType: "address", + name: "userVaultAddress", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + } + ], + name: "Delegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "id", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "proposer", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "target", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + indexed: false, + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + indexed: false, + internalType: "string", + name: "description", + type: "string" + } + ], + name: "ProposalCreated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "ProposalExecuted", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "bytes", + name: "errorData", + type: "bytes" + } + ], + name: "RewardUpdateFailed", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + } + ], + name: "RewardUpdateSuccessful", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "account", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + } + ], + name: "Undelegated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + indexed: true, + internalType: "address", + name: "voter", + type: "address" + }, + { + indexed: true, + internalType: "bool", + name: "support", + type: "bool" + }, + { + indexed: false, + internalType: "uint256", + name: "votes", + type: "uint256" + } + ], + name: "Voted", + type: "event" + }, + { + inputs: [], + name: "CLOSING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "EXECUTION_EXPIRATION", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "PROPOSAL_THRESHOLD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "QUORUM_VOTES", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "Staking", + outputs: [ + { + internalType: "contract ITornadoStakingRewards", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTE_EXTEND_TIME", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_DELAY", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "VOTING_PERIOD", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "canWithdrawAfter", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address[]", + name: "from", + type: "address[]" + }, + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castDelegatedVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "bool", + name: "support", + type: "bool" + } + ], + name: "castVote", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "checkIfQuorumReached", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + } + ], + name: "delegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "delegatedTo", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "execute", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [], + name: "gasCompensationVault", + outputs: [ + { + internalType: "contract IGasCompensationVault", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "address", + name: "voter", + type: "address" + } + ], + name: "getReceipt", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "hasVoted", + type: "bool" + }, + { + internalType: "bool", + name: "support", + type: "bool" + }, + { + internalType: "uint256", + name: "votes", + type: "uint256" + } + ], + internalType: "struct Governance.Receipt", + name: "", + type: "tuple" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + }, + { + internalType: "address", + name: "account", + type: "address" + } + ], + name: "hasAccountVoted", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "_torn", + type: "address" + } + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "latestProposalIds", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "lock", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "lockWithApproval", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "lockedBalance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "proposalCodehashes", + outputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "proposalCount", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "proposals", + outputs: [ + { + internalType: "address", + name: "proposer", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "uint256", + name: "startTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "endTime", + type: "uint256" + }, + { + internalType: "uint256", + name: "forVotes", + type: "uint256" + }, + { + internalType: "uint256", + name: "againstVotes", + type: "uint256" + }, + { + internalType: "bool", + name: "executed", + type: "bool" + }, + { + internalType: "bool", + name: "extended", + type: "bool" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "propose", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "string", + name: "description", + type: "string" + } + ], + name: "proposeByDelegate", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "returnMultisigAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "pure", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "closingPeriod", + type: "uint256" + } + ], + name: "setClosingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionDelay", + type: "uint256" + } + ], + name: "setExecutionDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "executionExpiration", + type: "uint256" + } + ], + name: "setExecutionExpiration", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "gasCompensationsLimit", + type: "uint256" + } + ], + name: "setGasCompensations", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalThreshold", + type: "uint256" + } + ], + name: "setProposalThreshold", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "quorumVotes", + type: "uint256" + } + ], + name: "setQuorumVotes", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "voteExtendTime", + type: "uint256" + } + ], + name: "setVoteExtendTime", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingDelay", + type: "uint256" + } + ], + name: "setVotingDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "votingPeriod", + type: "uint256" + } + ], + name: "setVotingPeriod", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "proposalId", + type: "uint256" + } + ], + name: "state", + outputs: [ + { + internalType: "enum Governance.ProposalState", + name: "", + type: "uint8" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "torn", + outputs: [ + { + internalType: "contract TORN", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "undelegate", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "unlock", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "userVault", + outputs: [ + { + internalType: "contract ITornadoVault", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "version", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + stateMutability: "pure", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "withdrawFromHelper", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + stateMutability: "payable", + type: "receive" + } +]; +const _bytecode$6 = "0x60e06040523480156200001157600080fd5b506040516200344138038062003441833981016040819052620000349162000171565b82828282828281818181600060019054906101000a900460ff16806200005f57506200005f6200012a565b806200006e575060005460ff16155b620000965760405162461bcd60e51b81526004016200008d90620001c4565b60405180910390fd5b600054610100900460ff16158015620000c2576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b03191661dead179055620000e062000130565b8015620000f3576000805461ff00191690555b506001600160601b0319606091821b811660805291811b821660a0529590951b90941660c052506200022b98505050505050505050565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b60008060006060848603121562000186578283fd5b8351620001938162000212565b6020850151909350620001a68162000212565b6040850151909250620001b98162000212565b809150509250925092565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b6001600160a01b03811681146200022857600080fd5b50565b60805160601c60a05160601c60c05160601c6131b36200028e60003980610d1a52806110db52806116ce52806117ff5250806109105280610ed15280610fc9528061164a5280611d745250806110645280611c1d52806124f852506131b36000f3fe6080604052600436106102815760003560e01c80639daafec71161014f578063d6f0948c116100c1578063ea0217cf1161007a578063ea0217cf14610755578063ece40cc114610775578063ef3f8bb114610795578063f0b76892146107b5578063f57df22e146107d5578063fe0d94c1146107ea57610288565b8063d6f0948c14610693578063da35c664146106b3578063e01f5237146106c8578063e23a9a52146106e8578063e4917d9f14610715578063e525aa081461073557610288565b8063b54426c811610113578063b54426c8146105e9578063b859f11b14610609578063c0c0e82014610629578063c4d66de814610649578063ce25d71c14610669578063d6159fe51461067e57610288565b80639daafec714610575578063a6c266031461058a578063a72edda31461059f578063adf898a4146105bf578063b1610d7e146105d457610288565b80635c19a95c116101f357806370b0f660116101ac57806370b0f660146104cb5780638b34a960146104eb57806392ab89bb14610500578063932d5157146105155780639a9e3b6e146105355780639ae697bf1461055557610288565b80635c19a95c146104215780636198e3391461044157806365da126414610461578063671dd275146104815780636a661755146104965780636dc2dc6c146104ab57610288565b806332687ec11161024557806332687ec11461035b57806337f135d7146103885780633e4f49e61461039d57806354fd4d50146103ca578063587a6ecb146103ec57806358e9fff01461040157610288565b8063013cf08b1461028d57806302ec8f9e146102ca57806315373e3d146102ec57806317977c611461030c57806324b0435f1461033957610288565b3661028857005b600080fd5b34801561029957600080fd5b506102ad6102a83660046128e8565b6107fd565b6040516102c19897969594939291906129f4565b60405180910390f35b3480156102d657600080fd5b506102ea6102e53660046128e8565b610862565b005b3480156102f857600080fd5b506102ea61030736600461292c565b61088f565b34801561031857600080fd5b5061032c6103273660046126df565b610992565b6040516102c19190612abd565b34801561034557600080fd5b5061034e6109a4565b6040516102c191906129a3565b34801561036757600080fd5b5061037b6103763660046128e8565b6109bc565b6040516102c19190612ab2565b34801561039457600080fd5b5061032c610a0a565b3480156103a957600080fd5b506103bd6103b83660046128e8565b610a10565b6040516102c19190612ac6565b3480156103d657600080fd5b506103df610b4c565b6040516102c19190612ada565b3480156103f857600080fd5b5061032c610b7c565b34801561040d57600080fd5b5061032c61041c3660046126fa565b610b82565b34801561042d57600080fd5b506102ea61043c3660046126df565b610bd0565b34801561044d57600080fd5b506102ea61045c3660046128e8565b610cf2565b34801561046d57600080fd5b5061034e61047c3660046126df565b610e3f565b34801561048d57600080fd5b5061032c610e5a565b3480156104a257600080fd5b5061032c610e60565b3480156104b757600080fd5b506102ea6104c63660046128e8565b610e66565b3480156104d757600080fd5b506102ea6104e63660046128e8565b610eab565b3480156104f757600080fd5b5061034e610ecf565b34801561050c57600080fd5b506102ea610ef3565b34801561052157600080fd5b506102ea6105303660046128e8565b610f7a565b34801561054157600080fd5b506102ea6105503660046128e8565b61102c565b34801561056157600080fd5b5061032c6105703660046126df565b611050565b34801561058157600080fd5b5061034e611062565b34801561059657600080fd5b5061032c611086565b3480156105ab57600080fd5b5061032c6105ba3660046126df565b61108c565b3480156105cb57600080fd5b5061034e61109e565b3480156105e057600080fd5b5061032c6110ad565b3480156105f557600080fd5b506102ea6106043660046128e8565b6110b3565b34801561061557600080fd5b506102ea610624366004612807565b6111fc565b34801561063557600080fd5b506102ea6106443660046128e8565b61124a565b34801561065557600080fd5b506102ea6106643660046126df565b61126e565b34801561067557600080fd5b5061032c6114b1565b34801561068a57600080fd5b5061032c6114b7565b34801561069f57600080fd5b5061032c6106ae36600461275a565b6114bd565b3480156106bf57600080fd5b5061032c6114d3565b3480156106d457600080fd5b5061032c6106e33660046128e8565b6114dd565b3480156106f457600080fd5b50610708610703366004612900565b6114ef565b6040516102c191906130e2565b34801561072157600080fd5b506102ea6107303660046128e8565b611561565b34801561074157600080fd5b5061037b610750366004612900565b611585565b34801561076157600080fd5b506102ea6107703660046128e8565b6115c8565b34801561078157600080fd5b506102ea6107903660046128e8565b6115ec565b3480156107a157600080fd5b506102ea6107b03660046128e8565b611610565b3480156107c157600080fd5b506102ea6107d03660046127a8565b6116a2565b3480156107e157600080fd5b5061034e6117fd565b6102ea6107f83660046128e8565b611821565b603d818154811061080a57fe5b600091825260209091206008909102018054600182015460028301546003840154600485015460058601546006909601546001600160a01b039586169750949093169491939092919060ff8082169161010090041688565b33301461088a5760405162461bcd60e51b815260040161088190612e50565b60405180910390fd5b603555565b3361089a8333611585565b1580156108ad57506108ab836109bc565b155b3332146108bb5760006108bf565b6152085b61ffff1681156109805760005a90506108d93387876118b3565b60006108f66127106108f0856108f05a8790611ae4565b90611b26565b60405163a99ce80760e01b81529091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a99ce8079061094790889085906004016129b7565b600060405180830381600087803b15801561096157600080fd5b505af1158015610975573d6000803e3d6000fd5b50505050505061098b565b61098b3386866118b3565b5050505050565b603e6020526000908152604090205481565b73b04e030140b30c27bcdfaafffa98c57d80eda7b490565b6000603554603d83815481106109ce57fe5b906000526020600020906008020160050154603d84815481106109ed57fe5b90600052602060002090600802016004015401101590505b919050565b60335481565b6000610a1a6114d3565b8211158015610a295750600082115b610a455760405162461bcd60e51b815260040161088190612fad565b6000603d8381548110610a5457fe5b906000526020600020906008020190508060020154610a71611b4b565b11610a80576000915050610a05565b8060030154610a8d611b4b565b11610a9c576001915050610a05565b600681015460ff1615610ab3576005915050610a05565b80600501548160040154111580610ad557506035548160050154826004015401105b15610ae4576002915050610a05565b610b036034546108f06033548460030154611b2690919063ffffffff16565b610b0b611b4b565b10610b1a576006915050610a05565b6033546003820154610b2b91611b26565b610b33611b4b565b10610b42576004915050610a05565b6003915050610a05565b60408051808201909152601681527506a5ce0e4dee0dee6c2d85ae6e8c2e8ca5ae0c2e8c6d60531b602082015290565b603a5481565b6001600160a01b038381166000908152603c60205260408120549091163314610bbd5760405162461bcd60e51b81526004016108819061303d565b610bc8848484611b4f565b949350505050565b336000818152603c60205260409020546001600160a01b039081169190831614801590610c0657506001600160a01b0382163014155b8015610c1a57506001600160a01b03821615155b8015610c385750806001600160a01b0316826001600160a01b031614155b610c545760405162461bcd60e51b815260040161088190612e87565b6001600160a01b03811615610c9a576040516001600160a01b0382169033907f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7290600090a35b336000818152603c602052604080822080546001600160a01b0319166001600160a01b03871690811790915590519092917f4bc154dd35d6a5cb9206482ecb473cdbf2473006d6bce728b9cc0741bcc59ea291a35050565b336000818152603b60205260409081902054905163e113335f60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163e113335f91610d4f9185916004016129b7565b600060405180830381600087803b158015610d6957600080fd5b505af1925050508015610d7a575060015b610dfd573d808015610da8576040519150601f19603f3d011682016040523d82523d6000602084013e610dad565b606091505b5080604051610dbc9190612987565b604051908190038120906001600160a01b038416907f5a6216e80d86159dc87dcebfe519205477a94005b7d9d6bd313606450a5344f690600090a350610e32565b6040516001600160a01b038216907f9b227b0c1ae308b34f72d4fdf9a1943fa769ff4814933595e7bc5230a117698b90600090a25b610e3b82611b77565b5050565b603c602052600090815260409020546001600160a01b031681565b60355481565b60345481565b333014610e855760405162461bcd60e51b815260040161088190612e50565b6033548110610ea65760405162461bcd60e51b815260040161088190612d74565b603a55565b333014610eca5760405162461bcd60e51b815260040161088190612e50565b603755565b7f000000000000000000000000000000000000000000000000000000000000000081565b336000908152603c60205260409020546001600160a01b031680610f295760405162461bcd60e51b815260040161088190612ff3565b336000818152603c602052604080822080546001600160a01b0319169055516001600160a01b03841692917f1af5b1c85495b3618ea659a1ba256c8b8974b437297d3b914e321e086a28da7291a350565b610f826109a4565b6001600160a01b0316336001600160a01b031614610fb25760405162461bcd60e51b815260040161088190612f86565b604051633a08bde160e21b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063e822f78490610ffe908490600401612abd565b600060405180830381600087803b15801561101857600080fd5b505af115801561098b573d6000803e3d6000fd5b33301461104b5760405162461bcd60e51b815260040161088190612e50565b603455565b603b6020526000908152604090205481565b7f000000000000000000000000000000000000000000000000000000000000000081565b60365481565b603f6020526000908152604090205481565b6040546001600160a01b031681565b60385481565b336000818152603b60205260409081902054905163e113335f60e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163e113335f916111109185916004016129b7565b600060405180830381600087803b15801561112a57600080fd5b505af192505050801561113b575060015b6111be573d808015611169576040519150601f19603f3d011682016040523d82523d6000602084013e61116e565b606091505b508060405161117d9190612987565b604051908190038120906001600160a01b038416907f5a6216e80d86159dc87dcebfe519205477a94005b7d9d6bd313606450a5344f690600090a3506111f3565b6040516001600160a01b038216907f9b227b0c1ae308b34f72d4fdf9a1943fa769ff4814933595e7bc5230a117698b90600090a25b610e3b82611c5b565b600083511161121d5760405162461bcd60e51b815260040161088190612e26565b61124583838361122d8633611585565b158015611240575061123e866109bc565b155b611c65565b505050565b3330146112695760405162461bcd60e51b815260040161088190612e50565b603955565b600054610100900460ff16806112875750611287611ea8565b80611295575060005460ff16155b6112b15760405162461bcd60e51b815260040161088190612f38565b600054610100900460ff161580156112dc576000805460ff1961ff0019909116610100171660011790555b604080546001600160a01b038085166001600160a01b03199283161783558251610100818101855230825261dead602083019081526000958301868152606084018781526080850188815260a08601898152600160c0880181815260e089018c8152603d80549384018155909c52975160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b16928c169290921790915594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc4860180549190991699169890981790965590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc5830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc682015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc784015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc8830155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990910180549351151590920261ff001991151560ff19909416939093171691909117905561149c611eae565b8015610e3b576000805461ff00191690555050565b60395481565b60375481565b60006114ca338484611b4f565b90505b92915050565b603d546000190190565b60416020526000908152604090205481565b6114f76125d9565b603d838154811061150457fe5b600091825260208083206001600160a01b0395909516835260089190910290930160070183526040908190208151606081018352815460ff8082161515835261010090910416151594810194909452600101549083015250919050565b3330146115805760405162461bcd60e51b815260040161088190612e50565b603355565b6000603d838154811061159457fe5b600091825260208083206001600160a01b03861684526007600890930201919091019052604090205460ff16905092915050565b3330146115e75760405162461bcd60e51b815260040161088190612e50565b603855565b33301461160b5760405162461bcd60e51b815260040161088190612e50565b603655565b6116186109a4565b6001600160a01b0316336001600160a01b0316146116485760405162461bcd60e51b815260040161088190612f86565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166108fc61167f8347611eef565b6040518115909202916000818181858888f1935050505061169f57600080fd5b50565b6001600160a01b038087166000908152603b60205260409081902054905163e113335f60e01b815288927f0000000000000000000000000000000000000000000000000000000000000000169163e113335f916117039185916004016129b7565b600060405180830381600087803b15801561171d57600080fd5b505af192505050801561172e575060015b6117b1573d80801561175c576040519150601f19603f3d011682016040523d82523d6000602084013e611761565b606091505b50806040516117709190612987565b604051908190038120906001600160a01b038416907f5a6216e80d86159dc87dcebfe519205477a94005b7d9d6bd313606450a5344f690600090a3506117e6565b6040516001600160a01b038216907f9b227b0c1ae308b34f72d4fdf9a1943fa769ff4814933595e7bc5230a117698b90600090a25b6117f4878787878787611f05565b50505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b333014156118415760405162461bcd60e51b815260040161088190612c3d565b6000603d828154811061185057fe5b6000918252602080832060016008909302019182015485845260419091526040909220549092506001600160a01b0390911690813f9081146118a45760405162461bcd60e51b815260040161088190612d1e565b6118ad84611f85565b50505050565b60016118be83610a10565b60068111156118c957fe5b146118e65760405162461bcd60e51b815260040161088190612bf6565b6000603d83815481106118f557fe5b600091825260208083206001600160a01b038816845260076008909302019182018152604080842060058401546004850154603b9094529190942054929450101590806119545760405162461bcd60e51b815260040161088190612ebe565b825460ff16156119a3578254610100900460ff161561198a576001830154600485015461198091611ae4565b60048501556119a3565b6001830154600585015461199d91611ae4565b60058501555b84156119c25760048401546119b89082611b26565b60048501556119d7565b60058401546119d19082611b26565b60058501555b6006840154610100900460ff16158015611a075750603954611a056119fa611b4b565b600387015490611ae4565b105b15611a4b576005840154600485015411158215158114611a495760068501805461ff001916610100179055603a546003860154611a4391611b26565b60038601555b505b8254600160ff19909116811761ff001916610100871515021784558301819055603354603454603a546003870154611a96938b93611a919391926108f092839190611b26565b612117565b841515876001600160a01b0316877f7c2de587c00d75474a0c6c6fa96fd3b45dc974cd4e8a75f712bb84c950dce1b584604051611ad39190612abd565b60405180910390a450505050505050565b60006114ca83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612154565b6000828201838110156114ca5760405162461bcd60e51b815260040161088190612ce7565b4290565b6000611b5c848484612180565b6000818152604160205260409020933f909355509092915050565b336000908152603f6020526040902054611b8f611b4b565b11611bac5760405162461bcd60e51b815260040161088190612db8565b60408051808201825260208082527f476f7665726e616e63653a20696e73756666696369656e742062616c616e636581830152336000908152603b9091529190912054611bfa918390612154565b336000818152603b6020526040908190209290925590516391fe357360e01b81527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316916391fe357391610ffe919085906004016129b7565b61169f33826124ce565b3381328214611c75576000611c79565b6152085b61ffff168115611de45760005a905060005b8851811015611d42576000898281518110611ca257fe5b6020908102919091018101516001600160a01b038082166000908152603c90935260409092205490925016331480611ce257506001600160a01b03811633145b611cfe5760405162461bcd60e51b81526004016108819061303d565b861580611d125750611d108982611585565b155b611d2e5760405162461bcd60e51b8152600401610881906130ab565b611d39818a8a6118b3565b50600101611c8b565b506000611d5a6127106108f0856108f05a8790611ae4565b60405163a99ce80760e01b81529091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a99ce80790611dab90889085906004016129b7565b600060405180830381600087803b158015611dc557600080fd5b505af1158015611dd9573d6000803e3d6000fd5b5050505050506117f4565b60005b8751811015611e9e576000888281518110611dfe57fe5b6020908102919091018101516001600160a01b038082166000908152603c90935260409092205490925016331480611e3e57506001600160a01b03811633145b611e5a5760405162461bcd60e51b81526004016108819061303d565b851580611e6e5750611e6c8882611585565b155b611e8a5760405162461bcd60e51b8152600401610881906130ab565b611e958189896118b3565b50600101611de7565b5050505050505050565b303b1590565b6202a3006033556203f480603481905569054b40b1f852bda00000603555683635c9adc5dea00000603655604b603755603855610e10603955615460603a55565b6000818310611efe57816114ca565b5090919050565b60408054905163d505accf60e01b81526001600160a01b039091169063d505accf90611f4190899030908a908a908a908a908a90600401612a3a565b600060405180830381600087803b158015611f5b57600080fd5b505af1158015611f6f573d6000803e3d6000fd5b50505050611f7d86866124ce565b505050505050565b6004611f9082610a10565b6006811115611f9b57fe5b14611fb85760405162461bcd60e51b815260040161088190612b30565b6000603d8281548110611fc757fe5b600091825260209091206006600890920201908101805460ff191660019081179091558101549091506001600160a01b0316612002816125d3565b61201e5760405162461bcd60e51b815260040161088190612aed565b60408051600481526024810182526020810180516001600160e01b03166306e60b1760e31b17905290516000916060916001600160a01b0385169161206291612987565b600060405180830381855af49150503d806000811461209d576040519150601f19603f3d011682016040523d82523d6000602084013e6120a2565b606091505b5091509150816120e5578051156120cd578060405162461bcd60e51b81526004016108819190612ada565b60405162461bcd60e51b815260040161088190613074565b60405185907f712ae1383f79ac853f8d882153778e0260ef8f03b504e2866e0593e04d2b291f90600090a25050505050565b6001600160a01b0382166000908152603f6020526040902054811115610e3b576001600160a01b03919091166000908152603f6020526040902055565b600081848411156121785760405162461bcd60e51b81526004016108819190612ada565b505050900390565b6001600160a01b0383166000908152603b60205260408120546036548110156121bb5760405162461bcd60e51b815260040161088190612c8a565b6121c4846125d3565b6121e05760405162461bcd60e51b815260040161088190612ef5565b6001600160a01b0385166000908152603e6020526040902054801561225257600061220a82610a10565b9050600181600681111561221a57fe5b141580156122345750600081600681111561223157fe5b14155b6122505760405162461bcd60e51b815260040161088190612b7b565b505b60006122626037546108f0611b4b565b9050600061227b60385483611b2690919063ffffffff16565b90506122856125f9565b506040805161010080820183526001600160a01b03808c1683528a8116602084019081529383018681526060840186815260006080860181815260a0870182815260c0880183815260e08901848152603d80546001810182559086528a5160089091027fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc381018054928b166001600160a01b03199384161790559b517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc48d01805491909a1691161790975594517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc58a015592517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc6890155517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc788015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc887015590517fece66cfdbd22e3f37d348a3d8e19074452862cd65fd4b9a11f0336d1ac6d1dc990950180549251151590930261ff001995151560ff199093169290921794909416179055906124376114d3565b82516001600160a01b03166000908152603e60205260409020819055603354603454603a54929350612479928d92611a919290916108f0919082908a90611b26565b896001600160a01b0316817f90ec05050aa23d54ba425e926fe646c318e85825bc400b13a46010abe86eb2f08b87878d6040516124b99493929190612a7b565b60405180910390a39998505050505050505050565b6040805490516323b872dd60e01b81526001600160a01b03909116906323b872dd906125229085907f00000000000000000000000000000000000000000000000000000000000000009086906004016129d0565b602060405180830381600087803b15801561253c57600080fd5b505af1158015612550573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061257491906128cc565b6125905760405162461bcd60e51b815260040161088190612def565b6001600160a01b0382166000908152603b60205260409020546125b39082611b26565b6001600160a01b039092166000908152603b602052604090209190915550565b3b151590565b604080516060810182526000808252602082018190529181019190915290565b60405180610100016040528060006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b80356001600160a01b03811681146114cd57600080fd5b80356114cd8161316f565b600082601f830112612686578081fd5b813567ffffffffffffffff81111561269c578182fd5b6126af601f8201601f1916602001613107565b91508082528360208285010111156126c657600080fd5b8060208401602084013760009082016020015292915050565b6000602082840312156126f0578081fd5b6114ca8383612654565b60008060006060848603121561270e578182fd5b83356127198161315a565b925060208401356127298161315a565b9150604084013567ffffffffffffffff811115612744578182fd5b61275086828701612676565b9150509250925092565b6000806040838503121561276c578182fd5b82356127778161315a565b9150602083013567ffffffffffffffff811115612792578182fd5b61279e85828601612676565b9150509250929050565b60008060008060008060c087890312156127c0578182fd5b6127ca8888612654565b95506020870135945060408701359350606087013560ff811681146127ed578283fd5b9598949750929560808101359460a0909101359350915050565b60008060006060848603121561281b578283fd5b833567ffffffffffffffff80821115612832578485fd5b818601915086601f830112612845578485fd5b813581811115612853578586fd5b60209150818102612865838201613107565b8281528381019085850183870186018c101561287f57898afd5b8996505b848710156128a9576128958c82612654565b835260019690960195918501918501612883565b50975050505085013592506128c39050856040860161266b565b90509250925092565b6000602082840312156128dd578081fd5b81516114ca8161316f565b6000602082840312156128f9578081fd5b5035919050565b60008060408385031215612912578182fd5b823591506129238460208501612654565b90509250929050565b6000806040838503121561293e578182fd5b8235915060208301356129508161316f565b809150509250929050565b6000815180845261297381602086016020860161312e565b601f01601f19169290920160200192915050565b6000825161299981846020870161312e565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03988916815296909716602087015260408601949094526060850192909252608084015260a0830152151560c082015290151560e08201526101000190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b600060018060a01b038616825284602083015283604083015260806060830152612aa8608083018461295b565b9695505050505050565b901515815260200190565b90815260200190565b6020810160078310612ad457fe5b91905290565b6000602082526114ca602083018461295b565b60208082526023908201527f476f7665726e616e63653a3a657865637574653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602b908201527f476f7665726e616e63653a3a657865637574653a20696e76616c69642070726f60408201526a706f73616c20737461746560a81b606082015260800190565b60208082526055908201527f476f7665726e616e63653a3a70726f706f73653a206f6e65206c69766520707260408201527f6f706f73616c207065722070726f706f7365722c20666f756e6420616e20616c6060820152741c9958591e481858dd1a5d99481c1c9bdc1bdcd85b605a1b608082015260a00190565b60208082526027908201527f476f7665726e616e63653a3a5f63617374566f74653a20766f74696e672069736040820152660818db1bdcd95960ca1b606082015260800190565b6020808252602d908201527f476f7665726e616e63653a3a70726f706f73653a2070736575646f2d6578746560408201526c393730b610333ab731ba34b7b760991b606082015260800190565b6020808252603c908201527f476f7665726e616e63653a3a70726f706f73653a2070726f706f73657220766f60408201527f7465732062656c6f772070726f706f73616c207468726573686f6c6400000000606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526036908201527f476f7665726e616e63653a3a70726f706f73653a206d6574616d6f72706869636040820152750818dbdb9d1c9858dd1cc81b9bdd08185b1b1bddd95960521b606082015260800190565b60208082526024908201527f476f7665726e616e63653a20696e636f727265637420766f7465457874656e6460408201526354696d6560e01b606082015260800190565b6020808252601d908201527f476f7665726e616e63653a20746f6b656e7320617265206c6f636b6564000000604082015260600190565b60208082526019908201527f544f524e3a207472616e7366657246726f6d206661696c656400000000000000604082015260600190565b60208082526010908201526f43616e206e6f7420626520656d70747960801b604082015260600190565b60208082526018908201527f476f7665726e616e63653a20756e617574686f72697a65640000000000000000604082015260600190565b6020808252601d908201527f476f7665726e616e63653a20696e76616c69642064656c656761746565000000604082015260600190565b60208082526018908201527f476f7665726e616e63653a2062616c616e636520697320300000000000000000604082015260600190565b60208082526023908201527f476f7665726e616e63653a3a70726f706f73653a206e6f74206120636f6e74726040820152621858dd60ea1b606082015260800190565b6020808252602e908201527f436f6e747261637420696e7374616e63652068617320616c726561647920626560408201526d195b881a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252600d908201526c6f6e6c79206d756c746973696760981b604082015260600190565b60208082526026908201527f476f7665726e616e63653a3a73746174653a20696e76616c69642070726f706f6040820152651cd85b081a5960d21b606082015260800190565b6020808252602a908201527f476f7665726e616e63653a20746f6b656e732061726520616c726561647920756040820152691b99195b1959d85d195960b21b606082015260800190565b6020808252601a908201527f476f7665726e616e63653a206e6f7420617574686f72697a6564000000000000604082015260600190565b60208082526019908201527f50726f706f73616c20657865637574696f6e206661696c656400000000000000604082015260600190565b60208082526019908201527f476f7665726e616e63653a20766f74656420616c726561647900000000000000604082015260600190565b8151151581526020808301511515908201526040918201519181019190915260600190565b60405181810167ffffffffffffffff8111828210171561312657600080fd5b604052919050565b60005b83811015613149578181015183820152602001613131565b838111156118ad5750506000910152565b6001600160a01b038116811461169f57600080fd5b801515811461169f57600080fdfea26469706673582212209ae80078297b488112cf4c0eaef3af85f34156332aa7d60065ce1ebb90ab93c264736f6c634300060c0033"; +const isSuperArgs$6 = (xs) => xs.length > 1; +class GovernanceProposalStateUpgrade__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$6(args)) { + super(...args); + } else { + super(_abi$6, _bytecode$6, args[0]); + } + } + getDeployTransaction(stakingRewardsAddress, gasCompLogic, userVaultAddress, overrides) { + return super.getDeployTransaction( + stakingRewardsAddress, + gasCompLogic, + userVaultAddress, + overrides || {} + ); + } + deploy(stakingRewardsAddress, gasCompLogic, userVaultAddress, overrides) { + return super.deploy( + stakingRewardsAddress, + gasCompLogic, + userVaultAddress, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$6); + } + static connect(address, runner) { + return new Contract( + address, + _abi$6, + runner + ); + } +} +GovernanceProposalStateUpgrade__factory.bytecode = _bytecode$6; +GovernanceProposalStateUpgrade__factory.abi = _abi$6; + +const _abi$5 = [ + { + inputs: [ + { + internalType: "address", + name: "_logic", + type: "address" + }, + { + internalType: "address", + name: "_admin", + type: "address" + }, + { + internalType: "bytes", + name: "_data", + type: "bytes" + } + ], + stateMutability: "payable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "previousAdmin", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "newAdmin", + type: "address" + } + ], + name: "AdminChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "implementation", + type: "address" + } + ], + name: "Upgraded", + type: "event" + }, + { + stateMutability: "payable", + type: "fallback" + }, + { + inputs: [], + name: "admin", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newAdmin", + type: "address" + } + ], + name: "changeAdmin", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "implementation", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address" + } + ], + name: "upgradeTo", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + stateMutability: "payable", + type: "receive" + } +]; +const _bytecode$5 = "0x60806040526040516108403803806108408339818101604052606081101561002657600080fd5b8151602083015160408085018051915193959294830192918464010000000082111561005157600080fd5b90830190602082018581111561006657600080fd5b825164010000000081118282018810171561008057600080fd5b82525081516020918201929091019080838360005b838110156100ad578181015183820152602001610095565b50505050905090810190601f1680156100da5780820380516001836020036101000a031916815260200191505b50604052508491508390508282816100f1826101c5565b8051156101a9576000826001600160a01b0316826040518082805190602001908083835b602083106101345780518252601f199092019160209182019101610115565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114610194576040519150601f19603f3d011682016040523d82523d6000602084013e610199565b606091505b50509050806101a757600080fd5b505b506101b19050565b6101ba82610237565b505050505050610261565b6101d88161025b60201b6103b41760201c565b6102135760405162461bcd60e51b815260040180806020018281038252603681526020018061080a6036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b3b151590565b61059a806102706000396000f3fe60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100985780635c60da1b146101185780638f28397014610149578063f851a4401461017c5761005d565b3661005d5761005b610191565b005b61005b610191565b34801561007157600080fd5b5061005b6004803603602081101561008857600080fd5b50356001600160a01b03166101ab565b61005b600480360360408110156100ae57600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100d957600080fd5b8201836020820111156100eb57600080fd5b8035906020019184600183028401116401000000008311171561010d57600080fd5b5090925090506101e5565b34801561012457600080fd5b5061012d610292565b604080516001600160a01b039092168252519081900360200190f35b34801561015557600080fd5b5061005b6004803603602081101561016c57600080fd5b50356001600160a01b03166102cf565b34801561018857600080fd5b5061012d610389565b6101996101a9565b6101a96101a46103ba565b6103df565b565b6101b3610403565b6001600160a01b0316336001600160a01b031614156101da576101d581610428565b6101e2565b6101e2610191565b50565b6101ed610403565b6001600160a01b0316336001600160a01b031614156102855761020f83610428565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d806000811461026c576040519150601f19603f3d011682016040523d82523d6000602084013e610271565b606091505b505090508061027f57600080fd5b5061028d565b61028d610191565b505050565b600061029c610403565b6001600160a01b0316336001600160a01b031614156102c4576102bd6103ba565b90506102cc565b6102cc610191565b90565b6102d7610403565b6001600160a01b0316336001600160a01b031614156101da576001600160a01b0381166103355760405162461bcd60e51b815260040180806020018281038252603a8152602001806104f5603a913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61035e610403565b604080516001600160a01b03928316815291841660208301528051918290030190a16101d581610468565b6000610393610403565b6001600160a01b0316336001600160a01b031614156102c4576102bd610403565b3b151590565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e8080156103fe573d6000f35b3d6000fd5b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b6104318161048c565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b610495816103b4565b6104d05760405162461bcd60e51b815260040180806020018281038252603681526020018061052f6036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5556fe5472616e73706172656e745570677261646561626c6550726f78793a206e65772061646d696e20697320746865207a65726f20616464726573735570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374a2646970667358221220f9da162f8a2d779a4f5f08577ac886bc4694791f749bd6ecc5d270427405583364736f6c634300060c00335570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374"; +const isSuperArgs$5 = (xs) => xs.length > 1; +class AdminUpgradeableProxy__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$5(args)) { + super(...args); + } else { + super(_abi$5, _bytecode$5, args[0]); + } + } + getDeployTransaction(_logic, _admin, _data, overrides) { + return super.getDeployTransaction(_logic, _admin, _data, overrides || {}); + } + deploy(_logic, _admin, _data, overrides) { + return super.deploy(_logic, _admin, _data, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$5); + } + static connect(address, runner) { + return new Contract( + address, + _abi$5, + runner + ); + } +} +AdminUpgradeableProxy__factory.bytecode = _bytecode$5; +AdminUpgradeableProxy__factory.abi = _abi$5; + +const _abi$4$1 = [ + { + inputs: [ + { + internalType: "address", + name: "_torn", + type: "address" + }, + { + internalType: "address", + name: "_governance", + type: "address" + }, + { + internalType: "address", + name: "_registry", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "instance", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "newFee", + type: "uint256" + } + ], + name: "FeeUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint24", + name: "newFee", + type: "uint24" + } + ], + name: "UniswapTornPoolSwappingFeeChanged", + type: "event" + }, + { + inputs: [], + name: "PROTOCOL_FEE_DIVIDER", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "_instance", + type: "address" + } + ], + name: "calculatePoolFee", + outputs: [ + { + internalType: "uint160", + name: "", + type: "uint160" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "feeDeviations", + outputs: [ + { + components: [ + { + internalType: "address", + name: "instance", + type: "address" + }, + { + internalType: "int256", + name: "deviation", + type: "int256" + } + ], + internalType: "struct FeeManager.Deviation[]", + name: "results", + type: "tuple[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "governance", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "", + type: "address" + } + ], + name: "instanceFee", + outputs: [ + { + internalType: "uint160", + name: "", + type: "uint160" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "", + type: "address" + } + ], + name: "instanceFeeUpdated", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "_instance", + type: "address" + } + ], + name: "instanceFeeWithUpdate", + outputs: [ + { + internalType: "uint160", + name: "", + type: "uint160" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "registry", + outputs: [ + { + internalType: "contract InstanceRegistry", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint32", + name: "newPeriod", + type: "uint32" + } + ], + name: "setPeriodForTWAPOracle", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint24", + name: "_uniswapTornPoolSwappingFee", + type: "uint24" + } + ], + name: "setUniswapTornPoolSwappingFee", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint24", + name: "newLimit", + type: "uint24" + } + ], + name: "setUpdateFeeTimeLimit", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "torn", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "uniswapTimePeriod", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "uniswapTornPoolSwappingFee", + outputs: [ + { + internalType: "uint24", + name: "", + type: "uint24" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "updateAllFees", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "_instance", + type: "address" + } + ], + name: "updateFee", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "updateFeeTimeLimit", + outputs: [ + { + internalType: "uint24", + name: "", + type: "uint24" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance[]", + name: "_instances", + type: "address[]" + } + ], + name: "updateFees", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode$4 = "0x60e06040523480156200001157600080fd5b5060405162001a7f38038062001a7f83398101604081905262000034916200005c565b6001600160601b0319606093841b811660805291831b821660a05290911b1660c052620000c8565b60008060006060848603121562000071578283fd5b83516200007e81620000af565b60208501519093506200009181620000af565b6040850151909250620000a481620000af565b809150509250925092565b6001600160a01b0381168114620000c557600080fd5b50565b60805160601c60a05160601c60c05160601c61195e62000121600039806102ce52806104f6528061077752806109945250806104b7528061052e528061060f528061070852508061068f528061087e525061195e6000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c8063a0287520116100a2578063bcc5ee6411610071578063bcc5ee641461020f578063c51c229714610217578063d8718fb11461022a578063e1f121561461023f578063f522d6d61461025257610116565b8063a0287520146101d9578063adf898a4146101ec578063aeb3077a146101f4578063b19a2972146101fc57610116565b8063603a54fe116100e9578063603a54fe146101815780637b103999146101945780637ccd2f481461019c57806380679eb3146101b157806380eb7bf0146101c657610116565b806305e343641461011b5780632efbf384146101445780634bf0a542146101645780635aa6e67514610179575b600080fd5b61012e610129366004611646565b61025a565b60405161013b919061188c565b60405180910390f35b610157610152366004611646565b61026c565b60405161013b91906116d3565b61016c6102c9565b60405161013b919061170f565b6101576104b5565b61015761018f366004611646565b6104d9565b6101576104f4565b6101a4610518565b60405161013b919061187c565b6101c46101bf366004611696565b610523565b005b6101c46101d4366004611646565b61057e565b6101c46101e7366004611662565b610604565b61015761068d565b61012e6106b1565b6101c461020a3660046113e4565b6106b7565b6101a46106eb565b6101c4610225366004611662565b6106fd565b61023261075a565b60405161013b9190611895565b61015761024d366004611646565b61076d565b6101c461098f565b60026020526000908152604090205481565b600080546001600160a01b038316825260026020526040822054600160381b90910462ffffff16429190910311156102a7576102a78261057e565b506001600160a01b03808216600090815260016020526040902054165b919050565b6060807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166310c13ac36040518163ffffffff1660e01b815260040160006040518083038186803b15801561032557600080fd5b505afa158015610339573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610361919081019061147d565b9050805167ffffffffffffffff8111801561037b57600080fd5b506040519080825280602002602001820160405280156103b557816020015b6103a261131d565b81526020019060019003908161039a5790505b50915060005b81518110156104b05760006103e28383815181106103d557fe5b602002602001015161076d565b6001600160a01b031690506000811561045e576103e8826001600087878151811061040957fe5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060009054906101000a90046001600160a01b03166103e8026001600160a01b03168161045957fe5b040390505b604051806040016040528085858151811061047557fe5b60200260200101516001600160a01b031681526020018281525085848151811061049b57fe5b602090810291909101015250506001016103bb565b505090565b7f000000000000000000000000000000000000000000000000000000000000000081565b6001602052600090815260409020546001600160a01b031681565b7f000000000000000000000000000000000000000000000000000000000000000081565b60005462ffffff1681565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461055857600080fd5b6000805463ffffffff90921663010000000266ffffffff00000019909216919091179055565b60006105898261076d565b6001600160a01b03838116600081815260016020908152604080832080546001600160a01b03191695871695909517909455600290528290204290559051919250907f6f0eaf2c2f89fb4cfe96a1dee5e764d60b52c7f48aaa590f0850e308aa1b953a906105f89084906116d3565b60405180910390a25050565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461063957600080fd5b6000805462ffffff191662ffffff83811691909117918290556040517fbfe65cfc2359076c4468c9b895156c309c78f94fb09f6d2fc0463c4ca9a71ac29261068292169061187c565b60405180910390a150565b7f000000000000000000000000000000000000000000000000000000000000000081565b61271081565b60005b81518110156106e7576106df8282815181106106d257fe5b602002602001015161057e565b6001016106ba565b5050565b600054600160381b900462ffffff1681565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461073257600080fd5b6000805462ffffff909216600160381b0269ffffff0000000000000019909216919091179055565b6000546301000000900463ffffffff1681565b60008060008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663032bb443876040518263ffffffff1660e01b81526004016107c191906116d3565b60a06040518083038186803b1580156107d957600080fd5b505afa1580156107ed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061081191906115cb565b9450945050935093508063ffffffff16600014156108365760009450505050506102c4565b6001600160a01b03831615801561084b575083155b610855578261086b565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc25b6040805180820182526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081168252831660208083019190915282518084019093526000805462ffffff80821686528816928501929092529396506108e5929063ffffffff630100000090910416610a29565b905061098461271061097e8463ffffffff166109788561097e670de0b6b3a76400008e6001600160a01b0316638bca6d166040518163ffffffff1660e01b815260040160206040518083038186803b15801561094057600080fd5b505afa158015610954573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610978919061167e565b90610a75565b90610ac1565b979650505050505050565b610a277f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166310c13ac36040518163ffffffff1660e01b815260040160006040518083038186803b1580156109eb57600080fd5b505afa1580156109ff573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261020a919081019061147d565b565b60208084015190830151600091610a409184610b03565b84518451610a6391670de0b6b3a764000091610a5d919087610b03565b90610b2d565b81610a6a57fe5b0490505b9392505050565b600082610a8457506000610abb565b82820282848281610a9157fe5b0414610ab85760405162461bcd60e51b8152600401610aaf9061183b565b60405180910390fd5b90505b92915050565b6000610ab883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250610b51565b6000610b258473c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28585610b88565b949350505050565b6000821580610b4857505081810281838281610b4557fe5b04145b610abb57600080fd5b60008183610b725760405162461bcd60e51b8152600401610aaf91906117b1565b506000838581610b7e57fe5b0495945050505050565b600080846001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610bc457600080fd5b505afa158015610bd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bfc91906116b2565b60ff16600a0a90506001600160a01b038681169086161415610c28576001600160801b03169050610b25565b604051630b4c774160e11b8152610cc990610cc190731f98431c8ad98523631ae4a59f267346ea31f98490631698ee8290610c6b908b908b908b906004016116e7565b60206040518083038186803b158015610c8357600080fd5b505afa158015610c97573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cbb91906113c8565b85610cda565b828888610e6f565b915050610b25565b50949350505050565b600063ffffffff8216610cff5760405162461bcd60e51b8152600401610aaf90611804565b60408051600280825260608083018452926020830190803683370190505090508281600081518110610d2d57fe5b602002602001019063ffffffff16908163ffffffff1681525050600081600181518110610d5657fe5b63ffffffff9092166020928302919091019091015260405163883bdbfd60e01b81526060906001600160a01b0386169063883bdbfd90610d9a908590600401611767565b60006040518083038186803b158015610db257600080fd5b505afa158015610dc6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610dee9190810190611509565b509050600081600081518110610e0057fe5b602002602001015182600181518110610e1557fe5b60200260200101510390508463ffffffff168160060b81610e3257fe5b05935060008160060b128015610e5957508463ffffffff168160060b81610e5557fe5b0715155b15610e6657600019909301925b50505092915050565b600080610e7b86610f59565b90506001600160801b036001600160a01b03821611610eea576001600160a01b0380821680029084811690861610610eca57610ec5600160c01b876001600160801b031683611272565b610ee2565b610ee281876001600160801b0316600160c01b611272565b925050610cd1565b6000610f096001600160a01b0383168068010000000000000000611272565b9050836001600160a01b0316856001600160a01b031610610f4157610f3c600160801b876001600160801b031683611272565b610984565b61098481876001600160801b0316600160801b611272565b60008060008360020b12610f70578260020b610f78565b8260020b6000035b9050620d89e8811115610f9d5760405162461bcd60e51b8152600401610aaf90611820565b600060018216610fb157600160801b610fc3565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615610ff7576ffff97272373d413259a46990580e213a0260801c5b6004821615611016576ffff2e50f5f656932ef12357cf3c7fdcc0260801c5b6008821615611035576fffe5caca7e10e4e61c3624eaa0941cd00260801c5b6010821615611054576fffcb9843d60f6159c9db58835c9266440260801c5b6020821615611073576fff973b41fa98c081472e6896dfb254c00260801c5b6040821615611092576fff2ea16466c96a3843ec78b326b528610260801c5b60808216156110b1576ffe5dee046a99a2a811c461f1969c30530260801c5b6101008216156110d1576ffcbe86c7900a88aedcffc83b479aa3a40260801c5b6102008216156110f1576ff987a7253ac413176f2b074cf7815e540260801c5b610400821615611111576ff3392b0822b70005940c7a398e4b70f30260801c5b610800821615611131576fe7159475a2c29b7443b29c7fa6e889d90260801c5b611000821615611151576fd097f3bdfd2022b8845ad8f792aa58250260801c5b612000821615611171576fa9f746462d870fdf8a65dc1f90e061e50260801c5b614000821615611191576f70d869a156d2a1b890bb3df62baf32f70260801c5b6180008216156111b1576f31be135f97d08fd981231505542fcfa60260801c5b620100008216156111d2576f09aa508b5b7a84e1c677de54f3e99bc90260801c5b620200008216156111f2576e5d6af8dedb81196699c329225ee6040260801c5b62040000821615611211576d2216e584f5fa1ea926041bedfe980260801c5b6208000082161561122e576b048a170391f7dc42444e8fa20260801c5b60008460020b131561124957806000198161124557fe5b0490505b64010000000081061561125d576001611260565b60005b60ff16602082901c0192505050919050565b60008080600019858709868602925082811090839003039050806112a8576000841161129d57600080fd5b508290049050610a6e565b8084116112b457600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b604080518082019091526000808252602082015290565b600082601f830112611344578081fd5b8151611357611352826118cd565b6118a6565b81815291506020808301908481018184028601820187101561137857600080fd5b60005b848110156113a057815161138e816118ed565b8452928201929082019060010161137b565b505050505092915050565b8051610abb816118ed565b8051600681900b8114610abb57600080fd5b6000602082840312156113d9578081fd5b8151610ab8816118ed565b600060208083850312156113f6578182fd5b823567ffffffffffffffff81111561140c578283fd5b8301601f8101851361141c578283fd5b803561142a611352826118cd565b8181528381019083850185840285018601891015611446578687fd5b8694505b8385101561147157803561145d816118ed565b83526001949094019391850191850161144a565b50979650505050505050565b6000602080838503121561148f578182fd5b825167ffffffffffffffff8111156114a5578283fd5b8301601f810185136114b5578283fd5b80516114c3611352826118cd565b81815283810190838501858402850186018910156114df578687fd5b8694505b83851015611471576114f589826113ab565b8352600194909401939185019185016114e3565b6000806040838503121561151b578081fd5b825167ffffffffffffffff80821115611532578283fd5b818501915085601f830112611545578283fd5b8151611553611352826118cd565b80828252602080830192508086018a828387028901011115611573578788fd5b8796505b8487101561159d576115898b826113b6565b845260019690960195928101928101611577565b5088015190965093505050808211156115b4578283fd5b506115c185828601611334565b9150509250929050565b600080600080600060a086880312156115e2578081fd5b855180151581146115f1578182fd5b6020870151909550611602816118ed565b604087015190945060028110611616578182fd5b606087015190935061162781611905565b608087015190925061163881611916565b809150509295509295909350565b600060208284031215611657578081fd5b8135610ab8816118ed565b600060208284031215611673578081fd5b8135610ab881611905565b60006020828403121561168f578081fd5b5051919050565b6000602082840312156116a7578081fd5b8135610ab881611916565b6000602082840312156116c3578081fd5b815160ff81168114610ab8578182fd5b6001600160a01b0391909116815260200190565b6001600160a01b03938416815291909216602082015262ffffff909116604082015260600190565b602080825282518282018190526000919060409081850190868401855b8281101561175a57815180516001600160a01b0316855286015186850152928401929085019060010161172c565b5091979650505050505050565b6020808252825182820181905260009190848201906040850190845b818110156117a557835163ffffffff1683529284019291840191600101611783565b50909695505050505050565b6000602080835283518082850152825b818110156117dd578581018301518582016040015282016117c1565b818111156117ee5783604083870101525b50601f01601f1916929092016040019392505050565b602080825260029082015261042560f41b604082015260600190565b6020808252600190820152601560fa1b604082015260600190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b62ffffff91909116815260200190565b90815260200190565b63ffffffff91909116815260200190565b60405181810167ffffffffffffffff811182821017156118c557600080fd5b604052919050565b600067ffffffffffffffff8211156118e3578081fd5b5060209081020190565b6001600160a01b038116811461190257600080fd5b50565b62ffffff8116811461190257600080fd5b63ffffffff8116811461190257600080fdfea26469706673582212205690be246e00d9bf30da35441a160026439ececfa962348f01e498d25f89f5d164736f6c634300060c0033"; +const isSuperArgs$4 = (xs) => xs.length > 1; +class FeeManager__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$4(args)) { + super(...args); + } else { + super(_abi$4$1, _bytecode$4, args[0]); + } + } + getDeployTransaction(_torn, _governance, _registry, overrides) { + return super.getDeployTransaction( + _torn, + _governance, + _registry, + overrides || {} + ); + } + deploy(_torn, _governance, _registry, overrides) { + return super.deploy( + _torn, + _governance, + _registry, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$4$1); + } + static connect(address, runner) { + return new Contract(address, _abi$4$1, runner); + } +} +FeeManager__factory.bytecode = _bytecode$4; +FeeManager__factory.abi = _abi$4$1; + +const _abi$3$1 = [ + { + inputs: [ + { + internalType: "address", + name: "_governance", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [], + name: "GovernanceAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "gasAmount", + type: "uint256" + } + ], + name: "compensateGas", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "withdrawToGovernance", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + stateMutability: "payable", + type: "receive" + } +]; +const _bytecode$3 = "0x60a0604052348015600f57600080fd5b50604051610472380380610472833981016040819052602c91603c565b6001600160a01b0316608052606a565b600060208284031215604d57600080fd5b81516001600160a01b0381168114606357600080fd5b9392505050565b6080516103da6100986000396000818160560152818160e101528181610212015261027701526103da6000f3fe6080604052600436106100385760003560e01c8063a3221c2e14610044578063a99ce80714610094578063e822f784146100b657600080fd5b3661003f57005b600080fd5b34801561005057600080fd5b506100787f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200160405180910390f35b3480156100a057600080fd5b506100b46100af366004610328565b6100d6565b005b3480156100c257600080fd5b506100b46100d1366004610360565b610207565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461013e5760405162461bcd60e51b815260206004820152600860248201526737b7363c9033b7bb60c11b60448201526064015b60405180910390fd5b47600061014b4884610379565b90508160000361015b5750505050565b6000846001600160a01b03168383116101745782610176565b835b604051600081818185875af1925050503d80600081146101b2576040519150601f19603f3d011682016040523d82523d6000602084013e6101b7565b606091505b50509050806102005760405162461bcd60e51b815260206004820152601560248201527418dbdb5c195b9cd85d194819d85cc819985a5b1959605a1b6044820152606401610135565b5050505050565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461026a5760405162461bcd60e51b815260206004820152600860248201526737b7363c9033b7bb60c11b6044820152606401610135565b4760006001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168284116102a457836102a6565b825b604051600081818185875af1925050503d80600081146102e2576040519150601f19603f3d011682016040523d82523d6000602084013e6102e7565b606091505b50509050806103235760405162461bcd60e51b81526020600482015260086024820152671c185e4819985a5b60c21b6044820152606401610135565b505050565b6000806040838503121561033b57600080fd5b82356001600160a01b038116811461035257600080fd5b946020939093013593505050565b60006020828403121561037257600080fd5b5035919050565b808202811582820484141761039e57634e487b7160e01b600052601160045260246000fd5b9291505056fea264697066735822122073841dd5b5d8687d927814633a2fcb7944a306bb89a9b65a0aab4cc361c8312264736f6c63430008190033"; +const isSuperArgs$3 = (xs) => xs.length > 1; +class GasCompensationVault__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$3(args)) { + super(...args); + } else { + super(_abi$3$1, _bytecode$3, args[0]); + } + } + getDeployTransaction(_governance, overrides) { + return super.getDeployTransaction(_governance, overrides || {}); + } + deploy(_governance, overrides) { + return super.deploy(_governance, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$3$1); + } + static connect(address, runner) { + return new Contract( + address, + _abi$3$1, + runner + ); + } +} +GasCompensationVault__factory.bytecode = _bytecode$3; +GasCompensationVault__factory.abi = _abi$3$1; + +const _abi$2$1 = [ + { + inputs: [ + { + internalType: "address", + name: "_logic", + type: "address" + }, + { + internalType: "bytes", + name: "_data", + type: "bytes" + } + ], + stateMutability: "payable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "previousAdmin", + type: "address" + }, + { + indexed: false, + internalType: "address", + name: "newAdmin", + type: "address" + } + ], + name: "AdminChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "implementation", + type: "address" + } + ], + name: "Upgraded", + type: "event" + }, + { + stateMutability: "payable", + type: "fallback" + }, + { + inputs: [], + name: "admin", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newAdmin", + type: "address" + } + ], + name: "changeAdmin", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "implementation", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address" + } + ], + name: "upgradeTo", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newImplementation", + type: "address" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + stateMutability: "payable", + type: "receive" + } +]; +const _bytecode$2 = "0x608060405260405161083b38038061083b8339818101604052604081101561002657600080fd5b81516020830180516040519294929383019291908464010000000082111561004d57600080fd5b90830190602082018581111561006257600080fd5b825164010000000081118282018810171561007c57600080fd5b82525081516020918201929091019080838360005b838110156100a9578181015183820152602001610091565b50505050905090810190601f1680156100d65780820380516001836020036101000a031916815260200191505b50604052508391503090508282816100ed826101c0565b8051156101a5576000826001600160a01b0316826040518082805190602001908083835b602083106101305780518252601f199092019160209182019101610111565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114610190576040519150601f19603f3d011682016040523d82523d6000602084013e610195565b606091505b50509050806101a357600080fd5b505b506101ad9050565b6101b682610232565b505050505061025c565b6101d38161025660201b6103b41760201c565b61020e5760405162461bcd60e51b81526004018080602001828103825260368152602001806108056036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b3b151590565b61059a8061026b6000396000f3fe60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100985780635c60da1b146101185780638f28397014610149578063f851a4401461017c5761005d565b3661005d5761005b610191565b005b61005b610191565b34801561007157600080fd5b5061005b6004803603602081101561008857600080fd5b50356001600160a01b03166101ab565b61005b600480360360408110156100ae57600080fd5b6001600160a01b0382351691908101906040810160208201356401000000008111156100d957600080fd5b8201836020820111156100eb57600080fd5b8035906020019184600183028401116401000000008311171561010d57600080fd5b5090925090506101e5565b34801561012457600080fd5b5061012d610292565b604080516001600160a01b039092168252519081900360200190f35b34801561015557600080fd5b5061005b6004803603602081101561016c57600080fd5b50356001600160a01b03166102cf565b34801561018857600080fd5b5061012d610389565b6101996101a9565b6101a96101a46103ba565b6103df565b565b6101b3610403565b6001600160a01b0316336001600160a01b031614156101da576101d581610428565b6101e2565b6101e2610191565b50565b6101ed610403565b6001600160a01b0316336001600160a01b031614156102855761020f83610428565b6000836001600160a01b031683836040518083838082843760405192019450600093509091505080830381855af49150503d806000811461026c576040519150601f19603f3d011682016040523d82523d6000602084013e610271565b606091505b505090508061027f57600080fd5b5061028d565b61028d610191565b505050565b600061029c610403565b6001600160a01b0316336001600160a01b031614156102c4576102bd6103ba565b90506102cc565b6102cc610191565b90565b6102d7610403565b6001600160a01b0316336001600160a01b031614156101da576001600160a01b0381166103355760405162461bcd60e51b815260040180806020018281038252603a8152602001806104f5603a913960400191505060405180910390fd5b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f61035e610403565b604080516001600160a01b03928316815291841660208301528051918290030190a16101d581610468565b6000610393610403565b6001600160a01b0316336001600160a01b031614156102c4576102bd610403565b3b151590565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e8080156103fe573d6000f35b3d6000fd5b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035490565b6104318161048c565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610355565b610495816103b4565b6104d05760405162461bcd60e51b815260040180806020018281038252603681526020018061052f6036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5556fe5472616e73706172656e745570677261646561626c6550726f78793a206e65772061646d696e20697320746865207a65726f20616464726573735570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374a264697066735822122014d721b179bdff3154685a6f1f0fecdd0d99b7cfc61b3f1a2f7a95c6f6d2c2ae64736f6c634300060c00335570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374"; +const isSuperArgs$2 = (xs) => xs.length > 1; +class LoopbackProxy__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$2(args)) { + super(...args); + } else { + super(_abi$2$1, _bytecode$2, args[0]); + } + } + getDeployTransaction(_logic, _data, overrides) { + return super.getDeployTransaction(_logic, _data, overrides || {}); + } + deploy(_logic, _data, overrides) { + return super.deploy(_logic, _data, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$2$1); + } + static connect(address, runner) { + return new Contract(address, _abi$2$1, runner); + } +} +LoopbackProxy__factory.bytecode = _bytecode$2; +LoopbackProxy__factory.abi = _abi$2$1; + +const _abi$1$1 = [ + { + inputs: [ + { + internalType: "address", + name: "_governance", + type: "address" + }, + { + internalType: "address", + name: "_instanceRegistry", + type: "address" + }, + { + internalType: "address", + name: "_relayerRegistry", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "sender", + type: "address" + }, + { + indexed: false, + internalType: "bytes", + name: "encryptedNote", + type: "bytes" + } + ], + name: "EncryptedNote", + type: "event" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "_token", + type: "address" + }, + { + internalType: "address", + name: "_spender", + type: "address" + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256" + } + ], + name: "approveExactToken", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes[]", + name: "_encryptedNotes", + type: "bytes[]" + } + ], + name: "backupNotes", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "_tornado", + type: "address" + }, + { + internalType: "bytes32", + name: "_commitment", + type: "bytes32" + }, + { + internalType: "bytes", + name: "_encryptedNote", + type: "bytes" + } + ], + name: "deposit", + outputs: [], + stateMutability: "payable", + type: "function" + }, + { + inputs: [], + name: "governance", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "instanceRegistry", + outputs: [ + { + internalType: "contract InstanceRegistry", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "relayerRegistry", + outputs: [ + { + internalType: "contract RelayerRegistry", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "_token", + type: "address" + }, + { + internalType: "address payable", + name: "_to", + type: "address" + }, + { + internalType: "uint256", + name: "_amount", + type: "uint256" + } + ], + name: "rescueTokens", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ITornadoInstance", + name: "_tornado", + type: "address" + }, + { + internalType: "bytes", + name: "_proof", + type: "bytes" + }, + { + internalType: "bytes32", + name: "_root", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "_nullifierHash", + type: "bytes32" + }, + { + internalType: "address payable", + name: "_recipient", + type: "address" + }, + { + internalType: "address payable", + name: "_relayer", + type: "address" + }, + { + internalType: "uint256", + name: "_fee", + type: "uint256" + }, + { + internalType: "uint256", + name: "_refund", + type: "uint256" + } + ], + name: "withdraw", + outputs: [], + stateMutability: "payable", + type: "function" + } +]; +const _bytecode$1 = "0x60e060405234801561001057600080fd5b5060405161128438038061128483398101604081905261002f91610056565b6001600160601b0319606093841b811660805291831b821660a05290911b1660c0526100ba565b60008060006060848603121561006a578283fd5b8351610075816100a2565b6020850151909350610086816100a2565b6040850151909250610097816100a2565b809150509250925092565b6001600160a01b03811681146100b757600080fd5b50565b60805160601c60a05160601c60c05160601c61117c610108600039806103ff528061059e525080610164528061037a52806103a752806104c8525080610423528061068e525061117c6000f3fe60806040526004361061007b5760003560e01c80635aa6e6751161004e5780635aa6e675146100f55780636485ba2a1461010a578063b438689f1461012a578063cea9d26f1461013d5761007b565b806313d98d131461008057806336a3874b146100955780633ef10783146100c057806347ff589d146100e0575b600080fd5b61009361008e366004610c77565b61015d565b005b3480156100a157600080fd5b506100aa610378565b6040516100b79190610dd0565b60405180910390f35b3480156100cc57600080fd5b506100936100db366004610c37565b61039c565b3480156100ec57600080fd5b506100aa6103fd565b34801561010157600080fd5b506100aa610421565b34801561011657600080fd5b50610093610125366004610b26565b610445565b610093610138366004610cd1565b6104ae565b34801561014957600080fd5b50610093610158366004610c37565b610683565b60008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663032bb443886040518263ffffffff1660e01b81526004016101ae9190610dd0565b60a06040518083038186803b1580156101c657600080fd5b505afa1580156101da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101fe9190610bb1565b5092955090935091506000905081600181111561021757fe5b141561023e5760405162461bcd60e51b815260040161023590610f00565b60405180910390fd5b82156102cc576102cc3330896001600160a01b0316638bca6d166040518163ffffffff1660e01b815260040160206040518083038186803b15801561028257600080fd5b505afa158015610296573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ba9190610d72565b6001600160a01b038616929190610817565b60405163b214faa560e01b81526001600160a01b0388169063b214faa59034906102fa908a90600401610e5e565b6000604051808303818588803b15801561031357600080fd5b505af1158015610327573d6000803e3d6000fd5b5050505050336001600160a01b03167ffa28df43db3553771f7209dcef046f3bdfea15870ab625dcda30ac58b82b40088686604051610367929190610e67565b60405180910390a250505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146103e45760405162461bcd60e51b815260040161023590611087565b6103f86001600160a01b0384168383610875565b505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60005b818110156103f857337ffa28df43db3553771f7209dcef046f3bdfea15870ab625dcda30ac58b82b400884848481811061047e57fe5b905060200281019061049091906110af565b60405161049e929190610e67565b60405180910390a2600101610448565b60405163032bb44360e01b81526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063032bb443906104fd908d90600401610dd0565b60a06040518083038186803b15801561051557600080fd5b505afa158015610529573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061054d9190610bb1565b509093506000925061055d915050565b81600181111561056957fe5b14156105875760405162461bcd60e51b815260040161023590610f00565b604051631168473b60e21b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906345a11cec906105d790339088908f90600401610de4565b600060405180830381600087803b1580156105f157600080fd5b505af1158015610605573d6000803e3d6000fd5b50506040516310d056db60e11b81526001600160a01b038d1692506321a0adb691503490610645908d908d908d908d908d908d908d908d90600401610e7b565b6000604051808303818588803b15801561065e57600080fd5b505af1158015610672573d6000803e3d6000fd5b505050505050505050505050505050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146106cb5760405162461bcd60e51b815260040161023590611087565b6001600160a01b0382166106f15760405162461bcd60e51b815260040161023590610f6e565b6001600160a01b03831661074d5747600061070c8284610938565b6040519091506001600160a01b0385169082156108fc029083906000818181858888f19350505050158015610745573d6000803e3d6000fd5b5050506103f8565b6040516370a0823160e01b81526000906001600160a01b038516906370a082319061077c903090600401610dd0565b60206040518083038186803b15801561079457600080fd5b505afa1580156107a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107cc9190610d72565b905060006107da8284610938565b9050600081116107fc5760405162461bcd60e51b815260040161023590610ffa565b6108106001600160a01b0386168583610950565b5050505050565b61086f846323b872dd60e01b85858560405160240161083893929190610e21565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261096f565b50505050565b8015806108fd5750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e906108ab9030908690600401610e07565b60206040518083038186803b1580156108c357600080fd5b505afa1580156108d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108fb9190610d72565b155b6109195760405162461bcd60e51b815260040161023590611031565b6103f88363095ea7b360e01b8484604051602401610838929190610e45565b60008183106109475781610949565b825b9392505050565b6103f88363a9059cbb60e01b8484604051602401610838929190610e45565b60606109c4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166109fe9092919063ffffffff16565b8051909150156103f857808060200190518101906109e29190610b95565b6103f85760405162461bcd60e51b815260040161023590610fb0565b6060610a0d8484600085610a15565b949350505050565b6060610a2085610ad9565b610a3c5760405162461bcd60e51b815260040161023590610f37565b60006060866001600160a01b03168587604051610a599190610db4565b60006040518083038185875af1925050503d8060008114610a96576040519150601f19603f3d011682016040523d82523d6000602084013e610a9b565b606091505b50915091508115610aaf579150610a0d9050565b805115610abf5780518082602001fd5b8360405162461bcd60e51b81526004016102359190610ecd565b3b151590565b60008083601f840112610af0578182fd5b50813567ffffffffffffffff811115610b07578182fd5b602083019150836020828501011115610b1f57600080fd5b9250929050565b60008060208385031215610b38578182fd5b823567ffffffffffffffff80821115610b4f578384fd5b818501915085601f830112610b62578384fd5b813581811115610b70578485fd5b8660208083028501011115610b83578485fd5b60209290920196919550909350505050565b600060208284031215610ba6578081fd5b815161094981611138565b600080600080600060a08688031215610bc8578081fd5b8551610bd381611138565b6020870151909550610be481611120565b604087015190945060028110610bf8578182fd5b606087015190935062ffffff81168114610c10578182fd5b608087015190925063ffffffff81168114610c29578182fd5b809150509295509295909350565b600080600060608486031215610c4b578283fd5b8335610c5681611120565b92506020840135610c6681611120565b929592945050506040919091013590565b60008060008060608587031215610c8c578384fd5b8435610c9781611120565b935060208501359250604085013567ffffffffffffffff811115610cb9578283fd5b610cc587828801610adf565b95989497509550505050565b60008060008060008060008060006101008a8c031215610cef578384fd5b8935610cfa81611120565b985060208a013567ffffffffffffffff811115610d15578485fd5b610d218c828d01610adf565b90995097505060408a0135955060608a0135945060808a0135610d4381611120565b935060a08a0135610d5381611120565b8093505060c08a0135915060e08a013590509295985092959850929598565b600060208284031215610d83578081fd5b5051919050565b60008284528282602086013780602084860101526020601f19601f85011685010190509392505050565b60008251610dc68184602087016110f4565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b0393841681529183166020830152909116604082015260600190565b6001600160a01b0392831681529116602082015260400190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b90815260200190565b600060208252610a0d602083018486610d8a565b600060e08252610e8f60e083018a8c610d8a565b60208301989098525060408101959095526001600160a01b03938416606086015291909216608084015260a083019190915260c09091015292915050565b6000602082528251806020840152610eec8160408501602087016110f4565b601f01601f19169190910160400192915050565b6020808252601d908201527f54686520696e7374616e6365206973206e6f7420737570706f72746564000000604082015260600190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b60208082526022908201527f544f524e3a2063616e206e6f742073656e6420746f207a65726f206164647265604082015261737360f01b606082015260800190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b6020808252601e908201527f544f524e3a20747279696e6720746f2073656e6420302062616c616e63650000604082015260600190565b60208082526036908201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60408201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606082015260800190565b6020808252600e908201526d139bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b6000808335601e198436030181126110c5578283fd5b83018035915067ffffffffffffffff8211156110df578283fd5b602001915036819003821315610b1f57600080fd5b60005b8381101561110f5781810151838201526020016110f7565b8381111561086f5750506000910152565b6001600160a01b038116811461113557600080fd5b50565b801515811461113557600080fdfea26469706673582212209d7fe04aba36de62ec470c0d6176fa1eec04a15a73bce5d2370ff3ab967e9c2564736f6c634300060c0033"; +const isSuperArgs$1 = (xs) => xs.length > 1; +class TornadoRouter__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs$1(args)) { + super(...args); + } else { + super(_abi$1$1, _bytecode$1, args[0]); + } + } + getDeployTransaction(_governance, _instanceRegistry, _relayerRegistry, overrides) { + return super.getDeployTransaction( + _governance, + _instanceRegistry, + _relayerRegistry, + overrides || {} + ); + } + deploy(_governance, _instanceRegistry, _relayerRegistry, overrides) { + return super.deploy( + _governance, + _instanceRegistry, + _relayerRegistry, + overrides || {} + ); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$1$1); + } + static connect(address, runner) { + return new Contract(address, _abi$1$1, runner); + } +} +TornadoRouter__factory.bytecode = _bytecode$1; +TornadoRouter__factory.abi = _abi$1$1; + +const _abi$1I = [ + { + inputs: [ + { + internalType: "address", + name: "_torn", + type: "address" + }, + { + internalType: "address", + name: "_governance", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [ + { + internalType: "address", + name: "recipient", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + } + ], + name: "withdrawTorn", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +const _bytecode = "0x60c060405234801561001057600080fd5b506040516104aa3803806104aa8339818101604052604081101561003357600080fd5b5080516020909101516001600160601b0319606092831b8116608052911b1660a05260805160601c60a05160601c61042e61007c60003980606952508060d3525061042e6000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c806391fe357314610030575b600080fd5b61005c6004803603604081101561004657600080fd5b506001600160a01b03813516906020013561005e565b005b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146100c6576040805162461bcd60e51b815260206004820152600860248201526737b7363c9033b7bb60c11b604482015290519081900360640190fd5b6100fa6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001683836100fe565b5050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610150908490610155565b505050565b60606101aa826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166102069092919063ffffffff16565b805190915015610150578080602001905160208110156101c957600080fd5b50516101505760405162461bcd60e51b815260040180806020018281038252602a8152602001806103cf602a913960400191505060405180910390fd5b6060610215848460008561021d565b949350505050565b6060610228856103c8565b610279576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106102b85780518252601f199092019160209182019101610299565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461031a576040519150601f19603f3d011682016040523d82523d6000602084013e61031f565b606091505b509150915081156103335791506102159050565b8051156103435780518082602001fd5b8360405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561038d578181015183820152602001610375565b50505050905090810190601f1680156103ba5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b3b15159056fe5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a26469706673582212208fc65ae8299d617f6cff836a2822363849c7fb35b0b27a6f0aebfa62084005c764736f6c634300060c0033"; +const isSuperArgs = (xs) => xs.length > 1; +class TornadoVault__factory extends ContractFactory { + constructor(...args) { + if (isSuperArgs(args)) { + super(...args); + } else { + super(_abi$1I, _bytecode, args[0]); + } + } + getDeployTransaction(_torn, _governance, overrides) { + return super.getDeployTransaction(_torn, _governance, overrides || {}); + } + deploy(_torn, _governance, overrides) { + return super.deploy(_torn, _governance, overrides || {}); + } + connect(runner) { + return super.connect(runner); + } + static createInterface() { + return new Interface(_abi$1I); + } + static connect(address, runner) { + return new Contract(address, _abi$1I, runner); + } +} +TornadoVault__factory.bytecode = _bytecode; +TornadoVault__factory.abi = _abi$1I; + +var name = "tornado-cli"; +var version$3 = "1.0.1-alpha"; +var description$1 = "Modern Toolsets for Privacy Pools on Ethereum"; +var main = "./dist/index.js"; +var module$1 = "./dist/index.mjs"; +var types$1 = "./dist/index.d.ts"; +var bin = { + "tornado-cli": "./dist/cli.js" +}; +var scripts = { + typechain: "typechain --target ethers-v6 --out-dir src/typechain src/abi/*.json", + types: "tsc --declaration --emitDeclarationOnly", + lint: "eslint src/**/*.ts --ext .ts --ignore-pattern src/typechain", + build: "yarn types && rollup -c", + start: "ts-node src/cli.ts", + startHelp: "ts-node src/cli.ts help", + createDeposit: "ts-node src/cli.ts create", + deposit: "ts-node src/cli.ts deposit", + depositInvoice: "ts-node src/cli.ts depositInvoice", + withdraw: "ts-node src/cli.ts withdraw", + compliance: "ts-node src/cli.ts compliance", + syncEvents: "ts-node src/cli.ts syncEvents", + relayers: "ts-node src/cli.ts relayers", + send: "ts-node src/cli.ts send", + balance: "ts-node src/cli.ts balance", + sign: "ts-node src/cli.ts sign", + broadcast: "ts-node src/cli.ts broadcast" +}; +var author = ""; +var license = "MIT"; +var files = [ + "dist", + "scripts", + "src", + "static", + ".env.example", + ".eslintrc.js", + ".gitattributes", + ".gitignore", + ".npmrc", + "rollup.config.mjs", + "tsconfig.json", + "yarn.lock" +]; +var dependencies$1 = { + "@colors/colors": "1.5.0", + "@tornado/contracts": "1.0.0", + "@tornado/fixed-merkle-tree": "0.7.3", + "@tornado/snarkjs": "0.1.20", + "@tornado/websnark": "0.0.4", + ajv: "^8.12.0", + "bignumber.js": "^9.1.2", + "bn.js": "^5.2.1", + circomlibjs: "0.1.7", + "cli-table3": "^0.6.4", + commander: "^12.0.0", + "cross-fetch": "^4.0.0", + dotenv: "^16.4.5", + ethers: "^6.12.0", + ffjavascript: "0.2.48", + fflate: "^0.8.2", + figlet: "^1.7.0", + "http-proxy-agent": "^7.0.2", + "https-proxy-agent": "^7.0.4", + moment: "^2.30.1", + "socks-proxy-agent": "^8.0.3" +}; +var devDependencies = { + "@rollup/plugin-commonjs": "^25.0.7", + "@rollup/plugin-json": "^6.1.0", + "@rollup/plugin-node-resolve": "^15.2.3", + "@rollup/plugin-replace": "^5.0.5", + "@typechain/ethers-v6": "^0.5.1", + "@types/bn.js": "^5.1.5", + "@types/circomlibjs": "^0.1.6", + "@types/figlet": "^1.5.8", + "@types/node": "^20.12.5", + "@types/node-fetch": "^2.6.11", + "@typescript-eslint/eslint-plugin": "^7.6.0", + "@typescript-eslint/parser": "^7.6.0", + esbuild: "^0.20.2", + eslint: "^8.57.0", + "eslint-config-prettier": "^9.1.0", + "eslint-import-resolver-typescript": "^3.6.1", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-prettier": "^5.1.3", + prettier: "^3.2.5", + rollup: "^4.14.1", + "rollup-plugin-esbuild": "^6.1.1", + "ts-node": "^10.9.2", + tsc: "^2.0.4", + typechain: "^8.3.2", + typescript: "^5.4.4" +}; +var _package = { + name: name, + version: version$3, + description: description$1, + main: main, + module: module$1, + types: types$1, + bin: bin, + scripts: scripts, + author: author, + license: license, + files: files, + dependencies: dependencies$1, + devDependencies: devDependencies +}; + +var packageJson = /*#__PURE__*/Object.freeze({ + __proto__: null, + author: author, + bin: bin, + default: _package, + dependencies: dependencies$1, + description: description$1, + devDependencies: devDependencies, + files: files, + license: license, + main: main, + module: module$1, + name: name, + scripts: scripts, + types: types$1, + version: version$3 +}); + +const _abi$4 = [ + { + constant: true, + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [], + name: "_totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "address", + name: "who", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transfer", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + constant: true, + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "approve", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + } + ], + name: "nonces", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "permit", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class ERC20__factory { + static createInterface() { + return new Interface(_abi$4); + } + static connect(address, runner) { + return new Contract(address, _abi$4, runner); + } +} +ERC20__factory.abi = _abi$4; + +const _abi$3 = [ + { + inputs: [], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [], + name: "GAS_UNIT", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint32", + name: "_derivationThresold", + type: "uint32" + } + ], + name: "changeDerivationThresold", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint32", + name: "_gasUnit", + type: "uint32" + } + ], + name: "changeGasUnit", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint32", + name: "_heartbeat", + type: "uint32" + } + ], + name: "changeHeartbeat", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address" + } + ], + name: "changeOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "derivationThresold", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "gasPrice", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "heartbeat", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "maxFeePerGas", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "maxPriorityFeePerGas", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "pastGasPrice", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint32", + name: "_gasPrice", + type: "uint32" + } + ], + name: "setGasPrice", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "timestamp", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + } +]; +class GasPriceOracle__factory { + static createInterface() { + return new Interface(_abi$3); + } + static connect(address, runner) { + return new Contract(address, _abi$3, runner); + } +} +GasPriceOracle__factory.abi = _abi$3; + +const _abi$2 = [ + { + inputs: [ + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call[]", + name: "calls", + type: "tuple[]" + } + ], + name: "aggregate", + outputs: [ + { + internalType: "uint256", + name: "blockNumber", + type: "uint256" + }, + { + internalType: "bytes[]", + name: "returnData", + type: "bytes[]" + } + ], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bool", + name: "allowFailure", + type: "bool" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call3[]", + name: "calls", + type: "tuple[]" + } + ], + name: "aggregate3", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "success", + type: "bool" + }, + { + internalType: "bytes", + name: "returnData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Result[]", + name: "returnData", + type: "tuple[]" + } + ], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bool", + name: "allowFailure", + type: "bool" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call3Value[]", + name: "calls", + type: "tuple[]" + } + ], + name: "aggregate3Value", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "success", + type: "bool" + }, + { + internalType: "bytes", + name: "returnData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Result[]", + name: "returnData", + type: "tuple[]" + } + ], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call[]", + name: "calls", + type: "tuple[]" + } + ], + name: "blockAndAggregate", + outputs: [ + { + internalType: "uint256", + name: "blockNumber", + type: "uint256" + }, + { + internalType: "bytes32", + name: "blockHash", + type: "bytes32" + }, + { + components: [ + { + internalType: "bool", + name: "success", + type: "bool" + }, + { + internalType: "bytes", + name: "returnData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Result[]", + name: "returnData", + type: "tuple[]" + } + ], + stateMutability: "payable", + type: "function" + }, + { + inputs: [], + name: "getBasefee", + outputs: [ + { + internalType: "uint256", + name: "basefee", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "blockNumber", + type: "uint256" + } + ], + name: "getBlockHash", + outputs: [ + { + internalType: "bytes32", + name: "blockHash", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getBlockNumber", + outputs: [ + { + internalType: "uint256", + name: "blockNumber", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getChainId", + outputs: [ + { + internalType: "uint256", + name: "chainid", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getCurrentBlockCoinbase", + outputs: [ + { + internalType: "address", + name: "coinbase", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getCurrentBlockDifficulty", + outputs: [ + { + internalType: "uint256", + name: "difficulty", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getCurrentBlockGasLimit", + outputs: [ + { + internalType: "uint256", + name: "gaslimit", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getCurrentBlockTimestamp", + outputs: [ + { + internalType: "uint256", + name: "timestamp", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "addr", + type: "address" + } + ], + name: "getEthBalance", + outputs: [ + { + internalType: "uint256", + name: "balance", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getLastBlockHash", + outputs: [ + { + internalType: "bytes32", + name: "blockHash", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bool", + name: "requireSuccess", + type: "bool" + }, + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call[]", + name: "calls", + type: "tuple[]" + } + ], + name: "tryAggregate", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "success", + type: "bool" + }, + { + internalType: "bytes", + name: "returnData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Result[]", + name: "returnData", + type: "tuple[]" + } + ], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "bool", + name: "requireSuccess", + type: "bool" + }, + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call[]", + name: "calls", + type: "tuple[]" + } + ], + name: "tryBlockAndAggregate", + outputs: [ + { + internalType: "uint256", + name: "blockNumber", + type: "uint256" + }, + { + internalType: "bytes32", + name: "blockHash", + type: "bytes32" + }, + { + components: [ + { + internalType: "bool", + name: "success", + type: "bool" + }, + { + internalType: "bytes", + name: "returnData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Result[]", + name: "returnData", + type: "tuple[]" + } + ], + stateMutability: "payable", + type: "function" + } +]; +class Multicall__factory { + static createInterface() { + return new Interface(_abi$2); + } + static connect(address, runner) { + return new Contract(address, _abi$2, runner); + } +} +Multicall__factory.abi = _abi$2; + +const _abi$1 = [ + { + inputs: [ + { + internalType: "contract MultiWrapper", + name: "_multiWrapper", + type: "address" + }, + { + internalType: "contract IOracle[]", + name: "existingOracles", + type: "address[]" + }, + { + internalType: "enum OffchainOracle.OracleType[]", + name: "oracleTypes", + type: "uint8[]" + }, + { + internalType: "contract IERC20[]", + name: "existingConnectors", + type: "address[]" + }, + { + internalType: "contract IERC20", + name: "wBase", + type: "address" + }, + { + internalType: "address", + name: "owner", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [], + name: "ArraysLengthMismatch", + type: "error" + }, + { + inputs: [], + name: "ConnectorAlreadyAdded", + type: "error" + }, + { + inputs: [], + name: "InvalidOracleTokenKind", + type: "error" + }, + { + inputs: [], + name: "OracleAlreadyAdded", + type: "error" + }, + { + inputs: [], + name: "SameTokens", + type: "error" + }, + { + inputs: [], + name: "TooBigThreshold", + type: "error" + }, + { + inputs: [], + name: "UnknownConnector", + type: "error" + }, + { + inputs: [], + name: "UnknownOracle", + type: "error" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "contract IERC20", + name: "connector", + type: "address" + } + ], + name: "ConnectorAdded", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "contract IERC20", + name: "connector", + type: "address" + } + ], + name: "ConnectorRemoved", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "contract MultiWrapper", + name: "multiWrapper", + type: "address" + } + ], + name: "MultiWrapperUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "contract IOracle", + name: "oracle", + type: "address" + }, + { + indexed: false, + internalType: "enum OffchainOracle.OracleType", + name: "oracleType", + type: "uint8" + } + ], + name: "OracleAdded", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "contract IOracle", + name: "oracle", + type: "address" + }, + { + indexed: false, + internalType: "enum OffchainOracle.OracleType", + name: "oracleType", + type: "uint8" + } + ], + name: "OracleRemoved", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "OwnershipTransferred", + type: "event" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "connector", + type: "address" + } + ], + name: "addConnector", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IOracle", + name: "oracle", + type: "address" + }, + { + internalType: "enum OffchainOracle.OracleType", + name: "oracleKind", + type: "uint8" + } + ], + name: "addOracle", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "connectors", + outputs: [ + { + internalType: "contract IERC20[]", + name: "allConnectors", + type: "address[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "contract IERC20", + name: "dstToken", + type: "address" + }, + { + internalType: "bool", + name: "useWrappers", + type: "bool" + } + ], + name: "getRate", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "bool", + name: "useSrcWrappers", + type: "bool" + } + ], + name: "getRateToEth", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "bool", + name: "useSrcWrappers", + type: "bool" + }, + { + internalType: "contract IERC20[]", + name: "customConnectors", + type: "address[]" + }, + { + internalType: "uint256", + name: "thresholdFilter", + type: "uint256" + } + ], + name: "getRateToEthWithCustomConnectors", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "bool", + name: "useSrcWrappers", + type: "bool" + }, + { + internalType: "uint256", + name: "thresholdFilter", + type: "uint256" + } + ], + name: "getRateToEthWithThreshold", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "contract IERC20", + name: "dstToken", + type: "address" + }, + { + internalType: "bool", + name: "useWrappers", + type: "bool" + }, + { + internalType: "contract IERC20[]", + name: "customConnectors", + type: "address[]" + }, + { + internalType: "uint256", + name: "thresholdFilter", + type: "uint256" + } + ], + name: "getRateWithCustomConnectors", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "contract IERC20", + name: "dstToken", + type: "address" + }, + { + internalType: "bool", + name: "useWrappers", + type: "bool" + }, + { + internalType: "uint256", + name: "thresholdFilter", + type: "uint256" + } + ], + name: "getRateWithThreshold", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "multiWrapper", + outputs: [ + { + internalType: "contract MultiWrapper", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "oracles", + outputs: [ + { + internalType: "contract IOracle[]", + name: "allOracles", + type: "address[]" + }, + { + internalType: "enum OffchainOracle.OracleType[]", + name: "oracleTypes", + type: "uint8[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "connector", + type: "address" + } + ], + name: "removeConnector", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IOracle", + name: "oracle", + type: "address" + }, + { + internalType: "enum OffchainOracle.OracleType", + name: "oracleKind", + type: "uint8" + } + ], + name: "removeOracle", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract MultiWrapper", + name: "_multiWrapper", + type: "address" + } + ], + name: "setMultiWrapper", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class OffchainOracle__factory { + static createInterface() { + return new Interface(_abi$1); + } + static connect(address, runner) { + return new Contract(address, _abi$1, runner); + } +} +OffchainOracle__factory.abi = _abi$1; + +const _abi = [ + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "DecimalsUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "GasPriceUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "L1BaseFeeUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "OverheadUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "OwnershipTransferred", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "ScalarUpdated", + type: "event" + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "gasPrice", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes", + name: "_data", + type: "bytes" + } + ], + name: "getL1Fee", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes", + name: "_data", + type: "bytes" + } + ], + name: "getL1GasUsed", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "l1BaseFee", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "overhead", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "scalar", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_decimals", + type: "uint256" + } + ], + name: "setDecimals", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_gasPrice", + type: "uint256" + } + ], + name: "setGasPrice", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_baseFee", + type: "uint256" + } + ], + name: "setL1BaseFee", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_overhead", + type: "uint256" + } + ], + name: "setOverhead", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_scalar", + type: "uint256" + } + ], + name: "setScalar", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class OvmGasPriceOracle__factory { + static createInterface() { + return new Interface(_abi); + } + static connect(address, runner) { + return new Contract(address, _abi, runner); + } +} +OvmGasPriceOracle__factory.abi = _abi; + +var nodePonyfill = {exports: {}}; + +var publicApi = {}; + +var URL$2 = {exports: {}}; + +var conversions = {}; +var lib$3 = conversions; + +function sign(x) { + return x < 0 ? -1 : 1; +} + +function evenRound(x) { + // Round x to the nearest integer, choosing the even integer if it lies halfway between two. + if ((x % 1) === 0.5 && (x & 1) === 0) { // [even number].5; round down (i.e. floor) + return Math.floor(x); + } else { + return Math.round(x); + } +} + +function createNumberConversion(bitLength, typeOpts) { + if (!typeOpts.unsigned) { + --bitLength; + } + const lowerBound = typeOpts.unsigned ? 0 : -Math.pow(2, bitLength); + const upperBound = Math.pow(2, bitLength) - 1; + + const moduloVal = typeOpts.moduloBitLength ? Math.pow(2, typeOpts.moduloBitLength) : Math.pow(2, bitLength); + const moduloBound = typeOpts.moduloBitLength ? Math.pow(2, typeOpts.moduloBitLength - 1) : Math.pow(2, bitLength - 1); + + return function(V, opts) { + if (!opts) opts = {}; + + let x = +V; + + if (opts.enforceRange) { + if (!Number.isFinite(x)) { + throw new TypeError("Argument is not a finite number"); + } + + x = sign(x) * Math.floor(Math.abs(x)); + if (x < lowerBound || x > upperBound) { + throw new TypeError("Argument is not in byte range"); + } + + return x; + } + + if (!isNaN(x) && opts.clamp) { + x = evenRound(x); + + if (x < lowerBound) x = lowerBound; + if (x > upperBound) x = upperBound; + return x; + } + + if (!Number.isFinite(x) || x === 0) { + return 0; + } + + x = sign(x) * Math.floor(Math.abs(x)); + x = x % moduloVal; + + if (!typeOpts.unsigned && x >= moduloBound) { + return x - moduloVal; + } else if (typeOpts.unsigned) { + if (x < 0) { + x += moduloVal; + } else if (x === -0) { // don't return negative zero + return 0; + } + } + + return x; + } +} + +conversions["void"] = function () { + return undefined; +}; + +conversions["boolean"] = function (val) { + return !!val; +}; + +conversions["byte"] = createNumberConversion(8, { unsigned: false }); +conversions["octet"] = createNumberConversion(8, { unsigned: true }); + +conversions["short"] = createNumberConversion(16, { unsigned: false }); +conversions["unsigned short"] = createNumberConversion(16, { unsigned: true }); + +conversions["long"] = createNumberConversion(32, { unsigned: false }); +conversions["unsigned long"] = createNumberConversion(32, { unsigned: true }); + +conversions["long long"] = createNumberConversion(32, { unsigned: false, moduloBitLength: 64 }); +conversions["unsigned long long"] = createNumberConversion(32, { unsigned: true, moduloBitLength: 64 }); + +conversions["double"] = function (V) { + const x = +V; + + if (!Number.isFinite(x)) { + throw new TypeError("Argument is not a finite floating-point value"); + } + + return x; +}; + +conversions["unrestricted double"] = function (V) { + const x = +V; + + if (isNaN(x)) { + throw new TypeError("Argument is NaN"); + } + + return x; +}; + +// not quite valid, but good enough for JS +conversions["float"] = conversions["double"]; +conversions["unrestricted float"] = conversions["unrestricted double"]; + +conversions["DOMString"] = function (V, opts) { + if (!opts) opts = {}; + + if (opts.treatNullAsEmptyString && V === null) { + return ""; + } + + return String(V); +}; + +conversions["ByteString"] = function (V, opts) { + const x = String(V); + let c = undefined; + for (let i = 0; (c = x.codePointAt(i)) !== undefined; ++i) { + if (c > 255) { + throw new TypeError("Argument is not a valid bytestring"); + } + } + + return x; +}; + +conversions["USVString"] = function (V) { + const S = String(V); + const n = S.length; + const U = []; + for (let i = 0; i < n; ++i) { + const c = S.charCodeAt(i); + if (c < 0xD800 || c > 0xDFFF) { + U.push(String.fromCodePoint(c)); + } else if (0xDC00 <= c && c <= 0xDFFF) { + U.push(String.fromCodePoint(0xFFFD)); + } else { + if (i === n - 1) { + U.push(String.fromCodePoint(0xFFFD)); + } else { + const d = S.charCodeAt(i + 1); + if (0xDC00 <= d && d <= 0xDFFF) { + const a = c & 0x3FF; + const b = d & 0x3FF; + U.push(String.fromCodePoint((2 << 15) + (2 << 9) * a + b)); + ++i; + } else { + U.push(String.fromCodePoint(0xFFFD)); + } + } + } + } + + return U.join(''); +}; + +conversions["Date"] = function (V, opts) { + if (!(V instanceof Date)) { + throw new TypeError("Argument is not a Date object"); + } + if (isNaN(V)) { + return undefined; + } + + return V; +}; + +conversions["RegExp"] = function (V, opts) { + if (!(V instanceof RegExp)) { + V = new RegExp(V); + } + + return V; +}; + +var utils$f = {exports: {}}; + +(function (module) { + + module.exports.mixin = function mixin(target, source) { + const keys = Object.getOwnPropertyNames(source); + for (let i = 0; i < keys.length; ++i) { + Object.defineProperty(target, keys[i], Object.getOwnPropertyDescriptor(source, keys[i])); + } + }; + + module.exports.wrapperSymbol = Symbol("wrapper"); + module.exports.implSymbol = Symbol("impl"); + + module.exports.wrapperForImpl = function (impl) { + return impl[module.exports.wrapperSymbol]; + }; + + module.exports.implForWrapper = function (wrapper) { + return wrapper[module.exports.implSymbol]; + }; +} (utils$f)); + +var utilsExports = utils$f.exports; + +var URLImpl = {}; + +var urlStateMachine = {exports: {}}; + +var tr46 = {}; + +var require$$1 = [ + [ + [ + 0, + 44 + ], + "disallowed_STD3_valid" + ], + [ + [ + 45, + 46 + ], + "valid" + ], + [ + [ + 47, + 47 + ], + "disallowed_STD3_valid" + ], + [ + [ + 48, + 57 + ], + "valid" + ], + [ + [ + 58, + 64 + ], + "disallowed_STD3_valid" + ], + [ + [ + 65, + 65 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 66, + 66 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 67, + 67 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 68, + 68 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 69, + 69 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 70, + 70 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 71, + 71 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 72, + 72 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 73, + 73 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 74, + 74 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 75, + 75 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 76, + 76 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 77, + 77 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 78, + 78 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 79, + 79 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 80, + 80 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 81, + 81 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 82, + 82 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 83, + 83 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 84, + 84 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 85, + 85 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 86, + 86 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 87, + 87 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 88, + 88 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 89, + 89 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 90, + 90 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 91, + 96 + ], + "disallowed_STD3_valid" + ], + [ + [ + 97, + 122 + ], + "valid" + ], + [ + [ + 123, + 127 + ], + "disallowed_STD3_valid" + ], + [ + [ + 128, + 159 + ], + "disallowed" + ], + [ + [ + 160, + 160 + ], + "disallowed_STD3_mapped", + [ + 32 + ] + ], + [ + [ + 161, + 167 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 168, + 168 + ], + "disallowed_STD3_mapped", + [ + 32, + 776 + ] + ], + [ + [ + 169, + 169 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 170, + 170 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 171, + 172 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 173, + 173 + ], + "ignored" + ], + [ + [ + 174, + 174 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 175, + 175 + ], + "disallowed_STD3_mapped", + [ + 32, + 772 + ] + ], + [ + [ + 176, + 177 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 178, + 178 + ], + "mapped", + [ + 50 + ] + ], + [ + [ + 179, + 179 + ], + "mapped", + [ + 51 + ] + ], + [ + [ + 180, + 180 + ], + "disallowed_STD3_mapped", + [ + 32, + 769 + ] + ], + [ + [ + 181, + 181 + ], + "mapped", + [ + 956 + ] + ], + [ + [ + 182, + 182 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 183, + 183 + ], + "valid" + ], + [ + [ + 184, + 184 + ], + "disallowed_STD3_mapped", + [ + 32, + 807 + ] + ], + [ + [ + 185, + 185 + ], + "mapped", + [ + 49 + ] + ], + [ + [ + 186, + 186 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 187, + 187 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 188, + 188 + ], + "mapped", + [ + 49, + 8260, + 52 + ] + ], + [ + [ + 189, + 189 + ], + "mapped", + [ + 49, + 8260, + 50 + ] + ], + [ + [ + 190, + 190 + ], + "mapped", + [ + 51, + 8260, + 52 + ] + ], + [ + [ + 191, + 191 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 192, + 192 + ], + "mapped", + [ + 224 + ] + ], + [ + [ + 193, + 193 + ], + "mapped", + [ + 225 + ] + ], + [ + [ + 194, + 194 + ], + "mapped", + [ + 226 + ] + ], + [ + [ + 195, + 195 + ], + "mapped", + [ + 227 + ] + ], + [ + [ + 196, + 196 + ], + "mapped", + [ + 228 + ] + ], + [ + [ + 197, + 197 + ], + "mapped", + [ + 229 + ] + ], + [ + [ + 198, + 198 + ], + "mapped", + [ + 230 + ] + ], + [ + [ + 199, + 199 + ], + "mapped", + [ + 231 + ] + ], + [ + [ + 200, + 200 + ], + "mapped", + [ + 232 + ] + ], + [ + [ + 201, + 201 + ], + "mapped", + [ + 233 + ] + ], + [ + [ + 202, + 202 + ], + "mapped", + [ + 234 + ] + ], + [ + [ + 203, + 203 + ], + "mapped", + [ + 235 + ] + ], + [ + [ + 204, + 204 + ], + "mapped", + [ + 236 + ] + ], + [ + [ + 205, + 205 + ], + "mapped", + [ + 237 + ] + ], + [ + [ + 206, + 206 + ], + "mapped", + [ + 238 + ] + ], + [ + [ + 207, + 207 + ], + "mapped", + [ + 239 + ] + ], + [ + [ + 208, + 208 + ], + "mapped", + [ + 240 + ] + ], + [ + [ + 209, + 209 + ], + "mapped", + [ + 241 + ] + ], + [ + [ + 210, + 210 + ], + "mapped", + [ + 242 + ] + ], + [ + [ + 211, + 211 + ], + "mapped", + [ + 243 + ] + ], + [ + [ + 212, + 212 + ], + "mapped", + [ + 244 + ] + ], + [ + [ + 213, + 213 + ], + "mapped", + [ + 245 + ] + ], + [ + [ + 214, + 214 + ], + "mapped", + [ + 246 + ] + ], + [ + [ + 215, + 215 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 216, + 216 + ], + "mapped", + [ + 248 + ] + ], + [ + [ + 217, + 217 + ], + "mapped", + [ + 249 + ] + ], + [ + [ + 218, + 218 + ], + "mapped", + [ + 250 + ] + ], + [ + [ + 219, + 219 + ], + "mapped", + [ + 251 + ] + ], + [ + [ + 220, + 220 + ], + "mapped", + [ + 252 + ] + ], + [ + [ + 221, + 221 + ], + "mapped", + [ + 253 + ] + ], + [ + [ + 222, + 222 + ], + "mapped", + [ + 254 + ] + ], + [ + [ + 223, + 223 + ], + "deviation", + [ + 115, + 115 + ] + ], + [ + [ + 224, + 246 + ], + "valid" + ], + [ + [ + 247, + 247 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 248, + 255 + ], + "valid" + ], + [ + [ + 256, + 256 + ], + "mapped", + [ + 257 + ] + ], + [ + [ + 257, + 257 + ], + "valid" + ], + [ + [ + 258, + 258 + ], + "mapped", + [ + 259 + ] + ], + [ + [ + 259, + 259 + ], + "valid" + ], + [ + [ + 260, + 260 + ], + "mapped", + [ + 261 + ] + ], + [ + [ + 261, + 261 + ], + "valid" + ], + [ + [ + 262, + 262 + ], + "mapped", + [ + 263 + ] + ], + [ + [ + 263, + 263 + ], + "valid" + ], + [ + [ + 264, + 264 + ], + "mapped", + [ + 265 + ] + ], + [ + [ + 265, + 265 + ], + "valid" + ], + [ + [ + 266, + 266 + ], + "mapped", + [ + 267 + ] + ], + [ + [ + 267, + 267 + ], + "valid" + ], + [ + [ + 268, + 268 + ], + "mapped", + [ + 269 + ] + ], + [ + [ + 269, + 269 + ], + "valid" + ], + [ + [ + 270, + 270 + ], + "mapped", + [ + 271 + ] + ], + [ + [ + 271, + 271 + ], + "valid" + ], + [ + [ + 272, + 272 + ], + "mapped", + [ + 273 + ] + ], + [ + [ + 273, + 273 + ], + "valid" + ], + [ + [ + 274, + 274 + ], + "mapped", + [ + 275 + ] + ], + [ + [ + 275, + 275 + ], + "valid" + ], + [ + [ + 276, + 276 + ], + "mapped", + [ + 277 + ] + ], + [ + [ + 277, + 277 + ], + "valid" + ], + [ + [ + 278, + 278 + ], + "mapped", + [ + 279 + ] + ], + [ + [ + 279, + 279 + ], + "valid" + ], + [ + [ + 280, + 280 + ], + "mapped", + [ + 281 + ] + ], + [ + [ + 281, + 281 + ], + "valid" + ], + [ + [ + 282, + 282 + ], + "mapped", + [ + 283 + ] + ], + [ + [ + 283, + 283 + ], + "valid" + ], + [ + [ + 284, + 284 + ], + "mapped", + [ + 285 + ] + ], + [ + [ + 285, + 285 + ], + "valid" + ], + [ + [ + 286, + 286 + ], + "mapped", + [ + 287 + ] + ], + [ + [ + 287, + 287 + ], + "valid" + ], + [ + [ + 288, + 288 + ], + "mapped", + [ + 289 + ] + ], + [ + [ + 289, + 289 + ], + "valid" + ], + [ + [ + 290, + 290 + ], + "mapped", + [ + 291 + ] + ], + [ + [ + 291, + 291 + ], + "valid" + ], + [ + [ + 292, + 292 + ], + "mapped", + [ + 293 + ] + ], + [ + [ + 293, + 293 + ], + "valid" + ], + [ + [ + 294, + 294 + ], + "mapped", + [ + 295 + ] + ], + [ + [ + 295, + 295 + ], + "valid" + ], + [ + [ + 296, + 296 + ], + "mapped", + [ + 297 + ] + ], + [ + [ + 297, + 297 + ], + "valid" + ], + [ + [ + 298, + 298 + ], + "mapped", + [ + 299 + ] + ], + [ + [ + 299, + 299 + ], + "valid" + ], + [ + [ + 300, + 300 + ], + "mapped", + [ + 301 + ] + ], + [ + [ + 301, + 301 + ], + "valid" + ], + [ + [ + 302, + 302 + ], + "mapped", + [ + 303 + ] + ], + [ + [ + 303, + 303 + ], + "valid" + ], + [ + [ + 304, + 304 + ], + "mapped", + [ + 105, + 775 + ] + ], + [ + [ + 305, + 305 + ], + "valid" + ], + [ + [ + 306, + 307 + ], + "mapped", + [ + 105, + 106 + ] + ], + [ + [ + 308, + 308 + ], + "mapped", + [ + 309 + ] + ], + [ + [ + 309, + 309 + ], + "valid" + ], + [ + [ + 310, + 310 + ], + "mapped", + [ + 311 + ] + ], + [ + [ + 311, + 312 + ], + "valid" + ], + [ + [ + 313, + 313 + ], + "mapped", + [ + 314 + ] + ], + [ + [ + 314, + 314 + ], + "valid" + ], + [ + [ + 315, + 315 + ], + "mapped", + [ + 316 + ] + ], + [ + [ + 316, + 316 + ], + "valid" + ], + [ + [ + 317, + 317 + ], + "mapped", + [ + 318 + ] + ], + [ + [ + 318, + 318 + ], + "valid" + ], + [ + [ + 319, + 320 + ], + "mapped", + [ + 108, + 183 + ] + ], + [ + [ + 321, + 321 + ], + "mapped", + [ + 322 + ] + ], + [ + [ + 322, + 322 + ], + "valid" + ], + [ + [ + 323, + 323 + ], + "mapped", + [ + 324 + ] + ], + [ + [ + 324, + 324 + ], + "valid" + ], + [ + [ + 325, + 325 + ], + "mapped", + [ + 326 + ] + ], + [ + [ + 326, + 326 + ], + "valid" + ], + [ + [ + 327, + 327 + ], + "mapped", + [ + 328 + ] + ], + [ + [ + 328, + 328 + ], + "valid" + ], + [ + [ + 329, + 329 + ], + "mapped", + [ + 700, + 110 + ] + ], + [ + [ + 330, + 330 + ], + "mapped", + [ + 331 + ] + ], + [ + [ + 331, + 331 + ], + "valid" + ], + [ + [ + 332, + 332 + ], + "mapped", + [ + 333 + ] + ], + [ + [ + 333, + 333 + ], + "valid" + ], + [ + [ + 334, + 334 + ], + "mapped", + [ + 335 + ] + ], + [ + [ + 335, + 335 + ], + "valid" + ], + [ + [ + 336, + 336 + ], + "mapped", + [ + 337 + ] + ], + [ + [ + 337, + 337 + ], + "valid" + ], + [ + [ + 338, + 338 + ], + "mapped", + [ + 339 + ] + ], + [ + [ + 339, + 339 + ], + "valid" + ], + [ + [ + 340, + 340 + ], + "mapped", + [ + 341 + ] + ], + [ + [ + 341, + 341 + ], + "valid" + ], + [ + [ + 342, + 342 + ], + "mapped", + [ + 343 + ] + ], + [ + [ + 343, + 343 + ], + "valid" + ], + [ + [ + 344, + 344 + ], + "mapped", + [ + 345 + ] + ], + [ + [ + 345, + 345 + ], + "valid" + ], + [ + [ + 346, + 346 + ], + "mapped", + [ + 347 + ] + ], + [ + [ + 347, + 347 + ], + "valid" + ], + [ + [ + 348, + 348 + ], + "mapped", + [ + 349 + ] + ], + [ + [ + 349, + 349 + ], + "valid" + ], + [ + [ + 350, + 350 + ], + "mapped", + [ + 351 + ] + ], + [ + [ + 351, + 351 + ], + "valid" + ], + [ + [ + 352, + 352 + ], + "mapped", + [ + 353 + ] + ], + [ + [ + 353, + 353 + ], + "valid" + ], + [ + [ + 354, + 354 + ], + "mapped", + [ + 355 + ] + ], + [ + [ + 355, + 355 + ], + "valid" + ], + [ + [ + 356, + 356 + ], + "mapped", + [ + 357 + ] + ], + [ + [ + 357, + 357 + ], + "valid" + ], + [ + [ + 358, + 358 + ], + "mapped", + [ + 359 + ] + ], + [ + [ + 359, + 359 + ], + "valid" + ], + [ + [ + 360, + 360 + ], + "mapped", + [ + 361 + ] + ], + [ + [ + 361, + 361 + ], + "valid" + ], + [ + [ + 362, + 362 + ], + "mapped", + [ + 363 + ] + ], + [ + [ + 363, + 363 + ], + "valid" + ], + [ + [ + 364, + 364 + ], + "mapped", + [ + 365 + ] + ], + [ + [ + 365, + 365 + ], + "valid" + ], + [ + [ + 366, + 366 + ], + "mapped", + [ + 367 + ] + ], + [ + [ + 367, + 367 + ], + "valid" + ], + [ + [ + 368, + 368 + ], + "mapped", + [ + 369 + ] + ], + [ + [ + 369, + 369 + ], + "valid" + ], + [ + [ + 370, + 370 + ], + "mapped", + [ + 371 + ] + ], + [ + [ + 371, + 371 + ], + "valid" + ], + [ + [ + 372, + 372 + ], + "mapped", + [ + 373 + ] + ], + [ + [ + 373, + 373 + ], + "valid" + ], + [ + [ + 374, + 374 + ], + "mapped", + [ + 375 + ] + ], + [ + [ + 375, + 375 + ], + "valid" + ], + [ + [ + 376, + 376 + ], + "mapped", + [ + 255 + ] + ], + [ + [ + 377, + 377 + ], + "mapped", + [ + 378 + ] + ], + [ + [ + 378, + 378 + ], + "valid" + ], + [ + [ + 379, + 379 + ], + "mapped", + [ + 380 + ] + ], + [ + [ + 380, + 380 + ], + "valid" + ], + [ + [ + 381, + 381 + ], + "mapped", + [ + 382 + ] + ], + [ + [ + 382, + 382 + ], + "valid" + ], + [ + [ + 383, + 383 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 384, + 384 + ], + "valid" + ], + [ + [ + 385, + 385 + ], + "mapped", + [ + 595 + ] + ], + [ + [ + 386, + 386 + ], + "mapped", + [ + 387 + ] + ], + [ + [ + 387, + 387 + ], + "valid" + ], + [ + [ + 388, + 388 + ], + "mapped", + [ + 389 + ] + ], + [ + [ + 389, + 389 + ], + "valid" + ], + [ + [ + 390, + 390 + ], + "mapped", + [ + 596 + ] + ], + [ + [ + 391, + 391 + ], + "mapped", + [ + 392 + ] + ], + [ + [ + 392, + 392 + ], + "valid" + ], + [ + [ + 393, + 393 + ], + "mapped", + [ + 598 + ] + ], + [ + [ + 394, + 394 + ], + "mapped", + [ + 599 + ] + ], + [ + [ + 395, + 395 + ], + "mapped", + [ + 396 + ] + ], + [ + [ + 396, + 397 + ], + "valid" + ], + [ + [ + 398, + 398 + ], + "mapped", + [ + 477 + ] + ], + [ + [ + 399, + 399 + ], + "mapped", + [ + 601 + ] + ], + [ + [ + 400, + 400 + ], + "mapped", + [ + 603 + ] + ], + [ + [ + 401, + 401 + ], + "mapped", + [ + 402 + ] + ], + [ + [ + 402, + 402 + ], + "valid" + ], + [ + [ + 403, + 403 + ], + "mapped", + [ + 608 + ] + ], + [ + [ + 404, + 404 + ], + "mapped", + [ + 611 + ] + ], + [ + [ + 405, + 405 + ], + "valid" + ], + [ + [ + 406, + 406 + ], + "mapped", + [ + 617 + ] + ], + [ + [ + 407, + 407 + ], + "mapped", + [ + 616 + ] + ], + [ + [ + 408, + 408 + ], + "mapped", + [ + 409 + ] + ], + [ + [ + 409, + 411 + ], + "valid" + ], + [ + [ + 412, + 412 + ], + "mapped", + [ + 623 + ] + ], + [ + [ + 413, + 413 + ], + "mapped", + [ + 626 + ] + ], + [ + [ + 414, + 414 + ], + "valid" + ], + [ + [ + 415, + 415 + ], + "mapped", + [ + 629 + ] + ], + [ + [ + 416, + 416 + ], + "mapped", + [ + 417 + ] + ], + [ + [ + 417, + 417 + ], + "valid" + ], + [ + [ + 418, + 418 + ], + "mapped", + [ + 419 + ] + ], + [ + [ + 419, + 419 + ], + "valid" + ], + [ + [ + 420, + 420 + ], + "mapped", + [ + 421 + ] + ], + [ + [ + 421, + 421 + ], + "valid" + ], + [ + [ + 422, + 422 + ], + "mapped", + [ + 640 + ] + ], + [ + [ + 423, + 423 + ], + "mapped", + [ + 424 + ] + ], + [ + [ + 424, + 424 + ], + "valid" + ], + [ + [ + 425, + 425 + ], + "mapped", + [ + 643 + ] + ], + [ + [ + 426, + 427 + ], + "valid" + ], + [ + [ + 428, + 428 + ], + "mapped", + [ + 429 + ] + ], + [ + [ + 429, + 429 + ], + "valid" + ], + [ + [ + 430, + 430 + ], + "mapped", + [ + 648 + ] + ], + [ + [ + 431, + 431 + ], + "mapped", + [ + 432 + ] + ], + [ + [ + 432, + 432 + ], + "valid" + ], + [ + [ + 433, + 433 + ], + "mapped", + [ + 650 + ] + ], + [ + [ + 434, + 434 + ], + "mapped", + [ + 651 + ] + ], + [ + [ + 435, + 435 + ], + "mapped", + [ + 436 + ] + ], + [ + [ + 436, + 436 + ], + "valid" + ], + [ + [ + 437, + 437 + ], + "mapped", + [ + 438 + ] + ], + [ + [ + 438, + 438 + ], + "valid" + ], + [ + [ + 439, + 439 + ], + "mapped", + [ + 658 + ] + ], + [ + [ + 440, + 440 + ], + "mapped", + [ + 441 + ] + ], + [ + [ + 441, + 443 + ], + "valid" + ], + [ + [ + 444, + 444 + ], + "mapped", + [ + 445 + ] + ], + [ + [ + 445, + 451 + ], + "valid" + ], + [ + [ + 452, + 454 + ], + "mapped", + [ + 100, + 382 + ] + ], + [ + [ + 455, + 457 + ], + "mapped", + [ + 108, + 106 + ] + ], + [ + [ + 458, + 460 + ], + "mapped", + [ + 110, + 106 + ] + ], + [ + [ + 461, + 461 + ], + "mapped", + [ + 462 + ] + ], + [ + [ + 462, + 462 + ], + "valid" + ], + [ + [ + 463, + 463 + ], + "mapped", + [ + 464 + ] + ], + [ + [ + 464, + 464 + ], + "valid" + ], + [ + [ + 465, + 465 + ], + "mapped", + [ + 466 + ] + ], + [ + [ + 466, + 466 + ], + "valid" + ], + [ + [ + 467, + 467 + ], + "mapped", + [ + 468 + ] + ], + [ + [ + 468, + 468 + ], + "valid" + ], + [ + [ + 469, + 469 + ], + "mapped", + [ + 470 + ] + ], + [ + [ + 470, + 470 + ], + "valid" + ], + [ + [ + 471, + 471 + ], + "mapped", + [ + 472 + ] + ], + [ + [ + 472, + 472 + ], + "valid" + ], + [ + [ + 473, + 473 + ], + "mapped", + [ + 474 + ] + ], + [ + [ + 474, + 474 + ], + "valid" + ], + [ + [ + 475, + 475 + ], + "mapped", + [ + 476 + ] + ], + [ + [ + 476, + 477 + ], + "valid" + ], + [ + [ + 478, + 478 + ], + "mapped", + [ + 479 + ] + ], + [ + [ + 479, + 479 + ], + "valid" + ], + [ + [ + 480, + 480 + ], + "mapped", + [ + 481 + ] + ], + [ + [ + 481, + 481 + ], + "valid" + ], + [ + [ + 482, + 482 + ], + "mapped", + [ + 483 + ] + ], + [ + [ + 483, + 483 + ], + "valid" + ], + [ + [ + 484, + 484 + ], + "mapped", + [ + 485 + ] + ], + [ + [ + 485, + 485 + ], + "valid" + ], + [ + [ + 486, + 486 + ], + "mapped", + [ + 487 + ] + ], + [ + [ + 487, + 487 + ], + "valid" + ], + [ + [ + 488, + 488 + ], + "mapped", + [ + 489 + ] + ], + [ + [ + 489, + 489 + ], + "valid" + ], + [ + [ + 490, + 490 + ], + "mapped", + [ + 491 + ] + ], + [ + [ + 491, + 491 + ], + "valid" + ], + [ + [ + 492, + 492 + ], + "mapped", + [ + 493 + ] + ], + [ + [ + 493, + 493 + ], + "valid" + ], + [ + [ + 494, + 494 + ], + "mapped", + [ + 495 + ] + ], + [ + [ + 495, + 496 + ], + "valid" + ], + [ + [ + 497, + 499 + ], + "mapped", + [ + 100, + 122 + ] + ], + [ + [ + 500, + 500 + ], + "mapped", + [ + 501 + ] + ], + [ + [ + 501, + 501 + ], + "valid" + ], + [ + [ + 502, + 502 + ], + "mapped", + [ + 405 + ] + ], + [ + [ + 503, + 503 + ], + "mapped", + [ + 447 + ] + ], + [ + [ + 504, + 504 + ], + "mapped", + [ + 505 + ] + ], + [ + [ + 505, + 505 + ], + "valid" + ], + [ + [ + 506, + 506 + ], + "mapped", + [ + 507 + ] + ], + [ + [ + 507, + 507 + ], + "valid" + ], + [ + [ + 508, + 508 + ], + "mapped", + [ + 509 + ] + ], + [ + [ + 509, + 509 + ], + "valid" + ], + [ + [ + 510, + 510 + ], + "mapped", + [ + 511 + ] + ], + [ + [ + 511, + 511 + ], + "valid" + ], + [ + [ + 512, + 512 + ], + "mapped", + [ + 513 + ] + ], + [ + [ + 513, + 513 + ], + "valid" + ], + [ + [ + 514, + 514 + ], + "mapped", + [ + 515 + ] + ], + [ + [ + 515, + 515 + ], + "valid" + ], + [ + [ + 516, + 516 + ], + "mapped", + [ + 517 + ] + ], + [ + [ + 517, + 517 + ], + "valid" + ], + [ + [ + 518, + 518 + ], + "mapped", + [ + 519 + ] + ], + [ + [ + 519, + 519 + ], + "valid" + ], + [ + [ + 520, + 520 + ], + "mapped", + [ + 521 + ] + ], + [ + [ + 521, + 521 + ], + "valid" + ], + [ + [ + 522, + 522 + ], + "mapped", + [ + 523 + ] + ], + [ + [ + 523, + 523 + ], + "valid" + ], + [ + [ + 524, + 524 + ], + "mapped", + [ + 525 + ] + ], + [ + [ + 525, + 525 + ], + "valid" + ], + [ + [ + 526, + 526 + ], + "mapped", + [ + 527 + ] + ], + [ + [ + 527, + 527 + ], + "valid" + ], + [ + [ + 528, + 528 + ], + "mapped", + [ + 529 + ] + ], + [ + [ + 529, + 529 + ], + "valid" + ], + [ + [ + 530, + 530 + ], + "mapped", + [ + 531 + ] + ], + [ + [ + 531, + 531 + ], + "valid" + ], + [ + [ + 532, + 532 + ], + "mapped", + [ + 533 + ] + ], + [ + [ + 533, + 533 + ], + "valid" + ], + [ + [ + 534, + 534 + ], + "mapped", + [ + 535 + ] + ], + [ + [ + 535, + 535 + ], + "valid" + ], + [ + [ + 536, + 536 + ], + "mapped", + [ + 537 + ] + ], + [ + [ + 537, + 537 + ], + "valid" + ], + [ + [ + 538, + 538 + ], + "mapped", + [ + 539 + ] + ], + [ + [ + 539, + 539 + ], + "valid" + ], + [ + [ + 540, + 540 + ], + "mapped", + [ + 541 + ] + ], + [ + [ + 541, + 541 + ], + "valid" + ], + [ + [ + 542, + 542 + ], + "mapped", + [ + 543 + ] + ], + [ + [ + 543, + 543 + ], + "valid" + ], + [ + [ + 544, + 544 + ], + "mapped", + [ + 414 + ] + ], + [ + [ + 545, + 545 + ], + "valid" + ], + [ + [ + 546, + 546 + ], + "mapped", + [ + 547 + ] + ], + [ + [ + 547, + 547 + ], + "valid" + ], + [ + [ + 548, + 548 + ], + "mapped", + [ + 549 + ] + ], + [ + [ + 549, + 549 + ], + "valid" + ], + [ + [ + 550, + 550 + ], + "mapped", + [ + 551 + ] + ], + [ + [ + 551, + 551 + ], + "valid" + ], + [ + [ + 552, + 552 + ], + "mapped", + [ + 553 + ] + ], + [ + [ + 553, + 553 + ], + "valid" + ], + [ + [ + 554, + 554 + ], + "mapped", + [ + 555 + ] + ], + [ + [ + 555, + 555 + ], + "valid" + ], + [ + [ + 556, + 556 + ], + "mapped", + [ + 557 + ] + ], + [ + [ + 557, + 557 + ], + "valid" + ], + [ + [ + 558, + 558 + ], + "mapped", + [ + 559 + ] + ], + [ + [ + 559, + 559 + ], + "valid" + ], + [ + [ + 560, + 560 + ], + "mapped", + [ + 561 + ] + ], + [ + [ + 561, + 561 + ], + "valid" + ], + [ + [ + 562, + 562 + ], + "mapped", + [ + 563 + ] + ], + [ + [ + 563, + 563 + ], + "valid" + ], + [ + [ + 564, + 566 + ], + "valid" + ], + [ + [ + 567, + 569 + ], + "valid" + ], + [ + [ + 570, + 570 + ], + "mapped", + [ + 11365 + ] + ], + [ + [ + 571, + 571 + ], + "mapped", + [ + 572 + ] + ], + [ + [ + 572, + 572 + ], + "valid" + ], + [ + [ + 573, + 573 + ], + "mapped", + [ + 410 + ] + ], + [ + [ + 574, + 574 + ], + "mapped", + [ + 11366 + ] + ], + [ + [ + 575, + 576 + ], + "valid" + ], + [ + [ + 577, + 577 + ], + "mapped", + [ + 578 + ] + ], + [ + [ + 578, + 578 + ], + "valid" + ], + [ + [ + 579, + 579 + ], + "mapped", + [ + 384 + ] + ], + [ + [ + 580, + 580 + ], + "mapped", + [ + 649 + ] + ], + [ + [ + 581, + 581 + ], + "mapped", + [ + 652 + ] + ], + [ + [ + 582, + 582 + ], + "mapped", + [ + 583 + ] + ], + [ + [ + 583, + 583 + ], + "valid" + ], + [ + [ + 584, + 584 + ], + "mapped", + [ + 585 + ] + ], + [ + [ + 585, + 585 + ], + "valid" + ], + [ + [ + 586, + 586 + ], + "mapped", + [ + 587 + ] + ], + [ + [ + 587, + 587 + ], + "valid" + ], + [ + [ + 588, + 588 + ], + "mapped", + [ + 589 + ] + ], + [ + [ + 589, + 589 + ], + "valid" + ], + [ + [ + 590, + 590 + ], + "mapped", + [ + 591 + ] + ], + [ + [ + 591, + 591 + ], + "valid" + ], + [ + [ + 592, + 680 + ], + "valid" + ], + [ + [ + 681, + 685 + ], + "valid" + ], + [ + [ + 686, + 687 + ], + "valid" + ], + [ + [ + 688, + 688 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 689, + 689 + ], + "mapped", + [ + 614 + ] + ], + [ + [ + 690, + 690 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 691, + 691 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 692, + 692 + ], + "mapped", + [ + 633 + ] + ], + [ + [ + 693, + 693 + ], + "mapped", + [ + 635 + ] + ], + [ + [ + 694, + 694 + ], + "mapped", + [ + 641 + ] + ], + [ + [ + 695, + 695 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 696, + 696 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 697, + 705 + ], + "valid" + ], + [ + [ + 706, + 709 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 710, + 721 + ], + "valid" + ], + [ + [ + 722, + 727 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 728, + 728 + ], + "disallowed_STD3_mapped", + [ + 32, + 774 + ] + ], + [ + [ + 729, + 729 + ], + "disallowed_STD3_mapped", + [ + 32, + 775 + ] + ], + [ + [ + 730, + 730 + ], + "disallowed_STD3_mapped", + [ + 32, + 778 + ] + ], + [ + [ + 731, + 731 + ], + "disallowed_STD3_mapped", + [ + 32, + 808 + ] + ], + [ + [ + 732, + 732 + ], + "disallowed_STD3_mapped", + [ + 32, + 771 + ] + ], + [ + [ + 733, + 733 + ], + "disallowed_STD3_mapped", + [ + 32, + 779 + ] + ], + [ + [ + 734, + 734 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 735, + 735 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 736, + 736 + ], + "mapped", + [ + 611 + ] + ], + [ + [ + 737, + 737 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 738, + 738 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 739, + 739 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 740, + 740 + ], + "mapped", + [ + 661 + ] + ], + [ + [ + 741, + 745 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 746, + 747 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 748, + 748 + ], + "valid" + ], + [ + [ + 749, + 749 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 750, + 750 + ], + "valid" + ], + [ + [ + 751, + 767 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 768, + 831 + ], + "valid" + ], + [ + [ + 832, + 832 + ], + "mapped", + [ + 768 + ] + ], + [ + [ + 833, + 833 + ], + "mapped", + [ + 769 + ] + ], + [ + [ + 834, + 834 + ], + "valid" + ], + [ + [ + 835, + 835 + ], + "mapped", + [ + 787 + ] + ], + [ + [ + 836, + 836 + ], + "mapped", + [ + 776, + 769 + ] + ], + [ + [ + 837, + 837 + ], + "mapped", + [ + 953 + ] + ], + [ + [ + 838, + 846 + ], + "valid" + ], + [ + [ + 847, + 847 + ], + "ignored" + ], + [ + [ + 848, + 855 + ], + "valid" + ], + [ + [ + 856, + 860 + ], + "valid" + ], + [ + [ + 861, + 863 + ], + "valid" + ], + [ + [ + 864, + 865 + ], + "valid" + ], + [ + [ + 866, + 866 + ], + "valid" + ], + [ + [ + 867, + 879 + ], + "valid" + ], + [ + [ + 880, + 880 + ], + "mapped", + [ + 881 + ] + ], + [ + [ + 881, + 881 + ], + "valid" + ], + [ + [ + 882, + 882 + ], + "mapped", + [ + 883 + ] + ], + [ + [ + 883, + 883 + ], + "valid" + ], + [ + [ + 884, + 884 + ], + "mapped", + [ + 697 + ] + ], + [ + [ + 885, + 885 + ], + "valid" + ], + [ + [ + 886, + 886 + ], + "mapped", + [ + 887 + ] + ], + [ + [ + 887, + 887 + ], + "valid" + ], + [ + [ + 888, + 889 + ], + "disallowed" + ], + [ + [ + 890, + 890 + ], + "disallowed_STD3_mapped", + [ + 32, + 953 + ] + ], + [ + [ + 891, + 893 + ], + "valid" + ], + [ + [ + 894, + 894 + ], + "disallowed_STD3_mapped", + [ + 59 + ] + ], + [ + [ + 895, + 895 + ], + "mapped", + [ + 1011 + ] + ], + [ + [ + 896, + 899 + ], + "disallowed" + ], + [ + [ + 900, + 900 + ], + "disallowed_STD3_mapped", + [ + 32, + 769 + ] + ], + [ + [ + 901, + 901 + ], + "disallowed_STD3_mapped", + [ + 32, + 776, + 769 + ] + ], + [ + [ + 902, + 902 + ], + "mapped", + [ + 940 + ] + ], + [ + [ + 903, + 903 + ], + "mapped", + [ + 183 + ] + ], + [ + [ + 904, + 904 + ], + "mapped", + [ + 941 + ] + ], + [ + [ + 905, + 905 + ], + "mapped", + [ + 942 + ] + ], + [ + [ + 906, + 906 + ], + "mapped", + [ + 943 + ] + ], + [ + [ + 907, + 907 + ], + "disallowed" + ], + [ + [ + 908, + 908 + ], + "mapped", + [ + 972 + ] + ], + [ + [ + 909, + 909 + ], + "disallowed" + ], + [ + [ + 910, + 910 + ], + "mapped", + [ + 973 + ] + ], + [ + [ + 911, + 911 + ], + "mapped", + [ + 974 + ] + ], + [ + [ + 912, + 912 + ], + "valid" + ], + [ + [ + 913, + 913 + ], + "mapped", + [ + 945 + ] + ], + [ + [ + 914, + 914 + ], + "mapped", + [ + 946 + ] + ], + [ + [ + 915, + 915 + ], + "mapped", + [ + 947 + ] + ], + [ + [ + 916, + 916 + ], + "mapped", + [ + 948 + ] + ], + [ + [ + 917, + 917 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 918, + 918 + ], + "mapped", + [ + 950 + ] + ], + [ + [ + 919, + 919 + ], + "mapped", + [ + 951 + ] + ], + [ + [ + 920, + 920 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 921, + 921 + ], + "mapped", + [ + 953 + ] + ], + [ + [ + 922, + 922 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 923, + 923 + ], + "mapped", + [ + 955 + ] + ], + [ + [ + 924, + 924 + ], + "mapped", + [ + 956 + ] + ], + [ + [ + 925, + 925 + ], + "mapped", + [ + 957 + ] + ], + [ + [ + 926, + 926 + ], + "mapped", + [ + 958 + ] + ], + [ + [ + 927, + 927 + ], + "mapped", + [ + 959 + ] + ], + [ + [ + 928, + 928 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 929, + 929 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 930, + 930 + ], + "disallowed" + ], + [ + [ + 931, + 931 + ], + "mapped", + [ + 963 + ] + ], + [ + [ + 932, + 932 + ], + "mapped", + [ + 964 + ] + ], + [ + [ + 933, + 933 + ], + "mapped", + [ + 965 + ] + ], + [ + [ + 934, + 934 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 935, + 935 + ], + "mapped", + [ + 967 + ] + ], + [ + [ + 936, + 936 + ], + "mapped", + [ + 968 + ] + ], + [ + [ + 937, + 937 + ], + "mapped", + [ + 969 + ] + ], + [ + [ + 938, + 938 + ], + "mapped", + [ + 970 + ] + ], + [ + [ + 939, + 939 + ], + "mapped", + [ + 971 + ] + ], + [ + [ + 940, + 961 + ], + "valid" + ], + [ + [ + 962, + 962 + ], + "deviation", + [ + 963 + ] + ], + [ + [ + 963, + 974 + ], + "valid" + ], + [ + [ + 975, + 975 + ], + "mapped", + [ + 983 + ] + ], + [ + [ + 976, + 976 + ], + "mapped", + [ + 946 + ] + ], + [ + [ + 977, + 977 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 978, + 978 + ], + "mapped", + [ + 965 + ] + ], + [ + [ + 979, + 979 + ], + "mapped", + [ + 973 + ] + ], + [ + [ + 980, + 980 + ], + "mapped", + [ + 971 + ] + ], + [ + [ + 981, + 981 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 982, + 982 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 983, + 983 + ], + "valid" + ], + [ + [ + 984, + 984 + ], + "mapped", + [ + 985 + ] + ], + [ + [ + 985, + 985 + ], + "valid" + ], + [ + [ + 986, + 986 + ], + "mapped", + [ + 987 + ] + ], + [ + [ + 987, + 987 + ], + "valid" + ], + [ + [ + 988, + 988 + ], + "mapped", + [ + 989 + ] + ], + [ + [ + 989, + 989 + ], + "valid" + ], + [ + [ + 990, + 990 + ], + "mapped", + [ + 991 + ] + ], + [ + [ + 991, + 991 + ], + "valid" + ], + [ + [ + 992, + 992 + ], + "mapped", + [ + 993 + ] + ], + [ + [ + 993, + 993 + ], + "valid" + ], + [ + [ + 994, + 994 + ], + "mapped", + [ + 995 + ] + ], + [ + [ + 995, + 995 + ], + "valid" + ], + [ + [ + 996, + 996 + ], + "mapped", + [ + 997 + ] + ], + [ + [ + 997, + 997 + ], + "valid" + ], + [ + [ + 998, + 998 + ], + "mapped", + [ + 999 + ] + ], + [ + [ + 999, + 999 + ], + "valid" + ], + [ + [ + 1000, + 1000 + ], + "mapped", + [ + 1001 + ] + ], + [ + [ + 1001, + 1001 + ], + "valid" + ], + [ + [ + 1002, + 1002 + ], + "mapped", + [ + 1003 + ] + ], + [ + [ + 1003, + 1003 + ], + "valid" + ], + [ + [ + 1004, + 1004 + ], + "mapped", + [ + 1005 + ] + ], + [ + [ + 1005, + 1005 + ], + "valid" + ], + [ + [ + 1006, + 1006 + ], + "mapped", + [ + 1007 + ] + ], + [ + [ + 1007, + 1007 + ], + "valid" + ], + [ + [ + 1008, + 1008 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 1009, + 1009 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 1010, + 1010 + ], + "mapped", + [ + 963 + ] + ], + [ + [ + 1011, + 1011 + ], + "valid" + ], + [ + [ + 1012, + 1012 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 1013, + 1013 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 1014, + 1014 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1015, + 1015 + ], + "mapped", + [ + 1016 + ] + ], + [ + [ + 1016, + 1016 + ], + "valid" + ], + [ + [ + 1017, + 1017 + ], + "mapped", + [ + 963 + ] + ], + [ + [ + 1018, + 1018 + ], + "mapped", + [ + 1019 + ] + ], + [ + [ + 1019, + 1019 + ], + "valid" + ], + [ + [ + 1020, + 1020 + ], + "valid" + ], + [ + [ + 1021, + 1021 + ], + "mapped", + [ + 891 + ] + ], + [ + [ + 1022, + 1022 + ], + "mapped", + [ + 892 + ] + ], + [ + [ + 1023, + 1023 + ], + "mapped", + [ + 893 + ] + ], + [ + [ + 1024, + 1024 + ], + "mapped", + [ + 1104 + ] + ], + [ + [ + 1025, + 1025 + ], + "mapped", + [ + 1105 + ] + ], + [ + [ + 1026, + 1026 + ], + "mapped", + [ + 1106 + ] + ], + [ + [ + 1027, + 1027 + ], + "mapped", + [ + 1107 + ] + ], + [ + [ + 1028, + 1028 + ], + "mapped", + [ + 1108 + ] + ], + [ + [ + 1029, + 1029 + ], + "mapped", + [ + 1109 + ] + ], + [ + [ + 1030, + 1030 + ], + "mapped", + [ + 1110 + ] + ], + [ + [ + 1031, + 1031 + ], + "mapped", + [ + 1111 + ] + ], + [ + [ + 1032, + 1032 + ], + "mapped", + [ + 1112 + ] + ], + [ + [ + 1033, + 1033 + ], + "mapped", + [ + 1113 + ] + ], + [ + [ + 1034, + 1034 + ], + "mapped", + [ + 1114 + ] + ], + [ + [ + 1035, + 1035 + ], + "mapped", + [ + 1115 + ] + ], + [ + [ + 1036, + 1036 + ], + "mapped", + [ + 1116 + ] + ], + [ + [ + 1037, + 1037 + ], + "mapped", + [ + 1117 + ] + ], + [ + [ + 1038, + 1038 + ], + "mapped", + [ + 1118 + ] + ], + [ + [ + 1039, + 1039 + ], + "mapped", + [ + 1119 + ] + ], + [ + [ + 1040, + 1040 + ], + "mapped", + [ + 1072 + ] + ], + [ + [ + 1041, + 1041 + ], + "mapped", + [ + 1073 + ] + ], + [ + [ + 1042, + 1042 + ], + "mapped", + [ + 1074 + ] + ], + [ + [ + 1043, + 1043 + ], + "mapped", + [ + 1075 + ] + ], + [ + [ + 1044, + 1044 + ], + "mapped", + [ + 1076 + ] + ], + [ + [ + 1045, + 1045 + ], + "mapped", + [ + 1077 + ] + ], + [ + [ + 1046, + 1046 + ], + "mapped", + [ + 1078 + ] + ], + [ + [ + 1047, + 1047 + ], + "mapped", + [ + 1079 + ] + ], + [ + [ + 1048, + 1048 + ], + "mapped", + [ + 1080 + ] + ], + [ + [ + 1049, + 1049 + ], + "mapped", + [ + 1081 + ] + ], + [ + [ + 1050, + 1050 + ], + "mapped", + [ + 1082 + ] + ], + [ + [ + 1051, + 1051 + ], + "mapped", + [ + 1083 + ] + ], + [ + [ + 1052, + 1052 + ], + "mapped", + [ + 1084 + ] + ], + [ + [ + 1053, + 1053 + ], + "mapped", + [ + 1085 + ] + ], + [ + [ + 1054, + 1054 + ], + "mapped", + [ + 1086 + ] + ], + [ + [ + 1055, + 1055 + ], + "mapped", + [ + 1087 + ] + ], + [ + [ + 1056, + 1056 + ], + "mapped", + [ + 1088 + ] + ], + [ + [ + 1057, + 1057 + ], + "mapped", + [ + 1089 + ] + ], + [ + [ + 1058, + 1058 + ], + "mapped", + [ + 1090 + ] + ], + [ + [ + 1059, + 1059 + ], + "mapped", + [ + 1091 + ] + ], + [ + [ + 1060, + 1060 + ], + "mapped", + [ + 1092 + ] + ], + [ + [ + 1061, + 1061 + ], + "mapped", + [ + 1093 + ] + ], + [ + [ + 1062, + 1062 + ], + "mapped", + [ + 1094 + ] + ], + [ + [ + 1063, + 1063 + ], + "mapped", + [ + 1095 + ] + ], + [ + [ + 1064, + 1064 + ], + "mapped", + [ + 1096 + ] + ], + [ + [ + 1065, + 1065 + ], + "mapped", + [ + 1097 + ] + ], + [ + [ + 1066, + 1066 + ], + "mapped", + [ + 1098 + ] + ], + [ + [ + 1067, + 1067 + ], + "mapped", + [ + 1099 + ] + ], + [ + [ + 1068, + 1068 + ], + "mapped", + [ + 1100 + ] + ], + [ + [ + 1069, + 1069 + ], + "mapped", + [ + 1101 + ] + ], + [ + [ + 1070, + 1070 + ], + "mapped", + [ + 1102 + ] + ], + [ + [ + 1071, + 1071 + ], + "mapped", + [ + 1103 + ] + ], + [ + [ + 1072, + 1103 + ], + "valid" + ], + [ + [ + 1104, + 1104 + ], + "valid" + ], + [ + [ + 1105, + 1116 + ], + "valid" + ], + [ + [ + 1117, + 1117 + ], + "valid" + ], + [ + [ + 1118, + 1119 + ], + "valid" + ], + [ + [ + 1120, + 1120 + ], + "mapped", + [ + 1121 + ] + ], + [ + [ + 1121, + 1121 + ], + "valid" + ], + [ + [ + 1122, + 1122 + ], + "mapped", + [ + 1123 + ] + ], + [ + [ + 1123, + 1123 + ], + "valid" + ], + [ + [ + 1124, + 1124 + ], + "mapped", + [ + 1125 + ] + ], + [ + [ + 1125, + 1125 + ], + "valid" + ], + [ + [ + 1126, + 1126 + ], + "mapped", + [ + 1127 + ] + ], + [ + [ + 1127, + 1127 + ], + "valid" + ], + [ + [ + 1128, + 1128 + ], + "mapped", + [ + 1129 + ] + ], + [ + [ + 1129, + 1129 + ], + "valid" + ], + [ + [ + 1130, + 1130 + ], + "mapped", + [ + 1131 + ] + ], + [ + [ + 1131, + 1131 + ], + "valid" + ], + [ + [ + 1132, + 1132 + ], + "mapped", + [ + 1133 + ] + ], + [ + [ + 1133, + 1133 + ], + "valid" + ], + [ + [ + 1134, + 1134 + ], + "mapped", + [ + 1135 + ] + ], + [ + [ + 1135, + 1135 + ], + "valid" + ], + [ + [ + 1136, + 1136 + ], + "mapped", + [ + 1137 + ] + ], + [ + [ + 1137, + 1137 + ], + "valid" + ], + [ + [ + 1138, + 1138 + ], + "mapped", + [ + 1139 + ] + ], + [ + [ + 1139, + 1139 + ], + "valid" + ], + [ + [ + 1140, + 1140 + ], + "mapped", + [ + 1141 + ] + ], + [ + [ + 1141, + 1141 + ], + "valid" + ], + [ + [ + 1142, + 1142 + ], + "mapped", + [ + 1143 + ] + ], + [ + [ + 1143, + 1143 + ], + "valid" + ], + [ + [ + 1144, + 1144 + ], + "mapped", + [ + 1145 + ] + ], + [ + [ + 1145, + 1145 + ], + "valid" + ], + [ + [ + 1146, + 1146 + ], + "mapped", + [ + 1147 + ] + ], + [ + [ + 1147, + 1147 + ], + "valid" + ], + [ + [ + 1148, + 1148 + ], + "mapped", + [ + 1149 + ] + ], + [ + [ + 1149, + 1149 + ], + "valid" + ], + [ + [ + 1150, + 1150 + ], + "mapped", + [ + 1151 + ] + ], + [ + [ + 1151, + 1151 + ], + "valid" + ], + [ + [ + 1152, + 1152 + ], + "mapped", + [ + 1153 + ] + ], + [ + [ + 1153, + 1153 + ], + "valid" + ], + [ + [ + 1154, + 1154 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1155, + 1158 + ], + "valid" + ], + [ + [ + 1159, + 1159 + ], + "valid" + ], + [ + [ + 1160, + 1161 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1162, + 1162 + ], + "mapped", + [ + 1163 + ] + ], + [ + [ + 1163, + 1163 + ], + "valid" + ], + [ + [ + 1164, + 1164 + ], + "mapped", + [ + 1165 + ] + ], + [ + [ + 1165, + 1165 + ], + "valid" + ], + [ + [ + 1166, + 1166 + ], + "mapped", + [ + 1167 + ] + ], + [ + [ + 1167, + 1167 + ], + "valid" + ], + [ + [ + 1168, + 1168 + ], + "mapped", + [ + 1169 + ] + ], + [ + [ + 1169, + 1169 + ], + "valid" + ], + [ + [ + 1170, + 1170 + ], + "mapped", + [ + 1171 + ] + ], + [ + [ + 1171, + 1171 + ], + "valid" + ], + [ + [ + 1172, + 1172 + ], + "mapped", + [ + 1173 + ] + ], + [ + [ + 1173, + 1173 + ], + "valid" + ], + [ + [ + 1174, + 1174 + ], + "mapped", + [ + 1175 + ] + ], + [ + [ + 1175, + 1175 + ], + "valid" + ], + [ + [ + 1176, + 1176 + ], + "mapped", + [ + 1177 + ] + ], + [ + [ + 1177, + 1177 + ], + "valid" + ], + [ + [ + 1178, + 1178 + ], + "mapped", + [ + 1179 + ] + ], + [ + [ + 1179, + 1179 + ], + "valid" + ], + [ + [ + 1180, + 1180 + ], + "mapped", + [ + 1181 + ] + ], + [ + [ + 1181, + 1181 + ], + "valid" + ], + [ + [ + 1182, + 1182 + ], + "mapped", + [ + 1183 + ] + ], + [ + [ + 1183, + 1183 + ], + "valid" + ], + [ + [ + 1184, + 1184 + ], + "mapped", + [ + 1185 + ] + ], + [ + [ + 1185, + 1185 + ], + "valid" + ], + [ + [ + 1186, + 1186 + ], + "mapped", + [ + 1187 + ] + ], + [ + [ + 1187, + 1187 + ], + "valid" + ], + [ + [ + 1188, + 1188 + ], + "mapped", + [ + 1189 + ] + ], + [ + [ + 1189, + 1189 + ], + "valid" + ], + [ + [ + 1190, + 1190 + ], + "mapped", + [ + 1191 + ] + ], + [ + [ + 1191, + 1191 + ], + "valid" + ], + [ + [ + 1192, + 1192 + ], + "mapped", + [ + 1193 + ] + ], + [ + [ + 1193, + 1193 + ], + "valid" + ], + [ + [ + 1194, + 1194 + ], + "mapped", + [ + 1195 + ] + ], + [ + [ + 1195, + 1195 + ], + "valid" + ], + [ + [ + 1196, + 1196 + ], + "mapped", + [ + 1197 + ] + ], + [ + [ + 1197, + 1197 + ], + "valid" + ], + [ + [ + 1198, + 1198 + ], + "mapped", + [ + 1199 + ] + ], + [ + [ + 1199, + 1199 + ], + "valid" + ], + [ + [ + 1200, + 1200 + ], + "mapped", + [ + 1201 + ] + ], + [ + [ + 1201, + 1201 + ], + "valid" + ], + [ + [ + 1202, + 1202 + ], + "mapped", + [ + 1203 + ] + ], + [ + [ + 1203, + 1203 + ], + "valid" + ], + [ + [ + 1204, + 1204 + ], + "mapped", + [ + 1205 + ] + ], + [ + [ + 1205, + 1205 + ], + "valid" + ], + [ + [ + 1206, + 1206 + ], + "mapped", + [ + 1207 + ] + ], + [ + [ + 1207, + 1207 + ], + "valid" + ], + [ + [ + 1208, + 1208 + ], + "mapped", + [ + 1209 + ] + ], + [ + [ + 1209, + 1209 + ], + "valid" + ], + [ + [ + 1210, + 1210 + ], + "mapped", + [ + 1211 + ] + ], + [ + [ + 1211, + 1211 + ], + "valid" + ], + [ + [ + 1212, + 1212 + ], + "mapped", + [ + 1213 + ] + ], + [ + [ + 1213, + 1213 + ], + "valid" + ], + [ + [ + 1214, + 1214 + ], + "mapped", + [ + 1215 + ] + ], + [ + [ + 1215, + 1215 + ], + "valid" + ], + [ + [ + 1216, + 1216 + ], + "disallowed" + ], + [ + [ + 1217, + 1217 + ], + "mapped", + [ + 1218 + ] + ], + [ + [ + 1218, + 1218 + ], + "valid" + ], + [ + [ + 1219, + 1219 + ], + "mapped", + [ + 1220 + ] + ], + [ + [ + 1220, + 1220 + ], + "valid" + ], + [ + [ + 1221, + 1221 + ], + "mapped", + [ + 1222 + ] + ], + [ + [ + 1222, + 1222 + ], + "valid" + ], + [ + [ + 1223, + 1223 + ], + "mapped", + [ + 1224 + ] + ], + [ + [ + 1224, + 1224 + ], + "valid" + ], + [ + [ + 1225, + 1225 + ], + "mapped", + [ + 1226 + ] + ], + [ + [ + 1226, + 1226 + ], + "valid" + ], + [ + [ + 1227, + 1227 + ], + "mapped", + [ + 1228 + ] + ], + [ + [ + 1228, + 1228 + ], + "valid" + ], + [ + [ + 1229, + 1229 + ], + "mapped", + [ + 1230 + ] + ], + [ + [ + 1230, + 1230 + ], + "valid" + ], + [ + [ + 1231, + 1231 + ], + "valid" + ], + [ + [ + 1232, + 1232 + ], + "mapped", + [ + 1233 + ] + ], + [ + [ + 1233, + 1233 + ], + "valid" + ], + [ + [ + 1234, + 1234 + ], + "mapped", + [ + 1235 + ] + ], + [ + [ + 1235, + 1235 + ], + "valid" + ], + [ + [ + 1236, + 1236 + ], + "mapped", + [ + 1237 + ] + ], + [ + [ + 1237, + 1237 + ], + "valid" + ], + [ + [ + 1238, + 1238 + ], + "mapped", + [ + 1239 + ] + ], + [ + [ + 1239, + 1239 + ], + "valid" + ], + [ + [ + 1240, + 1240 + ], + "mapped", + [ + 1241 + ] + ], + [ + [ + 1241, + 1241 + ], + "valid" + ], + [ + [ + 1242, + 1242 + ], + "mapped", + [ + 1243 + ] + ], + [ + [ + 1243, + 1243 + ], + "valid" + ], + [ + [ + 1244, + 1244 + ], + "mapped", + [ + 1245 + ] + ], + [ + [ + 1245, + 1245 + ], + "valid" + ], + [ + [ + 1246, + 1246 + ], + "mapped", + [ + 1247 + ] + ], + [ + [ + 1247, + 1247 + ], + "valid" + ], + [ + [ + 1248, + 1248 + ], + "mapped", + [ + 1249 + ] + ], + [ + [ + 1249, + 1249 + ], + "valid" + ], + [ + [ + 1250, + 1250 + ], + "mapped", + [ + 1251 + ] + ], + [ + [ + 1251, + 1251 + ], + "valid" + ], + [ + [ + 1252, + 1252 + ], + "mapped", + [ + 1253 + ] + ], + [ + [ + 1253, + 1253 + ], + "valid" + ], + [ + [ + 1254, + 1254 + ], + "mapped", + [ + 1255 + ] + ], + [ + [ + 1255, + 1255 + ], + "valid" + ], + [ + [ + 1256, + 1256 + ], + "mapped", + [ + 1257 + ] + ], + [ + [ + 1257, + 1257 + ], + "valid" + ], + [ + [ + 1258, + 1258 + ], + "mapped", + [ + 1259 + ] + ], + [ + [ + 1259, + 1259 + ], + "valid" + ], + [ + [ + 1260, + 1260 + ], + "mapped", + [ + 1261 + ] + ], + [ + [ + 1261, + 1261 + ], + "valid" + ], + [ + [ + 1262, + 1262 + ], + "mapped", + [ + 1263 + ] + ], + [ + [ + 1263, + 1263 + ], + "valid" + ], + [ + [ + 1264, + 1264 + ], + "mapped", + [ + 1265 + ] + ], + [ + [ + 1265, + 1265 + ], + "valid" + ], + [ + [ + 1266, + 1266 + ], + "mapped", + [ + 1267 + ] + ], + [ + [ + 1267, + 1267 + ], + "valid" + ], + [ + [ + 1268, + 1268 + ], + "mapped", + [ + 1269 + ] + ], + [ + [ + 1269, + 1269 + ], + "valid" + ], + [ + [ + 1270, + 1270 + ], + "mapped", + [ + 1271 + ] + ], + [ + [ + 1271, + 1271 + ], + "valid" + ], + [ + [ + 1272, + 1272 + ], + "mapped", + [ + 1273 + ] + ], + [ + [ + 1273, + 1273 + ], + "valid" + ], + [ + [ + 1274, + 1274 + ], + "mapped", + [ + 1275 + ] + ], + [ + [ + 1275, + 1275 + ], + "valid" + ], + [ + [ + 1276, + 1276 + ], + "mapped", + [ + 1277 + ] + ], + [ + [ + 1277, + 1277 + ], + "valid" + ], + [ + [ + 1278, + 1278 + ], + "mapped", + [ + 1279 + ] + ], + [ + [ + 1279, + 1279 + ], + "valid" + ], + [ + [ + 1280, + 1280 + ], + "mapped", + [ + 1281 + ] + ], + [ + [ + 1281, + 1281 + ], + "valid" + ], + [ + [ + 1282, + 1282 + ], + "mapped", + [ + 1283 + ] + ], + [ + [ + 1283, + 1283 + ], + "valid" + ], + [ + [ + 1284, + 1284 + ], + "mapped", + [ + 1285 + ] + ], + [ + [ + 1285, + 1285 + ], + "valid" + ], + [ + [ + 1286, + 1286 + ], + "mapped", + [ + 1287 + ] + ], + [ + [ + 1287, + 1287 + ], + "valid" + ], + [ + [ + 1288, + 1288 + ], + "mapped", + [ + 1289 + ] + ], + [ + [ + 1289, + 1289 + ], + "valid" + ], + [ + [ + 1290, + 1290 + ], + "mapped", + [ + 1291 + ] + ], + [ + [ + 1291, + 1291 + ], + "valid" + ], + [ + [ + 1292, + 1292 + ], + "mapped", + [ + 1293 + ] + ], + [ + [ + 1293, + 1293 + ], + "valid" + ], + [ + [ + 1294, + 1294 + ], + "mapped", + [ + 1295 + ] + ], + [ + [ + 1295, + 1295 + ], + "valid" + ], + [ + [ + 1296, + 1296 + ], + "mapped", + [ + 1297 + ] + ], + [ + [ + 1297, + 1297 + ], + "valid" + ], + [ + [ + 1298, + 1298 + ], + "mapped", + [ + 1299 + ] + ], + [ + [ + 1299, + 1299 + ], + "valid" + ], + [ + [ + 1300, + 1300 + ], + "mapped", + [ + 1301 + ] + ], + [ + [ + 1301, + 1301 + ], + "valid" + ], + [ + [ + 1302, + 1302 + ], + "mapped", + [ + 1303 + ] + ], + [ + [ + 1303, + 1303 + ], + "valid" + ], + [ + [ + 1304, + 1304 + ], + "mapped", + [ + 1305 + ] + ], + [ + [ + 1305, + 1305 + ], + "valid" + ], + [ + [ + 1306, + 1306 + ], + "mapped", + [ + 1307 + ] + ], + [ + [ + 1307, + 1307 + ], + "valid" + ], + [ + [ + 1308, + 1308 + ], + "mapped", + [ + 1309 + ] + ], + [ + [ + 1309, + 1309 + ], + "valid" + ], + [ + [ + 1310, + 1310 + ], + "mapped", + [ + 1311 + ] + ], + [ + [ + 1311, + 1311 + ], + "valid" + ], + [ + [ + 1312, + 1312 + ], + "mapped", + [ + 1313 + ] + ], + [ + [ + 1313, + 1313 + ], + "valid" + ], + [ + [ + 1314, + 1314 + ], + "mapped", + [ + 1315 + ] + ], + [ + [ + 1315, + 1315 + ], + "valid" + ], + [ + [ + 1316, + 1316 + ], + "mapped", + [ + 1317 + ] + ], + [ + [ + 1317, + 1317 + ], + "valid" + ], + [ + [ + 1318, + 1318 + ], + "mapped", + [ + 1319 + ] + ], + [ + [ + 1319, + 1319 + ], + "valid" + ], + [ + [ + 1320, + 1320 + ], + "mapped", + [ + 1321 + ] + ], + [ + [ + 1321, + 1321 + ], + "valid" + ], + [ + [ + 1322, + 1322 + ], + "mapped", + [ + 1323 + ] + ], + [ + [ + 1323, + 1323 + ], + "valid" + ], + [ + [ + 1324, + 1324 + ], + "mapped", + [ + 1325 + ] + ], + [ + [ + 1325, + 1325 + ], + "valid" + ], + [ + [ + 1326, + 1326 + ], + "mapped", + [ + 1327 + ] + ], + [ + [ + 1327, + 1327 + ], + "valid" + ], + [ + [ + 1328, + 1328 + ], + "disallowed" + ], + [ + [ + 1329, + 1329 + ], + "mapped", + [ + 1377 + ] + ], + [ + [ + 1330, + 1330 + ], + "mapped", + [ + 1378 + ] + ], + [ + [ + 1331, + 1331 + ], + "mapped", + [ + 1379 + ] + ], + [ + [ + 1332, + 1332 + ], + "mapped", + [ + 1380 + ] + ], + [ + [ + 1333, + 1333 + ], + "mapped", + [ + 1381 + ] + ], + [ + [ + 1334, + 1334 + ], + "mapped", + [ + 1382 + ] + ], + [ + [ + 1335, + 1335 + ], + "mapped", + [ + 1383 + ] + ], + [ + [ + 1336, + 1336 + ], + "mapped", + [ + 1384 + ] + ], + [ + [ + 1337, + 1337 + ], + "mapped", + [ + 1385 + ] + ], + [ + [ + 1338, + 1338 + ], + "mapped", + [ + 1386 + ] + ], + [ + [ + 1339, + 1339 + ], + "mapped", + [ + 1387 + ] + ], + [ + [ + 1340, + 1340 + ], + "mapped", + [ + 1388 + ] + ], + [ + [ + 1341, + 1341 + ], + "mapped", + [ + 1389 + ] + ], + [ + [ + 1342, + 1342 + ], + "mapped", + [ + 1390 + ] + ], + [ + [ + 1343, + 1343 + ], + "mapped", + [ + 1391 + ] + ], + [ + [ + 1344, + 1344 + ], + "mapped", + [ + 1392 + ] + ], + [ + [ + 1345, + 1345 + ], + "mapped", + [ + 1393 + ] + ], + [ + [ + 1346, + 1346 + ], + "mapped", + [ + 1394 + ] + ], + [ + [ + 1347, + 1347 + ], + "mapped", + [ + 1395 + ] + ], + [ + [ + 1348, + 1348 + ], + "mapped", + [ + 1396 + ] + ], + [ + [ + 1349, + 1349 + ], + "mapped", + [ + 1397 + ] + ], + [ + [ + 1350, + 1350 + ], + "mapped", + [ + 1398 + ] + ], + [ + [ + 1351, + 1351 + ], + "mapped", + [ + 1399 + ] + ], + [ + [ + 1352, + 1352 + ], + "mapped", + [ + 1400 + ] + ], + [ + [ + 1353, + 1353 + ], + "mapped", + [ + 1401 + ] + ], + [ + [ + 1354, + 1354 + ], + "mapped", + [ + 1402 + ] + ], + [ + [ + 1355, + 1355 + ], + "mapped", + [ + 1403 + ] + ], + [ + [ + 1356, + 1356 + ], + "mapped", + [ + 1404 + ] + ], + [ + [ + 1357, + 1357 + ], + "mapped", + [ + 1405 + ] + ], + [ + [ + 1358, + 1358 + ], + "mapped", + [ + 1406 + ] + ], + [ + [ + 1359, + 1359 + ], + "mapped", + [ + 1407 + ] + ], + [ + [ + 1360, + 1360 + ], + "mapped", + [ + 1408 + ] + ], + [ + [ + 1361, + 1361 + ], + "mapped", + [ + 1409 + ] + ], + [ + [ + 1362, + 1362 + ], + "mapped", + [ + 1410 + ] + ], + [ + [ + 1363, + 1363 + ], + "mapped", + [ + 1411 + ] + ], + [ + [ + 1364, + 1364 + ], + "mapped", + [ + 1412 + ] + ], + [ + [ + 1365, + 1365 + ], + "mapped", + [ + 1413 + ] + ], + [ + [ + 1366, + 1366 + ], + "mapped", + [ + 1414 + ] + ], + [ + [ + 1367, + 1368 + ], + "disallowed" + ], + [ + [ + 1369, + 1369 + ], + "valid" + ], + [ + [ + 1370, + 1375 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1376, + 1376 + ], + "disallowed" + ], + [ + [ + 1377, + 1414 + ], + "valid" + ], + [ + [ + 1415, + 1415 + ], + "mapped", + [ + 1381, + 1410 + ] + ], + [ + [ + 1416, + 1416 + ], + "disallowed" + ], + [ + [ + 1417, + 1417 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1418, + 1418 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1419, + 1420 + ], + "disallowed" + ], + [ + [ + 1421, + 1422 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1423, + 1423 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1424, + 1424 + ], + "disallowed" + ], + [ + [ + 1425, + 1441 + ], + "valid" + ], + [ + [ + 1442, + 1442 + ], + "valid" + ], + [ + [ + 1443, + 1455 + ], + "valid" + ], + [ + [ + 1456, + 1465 + ], + "valid" + ], + [ + [ + 1466, + 1466 + ], + "valid" + ], + [ + [ + 1467, + 1469 + ], + "valid" + ], + [ + [ + 1470, + 1470 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1471, + 1471 + ], + "valid" + ], + [ + [ + 1472, + 1472 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1473, + 1474 + ], + "valid" + ], + [ + [ + 1475, + 1475 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1476, + 1476 + ], + "valid" + ], + [ + [ + 1477, + 1477 + ], + "valid" + ], + [ + [ + 1478, + 1478 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1479, + 1479 + ], + "valid" + ], + [ + [ + 1480, + 1487 + ], + "disallowed" + ], + [ + [ + 1488, + 1514 + ], + "valid" + ], + [ + [ + 1515, + 1519 + ], + "disallowed" + ], + [ + [ + 1520, + 1524 + ], + "valid" + ], + [ + [ + 1525, + 1535 + ], + "disallowed" + ], + [ + [ + 1536, + 1539 + ], + "disallowed" + ], + [ + [ + 1540, + 1540 + ], + "disallowed" + ], + [ + [ + 1541, + 1541 + ], + "disallowed" + ], + [ + [ + 1542, + 1546 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1547, + 1547 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1548, + 1548 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1549, + 1551 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1552, + 1557 + ], + "valid" + ], + [ + [ + 1558, + 1562 + ], + "valid" + ], + [ + [ + 1563, + 1563 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1564, + 1564 + ], + "disallowed" + ], + [ + [ + 1565, + 1565 + ], + "disallowed" + ], + [ + [ + 1566, + 1566 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1567, + 1567 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1568, + 1568 + ], + "valid" + ], + [ + [ + 1569, + 1594 + ], + "valid" + ], + [ + [ + 1595, + 1599 + ], + "valid" + ], + [ + [ + 1600, + 1600 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1601, + 1618 + ], + "valid" + ], + [ + [ + 1619, + 1621 + ], + "valid" + ], + [ + [ + 1622, + 1624 + ], + "valid" + ], + [ + [ + 1625, + 1630 + ], + "valid" + ], + [ + [ + 1631, + 1631 + ], + "valid" + ], + [ + [ + 1632, + 1641 + ], + "valid" + ], + [ + [ + 1642, + 1645 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1646, + 1647 + ], + "valid" + ], + [ + [ + 1648, + 1652 + ], + "valid" + ], + [ + [ + 1653, + 1653 + ], + "mapped", + [ + 1575, + 1652 + ] + ], + [ + [ + 1654, + 1654 + ], + "mapped", + [ + 1608, + 1652 + ] + ], + [ + [ + 1655, + 1655 + ], + "mapped", + [ + 1735, + 1652 + ] + ], + [ + [ + 1656, + 1656 + ], + "mapped", + [ + 1610, + 1652 + ] + ], + [ + [ + 1657, + 1719 + ], + "valid" + ], + [ + [ + 1720, + 1721 + ], + "valid" + ], + [ + [ + 1722, + 1726 + ], + "valid" + ], + [ + [ + 1727, + 1727 + ], + "valid" + ], + [ + [ + 1728, + 1742 + ], + "valid" + ], + [ + [ + 1743, + 1743 + ], + "valid" + ], + [ + [ + 1744, + 1747 + ], + "valid" + ], + [ + [ + 1748, + 1748 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1749, + 1756 + ], + "valid" + ], + [ + [ + 1757, + 1757 + ], + "disallowed" + ], + [ + [ + 1758, + 1758 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1759, + 1768 + ], + "valid" + ], + [ + [ + 1769, + 1769 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1770, + 1773 + ], + "valid" + ], + [ + [ + 1774, + 1775 + ], + "valid" + ], + [ + [ + 1776, + 1785 + ], + "valid" + ], + [ + [ + 1786, + 1790 + ], + "valid" + ], + [ + [ + 1791, + 1791 + ], + "valid" + ], + [ + [ + 1792, + 1805 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 1806, + 1806 + ], + "disallowed" + ], + [ + [ + 1807, + 1807 + ], + "disallowed" + ], + [ + [ + 1808, + 1836 + ], + "valid" + ], + [ + [ + 1837, + 1839 + ], + "valid" + ], + [ + [ + 1840, + 1866 + ], + "valid" + ], + [ + [ + 1867, + 1868 + ], + "disallowed" + ], + [ + [ + 1869, + 1871 + ], + "valid" + ], + [ + [ + 1872, + 1901 + ], + "valid" + ], + [ + [ + 1902, + 1919 + ], + "valid" + ], + [ + [ + 1920, + 1968 + ], + "valid" + ], + [ + [ + 1969, + 1969 + ], + "valid" + ], + [ + [ + 1970, + 1983 + ], + "disallowed" + ], + [ + [ + 1984, + 2037 + ], + "valid" + ], + [ + [ + 2038, + 2042 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 2043, + 2047 + ], + "disallowed" + ], + [ + [ + 2048, + 2093 + ], + "valid" + ], + [ + [ + 2094, + 2095 + ], + "disallowed" + ], + [ + [ + 2096, + 2110 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 2111, + 2111 + ], + "disallowed" + ], + [ + [ + 2112, + 2139 + ], + "valid" + ], + [ + [ + 2140, + 2141 + ], + "disallowed" + ], + [ + [ + 2142, + 2142 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 2143, + 2207 + ], + "disallowed" + ], + [ + [ + 2208, + 2208 + ], + "valid" + ], + [ + [ + 2209, + 2209 + ], + "valid" + ], + [ + [ + 2210, + 2220 + ], + "valid" + ], + [ + [ + 2221, + 2226 + ], + "valid" + ], + [ + [ + 2227, + 2228 + ], + "valid" + ], + [ + [ + 2229, + 2274 + ], + "disallowed" + ], + [ + [ + 2275, + 2275 + ], + "valid" + ], + [ + [ + 2276, + 2302 + ], + "valid" + ], + [ + [ + 2303, + 2303 + ], + "valid" + ], + [ + [ + 2304, + 2304 + ], + "valid" + ], + [ + [ + 2305, + 2307 + ], + "valid" + ], + [ + [ + 2308, + 2308 + ], + "valid" + ], + [ + [ + 2309, + 2361 + ], + "valid" + ], + [ + [ + 2362, + 2363 + ], + "valid" + ], + [ + [ + 2364, + 2381 + ], + "valid" + ], + [ + [ + 2382, + 2382 + ], + "valid" + ], + [ + [ + 2383, + 2383 + ], + "valid" + ], + [ + [ + 2384, + 2388 + ], + "valid" + ], + [ + [ + 2389, + 2389 + ], + "valid" + ], + [ + [ + 2390, + 2391 + ], + "valid" + ], + [ + [ + 2392, + 2392 + ], + "mapped", + [ + 2325, + 2364 + ] + ], + [ + [ + 2393, + 2393 + ], + "mapped", + [ + 2326, + 2364 + ] + ], + [ + [ + 2394, + 2394 + ], + "mapped", + [ + 2327, + 2364 + ] + ], + [ + [ + 2395, + 2395 + ], + "mapped", + [ + 2332, + 2364 + ] + ], + [ + [ + 2396, + 2396 + ], + "mapped", + [ + 2337, + 2364 + ] + ], + [ + [ + 2397, + 2397 + ], + "mapped", + [ + 2338, + 2364 + ] + ], + [ + [ + 2398, + 2398 + ], + "mapped", + [ + 2347, + 2364 + ] + ], + [ + [ + 2399, + 2399 + ], + "mapped", + [ + 2351, + 2364 + ] + ], + [ + [ + 2400, + 2403 + ], + "valid" + ], + [ + [ + 2404, + 2405 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 2406, + 2415 + ], + "valid" + ], + [ + [ + 2416, + 2416 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 2417, + 2418 + ], + "valid" + ], + [ + [ + 2419, + 2423 + ], + "valid" + ], + [ + [ + 2424, + 2424 + ], + "valid" + ], + [ + [ + 2425, + 2426 + ], + "valid" + ], + [ + [ + 2427, + 2428 + ], + "valid" + ], + [ + [ + 2429, + 2429 + ], + "valid" + ], + [ + [ + 2430, + 2431 + ], + "valid" + ], + [ + [ + 2432, + 2432 + ], + "valid" + ], + [ + [ + 2433, + 2435 + ], + "valid" + ], + [ + [ + 2436, + 2436 + ], + "disallowed" + ], + [ + [ + 2437, + 2444 + ], + "valid" + ], + [ + [ + 2445, + 2446 + ], + "disallowed" + ], + [ + [ + 2447, + 2448 + ], + "valid" + ], + [ + [ + 2449, + 2450 + ], + "disallowed" + ], + [ + [ + 2451, + 2472 + ], + "valid" + ], + [ + [ + 2473, + 2473 + ], + "disallowed" + ], + [ + [ + 2474, + 2480 + ], + "valid" + ], + [ + [ + 2481, + 2481 + ], + "disallowed" + ], + [ + [ + 2482, + 2482 + ], + "valid" + ], + [ + [ + 2483, + 2485 + ], + "disallowed" + ], + [ + [ + 2486, + 2489 + ], + "valid" + ], + [ + [ + 2490, + 2491 + ], + "disallowed" + ], + [ + [ + 2492, + 2492 + ], + "valid" + ], + [ + [ + 2493, + 2493 + ], + "valid" + ], + [ + [ + 2494, + 2500 + ], + "valid" + ], + [ + [ + 2501, + 2502 + ], + "disallowed" + ], + [ + [ + 2503, + 2504 + ], + "valid" + ], + [ + [ + 2505, + 2506 + ], + "disallowed" + ], + [ + [ + 2507, + 2509 + ], + "valid" + ], + [ + [ + 2510, + 2510 + ], + "valid" + ], + [ + [ + 2511, + 2518 + ], + "disallowed" + ], + [ + [ + 2519, + 2519 + ], + "valid" + ], + [ + [ + 2520, + 2523 + ], + "disallowed" + ], + [ + [ + 2524, + 2524 + ], + "mapped", + [ + 2465, + 2492 + ] + ], + [ + [ + 2525, + 2525 + ], + "mapped", + [ + 2466, + 2492 + ] + ], + [ + [ + 2526, + 2526 + ], + "disallowed" + ], + [ + [ + 2527, + 2527 + ], + "mapped", + [ + 2479, + 2492 + ] + ], + [ + [ + 2528, + 2531 + ], + "valid" + ], + [ + [ + 2532, + 2533 + ], + "disallowed" + ], + [ + [ + 2534, + 2545 + ], + "valid" + ], + [ + [ + 2546, + 2554 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 2555, + 2555 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 2556, + 2560 + ], + "disallowed" + ], + [ + [ + 2561, + 2561 + ], + "valid" + ], + [ + [ + 2562, + 2562 + ], + "valid" + ], + [ + [ + 2563, + 2563 + ], + "valid" + ], + [ + [ + 2564, + 2564 + ], + "disallowed" + ], + [ + [ + 2565, + 2570 + ], + "valid" + ], + [ + [ + 2571, + 2574 + ], + "disallowed" + ], + [ + [ + 2575, + 2576 + ], + "valid" + ], + [ + [ + 2577, + 2578 + ], + "disallowed" + ], + [ + [ + 2579, + 2600 + ], + "valid" + ], + [ + [ + 2601, + 2601 + ], + "disallowed" + ], + [ + [ + 2602, + 2608 + ], + "valid" + ], + [ + [ + 2609, + 2609 + ], + "disallowed" + ], + [ + [ + 2610, + 2610 + ], + "valid" + ], + [ + [ + 2611, + 2611 + ], + "mapped", + [ + 2610, + 2620 + ] + ], + [ + [ + 2612, + 2612 + ], + "disallowed" + ], + [ + [ + 2613, + 2613 + ], + "valid" + ], + [ + [ + 2614, + 2614 + ], + "mapped", + [ + 2616, + 2620 + ] + ], + [ + [ + 2615, + 2615 + ], + "disallowed" + ], + [ + [ + 2616, + 2617 + ], + "valid" + ], + [ + [ + 2618, + 2619 + ], + "disallowed" + ], + [ + [ + 2620, + 2620 + ], + "valid" + ], + [ + [ + 2621, + 2621 + ], + "disallowed" + ], + [ + [ + 2622, + 2626 + ], + "valid" + ], + [ + [ + 2627, + 2630 + ], + "disallowed" + ], + [ + [ + 2631, + 2632 + ], + "valid" + ], + [ + [ + 2633, + 2634 + ], + "disallowed" + ], + [ + [ + 2635, + 2637 + ], + "valid" + ], + [ + [ + 2638, + 2640 + ], + "disallowed" + ], + [ + [ + 2641, + 2641 + ], + "valid" + ], + [ + [ + 2642, + 2648 + ], + "disallowed" + ], + [ + [ + 2649, + 2649 + ], + "mapped", + [ + 2582, + 2620 + ] + ], + [ + [ + 2650, + 2650 + ], + "mapped", + [ + 2583, + 2620 + ] + ], + [ + [ + 2651, + 2651 + ], + "mapped", + [ + 2588, + 2620 + ] + ], + [ + [ + 2652, + 2652 + ], + "valid" + ], + [ + [ + 2653, + 2653 + ], + "disallowed" + ], + [ + [ + 2654, + 2654 + ], + "mapped", + [ + 2603, + 2620 + ] + ], + [ + [ + 2655, + 2661 + ], + "disallowed" + ], + [ + [ + 2662, + 2676 + ], + "valid" + ], + [ + [ + 2677, + 2677 + ], + "valid" + ], + [ + [ + 2678, + 2688 + ], + "disallowed" + ], + [ + [ + 2689, + 2691 + ], + "valid" + ], + [ + [ + 2692, + 2692 + ], + "disallowed" + ], + [ + [ + 2693, + 2699 + ], + "valid" + ], + [ + [ + 2700, + 2700 + ], + "valid" + ], + [ + [ + 2701, + 2701 + ], + "valid" + ], + [ + [ + 2702, + 2702 + ], + "disallowed" + ], + [ + [ + 2703, + 2705 + ], + "valid" + ], + [ + [ + 2706, + 2706 + ], + "disallowed" + ], + [ + [ + 2707, + 2728 + ], + "valid" + ], + [ + [ + 2729, + 2729 + ], + "disallowed" + ], + [ + [ + 2730, + 2736 + ], + "valid" + ], + [ + [ + 2737, + 2737 + ], + "disallowed" + ], + [ + [ + 2738, + 2739 + ], + "valid" + ], + [ + [ + 2740, + 2740 + ], + "disallowed" + ], + [ + [ + 2741, + 2745 + ], + "valid" + ], + [ + [ + 2746, + 2747 + ], + "disallowed" + ], + [ + [ + 2748, + 2757 + ], + "valid" + ], + [ + [ + 2758, + 2758 + ], + "disallowed" + ], + [ + [ + 2759, + 2761 + ], + "valid" + ], + [ + [ + 2762, + 2762 + ], + "disallowed" + ], + [ + [ + 2763, + 2765 + ], + "valid" + ], + [ + [ + 2766, + 2767 + ], + "disallowed" + ], + [ + [ + 2768, + 2768 + ], + "valid" + ], + [ + [ + 2769, + 2783 + ], + "disallowed" + ], + [ + [ + 2784, + 2784 + ], + "valid" + ], + [ + [ + 2785, + 2787 + ], + "valid" + ], + [ + [ + 2788, + 2789 + ], + "disallowed" + ], + [ + [ + 2790, + 2799 + ], + "valid" + ], + [ + [ + 2800, + 2800 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 2801, + 2801 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 2802, + 2808 + ], + "disallowed" + ], + [ + [ + 2809, + 2809 + ], + "valid" + ], + [ + [ + 2810, + 2816 + ], + "disallowed" + ], + [ + [ + 2817, + 2819 + ], + "valid" + ], + [ + [ + 2820, + 2820 + ], + "disallowed" + ], + [ + [ + 2821, + 2828 + ], + "valid" + ], + [ + [ + 2829, + 2830 + ], + "disallowed" + ], + [ + [ + 2831, + 2832 + ], + "valid" + ], + [ + [ + 2833, + 2834 + ], + "disallowed" + ], + [ + [ + 2835, + 2856 + ], + "valid" + ], + [ + [ + 2857, + 2857 + ], + "disallowed" + ], + [ + [ + 2858, + 2864 + ], + "valid" + ], + [ + [ + 2865, + 2865 + ], + "disallowed" + ], + [ + [ + 2866, + 2867 + ], + "valid" + ], + [ + [ + 2868, + 2868 + ], + "disallowed" + ], + [ + [ + 2869, + 2869 + ], + "valid" + ], + [ + [ + 2870, + 2873 + ], + "valid" + ], + [ + [ + 2874, + 2875 + ], + "disallowed" + ], + [ + [ + 2876, + 2883 + ], + "valid" + ], + [ + [ + 2884, + 2884 + ], + "valid" + ], + [ + [ + 2885, + 2886 + ], + "disallowed" + ], + [ + [ + 2887, + 2888 + ], + "valid" + ], + [ + [ + 2889, + 2890 + ], + "disallowed" + ], + [ + [ + 2891, + 2893 + ], + "valid" + ], + [ + [ + 2894, + 2901 + ], + "disallowed" + ], + [ + [ + 2902, + 2903 + ], + "valid" + ], + [ + [ + 2904, + 2907 + ], + "disallowed" + ], + [ + [ + 2908, + 2908 + ], + "mapped", + [ + 2849, + 2876 + ] + ], + [ + [ + 2909, + 2909 + ], + "mapped", + [ + 2850, + 2876 + ] + ], + [ + [ + 2910, + 2910 + ], + "disallowed" + ], + [ + [ + 2911, + 2913 + ], + "valid" + ], + [ + [ + 2914, + 2915 + ], + "valid" + ], + [ + [ + 2916, + 2917 + ], + "disallowed" + ], + [ + [ + 2918, + 2927 + ], + "valid" + ], + [ + [ + 2928, + 2928 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 2929, + 2929 + ], + "valid" + ], + [ + [ + 2930, + 2935 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 2936, + 2945 + ], + "disallowed" + ], + [ + [ + 2946, + 2947 + ], + "valid" + ], + [ + [ + 2948, + 2948 + ], + "disallowed" + ], + [ + [ + 2949, + 2954 + ], + "valid" + ], + [ + [ + 2955, + 2957 + ], + "disallowed" + ], + [ + [ + 2958, + 2960 + ], + "valid" + ], + [ + [ + 2961, + 2961 + ], + "disallowed" + ], + [ + [ + 2962, + 2965 + ], + "valid" + ], + [ + [ + 2966, + 2968 + ], + "disallowed" + ], + [ + [ + 2969, + 2970 + ], + "valid" + ], + [ + [ + 2971, + 2971 + ], + "disallowed" + ], + [ + [ + 2972, + 2972 + ], + "valid" + ], + [ + [ + 2973, + 2973 + ], + "disallowed" + ], + [ + [ + 2974, + 2975 + ], + "valid" + ], + [ + [ + 2976, + 2978 + ], + "disallowed" + ], + [ + [ + 2979, + 2980 + ], + "valid" + ], + [ + [ + 2981, + 2983 + ], + "disallowed" + ], + [ + [ + 2984, + 2986 + ], + "valid" + ], + [ + [ + 2987, + 2989 + ], + "disallowed" + ], + [ + [ + 2990, + 2997 + ], + "valid" + ], + [ + [ + 2998, + 2998 + ], + "valid" + ], + [ + [ + 2999, + 3001 + ], + "valid" + ], + [ + [ + 3002, + 3005 + ], + "disallowed" + ], + [ + [ + 3006, + 3010 + ], + "valid" + ], + [ + [ + 3011, + 3013 + ], + "disallowed" + ], + [ + [ + 3014, + 3016 + ], + "valid" + ], + [ + [ + 3017, + 3017 + ], + "disallowed" + ], + [ + [ + 3018, + 3021 + ], + "valid" + ], + [ + [ + 3022, + 3023 + ], + "disallowed" + ], + [ + [ + 3024, + 3024 + ], + "valid" + ], + [ + [ + 3025, + 3030 + ], + "disallowed" + ], + [ + [ + 3031, + 3031 + ], + "valid" + ], + [ + [ + 3032, + 3045 + ], + "disallowed" + ], + [ + [ + 3046, + 3046 + ], + "valid" + ], + [ + [ + 3047, + 3055 + ], + "valid" + ], + [ + [ + 3056, + 3058 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3059, + 3066 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3067, + 3071 + ], + "disallowed" + ], + [ + [ + 3072, + 3072 + ], + "valid" + ], + [ + [ + 3073, + 3075 + ], + "valid" + ], + [ + [ + 3076, + 3076 + ], + "disallowed" + ], + [ + [ + 3077, + 3084 + ], + "valid" + ], + [ + [ + 3085, + 3085 + ], + "disallowed" + ], + [ + [ + 3086, + 3088 + ], + "valid" + ], + [ + [ + 3089, + 3089 + ], + "disallowed" + ], + [ + [ + 3090, + 3112 + ], + "valid" + ], + [ + [ + 3113, + 3113 + ], + "disallowed" + ], + [ + [ + 3114, + 3123 + ], + "valid" + ], + [ + [ + 3124, + 3124 + ], + "valid" + ], + [ + [ + 3125, + 3129 + ], + "valid" + ], + [ + [ + 3130, + 3132 + ], + "disallowed" + ], + [ + [ + 3133, + 3133 + ], + "valid" + ], + [ + [ + 3134, + 3140 + ], + "valid" + ], + [ + [ + 3141, + 3141 + ], + "disallowed" + ], + [ + [ + 3142, + 3144 + ], + "valid" + ], + [ + [ + 3145, + 3145 + ], + "disallowed" + ], + [ + [ + 3146, + 3149 + ], + "valid" + ], + [ + [ + 3150, + 3156 + ], + "disallowed" + ], + [ + [ + 3157, + 3158 + ], + "valid" + ], + [ + [ + 3159, + 3159 + ], + "disallowed" + ], + [ + [ + 3160, + 3161 + ], + "valid" + ], + [ + [ + 3162, + 3162 + ], + "valid" + ], + [ + [ + 3163, + 3167 + ], + "disallowed" + ], + [ + [ + 3168, + 3169 + ], + "valid" + ], + [ + [ + 3170, + 3171 + ], + "valid" + ], + [ + [ + 3172, + 3173 + ], + "disallowed" + ], + [ + [ + 3174, + 3183 + ], + "valid" + ], + [ + [ + 3184, + 3191 + ], + "disallowed" + ], + [ + [ + 3192, + 3199 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3200, + 3200 + ], + "disallowed" + ], + [ + [ + 3201, + 3201 + ], + "valid" + ], + [ + [ + 3202, + 3203 + ], + "valid" + ], + [ + [ + 3204, + 3204 + ], + "disallowed" + ], + [ + [ + 3205, + 3212 + ], + "valid" + ], + [ + [ + 3213, + 3213 + ], + "disallowed" + ], + [ + [ + 3214, + 3216 + ], + "valid" + ], + [ + [ + 3217, + 3217 + ], + "disallowed" + ], + [ + [ + 3218, + 3240 + ], + "valid" + ], + [ + [ + 3241, + 3241 + ], + "disallowed" + ], + [ + [ + 3242, + 3251 + ], + "valid" + ], + [ + [ + 3252, + 3252 + ], + "disallowed" + ], + [ + [ + 3253, + 3257 + ], + "valid" + ], + [ + [ + 3258, + 3259 + ], + "disallowed" + ], + [ + [ + 3260, + 3261 + ], + "valid" + ], + [ + [ + 3262, + 3268 + ], + "valid" + ], + [ + [ + 3269, + 3269 + ], + "disallowed" + ], + [ + [ + 3270, + 3272 + ], + "valid" + ], + [ + [ + 3273, + 3273 + ], + "disallowed" + ], + [ + [ + 3274, + 3277 + ], + "valid" + ], + [ + [ + 3278, + 3284 + ], + "disallowed" + ], + [ + [ + 3285, + 3286 + ], + "valid" + ], + [ + [ + 3287, + 3293 + ], + "disallowed" + ], + [ + [ + 3294, + 3294 + ], + "valid" + ], + [ + [ + 3295, + 3295 + ], + "disallowed" + ], + [ + [ + 3296, + 3297 + ], + "valid" + ], + [ + [ + 3298, + 3299 + ], + "valid" + ], + [ + [ + 3300, + 3301 + ], + "disallowed" + ], + [ + [ + 3302, + 3311 + ], + "valid" + ], + [ + [ + 3312, + 3312 + ], + "disallowed" + ], + [ + [ + 3313, + 3314 + ], + "valid" + ], + [ + [ + 3315, + 3328 + ], + "disallowed" + ], + [ + [ + 3329, + 3329 + ], + "valid" + ], + [ + [ + 3330, + 3331 + ], + "valid" + ], + [ + [ + 3332, + 3332 + ], + "disallowed" + ], + [ + [ + 3333, + 3340 + ], + "valid" + ], + [ + [ + 3341, + 3341 + ], + "disallowed" + ], + [ + [ + 3342, + 3344 + ], + "valid" + ], + [ + [ + 3345, + 3345 + ], + "disallowed" + ], + [ + [ + 3346, + 3368 + ], + "valid" + ], + [ + [ + 3369, + 3369 + ], + "valid" + ], + [ + [ + 3370, + 3385 + ], + "valid" + ], + [ + [ + 3386, + 3386 + ], + "valid" + ], + [ + [ + 3387, + 3388 + ], + "disallowed" + ], + [ + [ + 3389, + 3389 + ], + "valid" + ], + [ + [ + 3390, + 3395 + ], + "valid" + ], + [ + [ + 3396, + 3396 + ], + "valid" + ], + [ + [ + 3397, + 3397 + ], + "disallowed" + ], + [ + [ + 3398, + 3400 + ], + "valid" + ], + [ + [ + 3401, + 3401 + ], + "disallowed" + ], + [ + [ + 3402, + 3405 + ], + "valid" + ], + [ + [ + 3406, + 3406 + ], + "valid" + ], + [ + [ + 3407, + 3414 + ], + "disallowed" + ], + [ + [ + 3415, + 3415 + ], + "valid" + ], + [ + [ + 3416, + 3422 + ], + "disallowed" + ], + [ + [ + 3423, + 3423 + ], + "valid" + ], + [ + [ + 3424, + 3425 + ], + "valid" + ], + [ + [ + 3426, + 3427 + ], + "valid" + ], + [ + [ + 3428, + 3429 + ], + "disallowed" + ], + [ + [ + 3430, + 3439 + ], + "valid" + ], + [ + [ + 3440, + 3445 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3446, + 3448 + ], + "disallowed" + ], + [ + [ + 3449, + 3449 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3450, + 3455 + ], + "valid" + ], + [ + [ + 3456, + 3457 + ], + "disallowed" + ], + [ + [ + 3458, + 3459 + ], + "valid" + ], + [ + [ + 3460, + 3460 + ], + "disallowed" + ], + [ + [ + 3461, + 3478 + ], + "valid" + ], + [ + [ + 3479, + 3481 + ], + "disallowed" + ], + [ + [ + 3482, + 3505 + ], + "valid" + ], + [ + [ + 3506, + 3506 + ], + "disallowed" + ], + [ + [ + 3507, + 3515 + ], + "valid" + ], + [ + [ + 3516, + 3516 + ], + "disallowed" + ], + [ + [ + 3517, + 3517 + ], + "valid" + ], + [ + [ + 3518, + 3519 + ], + "disallowed" + ], + [ + [ + 3520, + 3526 + ], + "valid" + ], + [ + [ + 3527, + 3529 + ], + "disallowed" + ], + [ + [ + 3530, + 3530 + ], + "valid" + ], + [ + [ + 3531, + 3534 + ], + "disallowed" + ], + [ + [ + 3535, + 3540 + ], + "valid" + ], + [ + [ + 3541, + 3541 + ], + "disallowed" + ], + [ + [ + 3542, + 3542 + ], + "valid" + ], + [ + [ + 3543, + 3543 + ], + "disallowed" + ], + [ + [ + 3544, + 3551 + ], + "valid" + ], + [ + [ + 3552, + 3557 + ], + "disallowed" + ], + [ + [ + 3558, + 3567 + ], + "valid" + ], + [ + [ + 3568, + 3569 + ], + "disallowed" + ], + [ + [ + 3570, + 3571 + ], + "valid" + ], + [ + [ + 3572, + 3572 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3573, + 3584 + ], + "disallowed" + ], + [ + [ + 3585, + 3634 + ], + "valid" + ], + [ + [ + 3635, + 3635 + ], + "mapped", + [ + 3661, + 3634 + ] + ], + [ + [ + 3636, + 3642 + ], + "valid" + ], + [ + [ + 3643, + 3646 + ], + "disallowed" + ], + [ + [ + 3647, + 3647 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3648, + 3662 + ], + "valid" + ], + [ + [ + 3663, + 3663 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3664, + 3673 + ], + "valid" + ], + [ + [ + 3674, + 3675 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3676, + 3712 + ], + "disallowed" + ], + [ + [ + 3713, + 3714 + ], + "valid" + ], + [ + [ + 3715, + 3715 + ], + "disallowed" + ], + [ + [ + 3716, + 3716 + ], + "valid" + ], + [ + [ + 3717, + 3718 + ], + "disallowed" + ], + [ + [ + 3719, + 3720 + ], + "valid" + ], + [ + [ + 3721, + 3721 + ], + "disallowed" + ], + [ + [ + 3722, + 3722 + ], + "valid" + ], + [ + [ + 3723, + 3724 + ], + "disallowed" + ], + [ + [ + 3725, + 3725 + ], + "valid" + ], + [ + [ + 3726, + 3731 + ], + "disallowed" + ], + [ + [ + 3732, + 3735 + ], + "valid" + ], + [ + [ + 3736, + 3736 + ], + "disallowed" + ], + [ + [ + 3737, + 3743 + ], + "valid" + ], + [ + [ + 3744, + 3744 + ], + "disallowed" + ], + [ + [ + 3745, + 3747 + ], + "valid" + ], + [ + [ + 3748, + 3748 + ], + "disallowed" + ], + [ + [ + 3749, + 3749 + ], + "valid" + ], + [ + [ + 3750, + 3750 + ], + "disallowed" + ], + [ + [ + 3751, + 3751 + ], + "valid" + ], + [ + [ + 3752, + 3753 + ], + "disallowed" + ], + [ + [ + 3754, + 3755 + ], + "valid" + ], + [ + [ + 3756, + 3756 + ], + "disallowed" + ], + [ + [ + 3757, + 3762 + ], + "valid" + ], + [ + [ + 3763, + 3763 + ], + "mapped", + [ + 3789, + 3762 + ] + ], + [ + [ + 3764, + 3769 + ], + "valid" + ], + [ + [ + 3770, + 3770 + ], + "disallowed" + ], + [ + [ + 3771, + 3773 + ], + "valid" + ], + [ + [ + 3774, + 3775 + ], + "disallowed" + ], + [ + [ + 3776, + 3780 + ], + "valid" + ], + [ + [ + 3781, + 3781 + ], + "disallowed" + ], + [ + [ + 3782, + 3782 + ], + "valid" + ], + [ + [ + 3783, + 3783 + ], + "disallowed" + ], + [ + [ + 3784, + 3789 + ], + "valid" + ], + [ + [ + 3790, + 3791 + ], + "disallowed" + ], + [ + [ + 3792, + 3801 + ], + "valid" + ], + [ + [ + 3802, + 3803 + ], + "disallowed" + ], + [ + [ + 3804, + 3804 + ], + "mapped", + [ + 3755, + 3737 + ] + ], + [ + [ + 3805, + 3805 + ], + "mapped", + [ + 3755, + 3745 + ] + ], + [ + [ + 3806, + 3807 + ], + "valid" + ], + [ + [ + 3808, + 3839 + ], + "disallowed" + ], + [ + [ + 3840, + 3840 + ], + "valid" + ], + [ + [ + 3841, + 3850 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3851, + 3851 + ], + "valid" + ], + [ + [ + 3852, + 3852 + ], + "mapped", + [ + 3851 + ] + ], + [ + [ + 3853, + 3863 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3864, + 3865 + ], + "valid" + ], + [ + [ + 3866, + 3871 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3872, + 3881 + ], + "valid" + ], + [ + [ + 3882, + 3892 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3893, + 3893 + ], + "valid" + ], + [ + [ + 3894, + 3894 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3895, + 3895 + ], + "valid" + ], + [ + [ + 3896, + 3896 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3897, + 3897 + ], + "valid" + ], + [ + [ + 3898, + 3901 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3902, + 3906 + ], + "valid" + ], + [ + [ + 3907, + 3907 + ], + "mapped", + [ + 3906, + 4023 + ] + ], + [ + [ + 3908, + 3911 + ], + "valid" + ], + [ + [ + 3912, + 3912 + ], + "disallowed" + ], + [ + [ + 3913, + 3916 + ], + "valid" + ], + [ + [ + 3917, + 3917 + ], + "mapped", + [ + 3916, + 4023 + ] + ], + [ + [ + 3918, + 3921 + ], + "valid" + ], + [ + [ + 3922, + 3922 + ], + "mapped", + [ + 3921, + 4023 + ] + ], + [ + [ + 3923, + 3926 + ], + "valid" + ], + [ + [ + 3927, + 3927 + ], + "mapped", + [ + 3926, + 4023 + ] + ], + [ + [ + 3928, + 3931 + ], + "valid" + ], + [ + [ + 3932, + 3932 + ], + "mapped", + [ + 3931, + 4023 + ] + ], + [ + [ + 3933, + 3944 + ], + "valid" + ], + [ + [ + 3945, + 3945 + ], + "mapped", + [ + 3904, + 4021 + ] + ], + [ + [ + 3946, + 3946 + ], + "valid" + ], + [ + [ + 3947, + 3948 + ], + "valid" + ], + [ + [ + 3949, + 3952 + ], + "disallowed" + ], + [ + [ + 3953, + 3954 + ], + "valid" + ], + [ + [ + 3955, + 3955 + ], + "mapped", + [ + 3953, + 3954 + ] + ], + [ + [ + 3956, + 3956 + ], + "valid" + ], + [ + [ + 3957, + 3957 + ], + "mapped", + [ + 3953, + 3956 + ] + ], + [ + [ + 3958, + 3958 + ], + "mapped", + [ + 4018, + 3968 + ] + ], + [ + [ + 3959, + 3959 + ], + "mapped", + [ + 4018, + 3953, + 3968 + ] + ], + [ + [ + 3960, + 3960 + ], + "mapped", + [ + 4019, + 3968 + ] + ], + [ + [ + 3961, + 3961 + ], + "mapped", + [ + 4019, + 3953, + 3968 + ] + ], + [ + [ + 3962, + 3968 + ], + "valid" + ], + [ + [ + 3969, + 3969 + ], + "mapped", + [ + 3953, + 3968 + ] + ], + [ + [ + 3970, + 3972 + ], + "valid" + ], + [ + [ + 3973, + 3973 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 3974, + 3979 + ], + "valid" + ], + [ + [ + 3980, + 3983 + ], + "valid" + ], + [ + [ + 3984, + 3986 + ], + "valid" + ], + [ + [ + 3987, + 3987 + ], + "mapped", + [ + 3986, + 4023 + ] + ], + [ + [ + 3988, + 3989 + ], + "valid" + ], + [ + [ + 3990, + 3990 + ], + "valid" + ], + [ + [ + 3991, + 3991 + ], + "valid" + ], + [ + [ + 3992, + 3992 + ], + "disallowed" + ], + [ + [ + 3993, + 3996 + ], + "valid" + ], + [ + [ + 3997, + 3997 + ], + "mapped", + [ + 3996, + 4023 + ] + ], + [ + [ + 3998, + 4001 + ], + "valid" + ], + [ + [ + 4002, + 4002 + ], + "mapped", + [ + 4001, + 4023 + ] + ], + [ + [ + 4003, + 4006 + ], + "valid" + ], + [ + [ + 4007, + 4007 + ], + "mapped", + [ + 4006, + 4023 + ] + ], + [ + [ + 4008, + 4011 + ], + "valid" + ], + [ + [ + 4012, + 4012 + ], + "mapped", + [ + 4011, + 4023 + ] + ], + [ + [ + 4013, + 4013 + ], + "valid" + ], + [ + [ + 4014, + 4016 + ], + "valid" + ], + [ + [ + 4017, + 4023 + ], + "valid" + ], + [ + [ + 4024, + 4024 + ], + "valid" + ], + [ + [ + 4025, + 4025 + ], + "mapped", + [ + 3984, + 4021 + ] + ], + [ + [ + 4026, + 4028 + ], + "valid" + ], + [ + [ + 4029, + 4029 + ], + "disallowed" + ], + [ + [ + 4030, + 4037 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4038, + 4038 + ], + "valid" + ], + [ + [ + 4039, + 4044 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4045, + 4045 + ], + "disallowed" + ], + [ + [ + 4046, + 4046 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4047, + 4047 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4048, + 4049 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4050, + 4052 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4053, + 4056 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4057, + 4058 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4059, + 4095 + ], + "disallowed" + ], + [ + [ + 4096, + 4129 + ], + "valid" + ], + [ + [ + 4130, + 4130 + ], + "valid" + ], + [ + [ + 4131, + 4135 + ], + "valid" + ], + [ + [ + 4136, + 4136 + ], + "valid" + ], + [ + [ + 4137, + 4138 + ], + "valid" + ], + [ + [ + 4139, + 4139 + ], + "valid" + ], + [ + [ + 4140, + 4146 + ], + "valid" + ], + [ + [ + 4147, + 4149 + ], + "valid" + ], + [ + [ + 4150, + 4153 + ], + "valid" + ], + [ + [ + 4154, + 4159 + ], + "valid" + ], + [ + [ + 4160, + 4169 + ], + "valid" + ], + [ + [ + 4170, + 4175 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4176, + 4185 + ], + "valid" + ], + [ + [ + 4186, + 4249 + ], + "valid" + ], + [ + [ + 4250, + 4253 + ], + "valid" + ], + [ + [ + 4254, + 4255 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4256, + 4293 + ], + "disallowed" + ], + [ + [ + 4294, + 4294 + ], + "disallowed" + ], + [ + [ + 4295, + 4295 + ], + "mapped", + [ + 11559 + ] + ], + [ + [ + 4296, + 4300 + ], + "disallowed" + ], + [ + [ + 4301, + 4301 + ], + "mapped", + [ + 11565 + ] + ], + [ + [ + 4302, + 4303 + ], + "disallowed" + ], + [ + [ + 4304, + 4342 + ], + "valid" + ], + [ + [ + 4343, + 4344 + ], + "valid" + ], + [ + [ + 4345, + 4346 + ], + "valid" + ], + [ + [ + 4347, + 4347 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4348, + 4348 + ], + "mapped", + [ + 4316 + ] + ], + [ + [ + 4349, + 4351 + ], + "valid" + ], + [ + [ + 4352, + 4441 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4442, + 4446 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4447, + 4448 + ], + "disallowed" + ], + [ + [ + 4449, + 4514 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4515, + 4519 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4520, + 4601 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4602, + 4607 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4608, + 4614 + ], + "valid" + ], + [ + [ + 4615, + 4615 + ], + "valid" + ], + [ + [ + 4616, + 4678 + ], + "valid" + ], + [ + [ + 4679, + 4679 + ], + "valid" + ], + [ + [ + 4680, + 4680 + ], + "valid" + ], + [ + [ + 4681, + 4681 + ], + "disallowed" + ], + [ + [ + 4682, + 4685 + ], + "valid" + ], + [ + [ + 4686, + 4687 + ], + "disallowed" + ], + [ + [ + 4688, + 4694 + ], + "valid" + ], + [ + [ + 4695, + 4695 + ], + "disallowed" + ], + [ + [ + 4696, + 4696 + ], + "valid" + ], + [ + [ + 4697, + 4697 + ], + "disallowed" + ], + [ + [ + 4698, + 4701 + ], + "valid" + ], + [ + [ + 4702, + 4703 + ], + "disallowed" + ], + [ + [ + 4704, + 4742 + ], + "valid" + ], + [ + [ + 4743, + 4743 + ], + "valid" + ], + [ + [ + 4744, + 4744 + ], + "valid" + ], + [ + [ + 4745, + 4745 + ], + "disallowed" + ], + [ + [ + 4746, + 4749 + ], + "valid" + ], + [ + [ + 4750, + 4751 + ], + "disallowed" + ], + [ + [ + 4752, + 4782 + ], + "valid" + ], + [ + [ + 4783, + 4783 + ], + "valid" + ], + [ + [ + 4784, + 4784 + ], + "valid" + ], + [ + [ + 4785, + 4785 + ], + "disallowed" + ], + [ + [ + 4786, + 4789 + ], + "valid" + ], + [ + [ + 4790, + 4791 + ], + "disallowed" + ], + [ + [ + 4792, + 4798 + ], + "valid" + ], + [ + [ + 4799, + 4799 + ], + "disallowed" + ], + [ + [ + 4800, + 4800 + ], + "valid" + ], + [ + [ + 4801, + 4801 + ], + "disallowed" + ], + [ + [ + 4802, + 4805 + ], + "valid" + ], + [ + [ + 4806, + 4807 + ], + "disallowed" + ], + [ + [ + 4808, + 4814 + ], + "valid" + ], + [ + [ + 4815, + 4815 + ], + "valid" + ], + [ + [ + 4816, + 4822 + ], + "valid" + ], + [ + [ + 4823, + 4823 + ], + "disallowed" + ], + [ + [ + 4824, + 4846 + ], + "valid" + ], + [ + [ + 4847, + 4847 + ], + "valid" + ], + [ + [ + 4848, + 4878 + ], + "valid" + ], + [ + [ + 4879, + 4879 + ], + "valid" + ], + [ + [ + 4880, + 4880 + ], + "valid" + ], + [ + [ + 4881, + 4881 + ], + "disallowed" + ], + [ + [ + 4882, + 4885 + ], + "valid" + ], + [ + [ + 4886, + 4887 + ], + "disallowed" + ], + [ + [ + 4888, + 4894 + ], + "valid" + ], + [ + [ + 4895, + 4895 + ], + "valid" + ], + [ + [ + 4896, + 4934 + ], + "valid" + ], + [ + [ + 4935, + 4935 + ], + "valid" + ], + [ + [ + 4936, + 4954 + ], + "valid" + ], + [ + [ + 4955, + 4956 + ], + "disallowed" + ], + [ + [ + 4957, + 4958 + ], + "valid" + ], + [ + [ + 4959, + 4959 + ], + "valid" + ], + [ + [ + 4960, + 4960 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4961, + 4988 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 4989, + 4991 + ], + "disallowed" + ], + [ + [ + 4992, + 5007 + ], + "valid" + ], + [ + [ + 5008, + 5017 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 5018, + 5023 + ], + "disallowed" + ], + [ + [ + 5024, + 5108 + ], + "valid" + ], + [ + [ + 5109, + 5109 + ], + "valid" + ], + [ + [ + 5110, + 5111 + ], + "disallowed" + ], + [ + [ + 5112, + 5112 + ], + "mapped", + [ + 5104 + ] + ], + [ + [ + 5113, + 5113 + ], + "mapped", + [ + 5105 + ] + ], + [ + [ + 5114, + 5114 + ], + "mapped", + [ + 5106 + ] + ], + [ + [ + 5115, + 5115 + ], + "mapped", + [ + 5107 + ] + ], + [ + [ + 5116, + 5116 + ], + "mapped", + [ + 5108 + ] + ], + [ + [ + 5117, + 5117 + ], + "mapped", + [ + 5109 + ] + ], + [ + [ + 5118, + 5119 + ], + "disallowed" + ], + [ + [ + 5120, + 5120 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 5121, + 5740 + ], + "valid" + ], + [ + [ + 5741, + 5742 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 5743, + 5750 + ], + "valid" + ], + [ + [ + 5751, + 5759 + ], + "valid" + ], + [ + [ + 5760, + 5760 + ], + "disallowed" + ], + [ + [ + 5761, + 5786 + ], + "valid" + ], + [ + [ + 5787, + 5788 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 5789, + 5791 + ], + "disallowed" + ], + [ + [ + 5792, + 5866 + ], + "valid" + ], + [ + [ + 5867, + 5872 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 5873, + 5880 + ], + "valid" + ], + [ + [ + 5881, + 5887 + ], + "disallowed" + ], + [ + [ + 5888, + 5900 + ], + "valid" + ], + [ + [ + 5901, + 5901 + ], + "disallowed" + ], + [ + [ + 5902, + 5908 + ], + "valid" + ], + [ + [ + 5909, + 5919 + ], + "disallowed" + ], + [ + [ + 5920, + 5940 + ], + "valid" + ], + [ + [ + 5941, + 5942 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 5943, + 5951 + ], + "disallowed" + ], + [ + [ + 5952, + 5971 + ], + "valid" + ], + [ + [ + 5972, + 5983 + ], + "disallowed" + ], + [ + [ + 5984, + 5996 + ], + "valid" + ], + [ + [ + 5997, + 5997 + ], + "disallowed" + ], + [ + [ + 5998, + 6000 + ], + "valid" + ], + [ + [ + 6001, + 6001 + ], + "disallowed" + ], + [ + [ + 6002, + 6003 + ], + "valid" + ], + [ + [ + 6004, + 6015 + ], + "disallowed" + ], + [ + [ + 6016, + 6067 + ], + "valid" + ], + [ + [ + 6068, + 6069 + ], + "disallowed" + ], + [ + [ + 6070, + 6099 + ], + "valid" + ], + [ + [ + 6100, + 6102 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 6103, + 6103 + ], + "valid" + ], + [ + [ + 6104, + 6107 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 6108, + 6108 + ], + "valid" + ], + [ + [ + 6109, + 6109 + ], + "valid" + ], + [ + [ + 6110, + 6111 + ], + "disallowed" + ], + [ + [ + 6112, + 6121 + ], + "valid" + ], + [ + [ + 6122, + 6127 + ], + "disallowed" + ], + [ + [ + 6128, + 6137 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 6138, + 6143 + ], + "disallowed" + ], + [ + [ + 6144, + 6149 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 6150, + 6150 + ], + "disallowed" + ], + [ + [ + 6151, + 6154 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 6155, + 6157 + ], + "ignored" + ], + [ + [ + 6158, + 6158 + ], + "disallowed" + ], + [ + [ + 6159, + 6159 + ], + "disallowed" + ], + [ + [ + 6160, + 6169 + ], + "valid" + ], + [ + [ + 6170, + 6175 + ], + "disallowed" + ], + [ + [ + 6176, + 6263 + ], + "valid" + ], + [ + [ + 6264, + 6271 + ], + "disallowed" + ], + [ + [ + 6272, + 6313 + ], + "valid" + ], + [ + [ + 6314, + 6314 + ], + "valid" + ], + [ + [ + 6315, + 6319 + ], + "disallowed" + ], + [ + [ + 6320, + 6389 + ], + "valid" + ], + [ + [ + 6390, + 6399 + ], + "disallowed" + ], + [ + [ + 6400, + 6428 + ], + "valid" + ], + [ + [ + 6429, + 6430 + ], + "valid" + ], + [ + [ + 6431, + 6431 + ], + "disallowed" + ], + [ + [ + 6432, + 6443 + ], + "valid" + ], + [ + [ + 6444, + 6447 + ], + "disallowed" + ], + [ + [ + 6448, + 6459 + ], + "valid" + ], + [ + [ + 6460, + 6463 + ], + "disallowed" + ], + [ + [ + 6464, + 6464 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 6465, + 6467 + ], + "disallowed" + ], + [ + [ + 6468, + 6469 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 6470, + 6509 + ], + "valid" + ], + [ + [ + 6510, + 6511 + ], + "disallowed" + ], + [ + [ + 6512, + 6516 + ], + "valid" + ], + [ + [ + 6517, + 6527 + ], + "disallowed" + ], + [ + [ + 6528, + 6569 + ], + "valid" + ], + [ + [ + 6570, + 6571 + ], + "valid" + ], + [ + [ + 6572, + 6575 + ], + "disallowed" + ], + [ + [ + 6576, + 6601 + ], + "valid" + ], + [ + [ + 6602, + 6607 + ], + "disallowed" + ], + [ + [ + 6608, + 6617 + ], + "valid" + ], + [ + [ + 6618, + 6618 + ], + "valid", + [ + ], + "XV8" + ], + [ + [ + 6619, + 6621 + ], + "disallowed" + ], + [ + [ + 6622, + 6623 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 6624, + 6655 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 6656, + 6683 + ], + "valid" + ], + [ + [ + 6684, + 6685 + ], + "disallowed" + ], + [ + [ + 6686, + 6687 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 6688, + 6750 + ], + "valid" + ], + [ + [ + 6751, + 6751 + ], + "disallowed" + ], + [ + [ + 6752, + 6780 + ], + "valid" + ], + [ + [ + 6781, + 6782 + ], + "disallowed" + ], + [ + [ + 6783, + 6793 + ], + "valid" + ], + [ + [ + 6794, + 6799 + ], + "disallowed" + ], + [ + [ + 6800, + 6809 + ], + "valid" + ], + [ + [ + 6810, + 6815 + ], + "disallowed" + ], + [ + [ + 6816, + 6822 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 6823, + 6823 + ], + "valid" + ], + [ + [ + 6824, + 6829 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 6830, + 6831 + ], + "disallowed" + ], + [ + [ + 6832, + 6845 + ], + "valid" + ], + [ + [ + 6846, + 6846 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 6847, + 6911 + ], + "disallowed" + ], + [ + [ + 6912, + 6987 + ], + "valid" + ], + [ + [ + 6988, + 6991 + ], + "disallowed" + ], + [ + [ + 6992, + 7001 + ], + "valid" + ], + [ + [ + 7002, + 7018 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 7019, + 7027 + ], + "valid" + ], + [ + [ + 7028, + 7036 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 7037, + 7039 + ], + "disallowed" + ], + [ + [ + 7040, + 7082 + ], + "valid" + ], + [ + [ + 7083, + 7085 + ], + "valid" + ], + [ + [ + 7086, + 7097 + ], + "valid" + ], + [ + [ + 7098, + 7103 + ], + "valid" + ], + [ + [ + 7104, + 7155 + ], + "valid" + ], + [ + [ + 7156, + 7163 + ], + "disallowed" + ], + [ + [ + 7164, + 7167 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 7168, + 7223 + ], + "valid" + ], + [ + [ + 7224, + 7226 + ], + "disallowed" + ], + [ + [ + 7227, + 7231 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 7232, + 7241 + ], + "valid" + ], + [ + [ + 7242, + 7244 + ], + "disallowed" + ], + [ + [ + 7245, + 7293 + ], + "valid" + ], + [ + [ + 7294, + 7295 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 7296, + 7359 + ], + "disallowed" + ], + [ + [ + 7360, + 7367 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 7368, + 7375 + ], + "disallowed" + ], + [ + [ + 7376, + 7378 + ], + "valid" + ], + [ + [ + 7379, + 7379 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 7380, + 7410 + ], + "valid" + ], + [ + [ + 7411, + 7414 + ], + "valid" + ], + [ + [ + 7415, + 7415 + ], + "disallowed" + ], + [ + [ + 7416, + 7417 + ], + "valid" + ], + [ + [ + 7418, + 7423 + ], + "disallowed" + ], + [ + [ + 7424, + 7467 + ], + "valid" + ], + [ + [ + 7468, + 7468 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 7469, + 7469 + ], + "mapped", + [ + 230 + ] + ], + [ + [ + 7470, + 7470 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 7471, + 7471 + ], + "valid" + ], + [ + [ + 7472, + 7472 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 7473, + 7473 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 7474, + 7474 + ], + "mapped", + [ + 477 + ] + ], + [ + [ + 7475, + 7475 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 7476, + 7476 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 7477, + 7477 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 7478, + 7478 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 7479, + 7479 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 7480, + 7480 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 7481, + 7481 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 7482, + 7482 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 7483, + 7483 + ], + "valid" + ], + [ + [ + 7484, + 7484 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 7485, + 7485 + ], + "mapped", + [ + 547 + ] + ], + [ + [ + 7486, + 7486 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 7487, + 7487 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 7488, + 7488 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 7489, + 7489 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 7490, + 7490 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 7491, + 7491 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 7492, + 7492 + ], + "mapped", + [ + 592 + ] + ], + [ + [ + 7493, + 7493 + ], + "mapped", + [ + 593 + ] + ], + [ + [ + 7494, + 7494 + ], + "mapped", + [ + 7426 + ] + ], + [ + [ + 7495, + 7495 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 7496, + 7496 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 7497, + 7497 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 7498, + 7498 + ], + "mapped", + [ + 601 + ] + ], + [ + [ + 7499, + 7499 + ], + "mapped", + [ + 603 + ] + ], + [ + [ + 7500, + 7500 + ], + "mapped", + [ + 604 + ] + ], + [ + [ + 7501, + 7501 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 7502, + 7502 + ], + "valid" + ], + [ + [ + 7503, + 7503 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 7504, + 7504 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 7505, + 7505 + ], + "mapped", + [ + 331 + ] + ], + [ + [ + 7506, + 7506 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 7507, + 7507 + ], + "mapped", + [ + 596 + ] + ], + [ + [ + 7508, + 7508 + ], + "mapped", + [ + 7446 + ] + ], + [ + [ + 7509, + 7509 + ], + "mapped", + [ + 7447 + ] + ], + [ + [ + 7510, + 7510 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 7511, + 7511 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 7512, + 7512 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 7513, + 7513 + ], + "mapped", + [ + 7453 + ] + ], + [ + [ + 7514, + 7514 + ], + "mapped", + [ + 623 + ] + ], + [ + [ + 7515, + 7515 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 7516, + 7516 + ], + "mapped", + [ + 7461 + ] + ], + [ + [ + 7517, + 7517 + ], + "mapped", + [ + 946 + ] + ], + [ + [ + 7518, + 7518 + ], + "mapped", + [ + 947 + ] + ], + [ + [ + 7519, + 7519 + ], + "mapped", + [ + 948 + ] + ], + [ + [ + 7520, + 7520 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 7521, + 7521 + ], + "mapped", + [ + 967 + ] + ], + [ + [ + 7522, + 7522 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 7523, + 7523 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 7524, + 7524 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 7525, + 7525 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 7526, + 7526 + ], + "mapped", + [ + 946 + ] + ], + [ + [ + 7527, + 7527 + ], + "mapped", + [ + 947 + ] + ], + [ + [ + 7528, + 7528 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 7529, + 7529 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 7530, + 7530 + ], + "mapped", + [ + 967 + ] + ], + [ + [ + 7531, + 7531 + ], + "valid" + ], + [ + [ + 7532, + 7543 + ], + "valid" + ], + [ + [ + 7544, + 7544 + ], + "mapped", + [ + 1085 + ] + ], + [ + [ + 7545, + 7578 + ], + "valid" + ], + [ + [ + 7579, + 7579 + ], + "mapped", + [ + 594 + ] + ], + [ + [ + 7580, + 7580 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 7581, + 7581 + ], + "mapped", + [ + 597 + ] + ], + [ + [ + 7582, + 7582 + ], + "mapped", + [ + 240 + ] + ], + [ + [ + 7583, + 7583 + ], + "mapped", + [ + 604 + ] + ], + [ + [ + 7584, + 7584 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 7585, + 7585 + ], + "mapped", + [ + 607 + ] + ], + [ + [ + 7586, + 7586 + ], + "mapped", + [ + 609 + ] + ], + [ + [ + 7587, + 7587 + ], + "mapped", + [ + 613 + ] + ], + [ + [ + 7588, + 7588 + ], + "mapped", + [ + 616 + ] + ], + [ + [ + 7589, + 7589 + ], + "mapped", + [ + 617 + ] + ], + [ + [ + 7590, + 7590 + ], + "mapped", + [ + 618 + ] + ], + [ + [ + 7591, + 7591 + ], + "mapped", + [ + 7547 + ] + ], + [ + [ + 7592, + 7592 + ], + "mapped", + [ + 669 + ] + ], + [ + [ + 7593, + 7593 + ], + "mapped", + [ + 621 + ] + ], + [ + [ + 7594, + 7594 + ], + "mapped", + [ + 7557 + ] + ], + [ + [ + 7595, + 7595 + ], + "mapped", + [ + 671 + ] + ], + [ + [ + 7596, + 7596 + ], + "mapped", + [ + 625 + ] + ], + [ + [ + 7597, + 7597 + ], + "mapped", + [ + 624 + ] + ], + [ + [ + 7598, + 7598 + ], + "mapped", + [ + 626 + ] + ], + [ + [ + 7599, + 7599 + ], + "mapped", + [ + 627 + ] + ], + [ + [ + 7600, + 7600 + ], + "mapped", + [ + 628 + ] + ], + [ + [ + 7601, + 7601 + ], + "mapped", + [ + 629 + ] + ], + [ + [ + 7602, + 7602 + ], + "mapped", + [ + 632 + ] + ], + [ + [ + 7603, + 7603 + ], + "mapped", + [ + 642 + ] + ], + [ + [ + 7604, + 7604 + ], + "mapped", + [ + 643 + ] + ], + [ + [ + 7605, + 7605 + ], + "mapped", + [ + 427 + ] + ], + [ + [ + 7606, + 7606 + ], + "mapped", + [ + 649 + ] + ], + [ + [ + 7607, + 7607 + ], + "mapped", + [ + 650 + ] + ], + [ + [ + 7608, + 7608 + ], + "mapped", + [ + 7452 + ] + ], + [ + [ + 7609, + 7609 + ], + "mapped", + [ + 651 + ] + ], + [ + [ + 7610, + 7610 + ], + "mapped", + [ + 652 + ] + ], + [ + [ + 7611, + 7611 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 7612, + 7612 + ], + "mapped", + [ + 656 + ] + ], + [ + [ + 7613, + 7613 + ], + "mapped", + [ + 657 + ] + ], + [ + [ + 7614, + 7614 + ], + "mapped", + [ + 658 + ] + ], + [ + [ + 7615, + 7615 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 7616, + 7619 + ], + "valid" + ], + [ + [ + 7620, + 7626 + ], + "valid" + ], + [ + [ + 7627, + 7654 + ], + "valid" + ], + [ + [ + 7655, + 7669 + ], + "valid" + ], + [ + [ + 7670, + 7675 + ], + "disallowed" + ], + [ + [ + 7676, + 7676 + ], + "valid" + ], + [ + [ + 7677, + 7677 + ], + "valid" + ], + [ + [ + 7678, + 7679 + ], + "valid" + ], + [ + [ + 7680, + 7680 + ], + "mapped", + [ + 7681 + ] + ], + [ + [ + 7681, + 7681 + ], + "valid" + ], + [ + [ + 7682, + 7682 + ], + "mapped", + [ + 7683 + ] + ], + [ + [ + 7683, + 7683 + ], + "valid" + ], + [ + [ + 7684, + 7684 + ], + "mapped", + [ + 7685 + ] + ], + [ + [ + 7685, + 7685 + ], + "valid" + ], + [ + [ + 7686, + 7686 + ], + "mapped", + [ + 7687 + ] + ], + [ + [ + 7687, + 7687 + ], + "valid" + ], + [ + [ + 7688, + 7688 + ], + "mapped", + [ + 7689 + ] + ], + [ + [ + 7689, + 7689 + ], + "valid" + ], + [ + [ + 7690, + 7690 + ], + "mapped", + [ + 7691 + ] + ], + [ + [ + 7691, + 7691 + ], + "valid" + ], + [ + [ + 7692, + 7692 + ], + "mapped", + [ + 7693 + ] + ], + [ + [ + 7693, + 7693 + ], + "valid" + ], + [ + [ + 7694, + 7694 + ], + "mapped", + [ + 7695 + ] + ], + [ + [ + 7695, + 7695 + ], + "valid" + ], + [ + [ + 7696, + 7696 + ], + "mapped", + [ + 7697 + ] + ], + [ + [ + 7697, + 7697 + ], + "valid" + ], + [ + [ + 7698, + 7698 + ], + "mapped", + [ + 7699 + ] + ], + [ + [ + 7699, + 7699 + ], + "valid" + ], + [ + [ + 7700, + 7700 + ], + "mapped", + [ + 7701 + ] + ], + [ + [ + 7701, + 7701 + ], + "valid" + ], + [ + [ + 7702, + 7702 + ], + "mapped", + [ + 7703 + ] + ], + [ + [ + 7703, + 7703 + ], + "valid" + ], + [ + [ + 7704, + 7704 + ], + "mapped", + [ + 7705 + ] + ], + [ + [ + 7705, + 7705 + ], + "valid" + ], + [ + [ + 7706, + 7706 + ], + "mapped", + [ + 7707 + ] + ], + [ + [ + 7707, + 7707 + ], + "valid" + ], + [ + [ + 7708, + 7708 + ], + "mapped", + [ + 7709 + ] + ], + [ + [ + 7709, + 7709 + ], + "valid" + ], + [ + [ + 7710, + 7710 + ], + "mapped", + [ + 7711 + ] + ], + [ + [ + 7711, + 7711 + ], + "valid" + ], + [ + [ + 7712, + 7712 + ], + "mapped", + [ + 7713 + ] + ], + [ + [ + 7713, + 7713 + ], + "valid" + ], + [ + [ + 7714, + 7714 + ], + "mapped", + [ + 7715 + ] + ], + [ + [ + 7715, + 7715 + ], + "valid" + ], + [ + [ + 7716, + 7716 + ], + "mapped", + [ + 7717 + ] + ], + [ + [ + 7717, + 7717 + ], + "valid" + ], + [ + [ + 7718, + 7718 + ], + "mapped", + [ + 7719 + ] + ], + [ + [ + 7719, + 7719 + ], + "valid" + ], + [ + [ + 7720, + 7720 + ], + "mapped", + [ + 7721 + ] + ], + [ + [ + 7721, + 7721 + ], + "valid" + ], + [ + [ + 7722, + 7722 + ], + "mapped", + [ + 7723 + ] + ], + [ + [ + 7723, + 7723 + ], + "valid" + ], + [ + [ + 7724, + 7724 + ], + "mapped", + [ + 7725 + ] + ], + [ + [ + 7725, + 7725 + ], + "valid" + ], + [ + [ + 7726, + 7726 + ], + "mapped", + [ + 7727 + ] + ], + [ + [ + 7727, + 7727 + ], + "valid" + ], + [ + [ + 7728, + 7728 + ], + "mapped", + [ + 7729 + ] + ], + [ + [ + 7729, + 7729 + ], + "valid" + ], + [ + [ + 7730, + 7730 + ], + "mapped", + [ + 7731 + ] + ], + [ + [ + 7731, + 7731 + ], + "valid" + ], + [ + [ + 7732, + 7732 + ], + "mapped", + [ + 7733 + ] + ], + [ + [ + 7733, + 7733 + ], + "valid" + ], + [ + [ + 7734, + 7734 + ], + "mapped", + [ + 7735 + ] + ], + [ + [ + 7735, + 7735 + ], + "valid" + ], + [ + [ + 7736, + 7736 + ], + "mapped", + [ + 7737 + ] + ], + [ + [ + 7737, + 7737 + ], + "valid" + ], + [ + [ + 7738, + 7738 + ], + "mapped", + [ + 7739 + ] + ], + [ + [ + 7739, + 7739 + ], + "valid" + ], + [ + [ + 7740, + 7740 + ], + "mapped", + [ + 7741 + ] + ], + [ + [ + 7741, + 7741 + ], + "valid" + ], + [ + [ + 7742, + 7742 + ], + "mapped", + [ + 7743 + ] + ], + [ + [ + 7743, + 7743 + ], + "valid" + ], + [ + [ + 7744, + 7744 + ], + "mapped", + [ + 7745 + ] + ], + [ + [ + 7745, + 7745 + ], + "valid" + ], + [ + [ + 7746, + 7746 + ], + "mapped", + [ + 7747 + ] + ], + [ + [ + 7747, + 7747 + ], + "valid" + ], + [ + [ + 7748, + 7748 + ], + "mapped", + [ + 7749 + ] + ], + [ + [ + 7749, + 7749 + ], + "valid" + ], + [ + [ + 7750, + 7750 + ], + "mapped", + [ + 7751 + ] + ], + [ + [ + 7751, + 7751 + ], + "valid" + ], + [ + [ + 7752, + 7752 + ], + "mapped", + [ + 7753 + ] + ], + [ + [ + 7753, + 7753 + ], + "valid" + ], + [ + [ + 7754, + 7754 + ], + "mapped", + [ + 7755 + ] + ], + [ + [ + 7755, + 7755 + ], + "valid" + ], + [ + [ + 7756, + 7756 + ], + "mapped", + [ + 7757 + ] + ], + [ + [ + 7757, + 7757 + ], + "valid" + ], + [ + [ + 7758, + 7758 + ], + "mapped", + [ + 7759 + ] + ], + [ + [ + 7759, + 7759 + ], + "valid" + ], + [ + [ + 7760, + 7760 + ], + "mapped", + [ + 7761 + ] + ], + [ + [ + 7761, + 7761 + ], + "valid" + ], + [ + [ + 7762, + 7762 + ], + "mapped", + [ + 7763 + ] + ], + [ + [ + 7763, + 7763 + ], + "valid" + ], + [ + [ + 7764, + 7764 + ], + "mapped", + [ + 7765 + ] + ], + [ + [ + 7765, + 7765 + ], + "valid" + ], + [ + [ + 7766, + 7766 + ], + "mapped", + [ + 7767 + ] + ], + [ + [ + 7767, + 7767 + ], + "valid" + ], + [ + [ + 7768, + 7768 + ], + "mapped", + [ + 7769 + ] + ], + [ + [ + 7769, + 7769 + ], + "valid" + ], + [ + [ + 7770, + 7770 + ], + "mapped", + [ + 7771 + ] + ], + [ + [ + 7771, + 7771 + ], + "valid" + ], + [ + [ + 7772, + 7772 + ], + "mapped", + [ + 7773 + ] + ], + [ + [ + 7773, + 7773 + ], + "valid" + ], + [ + [ + 7774, + 7774 + ], + "mapped", + [ + 7775 + ] + ], + [ + [ + 7775, + 7775 + ], + "valid" + ], + [ + [ + 7776, + 7776 + ], + "mapped", + [ + 7777 + ] + ], + [ + [ + 7777, + 7777 + ], + "valid" + ], + [ + [ + 7778, + 7778 + ], + "mapped", + [ + 7779 + ] + ], + [ + [ + 7779, + 7779 + ], + "valid" + ], + [ + [ + 7780, + 7780 + ], + "mapped", + [ + 7781 + ] + ], + [ + [ + 7781, + 7781 + ], + "valid" + ], + [ + [ + 7782, + 7782 + ], + "mapped", + [ + 7783 + ] + ], + [ + [ + 7783, + 7783 + ], + "valid" + ], + [ + [ + 7784, + 7784 + ], + "mapped", + [ + 7785 + ] + ], + [ + [ + 7785, + 7785 + ], + "valid" + ], + [ + [ + 7786, + 7786 + ], + "mapped", + [ + 7787 + ] + ], + [ + [ + 7787, + 7787 + ], + "valid" + ], + [ + [ + 7788, + 7788 + ], + "mapped", + [ + 7789 + ] + ], + [ + [ + 7789, + 7789 + ], + "valid" + ], + [ + [ + 7790, + 7790 + ], + "mapped", + [ + 7791 + ] + ], + [ + [ + 7791, + 7791 + ], + "valid" + ], + [ + [ + 7792, + 7792 + ], + "mapped", + [ + 7793 + ] + ], + [ + [ + 7793, + 7793 + ], + "valid" + ], + [ + [ + 7794, + 7794 + ], + "mapped", + [ + 7795 + ] + ], + [ + [ + 7795, + 7795 + ], + "valid" + ], + [ + [ + 7796, + 7796 + ], + "mapped", + [ + 7797 + ] + ], + [ + [ + 7797, + 7797 + ], + "valid" + ], + [ + [ + 7798, + 7798 + ], + "mapped", + [ + 7799 + ] + ], + [ + [ + 7799, + 7799 + ], + "valid" + ], + [ + [ + 7800, + 7800 + ], + "mapped", + [ + 7801 + ] + ], + [ + [ + 7801, + 7801 + ], + "valid" + ], + [ + [ + 7802, + 7802 + ], + "mapped", + [ + 7803 + ] + ], + [ + [ + 7803, + 7803 + ], + "valid" + ], + [ + [ + 7804, + 7804 + ], + "mapped", + [ + 7805 + ] + ], + [ + [ + 7805, + 7805 + ], + "valid" + ], + [ + [ + 7806, + 7806 + ], + "mapped", + [ + 7807 + ] + ], + [ + [ + 7807, + 7807 + ], + "valid" + ], + [ + [ + 7808, + 7808 + ], + "mapped", + [ + 7809 + ] + ], + [ + [ + 7809, + 7809 + ], + "valid" + ], + [ + [ + 7810, + 7810 + ], + "mapped", + [ + 7811 + ] + ], + [ + [ + 7811, + 7811 + ], + "valid" + ], + [ + [ + 7812, + 7812 + ], + "mapped", + [ + 7813 + ] + ], + [ + [ + 7813, + 7813 + ], + "valid" + ], + [ + [ + 7814, + 7814 + ], + "mapped", + [ + 7815 + ] + ], + [ + [ + 7815, + 7815 + ], + "valid" + ], + [ + [ + 7816, + 7816 + ], + "mapped", + [ + 7817 + ] + ], + [ + [ + 7817, + 7817 + ], + "valid" + ], + [ + [ + 7818, + 7818 + ], + "mapped", + [ + 7819 + ] + ], + [ + [ + 7819, + 7819 + ], + "valid" + ], + [ + [ + 7820, + 7820 + ], + "mapped", + [ + 7821 + ] + ], + [ + [ + 7821, + 7821 + ], + "valid" + ], + [ + [ + 7822, + 7822 + ], + "mapped", + [ + 7823 + ] + ], + [ + [ + 7823, + 7823 + ], + "valid" + ], + [ + [ + 7824, + 7824 + ], + "mapped", + [ + 7825 + ] + ], + [ + [ + 7825, + 7825 + ], + "valid" + ], + [ + [ + 7826, + 7826 + ], + "mapped", + [ + 7827 + ] + ], + [ + [ + 7827, + 7827 + ], + "valid" + ], + [ + [ + 7828, + 7828 + ], + "mapped", + [ + 7829 + ] + ], + [ + [ + 7829, + 7833 + ], + "valid" + ], + [ + [ + 7834, + 7834 + ], + "mapped", + [ + 97, + 702 + ] + ], + [ + [ + 7835, + 7835 + ], + "mapped", + [ + 7777 + ] + ], + [ + [ + 7836, + 7837 + ], + "valid" + ], + [ + [ + 7838, + 7838 + ], + "mapped", + [ + 115, + 115 + ] + ], + [ + [ + 7839, + 7839 + ], + "valid" + ], + [ + [ + 7840, + 7840 + ], + "mapped", + [ + 7841 + ] + ], + [ + [ + 7841, + 7841 + ], + "valid" + ], + [ + [ + 7842, + 7842 + ], + "mapped", + [ + 7843 + ] + ], + [ + [ + 7843, + 7843 + ], + "valid" + ], + [ + [ + 7844, + 7844 + ], + "mapped", + [ + 7845 + ] + ], + [ + [ + 7845, + 7845 + ], + "valid" + ], + [ + [ + 7846, + 7846 + ], + "mapped", + [ + 7847 + ] + ], + [ + [ + 7847, + 7847 + ], + "valid" + ], + [ + [ + 7848, + 7848 + ], + "mapped", + [ + 7849 + ] + ], + [ + [ + 7849, + 7849 + ], + "valid" + ], + [ + [ + 7850, + 7850 + ], + "mapped", + [ + 7851 + ] + ], + [ + [ + 7851, + 7851 + ], + "valid" + ], + [ + [ + 7852, + 7852 + ], + "mapped", + [ + 7853 + ] + ], + [ + [ + 7853, + 7853 + ], + "valid" + ], + [ + [ + 7854, + 7854 + ], + "mapped", + [ + 7855 + ] + ], + [ + [ + 7855, + 7855 + ], + "valid" + ], + [ + [ + 7856, + 7856 + ], + "mapped", + [ + 7857 + ] + ], + [ + [ + 7857, + 7857 + ], + "valid" + ], + [ + [ + 7858, + 7858 + ], + "mapped", + [ + 7859 + ] + ], + [ + [ + 7859, + 7859 + ], + "valid" + ], + [ + [ + 7860, + 7860 + ], + "mapped", + [ + 7861 + ] + ], + [ + [ + 7861, + 7861 + ], + "valid" + ], + [ + [ + 7862, + 7862 + ], + "mapped", + [ + 7863 + ] + ], + [ + [ + 7863, + 7863 + ], + "valid" + ], + [ + [ + 7864, + 7864 + ], + "mapped", + [ + 7865 + ] + ], + [ + [ + 7865, + 7865 + ], + "valid" + ], + [ + [ + 7866, + 7866 + ], + "mapped", + [ + 7867 + ] + ], + [ + [ + 7867, + 7867 + ], + "valid" + ], + [ + [ + 7868, + 7868 + ], + "mapped", + [ + 7869 + ] + ], + [ + [ + 7869, + 7869 + ], + "valid" + ], + [ + [ + 7870, + 7870 + ], + "mapped", + [ + 7871 + ] + ], + [ + [ + 7871, + 7871 + ], + "valid" + ], + [ + [ + 7872, + 7872 + ], + "mapped", + [ + 7873 + ] + ], + [ + [ + 7873, + 7873 + ], + "valid" + ], + [ + [ + 7874, + 7874 + ], + "mapped", + [ + 7875 + ] + ], + [ + [ + 7875, + 7875 + ], + "valid" + ], + [ + [ + 7876, + 7876 + ], + "mapped", + [ + 7877 + ] + ], + [ + [ + 7877, + 7877 + ], + "valid" + ], + [ + [ + 7878, + 7878 + ], + "mapped", + [ + 7879 + ] + ], + [ + [ + 7879, + 7879 + ], + "valid" + ], + [ + [ + 7880, + 7880 + ], + "mapped", + [ + 7881 + ] + ], + [ + [ + 7881, + 7881 + ], + "valid" + ], + [ + [ + 7882, + 7882 + ], + "mapped", + [ + 7883 + ] + ], + [ + [ + 7883, + 7883 + ], + "valid" + ], + [ + [ + 7884, + 7884 + ], + "mapped", + [ + 7885 + ] + ], + [ + [ + 7885, + 7885 + ], + "valid" + ], + [ + [ + 7886, + 7886 + ], + "mapped", + [ + 7887 + ] + ], + [ + [ + 7887, + 7887 + ], + "valid" + ], + [ + [ + 7888, + 7888 + ], + "mapped", + [ + 7889 + ] + ], + [ + [ + 7889, + 7889 + ], + "valid" + ], + [ + [ + 7890, + 7890 + ], + "mapped", + [ + 7891 + ] + ], + [ + [ + 7891, + 7891 + ], + "valid" + ], + [ + [ + 7892, + 7892 + ], + "mapped", + [ + 7893 + ] + ], + [ + [ + 7893, + 7893 + ], + "valid" + ], + [ + [ + 7894, + 7894 + ], + "mapped", + [ + 7895 + ] + ], + [ + [ + 7895, + 7895 + ], + "valid" + ], + [ + [ + 7896, + 7896 + ], + "mapped", + [ + 7897 + ] + ], + [ + [ + 7897, + 7897 + ], + "valid" + ], + [ + [ + 7898, + 7898 + ], + "mapped", + [ + 7899 + ] + ], + [ + [ + 7899, + 7899 + ], + "valid" + ], + [ + [ + 7900, + 7900 + ], + "mapped", + [ + 7901 + ] + ], + [ + [ + 7901, + 7901 + ], + "valid" + ], + [ + [ + 7902, + 7902 + ], + "mapped", + [ + 7903 + ] + ], + [ + [ + 7903, + 7903 + ], + "valid" + ], + [ + [ + 7904, + 7904 + ], + "mapped", + [ + 7905 + ] + ], + [ + [ + 7905, + 7905 + ], + "valid" + ], + [ + [ + 7906, + 7906 + ], + "mapped", + [ + 7907 + ] + ], + [ + [ + 7907, + 7907 + ], + "valid" + ], + [ + [ + 7908, + 7908 + ], + "mapped", + [ + 7909 + ] + ], + [ + [ + 7909, + 7909 + ], + "valid" + ], + [ + [ + 7910, + 7910 + ], + "mapped", + [ + 7911 + ] + ], + [ + [ + 7911, + 7911 + ], + "valid" + ], + [ + [ + 7912, + 7912 + ], + "mapped", + [ + 7913 + ] + ], + [ + [ + 7913, + 7913 + ], + "valid" + ], + [ + [ + 7914, + 7914 + ], + "mapped", + [ + 7915 + ] + ], + [ + [ + 7915, + 7915 + ], + "valid" + ], + [ + [ + 7916, + 7916 + ], + "mapped", + [ + 7917 + ] + ], + [ + [ + 7917, + 7917 + ], + "valid" + ], + [ + [ + 7918, + 7918 + ], + "mapped", + [ + 7919 + ] + ], + [ + [ + 7919, + 7919 + ], + "valid" + ], + [ + [ + 7920, + 7920 + ], + "mapped", + [ + 7921 + ] + ], + [ + [ + 7921, + 7921 + ], + "valid" + ], + [ + [ + 7922, + 7922 + ], + "mapped", + [ + 7923 + ] + ], + [ + [ + 7923, + 7923 + ], + "valid" + ], + [ + [ + 7924, + 7924 + ], + "mapped", + [ + 7925 + ] + ], + [ + [ + 7925, + 7925 + ], + "valid" + ], + [ + [ + 7926, + 7926 + ], + "mapped", + [ + 7927 + ] + ], + [ + [ + 7927, + 7927 + ], + "valid" + ], + [ + [ + 7928, + 7928 + ], + "mapped", + [ + 7929 + ] + ], + [ + [ + 7929, + 7929 + ], + "valid" + ], + [ + [ + 7930, + 7930 + ], + "mapped", + [ + 7931 + ] + ], + [ + [ + 7931, + 7931 + ], + "valid" + ], + [ + [ + 7932, + 7932 + ], + "mapped", + [ + 7933 + ] + ], + [ + [ + 7933, + 7933 + ], + "valid" + ], + [ + [ + 7934, + 7934 + ], + "mapped", + [ + 7935 + ] + ], + [ + [ + 7935, + 7935 + ], + "valid" + ], + [ + [ + 7936, + 7943 + ], + "valid" + ], + [ + [ + 7944, + 7944 + ], + "mapped", + [ + 7936 + ] + ], + [ + [ + 7945, + 7945 + ], + "mapped", + [ + 7937 + ] + ], + [ + [ + 7946, + 7946 + ], + "mapped", + [ + 7938 + ] + ], + [ + [ + 7947, + 7947 + ], + "mapped", + [ + 7939 + ] + ], + [ + [ + 7948, + 7948 + ], + "mapped", + [ + 7940 + ] + ], + [ + [ + 7949, + 7949 + ], + "mapped", + [ + 7941 + ] + ], + [ + [ + 7950, + 7950 + ], + "mapped", + [ + 7942 + ] + ], + [ + [ + 7951, + 7951 + ], + "mapped", + [ + 7943 + ] + ], + [ + [ + 7952, + 7957 + ], + "valid" + ], + [ + [ + 7958, + 7959 + ], + "disallowed" + ], + [ + [ + 7960, + 7960 + ], + "mapped", + [ + 7952 + ] + ], + [ + [ + 7961, + 7961 + ], + "mapped", + [ + 7953 + ] + ], + [ + [ + 7962, + 7962 + ], + "mapped", + [ + 7954 + ] + ], + [ + [ + 7963, + 7963 + ], + "mapped", + [ + 7955 + ] + ], + [ + [ + 7964, + 7964 + ], + "mapped", + [ + 7956 + ] + ], + [ + [ + 7965, + 7965 + ], + "mapped", + [ + 7957 + ] + ], + [ + [ + 7966, + 7967 + ], + "disallowed" + ], + [ + [ + 7968, + 7975 + ], + "valid" + ], + [ + [ + 7976, + 7976 + ], + "mapped", + [ + 7968 + ] + ], + [ + [ + 7977, + 7977 + ], + "mapped", + [ + 7969 + ] + ], + [ + [ + 7978, + 7978 + ], + "mapped", + [ + 7970 + ] + ], + [ + [ + 7979, + 7979 + ], + "mapped", + [ + 7971 + ] + ], + [ + [ + 7980, + 7980 + ], + "mapped", + [ + 7972 + ] + ], + [ + [ + 7981, + 7981 + ], + "mapped", + [ + 7973 + ] + ], + [ + [ + 7982, + 7982 + ], + "mapped", + [ + 7974 + ] + ], + [ + [ + 7983, + 7983 + ], + "mapped", + [ + 7975 + ] + ], + [ + [ + 7984, + 7991 + ], + "valid" + ], + [ + [ + 7992, + 7992 + ], + "mapped", + [ + 7984 + ] + ], + [ + [ + 7993, + 7993 + ], + "mapped", + [ + 7985 + ] + ], + [ + [ + 7994, + 7994 + ], + "mapped", + [ + 7986 + ] + ], + [ + [ + 7995, + 7995 + ], + "mapped", + [ + 7987 + ] + ], + [ + [ + 7996, + 7996 + ], + "mapped", + [ + 7988 + ] + ], + [ + [ + 7997, + 7997 + ], + "mapped", + [ + 7989 + ] + ], + [ + [ + 7998, + 7998 + ], + "mapped", + [ + 7990 + ] + ], + [ + [ + 7999, + 7999 + ], + "mapped", + [ + 7991 + ] + ], + [ + [ + 8000, + 8005 + ], + "valid" + ], + [ + [ + 8006, + 8007 + ], + "disallowed" + ], + [ + [ + 8008, + 8008 + ], + "mapped", + [ + 8000 + ] + ], + [ + [ + 8009, + 8009 + ], + "mapped", + [ + 8001 + ] + ], + [ + [ + 8010, + 8010 + ], + "mapped", + [ + 8002 + ] + ], + [ + [ + 8011, + 8011 + ], + "mapped", + [ + 8003 + ] + ], + [ + [ + 8012, + 8012 + ], + "mapped", + [ + 8004 + ] + ], + [ + [ + 8013, + 8013 + ], + "mapped", + [ + 8005 + ] + ], + [ + [ + 8014, + 8015 + ], + "disallowed" + ], + [ + [ + 8016, + 8023 + ], + "valid" + ], + [ + [ + 8024, + 8024 + ], + "disallowed" + ], + [ + [ + 8025, + 8025 + ], + "mapped", + [ + 8017 + ] + ], + [ + [ + 8026, + 8026 + ], + "disallowed" + ], + [ + [ + 8027, + 8027 + ], + "mapped", + [ + 8019 + ] + ], + [ + [ + 8028, + 8028 + ], + "disallowed" + ], + [ + [ + 8029, + 8029 + ], + "mapped", + [ + 8021 + ] + ], + [ + [ + 8030, + 8030 + ], + "disallowed" + ], + [ + [ + 8031, + 8031 + ], + "mapped", + [ + 8023 + ] + ], + [ + [ + 8032, + 8039 + ], + "valid" + ], + [ + [ + 8040, + 8040 + ], + "mapped", + [ + 8032 + ] + ], + [ + [ + 8041, + 8041 + ], + "mapped", + [ + 8033 + ] + ], + [ + [ + 8042, + 8042 + ], + "mapped", + [ + 8034 + ] + ], + [ + [ + 8043, + 8043 + ], + "mapped", + [ + 8035 + ] + ], + [ + [ + 8044, + 8044 + ], + "mapped", + [ + 8036 + ] + ], + [ + [ + 8045, + 8045 + ], + "mapped", + [ + 8037 + ] + ], + [ + [ + 8046, + 8046 + ], + "mapped", + [ + 8038 + ] + ], + [ + [ + 8047, + 8047 + ], + "mapped", + [ + 8039 + ] + ], + [ + [ + 8048, + 8048 + ], + "valid" + ], + [ + [ + 8049, + 8049 + ], + "mapped", + [ + 940 + ] + ], + [ + [ + 8050, + 8050 + ], + "valid" + ], + [ + [ + 8051, + 8051 + ], + "mapped", + [ + 941 + ] + ], + [ + [ + 8052, + 8052 + ], + "valid" + ], + [ + [ + 8053, + 8053 + ], + "mapped", + [ + 942 + ] + ], + [ + [ + 8054, + 8054 + ], + "valid" + ], + [ + [ + 8055, + 8055 + ], + "mapped", + [ + 943 + ] + ], + [ + [ + 8056, + 8056 + ], + "valid" + ], + [ + [ + 8057, + 8057 + ], + "mapped", + [ + 972 + ] + ], + [ + [ + 8058, + 8058 + ], + "valid" + ], + [ + [ + 8059, + 8059 + ], + "mapped", + [ + 973 + ] + ], + [ + [ + 8060, + 8060 + ], + "valid" + ], + [ + [ + 8061, + 8061 + ], + "mapped", + [ + 974 + ] + ], + [ + [ + 8062, + 8063 + ], + "disallowed" + ], + [ + [ + 8064, + 8064 + ], + "mapped", + [ + 7936, + 953 + ] + ], + [ + [ + 8065, + 8065 + ], + "mapped", + [ + 7937, + 953 + ] + ], + [ + [ + 8066, + 8066 + ], + "mapped", + [ + 7938, + 953 + ] + ], + [ + [ + 8067, + 8067 + ], + "mapped", + [ + 7939, + 953 + ] + ], + [ + [ + 8068, + 8068 + ], + "mapped", + [ + 7940, + 953 + ] + ], + [ + [ + 8069, + 8069 + ], + "mapped", + [ + 7941, + 953 + ] + ], + [ + [ + 8070, + 8070 + ], + "mapped", + [ + 7942, + 953 + ] + ], + [ + [ + 8071, + 8071 + ], + "mapped", + [ + 7943, + 953 + ] + ], + [ + [ + 8072, + 8072 + ], + "mapped", + [ + 7936, + 953 + ] + ], + [ + [ + 8073, + 8073 + ], + "mapped", + [ + 7937, + 953 + ] + ], + [ + [ + 8074, + 8074 + ], + "mapped", + [ + 7938, + 953 + ] + ], + [ + [ + 8075, + 8075 + ], + "mapped", + [ + 7939, + 953 + ] + ], + [ + [ + 8076, + 8076 + ], + "mapped", + [ + 7940, + 953 + ] + ], + [ + [ + 8077, + 8077 + ], + "mapped", + [ + 7941, + 953 + ] + ], + [ + [ + 8078, + 8078 + ], + "mapped", + [ + 7942, + 953 + ] + ], + [ + [ + 8079, + 8079 + ], + "mapped", + [ + 7943, + 953 + ] + ], + [ + [ + 8080, + 8080 + ], + "mapped", + [ + 7968, + 953 + ] + ], + [ + [ + 8081, + 8081 + ], + "mapped", + [ + 7969, + 953 + ] + ], + [ + [ + 8082, + 8082 + ], + "mapped", + [ + 7970, + 953 + ] + ], + [ + [ + 8083, + 8083 + ], + "mapped", + [ + 7971, + 953 + ] + ], + [ + [ + 8084, + 8084 + ], + "mapped", + [ + 7972, + 953 + ] + ], + [ + [ + 8085, + 8085 + ], + "mapped", + [ + 7973, + 953 + ] + ], + [ + [ + 8086, + 8086 + ], + "mapped", + [ + 7974, + 953 + ] + ], + [ + [ + 8087, + 8087 + ], + "mapped", + [ + 7975, + 953 + ] + ], + [ + [ + 8088, + 8088 + ], + "mapped", + [ + 7968, + 953 + ] + ], + [ + [ + 8089, + 8089 + ], + "mapped", + [ + 7969, + 953 + ] + ], + [ + [ + 8090, + 8090 + ], + "mapped", + [ + 7970, + 953 + ] + ], + [ + [ + 8091, + 8091 + ], + "mapped", + [ + 7971, + 953 + ] + ], + [ + [ + 8092, + 8092 + ], + "mapped", + [ + 7972, + 953 + ] + ], + [ + [ + 8093, + 8093 + ], + "mapped", + [ + 7973, + 953 + ] + ], + [ + [ + 8094, + 8094 + ], + "mapped", + [ + 7974, + 953 + ] + ], + [ + [ + 8095, + 8095 + ], + "mapped", + [ + 7975, + 953 + ] + ], + [ + [ + 8096, + 8096 + ], + "mapped", + [ + 8032, + 953 + ] + ], + [ + [ + 8097, + 8097 + ], + "mapped", + [ + 8033, + 953 + ] + ], + [ + [ + 8098, + 8098 + ], + "mapped", + [ + 8034, + 953 + ] + ], + [ + [ + 8099, + 8099 + ], + "mapped", + [ + 8035, + 953 + ] + ], + [ + [ + 8100, + 8100 + ], + "mapped", + [ + 8036, + 953 + ] + ], + [ + [ + 8101, + 8101 + ], + "mapped", + [ + 8037, + 953 + ] + ], + [ + [ + 8102, + 8102 + ], + "mapped", + [ + 8038, + 953 + ] + ], + [ + [ + 8103, + 8103 + ], + "mapped", + [ + 8039, + 953 + ] + ], + [ + [ + 8104, + 8104 + ], + "mapped", + [ + 8032, + 953 + ] + ], + [ + [ + 8105, + 8105 + ], + "mapped", + [ + 8033, + 953 + ] + ], + [ + [ + 8106, + 8106 + ], + "mapped", + [ + 8034, + 953 + ] + ], + [ + [ + 8107, + 8107 + ], + "mapped", + [ + 8035, + 953 + ] + ], + [ + [ + 8108, + 8108 + ], + "mapped", + [ + 8036, + 953 + ] + ], + [ + [ + 8109, + 8109 + ], + "mapped", + [ + 8037, + 953 + ] + ], + [ + [ + 8110, + 8110 + ], + "mapped", + [ + 8038, + 953 + ] + ], + [ + [ + 8111, + 8111 + ], + "mapped", + [ + 8039, + 953 + ] + ], + [ + [ + 8112, + 8113 + ], + "valid" + ], + [ + [ + 8114, + 8114 + ], + "mapped", + [ + 8048, + 953 + ] + ], + [ + [ + 8115, + 8115 + ], + "mapped", + [ + 945, + 953 + ] + ], + [ + [ + 8116, + 8116 + ], + "mapped", + [ + 940, + 953 + ] + ], + [ + [ + 8117, + 8117 + ], + "disallowed" + ], + [ + [ + 8118, + 8118 + ], + "valid" + ], + [ + [ + 8119, + 8119 + ], + "mapped", + [ + 8118, + 953 + ] + ], + [ + [ + 8120, + 8120 + ], + "mapped", + [ + 8112 + ] + ], + [ + [ + 8121, + 8121 + ], + "mapped", + [ + 8113 + ] + ], + [ + [ + 8122, + 8122 + ], + "mapped", + [ + 8048 + ] + ], + [ + [ + 8123, + 8123 + ], + "mapped", + [ + 940 + ] + ], + [ + [ + 8124, + 8124 + ], + "mapped", + [ + 945, + 953 + ] + ], + [ + [ + 8125, + 8125 + ], + "disallowed_STD3_mapped", + [ + 32, + 787 + ] + ], + [ + [ + 8126, + 8126 + ], + "mapped", + [ + 953 + ] + ], + [ + [ + 8127, + 8127 + ], + "disallowed_STD3_mapped", + [ + 32, + 787 + ] + ], + [ + [ + 8128, + 8128 + ], + "disallowed_STD3_mapped", + [ + 32, + 834 + ] + ], + [ + [ + 8129, + 8129 + ], + "disallowed_STD3_mapped", + [ + 32, + 776, + 834 + ] + ], + [ + [ + 8130, + 8130 + ], + "mapped", + [ + 8052, + 953 + ] + ], + [ + [ + 8131, + 8131 + ], + "mapped", + [ + 951, + 953 + ] + ], + [ + [ + 8132, + 8132 + ], + "mapped", + [ + 942, + 953 + ] + ], + [ + [ + 8133, + 8133 + ], + "disallowed" + ], + [ + [ + 8134, + 8134 + ], + "valid" + ], + [ + [ + 8135, + 8135 + ], + "mapped", + [ + 8134, + 953 + ] + ], + [ + [ + 8136, + 8136 + ], + "mapped", + [ + 8050 + ] + ], + [ + [ + 8137, + 8137 + ], + "mapped", + [ + 941 + ] + ], + [ + [ + 8138, + 8138 + ], + "mapped", + [ + 8052 + ] + ], + [ + [ + 8139, + 8139 + ], + "mapped", + [ + 942 + ] + ], + [ + [ + 8140, + 8140 + ], + "mapped", + [ + 951, + 953 + ] + ], + [ + [ + 8141, + 8141 + ], + "disallowed_STD3_mapped", + [ + 32, + 787, + 768 + ] + ], + [ + [ + 8142, + 8142 + ], + "disallowed_STD3_mapped", + [ + 32, + 787, + 769 + ] + ], + [ + [ + 8143, + 8143 + ], + "disallowed_STD3_mapped", + [ + 32, + 787, + 834 + ] + ], + [ + [ + 8144, + 8146 + ], + "valid" + ], + [ + [ + 8147, + 8147 + ], + "mapped", + [ + 912 + ] + ], + [ + [ + 8148, + 8149 + ], + "disallowed" + ], + [ + [ + 8150, + 8151 + ], + "valid" + ], + [ + [ + 8152, + 8152 + ], + "mapped", + [ + 8144 + ] + ], + [ + [ + 8153, + 8153 + ], + "mapped", + [ + 8145 + ] + ], + [ + [ + 8154, + 8154 + ], + "mapped", + [ + 8054 + ] + ], + [ + [ + 8155, + 8155 + ], + "mapped", + [ + 943 + ] + ], + [ + [ + 8156, + 8156 + ], + "disallowed" + ], + [ + [ + 8157, + 8157 + ], + "disallowed_STD3_mapped", + [ + 32, + 788, + 768 + ] + ], + [ + [ + 8158, + 8158 + ], + "disallowed_STD3_mapped", + [ + 32, + 788, + 769 + ] + ], + [ + [ + 8159, + 8159 + ], + "disallowed_STD3_mapped", + [ + 32, + 788, + 834 + ] + ], + [ + [ + 8160, + 8162 + ], + "valid" + ], + [ + [ + 8163, + 8163 + ], + "mapped", + [ + 944 + ] + ], + [ + [ + 8164, + 8167 + ], + "valid" + ], + [ + [ + 8168, + 8168 + ], + "mapped", + [ + 8160 + ] + ], + [ + [ + 8169, + 8169 + ], + "mapped", + [ + 8161 + ] + ], + [ + [ + 8170, + 8170 + ], + "mapped", + [ + 8058 + ] + ], + [ + [ + 8171, + 8171 + ], + "mapped", + [ + 973 + ] + ], + [ + [ + 8172, + 8172 + ], + "mapped", + [ + 8165 + ] + ], + [ + [ + 8173, + 8173 + ], + "disallowed_STD3_mapped", + [ + 32, + 776, + 768 + ] + ], + [ + [ + 8174, + 8174 + ], + "disallowed_STD3_mapped", + [ + 32, + 776, + 769 + ] + ], + [ + [ + 8175, + 8175 + ], + "disallowed_STD3_mapped", + [ + 96 + ] + ], + [ + [ + 8176, + 8177 + ], + "disallowed" + ], + [ + [ + 8178, + 8178 + ], + "mapped", + [ + 8060, + 953 + ] + ], + [ + [ + 8179, + 8179 + ], + "mapped", + [ + 969, + 953 + ] + ], + [ + [ + 8180, + 8180 + ], + "mapped", + [ + 974, + 953 + ] + ], + [ + [ + 8181, + 8181 + ], + "disallowed" + ], + [ + [ + 8182, + 8182 + ], + "valid" + ], + [ + [ + 8183, + 8183 + ], + "mapped", + [ + 8182, + 953 + ] + ], + [ + [ + 8184, + 8184 + ], + "mapped", + [ + 8056 + ] + ], + [ + [ + 8185, + 8185 + ], + "mapped", + [ + 972 + ] + ], + [ + [ + 8186, + 8186 + ], + "mapped", + [ + 8060 + ] + ], + [ + [ + 8187, + 8187 + ], + "mapped", + [ + 974 + ] + ], + [ + [ + 8188, + 8188 + ], + "mapped", + [ + 969, + 953 + ] + ], + [ + [ + 8189, + 8189 + ], + "disallowed_STD3_mapped", + [ + 32, + 769 + ] + ], + [ + [ + 8190, + 8190 + ], + "disallowed_STD3_mapped", + [ + 32, + 788 + ] + ], + [ + [ + 8191, + 8191 + ], + "disallowed" + ], + [ + [ + 8192, + 8202 + ], + "disallowed_STD3_mapped", + [ + 32 + ] + ], + [ + [ + 8203, + 8203 + ], + "ignored" + ], + [ + [ + 8204, + 8205 + ], + "deviation", + [ + ] + ], + [ + [ + 8206, + 8207 + ], + "disallowed" + ], + [ + [ + 8208, + 8208 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8209, + 8209 + ], + "mapped", + [ + 8208 + ] + ], + [ + [ + 8210, + 8214 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8215, + 8215 + ], + "disallowed_STD3_mapped", + [ + 32, + 819 + ] + ], + [ + [ + 8216, + 8227 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8228, + 8230 + ], + "disallowed" + ], + [ + [ + 8231, + 8231 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8232, + 8238 + ], + "disallowed" + ], + [ + [ + 8239, + 8239 + ], + "disallowed_STD3_mapped", + [ + 32 + ] + ], + [ + [ + 8240, + 8242 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8243, + 8243 + ], + "mapped", + [ + 8242, + 8242 + ] + ], + [ + [ + 8244, + 8244 + ], + "mapped", + [ + 8242, + 8242, + 8242 + ] + ], + [ + [ + 8245, + 8245 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8246, + 8246 + ], + "mapped", + [ + 8245, + 8245 + ] + ], + [ + [ + 8247, + 8247 + ], + "mapped", + [ + 8245, + 8245, + 8245 + ] + ], + [ + [ + 8248, + 8251 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8252, + 8252 + ], + "disallowed_STD3_mapped", + [ + 33, + 33 + ] + ], + [ + [ + 8253, + 8253 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8254, + 8254 + ], + "disallowed_STD3_mapped", + [ + 32, + 773 + ] + ], + [ + [ + 8255, + 8262 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8263, + 8263 + ], + "disallowed_STD3_mapped", + [ + 63, + 63 + ] + ], + [ + [ + 8264, + 8264 + ], + "disallowed_STD3_mapped", + [ + 63, + 33 + ] + ], + [ + [ + 8265, + 8265 + ], + "disallowed_STD3_mapped", + [ + 33, + 63 + ] + ], + [ + [ + 8266, + 8269 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8270, + 8274 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8275, + 8276 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8277, + 8278 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8279, + 8279 + ], + "mapped", + [ + 8242, + 8242, + 8242, + 8242 + ] + ], + [ + [ + 8280, + 8286 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8287, + 8287 + ], + "disallowed_STD3_mapped", + [ + 32 + ] + ], + [ + [ + 8288, + 8288 + ], + "ignored" + ], + [ + [ + 8289, + 8291 + ], + "disallowed" + ], + [ + [ + 8292, + 8292 + ], + "ignored" + ], + [ + [ + 8293, + 8293 + ], + "disallowed" + ], + [ + [ + 8294, + 8297 + ], + "disallowed" + ], + [ + [ + 8298, + 8303 + ], + "disallowed" + ], + [ + [ + 8304, + 8304 + ], + "mapped", + [ + 48 + ] + ], + [ + [ + 8305, + 8305 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 8306, + 8307 + ], + "disallowed" + ], + [ + [ + 8308, + 8308 + ], + "mapped", + [ + 52 + ] + ], + [ + [ + 8309, + 8309 + ], + "mapped", + [ + 53 + ] + ], + [ + [ + 8310, + 8310 + ], + "mapped", + [ + 54 + ] + ], + [ + [ + 8311, + 8311 + ], + "mapped", + [ + 55 + ] + ], + [ + [ + 8312, + 8312 + ], + "mapped", + [ + 56 + ] + ], + [ + [ + 8313, + 8313 + ], + "mapped", + [ + 57 + ] + ], + [ + [ + 8314, + 8314 + ], + "disallowed_STD3_mapped", + [ + 43 + ] + ], + [ + [ + 8315, + 8315 + ], + "mapped", + [ + 8722 + ] + ], + [ + [ + 8316, + 8316 + ], + "disallowed_STD3_mapped", + [ + 61 + ] + ], + [ + [ + 8317, + 8317 + ], + "disallowed_STD3_mapped", + [ + 40 + ] + ], + [ + [ + 8318, + 8318 + ], + "disallowed_STD3_mapped", + [ + 41 + ] + ], + [ + [ + 8319, + 8319 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 8320, + 8320 + ], + "mapped", + [ + 48 + ] + ], + [ + [ + 8321, + 8321 + ], + "mapped", + [ + 49 + ] + ], + [ + [ + 8322, + 8322 + ], + "mapped", + [ + 50 + ] + ], + [ + [ + 8323, + 8323 + ], + "mapped", + [ + 51 + ] + ], + [ + [ + 8324, + 8324 + ], + "mapped", + [ + 52 + ] + ], + [ + [ + 8325, + 8325 + ], + "mapped", + [ + 53 + ] + ], + [ + [ + 8326, + 8326 + ], + "mapped", + [ + 54 + ] + ], + [ + [ + 8327, + 8327 + ], + "mapped", + [ + 55 + ] + ], + [ + [ + 8328, + 8328 + ], + "mapped", + [ + 56 + ] + ], + [ + [ + 8329, + 8329 + ], + "mapped", + [ + 57 + ] + ], + [ + [ + 8330, + 8330 + ], + "disallowed_STD3_mapped", + [ + 43 + ] + ], + [ + [ + 8331, + 8331 + ], + "mapped", + [ + 8722 + ] + ], + [ + [ + 8332, + 8332 + ], + "disallowed_STD3_mapped", + [ + 61 + ] + ], + [ + [ + 8333, + 8333 + ], + "disallowed_STD3_mapped", + [ + 40 + ] + ], + [ + [ + 8334, + 8334 + ], + "disallowed_STD3_mapped", + [ + 41 + ] + ], + [ + [ + 8335, + 8335 + ], + "disallowed" + ], + [ + [ + 8336, + 8336 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 8337, + 8337 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 8338, + 8338 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 8339, + 8339 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 8340, + 8340 + ], + "mapped", + [ + 601 + ] + ], + [ + [ + 8341, + 8341 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 8342, + 8342 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 8343, + 8343 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 8344, + 8344 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 8345, + 8345 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 8346, + 8346 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 8347, + 8347 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 8348, + 8348 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 8349, + 8351 + ], + "disallowed" + ], + [ + [ + 8352, + 8359 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8360, + 8360 + ], + "mapped", + [ + 114, + 115 + ] + ], + [ + [ + 8361, + 8362 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8363, + 8363 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8364, + 8364 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8365, + 8367 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8368, + 8369 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8370, + 8373 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8374, + 8376 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8377, + 8377 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8378, + 8378 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8379, + 8381 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8382, + 8382 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8383, + 8399 + ], + "disallowed" + ], + [ + [ + 8400, + 8417 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8418, + 8419 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8420, + 8426 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8427, + 8427 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8428, + 8431 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8432, + 8432 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8433, + 8447 + ], + "disallowed" + ], + [ + [ + 8448, + 8448 + ], + "disallowed_STD3_mapped", + [ + 97, + 47, + 99 + ] + ], + [ + [ + 8449, + 8449 + ], + "disallowed_STD3_mapped", + [ + 97, + 47, + 115 + ] + ], + [ + [ + 8450, + 8450 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 8451, + 8451 + ], + "mapped", + [ + 176, + 99 + ] + ], + [ + [ + 8452, + 8452 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8453, + 8453 + ], + "disallowed_STD3_mapped", + [ + 99, + 47, + 111 + ] + ], + [ + [ + 8454, + 8454 + ], + "disallowed_STD3_mapped", + [ + 99, + 47, + 117 + ] + ], + [ + [ + 8455, + 8455 + ], + "mapped", + [ + 603 + ] + ], + [ + [ + 8456, + 8456 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8457, + 8457 + ], + "mapped", + [ + 176, + 102 + ] + ], + [ + [ + 8458, + 8458 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 8459, + 8462 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 8463, + 8463 + ], + "mapped", + [ + 295 + ] + ], + [ + [ + 8464, + 8465 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 8466, + 8467 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 8468, + 8468 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8469, + 8469 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 8470, + 8470 + ], + "mapped", + [ + 110, + 111 + ] + ], + [ + [ + 8471, + 8472 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8473, + 8473 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 8474, + 8474 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 8475, + 8477 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 8478, + 8479 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8480, + 8480 + ], + "mapped", + [ + 115, + 109 + ] + ], + [ + [ + 8481, + 8481 + ], + "mapped", + [ + 116, + 101, + 108 + ] + ], + [ + [ + 8482, + 8482 + ], + "mapped", + [ + 116, + 109 + ] + ], + [ + [ + 8483, + 8483 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8484, + 8484 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 8485, + 8485 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8486, + 8486 + ], + "mapped", + [ + 969 + ] + ], + [ + [ + 8487, + 8487 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8488, + 8488 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 8489, + 8489 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8490, + 8490 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 8491, + 8491 + ], + "mapped", + [ + 229 + ] + ], + [ + [ + 8492, + 8492 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 8493, + 8493 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 8494, + 8494 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8495, + 8496 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 8497, + 8497 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 8498, + 8498 + ], + "disallowed" + ], + [ + [ + 8499, + 8499 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 8500, + 8500 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 8501, + 8501 + ], + "mapped", + [ + 1488 + ] + ], + [ + [ + 8502, + 8502 + ], + "mapped", + [ + 1489 + ] + ], + [ + [ + 8503, + 8503 + ], + "mapped", + [ + 1490 + ] + ], + [ + [ + 8504, + 8504 + ], + "mapped", + [ + 1491 + ] + ], + [ + [ + 8505, + 8505 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 8506, + 8506 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8507, + 8507 + ], + "mapped", + [ + 102, + 97, + 120 + ] + ], + [ + [ + 8508, + 8508 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 8509, + 8510 + ], + "mapped", + [ + 947 + ] + ], + [ + [ + 8511, + 8511 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 8512, + 8512 + ], + "mapped", + [ + 8721 + ] + ], + [ + [ + 8513, + 8516 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8517, + 8518 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 8519, + 8519 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 8520, + 8520 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 8521, + 8521 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 8522, + 8523 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8524, + 8524 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8525, + 8525 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8526, + 8526 + ], + "valid" + ], + [ + [ + 8527, + 8527 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8528, + 8528 + ], + "mapped", + [ + 49, + 8260, + 55 + ] + ], + [ + [ + 8529, + 8529 + ], + "mapped", + [ + 49, + 8260, + 57 + ] + ], + [ + [ + 8530, + 8530 + ], + "mapped", + [ + 49, + 8260, + 49, + 48 + ] + ], + [ + [ + 8531, + 8531 + ], + "mapped", + [ + 49, + 8260, + 51 + ] + ], + [ + [ + 8532, + 8532 + ], + "mapped", + [ + 50, + 8260, + 51 + ] + ], + [ + [ + 8533, + 8533 + ], + "mapped", + [ + 49, + 8260, + 53 + ] + ], + [ + [ + 8534, + 8534 + ], + "mapped", + [ + 50, + 8260, + 53 + ] + ], + [ + [ + 8535, + 8535 + ], + "mapped", + [ + 51, + 8260, + 53 + ] + ], + [ + [ + 8536, + 8536 + ], + "mapped", + [ + 52, + 8260, + 53 + ] + ], + [ + [ + 8537, + 8537 + ], + "mapped", + [ + 49, + 8260, + 54 + ] + ], + [ + [ + 8538, + 8538 + ], + "mapped", + [ + 53, + 8260, + 54 + ] + ], + [ + [ + 8539, + 8539 + ], + "mapped", + [ + 49, + 8260, + 56 + ] + ], + [ + [ + 8540, + 8540 + ], + "mapped", + [ + 51, + 8260, + 56 + ] + ], + [ + [ + 8541, + 8541 + ], + "mapped", + [ + 53, + 8260, + 56 + ] + ], + [ + [ + 8542, + 8542 + ], + "mapped", + [ + 55, + 8260, + 56 + ] + ], + [ + [ + 8543, + 8543 + ], + "mapped", + [ + 49, + 8260 + ] + ], + [ + [ + 8544, + 8544 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 8545, + 8545 + ], + "mapped", + [ + 105, + 105 + ] + ], + [ + [ + 8546, + 8546 + ], + "mapped", + [ + 105, + 105, + 105 + ] + ], + [ + [ + 8547, + 8547 + ], + "mapped", + [ + 105, + 118 + ] + ], + [ + [ + 8548, + 8548 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 8549, + 8549 + ], + "mapped", + [ + 118, + 105 + ] + ], + [ + [ + 8550, + 8550 + ], + "mapped", + [ + 118, + 105, + 105 + ] + ], + [ + [ + 8551, + 8551 + ], + "mapped", + [ + 118, + 105, + 105, + 105 + ] + ], + [ + [ + 8552, + 8552 + ], + "mapped", + [ + 105, + 120 + ] + ], + [ + [ + 8553, + 8553 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 8554, + 8554 + ], + "mapped", + [ + 120, + 105 + ] + ], + [ + [ + 8555, + 8555 + ], + "mapped", + [ + 120, + 105, + 105 + ] + ], + [ + [ + 8556, + 8556 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 8557, + 8557 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 8558, + 8558 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 8559, + 8559 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 8560, + 8560 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 8561, + 8561 + ], + "mapped", + [ + 105, + 105 + ] + ], + [ + [ + 8562, + 8562 + ], + "mapped", + [ + 105, + 105, + 105 + ] + ], + [ + [ + 8563, + 8563 + ], + "mapped", + [ + 105, + 118 + ] + ], + [ + [ + 8564, + 8564 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 8565, + 8565 + ], + "mapped", + [ + 118, + 105 + ] + ], + [ + [ + 8566, + 8566 + ], + "mapped", + [ + 118, + 105, + 105 + ] + ], + [ + [ + 8567, + 8567 + ], + "mapped", + [ + 118, + 105, + 105, + 105 + ] + ], + [ + [ + 8568, + 8568 + ], + "mapped", + [ + 105, + 120 + ] + ], + [ + [ + 8569, + 8569 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 8570, + 8570 + ], + "mapped", + [ + 120, + 105 + ] + ], + [ + [ + 8571, + 8571 + ], + "mapped", + [ + 120, + 105, + 105 + ] + ], + [ + [ + 8572, + 8572 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 8573, + 8573 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 8574, + 8574 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 8575, + 8575 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 8576, + 8578 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8579, + 8579 + ], + "disallowed" + ], + [ + [ + 8580, + 8580 + ], + "valid" + ], + [ + [ + 8581, + 8584 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8585, + 8585 + ], + "mapped", + [ + 48, + 8260, + 51 + ] + ], + [ + [ + 8586, + 8587 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8588, + 8591 + ], + "disallowed" + ], + [ + [ + 8592, + 8682 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8683, + 8691 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8692, + 8703 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8704, + 8747 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8748, + 8748 + ], + "mapped", + [ + 8747, + 8747 + ] + ], + [ + [ + 8749, + 8749 + ], + "mapped", + [ + 8747, + 8747, + 8747 + ] + ], + [ + [ + 8750, + 8750 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8751, + 8751 + ], + "mapped", + [ + 8750, + 8750 + ] + ], + [ + [ + 8752, + 8752 + ], + "mapped", + [ + 8750, + 8750, + 8750 + ] + ], + [ + [ + 8753, + 8799 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8800, + 8800 + ], + "disallowed_STD3_valid" + ], + [ + [ + 8801, + 8813 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8814, + 8815 + ], + "disallowed_STD3_valid" + ], + [ + [ + 8816, + 8945 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8946, + 8959 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8960, + 8960 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8961, + 8961 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 8962, + 9000 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9001, + 9001 + ], + "mapped", + [ + 12296 + ] + ], + [ + [ + 9002, + 9002 + ], + "mapped", + [ + 12297 + ] + ], + [ + [ + 9003, + 9082 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9083, + 9083 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9084, + 9084 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9085, + 9114 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9115, + 9166 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9167, + 9168 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9169, + 9179 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9180, + 9191 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9192, + 9192 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9193, + 9203 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9204, + 9210 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9211, + 9215 + ], + "disallowed" + ], + [ + [ + 9216, + 9252 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9253, + 9254 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9255, + 9279 + ], + "disallowed" + ], + [ + [ + 9280, + 9290 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9291, + 9311 + ], + "disallowed" + ], + [ + [ + 9312, + 9312 + ], + "mapped", + [ + 49 + ] + ], + [ + [ + 9313, + 9313 + ], + "mapped", + [ + 50 + ] + ], + [ + [ + 9314, + 9314 + ], + "mapped", + [ + 51 + ] + ], + [ + [ + 9315, + 9315 + ], + "mapped", + [ + 52 + ] + ], + [ + [ + 9316, + 9316 + ], + "mapped", + [ + 53 + ] + ], + [ + [ + 9317, + 9317 + ], + "mapped", + [ + 54 + ] + ], + [ + [ + 9318, + 9318 + ], + "mapped", + [ + 55 + ] + ], + [ + [ + 9319, + 9319 + ], + "mapped", + [ + 56 + ] + ], + [ + [ + 9320, + 9320 + ], + "mapped", + [ + 57 + ] + ], + [ + [ + 9321, + 9321 + ], + "mapped", + [ + 49, + 48 + ] + ], + [ + [ + 9322, + 9322 + ], + "mapped", + [ + 49, + 49 + ] + ], + [ + [ + 9323, + 9323 + ], + "mapped", + [ + 49, + 50 + ] + ], + [ + [ + 9324, + 9324 + ], + "mapped", + [ + 49, + 51 + ] + ], + [ + [ + 9325, + 9325 + ], + "mapped", + [ + 49, + 52 + ] + ], + [ + [ + 9326, + 9326 + ], + "mapped", + [ + 49, + 53 + ] + ], + [ + [ + 9327, + 9327 + ], + "mapped", + [ + 49, + 54 + ] + ], + [ + [ + 9328, + 9328 + ], + "mapped", + [ + 49, + 55 + ] + ], + [ + [ + 9329, + 9329 + ], + "mapped", + [ + 49, + 56 + ] + ], + [ + [ + 9330, + 9330 + ], + "mapped", + [ + 49, + 57 + ] + ], + [ + [ + 9331, + 9331 + ], + "mapped", + [ + 50, + 48 + ] + ], + [ + [ + 9332, + 9332 + ], + "disallowed_STD3_mapped", + [ + 40, + 49, + 41 + ] + ], + [ + [ + 9333, + 9333 + ], + "disallowed_STD3_mapped", + [ + 40, + 50, + 41 + ] + ], + [ + [ + 9334, + 9334 + ], + "disallowed_STD3_mapped", + [ + 40, + 51, + 41 + ] + ], + [ + [ + 9335, + 9335 + ], + "disallowed_STD3_mapped", + [ + 40, + 52, + 41 + ] + ], + [ + [ + 9336, + 9336 + ], + "disallowed_STD3_mapped", + [ + 40, + 53, + 41 + ] + ], + [ + [ + 9337, + 9337 + ], + "disallowed_STD3_mapped", + [ + 40, + 54, + 41 + ] + ], + [ + [ + 9338, + 9338 + ], + "disallowed_STD3_mapped", + [ + 40, + 55, + 41 + ] + ], + [ + [ + 9339, + 9339 + ], + "disallowed_STD3_mapped", + [ + 40, + 56, + 41 + ] + ], + [ + [ + 9340, + 9340 + ], + "disallowed_STD3_mapped", + [ + 40, + 57, + 41 + ] + ], + [ + [ + 9341, + 9341 + ], + "disallowed_STD3_mapped", + [ + 40, + 49, + 48, + 41 + ] + ], + [ + [ + 9342, + 9342 + ], + "disallowed_STD3_mapped", + [ + 40, + 49, + 49, + 41 + ] + ], + [ + [ + 9343, + 9343 + ], + "disallowed_STD3_mapped", + [ + 40, + 49, + 50, + 41 + ] + ], + [ + [ + 9344, + 9344 + ], + "disallowed_STD3_mapped", + [ + 40, + 49, + 51, + 41 + ] + ], + [ + [ + 9345, + 9345 + ], + "disallowed_STD3_mapped", + [ + 40, + 49, + 52, + 41 + ] + ], + [ + [ + 9346, + 9346 + ], + "disallowed_STD3_mapped", + [ + 40, + 49, + 53, + 41 + ] + ], + [ + [ + 9347, + 9347 + ], + "disallowed_STD3_mapped", + [ + 40, + 49, + 54, + 41 + ] + ], + [ + [ + 9348, + 9348 + ], + "disallowed_STD3_mapped", + [ + 40, + 49, + 55, + 41 + ] + ], + [ + [ + 9349, + 9349 + ], + "disallowed_STD3_mapped", + [ + 40, + 49, + 56, + 41 + ] + ], + [ + [ + 9350, + 9350 + ], + "disallowed_STD3_mapped", + [ + 40, + 49, + 57, + 41 + ] + ], + [ + [ + 9351, + 9351 + ], + "disallowed_STD3_mapped", + [ + 40, + 50, + 48, + 41 + ] + ], + [ + [ + 9352, + 9371 + ], + "disallowed" + ], + [ + [ + 9372, + 9372 + ], + "disallowed_STD3_mapped", + [ + 40, + 97, + 41 + ] + ], + [ + [ + 9373, + 9373 + ], + "disallowed_STD3_mapped", + [ + 40, + 98, + 41 + ] + ], + [ + [ + 9374, + 9374 + ], + "disallowed_STD3_mapped", + [ + 40, + 99, + 41 + ] + ], + [ + [ + 9375, + 9375 + ], + "disallowed_STD3_mapped", + [ + 40, + 100, + 41 + ] + ], + [ + [ + 9376, + 9376 + ], + "disallowed_STD3_mapped", + [ + 40, + 101, + 41 + ] + ], + [ + [ + 9377, + 9377 + ], + "disallowed_STD3_mapped", + [ + 40, + 102, + 41 + ] + ], + [ + [ + 9378, + 9378 + ], + "disallowed_STD3_mapped", + [ + 40, + 103, + 41 + ] + ], + [ + [ + 9379, + 9379 + ], + "disallowed_STD3_mapped", + [ + 40, + 104, + 41 + ] + ], + [ + [ + 9380, + 9380 + ], + "disallowed_STD3_mapped", + [ + 40, + 105, + 41 + ] + ], + [ + [ + 9381, + 9381 + ], + "disallowed_STD3_mapped", + [ + 40, + 106, + 41 + ] + ], + [ + [ + 9382, + 9382 + ], + "disallowed_STD3_mapped", + [ + 40, + 107, + 41 + ] + ], + [ + [ + 9383, + 9383 + ], + "disallowed_STD3_mapped", + [ + 40, + 108, + 41 + ] + ], + [ + [ + 9384, + 9384 + ], + "disallowed_STD3_mapped", + [ + 40, + 109, + 41 + ] + ], + [ + [ + 9385, + 9385 + ], + "disallowed_STD3_mapped", + [ + 40, + 110, + 41 + ] + ], + [ + [ + 9386, + 9386 + ], + "disallowed_STD3_mapped", + [ + 40, + 111, + 41 + ] + ], + [ + [ + 9387, + 9387 + ], + "disallowed_STD3_mapped", + [ + 40, + 112, + 41 + ] + ], + [ + [ + 9388, + 9388 + ], + "disallowed_STD3_mapped", + [ + 40, + 113, + 41 + ] + ], + [ + [ + 9389, + 9389 + ], + "disallowed_STD3_mapped", + [ + 40, + 114, + 41 + ] + ], + [ + [ + 9390, + 9390 + ], + "disallowed_STD3_mapped", + [ + 40, + 115, + 41 + ] + ], + [ + [ + 9391, + 9391 + ], + "disallowed_STD3_mapped", + [ + 40, + 116, + 41 + ] + ], + [ + [ + 9392, + 9392 + ], + "disallowed_STD3_mapped", + [ + 40, + 117, + 41 + ] + ], + [ + [ + 9393, + 9393 + ], + "disallowed_STD3_mapped", + [ + 40, + 118, + 41 + ] + ], + [ + [ + 9394, + 9394 + ], + "disallowed_STD3_mapped", + [ + 40, + 119, + 41 + ] + ], + [ + [ + 9395, + 9395 + ], + "disallowed_STD3_mapped", + [ + 40, + 120, + 41 + ] + ], + [ + [ + 9396, + 9396 + ], + "disallowed_STD3_mapped", + [ + 40, + 121, + 41 + ] + ], + [ + [ + 9397, + 9397 + ], + "disallowed_STD3_mapped", + [ + 40, + 122, + 41 + ] + ], + [ + [ + 9398, + 9398 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 9399, + 9399 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 9400, + 9400 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 9401, + 9401 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 9402, + 9402 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 9403, + 9403 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 9404, + 9404 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 9405, + 9405 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 9406, + 9406 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 9407, + 9407 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 9408, + 9408 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 9409, + 9409 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 9410, + 9410 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 9411, + 9411 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 9412, + 9412 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 9413, + 9413 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 9414, + 9414 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 9415, + 9415 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 9416, + 9416 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 9417, + 9417 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 9418, + 9418 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 9419, + 9419 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 9420, + 9420 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 9421, + 9421 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 9422, + 9422 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 9423, + 9423 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 9424, + 9424 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 9425, + 9425 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 9426, + 9426 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 9427, + 9427 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 9428, + 9428 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 9429, + 9429 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 9430, + 9430 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 9431, + 9431 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 9432, + 9432 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 9433, + 9433 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 9434, + 9434 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 9435, + 9435 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 9436, + 9436 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 9437, + 9437 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 9438, + 9438 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 9439, + 9439 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 9440, + 9440 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 9441, + 9441 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 9442, + 9442 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 9443, + 9443 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 9444, + 9444 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 9445, + 9445 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 9446, + 9446 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 9447, + 9447 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 9448, + 9448 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 9449, + 9449 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 9450, + 9450 + ], + "mapped", + [ + 48 + ] + ], + [ + [ + 9451, + 9470 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9471, + 9471 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9472, + 9621 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9622, + 9631 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9632, + 9711 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9712, + 9719 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9720, + 9727 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9728, + 9747 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9748, + 9749 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9750, + 9751 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9752, + 9752 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9753, + 9753 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9754, + 9839 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9840, + 9841 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9842, + 9853 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9854, + 9855 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9856, + 9865 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9866, + 9873 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9874, + 9884 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9885, + 9885 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9886, + 9887 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9888, + 9889 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9890, + 9905 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9906, + 9906 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9907, + 9916 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9917, + 9919 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9920, + 9923 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9924, + 9933 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9934, + 9934 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9935, + 9953 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9954, + 9954 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9955, + 9955 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9956, + 9959 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9960, + 9983 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9984, + 9984 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9985, + 9988 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9989, + 9989 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9990, + 9993 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9994, + 9995 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 9996, + 10023 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10024, + 10024 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10025, + 10059 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10060, + 10060 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10061, + 10061 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10062, + 10062 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10063, + 10066 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10067, + 10069 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10070, + 10070 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10071, + 10071 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10072, + 10078 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10079, + 10080 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10081, + 10087 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10088, + 10101 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10102, + 10132 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10133, + 10135 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10136, + 10159 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10160, + 10160 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10161, + 10174 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10175, + 10175 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10176, + 10182 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10183, + 10186 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10187, + 10187 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10188, + 10188 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10189, + 10189 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10190, + 10191 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10192, + 10219 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10220, + 10223 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10224, + 10239 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10240, + 10495 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10496, + 10763 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10764, + 10764 + ], + "mapped", + [ + 8747, + 8747, + 8747, + 8747 + ] + ], + [ + [ + 10765, + 10867 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10868, + 10868 + ], + "disallowed_STD3_mapped", + [ + 58, + 58, + 61 + ] + ], + [ + [ + 10869, + 10869 + ], + "disallowed_STD3_mapped", + [ + 61, + 61 + ] + ], + [ + [ + 10870, + 10870 + ], + "disallowed_STD3_mapped", + [ + 61, + 61, + 61 + ] + ], + [ + [ + 10871, + 10971 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 10972, + 10972 + ], + "mapped", + [ + 10973, + 824 + ] + ], + [ + [ + 10973, + 11007 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11008, + 11021 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11022, + 11027 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11028, + 11034 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11035, + 11039 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11040, + 11043 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11044, + 11084 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11085, + 11087 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11088, + 11092 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11093, + 11097 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11098, + 11123 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11124, + 11125 + ], + "disallowed" + ], + [ + [ + 11126, + 11157 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11158, + 11159 + ], + "disallowed" + ], + [ + [ + 11160, + 11193 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11194, + 11196 + ], + "disallowed" + ], + [ + [ + 11197, + 11208 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11209, + 11209 + ], + "disallowed" + ], + [ + [ + 11210, + 11217 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11218, + 11243 + ], + "disallowed" + ], + [ + [ + 11244, + 11247 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11248, + 11263 + ], + "disallowed" + ], + [ + [ + 11264, + 11264 + ], + "mapped", + [ + 11312 + ] + ], + [ + [ + 11265, + 11265 + ], + "mapped", + [ + 11313 + ] + ], + [ + [ + 11266, + 11266 + ], + "mapped", + [ + 11314 + ] + ], + [ + [ + 11267, + 11267 + ], + "mapped", + [ + 11315 + ] + ], + [ + [ + 11268, + 11268 + ], + "mapped", + [ + 11316 + ] + ], + [ + [ + 11269, + 11269 + ], + "mapped", + [ + 11317 + ] + ], + [ + [ + 11270, + 11270 + ], + "mapped", + [ + 11318 + ] + ], + [ + [ + 11271, + 11271 + ], + "mapped", + [ + 11319 + ] + ], + [ + [ + 11272, + 11272 + ], + "mapped", + [ + 11320 + ] + ], + [ + [ + 11273, + 11273 + ], + "mapped", + [ + 11321 + ] + ], + [ + [ + 11274, + 11274 + ], + "mapped", + [ + 11322 + ] + ], + [ + [ + 11275, + 11275 + ], + "mapped", + [ + 11323 + ] + ], + [ + [ + 11276, + 11276 + ], + "mapped", + [ + 11324 + ] + ], + [ + [ + 11277, + 11277 + ], + "mapped", + [ + 11325 + ] + ], + [ + [ + 11278, + 11278 + ], + "mapped", + [ + 11326 + ] + ], + [ + [ + 11279, + 11279 + ], + "mapped", + [ + 11327 + ] + ], + [ + [ + 11280, + 11280 + ], + "mapped", + [ + 11328 + ] + ], + [ + [ + 11281, + 11281 + ], + "mapped", + [ + 11329 + ] + ], + [ + [ + 11282, + 11282 + ], + "mapped", + [ + 11330 + ] + ], + [ + [ + 11283, + 11283 + ], + "mapped", + [ + 11331 + ] + ], + [ + [ + 11284, + 11284 + ], + "mapped", + [ + 11332 + ] + ], + [ + [ + 11285, + 11285 + ], + "mapped", + [ + 11333 + ] + ], + [ + [ + 11286, + 11286 + ], + "mapped", + [ + 11334 + ] + ], + [ + [ + 11287, + 11287 + ], + "mapped", + [ + 11335 + ] + ], + [ + [ + 11288, + 11288 + ], + "mapped", + [ + 11336 + ] + ], + [ + [ + 11289, + 11289 + ], + "mapped", + [ + 11337 + ] + ], + [ + [ + 11290, + 11290 + ], + "mapped", + [ + 11338 + ] + ], + [ + [ + 11291, + 11291 + ], + "mapped", + [ + 11339 + ] + ], + [ + [ + 11292, + 11292 + ], + "mapped", + [ + 11340 + ] + ], + [ + [ + 11293, + 11293 + ], + "mapped", + [ + 11341 + ] + ], + [ + [ + 11294, + 11294 + ], + "mapped", + [ + 11342 + ] + ], + [ + [ + 11295, + 11295 + ], + "mapped", + [ + 11343 + ] + ], + [ + [ + 11296, + 11296 + ], + "mapped", + [ + 11344 + ] + ], + [ + [ + 11297, + 11297 + ], + "mapped", + [ + 11345 + ] + ], + [ + [ + 11298, + 11298 + ], + "mapped", + [ + 11346 + ] + ], + [ + [ + 11299, + 11299 + ], + "mapped", + [ + 11347 + ] + ], + [ + [ + 11300, + 11300 + ], + "mapped", + [ + 11348 + ] + ], + [ + [ + 11301, + 11301 + ], + "mapped", + [ + 11349 + ] + ], + [ + [ + 11302, + 11302 + ], + "mapped", + [ + 11350 + ] + ], + [ + [ + 11303, + 11303 + ], + "mapped", + [ + 11351 + ] + ], + [ + [ + 11304, + 11304 + ], + "mapped", + [ + 11352 + ] + ], + [ + [ + 11305, + 11305 + ], + "mapped", + [ + 11353 + ] + ], + [ + [ + 11306, + 11306 + ], + "mapped", + [ + 11354 + ] + ], + [ + [ + 11307, + 11307 + ], + "mapped", + [ + 11355 + ] + ], + [ + [ + 11308, + 11308 + ], + "mapped", + [ + 11356 + ] + ], + [ + [ + 11309, + 11309 + ], + "mapped", + [ + 11357 + ] + ], + [ + [ + 11310, + 11310 + ], + "mapped", + [ + 11358 + ] + ], + [ + [ + 11311, + 11311 + ], + "disallowed" + ], + [ + [ + 11312, + 11358 + ], + "valid" + ], + [ + [ + 11359, + 11359 + ], + "disallowed" + ], + [ + [ + 11360, + 11360 + ], + "mapped", + [ + 11361 + ] + ], + [ + [ + 11361, + 11361 + ], + "valid" + ], + [ + [ + 11362, + 11362 + ], + "mapped", + [ + 619 + ] + ], + [ + [ + 11363, + 11363 + ], + "mapped", + [ + 7549 + ] + ], + [ + [ + 11364, + 11364 + ], + "mapped", + [ + 637 + ] + ], + [ + [ + 11365, + 11366 + ], + "valid" + ], + [ + [ + 11367, + 11367 + ], + "mapped", + [ + 11368 + ] + ], + [ + [ + 11368, + 11368 + ], + "valid" + ], + [ + [ + 11369, + 11369 + ], + "mapped", + [ + 11370 + ] + ], + [ + [ + 11370, + 11370 + ], + "valid" + ], + [ + [ + 11371, + 11371 + ], + "mapped", + [ + 11372 + ] + ], + [ + [ + 11372, + 11372 + ], + "valid" + ], + [ + [ + 11373, + 11373 + ], + "mapped", + [ + 593 + ] + ], + [ + [ + 11374, + 11374 + ], + "mapped", + [ + 625 + ] + ], + [ + [ + 11375, + 11375 + ], + "mapped", + [ + 592 + ] + ], + [ + [ + 11376, + 11376 + ], + "mapped", + [ + 594 + ] + ], + [ + [ + 11377, + 11377 + ], + "valid" + ], + [ + [ + 11378, + 11378 + ], + "mapped", + [ + 11379 + ] + ], + [ + [ + 11379, + 11379 + ], + "valid" + ], + [ + [ + 11380, + 11380 + ], + "valid" + ], + [ + [ + 11381, + 11381 + ], + "mapped", + [ + 11382 + ] + ], + [ + [ + 11382, + 11383 + ], + "valid" + ], + [ + [ + 11384, + 11387 + ], + "valid" + ], + [ + [ + 11388, + 11388 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 11389, + 11389 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 11390, + 11390 + ], + "mapped", + [ + 575 + ] + ], + [ + [ + 11391, + 11391 + ], + "mapped", + [ + 576 + ] + ], + [ + [ + 11392, + 11392 + ], + "mapped", + [ + 11393 + ] + ], + [ + [ + 11393, + 11393 + ], + "valid" + ], + [ + [ + 11394, + 11394 + ], + "mapped", + [ + 11395 + ] + ], + [ + [ + 11395, + 11395 + ], + "valid" + ], + [ + [ + 11396, + 11396 + ], + "mapped", + [ + 11397 + ] + ], + [ + [ + 11397, + 11397 + ], + "valid" + ], + [ + [ + 11398, + 11398 + ], + "mapped", + [ + 11399 + ] + ], + [ + [ + 11399, + 11399 + ], + "valid" + ], + [ + [ + 11400, + 11400 + ], + "mapped", + [ + 11401 + ] + ], + [ + [ + 11401, + 11401 + ], + "valid" + ], + [ + [ + 11402, + 11402 + ], + "mapped", + [ + 11403 + ] + ], + [ + [ + 11403, + 11403 + ], + "valid" + ], + [ + [ + 11404, + 11404 + ], + "mapped", + [ + 11405 + ] + ], + [ + [ + 11405, + 11405 + ], + "valid" + ], + [ + [ + 11406, + 11406 + ], + "mapped", + [ + 11407 + ] + ], + [ + [ + 11407, + 11407 + ], + "valid" + ], + [ + [ + 11408, + 11408 + ], + "mapped", + [ + 11409 + ] + ], + [ + [ + 11409, + 11409 + ], + "valid" + ], + [ + [ + 11410, + 11410 + ], + "mapped", + [ + 11411 + ] + ], + [ + [ + 11411, + 11411 + ], + "valid" + ], + [ + [ + 11412, + 11412 + ], + "mapped", + [ + 11413 + ] + ], + [ + [ + 11413, + 11413 + ], + "valid" + ], + [ + [ + 11414, + 11414 + ], + "mapped", + [ + 11415 + ] + ], + [ + [ + 11415, + 11415 + ], + "valid" + ], + [ + [ + 11416, + 11416 + ], + "mapped", + [ + 11417 + ] + ], + [ + [ + 11417, + 11417 + ], + "valid" + ], + [ + [ + 11418, + 11418 + ], + "mapped", + [ + 11419 + ] + ], + [ + [ + 11419, + 11419 + ], + "valid" + ], + [ + [ + 11420, + 11420 + ], + "mapped", + [ + 11421 + ] + ], + [ + [ + 11421, + 11421 + ], + "valid" + ], + [ + [ + 11422, + 11422 + ], + "mapped", + [ + 11423 + ] + ], + [ + [ + 11423, + 11423 + ], + "valid" + ], + [ + [ + 11424, + 11424 + ], + "mapped", + [ + 11425 + ] + ], + [ + [ + 11425, + 11425 + ], + "valid" + ], + [ + [ + 11426, + 11426 + ], + "mapped", + [ + 11427 + ] + ], + [ + [ + 11427, + 11427 + ], + "valid" + ], + [ + [ + 11428, + 11428 + ], + "mapped", + [ + 11429 + ] + ], + [ + [ + 11429, + 11429 + ], + "valid" + ], + [ + [ + 11430, + 11430 + ], + "mapped", + [ + 11431 + ] + ], + [ + [ + 11431, + 11431 + ], + "valid" + ], + [ + [ + 11432, + 11432 + ], + "mapped", + [ + 11433 + ] + ], + [ + [ + 11433, + 11433 + ], + "valid" + ], + [ + [ + 11434, + 11434 + ], + "mapped", + [ + 11435 + ] + ], + [ + [ + 11435, + 11435 + ], + "valid" + ], + [ + [ + 11436, + 11436 + ], + "mapped", + [ + 11437 + ] + ], + [ + [ + 11437, + 11437 + ], + "valid" + ], + [ + [ + 11438, + 11438 + ], + "mapped", + [ + 11439 + ] + ], + [ + [ + 11439, + 11439 + ], + "valid" + ], + [ + [ + 11440, + 11440 + ], + "mapped", + [ + 11441 + ] + ], + [ + [ + 11441, + 11441 + ], + "valid" + ], + [ + [ + 11442, + 11442 + ], + "mapped", + [ + 11443 + ] + ], + [ + [ + 11443, + 11443 + ], + "valid" + ], + [ + [ + 11444, + 11444 + ], + "mapped", + [ + 11445 + ] + ], + [ + [ + 11445, + 11445 + ], + "valid" + ], + [ + [ + 11446, + 11446 + ], + "mapped", + [ + 11447 + ] + ], + [ + [ + 11447, + 11447 + ], + "valid" + ], + [ + [ + 11448, + 11448 + ], + "mapped", + [ + 11449 + ] + ], + [ + [ + 11449, + 11449 + ], + "valid" + ], + [ + [ + 11450, + 11450 + ], + "mapped", + [ + 11451 + ] + ], + [ + [ + 11451, + 11451 + ], + "valid" + ], + [ + [ + 11452, + 11452 + ], + "mapped", + [ + 11453 + ] + ], + [ + [ + 11453, + 11453 + ], + "valid" + ], + [ + [ + 11454, + 11454 + ], + "mapped", + [ + 11455 + ] + ], + [ + [ + 11455, + 11455 + ], + "valid" + ], + [ + [ + 11456, + 11456 + ], + "mapped", + [ + 11457 + ] + ], + [ + [ + 11457, + 11457 + ], + "valid" + ], + [ + [ + 11458, + 11458 + ], + "mapped", + [ + 11459 + ] + ], + [ + [ + 11459, + 11459 + ], + "valid" + ], + [ + [ + 11460, + 11460 + ], + "mapped", + [ + 11461 + ] + ], + [ + [ + 11461, + 11461 + ], + "valid" + ], + [ + [ + 11462, + 11462 + ], + "mapped", + [ + 11463 + ] + ], + [ + [ + 11463, + 11463 + ], + "valid" + ], + [ + [ + 11464, + 11464 + ], + "mapped", + [ + 11465 + ] + ], + [ + [ + 11465, + 11465 + ], + "valid" + ], + [ + [ + 11466, + 11466 + ], + "mapped", + [ + 11467 + ] + ], + [ + [ + 11467, + 11467 + ], + "valid" + ], + [ + [ + 11468, + 11468 + ], + "mapped", + [ + 11469 + ] + ], + [ + [ + 11469, + 11469 + ], + "valid" + ], + [ + [ + 11470, + 11470 + ], + "mapped", + [ + 11471 + ] + ], + [ + [ + 11471, + 11471 + ], + "valid" + ], + [ + [ + 11472, + 11472 + ], + "mapped", + [ + 11473 + ] + ], + [ + [ + 11473, + 11473 + ], + "valid" + ], + [ + [ + 11474, + 11474 + ], + "mapped", + [ + 11475 + ] + ], + [ + [ + 11475, + 11475 + ], + "valid" + ], + [ + [ + 11476, + 11476 + ], + "mapped", + [ + 11477 + ] + ], + [ + [ + 11477, + 11477 + ], + "valid" + ], + [ + [ + 11478, + 11478 + ], + "mapped", + [ + 11479 + ] + ], + [ + [ + 11479, + 11479 + ], + "valid" + ], + [ + [ + 11480, + 11480 + ], + "mapped", + [ + 11481 + ] + ], + [ + [ + 11481, + 11481 + ], + "valid" + ], + [ + [ + 11482, + 11482 + ], + "mapped", + [ + 11483 + ] + ], + [ + [ + 11483, + 11483 + ], + "valid" + ], + [ + [ + 11484, + 11484 + ], + "mapped", + [ + 11485 + ] + ], + [ + [ + 11485, + 11485 + ], + "valid" + ], + [ + [ + 11486, + 11486 + ], + "mapped", + [ + 11487 + ] + ], + [ + [ + 11487, + 11487 + ], + "valid" + ], + [ + [ + 11488, + 11488 + ], + "mapped", + [ + 11489 + ] + ], + [ + [ + 11489, + 11489 + ], + "valid" + ], + [ + [ + 11490, + 11490 + ], + "mapped", + [ + 11491 + ] + ], + [ + [ + 11491, + 11492 + ], + "valid" + ], + [ + [ + 11493, + 11498 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11499, + 11499 + ], + "mapped", + [ + 11500 + ] + ], + [ + [ + 11500, + 11500 + ], + "valid" + ], + [ + [ + 11501, + 11501 + ], + "mapped", + [ + 11502 + ] + ], + [ + [ + 11502, + 11505 + ], + "valid" + ], + [ + [ + 11506, + 11506 + ], + "mapped", + [ + 11507 + ] + ], + [ + [ + 11507, + 11507 + ], + "valid" + ], + [ + [ + 11508, + 11512 + ], + "disallowed" + ], + [ + [ + 11513, + 11519 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11520, + 11557 + ], + "valid" + ], + [ + [ + 11558, + 11558 + ], + "disallowed" + ], + [ + [ + 11559, + 11559 + ], + "valid" + ], + [ + [ + 11560, + 11564 + ], + "disallowed" + ], + [ + [ + 11565, + 11565 + ], + "valid" + ], + [ + [ + 11566, + 11567 + ], + "disallowed" + ], + [ + [ + 11568, + 11621 + ], + "valid" + ], + [ + [ + 11622, + 11623 + ], + "valid" + ], + [ + [ + 11624, + 11630 + ], + "disallowed" + ], + [ + [ + 11631, + 11631 + ], + "mapped", + [ + 11617 + ] + ], + [ + [ + 11632, + 11632 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11633, + 11646 + ], + "disallowed" + ], + [ + [ + 11647, + 11647 + ], + "valid" + ], + [ + [ + 11648, + 11670 + ], + "valid" + ], + [ + [ + 11671, + 11679 + ], + "disallowed" + ], + [ + [ + 11680, + 11686 + ], + "valid" + ], + [ + [ + 11687, + 11687 + ], + "disallowed" + ], + [ + [ + 11688, + 11694 + ], + "valid" + ], + [ + [ + 11695, + 11695 + ], + "disallowed" + ], + [ + [ + 11696, + 11702 + ], + "valid" + ], + [ + [ + 11703, + 11703 + ], + "disallowed" + ], + [ + [ + 11704, + 11710 + ], + "valid" + ], + [ + [ + 11711, + 11711 + ], + "disallowed" + ], + [ + [ + 11712, + 11718 + ], + "valid" + ], + [ + [ + 11719, + 11719 + ], + "disallowed" + ], + [ + [ + 11720, + 11726 + ], + "valid" + ], + [ + [ + 11727, + 11727 + ], + "disallowed" + ], + [ + [ + 11728, + 11734 + ], + "valid" + ], + [ + [ + 11735, + 11735 + ], + "disallowed" + ], + [ + [ + 11736, + 11742 + ], + "valid" + ], + [ + [ + 11743, + 11743 + ], + "disallowed" + ], + [ + [ + 11744, + 11775 + ], + "valid" + ], + [ + [ + 11776, + 11799 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11800, + 11803 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11804, + 11805 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11806, + 11822 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11823, + 11823 + ], + "valid" + ], + [ + [ + 11824, + 11824 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11825, + 11825 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11826, + 11835 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11836, + 11842 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11843, + 11903 + ], + "disallowed" + ], + [ + [ + 11904, + 11929 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11930, + 11930 + ], + "disallowed" + ], + [ + [ + 11931, + 11934 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 11935, + 11935 + ], + "mapped", + [ + 27597 + ] + ], + [ + [ + 11936, + 12018 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 12019, + 12019 + ], + "mapped", + [ + 40863 + ] + ], + [ + [ + 12020, + 12031 + ], + "disallowed" + ], + [ + [ + 12032, + 12032 + ], + "mapped", + [ + 19968 + ] + ], + [ + [ + 12033, + 12033 + ], + "mapped", + [ + 20008 + ] + ], + [ + [ + 12034, + 12034 + ], + "mapped", + [ + 20022 + ] + ], + [ + [ + 12035, + 12035 + ], + "mapped", + [ + 20031 + ] + ], + [ + [ + 12036, + 12036 + ], + "mapped", + [ + 20057 + ] + ], + [ + [ + 12037, + 12037 + ], + "mapped", + [ + 20101 + ] + ], + [ + [ + 12038, + 12038 + ], + "mapped", + [ + 20108 + ] + ], + [ + [ + 12039, + 12039 + ], + "mapped", + [ + 20128 + ] + ], + [ + [ + 12040, + 12040 + ], + "mapped", + [ + 20154 + ] + ], + [ + [ + 12041, + 12041 + ], + "mapped", + [ + 20799 + ] + ], + [ + [ + 12042, + 12042 + ], + "mapped", + [ + 20837 + ] + ], + [ + [ + 12043, + 12043 + ], + "mapped", + [ + 20843 + ] + ], + [ + [ + 12044, + 12044 + ], + "mapped", + [ + 20866 + ] + ], + [ + [ + 12045, + 12045 + ], + "mapped", + [ + 20886 + ] + ], + [ + [ + 12046, + 12046 + ], + "mapped", + [ + 20907 + ] + ], + [ + [ + 12047, + 12047 + ], + "mapped", + [ + 20960 + ] + ], + [ + [ + 12048, + 12048 + ], + "mapped", + [ + 20981 + ] + ], + [ + [ + 12049, + 12049 + ], + "mapped", + [ + 20992 + ] + ], + [ + [ + 12050, + 12050 + ], + "mapped", + [ + 21147 + ] + ], + [ + [ + 12051, + 12051 + ], + "mapped", + [ + 21241 + ] + ], + [ + [ + 12052, + 12052 + ], + "mapped", + [ + 21269 + ] + ], + [ + [ + 12053, + 12053 + ], + "mapped", + [ + 21274 + ] + ], + [ + [ + 12054, + 12054 + ], + "mapped", + [ + 21304 + ] + ], + [ + [ + 12055, + 12055 + ], + "mapped", + [ + 21313 + ] + ], + [ + [ + 12056, + 12056 + ], + "mapped", + [ + 21340 + ] + ], + [ + [ + 12057, + 12057 + ], + "mapped", + [ + 21353 + ] + ], + [ + [ + 12058, + 12058 + ], + "mapped", + [ + 21378 + ] + ], + [ + [ + 12059, + 12059 + ], + "mapped", + [ + 21430 + ] + ], + [ + [ + 12060, + 12060 + ], + "mapped", + [ + 21448 + ] + ], + [ + [ + 12061, + 12061 + ], + "mapped", + [ + 21475 + ] + ], + [ + [ + 12062, + 12062 + ], + "mapped", + [ + 22231 + ] + ], + [ + [ + 12063, + 12063 + ], + "mapped", + [ + 22303 + ] + ], + [ + [ + 12064, + 12064 + ], + "mapped", + [ + 22763 + ] + ], + [ + [ + 12065, + 12065 + ], + "mapped", + [ + 22786 + ] + ], + [ + [ + 12066, + 12066 + ], + "mapped", + [ + 22794 + ] + ], + [ + [ + 12067, + 12067 + ], + "mapped", + [ + 22805 + ] + ], + [ + [ + 12068, + 12068 + ], + "mapped", + [ + 22823 + ] + ], + [ + [ + 12069, + 12069 + ], + "mapped", + [ + 22899 + ] + ], + [ + [ + 12070, + 12070 + ], + "mapped", + [ + 23376 + ] + ], + [ + [ + 12071, + 12071 + ], + "mapped", + [ + 23424 + ] + ], + [ + [ + 12072, + 12072 + ], + "mapped", + [ + 23544 + ] + ], + [ + [ + 12073, + 12073 + ], + "mapped", + [ + 23567 + ] + ], + [ + [ + 12074, + 12074 + ], + "mapped", + [ + 23586 + ] + ], + [ + [ + 12075, + 12075 + ], + "mapped", + [ + 23608 + ] + ], + [ + [ + 12076, + 12076 + ], + "mapped", + [ + 23662 + ] + ], + [ + [ + 12077, + 12077 + ], + "mapped", + [ + 23665 + ] + ], + [ + [ + 12078, + 12078 + ], + "mapped", + [ + 24027 + ] + ], + [ + [ + 12079, + 12079 + ], + "mapped", + [ + 24037 + ] + ], + [ + [ + 12080, + 12080 + ], + "mapped", + [ + 24049 + ] + ], + [ + [ + 12081, + 12081 + ], + "mapped", + [ + 24062 + ] + ], + [ + [ + 12082, + 12082 + ], + "mapped", + [ + 24178 + ] + ], + [ + [ + 12083, + 12083 + ], + "mapped", + [ + 24186 + ] + ], + [ + [ + 12084, + 12084 + ], + "mapped", + [ + 24191 + ] + ], + [ + [ + 12085, + 12085 + ], + "mapped", + [ + 24308 + ] + ], + [ + [ + 12086, + 12086 + ], + "mapped", + [ + 24318 + ] + ], + [ + [ + 12087, + 12087 + ], + "mapped", + [ + 24331 + ] + ], + [ + [ + 12088, + 12088 + ], + "mapped", + [ + 24339 + ] + ], + [ + [ + 12089, + 12089 + ], + "mapped", + [ + 24400 + ] + ], + [ + [ + 12090, + 12090 + ], + "mapped", + [ + 24417 + ] + ], + [ + [ + 12091, + 12091 + ], + "mapped", + [ + 24435 + ] + ], + [ + [ + 12092, + 12092 + ], + "mapped", + [ + 24515 + ] + ], + [ + [ + 12093, + 12093 + ], + "mapped", + [ + 25096 + ] + ], + [ + [ + 12094, + 12094 + ], + "mapped", + [ + 25142 + ] + ], + [ + [ + 12095, + 12095 + ], + "mapped", + [ + 25163 + ] + ], + [ + [ + 12096, + 12096 + ], + "mapped", + [ + 25903 + ] + ], + [ + [ + 12097, + 12097 + ], + "mapped", + [ + 25908 + ] + ], + [ + [ + 12098, + 12098 + ], + "mapped", + [ + 25991 + ] + ], + [ + [ + 12099, + 12099 + ], + "mapped", + [ + 26007 + ] + ], + [ + [ + 12100, + 12100 + ], + "mapped", + [ + 26020 + ] + ], + [ + [ + 12101, + 12101 + ], + "mapped", + [ + 26041 + ] + ], + [ + [ + 12102, + 12102 + ], + "mapped", + [ + 26080 + ] + ], + [ + [ + 12103, + 12103 + ], + "mapped", + [ + 26085 + ] + ], + [ + [ + 12104, + 12104 + ], + "mapped", + [ + 26352 + ] + ], + [ + [ + 12105, + 12105 + ], + "mapped", + [ + 26376 + ] + ], + [ + [ + 12106, + 12106 + ], + "mapped", + [ + 26408 + ] + ], + [ + [ + 12107, + 12107 + ], + "mapped", + [ + 27424 + ] + ], + [ + [ + 12108, + 12108 + ], + "mapped", + [ + 27490 + ] + ], + [ + [ + 12109, + 12109 + ], + "mapped", + [ + 27513 + ] + ], + [ + [ + 12110, + 12110 + ], + "mapped", + [ + 27571 + ] + ], + [ + [ + 12111, + 12111 + ], + "mapped", + [ + 27595 + ] + ], + [ + [ + 12112, + 12112 + ], + "mapped", + [ + 27604 + ] + ], + [ + [ + 12113, + 12113 + ], + "mapped", + [ + 27611 + ] + ], + [ + [ + 12114, + 12114 + ], + "mapped", + [ + 27663 + ] + ], + [ + [ + 12115, + 12115 + ], + "mapped", + [ + 27668 + ] + ], + [ + [ + 12116, + 12116 + ], + "mapped", + [ + 27700 + ] + ], + [ + [ + 12117, + 12117 + ], + "mapped", + [ + 28779 + ] + ], + [ + [ + 12118, + 12118 + ], + "mapped", + [ + 29226 + ] + ], + [ + [ + 12119, + 12119 + ], + "mapped", + [ + 29238 + ] + ], + [ + [ + 12120, + 12120 + ], + "mapped", + [ + 29243 + ] + ], + [ + [ + 12121, + 12121 + ], + "mapped", + [ + 29247 + ] + ], + [ + [ + 12122, + 12122 + ], + "mapped", + [ + 29255 + ] + ], + [ + [ + 12123, + 12123 + ], + "mapped", + [ + 29273 + ] + ], + [ + [ + 12124, + 12124 + ], + "mapped", + [ + 29275 + ] + ], + [ + [ + 12125, + 12125 + ], + "mapped", + [ + 29356 + ] + ], + [ + [ + 12126, + 12126 + ], + "mapped", + [ + 29572 + ] + ], + [ + [ + 12127, + 12127 + ], + "mapped", + [ + 29577 + ] + ], + [ + [ + 12128, + 12128 + ], + "mapped", + [ + 29916 + ] + ], + [ + [ + 12129, + 12129 + ], + "mapped", + [ + 29926 + ] + ], + [ + [ + 12130, + 12130 + ], + "mapped", + [ + 29976 + ] + ], + [ + [ + 12131, + 12131 + ], + "mapped", + [ + 29983 + ] + ], + [ + [ + 12132, + 12132 + ], + "mapped", + [ + 29992 + ] + ], + [ + [ + 12133, + 12133 + ], + "mapped", + [ + 30000 + ] + ], + [ + [ + 12134, + 12134 + ], + "mapped", + [ + 30091 + ] + ], + [ + [ + 12135, + 12135 + ], + "mapped", + [ + 30098 + ] + ], + [ + [ + 12136, + 12136 + ], + "mapped", + [ + 30326 + ] + ], + [ + [ + 12137, + 12137 + ], + "mapped", + [ + 30333 + ] + ], + [ + [ + 12138, + 12138 + ], + "mapped", + [ + 30382 + ] + ], + [ + [ + 12139, + 12139 + ], + "mapped", + [ + 30399 + ] + ], + [ + [ + 12140, + 12140 + ], + "mapped", + [ + 30446 + ] + ], + [ + [ + 12141, + 12141 + ], + "mapped", + [ + 30683 + ] + ], + [ + [ + 12142, + 12142 + ], + "mapped", + [ + 30690 + ] + ], + [ + [ + 12143, + 12143 + ], + "mapped", + [ + 30707 + ] + ], + [ + [ + 12144, + 12144 + ], + "mapped", + [ + 31034 + ] + ], + [ + [ + 12145, + 12145 + ], + "mapped", + [ + 31160 + ] + ], + [ + [ + 12146, + 12146 + ], + "mapped", + [ + 31166 + ] + ], + [ + [ + 12147, + 12147 + ], + "mapped", + [ + 31348 + ] + ], + [ + [ + 12148, + 12148 + ], + "mapped", + [ + 31435 + ] + ], + [ + [ + 12149, + 12149 + ], + "mapped", + [ + 31481 + ] + ], + [ + [ + 12150, + 12150 + ], + "mapped", + [ + 31859 + ] + ], + [ + [ + 12151, + 12151 + ], + "mapped", + [ + 31992 + ] + ], + [ + [ + 12152, + 12152 + ], + "mapped", + [ + 32566 + ] + ], + [ + [ + 12153, + 12153 + ], + "mapped", + [ + 32593 + ] + ], + [ + [ + 12154, + 12154 + ], + "mapped", + [ + 32650 + ] + ], + [ + [ + 12155, + 12155 + ], + "mapped", + [ + 32701 + ] + ], + [ + [ + 12156, + 12156 + ], + "mapped", + [ + 32769 + ] + ], + [ + [ + 12157, + 12157 + ], + "mapped", + [ + 32780 + ] + ], + [ + [ + 12158, + 12158 + ], + "mapped", + [ + 32786 + ] + ], + [ + [ + 12159, + 12159 + ], + "mapped", + [ + 32819 + ] + ], + [ + [ + 12160, + 12160 + ], + "mapped", + [ + 32895 + ] + ], + [ + [ + 12161, + 12161 + ], + "mapped", + [ + 32905 + ] + ], + [ + [ + 12162, + 12162 + ], + "mapped", + [ + 33251 + ] + ], + [ + [ + 12163, + 12163 + ], + "mapped", + [ + 33258 + ] + ], + [ + [ + 12164, + 12164 + ], + "mapped", + [ + 33267 + ] + ], + [ + [ + 12165, + 12165 + ], + "mapped", + [ + 33276 + ] + ], + [ + [ + 12166, + 12166 + ], + "mapped", + [ + 33292 + ] + ], + [ + [ + 12167, + 12167 + ], + "mapped", + [ + 33307 + ] + ], + [ + [ + 12168, + 12168 + ], + "mapped", + [ + 33311 + ] + ], + [ + [ + 12169, + 12169 + ], + "mapped", + [ + 33390 + ] + ], + [ + [ + 12170, + 12170 + ], + "mapped", + [ + 33394 + ] + ], + [ + [ + 12171, + 12171 + ], + "mapped", + [ + 33400 + ] + ], + [ + [ + 12172, + 12172 + ], + "mapped", + [ + 34381 + ] + ], + [ + [ + 12173, + 12173 + ], + "mapped", + [ + 34411 + ] + ], + [ + [ + 12174, + 12174 + ], + "mapped", + [ + 34880 + ] + ], + [ + [ + 12175, + 12175 + ], + "mapped", + [ + 34892 + ] + ], + [ + [ + 12176, + 12176 + ], + "mapped", + [ + 34915 + ] + ], + [ + [ + 12177, + 12177 + ], + "mapped", + [ + 35198 + ] + ], + [ + [ + 12178, + 12178 + ], + "mapped", + [ + 35211 + ] + ], + [ + [ + 12179, + 12179 + ], + "mapped", + [ + 35282 + ] + ], + [ + [ + 12180, + 12180 + ], + "mapped", + [ + 35328 + ] + ], + [ + [ + 12181, + 12181 + ], + "mapped", + [ + 35895 + ] + ], + [ + [ + 12182, + 12182 + ], + "mapped", + [ + 35910 + ] + ], + [ + [ + 12183, + 12183 + ], + "mapped", + [ + 35925 + ] + ], + [ + [ + 12184, + 12184 + ], + "mapped", + [ + 35960 + ] + ], + [ + [ + 12185, + 12185 + ], + "mapped", + [ + 35997 + ] + ], + [ + [ + 12186, + 12186 + ], + "mapped", + [ + 36196 + ] + ], + [ + [ + 12187, + 12187 + ], + "mapped", + [ + 36208 + ] + ], + [ + [ + 12188, + 12188 + ], + "mapped", + [ + 36275 + ] + ], + [ + [ + 12189, + 12189 + ], + "mapped", + [ + 36523 + ] + ], + [ + [ + 12190, + 12190 + ], + "mapped", + [ + 36554 + ] + ], + [ + [ + 12191, + 12191 + ], + "mapped", + [ + 36763 + ] + ], + [ + [ + 12192, + 12192 + ], + "mapped", + [ + 36784 + ] + ], + [ + [ + 12193, + 12193 + ], + "mapped", + [ + 36789 + ] + ], + [ + [ + 12194, + 12194 + ], + "mapped", + [ + 37009 + ] + ], + [ + [ + 12195, + 12195 + ], + "mapped", + [ + 37193 + ] + ], + [ + [ + 12196, + 12196 + ], + "mapped", + [ + 37318 + ] + ], + [ + [ + 12197, + 12197 + ], + "mapped", + [ + 37324 + ] + ], + [ + [ + 12198, + 12198 + ], + "mapped", + [ + 37329 + ] + ], + [ + [ + 12199, + 12199 + ], + "mapped", + [ + 38263 + ] + ], + [ + [ + 12200, + 12200 + ], + "mapped", + [ + 38272 + ] + ], + [ + [ + 12201, + 12201 + ], + "mapped", + [ + 38428 + ] + ], + [ + [ + 12202, + 12202 + ], + "mapped", + [ + 38582 + ] + ], + [ + [ + 12203, + 12203 + ], + "mapped", + [ + 38585 + ] + ], + [ + [ + 12204, + 12204 + ], + "mapped", + [ + 38632 + ] + ], + [ + [ + 12205, + 12205 + ], + "mapped", + [ + 38737 + ] + ], + [ + [ + 12206, + 12206 + ], + "mapped", + [ + 38750 + ] + ], + [ + [ + 12207, + 12207 + ], + "mapped", + [ + 38754 + ] + ], + [ + [ + 12208, + 12208 + ], + "mapped", + [ + 38761 + ] + ], + [ + [ + 12209, + 12209 + ], + "mapped", + [ + 38859 + ] + ], + [ + [ + 12210, + 12210 + ], + "mapped", + [ + 38893 + ] + ], + [ + [ + 12211, + 12211 + ], + "mapped", + [ + 38899 + ] + ], + [ + [ + 12212, + 12212 + ], + "mapped", + [ + 38913 + ] + ], + [ + [ + 12213, + 12213 + ], + "mapped", + [ + 39080 + ] + ], + [ + [ + 12214, + 12214 + ], + "mapped", + [ + 39131 + ] + ], + [ + [ + 12215, + 12215 + ], + "mapped", + [ + 39135 + ] + ], + [ + [ + 12216, + 12216 + ], + "mapped", + [ + 39318 + ] + ], + [ + [ + 12217, + 12217 + ], + "mapped", + [ + 39321 + ] + ], + [ + [ + 12218, + 12218 + ], + "mapped", + [ + 39340 + ] + ], + [ + [ + 12219, + 12219 + ], + "mapped", + [ + 39592 + ] + ], + [ + [ + 12220, + 12220 + ], + "mapped", + [ + 39640 + ] + ], + [ + [ + 12221, + 12221 + ], + "mapped", + [ + 39647 + ] + ], + [ + [ + 12222, + 12222 + ], + "mapped", + [ + 39717 + ] + ], + [ + [ + 12223, + 12223 + ], + "mapped", + [ + 39727 + ] + ], + [ + [ + 12224, + 12224 + ], + "mapped", + [ + 39730 + ] + ], + [ + [ + 12225, + 12225 + ], + "mapped", + [ + 39740 + ] + ], + [ + [ + 12226, + 12226 + ], + "mapped", + [ + 39770 + ] + ], + [ + [ + 12227, + 12227 + ], + "mapped", + [ + 40165 + ] + ], + [ + [ + 12228, + 12228 + ], + "mapped", + [ + 40565 + ] + ], + [ + [ + 12229, + 12229 + ], + "mapped", + [ + 40575 + ] + ], + [ + [ + 12230, + 12230 + ], + "mapped", + [ + 40613 + ] + ], + [ + [ + 12231, + 12231 + ], + "mapped", + [ + 40635 + ] + ], + [ + [ + 12232, + 12232 + ], + "mapped", + [ + 40643 + ] + ], + [ + [ + 12233, + 12233 + ], + "mapped", + [ + 40653 + ] + ], + [ + [ + 12234, + 12234 + ], + "mapped", + [ + 40657 + ] + ], + [ + [ + 12235, + 12235 + ], + "mapped", + [ + 40697 + ] + ], + [ + [ + 12236, + 12236 + ], + "mapped", + [ + 40701 + ] + ], + [ + [ + 12237, + 12237 + ], + "mapped", + [ + 40718 + ] + ], + [ + [ + 12238, + 12238 + ], + "mapped", + [ + 40723 + ] + ], + [ + [ + 12239, + 12239 + ], + "mapped", + [ + 40736 + ] + ], + [ + [ + 12240, + 12240 + ], + "mapped", + [ + 40763 + ] + ], + [ + [ + 12241, + 12241 + ], + "mapped", + [ + 40778 + ] + ], + [ + [ + 12242, + 12242 + ], + "mapped", + [ + 40786 + ] + ], + [ + [ + 12243, + 12243 + ], + "mapped", + [ + 40845 + ] + ], + [ + [ + 12244, + 12244 + ], + "mapped", + [ + 40860 + ] + ], + [ + [ + 12245, + 12245 + ], + "mapped", + [ + 40864 + ] + ], + [ + [ + 12246, + 12271 + ], + "disallowed" + ], + [ + [ + 12272, + 12283 + ], + "disallowed" + ], + [ + [ + 12284, + 12287 + ], + "disallowed" + ], + [ + [ + 12288, + 12288 + ], + "disallowed_STD3_mapped", + [ + 32 + ] + ], + [ + [ + 12289, + 12289 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 12290, + 12290 + ], + "mapped", + [ + 46 + ] + ], + [ + [ + 12291, + 12292 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 12293, + 12295 + ], + "valid" + ], + [ + [ + 12296, + 12329 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 12330, + 12333 + ], + "valid" + ], + [ + [ + 12334, + 12341 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 12342, + 12342 + ], + "mapped", + [ + 12306 + ] + ], + [ + [ + 12343, + 12343 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 12344, + 12344 + ], + "mapped", + [ + 21313 + ] + ], + [ + [ + 12345, + 12345 + ], + "mapped", + [ + 21316 + ] + ], + [ + [ + 12346, + 12346 + ], + "mapped", + [ + 21317 + ] + ], + [ + [ + 12347, + 12347 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 12348, + 12348 + ], + "valid" + ], + [ + [ + 12349, + 12349 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 12350, + 12350 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 12351, + 12351 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 12352, + 12352 + ], + "disallowed" + ], + [ + [ + 12353, + 12436 + ], + "valid" + ], + [ + [ + 12437, + 12438 + ], + "valid" + ], + [ + [ + 12439, + 12440 + ], + "disallowed" + ], + [ + [ + 12441, + 12442 + ], + "valid" + ], + [ + [ + 12443, + 12443 + ], + "disallowed_STD3_mapped", + [ + 32, + 12441 + ] + ], + [ + [ + 12444, + 12444 + ], + "disallowed_STD3_mapped", + [ + 32, + 12442 + ] + ], + [ + [ + 12445, + 12446 + ], + "valid" + ], + [ + [ + 12447, + 12447 + ], + "mapped", + [ + 12424, + 12426 + ] + ], + [ + [ + 12448, + 12448 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 12449, + 12542 + ], + "valid" + ], + [ + [ + 12543, + 12543 + ], + "mapped", + [ + 12467, + 12488 + ] + ], + [ + [ + 12544, + 12548 + ], + "disallowed" + ], + [ + [ + 12549, + 12588 + ], + "valid" + ], + [ + [ + 12589, + 12589 + ], + "valid" + ], + [ + [ + 12590, + 12592 + ], + "disallowed" + ], + [ + [ + 12593, + 12593 + ], + "mapped", + [ + 4352 + ] + ], + [ + [ + 12594, + 12594 + ], + "mapped", + [ + 4353 + ] + ], + [ + [ + 12595, + 12595 + ], + "mapped", + [ + 4522 + ] + ], + [ + [ + 12596, + 12596 + ], + "mapped", + [ + 4354 + ] + ], + [ + [ + 12597, + 12597 + ], + "mapped", + [ + 4524 + ] + ], + [ + [ + 12598, + 12598 + ], + "mapped", + [ + 4525 + ] + ], + [ + [ + 12599, + 12599 + ], + "mapped", + [ + 4355 + ] + ], + [ + [ + 12600, + 12600 + ], + "mapped", + [ + 4356 + ] + ], + [ + [ + 12601, + 12601 + ], + "mapped", + [ + 4357 + ] + ], + [ + [ + 12602, + 12602 + ], + "mapped", + [ + 4528 + ] + ], + [ + [ + 12603, + 12603 + ], + "mapped", + [ + 4529 + ] + ], + [ + [ + 12604, + 12604 + ], + "mapped", + [ + 4530 + ] + ], + [ + [ + 12605, + 12605 + ], + "mapped", + [ + 4531 + ] + ], + [ + [ + 12606, + 12606 + ], + "mapped", + [ + 4532 + ] + ], + [ + [ + 12607, + 12607 + ], + "mapped", + [ + 4533 + ] + ], + [ + [ + 12608, + 12608 + ], + "mapped", + [ + 4378 + ] + ], + [ + [ + 12609, + 12609 + ], + "mapped", + [ + 4358 + ] + ], + [ + [ + 12610, + 12610 + ], + "mapped", + [ + 4359 + ] + ], + [ + [ + 12611, + 12611 + ], + "mapped", + [ + 4360 + ] + ], + [ + [ + 12612, + 12612 + ], + "mapped", + [ + 4385 + ] + ], + [ + [ + 12613, + 12613 + ], + "mapped", + [ + 4361 + ] + ], + [ + [ + 12614, + 12614 + ], + "mapped", + [ + 4362 + ] + ], + [ + [ + 12615, + 12615 + ], + "mapped", + [ + 4363 + ] + ], + [ + [ + 12616, + 12616 + ], + "mapped", + [ + 4364 + ] + ], + [ + [ + 12617, + 12617 + ], + "mapped", + [ + 4365 + ] + ], + [ + [ + 12618, + 12618 + ], + "mapped", + [ + 4366 + ] + ], + [ + [ + 12619, + 12619 + ], + "mapped", + [ + 4367 + ] + ], + [ + [ + 12620, + 12620 + ], + "mapped", + [ + 4368 + ] + ], + [ + [ + 12621, + 12621 + ], + "mapped", + [ + 4369 + ] + ], + [ + [ + 12622, + 12622 + ], + "mapped", + [ + 4370 + ] + ], + [ + [ + 12623, + 12623 + ], + "mapped", + [ + 4449 + ] + ], + [ + [ + 12624, + 12624 + ], + "mapped", + [ + 4450 + ] + ], + [ + [ + 12625, + 12625 + ], + "mapped", + [ + 4451 + ] + ], + [ + [ + 12626, + 12626 + ], + "mapped", + [ + 4452 + ] + ], + [ + [ + 12627, + 12627 + ], + "mapped", + [ + 4453 + ] + ], + [ + [ + 12628, + 12628 + ], + "mapped", + [ + 4454 + ] + ], + [ + [ + 12629, + 12629 + ], + "mapped", + [ + 4455 + ] + ], + [ + [ + 12630, + 12630 + ], + "mapped", + [ + 4456 + ] + ], + [ + [ + 12631, + 12631 + ], + "mapped", + [ + 4457 + ] + ], + [ + [ + 12632, + 12632 + ], + "mapped", + [ + 4458 + ] + ], + [ + [ + 12633, + 12633 + ], + "mapped", + [ + 4459 + ] + ], + [ + [ + 12634, + 12634 + ], + "mapped", + [ + 4460 + ] + ], + [ + [ + 12635, + 12635 + ], + "mapped", + [ + 4461 + ] + ], + [ + [ + 12636, + 12636 + ], + "mapped", + [ + 4462 + ] + ], + [ + [ + 12637, + 12637 + ], + "mapped", + [ + 4463 + ] + ], + [ + [ + 12638, + 12638 + ], + "mapped", + [ + 4464 + ] + ], + [ + [ + 12639, + 12639 + ], + "mapped", + [ + 4465 + ] + ], + [ + [ + 12640, + 12640 + ], + "mapped", + [ + 4466 + ] + ], + [ + [ + 12641, + 12641 + ], + "mapped", + [ + 4467 + ] + ], + [ + [ + 12642, + 12642 + ], + "mapped", + [ + 4468 + ] + ], + [ + [ + 12643, + 12643 + ], + "mapped", + [ + 4469 + ] + ], + [ + [ + 12644, + 12644 + ], + "disallowed" + ], + [ + [ + 12645, + 12645 + ], + "mapped", + [ + 4372 + ] + ], + [ + [ + 12646, + 12646 + ], + "mapped", + [ + 4373 + ] + ], + [ + [ + 12647, + 12647 + ], + "mapped", + [ + 4551 + ] + ], + [ + [ + 12648, + 12648 + ], + "mapped", + [ + 4552 + ] + ], + [ + [ + 12649, + 12649 + ], + "mapped", + [ + 4556 + ] + ], + [ + [ + 12650, + 12650 + ], + "mapped", + [ + 4558 + ] + ], + [ + [ + 12651, + 12651 + ], + "mapped", + [ + 4563 + ] + ], + [ + [ + 12652, + 12652 + ], + "mapped", + [ + 4567 + ] + ], + [ + [ + 12653, + 12653 + ], + "mapped", + [ + 4569 + ] + ], + [ + [ + 12654, + 12654 + ], + "mapped", + [ + 4380 + ] + ], + [ + [ + 12655, + 12655 + ], + "mapped", + [ + 4573 + ] + ], + [ + [ + 12656, + 12656 + ], + "mapped", + [ + 4575 + ] + ], + [ + [ + 12657, + 12657 + ], + "mapped", + [ + 4381 + ] + ], + [ + [ + 12658, + 12658 + ], + "mapped", + [ + 4382 + ] + ], + [ + [ + 12659, + 12659 + ], + "mapped", + [ + 4384 + ] + ], + [ + [ + 12660, + 12660 + ], + "mapped", + [ + 4386 + ] + ], + [ + [ + 12661, + 12661 + ], + "mapped", + [ + 4387 + ] + ], + [ + [ + 12662, + 12662 + ], + "mapped", + [ + 4391 + ] + ], + [ + [ + 12663, + 12663 + ], + "mapped", + [ + 4393 + ] + ], + [ + [ + 12664, + 12664 + ], + "mapped", + [ + 4395 + ] + ], + [ + [ + 12665, + 12665 + ], + "mapped", + [ + 4396 + ] + ], + [ + [ + 12666, + 12666 + ], + "mapped", + [ + 4397 + ] + ], + [ + [ + 12667, + 12667 + ], + "mapped", + [ + 4398 + ] + ], + [ + [ + 12668, + 12668 + ], + "mapped", + [ + 4399 + ] + ], + [ + [ + 12669, + 12669 + ], + "mapped", + [ + 4402 + ] + ], + [ + [ + 12670, + 12670 + ], + "mapped", + [ + 4406 + ] + ], + [ + [ + 12671, + 12671 + ], + "mapped", + [ + 4416 + ] + ], + [ + [ + 12672, + 12672 + ], + "mapped", + [ + 4423 + ] + ], + [ + [ + 12673, + 12673 + ], + "mapped", + [ + 4428 + ] + ], + [ + [ + 12674, + 12674 + ], + "mapped", + [ + 4593 + ] + ], + [ + [ + 12675, + 12675 + ], + "mapped", + [ + 4594 + ] + ], + [ + [ + 12676, + 12676 + ], + "mapped", + [ + 4439 + ] + ], + [ + [ + 12677, + 12677 + ], + "mapped", + [ + 4440 + ] + ], + [ + [ + 12678, + 12678 + ], + "mapped", + [ + 4441 + ] + ], + [ + [ + 12679, + 12679 + ], + "mapped", + [ + 4484 + ] + ], + [ + [ + 12680, + 12680 + ], + "mapped", + [ + 4485 + ] + ], + [ + [ + 12681, + 12681 + ], + "mapped", + [ + 4488 + ] + ], + [ + [ + 12682, + 12682 + ], + "mapped", + [ + 4497 + ] + ], + [ + [ + 12683, + 12683 + ], + "mapped", + [ + 4498 + ] + ], + [ + [ + 12684, + 12684 + ], + "mapped", + [ + 4500 + ] + ], + [ + [ + 12685, + 12685 + ], + "mapped", + [ + 4510 + ] + ], + [ + [ + 12686, + 12686 + ], + "mapped", + [ + 4513 + ] + ], + [ + [ + 12687, + 12687 + ], + "disallowed" + ], + [ + [ + 12688, + 12689 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 12690, + 12690 + ], + "mapped", + [ + 19968 + ] + ], + [ + [ + 12691, + 12691 + ], + "mapped", + [ + 20108 + ] + ], + [ + [ + 12692, + 12692 + ], + "mapped", + [ + 19977 + ] + ], + [ + [ + 12693, + 12693 + ], + "mapped", + [ + 22235 + ] + ], + [ + [ + 12694, + 12694 + ], + "mapped", + [ + 19978 + ] + ], + [ + [ + 12695, + 12695 + ], + "mapped", + [ + 20013 + ] + ], + [ + [ + 12696, + 12696 + ], + "mapped", + [ + 19979 + ] + ], + [ + [ + 12697, + 12697 + ], + "mapped", + [ + 30002 + ] + ], + [ + [ + 12698, + 12698 + ], + "mapped", + [ + 20057 + ] + ], + [ + [ + 12699, + 12699 + ], + "mapped", + [ + 19993 + ] + ], + [ + [ + 12700, + 12700 + ], + "mapped", + [ + 19969 + ] + ], + [ + [ + 12701, + 12701 + ], + "mapped", + [ + 22825 + ] + ], + [ + [ + 12702, + 12702 + ], + "mapped", + [ + 22320 + ] + ], + [ + [ + 12703, + 12703 + ], + "mapped", + [ + 20154 + ] + ], + [ + [ + 12704, + 12727 + ], + "valid" + ], + [ + [ + 12728, + 12730 + ], + "valid" + ], + [ + [ + 12731, + 12735 + ], + "disallowed" + ], + [ + [ + 12736, + 12751 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 12752, + 12771 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 12772, + 12783 + ], + "disallowed" + ], + [ + [ + 12784, + 12799 + ], + "valid" + ], + [ + [ + 12800, + 12800 + ], + "disallowed_STD3_mapped", + [ + 40, + 4352, + 41 + ] + ], + [ + [ + 12801, + 12801 + ], + "disallowed_STD3_mapped", + [ + 40, + 4354, + 41 + ] + ], + [ + [ + 12802, + 12802 + ], + "disallowed_STD3_mapped", + [ + 40, + 4355, + 41 + ] + ], + [ + [ + 12803, + 12803 + ], + "disallowed_STD3_mapped", + [ + 40, + 4357, + 41 + ] + ], + [ + [ + 12804, + 12804 + ], + "disallowed_STD3_mapped", + [ + 40, + 4358, + 41 + ] + ], + [ + [ + 12805, + 12805 + ], + "disallowed_STD3_mapped", + [ + 40, + 4359, + 41 + ] + ], + [ + [ + 12806, + 12806 + ], + "disallowed_STD3_mapped", + [ + 40, + 4361, + 41 + ] + ], + [ + [ + 12807, + 12807 + ], + "disallowed_STD3_mapped", + [ + 40, + 4363, + 41 + ] + ], + [ + [ + 12808, + 12808 + ], + "disallowed_STD3_mapped", + [ + 40, + 4364, + 41 + ] + ], + [ + [ + 12809, + 12809 + ], + "disallowed_STD3_mapped", + [ + 40, + 4366, + 41 + ] + ], + [ + [ + 12810, + 12810 + ], + "disallowed_STD3_mapped", + [ + 40, + 4367, + 41 + ] + ], + [ + [ + 12811, + 12811 + ], + "disallowed_STD3_mapped", + [ + 40, + 4368, + 41 + ] + ], + [ + [ + 12812, + 12812 + ], + "disallowed_STD3_mapped", + [ + 40, + 4369, + 41 + ] + ], + [ + [ + 12813, + 12813 + ], + "disallowed_STD3_mapped", + [ + 40, + 4370, + 41 + ] + ], + [ + [ + 12814, + 12814 + ], + "disallowed_STD3_mapped", + [ + 40, + 44032, + 41 + ] + ], + [ + [ + 12815, + 12815 + ], + "disallowed_STD3_mapped", + [ + 40, + 45208, + 41 + ] + ], + [ + [ + 12816, + 12816 + ], + "disallowed_STD3_mapped", + [ + 40, + 45796, + 41 + ] + ], + [ + [ + 12817, + 12817 + ], + "disallowed_STD3_mapped", + [ + 40, + 46972, + 41 + ] + ], + [ + [ + 12818, + 12818 + ], + "disallowed_STD3_mapped", + [ + 40, + 47560, + 41 + ] + ], + [ + [ + 12819, + 12819 + ], + "disallowed_STD3_mapped", + [ + 40, + 48148, + 41 + ] + ], + [ + [ + 12820, + 12820 + ], + "disallowed_STD3_mapped", + [ + 40, + 49324, + 41 + ] + ], + [ + [ + 12821, + 12821 + ], + "disallowed_STD3_mapped", + [ + 40, + 50500, + 41 + ] + ], + [ + [ + 12822, + 12822 + ], + "disallowed_STD3_mapped", + [ + 40, + 51088, + 41 + ] + ], + [ + [ + 12823, + 12823 + ], + "disallowed_STD3_mapped", + [ + 40, + 52264, + 41 + ] + ], + [ + [ + 12824, + 12824 + ], + "disallowed_STD3_mapped", + [ + 40, + 52852, + 41 + ] + ], + [ + [ + 12825, + 12825 + ], + "disallowed_STD3_mapped", + [ + 40, + 53440, + 41 + ] + ], + [ + [ + 12826, + 12826 + ], + "disallowed_STD3_mapped", + [ + 40, + 54028, + 41 + ] + ], + [ + [ + 12827, + 12827 + ], + "disallowed_STD3_mapped", + [ + 40, + 54616, + 41 + ] + ], + [ + [ + 12828, + 12828 + ], + "disallowed_STD3_mapped", + [ + 40, + 51452, + 41 + ] + ], + [ + [ + 12829, + 12829 + ], + "disallowed_STD3_mapped", + [ + 40, + 50724, + 51204, + 41 + ] + ], + [ + [ + 12830, + 12830 + ], + "disallowed_STD3_mapped", + [ + 40, + 50724, + 54980, + 41 + ] + ], + [ + [ + 12831, + 12831 + ], + "disallowed" + ], + [ + [ + 12832, + 12832 + ], + "disallowed_STD3_mapped", + [ + 40, + 19968, + 41 + ] + ], + [ + [ + 12833, + 12833 + ], + "disallowed_STD3_mapped", + [ + 40, + 20108, + 41 + ] + ], + [ + [ + 12834, + 12834 + ], + "disallowed_STD3_mapped", + [ + 40, + 19977, + 41 + ] + ], + [ + [ + 12835, + 12835 + ], + "disallowed_STD3_mapped", + [ + 40, + 22235, + 41 + ] + ], + [ + [ + 12836, + 12836 + ], + "disallowed_STD3_mapped", + [ + 40, + 20116, + 41 + ] + ], + [ + [ + 12837, + 12837 + ], + "disallowed_STD3_mapped", + [ + 40, + 20845, + 41 + ] + ], + [ + [ + 12838, + 12838 + ], + "disallowed_STD3_mapped", + [ + 40, + 19971, + 41 + ] + ], + [ + [ + 12839, + 12839 + ], + "disallowed_STD3_mapped", + [ + 40, + 20843, + 41 + ] + ], + [ + [ + 12840, + 12840 + ], + "disallowed_STD3_mapped", + [ + 40, + 20061, + 41 + ] + ], + [ + [ + 12841, + 12841 + ], + "disallowed_STD3_mapped", + [ + 40, + 21313, + 41 + ] + ], + [ + [ + 12842, + 12842 + ], + "disallowed_STD3_mapped", + [ + 40, + 26376, + 41 + ] + ], + [ + [ + 12843, + 12843 + ], + "disallowed_STD3_mapped", + [ + 40, + 28779, + 41 + ] + ], + [ + [ + 12844, + 12844 + ], + "disallowed_STD3_mapped", + [ + 40, + 27700, + 41 + ] + ], + [ + [ + 12845, + 12845 + ], + "disallowed_STD3_mapped", + [ + 40, + 26408, + 41 + ] + ], + [ + [ + 12846, + 12846 + ], + "disallowed_STD3_mapped", + [ + 40, + 37329, + 41 + ] + ], + [ + [ + 12847, + 12847 + ], + "disallowed_STD3_mapped", + [ + 40, + 22303, + 41 + ] + ], + [ + [ + 12848, + 12848 + ], + "disallowed_STD3_mapped", + [ + 40, + 26085, + 41 + ] + ], + [ + [ + 12849, + 12849 + ], + "disallowed_STD3_mapped", + [ + 40, + 26666, + 41 + ] + ], + [ + [ + 12850, + 12850 + ], + "disallowed_STD3_mapped", + [ + 40, + 26377, + 41 + ] + ], + [ + [ + 12851, + 12851 + ], + "disallowed_STD3_mapped", + [ + 40, + 31038, + 41 + ] + ], + [ + [ + 12852, + 12852 + ], + "disallowed_STD3_mapped", + [ + 40, + 21517, + 41 + ] + ], + [ + [ + 12853, + 12853 + ], + "disallowed_STD3_mapped", + [ + 40, + 29305, + 41 + ] + ], + [ + [ + 12854, + 12854 + ], + "disallowed_STD3_mapped", + [ + 40, + 36001, + 41 + ] + ], + [ + [ + 12855, + 12855 + ], + "disallowed_STD3_mapped", + [ + 40, + 31069, + 41 + ] + ], + [ + [ + 12856, + 12856 + ], + "disallowed_STD3_mapped", + [ + 40, + 21172, + 41 + ] + ], + [ + [ + 12857, + 12857 + ], + "disallowed_STD3_mapped", + [ + 40, + 20195, + 41 + ] + ], + [ + [ + 12858, + 12858 + ], + "disallowed_STD3_mapped", + [ + 40, + 21628, + 41 + ] + ], + [ + [ + 12859, + 12859 + ], + "disallowed_STD3_mapped", + [ + 40, + 23398, + 41 + ] + ], + [ + [ + 12860, + 12860 + ], + "disallowed_STD3_mapped", + [ + 40, + 30435, + 41 + ] + ], + [ + [ + 12861, + 12861 + ], + "disallowed_STD3_mapped", + [ + 40, + 20225, + 41 + ] + ], + [ + [ + 12862, + 12862 + ], + "disallowed_STD3_mapped", + [ + 40, + 36039, + 41 + ] + ], + [ + [ + 12863, + 12863 + ], + "disallowed_STD3_mapped", + [ + 40, + 21332, + 41 + ] + ], + [ + [ + 12864, + 12864 + ], + "disallowed_STD3_mapped", + [ + 40, + 31085, + 41 + ] + ], + [ + [ + 12865, + 12865 + ], + "disallowed_STD3_mapped", + [ + 40, + 20241, + 41 + ] + ], + [ + [ + 12866, + 12866 + ], + "disallowed_STD3_mapped", + [ + 40, + 33258, + 41 + ] + ], + [ + [ + 12867, + 12867 + ], + "disallowed_STD3_mapped", + [ + 40, + 33267, + 41 + ] + ], + [ + [ + 12868, + 12868 + ], + "mapped", + [ + 21839 + ] + ], + [ + [ + 12869, + 12869 + ], + "mapped", + [ + 24188 + ] + ], + [ + [ + 12870, + 12870 + ], + "mapped", + [ + 25991 + ] + ], + [ + [ + 12871, + 12871 + ], + "mapped", + [ + 31631 + ] + ], + [ + [ + 12872, + 12879 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 12880, + 12880 + ], + "mapped", + [ + 112, + 116, + 101 + ] + ], + [ + [ + 12881, + 12881 + ], + "mapped", + [ + 50, + 49 + ] + ], + [ + [ + 12882, + 12882 + ], + "mapped", + [ + 50, + 50 + ] + ], + [ + [ + 12883, + 12883 + ], + "mapped", + [ + 50, + 51 + ] + ], + [ + [ + 12884, + 12884 + ], + "mapped", + [ + 50, + 52 + ] + ], + [ + [ + 12885, + 12885 + ], + "mapped", + [ + 50, + 53 + ] + ], + [ + [ + 12886, + 12886 + ], + "mapped", + [ + 50, + 54 + ] + ], + [ + [ + 12887, + 12887 + ], + "mapped", + [ + 50, + 55 + ] + ], + [ + [ + 12888, + 12888 + ], + "mapped", + [ + 50, + 56 + ] + ], + [ + [ + 12889, + 12889 + ], + "mapped", + [ + 50, + 57 + ] + ], + [ + [ + 12890, + 12890 + ], + "mapped", + [ + 51, + 48 + ] + ], + [ + [ + 12891, + 12891 + ], + "mapped", + [ + 51, + 49 + ] + ], + [ + [ + 12892, + 12892 + ], + "mapped", + [ + 51, + 50 + ] + ], + [ + [ + 12893, + 12893 + ], + "mapped", + [ + 51, + 51 + ] + ], + [ + [ + 12894, + 12894 + ], + "mapped", + [ + 51, + 52 + ] + ], + [ + [ + 12895, + 12895 + ], + "mapped", + [ + 51, + 53 + ] + ], + [ + [ + 12896, + 12896 + ], + "mapped", + [ + 4352 + ] + ], + [ + [ + 12897, + 12897 + ], + "mapped", + [ + 4354 + ] + ], + [ + [ + 12898, + 12898 + ], + "mapped", + [ + 4355 + ] + ], + [ + [ + 12899, + 12899 + ], + "mapped", + [ + 4357 + ] + ], + [ + [ + 12900, + 12900 + ], + "mapped", + [ + 4358 + ] + ], + [ + [ + 12901, + 12901 + ], + "mapped", + [ + 4359 + ] + ], + [ + [ + 12902, + 12902 + ], + "mapped", + [ + 4361 + ] + ], + [ + [ + 12903, + 12903 + ], + "mapped", + [ + 4363 + ] + ], + [ + [ + 12904, + 12904 + ], + "mapped", + [ + 4364 + ] + ], + [ + [ + 12905, + 12905 + ], + "mapped", + [ + 4366 + ] + ], + [ + [ + 12906, + 12906 + ], + "mapped", + [ + 4367 + ] + ], + [ + [ + 12907, + 12907 + ], + "mapped", + [ + 4368 + ] + ], + [ + [ + 12908, + 12908 + ], + "mapped", + [ + 4369 + ] + ], + [ + [ + 12909, + 12909 + ], + "mapped", + [ + 4370 + ] + ], + [ + [ + 12910, + 12910 + ], + "mapped", + [ + 44032 + ] + ], + [ + [ + 12911, + 12911 + ], + "mapped", + [ + 45208 + ] + ], + [ + [ + 12912, + 12912 + ], + "mapped", + [ + 45796 + ] + ], + [ + [ + 12913, + 12913 + ], + "mapped", + [ + 46972 + ] + ], + [ + [ + 12914, + 12914 + ], + "mapped", + [ + 47560 + ] + ], + [ + [ + 12915, + 12915 + ], + "mapped", + [ + 48148 + ] + ], + [ + [ + 12916, + 12916 + ], + "mapped", + [ + 49324 + ] + ], + [ + [ + 12917, + 12917 + ], + "mapped", + [ + 50500 + ] + ], + [ + [ + 12918, + 12918 + ], + "mapped", + [ + 51088 + ] + ], + [ + [ + 12919, + 12919 + ], + "mapped", + [ + 52264 + ] + ], + [ + [ + 12920, + 12920 + ], + "mapped", + [ + 52852 + ] + ], + [ + [ + 12921, + 12921 + ], + "mapped", + [ + 53440 + ] + ], + [ + [ + 12922, + 12922 + ], + "mapped", + [ + 54028 + ] + ], + [ + [ + 12923, + 12923 + ], + "mapped", + [ + 54616 + ] + ], + [ + [ + 12924, + 12924 + ], + "mapped", + [ + 52280, + 44256 + ] + ], + [ + [ + 12925, + 12925 + ], + "mapped", + [ + 51452, + 51032 + ] + ], + [ + [ + 12926, + 12926 + ], + "mapped", + [ + 50864 + ] + ], + [ + [ + 12927, + 12927 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 12928, + 12928 + ], + "mapped", + [ + 19968 + ] + ], + [ + [ + 12929, + 12929 + ], + "mapped", + [ + 20108 + ] + ], + [ + [ + 12930, + 12930 + ], + "mapped", + [ + 19977 + ] + ], + [ + [ + 12931, + 12931 + ], + "mapped", + [ + 22235 + ] + ], + [ + [ + 12932, + 12932 + ], + "mapped", + [ + 20116 + ] + ], + [ + [ + 12933, + 12933 + ], + "mapped", + [ + 20845 + ] + ], + [ + [ + 12934, + 12934 + ], + "mapped", + [ + 19971 + ] + ], + [ + [ + 12935, + 12935 + ], + "mapped", + [ + 20843 + ] + ], + [ + [ + 12936, + 12936 + ], + "mapped", + [ + 20061 + ] + ], + [ + [ + 12937, + 12937 + ], + "mapped", + [ + 21313 + ] + ], + [ + [ + 12938, + 12938 + ], + "mapped", + [ + 26376 + ] + ], + [ + [ + 12939, + 12939 + ], + "mapped", + [ + 28779 + ] + ], + [ + [ + 12940, + 12940 + ], + "mapped", + [ + 27700 + ] + ], + [ + [ + 12941, + 12941 + ], + "mapped", + [ + 26408 + ] + ], + [ + [ + 12942, + 12942 + ], + "mapped", + [ + 37329 + ] + ], + [ + [ + 12943, + 12943 + ], + "mapped", + [ + 22303 + ] + ], + [ + [ + 12944, + 12944 + ], + "mapped", + [ + 26085 + ] + ], + [ + [ + 12945, + 12945 + ], + "mapped", + [ + 26666 + ] + ], + [ + [ + 12946, + 12946 + ], + "mapped", + [ + 26377 + ] + ], + [ + [ + 12947, + 12947 + ], + "mapped", + [ + 31038 + ] + ], + [ + [ + 12948, + 12948 + ], + "mapped", + [ + 21517 + ] + ], + [ + [ + 12949, + 12949 + ], + "mapped", + [ + 29305 + ] + ], + [ + [ + 12950, + 12950 + ], + "mapped", + [ + 36001 + ] + ], + [ + [ + 12951, + 12951 + ], + "mapped", + [ + 31069 + ] + ], + [ + [ + 12952, + 12952 + ], + "mapped", + [ + 21172 + ] + ], + [ + [ + 12953, + 12953 + ], + "mapped", + [ + 31192 + ] + ], + [ + [ + 12954, + 12954 + ], + "mapped", + [ + 30007 + ] + ], + [ + [ + 12955, + 12955 + ], + "mapped", + [ + 22899 + ] + ], + [ + [ + 12956, + 12956 + ], + "mapped", + [ + 36969 + ] + ], + [ + [ + 12957, + 12957 + ], + "mapped", + [ + 20778 + ] + ], + [ + [ + 12958, + 12958 + ], + "mapped", + [ + 21360 + ] + ], + [ + [ + 12959, + 12959 + ], + "mapped", + [ + 27880 + ] + ], + [ + [ + 12960, + 12960 + ], + "mapped", + [ + 38917 + ] + ], + [ + [ + 12961, + 12961 + ], + "mapped", + [ + 20241 + ] + ], + [ + [ + 12962, + 12962 + ], + "mapped", + [ + 20889 + ] + ], + [ + [ + 12963, + 12963 + ], + "mapped", + [ + 27491 + ] + ], + [ + [ + 12964, + 12964 + ], + "mapped", + [ + 19978 + ] + ], + [ + [ + 12965, + 12965 + ], + "mapped", + [ + 20013 + ] + ], + [ + [ + 12966, + 12966 + ], + "mapped", + [ + 19979 + ] + ], + [ + [ + 12967, + 12967 + ], + "mapped", + [ + 24038 + ] + ], + [ + [ + 12968, + 12968 + ], + "mapped", + [ + 21491 + ] + ], + [ + [ + 12969, + 12969 + ], + "mapped", + [ + 21307 + ] + ], + [ + [ + 12970, + 12970 + ], + "mapped", + [ + 23447 + ] + ], + [ + [ + 12971, + 12971 + ], + "mapped", + [ + 23398 + ] + ], + [ + [ + 12972, + 12972 + ], + "mapped", + [ + 30435 + ] + ], + [ + [ + 12973, + 12973 + ], + "mapped", + [ + 20225 + ] + ], + [ + [ + 12974, + 12974 + ], + "mapped", + [ + 36039 + ] + ], + [ + [ + 12975, + 12975 + ], + "mapped", + [ + 21332 + ] + ], + [ + [ + 12976, + 12976 + ], + "mapped", + [ + 22812 + ] + ], + [ + [ + 12977, + 12977 + ], + "mapped", + [ + 51, + 54 + ] + ], + [ + [ + 12978, + 12978 + ], + "mapped", + [ + 51, + 55 + ] + ], + [ + [ + 12979, + 12979 + ], + "mapped", + [ + 51, + 56 + ] + ], + [ + [ + 12980, + 12980 + ], + "mapped", + [ + 51, + 57 + ] + ], + [ + [ + 12981, + 12981 + ], + "mapped", + [ + 52, + 48 + ] + ], + [ + [ + 12982, + 12982 + ], + "mapped", + [ + 52, + 49 + ] + ], + [ + [ + 12983, + 12983 + ], + "mapped", + [ + 52, + 50 + ] + ], + [ + [ + 12984, + 12984 + ], + "mapped", + [ + 52, + 51 + ] + ], + [ + [ + 12985, + 12985 + ], + "mapped", + [ + 52, + 52 + ] + ], + [ + [ + 12986, + 12986 + ], + "mapped", + [ + 52, + 53 + ] + ], + [ + [ + 12987, + 12987 + ], + "mapped", + [ + 52, + 54 + ] + ], + [ + [ + 12988, + 12988 + ], + "mapped", + [ + 52, + 55 + ] + ], + [ + [ + 12989, + 12989 + ], + "mapped", + [ + 52, + 56 + ] + ], + [ + [ + 12990, + 12990 + ], + "mapped", + [ + 52, + 57 + ] + ], + [ + [ + 12991, + 12991 + ], + "mapped", + [ + 53, + 48 + ] + ], + [ + [ + 12992, + 12992 + ], + "mapped", + [ + 49, + 26376 + ] + ], + [ + [ + 12993, + 12993 + ], + "mapped", + [ + 50, + 26376 + ] + ], + [ + [ + 12994, + 12994 + ], + "mapped", + [ + 51, + 26376 + ] + ], + [ + [ + 12995, + 12995 + ], + "mapped", + [ + 52, + 26376 + ] + ], + [ + [ + 12996, + 12996 + ], + "mapped", + [ + 53, + 26376 + ] + ], + [ + [ + 12997, + 12997 + ], + "mapped", + [ + 54, + 26376 + ] + ], + [ + [ + 12998, + 12998 + ], + "mapped", + [ + 55, + 26376 + ] + ], + [ + [ + 12999, + 12999 + ], + "mapped", + [ + 56, + 26376 + ] + ], + [ + [ + 13000, + 13000 + ], + "mapped", + [ + 57, + 26376 + ] + ], + [ + [ + 13001, + 13001 + ], + "mapped", + [ + 49, + 48, + 26376 + ] + ], + [ + [ + 13002, + 13002 + ], + "mapped", + [ + 49, + 49, + 26376 + ] + ], + [ + [ + 13003, + 13003 + ], + "mapped", + [ + 49, + 50, + 26376 + ] + ], + [ + [ + 13004, + 13004 + ], + "mapped", + [ + 104, + 103 + ] + ], + [ + [ + 13005, + 13005 + ], + "mapped", + [ + 101, + 114, + 103 + ] + ], + [ + [ + 13006, + 13006 + ], + "mapped", + [ + 101, + 118 + ] + ], + [ + [ + 13007, + 13007 + ], + "mapped", + [ + 108, + 116, + 100 + ] + ], + [ + [ + 13008, + 13008 + ], + "mapped", + [ + 12450 + ] + ], + [ + [ + 13009, + 13009 + ], + "mapped", + [ + 12452 + ] + ], + [ + [ + 13010, + 13010 + ], + "mapped", + [ + 12454 + ] + ], + [ + [ + 13011, + 13011 + ], + "mapped", + [ + 12456 + ] + ], + [ + [ + 13012, + 13012 + ], + "mapped", + [ + 12458 + ] + ], + [ + [ + 13013, + 13013 + ], + "mapped", + [ + 12459 + ] + ], + [ + [ + 13014, + 13014 + ], + "mapped", + [ + 12461 + ] + ], + [ + [ + 13015, + 13015 + ], + "mapped", + [ + 12463 + ] + ], + [ + [ + 13016, + 13016 + ], + "mapped", + [ + 12465 + ] + ], + [ + [ + 13017, + 13017 + ], + "mapped", + [ + 12467 + ] + ], + [ + [ + 13018, + 13018 + ], + "mapped", + [ + 12469 + ] + ], + [ + [ + 13019, + 13019 + ], + "mapped", + [ + 12471 + ] + ], + [ + [ + 13020, + 13020 + ], + "mapped", + [ + 12473 + ] + ], + [ + [ + 13021, + 13021 + ], + "mapped", + [ + 12475 + ] + ], + [ + [ + 13022, + 13022 + ], + "mapped", + [ + 12477 + ] + ], + [ + [ + 13023, + 13023 + ], + "mapped", + [ + 12479 + ] + ], + [ + [ + 13024, + 13024 + ], + "mapped", + [ + 12481 + ] + ], + [ + [ + 13025, + 13025 + ], + "mapped", + [ + 12484 + ] + ], + [ + [ + 13026, + 13026 + ], + "mapped", + [ + 12486 + ] + ], + [ + [ + 13027, + 13027 + ], + "mapped", + [ + 12488 + ] + ], + [ + [ + 13028, + 13028 + ], + "mapped", + [ + 12490 + ] + ], + [ + [ + 13029, + 13029 + ], + "mapped", + [ + 12491 + ] + ], + [ + [ + 13030, + 13030 + ], + "mapped", + [ + 12492 + ] + ], + [ + [ + 13031, + 13031 + ], + "mapped", + [ + 12493 + ] + ], + [ + [ + 13032, + 13032 + ], + "mapped", + [ + 12494 + ] + ], + [ + [ + 13033, + 13033 + ], + "mapped", + [ + 12495 + ] + ], + [ + [ + 13034, + 13034 + ], + "mapped", + [ + 12498 + ] + ], + [ + [ + 13035, + 13035 + ], + "mapped", + [ + 12501 + ] + ], + [ + [ + 13036, + 13036 + ], + "mapped", + [ + 12504 + ] + ], + [ + [ + 13037, + 13037 + ], + "mapped", + [ + 12507 + ] + ], + [ + [ + 13038, + 13038 + ], + "mapped", + [ + 12510 + ] + ], + [ + [ + 13039, + 13039 + ], + "mapped", + [ + 12511 + ] + ], + [ + [ + 13040, + 13040 + ], + "mapped", + [ + 12512 + ] + ], + [ + [ + 13041, + 13041 + ], + "mapped", + [ + 12513 + ] + ], + [ + [ + 13042, + 13042 + ], + "mapped", + [ + 12514 + ] + ], + [ + [ + 13043, + 13043 + ], + "mapped", + [ + 12516 + ] + ], + [ + [ + 13044, + 13044 + ], + "mapped", + [ + 12518 + ] + ], + [ + [ + 13045, + 13045 + ], + "mapped", + [ + 12520 + ] + ], + [ + [ + 13046, + 13046 + ], + "mapped", + [ + 12521 + ] + ], + [ + [ + 13047, + 13047 + ], + "mapped", + [ + 12522 + ] + ], + [ + [ + 13048, + 13048 + ], + "mapped", + [ + 12523 + ] + ], + [ + [ + 13049, + 13049 + ], + "mapped", + [ + 12524 + ] + ], + [ + [ + 13050, + 13050 + ], + "mapped", + [ + 12525 + ] + ], + [ + [ + 13051, + 13051 + ], + "mapped", + [ + 12527 + ] + ], + [ + [ + 13052, + 13052 + ], + "mapped", + [ + 12528 + ] + ], + [ + [ + 13053, + 13053 + ], + "mapped", + [ + 12529 + ] + ], + [ + [ + 13054, + 13054 + ], + "mapped", + [ + 12530 + ] + ], + [ + [ + 13055, + 13055 + ], + "disallowed" + ], + [ + [ + 13056, + 13056 + ], + "mapped", + [ + 12450, + 12497, + 12540, + 12488 + ] + ], + [ + [ + 13057, + 13057 + ], + "mapped", + [ + 12450, + 12523, + 12501, + 12449 + ] + ], + [ + [ + 13058, + 13058 + ], + "mapped", + [ + 12450, + 12531, + 12506, + 12450 + ] + ], + [ + [ + 13059, + 13059 + ], + "mapped", + [ + 12450, + 12540, + 12523 + ] + ], + [ + [ + 13060, + 13060 + ], + "mapped", + [ + 12452, + 12491, + 12531, + 12464 + ] + ], + [ + [ + 13061, + 13061 + ], + "mapped", + [ + 12452, + 12531, + 12481 + ] + ], + [ + [ + 13062, + 13062 + ], + "mapped", + [ + 12454, + 12457, + 12531 + ] + ], + [ + [ + 13063, + 13063 + ], + "mapped", + [ + 12456, + 12473, + 12463, + 12540, + 12489 + ] + ], + [ + [ + 13064, + 13064 + ], + "mapped", + [ + 12456, + 12540, + 12459, + 12540 + ] + ], + [ + [ + 13065, + 13065 + ], + "mapped", + [ + 12458, + 12531, + 12473 + ] + ], + [ + [ + 13066, + 13066 + ], + "mapped", + [ + 12458, + 12540, + 12512 + ] + ], + [ + [ + 13067, + 13067 + ], + "mapped", + [ + 12459, + 12452, + 12522 + ] + ], + [ + [ + 13068, + 13068 + ], + "mapped", + [ + 12459, + 12521, + 12483, + 12488 + ] + ], + [ + [ + 13069, + 13069 + ], + "mapped", + [ + 12459, + 12525, + 12522, + 12540 + ] + ], + [ + [ + 13070, + 13070 + ], + "mapped", + [ + 12460, + 12525, + 12531 + ] + ], + [ + [ + 13071, + 13071 + ], + "mapped", + [ + 12460, + 12531, + 12510 + ] + ], + [ + [ + 13072, + 13072 + ], + "mapped", + [ + 12462, + 12460 + ] + ], + [ + [ + 13073, + 13073 + ], + "mapped", + [ + 12462, + 12491, + 12540 + ] + ], + [ + [ + 13074, + 13074 + ], + "mapped", + [ + 12461, + 12517, + 12522, + 12540 + ] + ], + [ + [ + 13075, + 13075 + ], + "mapped", + [ + 12462, + 12523, + 12480, + 12540 + ] + ], + [ + [ + 13076, + 13076 + ], + "mapped", + [ + 12461, + 12525 + ] + ], + [ + [ + 13077, + 13077 + ], + "mapped", + [ + 12461, + 12525, + 12464, + 12521, + 12512 + ] + ], + [ + [ + 13078, + 13078 + ], + "mapped", + [ + 12461, + 12525, + 12513, + 12540, + 12488, + 12523 + ] + ], + [ + [ + 13079, + 13079 + ], + "mapped", + [ + 12461, + 12525, + 12527, + 12483, + 12488 + ] + ], + [ + [ + 13080, + 13080 + ], + "mapped", + [ + 12464, + 12521, + 12512 + ] + ], + [ + [ + 13081, + 13081 + ], + "mapped", + [ + 12464, + 12521, + 12512, + 12488, + 12531 + ] + ], + [ + [ + 13082, + 13082 + ], + "mapped", + [ + 12463, + 12523, + 12476, + 12452, + 12525 + ] + ], + [ + [ + 13083, + 13083 + ], + "mapped", + [ + 12463, + 12525, + 12540, + 12493 + ] + ], + [ + [ + 13084, + 13084 + ], + "mapped", + [ + 12465, + 12540, + 12473 + ] + ], + [ + [ + 13085, + 13085 + ], + "mapped", + [ + 12467, + 12523, + 12490 + ] + ], + [ + [ + 13086, + 13086 + ], + "mapped", + [ + 12467, + 12540, + 12509 + ] + ], + [ + [ + 13087, + 13087 + ], + "mapped", + [ + 12469, + 12452, + 12463, + 12523 + ] + ], + [ + [ + 13088, + 13088 + ], + "mapped", + [ + 12469, + 12531, + 12481, + 12540, + 12512 + ] + ], + [ + [ + 13089, + 13089 + ], + "mapped", + [ + 12471, + 12522, + 12531, + 12464 + ] + ], + [ + [ + 13090, + 13090 + ], + "mapped", + [ + 12475, + 12531, + 12481 + ] + ], + [ + [ + 13091, + 13091 + ], + "mapped", + [ + 12475, + 12531, + 12488 + ] + ], + [ + [ + 13092, + 13092 + ], + "mapped", + [ + 12480, + 12540, + 12473 + ] + ], + [ + [ + 13093, + 13093 + ], + "mapped", + [ + 12487, + 12471 + ] + ], + [ + [ + 13094, + 13094 + ], + "mapped", + [ + 12489, + 12523 + ] + ], + [ + [ + 13095, + 13095 + ], + "mapped", + [ + 12488, + 12531 + ] + ], + [ + [ + 13096, + 13096 + ], + "mapped", + [ + 12490, + 12494 + ] + ], + [ + [ + 13097, + 13097 + ], + "mapped", + [ + 12494, + 12483, + 12488 + ] + ], + [ + [ + 13098, + 13098 + ], + "mapped", + [ + 12495, + 12452, + 12484 + ] + ], + [ + [ + 13099, + 13099 + ], + "mapped", + [ + 12497, + 12540, + 12475, + 12531, + 12488 + ] + ], + [ + [ + 13100, + 13100 + ], + "mapped", + [ + 12497, + 12540, + 12484 + ] + ], + [ + [ + 13101, + 13101 + ], + "mapped", + [ + 12496, + 12540, + 12524, + 12523 + ] + ], + [ + [ + 13102, + 13102 + ], + "mapped", + [ + 12500, + 12450, + 12473, + 12488, + 12523 + ] + ], + [ + [ + 13103, + 13103 + ], + "mapped", + [ + 12500, + 12463, + 12523 + ] + ], + [ + [ + 13104, + 13104 + ], + "mapped", + [ + 12500, + 12467 + ] + ], + [ + [ + 13105, + 13105 + ], + "mapped", + [ + 12499, + 12523 + ] + ], + [ + [ + 13106, + 13106 + ], + "mapped", + [ + 12501, + 12449, + 12521, + 12483, + 12489 + ] + ], + [ + [ + 13107, + 13107 + ], + "mapped", + [ + 12501, + 12451, + 12540, + 12488 + ] + ], + [ + [ + 13108, + 13108 + ], + "mapped", + [ + 12502, + 12483, + 12471, + 12455, + 12523 + ] + ], + [ + [ + 13109, + 13109 + ], + "mapped", + [ + 12501, + 12521, + 12531 + ] + ], + [ + [ + 13110, + 13110 + ], + "mapped", + [ + 12504, + 12463, + 12479, + 12540, + 12523 + ] + ], + [ + [ + 13111, + 13111 + ], + "mapped", + [ + 12506, + 12477 + ] + ], + [ + [ + 13112, + 13112 + ], + "mapped", + [ + 12506, + 12491, + 12498 + ] + ], + [ + [ + 13113, + 13113 + ], + "mapped", + [ + 12504, + 12523, + 12484 + ] + ], + [ + [ + 13114, + 13114 + ], + "mapped", + [ + 12506, + 12531, + 12473 + ] + ], + [ + [ + 13115, + 13115 + ], + "mapped", + [ + 12506, + 12540, + 12472 + ] + ], + [ + [ + 13116, + 13116 + ], + "mapped", + [ + 12505, + 12540, + 12479 + ] + ], + [ + [ + 13117, + 13117 + ], + "mapped", + [ + 12509, + 12452, + 12531, + 12488 + ] + ], + [ + [ + 13118, + 13118 + ], + "mapped", + [ + 12508, + 12523, + 12488 + ] + ], + [ + [ + 13119, + 13119 + ], + "mapped", + [ + 12507, + 12531 + ] + ], + [ + [ + 13120, + 13120 + ], + "mapped", + [ + 12509, + 12531, + 12489 + ] + ], + [ + [ + 13121, + 13121 + ], + "mapped", + [ + 12507, + 12540, + 12523 + ] + ], + [ + [ + 13122, + 13122 + ], + "mapped", + [ + 12507, + 12540, + 12531 + ] + ], + [ + [ + 13123, + 13123 + ], + "mapped", + [ + 12510, + 12452, + 12463, + 12525 + ] + ], + [ + [ + 13124, + 13124 + ], + "mapped", + [ + 12510, + 12452, + 12523 + ] + ], + [ + [ + 13125, + 13125 + ], + "mapped", + [ + 12510, + 12483, + 12495 + ] + ], + [ + [ + 13126, + 13126 + ], + "mapped", + [ + 12510, + 12523, + 12463 + ] + ], + [ + [ + 13127, + 13127 + ], + "mapped", + [ + 12510, + 12531, + 12471, + 12519, + 12531 + ] + ], + [ + [ + 13128, + 13128 + ], + "mapped", + [ + 12511, + 12463, + 12525, + 12531 + ] + ], + [ + [ + 13129, + 13129 + ], + "mapped", + [ + 12511, + 12522 + ] + ], + [ + [ + 13130, + 13130 + ], + "mapped", + [ + 12511, + 12522, + 12496, + 12540, + 12523 + ] + ], + [ + [ + 13131, + 13131 + ], + "mapped", + [ + 12513, + 12460 + ] + ], + [ + [ + 13132, + 13132 + ], + "mapped", + [ + 12513, + 12460, + 12488, + 12531 + ] + ], + [ + [ + 13133, + 13133 + ], + "mapped", + [ + 12513, + 12540, + 12488, + 12523 + ] + ], + [ + [ + 13134, + 13134 + ], + "mapped", + [ + 12516, + 12540, + 12489 + ] + ], + [ + [ + 13135, + 13135 + ], + "mapped", + [ + 12516, + 12540, + 12523 + ] + ], + [ + [ + 13136, + 13136 + ], + "mapped", + [ + 12518, + 12450, + 12531 + ] + ], + [ + [ + 13137, + 13137 + ], + "mapped", + [ + 12522, + 12483, + 12488, + 12523 + ] + ], + [ + [ + 13138, + 13138 + ], + "mapped", + [ + 12522, + 12521 + ] + ], + [ + [ + 13139, + 13139 + ], + "mapped", + [ + 12523, + 12500, + 12540 + ] + ], + [ + [ + 13140, + 13140 + ], + "mapped", + [ + 12523, + 12540, + 12502, + 12523 + ] + ], + [ + [ + 13141, + 13141 + ], + "mapped", + [ + 12524, + 12512 + ] + ], + [ + [ + 13142, + 13142 + ], + "mapped", + [ + 12524, + 12531, + 12488, + 12466, + 12531 + ] + ], + [ + [ + 13143, + 13143 + ], + "mapped", + [ + 12527, + 12483, + 12488 + ] + ], + [ + [ + 13144, + 13144 + ], + "mapped", + [ + 48, + 28857 + ] + ], + [ + [ + 13145, + 13145 + ], + "mapped", + [ + 49, + 28857 + ] + ], + [ + [ + 13146, + 13146 + ], + "mapped", + [ + 50, + 28857 + ] + ], + [ + [ + 13147, + 13147 + ], + "mapped", + [ + 51, + 28857 + ] + ], + [ + [ + 13148, + 13148 + ], + "mapped", + [ + 52, + 28857 + ] + ], + [ + [ + 13149, + 13149 + ], + "mapped", + [ + 53, + 28857 + ] + ], + [ + [ + 13150, + 13150 + ], + "mapped", + [ + 54, + 28857 + ] + ], + [ + [ + 13151, + 13151 + ], + "mapped", + [ + 55, + 28857 + ] + ], + [ + [ + 13152, + 13152 + ], + "mapped", + [ + 56, + 28857 + ] + ], + [ + [ + 13153, + 13153 + ], + "mapped", + [ + 57, + 28857 + ] + ], + [ + [ + 13154, + 13154 + ], + "mapped", + [ + 49, + 48, + 28857 + ] + ], + [ + [ + 13155, + 13155 + ], + "mapped", + [ + 49, + 49, + 28857 + ] + ], + [ + [ + 13156, + 13156 + ], + "mapped", + [ + 49, + 50, + 28857 + ] + ], + [ + [ + 13157, + 13157 + ], + "mapped", + [ + 49, + 51, + 28857 + ] + ], + [ + [ + 13158, + 13158 + ], + "mapped", + [ + 49, + 52, + 28857 + ] + ], + [ + [ + 13159, + 13159 + ], + "mapped", + [ + 49, + 53, + 28857 + ] + ], + [ + [ + 13160, + 13160 + ], + "mapped", + [ + 49, + 54, + 28857 + ] + ], + [ + [ + 13161, + 13161 + ], + "mapped", + [ + 49, + 55, + 28857 + ] + ], + [ + [ + 13162, + 13162 + ], + "mapped", + [ + 49, + 56, + 28857 + ] + ], + [ + [ + 13163, + 13163 + ], + "mapped", + [ + 49, + 57, + 28857 + ] + ], + [ + [ + 13164, + 13164 + ], + "mapped", + [ + 50, + 48, + 28857 + ] + ], + [ + [ + 13165, + 13165 + ], + "mapped", + [ + 50, + 49, + 28857 + ] + ], + [ + [ + 13166, + 13166 + ], + "mapped", + [ + 50, + 50, + 28857 + ] + ], + [ + [ + 13167, + 13167 + ], + "mapped", + [ + 50, + 51, + 28857 + ] + ], + [ + [ + 13168, + 13168 + ], + "mapped", + [ + 50, + 52, + 28857 + ] + ], + [ + [ + 13169, + 13169 + ], + "mapped", + [ + 104, + 112, + 97 + ] + ], + [ + [ + 13170, + 13170 + ], + "mapped", + [ + 100, + 97 + ] + ], + [ + [ + 13171, + 13171 + ], + "mapped", + [ + 97, + 117 + ] + ], + [ + [ + 13172, + 13172 + ], + "mapped", + [ + 98, + 97, + 114 + ] + ], + [ + [ + 13173, + 13173 + ], + "mapped", + [ + 111, + 118 + ] + ], + [ + [ + 13174, + 13174 + ], + "mapped", + [ + 112, + 99 + ] + ], + [ + [ + 13175, + 13175 + ], + "mapped", + [ + 100, + 109 + ] + ], + [ + [ + 13176, + 13176 + ], + "mapped", + [ + 100, + 109, + 50 + ] + ], + [ + [ + 13177, + 13177 + ], + "mapped", + [ + 100, + 109, + 51 + ] + ], + [ + [ + 13178, + 13178 + ], + "mapped", + [ + 105, + 117 + ] + ], + [ + [ + 13179, + 13179 + ], + "mapped", + [ + 24179, + 25104 + ] + ], + [ + [ + 13180, + 13180 + ], + "mapped", + [ + 26157, + 21644 + ] + ], + [ + [ + 13181, + 13181 + ], + "mapped", + [ + 22823, + 27491 + ] + ], + [ + [ + 13182, + 13182 + ], + "mapped", + [ + 26126, + 27835 + ] + ], + [ + [ + 13183, + 13183 + ], + "mapped", + [ + 26666, + 24335, + 20250, + 31038 + ] + ], + [ + [ + 13184, + 13184 + ], + "mapped", + [ + 112, + 97 + ] + ], + [ + [ + 13185, + 13185 + ], + "mapped", + [ + 110, + 97 + ] + ], + [ + [ + 13186, + 13186 + ], + "mapped", + [ + 956, + 97 + ] + ], + [ + [ + 13187, + 13187 + ], + "mapped", + [ + 109, + 97 + ] + ], + [ + [ + 13188, + 13188 + ], + "mapped", + [ + 107, + 97 + ] + ], + [ + [ + 13189, + 13189 + ], + "mapped", + [ + 107, + 98 + ] + ], + [ + [ + 13190, + 13190 + ], + "mapped", + [ + 109, + 98 + ] + ], + [ + [ + 13191, + 13191 + ], + "mapped", + [ + 103, + 98 + ] + ], + [ + [ + 13192, + 13192 + ], + "mapped", + [ + 99, + 97, + 108 + ] + ], + [ + [ + 13193, + 13193 + ], + "mapped", + [ + 107, + 99, + 97, + 108 + ] + ], + [ + [ + 13194, + 13194 + ], + "mapped", + [ + 112, + 102 + ] + ], + [ + [ + 13195, + 13195 + ], + "mapped", + [ + 110, + 102 + ] + ], + [ + [ + 13196, + 13196 + ], + "mapped", + [ + 956, + 102 + ] + ], + [ + [ + 13197, + 13197 + ], + "mapped", + [ + 956, + 103 + ] + ], + [ + [ + 13198, + 13198 + ], + "mapped", + [ + 109, + 103 + ] + ], + [ + [ + 13199, + 13199 + ], + "mapped", + [ + 107, + 103 + ] + ], + [ + [ + 13200, + 13200 + ], + "mapped", + [ + 104, + 122 + ] + ], + [ + [ + 13201, + 13201 + ], + "mapped", + [ + 107, + 104, + 122 + ] + ], + [ + [ + 13202, + 13202 + ], + "mapped", + [ + 109, + 104, + 122 + ] + ], + [ + [ + 13203, + 13203 + ], + "mapped", + [ + 103, + 104, + 122 + ] + ], + [ + [ + 13204, + 13204 + ], + "mapped", + [ + 116, + 104, + 122 + ] + ], + [ + [ + 13205, + 13205 + ], + "mapped", + [ + 956, + 108 + ] + ], + [ + [ + 13206, + 13206 + ], + "mapped", + [ + 109, + 108 + ] + ], + [ + [ + 13207, + 13207 + ], + "mapped", + [ + 100, + 108 + ] + ], + [ + [ + 13208, + 13208 + ], + "mapped", + [ + 107, + 108 + ] + ], + [ + [ + 13209, + 13209 + ], + "mapped", + [ + 102, + 109 + ] + ], + [ + [ + 13210, + 13210 + ], + "mapped", + [ + 110, + 109 + ] + ], + [ + [ + 13211, + 13211 + ], + "mapped", + [ + 956, + 109 + ] + ], + [ + [ + 13212, + 13212 + ], + "mapped", + [ + 109, + 109 + ] + ], + [ + [ + 13213, + 13213 + ], + "mapped", + [ + 99, + 109 + ] + ], + [ + [ + 13214, + 13214 + ], + "mapped", + [ + 107, + 109 + ] + ], + [ + [ + 13215, + 13215 + ], + "mapped", + [ + 109, + 109, + 50 + ] + ], + [ + [ + 13216, + 13216 + ], + "mapped", + [ + 99, + 109, + 50 + ] + ], + [ + [ + 13217, + 13217 + ], + "mapped", + [ + 109, + 50 + ] + ], + [ + [ + 13218, + 13218 + ], + "mapped", + [ + 107, + 109, + 50 + ] + ], + [ + [ + 13219, + 13219 + ], + "mapped", + [ + 109, + 109, + 51 + ] + ], + [ + [ + 13220, + 13220 + ], + "mapped", + [ + 99, + 109, + 51 + ] + ], + [ + [ + 13221, + 13221 + ], + "mapped", + [ + 109, + 51 + ] + ], + [ + [ + 13222, + 13222 + ], + "mapped", + [ + 107, + 109, + 51 + ] + ], + [ + [ + 13223, + 13223 + ], + "mapped", + [ + 109, + 8725, + 115 + ] + ], + [ + [ + 13224, + 13224 + ], + "mapped", + [ + 109, + 8725, + 115, + 50 + ] + ], + [ + [ + 13225, + 13225 + ], + "mapped", + [ + 112, + 97 + ] + ], + [ + [ + 13226, + 13226 + ], + "mapped", + [ + 107, + 112, + 97 + ] + ], + [ + [ + 13227, + 13227 + ], + "mapped", + [ + 109, + 112, + 97 + ] + ], + [ + [ + 13228, + 13228 + ], + "mapped", + [ + 103, + 112, + 97 + ] + ], + [ + [ + 13229, + 13229 + ], + "mapped", + [ + 114, + 97, + 100 + ] + ], + [ + [ + 13230, + 13230 + ], + "mapped", + [ + 114, + 97, + 100, + 8725, + 115 + ] + ], + [ + [ + 13231, + 13231 + ], + "mapped", + [ + 114, + 97, + 100, + 8725, + 115, + 50 + ] + ], + [ + [ + 13232, + 13232 + ], + "mapped", + [ + 112, + 115 + ] + ], + [ + [ + 13233, + 13233 + ], + "mapped", + [ + 110, + 115 + ] + ], + [ + [ + 13234, + 13234 + ], + "mapped", + [ + 956, + 115 + ] + ], + [ + [ + 13235, + 13235 + ], + "mapped", + [ + 109, + 115 + ] + ], + [ + [ + 13236, + 13236 + ], + "mapped", + [ + 112, + 118 + ] + ], + [ + [ + 13237, + 13237 + ], + "mapped", + [ + 110, + 118 + ] + ], + [ + [ + 13238, + 13238 + ], + "mapped", + [ + 956, + 118 + ] + ], + [ + [ + 13239, + 13239 + ], + "mapped", + [ + 109, + 118 + ] + ], + [ + [ + 13240, + 13240 + ], + "mapped", + [ + 107, + 118 + ] + ], + [ + [ + 13241, + 13241 + ], + "mapped", + [ + 109, + 118 + ] + ], + [ + [ + 13242, + 13242 + ], + "mapped", + [ + 112, + 119 + ] + ], + [ + [ + 13243, + 13243 + ], + "mapped", + [ + 110, + 119 + ] + ], + [ + [ + 13244, + 13244 + ], + "mapped", + [ + 956, + 119 + ] + ], + [ + [ + 13245, + 13245 + ], + "mapped", + [ + 109, + 119 + ] + ], + [ + [ + 13246, + 13246 + ], + "mapped", + [ + 107, + 119 + ] + ], + [ + [ + 13247, + 13247 + ], + "mapped", + [ + 109, + 119 + ] + ], + [ + [ + 13248, + 13248 + ], + "mapped", + [ + 107, + 969 + ] + ], + [ + [ + 13249, + 13249 + ], + "mapped", + [ + 109, + 969 + ] + ], + [ + [ + 13250, + 13250 + ], + "disallowed" + ], + [ + [ + 13251, + 13251 + ], + "mapped", + [ + 98, + 113 + ] + ], + [ + [ + 13252, + 13252 + ], + "mapped", + [ + 99, + 99 + ] + ], + [ + [ + 13253, + 13253 + ], + "mapped", + [ + 99, + 100 + ] + ], + [ + [ + 13254, + 13254 + ], + "mapped", + [ + 99, + 8725, + 107, + 103 + ] + ], + [ + [ + 13255, + 13255 + ], + "disallowed" + ], + [ + [ + 13256, + 13256 + ], + "mapped", + [ + 100, + 98 + ] + ], + [ + [ + 13257, + 13257 + ], + "mapped", + [ + 103, + 121 + ] + ], + [ + [ + 13258, + 13258 + ], + "mapped", + [ + 104, + 97 + ] + ], + [ + [ + 13259, + 13259 + ], + "mapped", + [ + 104, + 112 + ] + ], + [ + [ + 13260, + 13260 + ], + "mapped", + [ + 105, + 110 + ] + ], + [ + [ + 13261, + 13261 + ], + "mapped", + [ + 107, + 107 + ] + ], + [ + [ + 13262, + 13262 + ], + "mapped", + [ + 107, + 109 + ] + ], + [ + [ + 13263, + 13263 + ], + "mapped", + [ + 107, + 116 + ] + ], + [ + [ + 13264, + 13264 + ], + "mapped", + [ + 108, + 109 + ] + ], + [ + [ + 13265, + 13265 + ], + "mapped", + [ + 108, + 110 + ] + ], + [ + [ + 13266, + 13266 + ], + "mapped", + [ + 108, + 111, + 103 + ] + ], + [ + [ + 13267, + 13267 + ], + "mapped", + [ + 108, + 120 + ] + ], + [ + [ + 13268, + 13268 + ], + "mapped", + [ + 109, + 98 + ] + ], + [ + [ + 13269, + 13269 + ], + "mapped", + [ + 109, + 105, + 108 + ] + ], + [ + [ + 13270, + 13270 + ], + "mapped", + [ + 109, + 111, + 108 + ] + ], + [ + [ + 13271, + 13271 + ], + "mapped", + [ + 112, + 104 + ] + ], + [ + [ + 13272, + 13272 + ], + "disallowed" + ], + [ + [ + 13273, + 13273 + ], + "mapped", + [ + 112, + 112, + 109 + ] + ], + [ + [ + 13274, + 13274 + ], + "mapped", + [ + 112, + 114 + ] + ], + [ + [ + 13275, + 13275 + ], + "mapped", + [ + 115, + 114 + ] + ], + [ + [ + 13276, + 13276 + ], + "mapped", + [ + 115, + 118 + ] + ], + [ + [ + 13277, + 13277 + ], + "mapped", + [ + 119, + 98 + ] + ], + [ + [ + 13278, + 13278 + ], + "mapped", + [ + 118, + 8725, + 109 + ] + ], + [ + [ + 13279, + 13279 + ], + "mapped", + [ + 97, + 8725, + 109 + ] + ], + [ + [ + 13280, + 13280 + ], + "mapped", + [ + 49, + 26085 + ] + ], + [ + [ + 13281, + 13281 + ], + "mapped", + [ + 50, + 26085 + ] + ], + [ + [ + 13282, + 13282 + ], + "mapped", + [ + 51, + 26085 + ] + ], + [ + [ + 13283, + 13283 + ], + "mapped", + [ + 52, + 26085 + ] + ], + [ + [ + 13284, + 13284 + ], + "mapped", + [ + 53, + 26085 + ] + ], + [ + [ + 13285, + 13285 + ], + "mapped", + [ + 54, + 26085 + ] + ], + [ + [ + 13286, + 13286 + ], + "mapped", + [ + 55, + 26085 + ] + ], + [ + [ + 13287, + 13287 + ], + "mapped", + [ + 56, + 26085 + ] + ], + [ + [ + 13288, + 13288 + ], + "mapped", + [ + 57, + 26085 + ] + ], + [ + [ + 13289, + 13289 + ], + "mapped", + [ + 49, + 48, + 26085 + ] + ], + [ + [ + 13290, + 13290 + ], + "mapped", + [ + 49, + 49, + 26085 + ] + ], + [ + [ + 13291, + 13291 + ], + "mapped", + [ + 49, + 50, + 26085 + ] + ], + [ + [ + 13292, + 13292 + ], + "mapped", + [ + 49, + 51, + 26085 + ] + ], + [ + [ + 13293, + 13293 + ], + "mapped", + [ + 49, + 52, + 26085 + ] + ], + [ + [ + 13294, + 13294 + ], + "mapped", + [ + 49, + 53, + 26085 + ] + ], + [ + [ + 13295, + 13295 + ], + "mapped", + [ + 49, + 54, + 26085 + ] + ], + [ + [ + 13296, + 13296 + ], + "mapped", + [ + 49, + 55, + 26085 + ] + ], + [ + [ + 13297, + 13297 + ], + "mapped", + [ + 49, + 56, + 26085 + ] + ], + [ + [ + 13298, + 13298 + ], + "mapped", + [ + 49, + 57, + 26085 + ] + ], + [ + [ + 13299, + 13299 + ], + "mapped", + [ + 50, + 48, + 26085 + ] + ], + [ + [ + 13300, + 13300 + ], + "mapped", + [ + 50, + 49, + 26085 + ] + ], + [ + [ + 13301, + 13301 + ], + "mapped", + [ + 50, + 50, + 26085 + ] + ], + [ + [ + 13302, + 13302 + ], + "mapped", + [ + 50, + 51, + 26085 + ] + ], + [ + [ + 13303, + 13303 + ], + "mapped", + [ + 50, + 52, + 26085 + ] + ], + [ + [ + 13304, + 13304 + ], + "mapped", + [ + 50, + 53, + 26085 + ] + ], + [ + [ + 13305, + 13305 + ], + "mapped", + [ + 50, + 54, + 26085 + ] + ], + [ + [ + 13306, + 13306 + ], + "mapped", + [ + 50, + 55, + 26085 + ] + ], + [ + [ + 13307, + 13307 + ], + "mapped", + [ + 50, + 56, + 26085 + ] + ], + [ + [ + 13308, + 13308 + ], + "mapped", + [ + 50, + 57, + 26085 + ] + ], + [ + [ + 13309, + 13309 + ], + "mapped", + [ + 51, + 48, + 26085 + ] + ], + [ + [ + 13310, + 13310 + ], + "mapped", + [ + 51, + 49, + 26085 + ] + ], + [ + [ + 13311, + 13311 + ], + "mapped", + [ + 103, + 97, + 108 + ] + ], + [ + [ + 13312, + 19893 + ], + "valid" + ], + [ + [ + 19894, + 19903 + ], + "disallowed" + ], + [ + [ + 19904, + 19967 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 19968, + 40869 + ], + "valid" + ], + [ + [ + 40870, + 40891 + ], + "valid" + ], + [ + [ + 40892, + 40899 + ], + "valid" + ], + [ + [ + 40900, + 40907 + ], + "valid" + ], + [ + [ + 40908, + 40908 + ], + "valid" + ], + [ + [ + 40909, + 40917 + ], + "valid" + ], + [ + [ + 40918, + 40959 + ], + "disallowed" + ], + [ + [ + 40960, + 42124 + ], + "valid" + ], + [ + [ + 42125, + 42127 + ], + "disallowed" + ], + [ + [ + 42128, + 42145 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42146, + 42147 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42148, + 42163 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42164, + 42164 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42165, + 42176 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42177, + 42177 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42178, + 42180 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42181, + 42181 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42182, + 42182 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42183, + 42191 + ], + "disallowed" + ], + [ + [ + 42192, + 42237 + ], + "valid" + ], + [ + [ + 42238, + 42239 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42240, + 42508 + ], + "valid" + ], + [ + [ + 42509, + 42511 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42512, + 42539 + ], + "valid" + ], + [ + [ + 42540, + 42559 + ], + "disallowed" + ], + [ + [ + 42560, + 42560 + ], + "mapped", + [ + 42561 + ] + ], + [ + [ + 42561, + 42561 + ], + "valid" + ], + [ + [ + 42562, + 42562 + ], + "mapped", + [ + 42563 + ] + ], + [ + [ + 42563, + 42563 + ], + "valid" + ], + [ + [ + 42564, + 42564 + ], + "mapped", + [ + 42565 + ] + ], + [ + [ + 42565, + 42565 + ], + "valid" + ], + [ + [ + 42566, + 42566 + ], + "mapped", + [ + 42567 + ] + ], + [ + [ + 42567, + 42567 + ], + "valid" + ], + [ + [ + 42568, + 42568 + ], + "mapped", + [ + 42569 + ] + ], + [ + [ + 42569, + 42569 + ], + "valid" + ], + [ + [ + 42570, + 42570 + ], + "mapped", + [ + 42571 + ] + ], + [ + [ + 42571, + 42571 + ], + "valid" + ], + [ + [ + 42572, + 42572 + ], + "mapped", + [ + 42573 + ] + ], + [ + [ + 42573, + 42573 + ], + "valid" + ], + [ + [ + 42574, + 42574 + ], + "mapped", + [ + 42575 + ] + ], + [ + [ + 42575, + 42575 + ], + "valid" + ], + [ + [ + 42576, + 42576 + ], + "mapped", + [ + 42577 + ] + ], + [ + [ + 42577, + 42577 + ], + "valid" + ], + [ + [ + 42578, + 42578 + ], + "mapped", + [ + 42579 + ] + ], + [ + [ + 42579, + 42579 + ], + "valid" + ], + [ + [ + 42580, + 42580 + ], + "mapped", + [ + 42581 + ] + ], + [ + [ + 42581, + 42581 + ], + "valid" + ], + [ + [ + 42582, + 42582 + ], + "mapped", + [ + 42583 + ] + ], + [ + [ + 42583, + 42583 + ], + "valid" + ], + [ + [ + 42584, + 42584 + ], + "mapped", + [ + 42585 + ] + ], + [ + [ + 42585, + 42585 + ], + "valid" + ], + [ + [ + 42586, + 42586 + ], + "mapped", + [ + 42587 + ] + ], + [ + [ + 42587, + 42587 + ], + "valid" + ], + [ + [ + 42588, + 42588 + ], + "mapped", + [ + 42589 + ] + ], + [ + [ + 42589, + 42589 + ], + "valid" + ], + [ + [ + 42590, + 42590 + ], + "mapped", + [ + 42591 + ] + ], + [ + [ + 42591, + 42591 + ], + "valid" + ], + [ + [ + 42592, + 42592 + ], + "mapped", + [ + 42593 + ] + ], + [ + [ + 42593, + 42593 + ], + "valid" + ], + [ + [ + 42594, + 42594 + ], + "mapped", + [ + 42595 + ] + ], + [ + [ + 42595, + 42595 + ], + "valid" + ], + [ + [ + 42596, + 42596 + ], + "mapped", + [ + 42597 + ] + ], + [ + [ + 42597, + 42597 + ], + "valid" + ], + [ + [ + 42598, + 42598 + ], + "mapped", + [ + 42599 + ] + ], + [ + [ + 42599, + 42599 + ], + "valid" + ], + [ + [ + 42600, + 42600 + ], + "mapped", + [ + 42601 + ] + ], + [ + [ + 42601, + 42601 + ], + "valid" + ], + [ + [ + 42602, + 42602 + ], + "mapped", + [ + 42603 + ] + ], + [ + [ + 42603, + 42603 + ], + "valid" + ], + [ + [ + 42604, + 42604 + ], + "mapped", + [ + 42605 + ] + ], + [ + [ + 42605, + 42607 + ], + "valid" + ], + [ + [ + 42608, + 42611 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42612, + 42619 + ], + "valid" + ], + [ + [ + 42620, + 42621 + ], + "valid" + ], + [ + [ + 42622, + 42622 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42623, + 42623 + ], + "valid" + ], + [ + [ + 42624, + 42624 + ], + "mapped", + [ + 42625 + ] + ], + [ + [ + 42625, + 42625 + ], + "valid" + ], + [ + [ + 42626, + 42626 + ], + "mapped", + [ + 42627 + ] + ], + [ + [ + 42627, + 42627 + ], + "valid" + ], + [ + [ + 42628, + 42628 + ], + "mapped", + [ + 42629 + ] + ], + [ + [ + 42629, + 42629 + ], + "valid" + ], + [ + [ + 42630, + 42630 + ], + "mapped", + [ + 42631 + ] + ], + [ + [ + 42631, + 42631 + ], + "valid" + ], + [ + [ + 42632, + 42632 + ], + "mapped", + [ + 42633 + ] + ], + [ + [ + 42633, + 42633 + ], + "valid" + ], + [ + [ + 42634, + 42634 + ], + "mapped", + [ + 42635 + ] + ], + [ + [ + 42635, + 42635 + ], + "valid" + ], + [ + [ + 42636, + 42636 + ], + "mapped", + [ + 42637 + ] + ], + [ + [ + 42637, + 42637 + ], + "valid" + ], + [ + [ + 42638, + 42638 + ], + "mapped", + [ + 42639 + ] + ], + [ + [ + 42639, + 42639 + ], + "valid" + ], + [ + [ + 42640, + 42640 + ], + "mapped", + [ + 42641 + ] + ], + [ + [ + 42641, + 42641 + ], + "valid" + ], + [ + [ + 42642, + 42642 + ], + "mapped", + [ + 42643 + ] + ], + [ + [ + 42643, + 42643 + ], + "valid" + ], + [ + [ + 42644, + 42644 + ], + "mapped", + [ + 42645 + ] + ], + [ + [ + 42645, + 42645 + ], + "valid" + ], + [ + [ + 42646, + 42646 + ], + "mapped", + [ + 42647 + ] + ], + [ + [ + 42647, + 42647 + ], + "valid" + ], + [ + [ + 42648, + 42648 + ], + "mapped", + [ + 42649 + ] + ], + [ + [ + 42649, + 42649 + ], + "valid" + ], + [ + [ + 42650, + 42650 + ], + "mapped", + [ + 42651 + ] + ], + [ + [ + 42651, + 42651 + ], + "valid" + ], + [ + [ + 42652, + 42652 + ], + "mapped", + [ + 1098 + ] + ], + [ + [ + 42653, + 42653 + ], + "mapped", + [ + 1100 + ] + ], + [ + [ + 42654, + 42654 + ], + "valid" + ], + [ + [ + 42655, + 42655 + ], + "valid" + ], + [ + [ + 42656, + 42725 + ], + "valid" + ], + [ + [ + 42726, + 42735 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42736, + 42737 + ], + "valid" + ], + [ + [ + 42738, + 42743 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42744, + 42751 + ], + "disallowed" + ], + [ + [ + 42752, + 42774 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42775, + 42778 + ], + "valid" + ], + [ + [ + 42779, + 42783 + ], + "valid" + ], + [ + [ + 42784, + 42785 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42786, + 42786 + ], + "mapped", + [ + 42787 + ] + ], + [ + [ + 42787, + 42787 + ], + "valid" + ], + [ + [ + 42788, + 42788 + ], + "mapped", + [ + 42789 + ] + ], + [ + [ + 42789, + 42789 + ], + "valid" + ], + [ + [ + 42790, + 42790 + ], + "mapped", + [ + 42791 + ] + ], + [ + [ + 42791, + 42791 + ], + "valid" + ], + [ + [ + 42792, + 42792 + ], + "mapped", + [ + 42793 + ] + ], + [ + [ + 42793, + 42793 + ], + "valid" + ], + [ + [ + 42794, + 42794 + ], + "mapped", + [ + 42795 + ] + ], + [ + [ + 42795, + 42795 + ], + "valid" + ], + [ + [ + 42796, + 42796 + ], + "mapped", + [ + 42797 + ] + ], + [ + [ + 42797, + 42797 + ], + "valid" + ], + [ + [ + 42798, + 42798 + ], + "mapped", + [ + 42799 + ] + ], + [ + [ + 42799, + 42801 + ], + "valid" + ], + [ + [ + 42802, + 42802 + ], + "mapped", + [ + 42803 + ] + ], + [ + [ + 42803, + 42803 + ], + "valid" + ], + [ + [ + 42804, + 42804 + ], + "mapped", + [ + 42805 + ] + ], + [ + [ + 42805, + 42805 + ], + "valid" + ], + [ + [ + 42806, + 42806 + ], + "mapped", + [ + 42807 + ] + ], + [ + [ + 42807, + 42807 + ], + "valid" + ], + [ + [ + 42808, + 42808 + ], + "mapped", + [ + 42809 + ] + ], + [ + [ + 42809, + 42809 + ], + "valid" + ], + [ + [ + 42810, + 42810 + ], + "mapped", + [ + 42811 + ] + ], + [ + [ + 42811, + 42811 + ], + "valid" + ], + [ + [ + 42812, + 42812 + ], + "mapped", + [ + 42813 + ] + ], + [ + [ + 42813, + 42813 + ], + "valid" + ], + [ + [ + 42814, + 42814 + ], + "mapped", + [ + 42815 + ] + ], + [ + [ + 42815, + 42815 + ], + "valid" + ], + [ + [ + 42816, + 42816 + ], + "mapped", + [ + 42817 + ] + ], + [ + [ + 42817, + 42817 + ], + "valid" + ], + [ + [ + 42818, + 42818 + ], + "mapped", + [ + 42819 + ] + ], + [ + [ + 42819, + 42819 + ], + "valid" + ], + [ + [ + 42820, + 42820 + ], + "mapped", + [ + 42821 + ] + ], + [ + [ + 42821, + 42821 + ], + "valid" + ], + [ + [ + 42822, + 42822 + ], + "mapped", + [ + 42823 + ] + ], + [ + [ + 42823, + 42823 + ], + "valid" + ], + [ + [ + 42824, + 42824 + ], + "mapped", + [ + 42825 + ] + ], + [ + [ + 42825, + 42825 + ], + "valid" + ], + [ + [ + 42826, + 42826 + ], + "mapped", + [ + 42827 + ] + ], + [ + [ + 42827, + 42827 + ], + "valid" + ], + [ + [ + 42828, + 42828 + ], + "mapped", + [ + 42829 + ] + ], + [ + [ + 42829, + 42829 + ], + "valid" + ], + [ + [ + 42830, + 42830 + ], + "mapped", + [ + 42831 + ] + ], + [ + [ + 42831, + 42831 + ], + "valid" + ], + [ + [ + 42832, + 42832 + ], + "mapped", + [ + 42833 + ] + ], + [ + [ + 42833, + 42833 + ], + "valid" + ], + [ + [ + 42834, + 42834 + ], + "mapped", + [ + 42835 + ] + ], + [ + [ + 42835, + 42835 + ], + "valid" + ], + [ + [ + 42836, + 42836 + ], + "mapped", + [ + 42837 + ] + ], + [ + [ + 42837, + 42837 + ], + "valid" + ], + [ + [ + 42838, + 42838 + ], + "mapped", + [ + 42839 + ] + ], + [ + [ + 42839, + 42839 + ], + "valid" + ], + [ + [ + 42840, + 42840 + ], + "mapped", + [ + 42841 + ] + ], + [ + [ + 42841, + 42841 + ], + "valid" + ], + [ + [ + 42842, + 42842 + ], + "mapped", + [ + 42843 + ] + ], + [ + [ + 42843, + 42843 + ], + "valid" + ], + [ + [ + 42844, + 42844 + ], + "mapped", + [ + 42845 + ] + ], + [ + [ + 42845, + 42845 + ], + "valid" + ], + [ + [ + 42846, + 42846 + ], + "mapped", + [ + 42847 + ] + ], + [ + [ + 42847, + 42847 + ], + "valid" + ], + [ + [ + 42848, + 42848 + ], + "mapped", + [ + 42849 + ] + ], + [ + [ + 42849, + 42849 + ], + "valid" + ], + [ + [ + 42850, + 42850 + ], + "mapped", + [ + 42851 + ] + ], + [ + [ + 42851, + 42851 + ], + "valid" + ], + [ + [ + 42852, + 42852 + ], + "mapped", + [ + 42853 + ] + ], + [ + [ + 42853, + 42853 + ], + "valid" + ], + [ + [ + 42854, + 42854 + ], + "mapped", + [ + 42855 + ] + ], + [ + [ + 42855, + 42855 + ], + "valid" + ], + [ + [ + 42856, + 42856 + ], + "mapped", + [ + 42857 + ] + ], + [ + [ + 42857, + 42857 + ], + "valid" + ], + [ + [ + 42858, + 42858 + ], + "mapped", + [ + 42859 + ] + ], + [ + [ + 42859, + 42859 + ], + "valid" + ], + [ + [ + 42860, + 42860 + ], + "mapped", + [ + 42861 + ] + ], + [ + [ + 42861, + 42861 + ], + "valid" + ], + [ + [ + 42862, + 42862 + ], + "mapped", + [ + 42863 + ] + ], + [ + [ + 42863, + 42863 + ], + "valid" + ], + [ + [ + 42864, + 42864 + ], + "mapped", + [ + 42863 + ] + ], + [ + [ + 42865, + 42872 + ], + "valid" + ], + [ + [ + 42873, + 42873 + ], + "mapped", + [ + 42874 + ] + ], + [ + [ + 42874, + 42874 + ], + "valid" + ], + [ + [ + 42875, + 42875 + ], + "mapped", + [ + 42876 + ] + ], + [ + [ + 42876, + 42876 + ], + "valid" + ], + [ + [ + 42877, + 42877 + ], + "mapped", + [ + 7545 + ] + ], + [ + [ + 42878, + 42878 + ], + "mapped", + [ + 42879 + ] + ], + [ + [ + 42879, + 42879 + ], + "valid" + ], + [ + [ + 42880, + 42880 + ], + "mapped", + [ + 42881 + ] + ], + [ + [ + 42881, + 42881 + ], + "valid" + ], + [ + [ + 42882, + 42882 + ], + "mapped", + [ + 42883 + ] + ], + [ + [ + 42883, + 42883 + ], + "valid" + ], + [ + [ + 42884, + 42884 + ], + "mapped", + [ + 42885 + ] + ], + [ + [ + 42885, + 42885 + ], + "valid" + ], + [ + [ + 42886, + 42886 + ], + "mapped", + [ + 42887 + ] + ], + [ + [ + 42887, + 42888 + ], + "valid" + ], + [ + [ + 42889, + 42890 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 42891, + 42891 + ], + "mapped", + [ + 42892 + ] + ], + [ + [ + 42892, + 42892 + ], + "valid" + ], + [ + [ + 42893, + 42893 + ], + "mapped", + [ + 613 + ] + ], + [ + [ + 42894, + 42894 + ], + "valid" + ], + [ + [ + 42895, + 42895 + ], + "valid" + ], + [ + [ + 42896, + 42896 + ], + "mapped", + [ + 42897 + ] + ], + [ + [ + 42897, + 42897 + ], + "valid" + ], + [ + [ + 42898, + 42898 + ], + "mapped", + [ + 42899 + ] + ], + [ + [ + 42899, + 42899 + ], + "valid" + ], + [ + [ + 42900, + 42901 + ], + "valid" + ], + [ + [ + 42902, + 42902 + ], + "mapped", + [ + 42903 + ] + ], + [ + [ + 42903, + 42903 + ], + "valid" + ], + [ + [ + 42904, + 42904 + ], + "mapped", + [ + 42905 + ] + ], + [ + [ + 42905, + 42905 + ], + "valid" + ], + [ + [ + 42906, + 42906 + ], + "mapped", + [ + 42907 + ] + ], + [ + [ + 42907, + 42907 + ], + "valid" + ], + [ + [ + 42908, + 42908 + ], + "mapped", + [ + 42909 + ] + ], + [ + [ + 42909, + 42909 + ], + "valid" + ], + [ + [ + 42910, + 42910 + ], + "mapped", + [ + 42911 + ] + ], + [ + [ + 42911, + 42911 + ], + "valid" + ], + [ + [ + 42912, + 42912 + ], + "mapped", + [ + 42913 + ] + ], + [ + [ + 42913, + 42913 + ], + "valid" + ], + [ + [ + 42914, + 42914 + ], + "mapped", + [ + 42915 + ] + ], + [ + [ + 42915, + 42915 + ], + "valid" + ], + [ + [ + 42916, + 42916 + ], + "mapped", + [ + 42917 + ] + ], + [ + [ + 42917, + 42917 + ], + "valid" + ], + [ + [ + 42918, + 42918 + ], + "mapped", + [ + 42919 + ] + ], + [ + [ + 42919, + 42919 + ], + "valid" + ], + [ + [ + 42920, + 42920 + ], + "mapped", + [ + 42921 + ] + ], + [ + [ + 42921, + 42921 + ], + "valid" + ], + [ + [ + 42922, + 42922 + ], + "mapped", + [ + 614 + ] + ], + [ + [ + 42923, + 42923 + ], + "mapped", + [ + 604 + ] + ], + [ + [ + 42924, + 42924 + ], + "mapped", + [ + 609 + ] + ], + [ + [ + 42925, + 42925 + ], + "mapped", + [ + 620 + ] + ], + [ + [ + 42926, + 42927 + ], + "disallowed" + ], + [ + [ + 42928, + 42928 + ], + "mapped", + [ + 670 + ] + ], + [ + [ + 42929, + 42929 + ], + "mapped", + [ + 647 + ] + ], + [ + [ + 42930, + 42930 + ], + "mapped", + [ + 669 + ] + ], + [ + [ + 42931, + 42931 + ], + "mapped", + [ + 43859 + ] + ], + [ + [ + 42932, + 42932 + ], + "mapped", + [ + 42933 + ] + ], + [ + [ + 42933, + 42933 + ], + "valid" + ], + [ + [ + 42934, + 42934 + ], + "mapped", + [ + 42935 + ] + ], + [ + [ + 42935, + 42935 + ], + "valid" + ], + [ + [ + 42936, + 42998 + ], + "disallowed" + ], + [ + [ + 42999, + 42999 + ], + "valid" + ], + [ + [ + 43000, + 43000 + ], + "mapped", + [ + 295 + ] + ], + [ + [ + 43001, + 43001 + ], + "mapped", + [ + 339 + ] + ], + [ + [ + 43002, + 43002 + ], + "valid" + ], + [ + [ + 43003, + 43007 + ], + "valid" + ], + [ + [ + 43008, + 43047 + ], + "valid" + ], + [ + [ + 43048, + 43051 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 43052, + 43055 + ], + "disallowed" + ], + [ + [ + 43056, + 43065 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 43066, + 43071 + ], + "disallowed" + ], + [ + [ + 43072, + 43123 + ], + "valid" + ], + [ + [ + 43124, + 43127 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 43128, + 43135 + ], + "disallowed" + ], + [ + [ + 43136, + 43204 + ], + "valid" + ], + [ + [ + 43205, + 43213 + ], + "disallowed" + ], + [ + [ + 43214, + 43215 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 43216, + 43225 + ], + "valid" + ], + [ + [ + 43226, + 43231 + ], + "disallowed" + ], + [ + [ + 43232, + 43255 + ], + "valid" + ], + [ + [ + 43256, + 43258 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 43259, + 43259 + ], + "valid" + ], + [ + [ + 43260, + 43260 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 43261, + 43261 + ], + "valid" + ], + [ + [ + 43262, + 43263 + ], + "disallowed" + ], + [ + [ + 43264, + 43309 + ], + "valid" + ], + [ + [ + 43310, + 43311 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 43312, + 43347 + ], + "valid" + ], + [ + [ + 43348, + 43358 + ], + "disallowed" + ], + [ + [ + 43359, + 43359 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 43360, + 43388 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 43389, + 43391 + ], + "disallowed" + ], + [ + [ + 43392, + 43456 + ], + "valid" + ], + [ + [ + 43457, + 43469 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 43470, + 43470 + ], + "disallowed" + ], + [ + [ + 43471, + 43481 + ], + "valid" + ], + [ + [ + 43482, + 43485 + ], + "disallowed" + ], + [ + [ + 43486, + 43487 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 43488, + 43518 + ], + "valid" + ], + [ + [ + 43519, + 43519 + ], + "disallowed" + ], + [ + [ + 43520, + 43574 + ], + "valid" + ], + [ + [ + 43575, + 43583 + ], + "disallowed" + ], + [ + [ + 43584, + 43597 + ], + "valid" + ], + [ + [ + 43598, + 43599 + ], + "disallowed" + ], + [ + [ + 43600, + 43609 + ], + "valid" + ], + [ + [ + 43610, + 43611 + ], + "disallowed" + ], + [ + [ + 43612, + 43615 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 43616, + 43638 + ], + "valid" + ], + [ + [ + 43639, + 43641 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 43642, + 43643 + ], + "valid" + ], + [ + [ + 43644, + 43647 + ], + "valid" + ], + [ + [ + 43648, + 43714 + ], + "valid" + ], + [ + [ + 43715, + 43738 + ], + "disallowed" + ], + [ + [ + 43739, + 43741 + ], + "valid" + ], + [ + [ + 43742, + 43743 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 43744, + 43759 + ], + "valid" + ], + [ + [ + 43760, + 43761 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 43762, + 43766 + ], + "valid" + ], + [ + [ + 43767, + 43776 + ], + "disallowed" + ], + [ + [ + 43777, + 43782 + ], + "valid" + ], + [ + [ + 43783, + 43784 + ], + "disallowed" + ], + [ + [ + 43785, + 43790 + ], + "valid" + ], + [ + [ + 43791, + 43792 + ], + "disallowed" + ], + [ + [ + 43793, + 43798 + ], + "valid" + ], + [ + [ + 43799, + 43807 + ], + "disallowed" + ], + [ + [ + 43808, + 43814 + ], + "valid" + ], + [ + [ + 43815, + 43815 + ], + "disallowed" + ], + [ + [ + 43816, + 43822 + ], + "valid" + ], + [ + [ + 43823, + 43823 + ], + "disallowed" + ], + [ + [ + 43824, + 43866 + ], + "valid" + ], + [ + [ + 43867, + 43867 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 43868, + 43868 + ], + "mapped", + [ + 42791 + ] + ], + [ + [ + 43869, + 43869 + ], + "mapped", + [ + 43831 + ] + ], + [ + [ + 43870, + 43870 + ], + "mapped", + [ + 619 + ] + ], + [ + [ + 43871, + 43871 + ], + "mapped", + [ + 43858 + ] + ], + [ + [ + 43872, + 43875 + ], + "valid" + ], + [ + [ + 43876, + 43877 + ], + "valid" + ], + [ + [ + 43878, + 43887 + ], + "disallowed" + ], + [ + [ + 43888, + 43888 + ], + "mapped", + [ + 5024 + ] + ], + [ + [ + 43889, + 43889 + ], + "mapped", + [ + 5025 + ] + ], + [ + [ + 43890, + 43890 + ], + "mapped", + [ + 5026 + ] + ], + [ + [ + 43891, + 43891 + ], + "mapped", + [ + 5027 + ] + ], + [ + [ + 43892, + 43892 + ], + "mapped", + [ + 5028 + ] + ], + [ + [ + 43893, + 43893 + ], + "mapped", + [ + 5029 + ] + ], + [ + [ + 43894, + 43894 + ], + "mapped", + [ + 5030 + ] + ], + [ + [ + 43895, + 43895 + ], + "mapped", + [ + 5031 + ] + ], + [ + [ + 43896, + 43896 + ], + "mapped", + [ + 5032 + ] + ], + [ + [ + 43897, + 43897 + ], + "mapped", + [ + 5033 + ] + ], + [ + [ + 43898, + 43898 + ], + "mapped", + [ + 5034 + ] + ], + [ + [ + 43899, + 43899 + ], + "mapped", + [ + 5035 + ] + ], + [ + [ + 43900, + 43900 + ], + "mapped", + [ + 5036 + ] + ], + [ + [ + 43901, + 43901 + ], + "mapped", + [ + 5037 + ] + ], + [ + [ + 43902, + 43902 + ], + "mapped", + [ + 5038 + ] + ], + [ + [ + 43903, + 43903 + ], + "mapped", + [ + 5039 + ] + ], + [ + [ + 43904, + 43904 + ], + "mapped", + [ + 5040 + ] + ], + [ + [ + 43905, + 43905 + ], + "mapped", + [ + 5041 + ] + ], + [ + [ + 43906, + 43906 + ], + "mapped", + [ + 5042 + ] + ], + [ + [ + 43907, + 43907 + ], + "mapped", + [ + 5043 + ] + ], + [ + [ + 43908, + 43908 + ], + "mapped", + [ + 5044 + ] + ], + [ + [ + 43909, + 43909 + ], + "mapped", + [ + 5045 + ] + ], + [ + [ + 43910, + 43910 + ], + "mapped", + [ + 5046 + ] + ], + [ + [ + 43911, + 43911 + ], + "mapped", + [ + 5047 + ] + ], + [ + [ + 43912, + 43912 + ], + "mapped", + [ + 5048 + ] + ], + [ + [ + 43913, + 43913 + ], + "mapped", + [ + 5049 + ] + ], + [ + [ + 43914, + 43914 + ], + "mapped", + [ + 5050 + ] + ], + [ + [ + 43915, + 43915 + ], + "mapped", + [ + 5051 + ] + ], + [ + [ + 43916, + 43916 + ], + "mapped", + [ + 5052 + ] + ], + [ + [ + 43917, + 43917 + ], + "mapped", + [ + 5053 + ] + ], + [ + [ + 43918, + 43918 + ], + "mapped", + [ + 5054 + ] + ], + [ + [ + 43919, + 43919 + ], + "mapped", + [ + 5055 + ] + ], + [ + [ + 43920, + 43920 + ], + "mapped", + [ + 5056 + ] + ], + [ + [ + 43921, + 43921 + ], + "mapped", + [ + 5057 + ] + ], + [ + [ + 43922, + 43922 + ], + "mapped", + [ + 5058 + ] + ], + [ + [ + 43923, + 43923 + ], + "mapped", + [ + 5059 + ] + ], + [ + [ + 43924, + 43924 + ], + "mapped", + [ + 5060 + ] + ], + [ + [ + 43925, + 43925 + ], + "mapped", + [ + 5061 + ] + ], + [ + [ + 43926, + 43926 + ], + "mapped", + [ + 5062 + ] + ], + [ + [ + 43927, + 43927 + ], + "mapped", + [ + 5063 + ] + ], + [ + [ + 43928, + 43928 + ], + "mapped", + [ + 5064 + ] + ], + [ + [ + 43929, + 43929 + ], + "mapped", + [ + 5065 + ] + ], + [ + [ + 43930, + 43930 + ], + "mapped", + [ + 5066 + ] + ], + [ + [ + 43931, + 43931 + ], + "mapped", + [ + 5067 + ] + ], + [ + [ + 43932, + 43932 + ], + "mapped", + [ + 5068 + ] + ], + [ + [ + 43933, + 43933 + ], + "mapped", + [ + 5069 + ] + ], + [ + [ + 43934, + 43934 + ], + "mapped", + [ + 5070 + ] + ], + [ + [ + 43935, + 43935 + ], + "mapped", + [ + 5071 + ] + ], + [ + [ + 43936, + 43936 + ], + "mapped", + [ + 5072 + ] + ], + [ + [ + 43937, + 43937 + ], + "mapped", + [ + 5073 + ] + ], + [ + [ + 43938, + 43938 + ], + "mapped", + [ + 5074 + ] + ], + [ + [ + 43939, + 43939 + ], + "mapped", + [ + 5075 + ] + ], + [ + [ + 43940, + 43940 + ], + "mapped", + [ + 5076 + ] + ], + [ + [ + 43941, + 43941 + ], + "mapped", + [ + 5077 + ] + ], + [ + [ + 43942, + 43942 + ], + "mapped", + [ + 5078 + ] + ], + [ + [ + 43943, + 43943 + ], + "mapped", + [ + 5079 + ] + ], + [ + [ + 43944, + 43944 + ], + "mapped", + [ + 5080 + ] + ], + [ + [ + 43945, + 43945 + ], + "mapped", + [ + 5081 + ] + ], + [ + [ + 43946, + 43946 + ], + "mapped", + [ + 5082 + ] + ], + [ + [ + 43947, + 43947 + ], + "mapped", + [ + 5083 + ] + ], + [ + [ + 43948, + 43948 + ], + "mapped", + [ + 5084 + ] + ], + [ + [ + 43949, + 43949 + ], + "mapped", + [ + 5085 + ] + ], + [ + [ + 43950, + 43950 + ], + "mapped", + [ + 5086 + ] + ], + [ + [ + 43951, + 43951 + ], + "mapped", + [ + 5087 + ] + ], + [ + [ + 43952, + 43952 + ], + "mapped", + [ + 5088 + ] + ], + [ + [ + 43953, + 43953 + ], + "mapped", + [ + 5089 + ] + ], + [ + [ + 43954, + 43954 + ], + "mapped", + [ + 5090 + ] + ], + [ + [ + 43955, + 43955 + ], + "mapped", + [ + 5091 + ] + ], + [ + [ + 43956, + 43956 + ], + "mapped", + [ + 5092 + ] + ], + [ + [ + 43957, + 43957 + ], + "mapped", + [ + 5093 + ] + ], + [ + [ + 43958, + 43958 + ], + "mapped", + [ + 5094 + ] + ], + [ + [ + 43959, + 43959 + ], + "mapped", + [ + 5095 + ] + ], + [ + [ + 43960, + 43960 + ], + "mapped", + [ + 5096 + ] + ], + [ + [ + 43961, + 43961 + ], + "mapped", + [ + 5097 + ] + ], + [ + [ + 43962, + 43962 + ], + "mapped", + [ + 5098 + ] + ], + [ + [ + 43963, + 43963 + ], + "mapped", + [ + 5099 + ] + ], + [ + [ + 43964, + 43964 + ], + "mapped", + [ + 5100 + ] + ], + [ + [ + 43965, + 43965 + ], + "mapped", + [ + 5101 + ] + ], + [ + [ + 43966, + 43966 + ], + "mapped", + [ + 5102 + ] + ], + [ + [ + 43967, + 43967 + ], + "mapped", + [ + 5103 + ] + ], + [ + [ + 43968, + 44010 + ], + "valid" + ], + [ + [ + 44011, + 44011 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 44012, + 44013 + ], + "valid" + ], + [ + [ + 44014, + 44015 + ], + "disallowed" + ], + [ + [ + 44016, + 44025 + ], + "valid" + ], + [ + [ + 44026, + 44031 + ], + "disallowed" + ], + [ + [ + 44032, + 55203 + ], + "valid" + ], + [ + [ + 55204, + 55215 + ], + "disallowed" + ], + [ + [ + 55216, + 55238 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 55239, + 55242 + ], + "disallowed" + ], + [ + [ + 55243, + 55291 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 55292, + 55295 + ], + "disallowed" + ], + [ + [ + 55296, + 57343 + ], + "disallowed" + ], + [ + [ + 57344, + 63743 + ], + "disallowed" + ], + [ + [ + 63744, + 63744 + ], + "mapped", + [ + 35912 + ] + ], + [ + [ + 63745, + 63745 + ], + "mapped", + [ + 26356 + ] + ], + [ + [ + 63746, + 63746 + ], + "mapped", + [ + 36554 + ] + ], + [ + [ + 63747, + 63747 + ], + "mapped", + [ + 36040 + ] + ], + [ + [ + 63748, + 63748 + ], + "mapped", + [ + 28369 + ] + ], + [ + [ + 63749, + 63749 + ], + "mapped", + [ + 20018 + ] + ], + [ + [ + 63750, + 63750 + ], + "mapped", + [ + 21477 + ] + ], + [ + [ + 63751, + 63752 + ], + "mapped", + [ + 40860 + ] + ], + [ + [ + 63753, + 63753 + ], + "mapped", + [ + 22865 + ] + ], + [ + [ + 63754, + 63754 + ], + "mapped", + [ + 37329 + ] + ], + [ + [ + 63755, + 63755 + ], + "mapped", + [ + 21895 + ] + ], + [ + [ + 63756, + 63756 + ], + "mapped", + [ + 22856 + ] + ], + [ + [ + 63757, + 63757 + ], + "mapped", + [ + 25078 + ] + ], + [ + [ + 63758, + 63758 + ], + "mapped", + [ + 30313 + ] + ], + [ + [ + 63759, + 63759 + ], + "mapped", + [ + 32645 + ] + ], + [ + [ + 63760, + 63760 + ], + "mapped", + [ + 34367 + ] + ], + [ + [ + 63761, + 63761 + ], + "mapped", + [ + 34746 + ] + ], + [ + [ + 63762, + 63762 + ], + "mapped", + [ + 35064 + ] + ], + [ + [ + 63763, + 63763 + ], + "mapped", + [ + 37007 + ] + ], + [ + [ + 63764, + 63764 + ], + "mapped", + [ + 27138 + ] + ], + [ + [ + 63765, + 63765 + ], + "mapped", + [ + 27931 + ] + ], + [ + [ + 63766, + 63766 + ], + "mapped", + [ + 28889 + ] + ], + [ + [ + 63767, + 63767 + ], + "mapped", + [ + 29662 + ] + ], + [ + [ + 63768, + 63768 + ], + "mapped", + [ + 33853 + ] + ], + [ + [ + 63769, + 63769 + ], + "mapped", + [ + 37226 + ] + ], + [ + [ + 63770, + 63770 + ], + "mapped", + [ + 39409 + ] + ], + [ + [ + 63771, + 63771 + ], + "mapped", + [ + 20098 + ] + ], + [ + [ + 63772, + 63772 + ], + "mapped", + [ + 21365 + ] + ], + [ + [ + 63773, + 63773 + ], + "mapped", + [ + 27396 + ] + ], + [ + [ + 63774, + 63774 + ], + "mapped", + [ + 29211 + ] + ], + [ + [ + 63775, + 63775 + ], + "mapped", + [ + 34349 + ] + ], + [ + [ + 63776, + 63776 + ], + "mapped", + [ + 40478 + ] + ], + [ + [ + 63777, + 63777 + ], + "mapped", + [ + 23888 + ] + ], + [ + [ + 63778, + 63778 + ], + "mapped", + [ + 28651 + ] + ], + [ + [ + 63779, + 63779 + ], + "mapped", + [ + 34253 + ] + ], + [ + [ + 63780, + 63780 + ], + "mapped", + [ + 35172 + ] + ], + [ + [ + 63781, + 63781 + ], + "mapped", + [ + 25289 + ] + ], + [ + [ + 63782, + 63782 + ], + "mapped", + [ + 33240 + ] + ], + [ + [ + 63783, + 63783 + ], + "mapped", + [ + 34847 + ] + ], + [ + [ + 63784, + 63784 + ], + "mapped", + [ + 24266 + ] + ], + [ + [ + 63785, + 63785 + ], + "mapped", + [ + 26391 + ] + ], + [ + [ + 63786, + 63786 + ], + "mapped", + [ + 28010 + ] + ], + [ + [ + 63787, + 63787 + ], + "mapped", + [ + 29436 + ] + ], + [ + [ + 63788, + 63788 + ], + "mapped", + [ + 37070 + ] + ], + [ + [ + 63789, + 63789 + ], + "mapped", + [ + 20358 + ] + ], + [ + [ + 63790, + 63790 + ], + "mapped", + [ + 20919 + ] + ], + [ + [ + 63791, + 63791 + ], + "mapped", + [ + 21214 + ] + ], + [ + [ + 63792, + 63792 + ], + "mapped", + [ + 25796 + ] + ], + [ + [ + 63793, + 63793 + ], + "mapped", + [ + 27347 + ] + ], + [ + [ + 63794, + 63794 + ], + "mapped", + [ + 29200 + ] + ], + [ + [ + 63795, + 63795 + ], + "mapped", + [ + 30439 + ] + ], + [ + [ + 63796, + 63796 + ], + "mapped", + [ + 32769 + ] + ], + [ + [ + 63797, + 63797 + ], + "mapped", + [ + 34310 + ] + ], + [ + [ + 63798, + 63798 + ], + "mapped", + [ + 34396 + ] + ], + [ + [ + 63799, + 63799 + ], + "mapped", + [ + 36335 + ] + ], + [ + [ + 63800, + 63800 + ], + "mapped", + [ + 38706 + ] + ], + [ + [ + 63801, + 63801 + ], + "mapped", + [ + 39791 + ] + ], + [ + [ + 63802, + 63802 + ], + "mapped", + [ + 40442 + ] + ], + [ + [ + 63803, + 63803 + ], + "mapped", + [ + 30860 + ] + ], + [ + [ + 63804, + 63804 + ], + "mapped", + [ + 31103 + ] + ], + [ + [ + 63805, + 63805 + ], + "mapped", + [ + 32160 + ] + ], + [ + [ + 63806, + 63806 + ], + "mapped", + [ + 33737 + ] + ], + [ + [ + 63807, + 63807 + ], + "mapped", + [ + 37636 + ] + ], + [ + [ + 63808, + 63808 + ], + "mapped", + [ + 40575 + ] + ], + [ + [ + 63809, + 63809 + ], + "mapped", + [ + 35542 + ] + ], + [ + [ + 63810, + 63810 + ], + "mapped", + [ + 22751 + ] + ], + [ + [ + 63811, + 63811 + ], + "mapped", + [ + 24324 + ] + ], + [ + [ + 63812, + 63812 + ], + "mapped", + [ + 31840 + ] + ], + [ + [ + 63813, + 63813 + ], + "mapped", + [ + 32894 + ] + ], + [ + [ + 63814, + 63814 + ], + "mapped", + [ + 29282 + ] + ], + [ + [ + 63815, + 63815 + ], + "mapped", + [ + 30922 + ] + ], + [ + [ + 63816, + 63816 + ], + "mapped", + [ + 36034 + ] + ], + [ + [ + 63817, + 63817 + ], + "mapped", + [ + 38647 + ] + ], + [ + [ + 63818, + 63818 + ], + "mapped", + [ + 22744 + ] + ], + [ + [ + 63819, + 63819 + ], + "mapped", + [ + 23650 + ] + ], + [ + [ + 63820, + 63820 + ], + "mapped", + [ + 27155 + ] + ], + [ + [ + 63821, + 63821 + ], + "mapped", + [ + 28122 + ] + ], + [ + [ + 63822, + 63822 + ], + "mapped", + [ + 28431 + ] + ], + [ + [ + 63823, + 63823 + ], + "mapped", + [ + 32047 + ] + ], + [ + [ + 63824, + 63824 + ], + "mapped", + [ + 32311 + ] + ], + [ + [ + 63825, + 63825 + ], + "mapped", + [ + 38475 + ] + ], + [ + [ + 63826, + 63826 + ], + "mapped", + [ + 21202 + ] + ], + [ + [ + 63827, + 63827 + ], + "mapped", + [ + 32907 + ] + ], + [ + [ + 63828, + 63828 + ], + "mapped", + [ + 20956 + ] + ], + [ + [ + 63829, + 63829 + ], + "mapped", + [ + 20940 + ] + ], + [ + [ + 63830, + 63830 + ], + "mapped", + [ + 31260 + ] + ], + [ + [ + 63831, + 63831 + ], + "mapped", + [ + 32190 + ] + ], + [ + [ + 63832, + 63832 + ], + "mapped", + [ + 33777 + ] + ], + [ + [ + 63833, + 63833 + ], + "mapped", + [ + 38517 + ] + ], + [ + [ + 63834, + 63834 + ], + "mapped", + [ + 35712 + ] + ], + [ + [ + 63835, + 63835 + ], + "mapped", + [ + 25295 + ] + ], + [ + [ + 63836, + 63836 + ], + "mapped", + [ + 27138 + ] + ], + [ + [ + 63837, + 63837 + ], + "mapped", + [ + 35582 + ] + ], + [ + [ + 63838, + 63838 + ], + "mapped", + [ + 20025 + ] + ], + [ + [ + 63839, + 63839 + ], + "mapped", + [ + 23527 + ] + ], + [ + [ + 63840, + 63840 + ], + "mapped", + [ + 24594 + ] + ], + [ + [ + 63841, + 63841 + ], + "mapped", + [ + 29575 + ] + ], + [ + [ + 63842, + 63842 + ], + "mapped", + [ + 30064 + ] + ], + [ + [ + 63843, + 63843 + ], + "mapped", + [ + 21271 + ] + ], + [ + [ + 63844, + 63844 + ], + "mapped", + [ + 30971 + ] + ], + [ + [ + 63845, + 63845 + ], + "mapped", + [ + 20415 + ] + ], + [ + [ + 63846, + 63846 + ], + "mapped", + [ + 24489 + ] + ], + [ + [ + 63847, + 63847 + ], + "mapped", + [ + 19981 + ] + ], + [ + [ + 63848, + 63848 + ], + "mapped", + [ + 27852 + ] + ], + [ + [ + 63849, + 63849 + ], + "mapped", + [ + 25976 + ] + ], + [ + [ + 63850, + 63850 + ], + "mapped", + [ + 32034 + ] + ], + [ + [ + 63851, + 63851 + ], + "mapped", + [ + 21443 + ] + ], + [ + [ + 63852, + 63852 + ], + "mapped", + [ + 22622 + ] + ], + [ + [ + 63853, + 63853 + ], + "mapped", + [ + 30465 + ] + ], + [ + [ + 63854, + 63854 + ], + "mapped", + [ + 33865 + ] + ], + [ + [ + 63855, + 63855 + ], + "mapped", + [ + 35498 + ] + ], + [ + [ + 63856, + 63856 + ], + "mapped", + [ + 27578 + ] + ], + [ + [ + 63857, + 63857 + ], + "mapped", + [ + 36784 + ] + ], + [ + [ + 63858, + 63858 + ], + "mapped", + [ + 27784 + ] + ], + [ + [ + 63859, + 63859 + ], + "mapped", + [ + 25342 + ] + ], + [ + [ + 63860, + 63860 + ], + "mapped", + [ + 33509 + ] + ], + [ + [ + 63861, + 63861 + ], + "mapped", + [ + 25504 + ] + ], + [ + [ + 63862, + 63862 + ], + "mapped", + [ + 30053 + ] + ], + [ + [ + 63863, + 63863 + ], + "mapped", + [ + 20142 + ] + ], + [ + [ + 63864, + 63864 + ], + "mapped", + [ + 20841 + ] + ], + [ + [ + 63865, + 63865 + ], + "mapped", + [ + 20937 + ] + ], + [ + [ + 63866, + 63866 + ], + "mapped", + [ + 26753 + ] + ], + [ + [ + 63867, + 63867 + ], + "mapped", + [ + 31975 + ] + ], + [ + [ + 63868, + 63868 + ], + "mapped", + [ + 33391 + ] + ], + [ + [ + 63869, + 63869 + ], + "mapped", + [ + 35538 + ] + ], + [ + [ + 63870, + 63870 + ], + "mapped", + [ + 37327 + ] + ], + [ + [ + 63871, + 63871 + ], + "mapped", + [ + 21237 + ] + ], + [ + [ + 63872, + 63872 + ], + "mapped", + [ + 21570 + ] + ], + [ + [ + 63873, + 63873 + ], + "mapped", + [ + 22899 + ] + ], + [ + [ + 63874, + 63874 + ], + "mapped", + [ + 24300 + ] + ], + [ + [ + 63875, + 63875 + ], + "mapped", + [ + 26053 + ] + ], + [ + [ + 63876, + 63876 + ], + "mapped", + [ + 28670 + ] + ], + [ + [ + 63877, + 63877 + ], + "mapped", + [ + 31018 + ] + ], + [ + [ + 63878, + 63878 + ], + "mapped", + [ + 38317 + ] + ], + [ + [ + 63879, + 63879 + ], + "mapped", + [ + 39530 + ] + ], + [ + [ + 63880, + 63880 + ], + "mapped", + [ + 40599 + ] + ], + [ + [ + 63881, + 63881 + ], + "mapped", + [ + 40654 + ] + ], + [ + [ + 63882, + 63882 + ], + "mapped", + [ + 21147 + ] + ], + [ + [ + 63883, + 63883 + ], + "mapped", + [ + 26310 + ] + ], + [ + [ + 63884, + 63884 + ], + "mapped", + [ + 27511 + ] + ], + [ + [ + 63885, + 63885 + ], + "mapped", + [ + 36706 + ] + ], + [ + [ + 63886, + 63886 + ], + "mapped", + [ + 24180 + ] + ], + [ + [ + 63887, + 63887 + ], + "mapped", + [ + 24976 + ] + ], + [ + [ + 63888, + 63888 + ], + "mapped", + [ + 25088 + ] + ], + [ + [ + 63889, + 63889 + ], + "mapped", + [ + 25754 + ] + ], + [ + [ + 63890, + 63890 + ], + "mapped", + [ + 28451 + ] + ], + [ + [ + 63891, + 63891 + ], + "mapped", + [ + 29001 + ] + ], + [ + [ + 63892, + 63892 + ], + "mapped", + [ + 29833 + ] + ], + [ + [ + 63893, + 63893 + ], + "mapped", + [ + 31178 + ] + ], + [ + [ + 63894, + 63894 + ], + "mapped", + [ + 32244 + ] + ], + [ + [ + 63895, + 63895 + ], + "mapped", + [ + 32879 + ] + ], + [ + [ + 63896, + 63896 + ], + "mapped", + [ + 36646 + ] + ], + [ + [ + 63897, + 63897 + ], + "mapped", + [ + 34030 + ] + ], + [ + [ + 63898, + 63898 + ], + "mapped", + [ + 36899 + ] + ], + [ + [ + 63899, + 63899 + ], + "mapped", + [ + 37706 + ] + ], + [ + [ + 63900, + 63900 + ], + "mapped", + [ + 21015 + ] + ], + [ + [ + 63901, + 63901 + ], + "mapped", + [ + 21155 + ] + ], + [ + [ + 63902, + 63902 + ], + "mapped", + [ + 21693 + ] + ], + [ + [ + 63903, + 63903 + ], + "mapped", + [ + 28872 + ] + ], + [ + [ + 63904, + 63904 + ], + "mapped", + [ + 35010 + ] + ], + [ + [ + 63905, + 63905 + ], + "mapped", + [ + 35498 + ] + ], + [ + [ + 63906, + 63906 + ], + "mapped", + [ + 24265 + ] + ], + [ + [ + 63907, + 63907 + ], + "mapped", + [ + 24565 + ] + ], + [ + [ + 63908, + 63908 + ], + "mapped", + [ + 25467 + ] + ], + [ + [ + 63909, + 63909 + ], + "mapped", + [ + 27566 + ] + ], + [ + [ + 63910, + 63910 + ], + "mapped", + [ + 31806 + ] + ], + [ + [ + 63911, + 63911 + ], + "mapped", + [ + 29557 + ] + ], + [ + [ + 63912, + 63912 + ], + "mapped", + [ + 20196 + ] + ], + [ + [ + 63913, + 63913 + ], + "mapped", + [ + 22265 + ] + ], + [ + [ + 63914, + 63914 + ], + "mapped", + [ + 23527 + ] + ], + [ + [ + 63915, + 63915 + ], + "mapped", + [ + 23994 + ] + ], + [ + [ + 63916, + 63916 + ], + "mapped", + [ + 24604 + ] + ], + [ + [ + 63917, + 63917 + ], + "mapped", + [ + 29618 + ] + ], + [ + [ + 63918, + 63918 + ], + "mapped", + [ + 29801 + ] + ], + [ + [ + 63919, + 63919 + ], + "mapped", + [ + 32666 + ] + ], + [ + [ + 63920, + 63920 + ], + "mapped", + [ + 32838 + ] + ], + [ + [ + 63921, + 63921 + ], + "mapped", + [ + 37428 + ] + ], + [ + [ + 63922, + 63922 + ], + "mapped", + [ + 38646 + ] + ], + [ + [ + 63923, + 63923 + ], + "mapped", + [ + 38728 + ] + ], + [ + [ + 63924, + 63924 + ], + "mapped", + [ + 38936 + ] + ], + [ + [ + 63925, + 63925 + ], + "mapped", + [ + 20363 + ] + ], + [ + [ + 63926, + 63926 + ], + "mapped", + [ + 31150 + ] + ], + [ + [ + 63927, + 63927 + ], + "mapped", + [ + 37300 + ] + ], + [ + [ + 63928, + 63928 + ], + "mapped", + [ + 38584 + ] + ], + [ + [ + 63929, + 63929 + ], + "mapped", + [ + 24801 + ] + ], + [ + [ + 63930, + 63930 + ], + "mapped", + [ + 20102 + ] + ], + [ + [ + 63931, + 63931 + ], + "mapped", + [ + 20698 + ] + ], + [ + [ + 63932, + 63932 + ], + "mapped", + [ + 23534 + ] + ], + [ + [ + 63933, + 63933 + ], + "mapped", + [ + 23615 + ] + ], + [ + [ + 63934, + 63934 + ], + "mapped", + [ + 26009 + ] + ], + [ + [ + 63935, + 63935 + ], + "mapped", + [ + 27138 + ] + ], + [ + [ + 63936, + 63936 + ], + "mapped", + [ + 29134 + ] + ], + [ + [ + 63937, + 63937 + ], + "mapped", + [ + 30274 + ] + ], + [ + [ + 63938, + 63938 + ], + "mapped", + [ + 34044 + ] + ], + [ + [ + 63939, + 63939 + ], + "mapped", + [ + 36988 + ] + ], + [ + [ + 63940, + 63940 + ], + "mapped", + [ + 40845 + ] + ], + [ + [ + 63941, + 63941 + ], + "mapped", + [ + 26248 + ] + ], + [ + [ + 63942, + 63942 + ], + "mapped", + [ + 38446 + ] + ], + [ + [ + 63943, + 63943 + ], + "mapped", + [ + 21129 + ] + ], + [ + [ + 63944, + 63944 + ], + "mapped", + [ + 26491 + ] + ], + [ + [ + 63945, + 63945 + ], + "mapped", + [ + 26611 + ] + ], + [ + [ + 63946, + 63946 + ], + "mapped", + [ + 27969 + ] + ], + [ + [ + 63947, + 63947 + ], + "mapped", + [ + 28316 + ] + ], + [ + [ + 63948, + 63948 + ], + "mapped", + [ + 29705 + ] + ], + [ + [ + 63949, + 63949 + ], + "mapped", + [ + 30041 + ] + ], + [ + [ + 63950, + 63950 + ], + "mapped", + [ + 30827 + ] + ], + [ + [ + 63951, + 63951 + ], + "mapped", + [ + 32016 + ] + ], + [ + [ + 63952, + 63952 + ], + "mapped", + [ + 39006 + ] + ], + [ + [ + 63953, + 63953 + ], + "mapped", + [ + 20845 + ] + ], + [ + [ + 63954, + 63954 + ], + "mapped", + [ + 25134 + ] + ], + [ + [ + 63955, + 63955 + ], + "mapped", + [ + 38520 + ] + ], + [ + [ + 63956, + 63956 + ], + "mapped", + [ + 20523 + ] + ], + [ + [ + 63957, + 63957 + ], + "mapped", + [ + 23833 + ] + ], + [ + [ + 63958, + 63958 + ], + "mapped", + [ + 28138 + ] + ], + [ + [ + 63959, + 63959 + ], + "mapped", + [ + 36650 + ] + ], + [ + [ + 63960, + 63960 + ], + "mapped", + [ + 24459 + ] + ], + [ + [ + 63961, + 63961 + ], + "mapped", + [ + 24900 + ] + ], + [ + [ + 63962, + 63962 + ], + "mapped", + [ + 26647 + ] + ], + [ + [ + 63963, + 63963 + ], + "mapped", + [ + 29575 + ] + ], + [ + [ + 63964, + 63964 + ], + "mapped", + [ + 38534 + ] + ], + [ + [ + 63965, + 63965 + ], + "mapped", + [ + 21033 + ] + ], + [ + [ + 63966, + 63966 + ], + "mapped", + [ + 21519 + ] + ], + [ + [ + 63967, + 63967 + ], + "mapped", + [ + 23653 + ] + ], + [ + [ + 63968, + 63968 + ], + "mapped", + [ + 26131 + ] + ], + [ + [ + 63969, + 63969 + ], + "mapped", + [ + 26446 + ] + ], + [ + [ + 63970, + 63970 + ], + "mapped", + [ + 26792 + ] + ], + [ + [ + 63971, + 63971 + ], + "mapped", + [ + 27877 + ] + ], + [ + [ + 63972, + 63972 + ], + "mapped", + [ + 29702 + ] + ], + [ + [ + 63973, + 63973 + ], + "mapped", + [ + 30178 + ] + ], + [ + [ + 63974, + 63974 + ], + "mapped", + [ + 32633 + ] + ], + [ + [ + 63975, + 63975 + ], + "mapped", + [ + 35023 + ] + ], + [ + [ + 63976, + 63976 + ], + "mapped", + [ + 35041 + ] + ], + [ + [ + 63977, + 63977 + ], + "mapped", + [ + 37324 + ] + ], + [ + [ + 63978, + 63978 + ], + "mapped", + [ + 38626 + ] + ], + [ + [ + 63979, + 63979 + ], + "mapped", + [ + 21311 + ] + ], + [ + [ + 63980, + 63980 + ], + "mapped", + [ + 28346 + ] + ], + [ + [ + 63981, + 63981 + ], + "mapped", + [ + 21533 + ] + ], + [ + [ + 63982, + 63982 + ], + "mapped", + [ + 29136 + ] + ], + [ + [ + 63983, + 63983 + ], + "mapped", + [ + 29848 + ] + ], + [ + [ + 63984, + 63984 + ], + "mapped", + [ + 34298 + ] + ], + [ + [ + 63985, + 63985 + ], + "mapped", + [ + 38563 + ] + ], + [ + [ + 63986, + 63986 + ], + "mapped", + [ + 40023 + ] + ], + [ + [ + 63987, + 63987 + ], + "mapped", + [ + 40607 + ] + ], + [ + [ + 63988, + 63988 + ], + "mapped", + [ + 26519 + ] + ], + [ + [ + 63989, + 63989 + ], + "mapped", + [ + 28107 + ] + ], + [ + [ + 63990, + 63990 + ], + "mapped", + [ + 33256 + ] + ], + [ + [ + 63991, + 63991 + ], + "mapped", + [ + 31435 + ] + ], + [ + [ + 63992, + 63992 + ], + "mapped", + [ + 31520 + ] + ], + [ + [ + 63993, + 63993 + ], + "mapped", + [ + 31890 + ] + ], + [ + [ + 63994, + 63994 + ], + "mapped", + [ + 29376 + ] + ], + [ + [ + 63995, + 63995 + ], + "mapped", + [ + 28825 + ] + ], + [ + [ + 63996, + 63996 + ], + "mapped", + [ + 35672 + ] + ], + [ + [ + 63997, + 63997 + ], + "mapped", + [ + 20160 + ] + ], + [ + [ + 63998, + 63998 + ], + "mapped", + [ + 33590 + ] + ], + [ + [ + 63999, + 63999 + ], + "mapped", + [ + 21050 + ] + ], + [ + [ + 64000, + 64000 + ], + "mapped", + [ + 20999 + ] + ], + [ + [ + 64001, + 64001 + ], + "mapped", + [ + 24230 + ] + ], + [ + [ + 64002, + 64002 + ], + "mapped", + [ + 25299 + ] + ], + [ + [ + 64003, + 64003 + ], + "mapped", + [ + 31958 + ] + ], + [ + [ + 64004, + 64004 + ], + "mapped", + [ + 23429 + ] + ], + [ + [ + 64005, + 64005 + ], + "mapped", + [ + 27934 + ] + ], + [ + [ + 64006, + 64006 + ], + "mapped", + [ + 26292 + ] + ], + [ + [ + 64007, + 64007 + ], + "mapped", + [ + 36667 + ] + ], + [ + [ + 64008, + 64008 + ], + "mapped", + [ + 34892 + ] + ], + [ + [ + 64009, + 64009 + ], + "mapped", + [ + 38477 + ] + ], + [ + [ + 64010, + 64010 + ], + "mapped", + [ + 35211 + ] + ], + [ + [ + 64011, + 64011 + ], + "mapped", + [ + 24275 + ] + ], + [ + [ + 64012, + 64012 + ], + "mapped", + [ + 20800 + ] + ], + [ + [ + 64013, + 64013 + ], + "mapped", + [ + 21952 + ] + ], + [ + [ + 64014, + 64015 + ], + "valid" + ], + [ + [ + 64016, + 64016 + ], + "mapped", + [ + 22618 + ] + ], + [ + [ + 64017, + 64017 + ], + "valid" + ], + [ + [ + 64018, + 64018 + ], + "mapped", + [ + 26228 + ] + ], + [ + [ + 64019, + 64020 + ], + "valid" + ], + [ + [ + 64021, + 64021 + ], + "mapped", + [ + 20958 + ] + ], + [ + [ + 64022, + 64022 + ], + "mapped", + [ + 29482 + ] + ], + [ + [ + 64023, + 64023 + ], + "mapped", + [ + 30410 + ] + ], + [ + [ + 64024, + 64024 + ], + "mapped", + [ + 31036 + ] + ], + [ + [ + 64025, + 64025 + ], + "mapped", + [ + 31070 + ] + ], + [ + [ + 64026, + 64026 + ], + "mapped", + [ + 31077 + ] + ], + [ + [ + 64027, + 64027 + ], + "mapped", + [ + 31119 + ] + ], + [ + [ + 64028, + 64028 + ], + "mapped", + [ + 38742 + ] + ], + [ + [ + 64029, + 64029 + ], + "mapped", + [ + 31934 + ] + ], + [ + [ + 64030, + 64030 + ], + "mapped", + [ + 32701 + ] + ], + [ + [ + 64031, + 64031 + ], + "valid" + ], + [ + [ + 64032, + 64032 + ], + "mapped", + [ + 34322 + ] + ], + [ + [ + 64033, + 64033 + ], + "valid" + ], + [ + [ + 64034, + 64034 + ], + "mapped", + [ + 35576 + ] + ], + [ + [ + 64035, + 64036 + ], + "valid" + ], + [ + [ + 64037, + 64037 + ], + "mapped", + [ + 36920 + ] + ], + [ + [ + 64038, + 64038 + ], + "mapped", + [ + 37117 + ] + ], + [ + [ + 64039, + 64041 + ], + "valid" + ], + [ + [ + 64042, + 64042 + ], + "mapped", + [ + 39151 + ] + ], + [ + [ + 64043, + 64043 + ], + "mapped", + [ + 39164 + ] + ], + [ + [ + 64044, + 64044 + ], + "mapped", + [ + 39208 + ] + ], + [ + [ + 64045, + 64045 + ], + "mapped", + [ + 40372 + ] + ], + [ + [ + 64046, + 64046 + ], + "mapped", + [ + 37086 + ] + ], + [ + [ + 64047, + 64047 + ], + "mapped", + [ + 38583 + ] + ], + [ + [ + 64048, + 64048 + ], + "mapped", + [ + 20398 + ] + ], + [ + [ + 64049, + 64049 + ], + "mapped", + [ + 20711 + ] + ], + [ + [ + 64050, + 64050 + ], + "mapped", + [ + 20813 + ] + ], + [ + [ + 64051, + 64051 + ], + "mapped", + [ + 21193 + ] + ], + [ + [ + 64052, + 64052 + ], + "mapped", + [ + 21220 + ] + ], + [ + [ + 64053, + 64053 + ], + "mapped", + [ + 21329 + ] + ], + [ + [ + 64054, + 64054 + ], + "mapped", + [ + 21917 + ] + ], + [ + [ + 64055, + 64055 + ], + "mapped", + [ + 22022 + ] + ], + [ + [ + 64056, + 64056 + ], + "mapped", + [ + 22120 + ] + ], + [ + [ + 64057, + 64057 + ], + "mapped", + [ + 22592 + ] + ], + [ + [ + 64058, + 64058 + ], + "mapped", + [ + 22696 + ] + ], + [ + [ + 64059, + 64059 + ], + "mapped", + [ + 23652 + ] + ], + [ + [ + 64060, + 64060 + ], + "mapped", + [ + 23662 + ] + ], + [ + [ + 64061, + 64061 + ], + "mapped", + [ + 24724 + ] + ], + [ + [ + 64062, + 64062 + ], + "mapped", + [ + 24936 + ] + ], + [ + [ + 64063, + 64063 + ], + "mapped", + [ + 24974 + ] + ], + [ + [ + 64064, + 64064 + ], + "mapped", + [ + 25074 + ] + ], + [ + [ + 64065, + 64065 + ], + "mapped", + [ + 25935 + ] + ], + [ + [ + 64066, + 64066 + ], + "mapped", + [ + 26082 + ] + ], + [ + [ + 64067, + 64067 + ], + "mapped", + [ + 26257 + ] + ], + [ + [ + 64068, + 64068 + ], + "mapped", + [ + 26757 + ] + ], + [ + [ + 64069, + 64069 + ], + "mapped", + [ + 28023 + ] + ], + [ + [ + 64070, + 64070 + ], + "mapped", + [ + 28186 + ] + ], + [ + [ + 64071, + 64071 + ], + "mapped", + [ + 28450 + ] + ], + [ + [ + 64072, + 64072 + ], + "mapped", + [ + 29038 + ] + ], + [ + [ + 64073, + 64073 + ], + "mapped", + [ + 29227 + ] + ], + [ + [ + 64074, + 64074 + ], + "mapped", + [ + 29730 + ] + ], + [ + [ + 64075, + 64075 + ], + "mapped", + [ + 30865 + ] + ], + [ + [ + 64076, + 64076 + ], + "mapped", + [ + 31038 + ] + ], + [ + [ + 64077, + 64077 + ], + "mapped", + [ + 31049 + ] + ], + [ + [ + 64078, + 64078 + ], + "mapped", + [ + 31048 + ] + ], + [ + [ + 64079, + 64079 + ], + "mapped", + [ + 31056 + ] + ], + [ + [ + 64080, + 64080 + ], + "mapped", + [ + 31062 + ] + ], + [ + [ + 64081, + 64081 + ], + "mapped", + [ + 31069 + ] + ], + [ + [ + 64082, + 64082 + ], + "mapped", + [ + 31117 + ] + ], + [ + [ + 64083, + 64083 + ], + "mapped", + [ + 31118 + ] + ], + [ + [ + 64084, + 64084 + ], + "mapped", + [ + 31296 + ] + ], + [ + [ + 64085, + 64085 + ], + "mapped", + [ + 31361 + ] + ], + [ + [ + 64086, + 64086 + ], + "mapped", + [ + 31680 + ] + ], + [ + [ + 64087, + 64087 + ], + "mapped", + [ + 32244 + ] + ], + [ + [ + 64088, + 64088 + ], + "mapped", + [ + 32265 + ] + ], + [ + [ + 64089, + 64089 + ], + "mapped", + [ + 32321 + ] + ], + [ + [ + 64090, + 64090 + ], + "mapped", + [ + 32626 + ] + ], + [ + [ + 64091, + 64091 + ], + "mapped", + [ + 32773 + ] + ], + [ + [ + 64092, + 64092 + ], + "mapped", + [ + 33261 + ] + ], + [ + [ + 64093, + 64094 + ], + "mapped", + [ + 33401 + ] + ], + [ + [ + 64095, + 64095 + ], + "mapped", + [ + 33879 + ] + ], + [ + [ + 64096, + 64096 + ], + "mapped", + [ + 35088 + ] + ], + [ + [ + 64097, + 64097 + ], + "mapped", + [ + 35222 + ] + ], + [ + [ + 64098, + 64098 + ], + "mapped", + [ + 35585 + ] + ], + [ + [ + 64099, + 64099 + ], + "mapped", + [ + 35641 + ] + ], + [ + [ + 64100, + 64100 + ], + "mapped", + [ + 36051 + ] + ], + [ + [ + 64101, + 64101 + ], + "mapped", + [ + 36104 + ] + ], + [ + [ + 64102, + 64102 + ], + "mapped", + [ + 36790 + ] + ], + [ + [ + 64103, + 64103 + ], + "mapped", + [ + 36920 + ] + ], + [ + [ + 64104, + 64104 + ], + "mapped", + [ + 38627 + ] + ], + [ + [ + 64105, + 64105 + ], + "mapped", + [ + 38911 + ] + ], + [ + [ + 64106, + 64106 + ], + "mapped", + [ + 38971 + ] + ], + [ + [ + 64107, + 64107 + ], + "mapped", + [ + 24693 + ] + ], + [ + [ + 64108, + 64108 + ], + "mapped", + [ + 148206 + ] + ], + [ + [ + 64109, + 64109 + ], + "mapped", + [ + 33304 + ] + ], + [ + [ + 64110, + 64111 + ], + "disallowed" + ], + [ + [ + 64112, + 64112 + ], + "mapped", + [ + 20006 + ] + ], + [ + [ + 64113, + 64113 + ], + "mapped", + [ + 20917 + ] + ], + [ + [ + 64114, + 64114 + ], + "mapped", + [ + 20840 + ] + ], + [ + [ + 64115, + 64115 + ], + "mapped", + [ + 20352 + ] + ], + [ + [ + 64116, + 64116 + ], + "mapped", + [ + 20805 + ] + ], + [ + [ + 64117, + 64117 + ], + "mapped", + [ + 20864 + ] + ], + [ + [ + 64118, + 64118 + ], + "mapped", + [ + 21191 + ] + ], + [ + [ + 64119, + 64119 + ], + "mapped", + [ + 21242 + ] + ], + [ + [ + 64120, + 64120 + ], + "mapped", + [ + 21917 + ] + ], + [ + [ + 64121, + 64121 + ], + "mapped", + [ + 21845 + ] + ], + [ + [ + 64122, + 64122 + ], + "mapped", + [ + 21913 + ] + ], + [ + [ + 64123, + 64123 + ], + "mapped", + [ + 21986 + ] + ], + [ + [ + 64124, + 64124 + ], + "mapped", + [ + 22618 + ] + ], + [ + [ + 64125, + 64125 + ], + "mapped", + [ + 22707 + ] + ], + [ + [ + 64126, + 64126 + ], + "mapped", + [ + 22852 + ] + ], + [ + [ + 64127, + 64127 + ], + "mapped", + [ + 22868 + ] + ], + [ + [ + 64128, + 64128 + ], + "mapped", + [ + 23138 + ] + ], + [ + [ + 64129, + 64129 + ], + "mapped", + [ + 23336 + ] + ], + [ + [ + 64130, + 64130 + ], + "mapped", + [ + 24274 + ] + ], + [ + [ + 64131, + 64131 + ], + "mapped", + [ + 24281 + ] + ], + [ + [ + 64132, + 64132 + ], + "mapped", + [ + 24425 + ] + ], + [ + [ + 64133, + 64133 + ], + "mapped", + [ + 24493 + ] + ], + [ + [ + 64134, + 64134 + ], + "mapped", + [ + 24792 + ] + ], + [ + [ + 64135, + 64135 + ], + "mapped", + [ + 24910 + ] + ], + [ + [ + 64136, + 64136 + ], + "mapped", + [ + 24840 + ] + ], + [ + [ + 64137, + 64137 + ], + "mapped", + [ + 24974 + ] + ], + [ + [ + 64138, + 64138 + ], + "mapped", + [ + 24928 + ] + ], + [ + [ + 64139, + 64139 + ], + "mapped", + [ + 25074 + ] + ], + [ + [ + 64140, + 64140 + ], + "mapped", + [ + 25140 + ] + ], + [ + [ + 64141, + 64141 + ], + "mapped", + [ + 25540 + ] + ], + [ + [ + 64142, + 64142 + ], + "mapped", + [ + 25628 + ] + ], + [ + [ + 64143, + 64143 + ], + "mapped", + [ + 25682 + ] + ], + [ + [ + 64144, + 64144 + ], + "mapped", + [ + 25942 + ] + ], + [ + [ + 64145, + 64145 + ], + "mapped", + [ + 26228 + ] + ], + [ + [ + 64146, + 64146 + ], + "mapped", + [ + 26391 + ] + ], + [ + [ + 64147, + 64147 + ], + "mapped", + [ + 26395 + ] + ], + [ + [ + 64148, + 64148 + ], + "mapped", + [ + 26454 + ] + ], + [ + [ + 64149, + 64149 + ], + "mapped", + [ + 27513 + ] + ], + [ + [ + 64150, + 64150 + ], + "mapped", + [ + 27578 + ] + ], + [ + [ + 64151, + 64151 + ], + "mapped", + [ + 27969 + ] + ], + [ + [ + 64152, + 64152 + ], + "mapped", + [ + 28379 + ] + ], + [ + [ + 64153, + 64153 + ], + "mapped", + [ + 28363 + ] + ], + [ + [ + 64154, + 64154 + ], + "mapped", + [ + 28450 + ] + ], + [ + [ + 64155, + 64155 + ], + "mapped", + [ + 28702 + ] + ], + [ + [ + 64156, + 64156 + ], + "mapped", + [ + 29038 + ] + ], + [ + [ + 64157, + 64157 + ], + "mapped", + [ + 30631 + ] + ], + [ + [ + 64158, + 64158 + ], + "mapped", + [ + 29237 + ] + ], + [ + [ + 64159, + 64159 + ], + "mapped", + [ + 29359 + ] + ], + [ + [ + 64160, + 64160 + ], + "mapped", + [ + 29482 + ] + ], + [ + [ + 64161, + 64161 + ], + "mapped", + [ + 29809 + ] + ], + [ + [ + 64162, + 64162 + ], + "mapped", + [ + 29958 + ] + ], + [ + [ + 64163, + 64163 + ], + "mapped", + [ + 30011 + ] + ], + [ + [ + 64164, + 64164 + ], + "mapped", + [ + 30237 + ] + ], + [ + [ + 64165, + 64165 + ], + "mapped", + [ + 30239 + ] + ], + [ + [ + 64166, + 64166 + ], + "mapped", + [ + 30410 + ] + ], + [ + [ + 64167, + 64167 + ], + "mapped", + [ + 30427 + ] + ], + [ + [ + 64168, + 64168 + ], + "mapped", + [ + 30452 + ] + ], + [ + [ + 64169, + 64169 + ], + "mapped", + [ + 30538 + ] + ], + [ + [ + 64170, + 64170 + ], + "mapped", + [ + 30528 + ] + ], + [ + [ + 64171, + 64171 + ], + "mapped", + [ + 30924 + ] + ], + [ + [ + 64172, + 64172 + ], + "mapped", + [ + 31409 + ] + ], + [ + [ + 64173, + 64173 + ], + "mapped", + [ + 31680 + ] + ], + [ + [ + 64174, + 64174 + ], + "mapped", + [ + 31867 + ] + ], + [ + [ + 64175, + 64175 + ], + "mapped", + [ + 32091 + ] + ], + [ + [ + 64176, + 64176 + ], + "mapped", + [ + 32244 + ] + ], + [ + [ + 64177, + 64177 + ], + "mapped", + [ + 32574 + ] + ], + [ + [ + 64178, + 64178 + ], + "mapped", + [ + 32773 + ] + ], + [ + [ + 64179, + 64179 + ], + "mapped", + [ + 33618 + ] + ], + [ + [ + 64180, + 64180 + ], + "mapped", + [ + 33775 + ] + ], + [ + [ + 64181, + 64181 + ], + "mapped", + [ + 34681 + ] + ], + [ + [ + 64182, + 64182 + ], + "mapped", + [ + 35137 + ] + ], + [ + [ + 64183, + 64183 + ], + "mapped", + [ + 35206 + ] + ], + [ + [ + 64184, + 64184 + ], + "mapped", + [ + 35222 + ] + ], + [ + [ + 64185, + 64185 + ], + "mapped", + [ + 35519 + ] + ], + [ + [ + 64186, + 64186 + ], + "mapped", + [ + 35576 + ] + ], + [ + [ + 64187, + 64187 + ], + "mapped", + [ + 35531 + ] + ], + [ + [ + 64188, + 64188 + ], + "mapped", + [ + 35585 + ] + ], + [ + [ + 64189, + 64189 + ], + "mapped", + [ + 35582 + ] + ], + [ + [ + 64190, + 64190 + ], + "mapped", + [ + 35565 + ] + ], + [ + [ + 64191, + 64191 + ], + "mapped", + [ + 35641 + ] + ], + [ + [ + 64192, + 64192 + ], + "mapped", + [ + 35722 + ] + ], + [ + [ + 64193, + 64193 + ], + "mapped", + [ + 36104 + ] + ], + [ + [ + 64194, + 64194 + ], + "mapped", + [ + 36664 + ] + ], + [ + [ + 64195, + 64195 + ], + "mapped", + [ + 36978 + ] + ], + [ + [ + 64196, + 64196 + ], + "mapped", + [ + 37273 + ] + ], + [ + [ + 64197, + 64197 + ], + "mapped", + [ + 37494 + ] + ], + [ + [ + 64198, + 64198 + ], + "mapped", + [ + 38524 + ] + ], + [ + [ + 64199, + 64199 + ], + "mapped", + [ + 38627 + ] + ], + [ + [ + 64200, + 64200 + ], + "mapped", + [ + 38742 + ] + ], + [ + [ + 64201, + 64201 + ], + "mapped", + [ + 38875 + ] + ], + [ + [ + 64202, + 64202 + ], + "mapped", + [ + 38911 + ] + ], + [ + [ + 64203, + 64203 + ], + "mapped", + [ + 38923 + ] + ], + [ + [ + 64204, + 64204 + ], + "mapped", + [ + 38971 + ] + ], + [ + [ + 64205, + 64205 + ], + "mapped", + [ + 39698 + ] + ], + [ + [ + 64206, + 64206 + ], + "mapped", + [ + 40860 + ] + ], + [ + [ + 64207, + 64207 + ], + "mapped", + [ + 141386 + ] + ], + [ + [ + 64208, + 64208 + ], + "mapped", + [ + 141380 + ] + ], + [ + [ + 64209, + 64209 + ], + "mapped", + [ + 144341 + ] + ], + [ + [ + 64210, + 64210 + ], + "mapped", + [ + 15261 + ] + ], + [ + [ + 64211, + 64211 + ], + "mapped", + [ + 16408 + ] + ], + [ + [ + 64212, + 64212 + ], + "mapped", + [ + 16441 + ] + ], + [ + [ + 64213, + 64213 + ], + "mapped", + [ + 152137 + ] + ], + [ + [ + 64214, + 64214 + ], + "mapped", + [ + 154832 + ] + ], + [ + [ + 64215, + 64215 + ], + "mapped", + [ + 163539 + ] + ], + [ + [ + 64216, + 64216 + ], + "mapped", + [ + 40771 + ] + ], + [ + [ + 64217, + 64217 + ], + "mapped", + [ + 40846 + ] + ], + [ + [ + 64218, + 64255 + ], + "disallowed" + ], + [ + [ + 64256, + 64256 + ], + "mapped", + [ + 102, + 102 + ] + ], + [ + [ + 64257, + 64257 + ], + "mapped", + [ + 102, + 105 + ] + ], + [ + [ + 64258, + 64258 + ], + "mapped", + [ + 102, + 108 + ] + ], + [ + [ + 64259, + 64259 + ], + "mapped", + [ + 102, + 102, + 105 + ] + ], + [ + [ + 64260, + 64260 + ], + "mapped", + [ + 102, + 102, + 108 + ] + ], + [ + [ + 64261, + 64262 + ], + "mapped", + [ + 115, + 116 + ] + ], + [ + [ + 64263, + 64274 + ], + "disallowed" + ], + [ + [ + 64275, + 64275 + ], + "mapped", + [ + 1396, + 1398 + ] + ], + [ + [ + 64276, + 64276 + ], + "mapped", + [ + 1396, + 1381 + ] + ], + [ + [ + 64277, + 64277 + ], + "mapped", + [ + 1396, + 1387 + ] + ], + [ + [ + 64278, + 64278 + ], + "mapped", + [ + 1406, + 1398 + ] + ], + [ + [ + 64279, + 64279 + ], + "mapped", + [ + 1396, + 1389 + ] + ], + [ + [ + 64280, + 64284 + ], + "disallowed" + ], + [ + [ + 64285, + 64285 + ], + "mapped", + [ + 1497, + 1460 + ] + ], + [ + [ + 64286, + 64286 + ], + "valid" + ], + [ + [ + 64287, + 64287 + ], + "mapped", + [ + 1522, + 1463 + ] + ], + [ + [ + 64288, + 64288 + ], + "mapped", + [ + 1506 + ] + ], + [ + [ + 64289, + 64289 + ], + "mapped", + [ + 1488 + ] + ], + [ + [ + 64290, + 64290 + ], + "mapped", + [ + 1491 + ] + ], + [ + [ + 64291, + 64291 + ], + "mapped", + [ + 1492 + ] + ], + [ + [ + 64292, + 64292 + ], + "mapped", + [ + 1499 + ] + ], + [ + [ + 64293, + 64293 + ], + "mapped", + [ + 1500 + ] + ], + [ + [ + 64294, + 64294 + ], + "mapped", + [ + 1501 + ] + ], + [ + [ + 64295, + 64295 + ], + "mapped", + [ + 1512 + ] + ], + [ + [ + 64296, + 64296 + ], + "mapped", + [ + 1514 + ] + ], + [ + [ + 64297, + 64297 + ], + "disallowed_STD3_mapped", + [ + 43 + ] + ], + [ + [ + 64298, + 64298 + ], + "mapped", + [ + 1513, + 1473 + ] + ], + [ + [ + 64299, + 64299 + ], + "mapped", + [ + 1513, + 1474 + ] + ], + [ + [ + 64300, + 64300 + ], + "mapped", + [ + 1513, + 1468, + 1473 + ] + ], + [ + [ + 64301, + 64301 + ], + "mapped", + [ + 1513, + 1468, + 1474 + ] + ], + [ + [ + 64302, + 64302 + ], + "mapped", + [ + 1488, + 1463 + ] + ], + [ + [ + 64303, + 64303 + ], + "mapped", + [ + 1488, + 1464 + ] + ], + [ + [ + 64304, + 64304 + ], + "mapped", + [ + 1488, + 1468 + ] + ], + [ + [ + 64305, + 64305 + ], + "mapped", + [ + 1489, + 1468 + ] + ], + [ + [ + 64306, + 64306 + ], + "mapped", + [ + 1490, + 1468 + ] + ], + [ + [ + 64307, + 64307 + ], + "mapped", + [ + 1491, + 1468 + ] + ], + [ + [ + 64308, + 64308 + ], + "mapped", + [ + 1492, + 1468 + ] + ], + [ + [ + 64309, + 64309 + ], + "mapped", + [ + 1493, + 1468 + ] + ], + [ + [ + 64310, + 64310 + ], + "mapped", + [ + 1494, + 1468 + ] + ], + [ + [ + 64311, + 64311 + ], + "disallowed" + ], + [ + [ + 64312, + 64312 + ], + "mapped", + [ + 1496, + 1468 + ] + ], + [ + [ + 64313, + 64313 + ], + "mapped", + [ + 1497, + 1468 + ] + ], + [ + [ + 64314, + 64314 + ], + "mapped", + [ + 1498, + 1468 + ] + ], + [ + [ + 64315, + 64315 + ], + "mapped", + [ + 1499, + 1468 + ] + ], + [ + [ + 64316, + 64316 + ], + "mapped", + [ + 1500, + 1468 + ] + ], + [ + [ + 64317, + 64317 + ], + "disallowed" + ], + [ + [ + 64318, + 64318 + ], + "mapped", + [ + 1502, + 1468 + ] + ], + [ + [ + 64319, + 64319 + ], + "disallowed" + ], + [ + [ + 64320, + 64320 + ], + "mapped", + [ + 1504, + 1468 + ] + ], + [ + [ + 64321, + 64321 + ], + "mapped", + [ + 1505, + 1468 + ] + ], + [ + [ + 64322, + 64322 + ], + "disallowed" + ], + [ + [ + 64323, + 64323 + ], + "mapped", + [ + 1507, + 1468 + ] + ], + [ + [ + 64324, + 64324 + ], + "mapped", + [ + 1508, + 1468 + ] + ], + [ + [ + 64325, + 64325 + ], + "disallowed" + ], + [ + [ + 64326, + 64326 + ], + "mapped", + [ + 1510, + 1468 + ] + ], + [ + [ + 64327, + 64327 + ], + "mapped", + [ + 1511, + 1468 + ] + ], + [ + [ + 64328, + 64328 + ], + "mapped", + [ + 1512, + 1468 + ] + ], + [ + [ + 64329, + 64329 + ], + "mapped", + [ + 1513, + 1468 + ] + ], + [ + [ + 64330, + 64330 + ], + "mapped", + [ + 1514, + 1468 + ] + ], + [ + [ + 64331, + 64331 + ], + "mapped", + [ + 1493, + 1465 + ] + ], + [ + [ + 64332, + 64332 + ], + "mapped", + [ + 1489, + 1471 + ] + ], + [ + [ + 64333, + 64333 + ], + "mapped", + [ + 1499, + 1471 + ] + ], + [ + [ + 64334, + 64334 + ], + "mapped", + [ + 1508, + 1471 + ] + ], + [ + [ + 64335, + 64335 + ], + "mapped", + [ + 1488, + 1500 + ] + ], + [ + [ + 64336, + 64337 + ], + "mapped", + [ + 1649 + ] + ], + [ + [ + 64338, + 64341 + ], + "mapped", + [ + 1659 + ] + ], + [ + [ + 64342, + 64345 + ], + "mapped", + [ + 1662 + ] + ], + [ + [ + 64346, + 64349 + ], + "mapped", + [ + 1664 + ] + ], + [ + [ + 64350, + 64353 + ], + "mapped", + [ + 1658 + ] + ], + [ + [ + 64354, + 64357 + ], + "mapped", + [ + 1663 + ] + ], + [ + [ + 64358, + 64361 + ], + "mapped", + [ + 1657 + ] + ], + [ + [ + 64362, + 64365 + ], + "mapped", + [ + 1700 + ] + ], + [ + [ + 64366, + 64369 + ], + "mapped", + [ + 1702 + ] + ], + [ + [ + 64370, + 64373 + ], + "mapped", + [ + 1668 + ] + ], + [ + [ + 64374, + 64377 + ], + "mapped", + [ + 1667 + ] + ], + [ + [ + 64378, + 64381 + ], + "mapped", + [ + 1670 + ] + ], + [ + [ + 64382, + 64385 + ], + "mapped", + [ + 1671 + ] + ], + [ + [ + 64386, + 64387 + ], + "mapped", + [ + 1677 + ] + ], + [ + [ + 64388, + 64389 + ], + "mapped", + [ + 1676 + ] + ], + [ + [ + 64390, + 64391 + ], + "mapped", + [ + 1678 + ] + ], + [ + [ + 64392, + 64393 + ], + "mapped", + [ + 1672 + ] + ], + [ + [ + 64394, + 64395 + ], + "mapped", + [ + 1688 + ] + ], + [ + [ + 64396, + 64397 + ], + "mapped", + [ + 1681 + ] + ], + [ + [ + 64398, + 64401 + ], + "mapped", + [ + 1705 + ] + ], + [ + [ + 64402, + 64405 + ], + "mapped", + [ + 1711 + ] + ], + [ + [ + 64406, + 64409 + ], + "mapped", + [ + 1715 + ] + ], + [ + [ + 64410, + 64413 + ], + "mapped", + [ + 1713 + ] + ], + [ + [ + 64414, + 64415 + ], + "mapped", + [ + 1722 + ] + ], + [ + [ + 64416, + 64419 + ], + "mapped", + [ + 1723 + ] + ], + [ + [ + 64420, + 64421 + ], + "mapped", + [ + 1728 + ] + ], + [ + [ + 64422, + 64425 + ], + "mapped", + [ + 1729 + ] + ], + [ + [ + 64426, + 64429 + ], + "mapped", + [ + 1726 + ] + ], + [ + [ + 64430, + 64431 + ], + "mapped", + [ + 1746 + ] + ], + [ + [ + 64432, + 64433 + ], + "mapped", + [ + 1747 + ] + ], + [ + [ + 64434, + 64449 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 64450, + 64466 + ], + "disallowed" + ], + [ + [ + 64467, + 64470 + ], + "mapped", + [ + 1709 + ] + ], + [ + [ + 64471, + 64472 + ], + "mapped", + [ + 1735 + ] + ], + [ + [ + 64473, + 64474 + ], + "mapped", + [ + 1734 + ] + ], + [ + [ + 64475, + 64476 + ], + "mapped", + [ + 1736 + ] + ], + [ + [ + 64477, + 64477 + ], + "mapped", + [ + 1735, + 1652 + ] + ], + [ + [ + 64478, + 64479 + ], + "mapped", + [ + 1739 + ] + ], + [ + [ + 64480, + 64481 + ], + "mapped", + [ + 1733 + ] + ], + [ + [ + 64482, + 64483 + ], + "mapped", + [ + 1737 + ] + ], + [ + [ + 64484, + 64487 + ], + "mapped", + [ + 1744 + ] + ], + [ + [ + 64488, + 64489 + ], + "mapped", + [ + 1609 + ] + ], + [ + [ + 64490, + 64491 + ], + "mapped", + [ + 1574, + 1575 + ] + ], + [ + [ + 64492, + 64493 + ], + "mapped", + [ + 1574, + 1749 + ] + ], + [ + [ + 64494, + 64495 + ], + "mapped", + [ + 1574, + 1608 + ] + ], + [ + [ + 64496, + 64497 + ], + "mapped", + [ + 1574, + 1735 + ] + ], + [ + [ + 64498, + 64499 + ], + "mapped", + [ + 1574, + 1734 + ] + ], + [ + [ + 64500, + 64501 + ], + "mapped", + [ + 1574, + 1736 + ] + ], + [ + [ + 64502, + 64504 + ], + "mapped", + [ + 1574, + 1744 + ] + ], + [ + [ + 64505, + 64507 + ], + "mapped", + [ + 1574, + 1609 + ] + ], + [ + [ + 64508, + 64511 + ], + "mapped", + [ + 1740 + ] + ], + [ + [ + 64512, + 64512 + ], + "mapped", + [ + 1574, + 1580 + ] + ], + [ + [ + 64513, + 64513 + ], + "mapped", + [ + 1574, + 1581 + ] + ], + [ + [ + 64514, + 64514 + ], + "mapped", + [ + 1574, + 1605 + ] + ], + [ + [ + 64515, + 64515 + ], + "mapped", + [ + 1574, + 1609 + ] + ], + [ + [ + 64516, + 64516 + ], + "mapped", + [ + 1574, + 1610 + ] + ], + [ + [ + 64517, + 64517 + ], + "mapped", + [ + 1576, + 1580 + ] + ], + [ + [ + 64518, + 64518 + ], + "mapped", + [ + 1576, + 1581 + ] + ], + [ + [ + 64519, + 64519 + ], + "mapped", + [ + 1576, + 1582 + ] + ], + [ + [ + 64520, + 64520 + ], + "mapped", + [ + 1576, + 1605 + ] + ], + [ + [ + 64521, + 64521 + ], + "mapped", + [ + 1576, + 1609 + ] + ], + [ + [ + 64522, + 64522 + ], + "mapped", + [ + 1576, + 1610 + ] + ], + [ + [ + 64523, + 64523 + ], + "mapped", + [ + 1578, + 1580 + ] + ], + [ + [ + 64524, + 64524 + ], + "mapped", + [ + 1578, + 1581 + ] + ], + [ + [ + 64525, + 64525 + ], + "mapped", + [ + 1578, + 1582 + ] + ], + [ + [ + 64526, + 64526 + ], + "mapped", + [ + 1578, + 1605 + ] + ], + [ + [ + 64527, + 64527 + ], + "mapped", + [ + 1578, + 1609 + ] + ], + [ + [ + 64528, + 64528 + ], + "mapped", + [ + 1578, + 1610 + ] + ], + [ + [ + 64529, + 64529 + ], + "mapped", + [ + 1579, + 1580 + ] + ], + [ + [ + 64530, + 64530 + ], + "mapped", + [ + 1579, + 1605 + ] + ], + [ + [ + 64531, + 64531 + ], + "mapped", + [ + 1579, + 1609 + ] + ], + [ + [ + 64532, + 64532 + ], + "mapped", + [ + 1579, + 1610 + ] + ], + [ + [ + 64533, + 64533 + ], + "mapped", + [ + 1580, + 1581 + ] + ], + [ + [ + 64534, + 64534 + ], + "mapped", + [ + 1580, + 1605 + ] + ], + [ + [ + 64535, + 64535 + ], + "mapped", + [ + 1581, + 1580 + ] + ], + [ + [ + 64536, + 64536 + ], + "mapped", + [ + 1581, + 1605 + ] + ], + [ + [ + 64537, + 64537 + ], + "mapped", + [ + 1582, + 1580 + ] + ], + [ + [ + 64538, + 64538 + ], + "mapped", + [ + 1582, + 1581 + ] + ], + [ + [ + 64539, + 64539 + ], + "mapped", + [ + 1582, + 1605 + ] + ], + [ + [ + 64540, + 64540 + ], + "mapped", + [ + 1587, + 1580 + ] + ], + [ + [ + 64541, + 64541 + ], + "mapped", + [ + 1587, + 1581 + ] + ], + [ + [ + 64542, + 64542 + ], + "mapped", + [ + 1587, + 1582 + ] + ], + [ + [ + 64543, + 64543 + ], + "mapped", + [ + 1587, + 1605 + ] + ], + [ + [ + 64544, + 64544 + ], + "mapped", + [ + 1589, + 1581 + ] + ], + [ + [ + 64545, + 64545 + ], + "mapped", + [ + 1589, + 1605 + ] + ], + [ + [ + 64546, + 64546 + ], + "mapped", + [ + 1590, + 1580 + ] + ], + [ + [ + 64547, + 64547 + ], + "mapped", + [ + 1590, + 1581 + ] + ], + [ + [ + 64548, + 64548 + ], + "mapped", + [ + 1590, + 1582 + ] + ], + [ + [ + 64549, + 64549 + ], + "mapped", + [ + 1590, + 1605 + ] + ], + [ + [ + 64550, + 64550 + ], + "mapped", + [ + 1591, + 1581 + ] + ], + [ + [ + 64551, + 64551 + ], + "mapped", + [ + 1591, + 1605 + ] + ], + [ + [ + 64552, + 64552 + ], + "mapped", + [ + 1592, + 1605 + ] + ], + [ + [ + 64553, + 64553 + ], + "mapped", + [ + 1593, + 1580 + ] + ], + [ + [ + 64554, + 64554 + ], + "mapped", + [ + 1593, + 1605 + ] + ], + [ + [ + 64555, + 64555 + ], + "mapped", + [ + 1594, + 1580 + ] + ], + [ + [ + 64556, + 64556 + ], + "mapped", + [ + 1594, + 1605 + ] + ], + [ + [ + 64557, + 64557 + ], + "mapped", + [ + 1601, + 1580 + ] + ], + [ + [ + 64558, + 64558 + ], + "mapped", + [ + 1601, + 1581 + ] + ], + [ + [ + 64559, + 64559 + ], + "mapped", + [ + 1601, + 1582 + ] + ], + [ + [ + 64560, + 64560 + ], + "mapped", + [ + 1601, + 1605 + ] + ], + [ + [ + 64561, + 64561 + ], + "mapped", + [ + 1601, + 1609 + ] + ], + [ + [ + 64562, + 64562 + ], + "mapped", + [ + 1601, + 1610 + ] + ], + [ + [ + 64563, + 64563 + ], + "mapped", + [ + 1602, + 1581 + ] + ], + [ + [ + 64564, + 64564 + ], + "mapped", + [ + 1602, + 1605 + ] + ], + [ + [ + 64565, + 64565 + ], + "mapped", + [ + 1602, + 1609 + ] + ], + [ + [ + 64566, + 64566 + ], + "mapped", + [ + 1602, + 1610 + ] + ], + [ + [ + 64567, + 64567 + ], + "mapped", + [ + 1603, + 1575 + ] + ], + [ + [ + 64568, + 64568 + ], + "mapped", + [ + 1603, + 1580 + ] + ], + [ + [ + 64569, + 64569 + ], + "mapped", + [ + 1603, + 1581 + ] + ], + [ + [ + 64570, + 64570 + ], + "mapped", + [ + 1603, + 1582 + ] + ], + [ + [ + 64571, + 64571 + ], + "mapped", + [ + 1603, + 1604 + ] + ], + [ + [ + 64572, + 64572 + ], + "mapped", + [ + 1603, + 1605 + ] + ], + [ + [ + 64573, + 64573 + ], + "mapped", + [ + 1603, + 1609 + ] + ], + [ + [ + 64574, + 64574 + ], + "mapped", + [ + 1603, + 1610 + ] + ], + [ + [ + 64575, + 64575 + ], + "mapped", + [ + 1604, + 1580 + ] + ], + [ + [ + 64576, + 64576 + ], + "mapped", + [ + 1604, + 1581 + ] + ], + [ + [ + 64577, + 64577 + ], + "mapped", + [ + 1604, + 1582 + ] + ], + [ + [ + 64578, + 64578 + ], + "mapped", + [ + 1604, + 1605 + ] + ], + [ + [ + 64579, + 64579 + ], + "mapped", + [ + 1604, + 1609 + ] + ], + [ + [ + 64580, + 64580 + ], + "mapped", + [ + 1604, + 1610 + ] + ], + [ + [ + 64581, + 64581 + ], + "mapped", + [ + 1605, + 1580 + ] + ], + [ + [ + 64582, + 64582 + ], + "mapped", + [ + 1605, + 1581 + ] + ], + [ + [ + 64583, + 64583 + ], + "mapped", + [ + 1605, + 1582 + ] + ], + [ + [ + 64584, + 64584 + ], + "mapped", + [ + 1605, + 1605 + ] + ], + [ + [ + 64585, + 64585 + ], + "mapped", + [ + 1605, + 1609 + ] + ], + [ + [ + 64586, + 64586 + ], + "mapped", + [ + 1605, + 1610 + ] + ], + [ + [ + 64587, + 64587 + ], + "mapped", + [ + 1606, + 1580 + ] + ], + [ + [ + 64588, + 64588 + ], + "mapped", + [ + 1606, + 1581 + ] + ], + [ + [ + 64589, + 64589 + ], + "mapped", + [ + 1606, + 1582 + ] + ], + [ + [ + 64590, + 64590 + ], + "mapped", + [ + 1606, + 1605 + ] + ], + [ + [ + 64591, + 64591 + ], + "mapped", + [ + 1606, + 1609 + ] + ], + [ + [ + 64592, + 64592 + ], + "mapped", + [ + 1606, + 1610 + ] + ], + [ + [ + 64593, + 64593 + ], + "mapped", + [ + 1607, + 1580 + ] + ], + [ + [ + 64594, + 64594 + ], + "mapped", + [ + 1607, + 1605 + ] + ], + [ + [ + 64595, + 64595 + ], + "mapped", + [ + 1607, + 1609 + ] + ], + [ + [ + 64596, + 64596 + ], + "mapped", + [ + 1607, + 1610 + ] + ], + [ + [ + 64597, + 64597 + ], + "mapped", + [ + 1610, + 1580 + ] + ], + [ + [ + 64598, + 64598 + ], + "mapped", + [ + 1610, + 1581 + ] + ], + [ + [ + 64599, + 64599 + ], + "mapped", + [ + 1610, + 1582 + ] + ], + [ + [ + 64600, + 64600 + ], + "mapped", + [ + 1610, + 1605 + ] + ], + [ + [ + 64601, + 64601 + ], + "mapped", + [ + 1610, + 1609 + ] + ], + [ + [ + 64602, + 64602 + ], + "mapped", + [ + 1610, + 1610 + ] + ], + [ + [ + 64603, + 64603 + ], + "mapped", + [ + 1584, + 1648 + ] + ], + [ + [ + 64604, + 64604 + ], + "mapped", + [ + 1585, + 1648 + ] + ], + [ + [ + 64605, + 64605 + ], + "mapped", + [ + 1609, + 1648 + ] + ], + [ + [ + 64606, + 64606 + ], + "disallowed_STD3_mapped", + [ + 32, + 1612, + 1617 + ] + ], + [ + [ + 64607, + 64607 + ], + "disallowed_STD3_mapped", + [ + 32, + 1613, + 1617 + ] + ], + [ + [ + 64608, + 64608 + ], + "disallowed_STD3_mapped", + [ + 32, + 1614, + 1617 + ] + ], + [ + [ + 64609, + 64609 + ], + "disallowed_STD3_mapped", + [ + 32, + 1615, + 1617 + ] + ], + [ + [ + 64610, + 64610 + ], + "disallowed_STD3_mapped", + [ + 32, + 1616, + 1617 + ] + ], + [ + [ + 64611, + 64611 + ], + "disallowed_STD3_mapped", + [ + 32, + 1617, + 1648 + ] + ], + [ + [ + 64612, + 64612 + ], + "mapped", + [ + 1574, + 1585 + ] + ], + [ + [ + 64613, + 64613 + ], + "mapped", + [ + 1574, + 1586 + ] + ], + [ + [ + 64614, + 64614 + ], + "mapped", + [ + 1574, + 1605 + ] + ], + [ + [ + 64615, + 64615 + ], + "mapped", + [ + 1574, + 1606 + ] + ], + [ + [ + 64616, + 64616 + ], + "mapped", + [ + 1574, + 1609 + ] + ], + [ + [ + 64617, + 64617 + ], + "mapped", + [ + 1574, + 1610 + ] + ], + [ + [ + 64618, + 64618 + ], + "mapped", + [ + 1576, + 1585 + ] + ], + [ + [ + 64619, + 64619 + ], + "mapped", + [ + 1576, + 1586 + ] + ], + [ + [ + 64620, + 64620 + ], + "mapped", + [ + 1576, + 1605 + ] + ], + [ + [ + 64621, + 64621 + ], + "mapped", + [ + 1576, + 1606 + ] + ], + [ + [ + 64622, + 64622 + ], + "mapped", + [ + 1576, + 1609 + ] + ], + [ + [ + 64623, + 64623 + ], + "mapped", + [ + 1576, + 1610 + ] + ], + [ + [ + 64624, + 64624 + ], + "mapped", + [ + 1578, + 1585 + ] + ], + [ + [ + 64625, + 64625 + ], + "mapped", + [ + 1578, + 1586 + ] + ], + [ + [ + 64626, + 64626 + ], + "mapped", + [ + 1578, + 1605 + ] + ], + [ + [ + 64627, + 64627 + ], + "mapped", + [ + 1578, + 1606 + ] + ], + [ + [ + 64628, + 64628 + ], + "mapped", + [ + 1578, + 1609 + ] + ], + [ + [ + 64629, + 64629 + ], + "mapped", + [ + 1578, + 1610 + ] + ], + [ + [ + 64630, + 64630 + ], + "mapped", + [ + 1579, + 1585 + ] + ], + [ + [ + 64631, + 64631 + ], + "mapped", + [ + 1579, + 1586 + ] + ], + [ + [ + 64632, + 64632 + ], + "mapped", + [ + 1579, + 1605 + ] + ], + [ + [ + 64633, + 64633 + ], + "mapped", + [ + 1579, + 1606 + ] + ], + [ + [ + 64634, + 64634 + ], + "mapped", + [ + 1579, + 1609 + ] + ], + [ + [ + 64635, + 64635 + ], + "mapped", + [ + 1579, + 1610 + ] + ], + [ + [ + 64636, + 64636 + ], + "mapped", + [ + 1601, + 1609 + ] + ], + [ + [ + 64637, + 64637 + ], + "mapped", + [ + 1601, + 1610 + ] + ], + [ + [ + 64638, + 64638 + ], + "mapped", + [ + 1602, + 1609 + ] + ], + [ + [ + 64639, + 64639 + ], + "mapped", + [ + 1602, + 1610 + ] + ], + [ + [ + 64640, + 64640 + ], + "mapped", + [ + 1603, + 1575 + ] + ], + [ + [ + 64641, + 64641 + ], + "mapped", + [ + 1603, + 1604 + ] + ], + [ + [ + 64642, + 64642 + ], + "mapped", + [ + 1603, + 1605 + ] + ], + [ + [ + 64643, + 64643 + ], + "mapped", + [ + 1603, + 1609 + ] + ], + [ + [ + 64644, + 64644 + ], + "mapped", + [ + 1603, + 1610 + ] + ], + [ + [ + 64645, + 64645 + ], + "mapped", + [ + 1604, + 1605 + ] + ], + [ + [ + 64646, + 64646 + ], + "mapped", + [ + 1604, + 1609 + ] + ], + [ + [ + 64647, + 64647 + ], + "mapped", + [ + 1604, + 1610 + ] + ], + [ + [ + 64648, + 64648 + ], + "mapped", + [ + 1605, + 1575 + ] + ], + [ + [ + 64649, + 64649 + ], + "mapped", + [ + 1605, + 1605 + ] + ], + [ + [ + 64650, + 64650 + ], + "mapped", + [ + 1606, + 1585 + ] + ], + [ + [ + 64651, + 64651 + ], + "mapped", + [ + 1606, + 1586 + ] + ], + [ + [ + 64652, + 64652 + ], + "mapped", + [ + 1606, + 1605 + ] + ], + [ + [ + 64653, + 64653 + ], + "mapped", + [ + 1606, + 1606 + ] + ], + [ + [ + 64654, + 64654 + ], + "mapped", + [ + 1606, + 1609 + ] + ], + [ + [ + 64655, + 64655 + ], + "mapped", + [ + 1606, + 1610 + ] + ], + [ + [ + 64656, + 64656 + ], + "mapped", + [ + 1609, + 1648 + ] + ], + [ + [ + 64657, + 64657 + ], + "mapped", + [ + 1610, + 1585 + ] + ], + [ + [ + 64658, + 64658 + ], + "mapped", + [ + 1610, + 1586 + ] + ], + [ + [ + 64659, + 64659 + ], + "mapped", + [ + 1610, + 1605 + ] + ], + [ + [ + 64660, + 64660 + ], + "mapped", + [ + 1610, + 1606 + ] + ], + [ + [ + 64661, + 64661 + ], + "mapped", + [ + 1610, + 1609 + ] + ], + [ + [ + 64662, + 64662 + ], + "mapped", + [ + 1610, + 1610 + ] + ], + [ + [ + 64663, + 64663 + ], + "mapped", + [ + 1574, + 1580 + ] + ], + [ + [ + 64664, + 64664 + ], + "mapped", + [ + 1574, + 1581 + ] + ], + [ + [ + 64665, + 64665 + ], + "mapped", + [ + 1574, + 1582 + ] + ], + [ + [ + 64666, + 64666 + ], + "mapped", + [ + 1574, + 1605 + ] + ], + [ + [ + 64667, + 64667 + ], + "mapped", + [ + 1574, + 1607 + ] + ], + [ + [ + 64668, + 64668 + ], + "mapped", + [ + 1576, + 1580 + ] + ], + [ + [ + 64669, + 64669 + ], + "mapped", + [ + 1576, + 1581 + ] + ], + [ + [ + 64670, + 64670 + ], + "mapped", + [ + 1576, + 1582 + ] + ], + [ + [ + 64671, + 64671 + ], + "mapped", + [ + 1576, + 1605 + ] + ], + [ + [ + 64672, + 64672 + ], + "mapped", + [ + 1576, + 1607 + ] + ], + [ + [ + 64673, + 64673 + ], + "mapped", + [ + 1578, + 1580 + ] + ], + [ + [ + 64674, + 64674 + ], + "mapped", + [ + 1578, + 1581 + ] + ], + [ + [ + 64675, + 64675 + ], + "mapped", + [ + 1578, + 1582 + ] + ], + [ + [ + 64676, + 64676 + ], + "mapped", + [ + 1578, + 1605 + ] + ], + [ + [ + 64677, + 64677 + ], + "mapped", + [ + 1578, + 1607 + ] + ], + [ + [ + 64678, + 64678 + ], + "mapped", + [ + 1579, + 1605 + ] + ], + [ + [ + 64679, + 64679 + ], + "mapped", + [ + 1580, + 1581 + ] + ], + [ + [ + 64680, + 64680 + ], + "mapped", + [ + 1580, + 1605 + ] + ], + [ + [ + 64681, + 64681 + ], + "mapped", + [ + 1581, + 1580 + ] + ], + [ + [ + 64682, + 64682 + ], + "mapped", + [ + 1581, + 1605 + ] + ], + [ + [ + 64683, + 64683 + ], + "mapped", + [ + 1582, + 1580 + ] + ], + [ + [ + 64684, + 64684 + ], + "mapped", + [ + 1582, + 1605 + ] + ], + [ + [ + 64685, + 64685 + ], + "mapped", + [ + 1587, + 1580 + ] + ], + [ + [ + 64686, + 64686 + ], + "mapped", + [ + 1587, + 1581 + ] + ], + [ + [ + 64687, + 64687 + ], + "mapped", + [ + 1587, + 1582 + ] + ], + [ + [ + 64688, + 64688 + ], + "mapped", + [ + 1587, + 1605 + ] + ], + [ + [ + 64689, + 64689 + ], + "mapped", + [ + 1589, + 1581 + ] + ], + [ + [ + 64690, + 64690 + ], + "mapped", + [ + 1589, + 1582 + ] + ], + [ + [ + 64691, + 64691 + ], + "mapped", + [ + 1589, + 1605 + ] + ], + [ + [ + 64692, + 64692 + ], + "mapped", + [ + 1590, + 1580 + ] + ], + [ + [ + 64693, + 64693 + ], + "mapped", + [ + 1590, + 1581 + ] + ], + [ + [ + 64694, + 64694 + ], + "mapped", + [ + 1590, + 1582 + ] + ], + [ + [ + 64695, + 64695 + ], + "mapped", + [ + 1590, + 1605 + ] + ], + [ + [ + 64696, + 64696 + ], + "mapped", + [ + 1591, + 1581 + ] + ], + [ + [ + 64697, + 64697 + ], + "mapped", + [ + 1592, + 1605 + ] + ], + [ + [ + 64698, + 64698 + ], + "mapped", + [ + 1593, + 1580 + ] + ], + [ + [ + 64699, + 64699 + ], + "mapped", + [ + 1593, + 1605 + ] + ], + [ + [ + 64700, + 64700 + ], + "mapped", + [ + 1594, + 1580 + ] + ], + [ + [ + 64701, + 64701 + ], + "mapped", + [ + 1594, + 1605 + ] + ], + [ + [ + 64702, + 64702 + ], + "mapped", + [ + 1601, + 1580 + ] + ], + [ + [ + 64703, + 64703 + ], + "mapped", + [ + 1601, + 1581 + ] + ], + [ + [ + 64704, + 64704 + ], + "mapped", + [ + 1601, + 1582 + ] + ], + [ + [ + 64705, + 64705 + ], + "mapped", + [ + 1601, + 1605 + ] + ], + [ + [ + 64706, + 64706 + ], + "mapped", + [ + 1602, + 1581 + ] + ], + [ + [ + 64707, + 64707 + ], + "mapped", + [ + 1602, + 1605 + ] + ], + [ + [ + 64708, + 64708 + ], + "mapped", + [ + 1603, + 1580 + ] + ], + [ + [ + 64709, + 64709 + ], + "mapped", + [ + 1603, + 1581 + ] + ], + [ + [ + 64710, + 64710 + ], + "mapped", + [ + 1603, + 1582 + ] + ], + [ + [ + 64711, + 64711 + ], + "mapped", + [ + 1603, + 1604 + ] + ], + [ + [ + 64712, + 64712 + ], + "mapped", + [ + 1603, + 1605 + ] + ], + [ + [ + 64713, + 64713 + ], + "mapped", + [ + 1604, + 1580 + ] + ], + [ + [ + 64714, + 64714 + ], + "mapped", + [ + 1604, + 1581 + ] + ], + [ + [ + 64715, + 64715 + ], + "mapped", + [ + 1604, + 1582 + ] + ], + [ + [ + 64716, + 64716 + ], + "mapped", + [ + 1604, + 1605 + ] + ], + [ + [ + 64717, + 64717 + ], + "mapped", + [ + 1604, + 1607 + ] + ], + [ + [ + 64718, + 64718 + ], + "mapped", + [ + 1605, + 1580 + ] + ], + [ + [ + 64719, + 64719 + ], + "mapped", + [ + 1605, + 1581 + ] + ], + [ + [ + 64720, + 64720 + ], + "mapped", + [ + 1605, + 1582 + ] + ], + [ + [ + 64721, + 64721 + ], + "mapped", + [ + 1605, + 1605 + ] + ], + [ + [ + 64722, + 64722 + ], + "mapped", + [ + 1606, + 1580 + ] + ], + [ + [ + 64723, + 64723 + ], + "mapped", + [ + 1606, + 1581 + ] + ], + [ + [ + 64724, + 64724 + ], + "mapped", + [ + 1606, + 1582 + ] + ], + [ + [ + 64725, + 64725 + ], + "mapped", + [ + 1606, + 1605 + ] + ], + [ + [ + 64726, + 64726 + ], + "mapped", + [ + 1606, + 1607 + ] + ], + [ + [ + 64727, + 64727 + ], + "mapped", + [ + 1607, + 1580 + ] + ], + [ + [ + 64728, + 64728 + ], + "mapped", + [ + 1607, + 1605 + ] + ], + [ + [ + 64729, + 64729 + ], + "mapped", + [ + 1607, + 1648 + ] + ], + [ + [ + 64730, + 64730 + ], + "mapped", + [ + 1610, + 1580 + ] + ], + [ + [ + 64731, + 64731 + ], + "mapped", + [ + 1610, + 1581 + ] + ], + [ + [ + 64732, + 64732 + ], + "mapped", + [ + 1610, + 1582 + ] + ], + [ + [ + 64733, + 64733 + ], + "mapped", + [ + 1610, + 1605 + ] + ], + [ + [ + 64734, + 64734 + ], + "mapped", + [ + 1610, + 1607 + ] + ], + [ + [ + 64735, + 64735 + ], + "mapped", + [ + 1574, + 1605 + ] + ], + [ + [ + 64736, + 64736 + ], + "mapped", + [ + 1574, + 1607 + ] + ], + [ + [ + 64737, + 64737 + ], + "mapped", + [ + 1576, + 1605 + ] + ], + [ + [ + 64738, + 64738 + ], + "mapped", + [ + 1576, + 1607 + ] + ], + [ + [ + 64739, + 64739 + ], + "mapped", + [ + 1578, + 1605 + ] + ], + [ + [ + 64740, + 64740 + ], + "mapped", + [ + 1578, + 1607 + ] + ], + [ + [ + 64741, + 64741 + ], + "mapped", + [ + 1579, + 1605 + ] + ], + [ + [ + 64742, + 64742 + ], + "mapped", + [ + 1579, + 1607 + ] + ], + [ + [ + 64743, + 64743 + ], + "mapped", + [ + 1587, + 1605 + ] + ], + [ + [ + 64744, + 64744 + ], + "mapped", + [ + 1587, + 1607 + ] + ], + [ + [ + 64745, + 64745 + ], + "mapped", + [ + 1588, + 1605 + ] + ], + [ + [ + 64746, + 64746 + ], + "mapped", + [ + 1588, + 1607 + ] + ], + [ + [ + 64747, + 64747 + ], + "mapped", + [ + 1603, + 1604 + ] + ], + [ + [ + 64748, + 64748 + ], + "mapped", + [ + 1603, + 1605 + ] + ], + [ + [ + 64749, + 64749 + ], + "mapped", + [ + 1604, + 1605 + ] + ], + [ + [ + 64750, + 64750 + ], + "mapped", + [ + 1606, + 1605 + ] + ], + [ + [ + 64751, + 64751 + ], + "mapped", + [ + 1606, + 1607 + ] + ], + [ + [ + 64752, + 64752 + ], + "mapped", + [ + 1610, + 1605 + ] + ], + [ + [ + 64753, + 64753 + ], + "mapped", + [ + 1610, + 1607 + ] + ], + [ + [ + 64754, + 64754 + ], + "mapped", + [ + 1600, + 1614, + 1617 + ] + ], + [ + [ + 64755, + 64755 + ], + "mapped", + [ + 1600, + 1615, + 1617 + ] + ], + [ + [ + 64756, + 64756 + ], + "mapped", + [ + 1600, + 1616, + 1617 + ] + ], + [ + [ + 64757, + 64757 + ], + "mapped", + [ + 1591, + 1609 + ] + ], + [ + [ + 64758, + 64758 + ], + "mapped", + [ + 1591, + 1610 + ] + ], + [ + [ + 64759, + 64759 + ], + "mapped", + [ + 1593, + 1609 + ] + ], + [ + [ + 64760, + 64760 + ], + "mapped", + [ + 1593, + 1610 + ] + ], + [ + [ + 64761, + 64761 + ], + "mapped", + [ + 1594, + 1609 + ] + ], + [ + [ + 64762, + 64762 + ], + "mapped", + [ + 1594, + 1610 + ] + ], + [ + [ + 64763, + 64763 + ], + "mapped", + [ + 1587, + 1609 + ] + ], + [ + [ + 64764, + 64764 + ], + "mapped", + [ + 1587, + 1610 + ] + ], + [ + [ + 64765, + 64765 + ], + "mapped", + [ + 1588, + 1609 + ] + ], + [ + [ + 64766, + 64766 + ], + "mapped", + [ + 1588, + 1610 + ] + ], + [ + [ + 64767, + 64767 + ], + "mapped", + [ + 1581, + 1609 + ] + ], + [ + [ + 64768, + 64768 + ], + "mapped", + [ + 1581, + 1610 + ] + ], + [ + [ + 64769, + 64769 + ], + "mapped", + [ + 1580, + 1609 + ] + ], + [ + [ + 64770, + 64770 + ], + "mapped", + [ + 1580, + 1610 + ] + ], + [ + [ + 64771, + 64771 + ], + "mapped", + [ + 1582, + 1609 + ] + ], + [ + [ + 64772, + 64772 + ], + "mapped", + [ + 1582, + 1610 + ] + ], + [ + [ + 64773, + 64773 + ], + "mapped", + [ + 1589, + 1609 + ] + ], + [ + [ + 64774, + 64774 + ], + "mapped", + [ + 1589, + 1610 + ] + ], + [ + [ + 64775, + 64775 + ], + "mapped", + [ + 1590, + 1609 + ] + ], + [ + [ + 64776, + 64776 + ], + "mapped", + [ + 1590, + 1610 + ] + ], + [ + [ + 64777, + 64777 + ], + "mapped", + [ + 1588, + 1580 + ] + ], + [ + [ + 64778, + 64778 + ], + "mapped", + [ + 1588, + 1581 + ] + ], + [ + [ + 64779, + 64779 + ], + "mapped", + [ + 1588, + 1582 + ] + ], + [ + [ + 64780, + 64780 + ], + "mapped", + [ + 1588, + 1605 + ] + ], + [ + [ + 64781, + 64781 + ], + "mapped", + [ + 1588, + 1585 + ] + ], + [ + [ + 64782, + 64782 + ], + "mapped", + [ + 1587, + 1585 + ] + ], + [ + [ + 64783, + 64783 + ], + "mapped", + [ + 1589, + 1585 + ] + ], + [ + [ + 64784, + 64784 + ], + "mapped", + [ + 1590, + 1585 + ] + ], + [ + [ + 64785, + 64785 + ], + "mapped", + [ + 1591, + 1609 + ] + ], + [ + [ + 64786, + 64786 + ], + "mapped", + [ + 1591, + 1610 + ] + ], + [ + [ + 64787, + 64787 + ], + "mapped", + [ + 1593, + 1609 + ] + ], + [ + [ + 64788, + 64788 + ], + "mapped", + [ + 1593, + 1610 + ] + ], + [ + [ + 64789, + 64789 + ], + "mapped", + [ + 1594, + 1609 + ] + ], + [ + [ + 64790, + 64790 + ], + "mapped", + [ + 1594, + 1610 + ] + ], + [ + [ + 64791, + 64791 + ], + "mapped", + [ + 1587, + 1609 + ] + ], + [ + [ + 64792, + 64792 + ], + "mapped", + [ + 1587, + 1610 + ] + ], + [ + [ + 64793, + 64793 + ], + "mapped", + [ + 1588, + 1609 + ] + ], + [ + [ + 64794, + 64794 + ], + "mapped", + [ + 1588, + 1610 + ] + ], + [ + [ + 64795, + 64795 + ], + "mapped", + [ + 1581, + 1609 + ] + ], + [ + [ + 64796, + 64796 + ], + "mapped", + [ + 1581, + 1610 + ] + ], + [ + [ + 64797, + 64797 + ], + "mapped", + [ + 1580, + 1609 + ] + ], + [ + [ + 64798, + 64798 + ], + "mapped", + [ + 1580, + 1610 + ] + ], + [ + [ + 64799, + 64799 + ], + "mapped", + [ + 1582, + 1609 + ] + ], + [ + [ + 64800, + 64800 + ], + "mapped", + [ + 1582, + 1610 + ] + ], + [ + [ + 64801, + 64801 + ], + "mapped", + [ + 1589, + 1609 + ] + ], + [ + [ + 64802, + 64802 + ], + "mapped", + [ + 1589, + 1610 + ] + ], + [ + [ + 64803, + 64803 + ], + "mapped", + [ + 1590, + 1609 + ] + ], + [ + [ + 64804, + 64804 + ], + "mapped", + [ + 1590, + 1610 + ] + ], + [ + [ + 64805, + 64805 + ], + "mapped", + [ + 1588, + 1580 + ] + ], + [ + [ + 64806, + 64806 + ], + "mapped", + [ + 1588, + 1581 + ] + ], + [ + [ + 64807, + 64807 + ], + "mapped", + [ + 1588, + 1582 + ] + ], + [ + [ + 64808, + 64808 + ], + "mapped", + [ + 1588, + 1605 + ] + ], + [ + [ + 64809, + 64809 + ], + "mapped", + [ + 1588, + 1585 + ] + ], + [ + [ + 64810, + 64810 + ], + "mapped", + [ + 1587, + 1585 + ] + ], + [ + [ + 64811, + 64811 + ], + "mapped", + [ + 1589, + 1585 + ] + ], + [ + [ + 64812, + 64812 + ], + "mapped", + [ + 1590, + 1585 + ] + ], + [ + [ + 64813, + 64813 + ], + "mapped", + [ + 1588, + 1580 + ] + ], + [ + [ + 64814, + 64814 + ], + "mapped", + [ + 1588, + 1581 + ] + ], + [ + [ + 64815, + 64815 + ], + "mapped", + [ + 1588, + 1582 + ] + ], + [ + [ + 64816, + 64816 + ], + "mapped", + [ + 1588, + 1605 + ] + ], + [ + [ + 64817, + 64817 + ], + "mapped", + [ + 1587, + 1607 + ] + ], + [ + [ + 64818, + 64818 + ], + "mapped", + [ + 1588, + 1607 + ] + ], + [ + [ + 64819, + 64819 + ], + "mapped", + [ + 1591, + 1605 + ] + ], + [ + [ + 64820, + 64820 + ], + "mapped", + [ + 1587, + 1580 + ] + ], + [ + [ + 64821, + 64821 + ], + "mapped", + [ + 1587, + 1581 + ] + ], + [ + [ + 64822, + 64822 + ], + "mapped", + [ + 1587, + 1582 + ] + ], + [ + [ + 64823, + 64823 + ], + "mapped", + [ + 1588, + 1580 + ] + ], + [ + [ + 64824, + 64824 + ], + "mapped", + [ + 1588, + 1581 + ] + ], + [ + [ + 64825, + 64825 + ], + "mapped", + [ + 1588, + 1582 + ] + ], + [ + [ + 64826, + 64826 + ], + "mapped", + [ + 1591, + 1605 + ] + ], + [ + [ + 64827, + 64827 + ], + "mapped", + [ + 1592, + 1605 + ] + ], + [ + [ + 64828, + 64829 + ], + "mapped", + [ + 1575, + 1611 + ] + ], + [ + [ + 64830, + 64831 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 64832, + 64847 + ], + "disallowed" + ], + [ + [ + 64848, + 64848 + ], + "mapped", + [ + 1578, + 1580, + 1605 + ] + ], + [ + [ + 64849, + 64850 + ], + "mapped", + [ + 1578, + 1581, + 1580 + ] + ], + [ + [ + 64851, + 64851 + ], + "mapped", + [ + 1578, + 1581, + 1605 + ] + ], + [ + [ + 64852, + 64852 + ], + "mapped", + [ + 1578, + 1582, + 1605 + ] + ], + [ + [ + 64853, + 64853 + ], + "mapped", + [ + 1578, + 1605, + 1580 + ] + ], + [ + [ + 64854, + 64854 + ], + "mapped", + [ + 1578, + 1605, + 1581 + ] + ], + [ + [ + 64855, + 64855 + ], + "mapped", + [ + 1578, + 1605, + 1582 + ] + ], + [ + [ + 64856, + 64857 + ], + "mapped", + [ + 1580, + 1605, + 1581 + ] + ], + [ + [ + 64858, + 64858 + ], + "mapped", + [ + 1581, + 1605, + 1610 + ] + ], + [ + [ + 64859, + 64859 + ], + "mapped", + [ + 1581, + 1605, + 1609 + ] + ], + [ + [ + 64860, + 64860 + ], + "mapped", + [ + 1587, + 1581, + 1580 + ] + ], + [ + [ + 64861, + 64861 + ], + "mapped", + [ + 1587, + 1580, + 1581 + ] + ], + [ + [ + 64862, + 64862 + ], + "mapped", + [ + 1587, + 1580, + 1609 + ] + ], + [ + [ + 64863, + 64864 + ], + "mapped", + [ + 1587, + 1605, + 1581 + ] + ], + [ + [ + 64865, + 64865 + ], + "mapped", + [ + 1587, + 1605, + 1580 + ] + ], + [ + [ + 64866, + 64867 + ], + "mapped", + [ + 1587, + 1605, + 1605 + ] + ], + [ + [ + 64868, + 64869 + ], + "mapped", + [ + 1589, + 1581, + 1581 + ] + ], + [ + [ + 64870, + 64870 + ], + "mapped", + [ + 1589, + 1605, + 1605 + ] + ], + [ + [ + 64871, + 64872 + ], + "mapped", + [ + 1588, + 1581, + 1605 + ] + ], + [ + [ + 64873, + 64873 + ], + "mapped", + [ + 1588, + 1580, + 1610 + ] + ], + [ + [ + 64874, + 64875 + ], + "mapped", + [ + 1588, + 1605, + 1582 + ] + ], + [ + [ + 64876, + 64877 + ], + "mapped", + [ + 1588, + 1605, + 1605 + ] + ], + [ + [ + 64878, + 64878 + ], + "mapped", + [ + 1590, + 1581, + 1609 + ] + ], + [ + [ + 64879, + 64880 + ], + "mapped", + [ + 1590, + 1582, + 1605 + ] + ], + [ + [ + 64881, + 64882 + ], + "mapped", + [ + 1591, + 1605, + 1581 + ] + ], + [ + [ + 64883, + 64883 + ], + "mapped", + [ + 1591, + 1605, + 1605 + ] + ], + [ + [ + 64884, + 64884 + ], + "mapped", + [ + 1591, + 1605, + 1610 + ] + ], + [ + [ + 64885, + 64885 + ], + "mapped", + [ + 1593, + 1580, + 1605 + ] + ], + [ + [ + 64886, + 64887 + ], + "mapped", + [ + 1593, + 1605, + 1605 + ] + ], + [ + [ + 64888, + 64888 + ], + "mapped", + [ + 1593, + 1605, + 1609 + ] + ], + [ + [ + 64889, + 64889 + ], + "mapped", + [ + 1594, + 1605, + 1605 + ] + ], + [ + [ + 64890, + 64890 + ], + "mapped", + [ + 1594, + 1605, + 1610 + ] + ], + [ + [ + 64891, + 64891 + ], + "mapped", + [ + 1594, + 1605, + 1609 + ] + ], + [ + [ + 64892, + 64893 + ], + "mapped", + [ + 1601, + 1582, + 1605 + ] + ], + [ + [ + 64894, + 64894 + ], + "mapped", + [ + 1602, + 1605, + 1581 + ] + ], + [ + [ + 64895, + 64895 + ], + "mapped", + [ + 1602, + 1605, + 1605 + ] + ], + [ + [ + 64896, + 64896 + ], + "mapped", + [ + 1604, + 1581, + 1605 + ] + ], + [ + [ + 64897, + 64897 + ], + "mapped", + [ + 1604, + 1581, + 1610 + ] + ], + [ + [ + 64898, + 64898 + ], + "mapped", + [ + 1604, + 1581, + 1609 + ] + ], + [ + [ + 64899, + 64900 + ], + "mapped", + [ + 1604, + 1580, + 1580 + ] + ], + [ + [ + 64901, + 64902 + ], + "mapped", + [ + 1604, + 1582, + 1605 + ] + ], + [ + [ + 64903, + 64904 + ], + "mapped", + [ + 1604, + 1605, + 1581 + ] + ], + [ + [ + 64905, + 64905 + ], + "mapped", + [ + 1605, + 1581, + 1580 + ] + ], + [ + [ + 64906, + 64906 + ], + "mapped", + [ + 1605, + 1581, + 1605 + ] + ], + [ + [ + 64907, + 64907 + ], + "mapped", + [ + 1605, + 1581, + 1610 + ] + ], + [ + [ + 64908, + 64908 + ], + "mapped", + [ + 1605, + 1580, + 1581 + ] + ], + [ + [ + 64909, + 64909 + ], + "mapped", + [ + 1605, + 1580, + 1605 + ] + ], + [ + [ + 64910, + 64910 + ], + "mapped", + [ + 1605, + 1582, + 1580 + ] + ], + [ + [ + 64911, + 64911 + ], + "mapped", + [ + 1605, + 1582, + 1605 + ] + ], + [ + [ + 64912, + 64913 + ], + "disallowed" + ], + [ + [ + 64914, + 64914 + ], + "mapped", + [ + 1605, + 1580, + 1582 + ] + ], + [ + [ + 64915, + 64915 + ], + "mapped", + [ + 1607, + 1605, + 1580 + ] + ], + [ + [ + 64916, + 64916 + ], + "mapped", + [ + 1607, + 1605, + 1605 + ] + ], + [ + [ + 64917, + 64917 + ], + "mapped", + [ + 1606, + 1581, + 1605 + ] + ], + [ + [ + 64918, + 64918 + ], + "mapped", + [ + 1606, + 1581, + 1609 + ] + ], + [ + [ + 64919, + 64920 + ], + "mapped", + [ + 1606, + 1580, + 1605 + ] + ], + [ + [ + 64921, + 64921 + ], + "mapped", + [ + 1606, + 1580, + 1609 + ] + ], + [ + [ + 64922, + 64922 + ], + "mapped", + [ + 1606, + 1605, + 1610 + ] + ], + [ + [ + 64923, + 64923 + ], + "mapped", + [ + 1606, + 1605, + 1609 + ] + ], + [ + [ + 64924, + 64925 + ], + "mapped", + [ + 1610, + 1605, + 1605 + ] + ], + [ + [ + 64926, + 64926 + ], + "mapped", + [ + 1576, + 1582, + 1610 + ] + ], + [ + [ + 64927, + 64927 + ], + "mapped", + [ + 1578, + 1580, + 1610 + ] + ], + [ + [ + 64928, + 64928 + ], + "mapped", + [ + 1578, + 1580, + 1609 + ] + ], + [ + [ + 64929, + 64929 + ], + "mapped", + [ + 1578, + 1582, + 1610 + ] + ], + [ + [ + 64930, + 64930 + ], + "mapped", + [ + 1578, + 1582, + 1609 + ] + ], + [ + [ + 64931, + 64931 + ], + "mapped", + [ + 1578, + 1605, + 1610 + ] + ], + [ + [ + 64932, + 64932 + ], + "mapped", + [ + 1578, + 1605, + 1609 + ] + ], + [ + [ + 64933, + 64933 + ], + "mapped", + [ + 1580, + 1605, + 1610 + ] + ], + [ + [ + 64934, + 64934 + ], + "mapped", + [ + 1580, + 1581, + 1609 + ] + ], + [ + [ + 64935, + 64935 + ], + "mapped", + [ + 1580, + 1605, + 1609 + ] + ], + [ + [ + 64936, + 64936 + ], + "mapped", + [ + 1587, + 1582, + 1609 + ] + ], + [ + [ + 64937, + 64937 + ], + "mapped", + [ + 1589, + 1581, + 1610 + ] + ], + [ + [ + 64938, + 64938 + ], + "mapped", + [ + 1588, + 1581, + 1610 + ] + ], + [ + [ + 64939, + 64939 + ], + "mapped", + [ + 1590, + 1581, + 1610 + ] + ], + [ + [ + 64940, + 64940 + ], + "mapped", + [ + 1604, + 1580, + 1610 + ] + ], + [ + [ + 64941, + 64941 + ], + "mapped", + [ + 1604, + 1605, + 1610 + ] + ], + [ + [ + 64942, + 64942 + ], + "mapped", + [ + 1610, + 1581, + 1610 + ] + ], + [ + [ + 64943, + 64943 + ], + "mapped", + [ + 1610, + 1580, + 1610 + ] + ], + [ + [ + 64944, + 64944 + ], + "mapped", + [ + 1610, + 1605, + 1610 + ] + ], + [ + [ + 64945, + 64945 + ], + "mapped", + [ + 1605, + 1605, + 1610 + ] + ], + [ + [ + 64946, + 64946 + ], + "mapped", + [ + 1602, + 1605, + 1610 + ] + ], + [ + [ + 64947, + 64947 + ], + "mapped", + [ + 1606, + 1581, + 1610 + ] + ], + [ + [ + 64948, + 64948 + ], + "mapped", + [ + 1602, + 1605, + 1581 + ] + ], + [ + [ + 64949, + 64949 + ], + "mapped", + [ + 1604, + 1581, + 1605 + ] + ], + [ + [ + 64950, + 64950 + ], + "mapped", + [ + 1593, + 1605, + 1610 + ] + ], + [ + [ + 64951, + 64951 + ], + "mapped", + [ + 1603, + 1605, + 1610 + ] + ], + [ + [ + 64952, + 64952 + ], + "mapped", + [ + 1606, + 1580, + 1581 + ] + ], + [ + [ + 64953, + 64953 + ], + "mapped", + [ + 1605, + 1582, + 1610 + ] + ], + [ + [ + 64954, + 64954 + ], + "mapped", + [ + 1604, + 1580, + 1605 + ] + ], + [ + [ + 64955, + 64955 + ], + "mapped", + [ + 1603, + 1605, + 1605 + ] + ], + [ + [ + 64956, + 64956 + ], + "mapped", + [ + 1604, + 1580, + 1605 + ] + ], + [ + [ + 64957, + 64957 + ], + "mapped", + [ + 1606, + 1580, + 1581 + ] + ], + [ + [ + 64958, + 64958 + ], + "mapped", + [ + 1580, + 1581, + 1610 + ] + ], + [ + [ + 64959, + 64959 + ], + "mapped", + [ + 1581, + 1580, + 1610 + ] + ], + [ + [ + 64960, + 64960 + ], + "mapped", + [ + 1605, + 1580, + 1610 + ] + ], + [ + [ + 64961, + 64961 + ], + "mapped", + [ + 1601, + 1605, + 1610 + ] + ], + [ + [ + 64962, + 64962 + ], + "mapped", + [ + 1576, + 1581, + 1610 + ] + ], + [ + [ + 64963, + 64963 + ], + "mapped", + [ + 1603, + 1605, + 1605 + ] + ], + [ + [ + 64964, + 64964 + ], + "mapped", + [ + 1593, + 1580, + 1605 + ] + ], + [ + [ + 64965, + 64965 + ], + "mapped", + [ + 1589, + 1605, + 1605 + ] + ], + [ + [ + 64966, + 64966 + ], + "mapped", + [ + 1587, + 1582, + 1610 + ] + ], + [ + [ + 64967, + 64967 + ], + "mapped", + [ + 1606, + 1580, + 1610 + ] + ], + [ + [ + 64968, + 64975 + ], + "disallowed" + ], + [ + [ + 64976, + 65007 + ], + "disallowed" + ], + [ + [ + 65008, + 65008 + ], + "mapped", + [ + 1589, + 1604, + 1746 + ] + ], + [ + [ + 65009, + 65009 + ], + "mapped", + [ + 1602, + 1604, + 1746 + ] + ], + [ + [ + 65010, + 65010 + ], + "mapped", + [ + 1575, + 1604, + 1604, + 1607 + ] + ], + [ + [ + 65011, + 65011 + ], + "mapped", + [ + 1575, + 1603, + 1576, + 1585 + ] + ], + [ + [ + 65012, + 65012 + ], + "mapped", + [ + 1605, + 1581, + 1605, + 1583 + ] + ], + [ + [ + 65013, + 65013 + ], + "mapped", + [ + 1589, + 1604, + 1593, + 1605 + ] + ], + [ + [ + 65014, + 65014 + ], + "mapped", + [ + 1585, + 1587, + 1608, + 1604 + ] + ], + [ + [ + 65015, + 65015 + ], + "mapped", + [ + 1593, + 1604, + 1610, + 1607 + ] + ], + [ + [ + 65016, + 65016 + ], + "mapped", + [ + 1608, + 1587, + 1604, + 1605 + ] + ], + [ + [ + 65017, + 65017 + ], + "mapped", + [ + 1589, + 1604, + 1609 + ] + ], + [ + [ + 65018, + 65018 + ], + "disallowed_STD3_mapped", + [ + 1589, + 1604, + 1609, + 32, + 1575, + 1604, + 1604, + 1607, + 32, + 1593, + 1604, + 1610, + 1607, + 32, + 1608, + 1587, + 1604, + 1605 + ] + ], + [ + [ + 65019, + 65019 + ], + "disallowed_STD3_mapped", + [ + 1580, + 1604, + 32, + 1580, + 1604, + 1575, + 1604, + 1607 + ] + ], + [ + [ + 65020, + 65020 + ], + "mapped", + [ + 1585, + 1740, + 1575, + 1604 + ] + ], + [ + [ + 65021, + 65021 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 65022, + 65023 + ], + "disallowed" + ], + [ + [ + 65024, + 65039 + ], + "ignored" + ], + [ + [ + 65040, + 65040 + ], + "disallowed_STD3_mapped", + [ + 44 + ] + ], + [ + [ + 65041, + 65041 + ], + "mapped", + [ + 12289 + ] + ], + [ + [ + 65042, + 65042 + ], + "disallowed" + ], + [ + [ + 65043, + 65043 + ], + "disallowed_STD3_mapped", + [ + 58 + ] + ], + [ + [ + 65044, + 65044 + ], + "disallowed_STD3_mapped", + [ + 59 + ] + ], + [ + [ + 65045, + 65045 + ], + "disallowed_STD3_mapped", + [ + 33 + ] + ], + [ + [ + 65046, + 65046 + ], + "disallowed_STD3_mapped", + [ + 63 + ] + ], + [ + [ + 65047, + 65047 + ], + "mapped", + [ + 12310 + ] + ], + [ + [ + 65048, + 65048 + ], + "mapped", + [ + 12311 + ] + ], + [ + [ + 65049, + 65049 + ], + "disallowed" + ], + [ + [ + 65050, + 65055 + ], + "disallowed" + ], + [ + [ + 65056, + 65059 + ], + "valid" + ], + [ + [ + 65060, + 65062 + ], + "valid" + ], + [ + [ + 65063, + 65069 + ], + "valid" + ], + [ + [ + 65070, + 65071 + ], + "valid" + ], + [ + [ + 65072, + 65072 + ], + "disallowed" + ], + [ + [ + 65073, + 65073 + ], + "mapped", + [ + 8212 + ] + ], + [ + [ + 65074, + 65074 + ], + "mapped", + [ + 8211 + ] + ], + [ + [ + 65075, + 65076 + ], + "disallowed_STD3_mapped", + [ + 95 + ] + ], + [ + [ + 65077, + 65077 + ], + "disallowed_STD3_mapped", + [ + 40 + ] + ], + [ + [ + 65078, + 65078 + ], + "disallowed_STD3_mapped", + [ + 41 + ] + ], + [ + [ + 65079, + 65079 + ], + "disallowed_STD3_mapped", + [ + 123 + ] + ], + [ + [ + 65080, + 65080 + ], + "disallowed_STD3_mapped", + [ + 125 + ] + ], + [ + [ + 65081, + 65081 + ], + "mapped", + [ + 12308 + ] + ], + [ + [ + 65082, + 65082 + ], + "mapped", + [ + 12309 + ] + ], + [ + [ + 65083, + 65083 + ], + "mapped", + [ + 12304 + ] + ], + [ + [ + 65084, + 65084 + ], + "mapped", + [ + 12305 + ] + ], + [ + [ + 65085, + 65085 + ], + "mapped", + [ + 12298 + ] + ], + [ + [ + 65086, + 65086 + ], + "mapped", + [ + 12299 + ] + ], + [ + [ + 65087, + 65087 + ], + "mapped", + [ + 12296 + ] + ], + [ + [ + 65088, + 65088 + ], + "mapped", + [ + 12297 + ] + ], + [ + [ + 65089, + 65089 + ], + "mapped", + [ + 12300 + ] + ], + [ + [ + 65090, + 65090 + ], + "mapped", + [ + 12301 + ] + ], + [ + [ + 65091, + 65091 + ], + "mapped", + [ + 12302 + ] + ], + [ + [ + 65092, + 65092 + ], + "mapped", + [ + 12303 + ] + ], + [ + [ + 65093, + 65094 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 65095, + 65095 + ], + "disallowed_STD3_mapped", + [ + 91 + ] + ], + [ + [ + 65096, + 65096 + ], + "disallowed_STD3_mapped", + [ + 93 + ] + ], + [ + [ + 65097, + 65100 + ], + "disallowed_STD3_mapped", + [ + 32, + 773 + ] + ], + [ + [ + 65101, + 65103 + ], + "disallowed_STD3_mapped", + [ + 95 + ] + ], + [ + [ + 65104, + 65104 + ], + "disallowed_STD3_mapped", + [ + 44 + ] + ], + [ + [ + 65105, + 65105 + ], + "mapped", + [ + 12289 + ] + ], + [ + [ + 65106, + 65106 + ], + "disallowed" + ], + [ + [ + 65107, + 65107 + ], + "disallowed" + ], + [ + [ + 65108, + 65108 + ], + "disallowed_STD3_mapped", + [ + 59 + ] + ], + [ + [ + 65109, + 65109 + ], + "disallowed_STD3_mapped", + [ + 58 + ] + ], + [ + [ + 65110, + 65110 + ], + "disallowed_STD3_mapped", + [ + 63 + ] + ], + [ + [ + 65111, + 65111 + ], + "disallowed_STD3_mapped", + [ + 33 + ] + ], + [ + [ + 65112, + 65112 + ], + "mapped", + [ + 8212 + ] + ], + [ + [ + 65113, + 65113 + ], + "disallowed_STD3_mapped", + [ + 40 + ] + ], + [ + [ + 65114, + 65114 + ], + "disallowed_STD3_mapped", + [ + 41 + ] + ], + [ + [ + 65115, + 65115 + ], + "disallowed_STD3_mapped", + [ + 123 + ] + ], + [ + [ + 65116, + 65116 + ], + "disallowed_STD3_mapped", + [ + 125 + ] + ], + [ + [ + 65117, + 65117 + ], + "mapped", + [ + 12308 + ] + ], + [ + [ + 65118, + 65118 + ], + "mapped", + [ + 12309 + ] + ], + [ + [ + 65119, + 65119 + ], + "disallowed_STD3_mapped", + [ + 35 + ] + ], + [ + [ + 65120, + 65120 + ], + "disallowed_STD3_mapped", + [ + 38 + ] + ], + [ + [ + 65121, + 65121 + ], + "disallowed_STD3_mapped", + [ + 42 + ] + ], + [ + [ + 65122, + 65122 + ], + "disallowed_STD3_mapped", + [ + 43 + ] + ], + [ + [ + 65123, + 65123 + ], + "mapped", + [ + 45 + ] + ], + [ + [ + 65124, + 65124 + ], + "disallowed_STD3_mapped", + [ + 60 + ] + ], + [ + [ + 65125, + 65125 + ], + "disallowed_STD3_mapped", + [ + 62 + ] + ], + [ + [ + 65126, + 65126 + ], + "disallowed_STD3_mapped", + [ + 61 + ] + ], + [ + [ + 65127, + 65127 + ], + "disallowed" + ], + [ + [ + 65128, + 65128 + ], + "disallowed_STD3_mapped", + [ + 92 + ] + ], + [ + [ + 65129, + 65129 + ], + "disallowed_STD3_mapped", + [ + 36 + ] + ], + [ + [ + 65130, + 65130 + ], + "disallowed_STD3_mapped", + [ + 37 + ] + ], + [ + [ + 65131, + 65131 + ], + "disallowed_STD3_mapped", + [ + 64 + ] + ], + [ + [ + 65132, + 65135 + ], + "disallowed" + ], + [ + [ + 65136, + 65136 + ], + "disallowed_STD3_mapped", + [ + 32, + 1611 + ] + ], + [ + [ + 65137, + 65137 + ], + "mapped", + [ + 1600, + 1611 + ] + ], + [ + [ + 65138, + 65138 + ], + "disallowed_STD3_mapped", + [ + 32, + 1612 + ] + ], + [ + [ + 65139, + 65139 + ], + "valid" + ], + [ + [ + 65140, + 65140 + ], + "disallowed_STD3_mapped", + [ + 32, + 1613 + ] + ], + [ + [ + 65141, + 65141 + ], + "disallowed" + ], + [ + [ + 65142, + 65142 + ], + "disallowed_STD3_mapped", + [ + 32, + 1614 + ] + ], + [ + [ + 65143, + 65143 + ], + "mapped", + [ + 1600, + 1614 + ] + ], + [ + [ + 65144, + 65144 + ], + "disallowed_STD3_mapped", + [ + 32, + 1615 + ] + ], + [ + [ + 65145, + 65145 + ], + "mapped", + [ + 1600, + 1615 + ] + ], + [ + [ + 65146, + 65146 + ], + "disallowed_STD3_mapped", + [ + 32, + 1616 + ] + ], + [ + [ + 65147, + 65147 + ], + "mapped", + [ + 1600, + 1616 + ] + ], + [ + [ + 65148, + 65148 + ], + "disallowed_STD3_mapped", + [ + 32, + 1617 + ] + ], + [ + [ + 65149, + 65149 + ], + "mapped", + [ + 1600, + 1617 + ] + ], + [ + [ + 65150, + 65150 + ], + "disallowed_STD3_mapped", + [ + 32, + 1618 + ] + ], + [ + [ + 65151, + 65151 + ], + "mapped", + [ + 1600, + 1618 + ] + ], + [ + [ + 65152, + 65152 + ], + "mapped", + [ + 1569 + ] + ], + [ + [ + 65153, + 65154 + ], + "mapped", + [ + 1570 + ] + ], + [ + [ + 65155, + 65156 + ], + "mapped", + [ + 1571 + ] + ], + [ + [ + 65157, + 65158 + ], + "mapped", + [ + 1572 + ] + ], + [ + [ + 65159, + 65160 + ], + "mapped", + [ + 1573 + ] + ], + [ + [ + 65161, + 65164 + ], + "mapped", + [ + 1574 + ] + ], + [ + [ + 65165, + 65166 + ], + "mapped", + [ + 1575 + ] + ], + [ + [ + 65167, + 65170 + ], + "mapped", + [ + 1576 + ] + ], + [ + [ + 65171, + 65172 + ], + "mapped", + [ + 1577 + ] + ], + [ + [ + 65173, + 65176 + ], + "mapped", + [ + 1578 + ] + ], + [ + [ + 65177, + 65180 + ], + "mapped", + [ + 1579 + ] + ], + [ + [ + 65181, + 65184 + ], + "mapped", + [ + 1580 + ] + ], + [ + [ + 65185, + 65188 + ], + "mapped", + [ + 1581 + ] + ], + [ + [ + 65189, + 65192 + ], + "mapped", + [ + 1582 + ] + ], + [ + [ + 65193, + 65194 + ], + "mapped", + [ + 1583 + ] + ], + [ + [ + 65195, + 65196 + ], + "mapped", + [ + 1584 + ] + ], + [ + [ + 65197, + 65198 + ], + "mapped", + [ + 1585 + ] + ], + [ + [ + 65199, + 65200 + ], + "mapped", + [ + 1586 + ] + ], + [ + [ + 65201, + 65204 + ], + "mapped", + [ + 1587 + ] + ], + [ + [ + 65205, + 65208 + ], + "mapped", + [ + 1588 + ] + ], + [ + [ + 65209, + 65212 + ], + "mapped", + [ + 1589 + ] + ], + [ + [ + 65213, + 65216 + ], + "mapped", + [ + 1590 + ] + ], + [ + [ + 65217, + 65220 + ], + "mapped", + [ + 1591 + ] + ], + [ + [ + 65221, + 65224 + ], + "mapped", + [ + 1592 + ] + ], + [ + [ + 65225, + 65228 + ], + "mapped", + [ + 1593 + ] + ], + [ + [ + 65229, + 65232 + ], + "mapped", + [ + 1594 + ] + ], + [ + [ + 65233, + 65236 + ], + "mapped", + [ + 1601 + ] + ], + [ + [ + 65237, + 65240 + ], + "mapped", + [ + 1602 + ] + ], + [ + [ + 65241, + 65244 + ], + "mapped", + [ + 1603 + ] + ], + [ + [ + 65245, + 65248 + ], + "mapped", + [ + 1604 + ] + ], + [ + [ + 65249, + 65252 + ], + "mapped", + [ + 1605 + ] + ], + [ + [ + 65253, + 65256 + ], + "mapped", + [ + 1606 + ] + ], + [ + [ + 65257, + 65260 + ], + "mapped", + [ + 1607 + ] + ], + [ + [ + 65261, + 65262 + ], + "mapped", + [ + 1608 + ] + ], + [ + [ + 65263, + 65264 + ], + "mapped", + [ + 1609 + ] + ], + [ + [ + 65265, + 65268 + ], + "mapped", + [ + 1610 + ] + ], + [ + [ + 65269, + 65270 + ], + "mapped", + [ + 1604, + 1570 + ] + ], + [ + [ + 65271, + 65272 + ], + "mapped", + [ + 1604, + 1571 + ] + ], + [ + [ + 65273, + 65274 + ], + "mapped", + [ + 1604, + 1573 + ] + ], + [ + [ + 65275, + 65276 + ], + "mapped", + [ + 1604, + 1575 + ] + ], + [ + [ + 65277, + 65278 + ], + "disallowed" + ], + [ + [ + 65279, + 65279 + ], + "ignored" + ], + [ + [ + 65280, + 65280 + ], + "disallowed" + ], + [ + [ + 65281, + 65281 + ], + "disallowed_STD3_mapped", + [ + 33 + ] + ], + [ + [ + 65282, + 65282 + ], + "disallowed_STD3_mapped", + [ + 34 + ] + ], + [ + [ + 65283, + 65283 + ], + "disallowed_STD3_mapped", + [ + 35 + ] + ], + [ + [ + 65284, + 65284 + ], + "disallowed_STD3_mapped", + [ + 36 + ] + ], + [ + [ + 65285, + 65285 + ], + "disallowed_STD3_mapped", + [ + 37 + ] + ], + [ + [ + 65286, + 65286 + ], + "disallowed_STD3_mapped", + [ + 38 + ] + ], + [ + [ + 65287, + 65287 + ], + "disallowed_STD3_mapped", + [ + 39 + ] + ], + [ + [ + 65288, + 65288 + ], + "disallowed_STD3_mapped", + [ + 40 + ] + ], + [ + [ + 65289, + 65289 + ], + "disallowed_STD3_mapped", + [ + 41 + ] + ], + [ + [ + 65290, + 65290 + ], + "disallowed_STD3_mapped", + [ + 42 + ] + ], + [ + [ + 65291, + 65291 + ], + "disallowed_STD3_mapped", + [ + 43 + ] + ], + [ + [ + 65292, + 65292 + ], + "disallowed_STD3_mapped", + [ + 44 + ] + ], + [ + [ + 65293, + 65293 + ], + "mapped", + [ + 45 + ] + ], + [ + [ + 65294, + 65294 + ], + "mapped", + [ + 46 + ] + ], + [ + [ + 65295, + 65295 + ], + "disallowed_STD3_mapped", + [ + 47 + ] + ], + [ + [ + 65296, + 65296 + ], + "mapped", + [ + 48 + ] + ], + [ + [ + 65297, + 65297 + ], + "mapped", + [ + 49 + ] + ], + [ + [ + 65298, + 65298 + ], + "mapped", + [ + 50 + ] + ], + [ + [ + 65299, + 65299 + ], + "mapped", + [ + 51 + ] + ], + [ + [ + 65300, + 65300 + ], + "mapped", + [ + 52 + ] + ], + [ + [ + 65301, + 65301 + ], + "mapped", + [ + 53 + ] + ], + [ + [ + 65302, + 65302 + ], + "mapped", + [ + 54 + ] + ], + [ + [ + 65303, + 65303 + ], + "mapped", + [ + 55 + ] + ], + [ + [ + 65304, + 65304 + ], + "mapped", + [ + 56 + ] + ], + [ + [ + 65305, + 65305 + ], + "mapped", + [ + 57 + ] + ], + [ + [ + 65306, + 65306 + ], + "disallowed_STD3_mapped", + [ + 58 + ] + ], + [ + [ + 65307, + 65307 + ], + "disallowed_STD3_mapped", + [ + 59 + ] + ], + [ + [ + 65308, + 65308 + ], + "disallowed_STD3_mapped", + [ + 60 + ] + ], + [ + [ + 65309, + 65309 + ], + "disallowed_STD3_mapped", + [ + 61 + ] + ], + [ + [ + 65310, + 65310 + ], + "disallowed_STD3_mapped", + [ + 62 + ] + ], + [ + [ + 65311, + 65311 + ], + "disallowed_STD3_mapped", + [ + 63 + ] + ], + [ + [ + 65312, + 65312 + ], + "disallowed_STD3_mapped", + [ + 64 + ] + ], + [ + [ + 65313, + 65313 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 65314, + 65314 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 65315, + 65315 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 65316, + 65316 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 65317, + 65317 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 65318, + 65318 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 65319, + 65319 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 65320, + 65320 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 65321, + 65321 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 65322, + 65322 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 65323, + 65323 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 65324, + 65324 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 65325, + 65325 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 65326, + 65326 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 65327, + 65327 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 65328, + 65328 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 65329, + 65329 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 65330, + 65330 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 65331, + 65331 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 65332, + 65332 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 65333, + 65333 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 65334, + 65334 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 65335, + 65335 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 65336, + 65336 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 65337, + 65337 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 65338, + 65338 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 65339, + 65339 + ], + "disallowed_STD3_mapped", + [ + 91 + ] + ], + [ + [ + 65340, + 65340 + ], + "disallowed_STD3_mapped", + [ + 92 + ] + ], + [ + [ + 65341, + 65341 + ], + "disallowed_STD3_mapped", + [ + 93 + ] + ], + [ + [ + 65342, + 65342 + ], + "disallowed_STD3_mapped", + [ + 94 + ] + ], + [ + [ + 65343, + 65343 + ], + "disallowed_STD3_mapped", + [ + 95 + ] + ], + [ + [ + 65344, + 65344 + ], + "disallowed_STD3_mapped", + [ + 96 + ] + ], + [ + [ + 65345, + 65345 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 65346, + 65346 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 65347, + 65347 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 65348, + 65348 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 65349, + 65349 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 65350, + 65350 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 65351, + 65351 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 65352, + 65352 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 65353, + 65353 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 65354, + 65354 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 65355, + 65355 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 65356, + 65356 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 65357, + 65357 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 65358, + 65358 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 65359, + 65359 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 65360, + 65360 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 65361, + 65361 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 65362, + 65362 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 65363, + 65363 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 65364, + 65364 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 65365, + 65365 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 65366, + 65366 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 65367, + 65367 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 65368, + 65368 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 65369, + 65369 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 65370, + 65370 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 65371, + 65371 + ], + "disallowed_STD3_mapped", + [ + 123 + ] + ], + [ + [ + 65372, + 65372 + ], + "disallowed_STD3_mapped", + [ + 124 + ] + ], + [ + [ + 65373, + 65373 + ], + "disallowed_STD3_mapped", + [ + 125 + ] + ], + [ + [ + 65374, + 65374 + ], + "disallowed_STD3_mapped", + [ + 126 + ] + ], + [ + [ + 65375, + 65375 + ], + "mapped", + [ + 10629 + ] + ], + [ + [ + 65376, + 65376 + ], + "mapped", + [ + 10630 + ] + ], + [ + [ + 65377, + 65377 + ], + "mapped", + [ + 46 + ] + ], + [ + [ + 65378, + 65378 + ], + "mapped", + [ + 12300 + ] + ], + [ + [ + 65379, + 65379 + ], + "mapped", + [ + 12301 + ] + ], + [ + [ + 65380, + 65380 + ], + "mapped", + [ + 12289 + ] + ], + [ + [ + 65381, + 65381 + ], + "mapped", + [ + 12539 + ] + ], + [ + [ + 65382, + 65382 + ], + "mapped", + [ + 12530 + ] + ], + [ + [ + 65383, + 65383 + ], + "mapped", + [ + 12449 + ] + ], + [ + [ + 65384, + 65384 + ], + "mapped", + [ + 12451 + ] + ], + [ + [ + 65385, + 65385 + ], + "mapped", + [ + 12453 + ] + ], + [ + [ + 65386, + 65386 + ], + "mapped", + [ + 12455 + ] + ], + [ + [ + 65387, + 65387 + ], + "mapped", + [ + 12457 + ] + ], + [ + [ + 65388, + 65388 + ], + "mapped", + [ + 12515 + ] + ], + [ + [ + 65389, + 65389 + ], + "mapped", + [ + 12517 + ] + ], + [ + [ + 65390, + 65390 + ], + "mapped", + [ + 12519 + ] + ], + [ + [ + 65391, + 65391 + ], + "mapped", + [ + 12483 + ] + ], + [ + [ + 65392, + 65392 + ], + "mapped", + [ + 12540 + ] + ], + [ + [ + 65393, + 65393 + ], + "mapped", + [ + 12450 + ] + ], + [ + [ + 65394, + 65394 + ], + "mapped", + [ + 12452 + ] + ], + [ + [ + 65395, + 65395 + ], + "mapped", + [ + 12454 + ] + ], + [ + [ + 65396, + 65396 + ], + "mapped", + [ + 12456 + ] + ], + [ + [ + 65397, + 65397 + ], + "mapped", + [ + 12458 + ] + ], + [ + [ + 65398, + 65398 + ], + "mapped", + [ + 12459 + ] + ], + [ + [ + 65399, + 65399 + ], + "mapped", + [ + 12461 + ] + ], + [ + [ + 65400, + 65400 + ], + "mapped", + [ + 12463 + ] + ], + [ + [ + 65401, + 65401 + ], + "mapped", + [ + 12465 + ] + ], + [ + [ + 65402, + 65402 + ], + "mapped", + [ + 12467 + ] + ], + [ + [ + 65403, + 65403 + ], + "mapped", + [ + 12469 + ] + ], + [ + [ + 65404, + 65404 + ], + "mapped", + [ + 12471 + ] + ], + [ + [ + 65405, + 65405 + ], + "mapped", + [ + 12473 + ] + ], + [ + [ + 65406, + 65406 + ], + "mapped", + [ + 12475 + ] + ], + [ + [ + 65407, + 65407 + ], + "mapped", + [ + 12477 + ] + ], + [ + [ + 65408, + 65408 + ], + "mapped", + [ + 12479 + ] + ], + [ + [ + 65409, + 65409 + ], + "mapped", + [ + 12481 + ] + ], + [ + [ + 65410, + 65410 + ], + "mapped", + [ + 12484 + ] + ], + [ + [ + 65411, + 65411 + ], + "mapped", + [ + 12486 + ] + ], + [ + [ + 65412, + 65412 + ], + "mapped", + [ + 12488 + ] + ], + [ + [ + 65413, + 65413 + ], + "mapped", + [ + 12490 + ] + ], + [ + [ + 65414, + 65414 + ], + "mapped", + [ + 12491 + ] + ], + [ + [ + 65415, + 65415 + ], + "mapped", + [ + 12492 + ] + ], + [ + [ + 65416, + 65416 + ], + "mapped", + [ + 12493 + ] + ], + [ + [ + 65417, + 65417 + ], + "mapped", + [ + 12494 + ] + ], + [ + [ + 65418, + 65418 + ], + "mapped", + [ + 12495 + ] + ], + [ + [ + 65419, + 65419 + ], + "mapped", + [ + 12498 + ] + ], + [ + [ + 65420, + 65420 + ], + "mapped", + [ + 12501 + ] + ], + [ + [ + 65421, + 65421 + ], + "mapped", + [ + 12504 + ] + ], + [ + [ + 65422, + 65422 + ], + "mapped", + [ + 12507 + ] + ], + [ + [ + 65423, + 65423 + ], + "mapped", + [ + 12510 + ] + ], + [ + [ + 65424, + 65424 + ], + "mapped", + [ + 12511 + ] + ], + [ + [ + 65425, + 65425 + ], + "mapped", + [ + 12512 + ] + ], + [ + [ + 65426, + 65426 + ], + "mapped", + [ + 12513 + ] + ], + [ + [ + 65427, + 65427 + ], + "mapped", + [ + 12514 + ] + ], + [ + [ + 65428, + 65428 + ], + "mapped", + [ + 12516 + ] + ], + [ + [ + 65429, + 65429 + ], + "mapped", + [ + 12518 + ] + ], + [ + [ + 65430, + 65430 + ], + "mapped", + [ + 12520 + ] + ], + [ + [ + 65431, + 65431 + ], + "mapped", + [ + 12521 + ] + ], + [ + [ + 65432, + 65432 + ], + "mapped", + [ + 12522 + ] + ], + [ + [ + 65433, + 65433 + ], + "mapped", + [ + 12523 + ] + ], + [ + [ + 65434, + 65434 + ], + "mapped", + [ + 12524 + ] + ], + [ + [ + 65435, + 65435 + ], + "mapped", + [ + 12525 + ] + ], + [ + [ + 65436, + 65436 + ], + "mapped", + [ + 12527 + ] + ], + [ + [ + 65437, + 65437 + ], + "mapped", + [ + 12531 + ] + ], + [ + [ + 65438, + 65438 + ], + "mapped", + [ + 12441 + ] + ], + [ + [ + 65439, + 65439 + ], + "mapped", + [ + 12442 + ] + ], + [ + [ + 65440, + 65440 + ], + "disallowed" + ], + [ + [ + 65441, + 65441 + ], + "mapped", + [ + 4352 + ] + ], + [ + [ + 65442, + 65442 + ], + "mapped", + [ + 4353 + ] + ], + [ + [ + 65443, + 65443 + ], + "mapped", + [ + 4522 + ] + ], + [ + [ + 65444, + 65444 + ], + "mapped", + [ + 4354 + ] + ], + [ + [ + 65445, + 65445 + ], + "mapped", + [ + 4524 + ] + ], + [ + [ + 65446, + 65446 + ], + "mapped", + [ + 4525 + ] + ], + [ + [ + 65447, + 65447 + ], + "mapped", + [ + 4355 + ] + ], + [ + [ + 65448, + 65448 + ], + "mapped", + [ + 4356 + ] + ], + [ + [ + 65449, + 65449 + ], + "mapped", + [ + 4357 + ] + ], + [ + [ + 65450, + 65450 + ], + "mapped", + [ + 4528 + ] + ], + [ + [ + 65451, + 65451 + ], + "mapped", + [ + 4529 + ] + ], + [ + [ + 65452, + 65452 + ], + "mapped", + [ + 4530 + ] + ], + [ + [ + 65453, + 65453 + ], + "mapped", + [ + 4531 + ] + ], + [ + [ + 65454, + 65454 + ], + "mapped", + [ + 4532 + ] + ], + [ + [ + 65455, + 65455 + ], + "mapped", + [ + 4533 + ] + ], + [ + [ + 65456, + 65456 + ], + "mapped", + [ + 4378 + ] + ], + [ + [ + 65457, + 65457 + ], + "mapped", + [ + 4358 + ] + ], + [ + [ + 65458, + 65458 + ], + "mapped", + [ + 4359 + ] + ], + [ + [ + 65459, + 65459 + ], + "mapped", + [ + 4360 + ] + ], + [ + [ + 65460, + 65460 + ], + "mapped", + [ + 4385 + ] + ], + [ + [ + 65461, + 65461 + ], + "mapped", + [ + 4361 + ] + ], + [ + [ + 65462, + 65462 + ], + "mapped", + [ + 4362 + ] + ], + [ + [ + 65463, + 65463 + ], + "mapped", + [ + 4363 + ] + ], + [ + [ + 65464, + 65464 + ], + "mapped", + [ + 4364 + ] + ], + [ + [ + 65465, + 65465 + ], + "mapped", + [ + 4365 + ] + ], + [ + [ + 65466, + 65466 + ], + "mapped", + [ + 4366 + ] + ], + [ + [ + 65467, + 65467 + ], + "mapped", + [ + 4367 + ] + ], + [ + [ + 65468, + 65468 + ], + "mapped", + [ + 4368 + ] + ], + [ + [ + 65469, + 65469 + ], + "mapped", + [ + 4369 + ] + ], + [ + [ + 65470, + 65470 + ], + "mapped", + [ + 4370 + ] + ], + [ + [ + 65471, + 65473 + ], + "disallowed" + ], + [ + [ + 65474, + 65474 + ], + "mapped", + [ + 4449 + ] + ], + [ + [ + 65475, + 65475 + ], + "mapped", + [ + 4450 + ] + ], + [ + [ + 65476, + 65476 + ], + "mapped", + [ + 4451 + ] + ], + [ + [ + 65477, + 65477 + ], + "mapped", + [ + 4452 + ] + ], + [ + [ + 65478, + 65478 + ], + "mapped", + [ + 4453 + ] + ], + [ + [ + 65479, + 65479 + ], + "mapped", + [ + 4454 + ] + ], + [ + [ + 65480, + 65481 + ], + "disallowed" + ], + [ + [ + 65482, + 65482 + ], + "mapped", + [ + 4455 + ] + ], + [ + [ + 65483, + 65483 + ], + "mapped", + [ + 4456 + ] + ], + [ + [ + 65484, + 65484 + ], + "mapped", + [ + 4457 + ] + ], + [ + [ + 65485, + 65485 + ], + "mapped", + [ + 4458 + ] + ], + [ + [ + 65486, + 65486 + ], + "mapped", + [ + 4459 + ] + ], + [ + [ + 65487, + 65487 + ], + "mapped", + [ + 4460 + ] + ], + [ + [ + 65488, + 65489 + ], + "disallowed" + ], + [ + [ + 65490, + 65490 + ], + "mapped", + [ + 4461 + ] + ], + [ + [ + 65491, + 65491 + ], + "mapped", + [ + 4462 + ] + ], + [ + [ + 65492, + 65492 + ], + "mapped", + [ + 4463 + ] + ], + [ + [ + 65493, + 65493 + ], + "mapped", + [ + 4464 + ] + ], + [ + [ + 65494, + 65494 + ], + "mapped", + [ + 4465 + ] + ], + [ + [ + 65495, + 65495 + ], + "mapped", + [ + 4466 + ] + ], + [ + [ + 65496, + 65497 + ], + "disallowed" + ], + [ + [ + 65498, + 65498 + ], + "mapped", + [ + 4467 + ] + ], + [ + [ + 65499, + 65499 + ], + "mapped", + [ + 4468 + ] + ], + [ + [ + 65500, + 65500 + ], + "mapped", + [ + 4469 + ] + ], + [ + [ + 65501, + 65503 + ], + "disallowed" + ], + [ + [ + 65504, + 65504 + ], + "mapped", + [ + 162 + ] + ], + [ + [ + 65505, + 65505 + ], + "mapped", + [ + 163 + ] + ], + [ + [ + 65506, + 65506 + ], + "mapped", + [ + 172 + ] + ], + [ + [ + 65507, + 65507 + ], + "disallowed_STD3_mapped", + [ + 32, + 772 + ] + ], + [ + [ + 65508, + 65508 + ], + "mapped", + [ + 166 + ] + ], + [ + [ + 65509, + 65509 + ], + "mapped", + [ + 165 + ] + ], + [ + [ + 65510, + 65510 + ], + "mapped", + [ + 8361 + ] + ], + [ + [ + 65511, + 65511 + ], + "disallowed" + ], + [ + [ + 65512, + 65512 + ], + "mapped", + [ + 9474 + ] + ], + [ + [ + 65513, + 65513 + ], + "mapped", + [ + 8592 + ] + ], + [ + [ + 65514, + 65514 + ], + "mapped", + [ + 8593 + ] + ], + [ + [ + 65515, + 65515 + ], + "mapped", + [ + 8594 + ] + ], + [ + [ + 65516, + 65516 + ], + "mapped", + [ + 8595 + ] + ], + [ + [ + 65517, + 65517 + ], + "mapped", + [ + 9632 + ] + ], + [ + [ + 65518, + 65518 + ], + "mapped", + [ + 9675 + ] + ], + [ + [ + 65519, + 65528 + ], + "disallowed" + ], + [ + [ + 65529, + 65531 + ], + "disallowed" + ], + [ + [ + 65532, + 65532 + ], + "disallowed" + ], + [ + [ + 65533, + 65533 + ], + "disallowed" + ], + [ + [ + 65534, + 65535 + ], + "disallowed" + ], + [ + [ + 65536, + 65547 + ], + "valid" + ], + [ + [ + 65548, + 65548 + ], + "disallowed" + ], + [ + [ + 65549, + 65574 + ], + "valid" + ], + [ + [ + 65575, + 65575 + ], + "disallowed" + ], + [ + [ + 65576, + 65594 + ], + "valid" + ], + [ + [ + 65595, + 65595 + ], + "disallowed" + ], + [ + [ + 65596, + 65597 + ], + "valid" + ], + [ + [ + 65598, + 65598 + ], + "disallowed" + ], + [ + [ + 65599, + 65613 + ], + "valid" + ], + [ + [ + 65614, + 65615 + ], + "disallowed" + ], + [ + [ + 65616, + 65629 + ], + "valid" + ], + [ + [ + 65630, + 65663 + ], + "disallowed" + ], + [ + [ + 65664, + 65786 + ], + "valid" + ], + [ + [ + 65787, + 65791 + ], + "disallowed" + ], + [ + [ + 65792, + 65794 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 65795, + 65798 + ], + "disallowed" + ], + [ + [ + 65799, + 65843 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 65844, + 65846 + ], + "disallowed" + ], + [ + [ + 65847, + 65855 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 65856, + 65930 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 65931, + 65932 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 65933, + 65935 + ], + "disallowed" + ], + [ + [ + 65936, + 65947 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 65948, + 65951 + ], + "disallowed" + ], + [ + [ + 65952, + 65952 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 65953, + 65999 + ], + "disallowed" + ], + [ + [ + 66000, + 66044 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 66045, + 66045 + ], + "valid" + ], + [ + [ + 66046, + 66175 + ], + "disallowed" + ], + [ + [ + 66176, + 66204 + ], + "valid" + ], + [ + [ + 66205, + 66207 + ], + "disallowed" + ], + [ + [ + 66208, + 66256 + ], + "valid" + ], + [ + [ + 66257, + 66271 + ], + "disallowed" + ], + [ + [ + 66272, + 66272 + ], + "valid" + ], + [ + [ + 66273, + 66299 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 66300, + 66303 + ], + "disallowed" + ], + [ + [ + 66304, + 66334 + ], + "valid" + ], + [ + [ + 66335, + 66335 + ], + "valid" + ], + [ + [ + 66336, + 66339 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 66340, + 66351 + ], + "disallowed" + ], + [ + [ + 66352, + 66368 + ], + "valid" + ], + [ + [ + 66369, + 66369 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 66370, + 66377 + ], + "valid" + ], + [ + [ + 66378, + 66378 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 66379, + 66383 + ], + "disallowed" + ], + [ + [ + 66384, + 66426 + ], + "valid" + ], + [ + [ + 66427, + 66431 + ], + "disallowed" + ], + [ + [ + 66432, + 66461 + ], + "valid" + ], + [ + [ + 66462, + 66462 + ], + "disallowed" + ], + [ + [ + 66463, + 66463 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 66464, + 66499 + ], + "valid" + ], + [ + [ + 66500, + 66503 + ], + "disallowed" + ], + [ + [ + 66504, + 66511 + ], + "valid" + ], + [ + [ + 66512, + 66517 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 66518, + 66559 + ], + "disallowed" + ], + [ + [ + 66560, + 66560 + ], + "mapped", + [ + 66600 + ] + ], + [ + [ + 66561, + 66561 + ], + "mapped", + [ + 66601 + ] + ], + [ + [ + 66562, + 66562 + ], + "mapped", + [ + 66602 + ] + ], + [ + [ + 66563, + 66563 + ], + "mapped", + [ + 66603 + ] + ], + [ + [ + 66564, + 66564 + ], + "mapped", + [ + 66604 + ] + ], + [ + [ + 66565, + 66565 + ], + "mapped", + [ + 66605 + ] + ], + [ + [ + 66566, + 66566 + ], + "mapped", + [ + 66606 + ] + ], + [ + [ + 66567, + 66567 + ], + "mapped", + [ + 66607 + ] + ], + [ + [ + 66568, + 66568 + ], + "mapped", + [ + 66608 + ] + ], + [ + [ + 66569, + 66569 + ], + "mapped", + [ + 66609 + ] + ], + [ + [ + 66570, + 66570 + ], + "mapped", + [ + 66610 + ] + ], + [ + [ + 66571, + 66571 + ], + "mapped", + [ + 66611 + ] + ], + [ + [ + 66572, + 66572 + ], + "mapped", + [ + 66612 + ] + ], + [ + [ + 66573, + 66573 + ], + "mapped", + [ + 66613 + ] + ], + [ + [ + 66574, + 66574 + ], + "mapped", + [ + 66614 + ] + ], + [ + [ + 66575, + 66575 + ], + "mapped", + [ + 66615 + ] + ], + [ + [ + 66576, + 66576 + ], + "mapped", + [ + 66616 + ] + ], + [ + [ + 66577, + 66577 + ], + "mapped", + [ + 66617 + ] + ], + [ + [ + 66578, + 66578 + ], + "mapped", + [ + 66618 + ] + ], + [ + [ + 66579, + 66579 + ], + "mapped", + [ + 66619 + ] + ], + [ + [ + 66580, + 66580 + ], + "mapped", + [ + 66620 + ] + ], + [ + [ + 66581, + 66581 + ], + "mapped", + [ + 66621 + ] + ], + [ + [ + 66582, + 66582 + ], + "mapped", + [ + 66622 + ] + ], + [ + [ + 66583, + 66583 + ], + "mapped", + [ + 66623 + ] + ], + [ + [ + 66584, + 66584 + ], + "mapped", + [ + 66624 + ] + ], + [ + [ + 66585, + 66585 + ], + "mapped", + [ + 66625 + ] + ], + [ + [ + 66586, + 66586 + ], + "mapped", + [ + 66626 + ] + ], + [ + [ + 66587, + 66587 + ], + "mapped", + [ + 66627 + ] + ], + [ + [ + 66588, + 66588 + ], + "mapped", + [ + 66628 + ] + ], + [ + [ + 66589, + 66589 + ], + "mapped", + [ + 66629 + ] + ], + [ + [ + 66590, + 66590 + ], + "mapped", + [ + 66630 + ] + ], + [ + [ + 66591, + 66591 + ], + "mapped", + [ + 66631 + ] + ], + [ + [ + 66592, + 66592 + ], + "mapped", + [ + 66632 + ] + ], + [ + [ + 66593, + 66593 + ], + "mapped", + [ + 66633 + ] + ], + [ + [ + 66594, + 66594 + ], + "mapped", + [ + 66634 + ] + ], + [ + [ + 66595, + 66595 + ], + "mapped", + [ + 66635 + ] + ], + [ + [ + 66596, + 66596 + ], + "mapped", + [ + 66636 + ] + ], + [ + [ + 66597, + 66597 + ], + "mapped", + [ + 66637 + ] + ], + [ + [ + 66598, + 66598 + ], + "mapped", + [ + 66638 + ] + ], + [ + [ + 66599, + 66599 + ], + "mapped", + [ + 66639 + ] + ], + [ + [ + 66600, + 66637 + ], + "valid" + ], + [ + [ + 66638, + 66717 + ], + "valid" + ], + [ + [ + 66718, + 66719 + ], + "disallowed" + ], + [ + [ + 66720, + 66729 + ], + "valid" + ], + [ + [ + 66730, + 66815 + ], + "disallowed" + ], + [ + [ + 66816, + 66855 + ], + "valid" + ], + [ + [ + 66856, + 66863 + ], + "disallowed" + ], + [ + [ + 66864, + 66915 + ], + "valid" + ], + [ + [ + 66916, + 66926 + ], + "disallowed" + ], + [ + [ + 66927, + 66927 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 66928, + 67071 + ], + "disallowed" + ], + [ + [ + 67072, + 67382 + ], + "valid" + ], + [ + [ + 67383, + 67391 + ], + "disallowed" + ], + [ + [ + 67392, + 67413 + ], + "valid" + ], + [ + [ + 67414, + 67423 + ], + "disallowed" + ], + [ + [ + 67424, + 67431 + ], + "valid" + ], + [ + [ + 67432, + 67583 + ], + "disallowed" + ], + [ + [ + 67584, + 67589 + ], + "valid" + ], + [ + [ + 67590, + 67591 + ], + "disallowed" + ], + [ + [ + 67592, + 67592 + ], + "valid" + ], + [ + [ + 67593, + 67593 + ], + "disallowed" + ], + [ + [ + 67594, + 67637 + ], + "valid" + ], + [ + [ + 67638, + 67638 + ], + "disallowed" + ], + [ + [ + 67639, + 67640 + ], + "valid" + ], + [ + [ + 67641, + 67643 + ], + "disallowed" + ], + [ + [ + 67644, + 67644 + ], + "valid" + ], + [ + [ + 67645, + 67646 + ], + "disallowed" + ], + [ + [ + 67647, + 67647 + ], + "valid" + ], + [ + [ + 67648, + 67669 + ], + "valid" + ], + [ + [ + 67670, + 67670 + ], + "disallowed" + ], + [ + [ + 67671, + 67679 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 67680, + 67702 + ], + "valid" + ], + [ + [ + 67703, + 67711 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 67712, + 67742 + ], + "valid" + ], + [ + [ + 67743, + 67750 + ], + "disallowed" + ], + [ + [ + 67751, + 67759 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 67760, + 67807 + ], + "disallowed" + ], + [ + [ + 67808, + 67826 + ], + "valid" + ], + [ + [ + 67827, + 67827 + ], + "disallowed" + ], + [ + [ + 67828, + 67829 + ], + "valid" + ], + [ + [ + 67830, + 67834 + ], + "disallowed" + ], + [ + [ + 67835, + 67839 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 67840, + 67861 + ], + "valid" + ], + [ + [ + 67862, + 67865 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 67866, + 67867 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 67868, + 67870 + ], + "disallowed" + ], + [ + [ + 67871, + 67871 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 67872, + 67897 + ], + "valid" + ], + [ + [ + 67898, + 67902 + ], + "disallowed" + ], + [ + [ + 67903, + 67903 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 67904, + 67967 + ], + "disallowed" + ], + [ + [ + 67968, + 68023 + ], + "valid" + ], + [ + [ + 68024, + 68027 + ], + "disallowed" + ], + [ + [ + 68028, + 68029 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 68030, + 68031 + ], + "valid" + ], + [ + [ + 68032, + 68047 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 68048, + 68049 + ], + "disallowed" + ], + [ + [ + 68050, + 68095 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 68096, + 68099 + ], + "valid" + ], + [ + [ + 68100, + 68100 + ], + "disallowed" + ], + [ + [ + 68101, + 68102 + ], + "valid" + ], + [ + [ + 68103, + 68107 + ], + "disallowed" + ], + [ + [ + 68108, + 68115 + ], + "valid" + ], + [ + [ + 68116, + 68116 + ], + "disallowed" + ], + [ + [ + 68117, + 68119 + ], + "valid" + ], + [ + [ + 68120, + 68120 + ], + "disallowed" + ], + [ + [ + 68121, + 68147 + ], + "valid" + ], + [ + [ + 68148, + 68151 + ], + "disallowed" + ], + [ + [ + 68152, + 68154 + ], + "valid" + ], + [ + [ + 68155, + 68158 + ], + "disallowed" + ], + [ + [ + 68159, + 68159 + ], + "valid" + ], + [ + [ + 68160, + 68167 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 68168, + 68175 + ], + "disallowed" + ], + [ + [ + 68176, + 68184 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 68185, + 68191 + ], + "disallowed" + ], + [ + [ + 68192, + 68220 + ], + "valid" + ], + [ + [ + 68221, + 68223 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 68224, + 68252 + ], + "valid" + ], + [ + [ + 68253, + 68255 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 68256, + 68287 + ], + "disallowed" + ], + [ + [ + 68288, + 68295 + ], + "valid" + ], + [ + [ + 68296, + 68296 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 68297, + 68326 + ], + "valid" + ], + [ + [ + 68327, + 68330 + ], + "disallowed" + ], + [ + [ + 68331, + 68342 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 68343, + 68351 + ], + "disallowed" + ], + [ + [ + 68352, + 68405 + ], + "valid" + ], + [ + [ + 68406, + 68408 + ], + "disallowed" + ], + [ + [ + 68409, + 68415 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 68416, + 68437 + ], + "valid" + ], + [ + [ + 68438, + 68439 + ], + "disallowed" + ], + [ + [ + 68440, + 68447 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 68448, + 68466 + ], + "valid" + ], + [ + [ + 68467, + 68471 + ], + "disallowed" + ], + [ + [ + 68472, + 68479 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 68480, + 68497 + ], + "valid" + ], + [ + [ + 68498, + 68504 + ], + "disallowed" + ], + [ + [ + 68505, + 68508 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 68509, + 68520 + ], + "disallowed" + ], + [ + [ + 68521, + 68527 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 68528, + 68607 + ], + "disallowed" + ], + [ + [ + 68608, + 68680 + ], + "valid" + ], + [ + [ + 68681, + 68735 + ], + "disallowed" + ], + [ + [ + 68736, + 68736 + ], + "mapped", + [ + 68800 + ] + ], + [ + [ + 68737, + 68737 + ], + "mapped", + [ + 68801 + ] + ], + [ + [ + 68738, + 68738 + ], + "mapped", + [ + 68802 + ] + ], + [ + [ + 68739, + 68739 + ], + "mapped", + [ + 68803 + ] + ], + [ + [ + 68740, + 68740 + ], + "mapped", + [ + 68804 + ] + ], + [ + [ + 68741, + 68741 + ], + "mapped", + [ + 68805 + ] + ], + [ + [ + 68742, + 68742 + ], + "mapped", + [ + 68806 + ] + ], + [ + [ + 68743, + 68743 + ], + "mapped", + [ + 68807 + ] + ], + [ + [ + 68744, + 68744 + ], + "mapped", + [ + 68808 + ] + ], + [ + [ + 68745, + 68745 + ], + "mapped", + [ + 68809 + ] + ], + [ + [ + 68746, + 68746 + ], + "mapped", + [ + 68810 + ] + ], + [ + [ + 68747, + 68747 + ], + "mapped", + [ + 68811 + ] + ], + [ + [ + 68748, + 68748 + ], + "mapped", + [ + 68812 + ] + ], + [ + [ + 68749, + 68749 + ], + "mapped", + [ + 68813 + ] + ], + [ + [ + 68750, + 68750 + ], + "mapped", + [ + 68814 + ] + ], + [ + [ + 68751, + 68751 + ], + "mapped", + [ + 68815 + ] + ], + [ + [ + 68752, + 68752 + ], + "mapped", + [ + 68816 + ] + ], + [ + [ + 68753, + 68753 + ], + "mapped", + [ + 68817 + ] + ], + [ + [ + 68754, + 68754 + ], + "mapped", + [ + 68818 + ] + ], + [ + [ + 68755, + 68755 + ], + "mapped", + [ + 68819 + ] + ], + [ + [ + 68756, + 68756 + ], + "mapped", + [ + 68820 + ] + ], + [ + [ + 68757, + 68757 + ], + "mapped", + [ + 68821 + ] + ], + [ + [ + 68758, + 68758 + ], + "mapped", + [ + 68822 + ] + ], + [ + [ + 68759, + 68759 + ], + "mapped", + [ + 68823 + ] + ], + [ + [ + 68760, + 68760 + ], + "mapped", + [ + 68824 + ] + ], + [ + [ + 68761, + 68761 + ], + "mapped", + [ + 68825 + ] + ], + [ + [ + 68762, + 68762 + ], + "mapped", + [ + 68826 + ] + ], + [ + [ + 68763, + 68763 + ], + "mapped", + [ + 68827 + ] + ], + [ + [ + 68764, + 68764 + ], + "mapped", + [ + 68828 + ] + ], + [ + [ + 68765, + 68765 + ], + "mapped", + [ + 68829 + ] + ], + [ + [ + 68766, + 68766 + ], + "mapped", + [ + 68830 + ] + ], + [ + [ + 68767, + 68767 + ], + "mapped", + [ + 68831 + ] + ], + [ + [ + 68768, + 68768 + ], + "mapped", + [ + 68832 + ] + ], + [ + [ + 68769, + 68769 + ], + "mapped", + [ + 68833 + ] + ], + [ + [ + 68770, + 68770 + ], + "mapped", + [ + 68834 + ] + ], + [ + [ + 68771, + 68771 + ], + "mapped", + [ + 68835 + ] + ], + [ + [ + 68772, + 68772 + ], + "mapped", + [ + 68836 + ] + ], + [ + [ + 68773, + 68773 + ], + "mapped", + [ + 68837 + ] + ], + [ + [ + 68774, + 68774 + ], + "mapped", + [ + 68838 + ] + ], + [ + [ + 68775, + 68775 + ], + "mapped", + [ + 68839 + ] + ], + [ + [ + 68776, + 68776 + ], + "mapped", + [ + 68840 + ] + ], + [ + [ + 68777, + 68777 + ], + "mapped", + [ + 68841 + ] + ], + [ + [ + 68778, + 68778 + ], + "mapped", + [ + 68842 + ] + ], + [ + [ + 68779, + 68779 + ], + "mapped", + [ + 68843 + ] + ], + [ + [ + 68780, + 68780 + ], + "mapped", + [ + 68844 + ] + ], + [ + [ + 68781, + 68781 + ], + "mapped", + [ + 68845 + ] + ], + [ + [ + 68782, + 68782 + ], + "mapped", + [ + 68846 + ] + ], + [ + [ + 68783, + 68783 + ], + "mapped", + [ + 68847 + ] + ], + [ + [ + 68784, + 68784 + ], + "mapped", + [ + 68848 + ] + ], + [ + [ + 68785, + 68785 + ], + "mapped", + [ + 68849 + ] + ], + [ + [ + 68786, + 68786 + ], + "mapped", + [ + 68850 + ] + ], + [ + [ + 68787, + 68799 + ], + "disallowed" + ], + [ + [ + 68800, + 68850 + ], + "valid" + ], + [ + [ + 68851, + 68857 + ], + "disallowed" + ], + [ + [ + 68858, + 68863 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 68864, + 69215 + ], + "disallowed" + ], + [ + [ + 69216, + 69246 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 69247, + 69631 + ], + "disallowed" + ], + [ + [ + 69632, + 69702 + ], + "valid" + ], + [ + [ + 69703, + 69709 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 69710, + 69713 + ], + "disallowed" + ], + [ + [ + 69714, + 69733 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 69734, + 69743 + ], + "valid" + ], + [ + [ + 69744, + 69758 + ], + "disallowed" + ], + [ + [ + 69759, + 69759 + ], + "valid" + ], + [ + [ + 69760, + 69818 + ], + "valid" + ], + [ + [ + 69819, + 69820 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 69821, + 69821 + ], + "disallowed" + ], + [ + [ + 69822, + 69825 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 69826, + 69839 + ], + "disallowed" + ], + [ + [ + 69840, + 69864 + ], + "valid" + ], + [ + [ + 69865, + 69871 + ], + "disallowed" + ], + [ + [ + 69872, + 69881 + ], + "valid" + ], + [ + [ + 69882, + 69887 + ], + "disallowed" + ], + [ + [ + 69888, + 69940 + ], + "valid" + ], + [ + [ + 69941, + 69941 + ], + "disallowed" + ], + [ + [ + 69942, + 69951 + ], + "valid" + ], + [ + [ + 69952, + 69955 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 69956, + 69967 + ], + "disallowed" + ], + [ + [ + 69968, + 70003 + ], + "valid" + ], + [ + [ + 70004, + 70005 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 70006, + 70006 + ], + "valid" + ], + [ + [ + 70007, + 70015 + ], + "disallowed" + ], + [ + [ + 70016, + 70084 + ], + "valid" + ], + [ + [ + 70085, + 70088 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 70089, + 70089 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 70090, + 70092 + ], + "valid" + ], + [ + [ + 70093, + 70093 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 70094, + 70095 + ], + "disallowed" + ], + [ + [ + 70096, + 70105 + ], + "valid" + ], + [ + [ + 70106, + 70106 + ], + "valid" + ], + [ + [ + 70107, + 70107 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 70108, + 70108 + ], + "valid" + ], + [ + [ + 70109, + 70111 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 70112, + 70112 + ], + "disallowed" + ], + [ + [ + 70113, + 70132 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 70133, + 70143 + ], + "disallowed" + ], + [ + [ + 70144, + 70161 + ], + "valid" + ], + [ + [ + 70162, + 70162 + ], + "disallowed" + ], + [ + [ + 70163, + 70199 + ], + "valid" + ], + [ + [ + 70200, + 70205 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 70206, + 70271 + ], + "disallowed" + ], + [ + [ + 70272, + 70278 + ], + "valid" + ], + [ + [ + 70279, + 70279 + ], + "disallowed" + ], + [ + [ + 70280, + 70280 + ], + "valid" + ], + [ + [ + 70281, + 70281 + ], + "disallowed" + ], + [ + [ + 70282, + 70285 + ], + "valid" + ], + [ + [ + 70286, + 70286 + ], + "disallowed" + ], + [ + [ + 70287, + 70301 + ], + "valid" + ], + [ + [ + 70302, + 70302 + ], + "disallowed" + ], + [ + [ + 70303, + 70312 + ], + "valid" + ], + [ + [ + 70313, + 70313 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 70314, + 70319 + ], + "disallowed" + ], + [ + [ + 70320, + 70378 + ], + "valid" + ], + [ + [ + 70379, + 70383 + ], + "disallowed" + ], + [ + [ + 70384, + 70393 + ], + "valid" + ], + [ + [ + 70394, + 70399 + ], + "disallowed" + ], + [ + [ + 70400, + 70400 + ], + "valid" + ], + [ + [ + 70401, + 70403 + ], + "valid" + ], + [ + [ + 70404, + 70404 + ], + "disallowed" + ], + [ + [ + 70405, + 70412 + ], + "valid" + ], + [ + [ + 70413, + 70414 + ], + "disallowed" + ], + [ + [ + 70415, + 70416 + ], + "valid" + ], + [ + [ + 70417, + 70418 + ], + "disallowed" + ], + [ + [ + 70419, + 70440 + ], + "valid" + ], + [ + [ + 70441, + 70441 + ], + "disallowed" + ], + [ + [ + 70442, + 70448 + ], + "valid" + ], + [ + [ + 70449, + 70449 + ], + "disallowed" + ], + [ + [ + 70450, + 70451 + ], + "valid" + ], + [ + [ + 70452, + 70452 + ], + "disallowed" + ], + [ + [ + 70453, + 70457 + ], + "valid" + ], + [ + [ + 70458, + 70459 + ], + "disallowed" + ], + [ + [ + 70460, + 70468 + ], + "valid" + ], + [ + [ + 70469, + 70470 + ], + "disallowed" + ], + [ + [ + 70471, + 70472 + ], + "valid" + ], + [ + [ + 70473, + 70474 + ], + "disallowed" + ], + [ + [ + 70475, + 70477 + ], + "valid" + ], + [ + [ + 70478, + 70479 + ], + "disallowed" + ], + [ + [ + 70480, + 70480 + ], + "valid" + ], + [ + [ + 70481, + 70486 + ], + "disallowed" + ], + [ + [ + 70487, + 70487 + ], + "valid" + ], + [ + [ + 70488, + 70492 + ], + "disallowed" + ], + [ + [ + 70493, + 70499 + ], + "valid" + ], + [ + [ + 70500, + 70501 + ], + "disallowed" + ], + [ + [ + 70502, + 70508 + ], + "valid" + ], + [ + [ + 70509, + 70511 + ], + "disallowed" + ], + [ + [ + 70512, + 70516 + ], + "valid" + ], + [ + [ + 70517, + 70783 + ], + "disallowed" + ], + [ + [ + 70784, + 70853 + ], + "valid" + ], + [ + [ + 70854, + 70854 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 70855, + 70855 + ], + "valid" + ], + [ + [ + 70856, + 70863 + ], + "disallowed" + ], + [ + [ + 70864, + 70873 + ], + "valid" + ], + [ + [ + 70874, + 71039 + ], + "disallowed" + ], + [ + [ + 71040, + 71093 + ], + "valid" + ], + [ + [ + 71094, + 71095 + ], + "disallowed" + ], + [ + [ + 71096, + 71104 + ], + "valid" + ], + [ + [ + 71105, + 71113 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 71114, + 71127 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 71128, + 71133 + ], + "valid" + ], + [ + [ + 71134, + 71167 + ], + "disallowed" + ], + [ + [ + 71168, + 71232 + ], + "valid" + ], + [ + [ + 71233, + 71235 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 71236, + 71236 + ], + "valid" + ], + [ + [ + 71237, + 71247 + ], + "disallowed" + ], + [ + [ + 71248, + 71257 + ], + "valid" + ], + [ + [ + 71258, + 71295 + ], + "disallowed" + ], + [ + [ + 71296, + 71351 + ], + "valid" + ], + [ + [ + 71352, + 71359 + ], + "disallowed" + ], + [ + [ + 71360, + 71369 + ], + "valid" + ], + [ + [ + 71370, + 71423 + ], + "disallowed" + ], + [ + [ + 71424, + 71449 + ], + "valid" + ], + [ + [ + 71450, + 71452 + ], + "disallowed" + ], + [ + [ + 71453, + 71467 + ], + "valid" + ], + [ + [ + 71468, + 71471 + ], + "disallowed" + ], + [ + [ + 71472, + 71481 + ], + "valid" + ], + [ + [ + 71482, + 71487 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 71488, + 71839 + ], + "disallowed" + ], + [ + [ + 71840, + 71840 + ], + "mapped", + [ + 71872 + ] + ], + [ + [ + 71841, + 71841 + ], + "mapped", + [ + 71873 + ] + ], + [ + [ + 71842, + 71842 + ], + "mapped", + [ + 71874 + ] + ], + [ + [ + 71843, + 71843 + ], + "mapped", + [ + 71875 + ] + ], + [ + [ + 71844, + 71844 + ], + "mapped", + [ + 71876 + ] + ], + [ + [ + 71845, + 71845 + ], + "mapped", + [ + 71877 + ] + ], + [ + [ + 71846, + 71846 + ], + "mapped", + [ + 71878 + ] + ], + [ + [ + 71847, + 71847 + ], + "mapped", + [ + 71879 + ] + ], + [ + [ + 71848, + 71848 + ], + "mapped", + [ + 71880 + ] + ], + [ + [ + 71849, + 71849 + ], + "mapped", + [ + 71881 + ] + ], + [ + [ + 71850, + 71850 + ], + "mapped", + [ + 71882 + ] + ], + [ + [ + 71851, + 71851 + ], + "mapped", + [ + 71883 + ] + ], + [ + [ + 71852, + 71852 + ], + "mapped", + [ + 71884 + ] + ], + [ + [ + 71853, + 71853 + ], + "mapped", + [ + 71885 + ] + ], + [ + [ + 71854, + 71854 + ], + "mapped", + [ + 71886 + ] + ], + [ + [ + 71855, + 71855 + ], + "mapped", + [ + 71887 + ] + ], + [ + [ + 71856, + 71856 + ], + "mapped", + [ + 71888 + ] + ], + [ + [ + 71857, + 71857 + ], + "mapped", + [ + 71889 + ] + ], + [ + [ + 71858, + 71858 + ], + "mapped", + [ + 71890 + ] + ], + [ + [ + 71859, + 71859 + ], + "mapped", + [ + 71891 + ] + ], + [ + [ + 71860, + 71860 + ], + "mapped", + [ + 71892 + ] + ], + [ + [ + 71861, + 71861 + ], + "mapped", + [ + 71893 + ] + ], + [ + [ + 71862, + 71862 + ], + "mapped", + [ + 71894 + ] + ], + [ + [ + 71863, + 71863 + ], + "mapped", + [ + 71895 + ] + ], + [ + [ + 71864, + 71864 + ], + "mapped", + [ + 71896 + ] + ], + [ + [ + 71865, + 71865 + ], + "mapped", + [ + 71897 + ] + ], + [ + [ + 71866, + 71866 + ], + "mapped", + [ + 71898 + ] + ], + [ + [ + 71867, + 71867 + ], + "mapped", + [ + 71899 + ] + ], + [ + [ + 71868, + 71868 + ], + "mapped", + [ + 71900 + ] + ], + [ + [ + 71869, + 71869 + ], + "mapped", + [ + 71901 + ] + ], + [ + [ + 71870, + 71870 + ], + "mapped", + [ + 71902 + ] + ], + [ + [ + 71871, + 71871 + ], + "mapped", + [ + 71903 + ] + ], + [ + [ + 71872, + 71913 + ], + "valid" + ], + [ + [ + 71914, + 71922 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 71923, + 71934 + ], + "disallowed" + ], + [ + [ + 71935, + 71935 + ], + "valid" + ], + [ + [ + 71936, + 72383 + ], + "disallowed" + ], + [ + [ + 72384, + 72440 + ], + "valid" + ], + [ + [ + 72441, + 73727 + ], + "disallowed" + ], + [ + [ + 73728, + 74606 + ], + "valid" + ], + [ + [ + 74607, + 74648 + ], + "valid" + ], + [ + [ + 74649, + 74649 + ], + "valid" + ], + [ + [ + 74650, + 74751 + ], + "disallowed" + ], + [ + [ + 74752, + 74850 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 74851, + 74862 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 74863, + 74863 + ], + "disallowed" + ], + [ + [ + 74864, + 74867 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 74868, + 74868 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 74869, + 74879 + ], + "disallowed" + ], + [ + [ + 74880, + 75075 + ], + "valid" + ], + [ + [ + 75076, + 77823 + ], + "disallowed" + ], + [ + [ + 77824, + 78894 + ], + "valid" + ], + [ + [ + 78895, + 82943 + ], + "disallowed" + ], + [ + [ + 82944, + 83526 + ], + "valid" + ], + [ + [ + 83527, + 92159 + ], + "disallowed" + ], + [ + [ + 92160, + 92728 + ], + "valid" + ], + [ + [ + 92729, + 92735 + ], + "disallowed" + ], + [ + [ + 92736, + 92766 + ], + "valid" + ], + [ + [ + 92767, + 92767 + ], + "disallowed" + ], + [ + [ + 92768, + 92777 + ], + "valid" + ], + [ + [ + 92778, + 92781 + ], + "disallowed" + ], + [ + [ + 92782, + 92783 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 92784, + 92879 + ], + "disallowed" + ], + [ + [ + 92880, + 92909 + ], + "valid" + ], + [ + [ + 92910, + 92911 + ], + "disallowed" + ], + [ + [ + 92912, + 92916 + ], + "valid" + ], + [ + [ + 92917, + 92917 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 92918, + 92927 + ], + "disallowed" + ], + [ + [ + 92928, + 92982 + ], + "valid" + ], + [ + [ + 92983, + 92991 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 92992, + 92995 + ], + "valid" + ], + [ + [ + 92996, + 92997 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 92998, + 93007 + ], + "disallowed" + ], + [ + [ + 93008, + 93017 + ], + "valid" + ], + [ + [ + 93018, + 93018 + ], + "disallowed" + ], + [ + [ + 93019, + 93025 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 93026, + 93026 + ], + "disallowed" + ], + [ + [ + 93027, + 93047 + ], + "valid" + ], + [ + [ + 93048, + 93052 + ], + "disallowed" + ], + [ + [ + 93053, + 93071 + ], + "valid" + ], + [ + [ + 93072, + 93951 + ], + "disallowed" + ], + [ + [ + 93952, + 94020 + ], + "valid" + ], + [ + [ + 94021, + 94031 + ], + "disallowed" + ], + [ + [ + 94032, + 94078 + ], + "valid" + ], + [ + [ + 94079, + 94094 + ], + "disallowed" + ], + [ + [ + 94095, + 94111 + ], + "valid" + ], + [ + [ + 94112, + 110591 + ], + "disallowed" + ], + [ + [ + 110592, + 110593 + ], + "valid" + ], + [ + [ + 110594, + 113663 + ], + "disallowed" + ], + [ + [ + 113664, + 113770 + ], + "valid" + ], + [ + [ + 113771, + 113775 + ], + "disallowed" + ], + [ + [ + 113776, + 113788 + ], + "valid" + ], + [ + [ + 113789, + 113791 + ], + "disallowed" + ], + [ + [ + 113792, + 113800 + ], + "valid" + ], + [ + [ + 113801, + 113807 + ], + "disallowed" + ], + [ + [ + 113808, + 113817 + ], + "valid" + ], + [ + [ + 113818, + 113819 + ], + "disallowed" + ], + [ + [ + 113820, + 113820 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 113821, + 113822 + ], + "valid" + ], + [ + [ + 113823, + 113823 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 113824, + 113827 + ], + "ignored" + ], + [ + [ + 113828, + 118783 + ], + "disallowed" + ], + [ + [ + 118784, + 119029 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 119030, + 119039 + ], + "disallowed" + ], + [ + [ + 119040, + 119078 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 119079, + 119080 + ], + "disallowed" + ], + [ + [ + 119081, + 119081 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 119082, + 119133 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 119134, + 119134 + ], + "mapped", + [ + 119127, + 119141 + ] + ], + [ + [ + 119135, + 119135 + ], + "mapped", + [ + 119128, + 119141 + ] + ], + [ + [ + 119136, + 119136 + ], + "mapped", + [ + 119128, + 119141, + 119150 + ] + ], + [ + [ + 119137, + 119137 + ], + "mapped", + [ + 119128, + 119141, + 119151 + ] + ], + [ + [ + 119138, + 119138 + ], + "mapped", + [ + 119128, + 119141, + 119152 + ] + ], + [ + [ + 119139, + 119139 + ], + "mapped", + [ + 119128, + 119141, + 119153 + ] + ], + [ + [ + 119140, + 119140 + ], + "mapped", + [ + 119128, + 119141, + 119154 + ] + ], + [ + [ + 119141, + 119154 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 119155, + 119162 + ], + "disallowed" + ], + [ + [ + 119163, + 119226 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 119227, + 119227 + ], + "mapped", + [ + 119225, + 119141 + ] + ], + [ + [ + 119228, + 119228 + ], + "mapped", + [ + 119226, + 119141 + ] + ], + [ + [ + 119229, + 119229 + ], + "mapped", + [ + 119225, + 119141, + 119150 + ] + ], + [ + [ + 119230, + 119230 + ], + "mapped", + [ + 119226, + 119141, + 119150 + ] + ], + [ + [ + 119231, + 119231 + ], + "mapped", + [ + 119225, + 119141, + 119151 + ] + ], + [ + [ + 119232, + 119232 + ], + "mapped", + [ + 119226, + 119141, + 119151 + ] + ], + [ + [ + 119233, + 119261 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 119262, + 119272 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 119273, + 119295 + ], + "disallowed" + ], + [ + [ + 119296, + 119365 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 119366, + 119551 + ], + "disallowed" + ], + [ + [ + 119552, + 119638 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 119639, + 119647 + ], + "disallowed" + ], + [ + [ + 119648, + 119665 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 119666, + 119807 + ], + "disallowed" + ], + [ + [ + 119808, + 119808 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 119809, + 119809 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 119810, + 119810 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 119811, + 119811 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 119812, + 119812 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 119813, + 119813 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 119814, + 119814 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 119815, + 119815 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 119816, + 119816 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 119817, + 119817 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 119818, + 119818 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 119819, + 119819 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 119820, + 119820 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 119821, + 119821 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 119822, + 119822 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 119823, + 119823 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 119824, + 119824 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 119825, + 119825 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 119826, + 119826 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 119827, + 119827 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 119828, + 119828 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 119829, + 119829 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 119830, + 119830 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 119831, + 119831 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 119832, + 119832 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 119833, + 119833 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 119834, + 119834 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 119835, + 119835 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 119836, + 119836 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 119837, + 119837 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 119838, + 119838 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 119839, + 119839 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 119840, + 119840 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 119841, + 119841 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 119842, + 119842 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 119843, + 119843 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 119844, + 119844 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 119845, + 119845 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 119846, + 119846 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 119847, + 119847 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 119848, + 119848 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 119849, + 119849 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 119850, + 119850 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 119851, + 119851 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 119852, + 119852 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 119853, + 119853 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 119854, + 119854 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 119855, + 119855 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 119856, + 119856 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 119857, + 119857 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 119858, + 119858 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 119859, + 119859 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 119860, + 119860 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 119861, + 119861 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 119862, + 119862 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 119863, + 119863 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 119864, + 119864 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 119865, + 119865 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 119866, + 119866 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 119867, + 119867 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 119868, + 119868 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 119869, + 119869 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 119870, + 119870 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 119871, + 119871 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 119872, + 119872 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 119873, + 119873 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 119874, + 119874 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 119875, + 119875 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 119876, + 119876 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 119877, + 119877 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 119878, + 119878 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 119879, + 119879 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 119880, + 119880 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 119881, + 119881 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 119882, + 119882 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 119883, + 119883 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 119884, + 119884 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 119885, + 119885 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 119886, + 119886 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 119887, + 119887 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 119888, + 119888 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 119889, + 119889 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 119890, + 119890 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 119891, + 119891 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 119892, + 119892 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 119893, + 119893 + ], + "disallowed" + ], + [ + [ + 119894, + 119894 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 119895, + 119895 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 119896, + 119896 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 119897, + 119897 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 119898, + 119898 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 119899, + 119899 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 119900, + 119900 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 119901, + 119901 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 119902, + 119902 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 119903, + 119903 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 119904, + 119904 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 119905, + 119905 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 119906, + 119906 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 119907, + 119907 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 119908, + 119908 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 119909, + 119909 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 119910, + 119910 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 119911, + 119911 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 119912, + 119912 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 119913, + 119913 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 119914, + 119914 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 119915, + 119915 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 119916, + 119916 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 119917, + 119917 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 119918, + 119918 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 119919, + 119919 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 119920, + 119920 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 119921, + 119921 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 119922, + 119922 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 119923, + 119923 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 119924, + 119924 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 119925, + 119925 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 119926, + 119926 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 119927, + 119927 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 119928, + 119928 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 119929, + 119929 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 119930, + 119930 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 119931, + 119931 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 119932, + 119932 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 119933, + 119933 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 119934, + 119934 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 119935, + 119935 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 119936, + 119936 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 119937, + 119937 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 119938, + 119938 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 119939, + 119939 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 119940, + 119940 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 119941, + 119941 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 119942, + 119942 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 119943, + 119943 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 119944, + 119944 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 119945, + 119945 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 119946, + 119946 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 119947, + 119947 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 119948, + 119948 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 119949, + 119949 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 119950, + 119950 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 119951, + 119951 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 119952, + 119952 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 119953, + 119953 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 119954, + 119954 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 119955, + 119955 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 119956, + 119956 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 119957, + 119957 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 119958, + 119958 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 119959, + 119959 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 119960, + 119960 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 119961, + 119961 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 119962, + 119962 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 119963, + 119963 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 119964, + 119964 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 119965, + 119965 + ], + "disallowed" + ], + [ + [ + 119966, + 119966 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 119967, + 119967 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 119968, + 119969 + ], + "disallowed" + ], + [ + [ + 119970, + 119970 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 119971, + 119972 + ], + "disallowed" + ], + [ + [ + 119973, + 119973 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 119974, + 119974 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 119975, + 119976 + ], + "disallowed" + ], + [ + [ + 119977, + 119977 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 119978, + 119978 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 119979, + 119979 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 119980, + 119980 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 119981, + 119981 + ], + "disallowed" + ], + [ + [ + 119982, + 119982 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 119983, + 119983 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 119984, + 119984 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 119985, + 119985 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 119986, + 119986 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 119987, + 119987 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 119988, + 119988 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 119989, + 119989 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 119990, + 119990 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 119991, + 119991 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 119992, + 119992 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 119993, + 119993 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 119994, + 119994 + ], + "disallowed" + ], + [ + [ + 119995, + 119995 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 119996, + 119996 + ], + "disallowed" + ], + [ + [ + 119997, + 119997 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 119998, + 119998 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 119999, + 119999 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120000, + 120000 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120001, + 120001 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120002, + 120002 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120003, + 120003 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120004, + 120004 + ], + "disallowed" + ], + [ + [ + 120005, + 120005 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120006, + 120006 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120007, + 120007 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120008, + 120008 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120009, + 120009 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120010, + 120010 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120011, + 120011 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120012, + 120012 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120013, + 120013 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120014, + 120014 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120015, + 120015 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120016, + 120016 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120017, + 120017 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120018, + 120018 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 120019, + 120019 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120020, + 120020 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120021, + 120021 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120022, + 120022 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120023, + 120023 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 120024, + 120024 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120025, + 120025 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120026, + 120026 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120027, + 120027 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120028, + 120028 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120029, + 120029 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120030, + 120030 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120031, + 120031 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120032, + 120032 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120033, + 120033 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120034, + 120034 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120035, + 120035 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120036, + 120036 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120037, + 120037 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120038, + 120038 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120039, + 120039 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120040, + 120040 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120041, + 120041 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120042, + 120042 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120043, + 120043 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120044, + 120044 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 120045, + 120045 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120046, + 120046 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120047, + 120047 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120048, + 120048 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120049, + 120049 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 120050, + 120050 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120051, + 120051 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120052, + 120052 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120053, + 120053 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120054, + 120054 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120055, + 120055 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120056, + 120056 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120057, + 120057 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120058, + 120058 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120059, + 120059 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120060, + 120060 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120061, + 120061 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120062, + 120062 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120063, + 120063 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120064, + 120064 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120065, + 120065 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120066, + 120066 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120067, + 120067 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120068, + 120068 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120069, + 120069 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120070, + 120070 + ], + "disallowed" + ], + [ + [ + 120071, + 120071 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120072, + 120072 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120073, + 120073 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120074, + 120074 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120075, + 120076 + ], + "disallowed" + ], + [ + [ + 120077, + 120077 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120078, + 120078 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120079, + 120079 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120080, + 120080 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120081, + 120081 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120082, + 120082 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120083, + 120083 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120084, + 120084 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120085, + 120085 + ], + "disallowed" + ], + [ + [ + 120086, + 120086 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120087, + 120087 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120088, + 120088 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120089, + 120089 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120090, + 120090 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120091, + 120091 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120092, + 120092 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120093, + 120093 + ], + "disallowed" + ], + [ + [ + 120094, + 120094 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120095, + 120095 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120096, + 120096 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 120097, + 120097 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120098, + 120098 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120099, + 120099 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120100, + 120100 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120101, + 120101 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 120102, + 120102 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120103, + 120103 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120104, + 120104 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120105, + 120105 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120106, + 120106 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120107, + 120107 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120108, + 120108 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120109, + 120109 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120110, + 120110 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120111, + 120111 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120112, + 120112 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120113, + 120113 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120114, + 120114 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120115, + 120115 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120116, + 120116 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120117, + 120117 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120118, + 120118 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120119, + 120119 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120120, + 120120 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120121, + 120121 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120122, + 120122 + ], + "disallowed" + ], + [ + [ + 120123, + 120123 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120124, + 120124 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120125, + 120125 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120126, + 120126 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120127, + 120127 + ], + "disallowed" + ], + [ + [ + 120128, + 120128 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120129, + 120129 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120130, + 120130 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120131, + 120131 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120132, + 120132 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120133, + 120133 + ], + "disallowed" + ], + [ + [ + 120134, + 120134 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120135, + 120137 + ], + "disallowed" + ], + [ + [ + 120138, + 120138 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120139, + 120139 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120140, + 120140 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120141, + 120141 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120142, + 120142 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120143, + 120143 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120144, + 120144 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120145, + 120145 + ], + "disallowed" + ], + [ + [ + 120146, + 120146 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120147, + 120147 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120148, + 120148 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 120149, + 120149 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120150, + 120150 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120151, + 120151 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120152, + 120152 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120153, + 120153 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 120154, + 120154 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120155, + 120155 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120156, + 120156 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120157, + 120157 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120158, + 120158 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120159, + 120159 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120160, + 120160 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120161, + 120161 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120162, + 120162 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120163, + 120163 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120164, + 120164 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120165, + 120165 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120166, + 120166 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120167, + 120167 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120168, + 120168 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120169, + 120169 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120170, + 120170 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120171, + 120171 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120172, + 120172 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120173, + 120173 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120174, + 120174 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 120175, + 120175 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120176, + 120176 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120177, + 120177 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120178, + 120178 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120179, + 120179 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 120180, + 120180 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120181, + 120181 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120182, + 120182 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120183, + 120183 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120184, + 120184 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120185, + 120185 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120186, + 120186 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120187, + 120187 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120188, + 120188 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120189, + 120189 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120190, + 120190 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120191, + 120191 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120192, + 120192 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120193, + 120193 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120194, + 120194 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120195, + 120195 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120196, + 120196 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120197, + 120197 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120198, + 120198 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120199, + 120199 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120200, + 120200 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 120201, + 120201 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120202, + 120202 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120203, + 120203 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120204, + 120204 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120205, + 120205 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 120206, + 120206 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120207, + 120207 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120208, + 120208 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120209, + 120209 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120210, + 120210 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120211, + 120211 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120212, + 120212 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120213, + 120213 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120214, + 120214 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120215, + 120215 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120216, + 120216 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120217, + 120217 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120218, + 120218 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120219, + 120219 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120220, + 120220 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120221, + 120221 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120222, + 120222 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120223, + 120223 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120224, + 120224 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120225, + 120225 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120226, + 120226 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 120227, + 120227 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120228, + 120228 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120229, + 120229 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120230, + 120230 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120231, + 120231 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 120232, + 120232 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120233, + 120233 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120234, + 120234 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120235, + 120235 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120236, + 120236 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120237, + 120237 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120238, + 120238 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120239, + 120239 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120240, + 120240 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120241, + 120241 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120242, + 120242 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120243, + 120243 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120244, + 120244 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120245, + 120245 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120246, + 120246 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120247, + 120247 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120248, + 120248 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120249, + 120249 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120250, + 120250 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120251, + 120251 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120252, + 120252 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 120253, + 120253 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120254, + 120254 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120255, + 120255 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120256, + 120256 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120257, + 120257 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 120258, + 120258 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120259, + 120259 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120260, + 120260 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120261, + 120261 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120262, + 120262 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120263, + 120263 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120264, + 120264 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120265, + 120265 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120266, + 120266 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120267, + 120267 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120268, + 120268 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120269, + 120269 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120270, + 120270 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120271, + 120271 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120272, + 120272 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120273, + 120273 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120274, + 120274 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120275, + 120275 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120276, + 120276 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120277, + 120277 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120278, + 120278 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 120279, + 120279 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120280, + 120280 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120281, + 120281 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120282, + 120282 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120283, + 120283 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 120284, + 120284 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120285, + 120285 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120286, + 120286 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120287, + 120287 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120288, + 120288 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120289, + 120289 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120290, + 120290 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120291, + 120291 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120292, + 120292 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120293, + 120293 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120294, + 120294 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120295, + 120295 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120296, + 120296 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120297, + 120297 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120298, + 120298 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120299, + 120299 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120300, + 120300 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120301, + 120301 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120302, + 120302 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120303, + 120303 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120304, + 120304 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 120305, + 120305 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120306, + 120306 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120307, + 120307 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120308, + 120308 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120309, + 120309 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 120310, + 120310 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120311, + 120311 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120312, + 120312 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120313, + 120313 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120314, + 120314 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120315, + 120315 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120316, + 120316 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120317, + 120317 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120318, + 120318 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120319, + 120319 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120320, + 120320 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120321, + 120321 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120322, + 120322 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120323, + 120323 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120324, + 120324 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120325, + 120325 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120326, + 120326 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120327, + 120327 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120328, + 120328 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120329, + 120329 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120330, + 120330 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 120331, + 120331 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120332, + 120332 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120333, + 120333 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120334, + 120334 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120335, + 120335 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 120336, + 120336 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120337, + 120337 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120338, + 120338 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120339, + 120339 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120340, + 120340 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120341, + 120341 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120342, + 120342 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120343, + 120343 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120344, + 120344 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120345, + 120345 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120346, + 120346 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120347, + 120347 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120348, + 120348 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120349, + 120349 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120350, + 120350 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120351, + 120351 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120352, + 120352 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120353, + 120353 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120354, + 120354 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120355, + 120355 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120356, + 120356 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 120357, + 120357 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120358, + 120358 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120359, + 120359 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120360, + 120360 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120361, + 120361 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 120362, + 120362 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120363, + 120363 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120364, + 120364 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120365, + 120365 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120366, + 120366 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120367, + 120367 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120368, + 120368 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120369, + 120369 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120370, + 120370 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120371, + 120371 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120372, + 120372 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120373, + 120373 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120374, + 120374 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120375, + 120375 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120376, + 120376 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120377, + 120377 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120378, + 120378 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120379, + 120379 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120380, + 120380 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120381, + 120381 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120382, + 120382 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 120383, + 120383 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120384, + 120384 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120385, + 120385 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120386, + 120386 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120387, + 120387 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 120388, + 120388 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120389, + 120389 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120390, + 120390 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120391, + 120391 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120392, + 120392 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120393, + 120393 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120394, + 120394 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120395, + 120395 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120396, + 120396 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120397, + 120397 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120398, + 120398 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120399, + 120399 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120400, + 120400 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120401, + 120401 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120402, + 120402 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120403, + 120403 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120404, + 120404 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120405, + 120405 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120406, + 120406 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120407, + 120407 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120408, + 120408 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 120409, + 120409 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120410, + 120410 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120411, + 120411 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120412, + 120412 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120413, + 120413 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 120414, + 120414 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120415, + 120415 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120416, + 120416 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120417, + 120417 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120418, + 120418 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120419, + 120419 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120420, + 120420 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120421, + 120421 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120422, + 120422 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120423, + 120423 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120424, + 120424 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120425, + 120425 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120426, + 120426 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120427, + 120427 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120428, + 120428 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120429, + 120429 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120430, + 120430 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120431, + 120431 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120432, + 120432 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120433, + 120433 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120434, + 120434 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 120435, + 120435 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120436, + 120436 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120437, + 120437 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120438, + 120438 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120439, + 120439 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 120440, + 120440 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120441, + 120441 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120442, + 120442 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120443, + 120443 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120444, + 120444 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120445, + 120445 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120446, + 120446 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120447, + 120447 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120448, + 120448 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120449, + 120449 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120450, + 120450 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120451, + 120451 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120452, + 120452 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120453, + 120453 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120454, + 120454 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120455, + 120455 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120456, + 120456 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120457, + 120457 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120458, + 120458 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 120459, + 120459 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 120460, + 120460 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 120461, + 120461 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 120462, + 120462 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 120463, + 120463 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 120464, + 120464 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 120465, + 120465 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 120466, + 120466 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 120467, + 120467 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 120468, + 120468 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 120469, + 120469 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 120470, + 120470 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 120471, + 120471 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 120472, + 120472 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 120473, + 120473 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 120474, + 120474 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 120475, + 120475 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 120476, + 120476 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 120477, + 120477 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 120478, + 120478 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 120479, + 120479 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 120480, + 120480 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 120481, + 120481 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 120482, + 120482 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 120483, + 120483 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 120484, + 120484 + ], + "mapped", + [ + 305 + ] + ], + [ + [ + 120485, + 120485 + ], + "mapped", + [ + 567 + ] + ], + [ + [ + 120486, + 120487 + ], + "disallowed" + ], + [ + [ + 120488, + 120488 + ], + "mapped", + [ + 945 + ] + ], + [ + [ + 120489, + 120489 + ], + "mapped", + [ + 946 + ] + ], + [ + [ + 120490, + 120490 + ], + "mapped", + [ + 947 + ] + ], + [ + [ + 120491, + 120491 + ], + "mapped", + [ + 948 + ] + ], + [ + [ + 120492, + 120492 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 120493, + 120493 + ], + "mapped", + [ + 950 + ] + ], + [ + [ + 120494, + 120494 + ], + "mapped", + [ + 951 + ] + ], + [ + [ + 120495, + 120495 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120496, + 120496 + ], + "mapped", + [ + 953 + ] + ], + [ + [ + 120497, + 120497 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 120498, + 120498 + ], + "mapped", + [ + 955 + ] + ], + [ + [ + 120499, + 120499 + ], + "mapped", + [ + 956 + ] + ], + [ + [ + 120500, + 120500 + ], + "mapped", + [ + 957 + ] + ], + [ + [ + 120501, + 120501 + ], + "mapped", + [ + 958 + ] + ], + [ + [ + 120502, + 120502 + ], + "mapped", + [ + 959 + ] + ], + [ + [ + 120503, + 120503 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 120504, + 120504 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 120505, + 120505 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120506, + 120506 + ], + "mapped", + [ + 963 + ] + ], + [ + [ + 120507, + 120507 + ], + "mapped", + [ + 964 + ] + ], + [ + [ + 120508, + 120508 + ], + "mapped", + [ + 965 + ] + ], + [ + [ + 120509, + 120509 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 120510, + 120510 + ], + "mapped", + [ + 967 + ] + ], + [ + [ + 120511, + 120511 + ], + "mapped", + [ + 968 + ] + ], + [ + [ + 120512, + 120512 + ], + "mapped", + [ + 969 + ] + ], + [ + [ + 120513, + 120513 + ], + "mapped", + [ + 8711 + ] + ], + [ + [ + 120514, + 120514 + ], + "mapped", + [ + 945 + ] + ], + [ + [ + 120515, + 120515 + ], + "mapped", + [ + 946 + ] + ], + [ + [ + 120516, + 120516 + ], + "mapped", + [ + 947 + ] + ], + [ + [ + 120517, + 120517 + ], + "mapped", + [ + 948 + ] + ], + [ + [ + 120518, + 120518 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 120519, + 120519 + ], + "mapped", + [ + 950 + ] + ], + [ + [ + 120520, + 120520 + ], + "mapped", + [ + 951 + ] + ], + [ + [ + 120521, + 120521 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120522, + 120522 + ], + "mapped", + [ + 953 + ] + ], + [ + [ + 120523, + 120523 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 120524, + 120524 + ], + "mapped", + [ + 955 + ] + ], + [ + [ + 120525, + 120525 + ], + "mapped", + [ + 956 + ] + ], + [ + [ + 120526, + 120526 + ], + "mapped", + [ + 957 + ] + ], + [ + [ + 120527, + 120527 + ], + "mapped", + [ + 958 + ] + ], + [ + [ + 120528, + 120528 + ], + "mapped", + [ + 959 + ] + ], + [ + [ + 120529, + 120529 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 120530, + 120530 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 120531, + 120532 + ], + "mapped", + [ + 963 + ] + ], + [ + [ + 120533, + 120533 + ], + "mapped", + [ + 964 + ] + ], + [ + [ + 120534, + 120534 + ], + "mapped", + [ + 965 + ] + ], + [ + [ + 120535, + 120535 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 120536, + 120536 + ], + "mapped", + [ + 967 + ] + ], + [ + [ + 120537, + 120537 + ], + "mapped", + [ + 968 + ] + ], + [ + [ + 120538, + 120538 + ], + "mapped", + [ + 969 + ] + ], + [ + [ + 120539, + 120539 + ], + "mapped", + [ + 8706 + ] + ], + [ + [ + 120540, + 120540 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 120541, + 120541 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120542, + 120542 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 120543, + 120543 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 120544, + 120544 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 120545, + 120545 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 120546, + 120546 + ], + "mapped", + [ + 945 + ] + ], + [ + [ + 120547, + 120547 + ], + "mapped", + [ + 946 + ] + ], + [ + [ + 120548, + 120548 + ], + "mapped", + [ + 947 + ] + ], + [ + [ + 120549, + 120549 + ], + "mapped", + [ + 948 + ] + ], + [ + [ + 120550, + 120550 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 120551, + 120551 + ], + "mapped", + [ + 950 + ] + ], + [ + [ + 120552, + 120552 + ], + "mapped", + [ + 951 + ] + ], + [ + [ + 120553, + 120553 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120554, + 120554 + ], + "mapped", + [ + 953 + ] + ], + [ + [ + 120555, + 120555 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 120556, + 120556 + ], + "mapped", + [ + 955 + ] + ], + [ + [ + 120557, + 120557 + ], + "mapped", + [ + 956 + ] + ], + [ + [ + 120558, + 120558 + ], + "mapped", + [ + 957 + ] + ], + [ + [ + 120559, + 120559 + ], + "mapped", + [ + 958 + ] + ], + [ + [ + 120560, + 120560 + ], + "mapped", + [ + 959 + ] + ], + [ + [ + 120561, + 120561 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 120562, + 120562 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 120563, + 120563 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120564, + 120564 + ], + "mapped", + [ + 963 + ] + ], + [ + [ + 120565, + 120565 + ], + "mapped", + [ + 964 + ] + ], + [ + [ + 120566, + 120566 + ], + "mapped", + [ + 965 + ] + ], + [ + [ + 120567, + 120567 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 120568, + 120568 + ], + "mapped", + [ + 967 + ] + ], + [ + [ + 120569, + 120569 + ], + "mapped", + [ + 968 + ] + ], + [ + [ + 120570, + 120570 + ], + "mapped", + [ + 969 + ] + ], + [ + [ + 120571, + 120571 + ], + "mapped", + [ + 8711 + ] + ], + [ + [ + 120572, + 120572 + ], + "mapped", + [ + 945 + ] + ], + [ + [ + 120573, + 120573 + ], + "mapped", + [ + 946 + ] + ], + [ + [ + 120574, + 120574 + ], + "mapped", + [ + 947 + ] + ], + [ + [ + 120575, + 120575 + ], + "mapped", + [ + 948 + ] + ], + [ + [ + 120576, + 120576 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 120577, + 120577 + ], + "mapped", + [ + 950 + ] + ], + [ + [ + 120578, + 120578 + ], + "mapped", + [ + 951 + ] + ], + [ + [ + 120579, + 120579 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120580, + 120580 + ], + "mapped", + [ + 953 + ] + ], + [ + [ + 120581, + 120581 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 120582, + 120582 + ], + "mapped", + [ + 955 + ] + ], + [ + [ + 120583, + 120583 + ], + "mapped", + [ + 956 + ] + ], + [ + [ + 120584, + 120584 + ], + "mapped", + [ + 957 + ] + ], + [ + [ + 120585, + 120585 + ], + "mapped", + [ + 958 + ] + ], + [ + [ + 120586, + 120586 + ], + "mapped", + [ + 959 + ] + ], + [ + [ + 120587, + 120587 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 120588, + 120588 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 120589, + 120590 + ], + "mapped", + [ + 963 + ] + ], + [ + [ + 120591, + 120591 + ], + "mapped", + [ + 964 + ] + ], + [ + [ + 120592, + 120592 + ], + "mapped", + [ + 965 + ] + ], + [ + [ + 120593, + 120593 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 120594, + 120594 + ], + "mapped", + [ + 967 + ] + ], + [ + [ + 120595, + 120595 + ], + "mapped", + [ + 968 + ] + ], + [ + [ + 120596, + 120596 + ], + "mapped", + [ + 969 + ] + ], + [ + [ + 120597, + 120597 + ], + "mapped", + [ + 8706 + ] + ], + [ + [ + 120598, + 120598 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 120599, + 120599 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120600, + 120600 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 120601, + 120601 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 120602, + 120602 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 120603, + 120603 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 120604, + 120604 + ], + "mapped", + [ + 945 + ] + ], + [ + [ + 120605, + 120605 + ], + "mapped", + [ + 946 + ] + ], + [ + [ + 120606, + 120606 + ], + "mapped", + [ + 947 + ] + ], + [ + [ + 120607, + 120607 + ], + "mapped", + [ + 948 + ] + ], + [ + [ + 120608, + 120608 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 120609, + 120609 + ], + "mapped", + [ + 950 + ] + ], + [ + [ + 120610, + 120610 + ], + "mapped", + [ + 951 + ] + ], + [ + [ + 120611, + 120611 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120612, + 120612 + ], + "mapped", + [ + 953 + ] + ], + [ + [ + 120613, + 120613 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 120614, + 120614 + ], + "mapped", + [ + 955 + ] + ], + [ + [ + 120615, + 120615 + ], + "mapped", + [ + 956 + ] + ], + [ + [ + 120616, + 120616 + ], + "mapped", + [ + 957 + ] + ], + [ + [ + 120617, + 120617 + ], + "mapped", + [ + 958 + ] + ], + [ + [ + 120618, + 120618 + ], + "mapped", + [ + 959 + ] + ], + [ + [ + 120619, + 120619 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 120620, + 120620 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 120621, + 120621 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120622, + 120622 + ], + "mapped", + [ + 963 + ] + ], + [ + [ + 120623, + 120623 + ], + "mapped", + [ + 964 + ] + ], + [ + [ + 120624, + 120624 + ], + "mapped", + [ + 965 + ] + ], + [ + [ + 120625, + 120625 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 120626, + 120626 + ], + "mapped", + [ + 967 + ] + ], + [ + [ + 120627, + 120627 + ], + "mapped", + [ + 968 + ] + ], + [ + [ + 120628, + 120628 + ], + "mapped", + [ + 969 + ] + ], + [ + [ + 120629, + 120629 + ], + "mapped", + [ + 8711 + ] + ], + [ + [ + 120630, + 120630 + ], + "mapped", + [ + 945 + ] + ], + [ + [ + 120631, + 120631 + ], + "mapped", + [ + 946 + ] + ], + [ + [ + 120632, + 120632 + ], + "mapped", + [ + 947 + ] + ], + [ + [ + 120633, + 120633 + ], + "mapped", + [ + 948 + ] + ], + [ + [ + 120634, + 120634 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 120635, + 120635 + ], + "mapped", + [ + 950 + ] + ], + [ + [ + 120636, + 120636 + ], + "mapped", + [ + 951 + ] + ], + [ + [ + 120637, + 120637 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120638, + 120638 + ], + "mapped", + [ + 953 + ] + ], + [ + [ + 120639, + 120639 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 120640, + 120640 + ], + "mapped", + [ + 955 + ] + ], + [ + [ + 120641, + 120641 + ], + "mapped", + [ + 956 + ] + ], + [ + [ + 120642, + 120642 + ], + "mapped", + [ + 957 + ] + ], + [ + [ + 120643, + 120643 + ], + "mapped", + [ + 958 + ] + ], + [ + [ + 120644, + 120644 + ], + "mapped", + [ + 959 + ] + ], + [ + [ + 120645, + 120645 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 120646, + 120646 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 120647, + 120648 + ], + "mapped", + [ + 963 + ] + ], + [ + [ + 120649, + 120649 + ], + "mapped", + [ + 964 + ] + ], + [ + [ + 120650, + 120650 + ], + "mapped", + [ + 965 + ] + ], + [ + [ + 120651, + 120651 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 120652, + 120652 + ], + "mapped", + [ + 967 + ] + ], + [ + [ + 120653, + 120653 + ], + "mapped", + [ + 968 + ] + ], + [ + [ + 120654, + 120654 + ], + "mapped", + [ + 969 + ] + ], + [ + [ + 120655, + 120655 + ], + "mapped", + [ + 8706 + ] + ], + [ + [ + 120656, + 120656 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 120657, + 120657 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120658, + 120658 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 120659, + 120659 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 120660, + 120660 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 120661, + 120661 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 120662, + 120662 + ], + "mapped", + [ + 945 + ] + ], + [ + [ + 120663, + 120663 + ], + "mapped", + [ + 946 + ] + ], + [ + [ + 120664, + 120664 + ], + "mapped", + [ + 947 + ] + ], + [ + [ + 120665, + 120665 + ], + "mapped", + [ + 948 + ] + ], + [ + [ + 120666, + 120666 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 120667, + 120667 + ], + "mapped", + [ + 950 + ] + ], + [ + [ + 120668, + 120668 + ], + "mapped", + [ + 951 + ] + ], + [ + [ + 120669, + 120669 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120670, + 120670 + ], + "mapped", + [ + 953 + ] + ], + [ + [ + 120671, + 120671 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 120672, + 120672 + ], + "mapped", + [ + 955 + ] + ], + [ + [ + 120673, + 120673 + ], + "mapped", + [ + 956 + ] + ], + [ + [ + 120674, + 120674 + ], + "mapped", + [ + 957 + ] + ], + [ + [ + 120675, + 120675 + ], + "mapped", + [ + 958 + ] + ], + [ + [ + 120676, + 120676 + ], + "mapped", + [ + 959 + ] + ], + [ + [ + 120677, + 120677 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 120678, + 120678 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 120679, + 120679 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120680, + 120680 + ], + "mapped", + [ + 963 + ] + ], + [ + [ + 120681, + 120681 + ], + "mapped", + [ + 964 + ] + ], + [ + [ + 120682, + 120682 + ], + "mapped", + [ + 965 + ] + ], + [ + [ + 120683, + 120683 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 120684, + 120684 + ], + "mapped", + [ + 967 + ] + ], + [ + [ + 120685, + 120685 + ], + "mapped", + [ + 968 + ] + ], + [ + [ + 120686, + 120686 + ], + "mapped", + [ + 969 + ] + ], + [ + [ + 120687, + 120687 + ], + "mapped", + [ + 8711 + ] + ], + [ + [ + 120688, + 120688 + ], + "mapped", + [ + 945 + ] + ], + [ + [ + 120689, + 120689 + ], + "mapped", + [ + 946 + ] + ], + [ + [ + 120690, + 120690 + ], + "mapped", + [ + 947 + ] + ], + [ + [ + 120691, + 120691 + ], + "mapped", + [ + 948 + ] + ], + [ + [ + 120692, + 120692 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 120693, + 120693 + ], + "mapped", + [ + 950 + ] + ], + [ + [ + 120694, + 120694 + ], + "mapped", + [ + 951 + ] + ], + [ + [ + 120695, + 120695 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120696, + 120696 + ], + "mapped", + [ + 953 + ] + ], + [ + [ + 120697, + 120697 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 120698, + 120698 + ], + "mapped", + [ + 955 + ] + ], + [ + [ + 120699, + 120699 + ], + "mapped", + [ + 956 + ] + ], + [ + [ + 120700, + 120700 + ], + "mapped", + [ + 957 + ] + ], + [ + [ + 120701, + 120701 + ], + "mapped", + [ + 958 + ] + ], + [ + [ + 120702, + 120702 + ], + "mapped", + [ + 959 + ] + ], + [ + [ + 120703, + 120703 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 120704, + 120704 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 120705, + 120706 + ], + "mapped", + [ + 963 + ] + ], + [ + [ + 120707, + 120707 + ], + "mapped", + [ + 964 + ] + ], + [ + [ + 120708, + 120708 + ], + "mapped", + [ + 965 + ] + ], + [ + [ + 120709, + 120709 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 120710, + 120710 + ], + "mapped", + [ + 967 + ] + ], + [ + [ + 120711, + 120711 + ], + "mapped", + [ + 968 + ] + ], + [ + [ + 120712, + 120712 + ], + "mapped", + [ + 969 + ] + ], + [ + [ + 120713, + 120713 + ], + "mapped", + [ + 8706 + ] + ], + [ + [ + 120714, + 120714 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 120715, + 120715 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120716, + 120716 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 120717, + 120717 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 120718, + 120718 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 120719, + 120719 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 120720, + 120720 + ], + "mapped", + [ + 945 + ] + ], + [ + [ + 120721, + 120721 + ], + "mapped", + [ + 946 + ] + ], + [ + [ + 120722, + 120722 + ], + "mapped", + [ + 947 + ] + ], + [ + [ + 120723, + 120723 + ], + "mapped", + [ + 948 + ] + ], + [ + [ + 120724, + 120724 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 120725, + 120725 + ], + "mapped", + [ + 950 + ] + ], + [ + [ + 120726, + 120726 + ], + "mapped", + [ + 951 + ] + ], + [ + [ + 120727, + 120727 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120728, + 120728 + ], + "mapped", + [ + 953 + ] + ], + [ + [ + 120729, + 120729 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 120730, + 120730 + ], + "mapped", + [ + 955 + ] + ], + [ + [ + 120731, + 120731 + ], + "mapped", + [ + 956 + ] + ], + [ + [ + 120732, + 120732 + ], + "mapped", + [ + 957 + ] + ], + [ + [ + 120733, + 120733 + ], + "mapped", + [ + 958 + ] + ], + [ + [ + 120734, + 120734 + ], + "mapped", + [ + 959 + ] + ], + [ + [ + 120735, + 120735 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 120736, + 120736 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 120737, + 120737 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120738, + 120738 + ], + "mapped", + [ + 963 + ] + ], + [ + [ + 120739, + 120739 + ], + "mapped", + [ + 964 + ] + ], + [ + [ + 120740, + 120740 + ], + "mapped", + [ + 965 + ] + ], + [ + [ + 120741, + 120741 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 120742, + 120742 + ], + "mapped", + [ + 967 + ] + ], + [ + [ + 120743, + 120743 + ], + "mapped", + [ + 968 + ] + ], + [ + [ + 120744, + 120744 + ], + "mapped", + [ + 969 + ] + ], + [ + [ + 120745, + 120745 + ], + "mapped", + [ + 8711 + ] + ], + [ + [ + 120746, + 120746 + ], + "mapped", + [ + 945 + ] + ], + [ + [ + 120747, + 120747 + ], + "mapped", + [ + 946 + ] + ], + [ + [ + 120748, + 120748 + ], + "mapped", + [ + 947 + ] + ], + [ + [ + 120749, + 120749 + ], + "mapped", + [ + 948 + ] + ], + [ + [ + 120750, + 120750 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 120751, + 120751 + ], + "mapped", + [ + 950 + ] + ], + [ + [ + 120752, + 120752 + ], + "mapped", + [ + 951 + ] + ], + [ + [ + 120753, + 120753 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120754, + 120754 + ], + "mapped", + [ + 953 + ] + ], + [ + [ + 120755, + 120755 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 120756, + 120756 + ], + "mapped", + [ + 955 + ] + ], + [ + [ + 120757, + 120757 + ], + "mapped", + [ + 956 + ] + ], + [ + [ + 120758, + 120758 + ], + "mapped", + [ + 957 + ] + ], + [ + [ + 120759, + 120759 + ], + "mapped", + [ + 958 + ] + ], + [ + [ + 120760, + 120760 + ], + "mapped", + [ + 959 + ] + ], + [ + [ + 120761, + 120761 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 120762, + 120762 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 120763, + 120764 + ], + "mapped", + [ + 963 + ] + ], + [ + [ + 120765, + 120765 + ], + "mapped", + [ + 964 + ] + ], + [ + [ + 120766, + 120766 + ], + "mapped", + [ + 965 + ] + ], + [ + [ + 120767, + 120767 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 120768, + 120768 + ], + "mapped", + [ + 967 + ] + ], + [ + [ + 120769, + 120769 + ], + "mapped", + [ + 968 + ] + ], + [ + [ + 120770, + 120770 + ], + "mapped", + [ + 969 + ] + ], + [ + [ + 120771, + 120771 + ], + "mapped", + [ + 8706 + ] + ], + [ + [ + 120772, + 120772 + ], + "mapped", + [ + 949 + ] + ], + [ + [ + 120773, + 120773 + ], + "mapped", + [ + 952 + ] + ], + [ + [ + 120774, + 120774 + ], + "mapped", + [ + 954 + ] + ], + [ + [ + 120775, + 120775 + ], + "mapped", + [ + 966 + ] + ], + [ + [ + 120776, + 120776 + ], + "mapped", + [ + 961 + ] + ], + [ + [ + 120777, + 120777 + ], + "mapped", + [ + 960 + ] + ], + [ + [ + 120778, + 120779 + ], + "mapped", + [ + 989 + ] + ], + [ + [ + 120780, + 120781 + ], + "disallowed" + ], + [ + [ + 120782, + 120782 + ], + "mapped", + [ + 48 + ] + ], + [ + [ + 120783, + 120783 + ], + "mapped", + [ + 49 + ] + ], + [ + [ + 120784, + 120784 + ], + "mapped", + [ + 50 + ] + ], + [ + [ + 120785, + 120785 + ], + "mapped", + [ + 51 + ] + ], + [ + [ + 120786, + 120786 + ], + "mapped", + [ + 52 + ] + ], + [ + [ + 120787, + 120787 + ], + "mapped", + [ + 53 + ] + ], + [ + [ + 120788, + 120788 + ], + "mapped", + [ + 54 + ] + ], + [ + [ + 120789, + 120789 + ], + "mapped", + [ + 55 + ] + ], + [ + [ + 120790, + 120790 + ], + "mapped", + [ + 56 + ] + ], + [ + [ + 120791, + 120791 + ], + "mapped", + [ + 57 + ] + ], + [ + [ + 120792, + 120792 + ], + "mapped", + [ + 48 + ] + ], + [ + [ + 120793, + 120793 + ], + "mapped", + [ + 49 + ] + ], + [ + [ + 120794, + 120794 + ], + "mapped", + [ + 50 + ] + ], + [ + [ + 120795, + 120795 + ], + "mapped", + [ + 51 + ] + ], + [ + [ + 120796, + 120796 + ], + "mapped", + [ + 52 + ] + ], + [ + [ + 120797, + 120797 + ], + "mapped", + [ + 53 + ] + ], + [ + [ + 120798, + 120798 + ], + "mapped", + [ + 54 + ] + ], + [ + [ + 120799, + 120799 + ], + "mapped", + [ + 55 + ] + ], + [ + [ + 120800, + 120800 + ], + "mapped", + [ + 56 + ] + ], + [ + [ + 120801, + 120801 + ], + "mapped", + [ + 57 + ] + ], + [ + [ + 120802, + 120802 + ], + "mapped", + [ + 48 + ] + ], + [ + [ + 120803, + 120803 + ], + "mapped", + [ + 49 + ] + ], + [ + [ + 120804, + 120804 + ], + "mapped", + [ + 50 + ] + ], + [ + [ + 120805, + 120805 + ], + "mapped", + [ + 51 + ] + ], + [ + [ + 120806, + 120806 + ], + "mapped", + [ + 52 + ] + ], + [ + [ + 120807, + 120807 + ], + "mapped", + [ + 53 + ] + ], + [ + [ + 120808, + 120808 + ], + "mapped", + [ + 54 + ] + ], + [ + [ + 120809, + 120809 + ], + "mapped", + [ + 55 + ] + ], + [ + [ + 120810, + 120810 + ], + "mapped", + [ + 56 + ] + ], + [ + [ + 120811, + 120811 + ], + "mapped", + [ + 57 + ] + ], + [ + [ + 120812, + 120812 + ], + "mapped", + [ + 48 + ] + ], + [ + [ + 120813, + 120813 + ], + "mapped", + [ + 49 + ] + ], + [ + [ + 120814, + 120814 + ], + "mapped", + [ + 50 + ] + ], + [ + [ + 120815, + 120815 + ], + "mapped", + [ + 51 + ] + ], + [ + [ + 120816, + 120816 + ], + "mapped", + [ + 52 + ] + ], + [ + [ + 120817, + 120817 + ], + "mapped", + [ + 53 + ] + ], + [ + [ + 120818, + 120818 + ], + "mapped", + [ + 54 + ] + ], + [ + [ + 120819, + 120819 + ], + "mapped", + [ + 55 + ] + ], + [ + [ + 120820, + 120820 + ], + "mapped", + [ + 56 + ] + ], + [ + [ + 120821, + 120821 + ], + "mapped", + [ + 57 + ] + ], + [ + [ + 120822, + 120822 + ], + "mapped", + [ + 48 + ] + ], + [ + [ + 120823, + 120823 + ], + "mapped", + [ + 49 + ] + ], + [ + [ + 120824, + 120824 + ], + "mapped", + [ + 50 + ] + ], + [ + [ + 120825, + 120825 + ], + "mapped", + [ + 51 + ] + ], + [ + [ + 120826, + 120826 + ], + "mapped", + [ + 52 + ] + ], + [ + [ + 120827, + 120827 + ], + "mapped", + [ + 53 + ] + ], + [ + [ + 120828, + 120828 + ], + "mapped", + [ + 54 + ] + ], + [ + [ + 120829, + 120829 + ], + "mapped", + [ + 55 + ] + ], + [ + [ + 120830, + 120830 + ], + "mapped", + [ + 56 + ] + ], + [ + [ + 120831, + 120831 + ], + "mapped", + [ + 57 + ] + ], + [ + [ + 120832, + 121343 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 121344, + 121398 + ], + "valid" + ], + [ + [ + 121399, + 121402 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 121403, + 121452 + ], + "valid" + ], + [ + [ + 121453, + 121460 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 121461, + 121461 + ], + "valid" + ], + [ + [ + 121462, + 121475 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 121476, + 121476 + ], + "valid" + ], + [ + [ + 121477, + 121483 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 121484, + 121498 + ], + "disallowed" + ], + [ + [ + 121499, + 121503 + ], + "valid" + ], + [ + [ + 121504, + 121504 + ], + "disallowed" + ], + [ + [ + 121505, + 121519 + ], + "valid" + ], + [ + [ + 121520, + 124927 + ], + "disallowed" + ], + [ + [ + 124928, + 125124 + ], + "valid" + ], + [ + [ + 125125, + 125126 + ], + "disallowed" + ], + [ + [ + 125127, + 125135 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 125136, + 125142 + ], + "valid" + ], + [ + [ + 125143, + 126463 + ], + "disallowed" + ], + [ + [ + 126464, + 126464 + ], + "mapped", + [ + 1575 + ] + ], + [ + [ + 126465, + 126465 + ], + "mapped", + [ + 1576 + ] + ], + [ + [ + 126466, + 126466 + ], + "mapped", + [ + 1580 + ] + ], + [ + [ + 126467, + 126467 + ], + "mapped", + [ + 1583 + ] + ], + [ + [ + 126468, + 126468 + ], + "disallowed" + ], + [ + [ + 126469, + 126469 + ], + "mapped", + [ + 1608 + ] + ], + [ + [ + 126470, + 126470 + ], + "mapped", + [ + 1586 + ] + ], + [ + [ + 126471, + 126471 + ], + "mapped", + [ + 1581 + ] + ], + [ + [ + 126472, + 126472 + ], + "mapped", + [ + 1591 + ] + ], + [ + [ + 126473, + 126473 + ], + "mapped", + [ + 1610 + ] + ], + [ + [ + 126474, + 126474 + ], + "mapped", + [ + 1603 + ] + ], + [ + [ + 126475, + 126475 + ], + "mapped", + [ + 1604 + ] + ], + [ + [ + 126476, + 126476 + ], + "mapped", + [ + 1605 + ] + ], + [ + [ + 126477, + 126477 + ], + "mapped", + [ + 1606 + ] + ], + [ + [ + 126478, + 126478 + ], + "mapped", + [ + 1587 + ] + ], + [ + [ + 126479, + 126479 + ], + "mapped", + [ + 1593 + ] + ], + [ + [ + 126480, + 126480 + ], + "mapped", + [ + 1601 + ] + ], + [ + [ + 126481, + 126481 + ], + "mapped", + [ + 1589 + ] + ], + [ + [ + 126482, + 126482 + ], + "mapped", + [ + 1602 + ] + ], + [ + [ + 126483, + 126483 + ], + "mapped", + [ + 1585 + ] + ], + [ + [ + 126484, + 126484 + ], + "mapped", + [ + 1588 + ] + ], + [ + [ + 126485, + 126485 + ], + "mapped", + [ + 1578 + ] + ], + [ + [ + 126486, + 126486 + ], + "mapped", + [ + 1579 + ] + ], + [ + [ + 126487, + 126487 + ], + "mapped", + [ + 1582 + ] + ], + [ + [ + 126488, + 126488 + ], + "mapped", + [ + 1584 + ] + ], + [ + [ + 126489, + 126489 + ], + "mapped", + [ + 1590 + ] + ], + [ + [ + 126490, + 126490 + ], + "mapped", + [ + 1592 + ] + ], + [ + [ + 126491, + 126491 + ], + "mapped", + [ + 1594 + ] + ], + [ + [ + 126492, + 126492 + ], + "mapped", + [ + 1646 + ] + ], + [ + [ + 126493, + 126493 + ], + "mapped", + [ + 1722 + ] + ], + [ + [ + 126494, + 126494 + ], + "mapped", + [ + 1697 + ] + ], + [ + [ + 126495, + 126495 + ], + "mapped", + [ + 1647 + ] + ], + [ + [ + 126496, + 126496 + ], + "disallowed" + ], + [ + [ + 126497, + 126497 + ], + "mapped", + [ + 1576 + ] + ], + [ + [ + 126498, + 126498 + ], + "mapped", + [ + 1580 + ] + ], + [ + [ + 126499, + 126499 + ], + "disallowed" + ], + [ + [ + 126500, + 126500 + ], + "mapped", + [ + 1607 + ] + ], + [ + [ + 126501, + 126502 + ], + "disallowed" + ], + [ + [ + 126503, + 126503 + ], + "mapped", + [ + 1581 + ] + ], + [ + [ + 126504, + 126504 + ], + "disallowed" + ], + [ + [ + 126505, + 126505 + ], + "mapped", + [ + 1610 + ] + ], + [ + [ + 126506, + 126506 + ], + "mapped", + [ + 1603 + ] + ], + [ + [ + 126507, + 126507 + ], + "mapped", + [ + 1604 + ] + ], + [ + [ + 126508, + 126508 + ], + "mapped", + [ + 1605 + ] + ], + [ + [ + 126509, + 126509 + ], + "mapped", + [ + 1606 + ] + ], + [ + [ + 126510, + 126510 + ], + "mapped", + [ + 1587 + ] + ], + [ + [ + 126511, + 126511 + ], + "mapped", + [ + 1593 + ] + ], + [ + [ + 126512, + 126512 + ], + "mapped", + [ + 1601 + ] + ], + [ + [ + 126513, + 126513 + ], + "mapped", + [ + 1589 + ] + ], + [ + [ + 126514, + 126514 + ], + "mapped", + [ + 1602 + ] + ], + [ + [ + 126515, + 126515 + ], + "disallowed" + ], + [ + [ + 126516, + 126516 + ], + "mapped", + [ + 1588 + ] + ], + [ + [ + 126517, + 126517 + ], + "mapped", + [ + 1578 + ] + ], + [ + [ + 126518, + 126518 + ], + "mapped", + [ + 1579 + ] + ], + [ + [ + 126519, + 126519 + ], + "mapped", + [ + 1582 + ] + ], + [ + [ + 126520, + 126520 + ], + "disallowed" + ], + [ + [ + 126521, + 126521 + ], + "mapped", + [ + 1590 + ] + ], + [ + [ + 126522, + 126522 + ], + "disallowed" + ], + [ + [ + 126523, + 126523 + ], + "mapped", + [ + 1594 + ] + ], + [ + [ + 126524, + 126529 + ], + "disallowed" + ], + [ + [ + 126530, + 126530 + ], + "mapped", + [ + 1580 + ] + ], + [ + [ + 126531, + 126534 + ], + "disallowed" + ], + [ + [ + 126535, + 126535 + ], + "mapped", + [ + 1581 + ] + ], + [ + [ + 126536, + 126536 + ], + "disallowed" + ], + [ + [ + 126537, + 126537 + ], + "mapped", + [ + 1610 + ] + ], + [ + [ + 126538, + 126538 + ], + "disallowed" + ], + [ + [ + 126539, + 126539 + ], + "mapped", + [ + 1604 + ] + ], + [ + [ + 126540, + 126540 + ], + "disallowed" + ], + [ + [ + 126541, + 126541 + ], + "mapped", + [ + 1606 + ] + ], + [ + [ + 126542, + 126542 + ], + "mapped", + [ + 1587 + ] + ], + [ + [ + 126543, + 126543 + ], + "mapped", + [ + 1593 + ] + ], + [ + [ + 126544, + 126544 + ], + "disallowed" + ], + [ + [ + 126545, + 126545 + ], + "mapped", + [ + 1589 + ] + ], + [ + [ + 126546, + 126546 + ], + "mapped", + [ + 1602 + ] + ], + [ + [ + 126547, + 126547 + ], + "disallowed" + ], + [ + [ + 126548, + 126548 + ], + "mapped", + [ + 1588 + ] + ], + [ + [ + 126549, + 126550 + ], + "disallowed" + ], + [ + [ + 126551, + 126551 + ], + "mapped", + [ + 1582 + ] + ], + [ + [ + 126552, + 126552 + ], + "disallowed" + ], + [ + [ + 126553, + 126553 + ], + "mapped", + [ + 1590 + ] + ], + [ + [ + 126554, + 126554 + ], + "disallowed" + ], + [ + [ + 126555, + 126555 + ], + "mapped", + [ + 1594 + ] + ], + [ + [ + 126556, + 126556 + ], + "disallowed" + ], + [ + [ + 126557, + 126557 + ], + "mapped", + [ + 1722 + ] + ], + [ + [ + 126558, + 126558 + ], + "disallowed" + ], + [ + [ + 126559, + 126559 + ], + "mapped", + [ + 1647 + ] + ], + [ + [ + 126560, + 126560 + ], + "disallowed" + ], + [ + [ + 126561, + 126561 + ], + "mapped", + [ + 1576 + ] + ], + [ + [ + 126562, + 126562 + ], + "mapped", + [ + 1580 + ] + ], + [ + [ + 126563, + 126563 + ], + "disallowed" + ], + [ + [ + 126564, + 126564 + ], + "mapped", + [ + 1607 + ] + ], + [ + [ + 126565, + 126566 + ], + "disallowed" + ], + [ + [ + 126567, + 126567 + ], + "mapped", + [ + 1581 + ] + ], + [ + [ + 126568, + 126568 + ], + "mapped", + [ + 1591 + ] + ], + [ + [ + 126569, + 126569 + ], + "mapped", + [ + 1610 + ] + ], + [ + [ + 126570, + 126570 + ], + "mapped", + [ + 1603 + ] + ], + [ + [ + 126571, + 126571 + ], + "disallowed" + ], + [ + [ + 126572, + 126572 + ], + "mapped", + [ + 1605 + ] + ], + [ + [ + 126573, + 126573 + ], + "mapped", + [ + 1606 + ] + ], + [ + [ + 126574, + 126574 + ], + "mapped", + [ + 1587 + ] + ], + [ + [ + 126575, + 126575 + ], + "mapped", + [ + 1593 + ] + ], + [ + [ + 126576, + 126576 + ], + "mapped", + [ + 1601 + ] + ], + [ + [ + 126577, + 126577 + ], + "mapped", + [ + 1589 + ] + ], + [ + [ + 126578, + 126578 + ], + "mapped", + [ + 1602 + ] + ], + [ + [ + 126579, + 126579 + ], + "disallowed" + ], + [ + [ + 126580, + 126580 + ], + "mapped", + [ + 1588 + ] + ], + [ + [ + 126581, + 126581 + ], + "mapped", + [ + 1578 + ] + ], + [ + [ + 126582, + 126582 + ], + "mapped", + [ + 1579 + ] + ], + [ + [ + 126583, + 126583 + ], + "mapped", + [ + 1582 + ] + ], + [ + [ + 126584, + 126584 + ], + "disallowed" + ], + [ + [ + 126585, + 126585 + ], + "mapped", + [ + 1590 + ] + ], + [ + [ + 126586, + 126586 + ], + "mapped", + [ + 1592 + ] + ], + [ + [ + 126587, + 126587 + ], + "mapped", + [ + 1594 + ] + ], + [ + [ + 126588, + 126588 + ], + "mapped", + [ + 1646 + ] + ], + [ + [ + 126589, + 126589 + ], + "disallowed" + ], + [ + [ + 126590, + 126590 + ], + "mapped", + [ + 1697 + ] + ], + [ + [ + 126591, + 126591 + ], + "disallowed" + ], + [ + [ + 126592, + 126592 + ], + "mapped", + [ + 1575 + ] + ], + [ + [ + 126593, + 126593 + ], + "mapped", + [ + 1576 + ] + ], + [ + [ + 126594, + 126594 + ], + "mapped", + [ + 1580 + ] + ], + [ + [ + 126595, + 126595 + ], + "mapped", + [ + 1583 + ] + ], + [ + [ + 126596, + 126596 + ], + "mapped", + [ + 1607 + ] + ], + [ + [ + 126597, + 126597 + ], + "mapped", + [ + 1608 + ] + ], + [ + [ + 126598, + 126598 + ], + "mapped", + [ + 1586 + ] + ], + [ + [ + 126599, + 126599 + ], + "mapped", + [ + 1581 + ] + ], + [ + [ + 126600, + 126600 + ], + "mapped", + [ + 1591 + ] + ], + [ + [ + 126601, + 126601 + ], + "mapped", + [ + 1610 + ] + ], + [ + [ + 126602, + 126602 + ], + "disallowed" + ], + [ + [ + 126603, + 126603 + ], + "mapped", + [ + 1604 + ] + ], + [ + [ + 126604, + 126604 + ], + "mapped", + [ + 1605 + ] + ], + [ + [ + 126605, + 126605 + ], + "mapped", + [ + 1606 + ] + ], + [ + [ + 126606, + 126606 + ], + "mapped", + [ + 1587 + ] + ], + [ + [ + 126607, + 126607 + ], + "mapped", + [ + 1593 + ] + ], + [ + [ + 126608, + 126608 + ], + "mapped", + [ + 1601 + ] + ], + [ + [ + 126609, + 126609 + ], + "mapped", + [ + 1589 + ] + ], + [ + [ + 126610, + 126610 + ], + "mapped", + [ + 1602 + ] + ], + [ + [ + 126611, + 126611 + ], + "mapped", + [ + 1585 + ] + ], + [ + [ + 126612, + 126612 + ], + "mapped", + [ + 1588 + ] + ], + [ + [ + 126613, + 126613 + ], + "mapped", + [ + 1578 + ] + ], + [ + [ + 126614, + 126614 + ], + "mapped", + [ + 1579 + ] + ], + [ + [ + 126615, + 126615 + ], + "mapped", + [ + 1582 + ] + ], + [ + [ + 126616, + 126616 + ], + "mapped", + [ + 1584 + ] + ], + [ + [ + 126617, + 126617 + ], + "mapped", + [ + 1590 + ] + ], + [ + [ + 126618, + 126618 + ], + "mapped", + [ + 1592 + ] + ], + [ + [ + 126619, + 126619 + ], + "mapped", + [ + 1594 + ] + ], + [ + [ + 126620, + 126624 + ], + "disallowed" + ], + [ + [ + 126625, + 126625 + ], + "mapped", + [ + 1576 + ] + ], + [ + [ + 126626, + 126626 + ], + "mapped", + [ + 1580 + ] + ], + [ + [ + 126627, + 126627 + ], + "mapped", + [ + 1583 + ] + ], + [ + [ + 126628, + 126628 + ], + "disallowed" + ], + [ + [ + 126629, + 126629 + ], + "mapped", + [ + 1608 + ] + ], + [ + [ + 126630, + 126630 + ], + "mapped", + [ + 1586 + ] + ], + [ + [ + 126631, + 126631 + ], + "mapped", + [ + 1581 + ] + ], + [ + [ + 126632, + 126632 + ], + "mapped", + [ + 1591 + ] + ], + [ + [ + 126633, + 126633 + ], + "mapped", + [ + 1610 + ] + ], + [ + [ + 126634, + 126634 + ], + "disallowed" + ], + [ + [ + 126635, + 126635 + ], + "mapped", + [ + 1604 + ] + ], + [ + [ + 126636, + 126636 + ], + "mapped", + [ + 1605 + ] + ], + [ + [ + 126637, + 126637 + ], + "mapped", + [ + 1606 + ] + ], + [ + [ + 126638, + 126638 + ], + "mapped", + [ + 1587 + ] + ], + [ + [ + 126639, + 126639 + ], + "mapped", + [ + 1593 + ] + ], + [ + [ + 126640, + 126640 + ], + "mapped", + [ + 1601 + ] + ], + [ + [ + 126641, + 126641 + ], + "mapped", + [ + 1589 + ] + ], + [ + [ + 126642, + 126642 + ], + "mapped", + [ + 1602 + ] + ], + [ + [ + 126643, + 126643 + ], + "mapped", + [ + 1585 + ] + ], + [ + [ + 126644, + 126644 + ], + "mapped", + [ + 1588 + ] + ], + [ + [ + 126645, + 126645 + ], + "mapped", + [ + 1578 + ] + ], + [ + [ + 126646, + 126646 + ], + "mapped", + [ + 1579 + ] + ], + [ + [ + 126647, + 126647 + ], + "mapped", + [ + 1582 + ] + ], + [ + [ + 126648, + 126648 + ], + "mapped", + [ + 1584 + ] + ], + [ + [ + 126649, + 126649 + ], + "mapped", + [ + 1590 + ] + ], + [ + [ + 126650, + 126650 + ], + "mapped", + [ + 1592 + ] + ], + [ + [ + 126651, + 126651 + ], + "mapped", + [ + 1594 + ] + ], + [ + [ + 126652, + 126703 + ], + "disallowed" + ], + [ + [ + 126704, + 126705 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 126706, + 126975 + ], + "disallowed" + ], + [ + [ + 126976, + 127019 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127020, + 127023 + ], + "disallowed" + ], + [ + [ + 127024, + 127123 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127124, + 127135 + ], + "disallowed" + ], + [ + [ + 127136, + 127150 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127151, + 127152 + ], + "disallowed" + ], + [ + [ + 127153, + 127166 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127167, + 127167 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127168, + 127168 + ], + "disallowed" + ], + [ + [ + 127169, + 127183 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127184, + 127184 + ], + "disallowed" + ], + [ + [ + 127185, + 127199 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127200, + 127221 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127222, + 127231 + ], + "disallowed" + ], + [ + [ + 127232, + 127232 + ], + "disallowed" + ], + [ + [ + 127233, + 127233 + ], + "disallowed_STD3_mapped", + [ + 48, + 44 + ] + ], + [ + [ + 127234, + 127234 + ], + "disallowed_STD3_mapped", + [ + 49, + 44 + ] + ], + [ + [ + 127235, + 127235 + ], + "disallowed_STD3_mapped", + [ + 50, + 44 + ] + ], + [ + [ + 127236, + 127236 + ], + "disallowed_STD3_mapped", + [ + 51, + 44 + ] + ], + [ + [ + 127237, + 127237 + ], + "disallowed_STD3_mapped", + [ + 52, + 44 + ] + ], + [ + [ + 127238, + 127238 + ], + "disallowed_STD3_mapped", + [ + 53, + 44 + ] + ], + [ + [ + 127239, + 127239 + ], + "disallowed_STD3_mapped", + [ + 54, + 44 + ] + ], + [ + [ + 127240, + 127240 + ], + "disallowed_STD3_mapped", + [ + 55, + 44 + ] + ], + [ + [ + 127241, + 127241 + ], + "disallowed_STD3_mapped", + [ + 56, + 44 + ] + ], + [ + [ + 127242, + 127242 + ], + "disallowed_STD3_mapped", + [ + 57, + 44 + ] + ], + [ + [ + 127243, + 127244 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127245, + 127247 + ], + "disallowed" + ], + [ + [ + 127248, + 127248 + ], + "disallowed_STD3_mapped", + [ + 40, + 97, + 41 + ] + ], + [ + [ + 127249, + 127249 + ], + "disallowed_STD3_mapped", + [ + 40, + 98, + 41 + ] + ], + [ + [ + 127250, + 127250 + ], + "disallowed_STD3_mapped", + [ + 40, + 99, + 41 + ] + ], + [ + [ + 127251, + 127251 + ], + "disallowed_STD3_mapped", + [ + 40, + 100, + 41 + ] + ], + [ + [ + 127252, + 127252 + ], + "disallowed_STD3_mapped", + [ + 40, + 101, + 41 + ] + ], + [ + [ + 127253, + 127253 + ], + "disallowed_STD3_mapped", + [ + 40, + 102, + 41 + ] + ], + [ + [ + 127254, + 127254 + ], + "disallowed_STD3_mapped", + [ + 40, + 103, + 41 + ] + ], + [ + [ + 127255, + 127255 + ], + "disallowed_STD3_mapped", + [ + 40, + 104, + 41 + ] + ], + [ + [ + 127256, + 127256 + ], + "disallowed_STD3_mapped", + [ + 40, + 105, + 41 + ] + ], + [ + [ + 127257, + 127257 + ], + "disallowed_STD3_mapped", + [ + 40, + 106, + 41 + ] + ], + [ + [ + 127258, + 127258 + ], + "disallowed_STD3_mapped", + [ + 40, + 107, + 41 + ] + ], + [ + [ + 127259, + 127259 + ], + "disallowed_STD3_mapped", + [ + 40, + 108, + 41 + ] + ], + [ + [ + 127260, + 127260 + ], + "disallowed_STD3_mapped", + [ + 40, + 109, + 41 + ] + ], + [ + [ + 127261, + 127261 + ], + "disallowed_STD3_mapped", + [ + 40, + 110, + 41 + ] + ], + [ + [ + 127262, + 127262 + ], + "disallowed_STD3_mapped", + [ + 40, + 111, + 41 + ] + ], + [ + [ + 127263, + 127263 + ], + "disallowed_STD3_mapped", + [ + 40, + 112, + 41 + ] + ], + [ + [ + 127264, + 127264 + ], + "disallowed_STD3_mapped", + [ + 40, + 113, + 41 + ] + ], + [ + [ + 127265, + 127265 + ], + "disallowed_STD3_mapped", + [ + 40, + 114, + 41 + ] + ], + [ + [ + 127266, + 127266 + ], + "disallowed_STD3_mapped", + [ + 40, + 115, + 41 + ] + ], + [ + [ + 127267, + 127267 + ], + "disallowed_STD3_mapped", + [ + 40, + 116, + 41 + ] + ], + [ + [ + 127268, + 127268 + ], + "disallowed_STD3_mapped", + [ + 40, + 117, + 41 + ] + ], + [ + [ + 127269, + 127269 + ], + "disallowed_STD3_mapped", + [ + 40, + 118, + 41 + ] + ], + [ + [ + 127270, + 127270 + ], + "disallowed_STD3_mapped", + [ + 40, + 119, + 41 + ] + ], + [ + [ + 127271, + 127271 + ], + "disallowed_STD3_mapped", + [ + 40, + 120, + 41 + ] + ], + [ + [ + 127272, + 127272 + ], + "disallowed_STD3_mapped", + [ + 40, + 121, + 41 + ] + ], + [ + [ + 127273, + 127273 + ], + "disallowed_STD3_mapped", + [ + 40, + 122, + 41 + ] + ], + [ + [ + 127274, + 127274 + ], + "mapped", + [ + 12308, + 115, + 12309 + ] + ], + [ + [ + 127275, + 127275 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 127276, + 127276 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 127277, + 127277 + ], + "mapped", + [ + 99, + 100 + ] + ], + [ + [ + 127278, + 127278 + ], + "mapped", + [ + 119, + 122 + ] + ], + [ + [ + 127279, + 127279 + ], + "disallowed" + ], + [ + [ + 127280, + 127280 + ], + "mapped", + [ + 97 + ] + ], + [ + [ + 127281, + 127281 + ], + "mapped", + [ + 98 + ] + ], + [ + [ + 127282, + 127282 + ], + "mapped", + [ + 99 + ] + ], + [ + [ + 127283, + 127283 + ], + "mapped", + [ + 100 + ] + ], + [ + [ + 127284, + 127284 + ], + "mapped", + [ + 101 + ] + ], + [ + [ + 127285, + 127285 + ], + "mapped", + [ + 102 + ] + ], + [ + [ + 127286, + 127286 + ], + "mapped", + [ + 103 + ] + ], + [ + [ + 127287, + 127287 + ], + "mapped", + [ + 104 + ] + ], + [ + [ + 127288, + 127288 + ], + "mapped", + [ + 105 + ] + ], + [ + [ + 127289, + 127289 + ], + "mapped", + [ + 106 + ] + ], + [ + [ + 127290, + 127290 + ], + "mapped", + [ + 107 + ] + ], + [ + [ + 127291, + 127291 + ], + "mapped", + [ + 108 + ] + ], + [ + [ + 127292, + 127292 + ], + "mapped", + [ + 109 + ] + ], + [ + [ + 127293, + 127293 + ], + "mapped", + [ + 110 + ] + ], + [ + [ + 127294, + 127294 + ], + "mapped", + [ + 111 + ] + ], + [ + [ + 127295, + 127295 + ], + "mapped", + [ + 112 + ] + ], + [ + [ + 127296, + 127296 + ], + "mapped", + [ + 113 + ] + ], + [ + [ + 127297, + 127297 + ], + "mapped", + [ + 114 + ] + ], + [ + [ + 127298, + 127298 + ], + "mapped", + [ + 115 + ] + ], + [ + [ + 127299, + 127299 + ], + "mapped", + [ + 116 + ] + ], + [ + [ + 127300, + 127300 + ], + "mapped", + [ + 117 + ] + ], + [ + [ + 127301, + 127301 + ], + "mapped", + [ + 118 + ] + ], + [ + [ + 127302, + 127302 + ], + "mapped", + [ + 119 + ] + ], + [ + [ + 127303, + 127303 + ], + "mapped", + [ + 120 + ] + ], + [ + [ + 127304, + 127304 + ], + "mapped", + [ + 121 + ] + ], + [ + [ + 127305, + 127305 + ], + "mapped", + [ + 122 + ] + ], + [ + [ + 127306, + 127306 + ], + "mapped", + [ + 104, + 118 + ] + ], + [ + [ + 127307, + 127307 + ], + "mapped", + [ + 109, + 118 + ] + ], + [ + [ + 127308, + 127308 + ], + "mapped", + [ + 115, + 100 + ] + ], + [ + [ + 127309, + 127309 + ], + "mapped", + [ + 115, + 115 + ] + ], + [ + [ + 127310, + 127310 + ], + "mapped", + [ + 112, + 112, + 118 + ] + ], + [ + [ + 127311, + 127311 + ], + "mapped", + [ + 119, + 99 + ] + ], + [ + [ + 127312, + 127318 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127319, + 127319 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127320, + 127326 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127327, + 127327 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127328, + 127337 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127338, + 127338 + ], + "mapped", + [ + 109, + 99 + ] + ], + [ + [ + 127339, + 127339 + ], + "mapped", + [ + 109, + 100 + ] + ], + [ + [ + 127340, + 127343 + ], + "disallowed" + ], + [ + [ + 127344, + 127352 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127353, + 127353 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127354, + 127354 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127355, + 127356 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127357, + 127358 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127359, + 127359 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127360, + 127369 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127370, + 127373 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127374, + 127375 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127376, + 127376 + ], + "mapped", + [ + 100, + 106 + ] + ], + [ + [ + 127377, + 127386 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127387, + 127461 + ], + "disallowed" + ], + [ + [ + 127462, + 127487 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127488, + 127488 + ], + "mapped", + [ + 12411, + 12363 + ] + ], + [ + [ + 127489, + 127489 + ], + "mapped", + [ + 12467, + 12467 + ] + ], + [ + [ + 127490, + 127490 + ], + "mapped", + [ + 12469 + ] + ], + [ + [ + 127491, + 127503 + ], + "disallowed" + ], + [ + [ + 127504, + 127504 + ], + "mapped", + [ + 25163 + ] + ], + [ + [ + 127505, + 127505 + ], + "mapped", + [ + 23383 + ] + ], + [ + [ + 127506, + 127506 + ], + "mapped", + [ + 21452 + ] + ], + [ + [ + 127507, + 127507 + ], + "mapped", + [ + 12487 + ] + ], + [ + [ + 127508, + 127508 + ], + "mapped", + [ + 20108 + ] + ], + [ + [ + 127509, + 127509 + ], + "mapped", + [ + 22810 + ] + ], + [ + [ + 127510, + 127510 + ], + "mapped", + [ + 35299 + ] + ], + [ + [ + 127511, + 127511 + ], + "mapped", + [ + 22825 + ] + ], + [ + [ + 127512, + 127512 + ], + "mapped", + [ + 20132 + ] + ], + [ + [ + 127513, + 127513 + ], + "mapped", + [ + 26144 + ] + ], + [ + [ + 127514, + 127514 + ], + "mapped", + [ + 28961 + ] + ], + [ + [ + 127515, + 127515 + ], + "mapped", + [ + 26009 + ] + ], + [ + [ + 127516, + 127516 + ], + "mapped", + [ + 21069 + ] + ], + [ + [ + 127517, + 127517 + ], + "mapped", + [ + 24460 + ] + ], + [ + [ + 127518, + 127518 + ], + "mapped", + [ + 20877 + ] + ], + [ + [ + 127519, + 127519 + ], + "mapped", + [ + 26032 + ] + ], + [ + [ + 127520, + 127520 + ], + "mapped", + [ + 21021 + ] + ], + [ + [ + 127521, + 127521 + ], + "mapped", + [ + 32066 + ] + ], + [ + [ + 127522, + 127522 + ], + "mapped", + [ + 29983 + ] + ], + [ + [ + 127523, + 127523 + ], + "mapped", + [ + 36009 + ] + ], + [ + [ + 127524, + 127524 + ], + "mapped", + [ + 22768 + ] + ], + [ + [ + 127525, + 127525 + ], + "mapped", + [ + 21561 + ] + ], + [ + [ + 127526, + 127526 + ], + "mapped", + [ + 28436 + ] + ], + [ + [ + 127527, + 127527 + ], + "mapped", + [ + 25237 + ] + ], + [ + [ + 127528, + 127528 + ], + "mapped", + [ + 25429 + ] + ], + [ + [ + 127529, + 127529 + ], + "mapped", + [ + 19968 + ] + ], + [ + [ + 127530, + 127530 + ], + "mapped", + [ + 19977 + ] + ], + [ + [ + 127531, + 127531 + ], + "mapped", + [ + 36938 + ] + ], + [ + [ + 127532, + 127532 + ], + "mapped", + [ + 24038 + ] + ], + [ + [ + 127533, + 127533 + ], + "mapped", + [ + 20013 + ] + ], + [ + [ + 127534, + 127534 + ], + "mapped", + [ + 21491 + ] + ], + [ + [ + 127535, + 127535 + ], + "mapped", + [ + 25351 + ] + ], + [ + [ + 127536, + 127536 + ], + "mapped", + [ + 36208 + ] + ], + [ + [ + 127537, + 127537 + ], + "mapped", + [ + 25171 + ] + ], + [ + [ + 127538, + 127538 + ], + "mapped", + [ + 31105 + ] + ], + [ + [ + 127539, + 127539 + ], + "mapped", + [ + 31354 + ] + ], + [ + [ + 127540, + 127540 + ], + "mapped", + [ + 21512 + ] + ], + [ + [ + 127541, + 127541 + ], + "mapped", + [ + 28288 + ] + ], + [ + [ + 127542, + 127542 + ], + "mapped", + [ + 26377 + ] + ], + [ + [ + 127543, + 127543 + ], + "mapped", + [ + 26376 + ] + ], + [ + [ + 127544, + 127544 + ], + "mapped", + [ + 30003 + ] + ], + [ + [ + 127545, + 127545 + ], + "mapped", + [ + 21106 + ] + ], + [ + [ + 127546, + 127546 + ], + "mapped", + [ + 21942 + ] + ], + [ + [ + 127547, + 127551 + ], + "disallowed" + ], + [ + [ + 127552, + 127552 + ], + "mapped", + [ + 12308, + 26412, + 12309 + ] + ], + [ + [ + 127553, + 127553 + ], + "mapped", + [ + 12308, + 19977, + 12309 + ] + ], + [ + [ + 127554, + 127554 + ], + "mapped", + [ + 12308, + 20108, + 12309 + ] + ], + [ + [ + 127555, + 127555 + ], + "mapped", + [ + 12308, + 23433, + 12309 + ] + ], + [ + [ + 127556, + 127556 + ], + "mapped", + [ + 12308, + 28857, + 12309 + ] + ], + [ + [ + 127557, + 127557 + ], + "mapped", + [ + 12308, + 25171, + 12309 + ] + ], + [ + [ + 127558, + 127558 + ], + "mapped", + [ + 12308, + 30423, + 12309 + ] + ], + [ + [ + 127559, + 127559 + ], + "mapped", + [ + 12308, + 21213, + 12309 + ] + ], + [ + [ + 127560, + 127560 + ], + "mapped", + [ + 12308, + 25943, + 12309 + ] + ], + [ + [ + 127561, + 127567 + ], + "disallowed" + ], + [ + [ + 127568, + 127568 + ], + "mapped", + [ + 24471 + ] + ], + [ + [ + 127569, + 127569 + ], + "mapped", + [ + 21487 + ] + ], + [ + [ + 127570, + 127743 + ], + "disallowed" + ], + [ + [ + 127744, + 127776 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127777, + 127788 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127789, + 127791 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127792, + 127797 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127798, + 127798 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127799, + 127868 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127869, + 127869 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127870, + 127871 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127872, + 127891 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127892, + 127903 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127904, + 127940 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127941, + 127941 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127942, + 127946 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127947, + 127950 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127951, + 127955 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127956, + 127967 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127968, + 127984 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127985, + 127991 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 127992, + 127999 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128000, + 128062 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128063, + 128063 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128064, + 128064 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128065, + 128065 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128066, + 128247 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128248, + 128248 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128249, + 128252 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128253, + 128254 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128255, + 128255 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128256, + 128317 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128318, + 128319 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128320, + 128323 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128324, + 128330 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128331, + 128335 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128336, + 128359 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128360, + 128377 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128378, + 128378 + ], + "disallowed" + ], + [ + [ + 128379, + 128419 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128420, + 128420 + ], + "disallowed" + ], + [ + [ + 128421, + 128506 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128507, + 128511 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128512, + 128512 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128513, + 128528 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128529, + 128529 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128530, + 128532 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128533, + 128533 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128534, + 128534 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128535, + 128535 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128536, + 128536 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128537, + 128537 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128538, + 128538 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128539, + 128539 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128540, + 128542 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128543, + 128543 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128544, + 128549 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128550, + 128551 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128552, + 128555 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128556, + 128556 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128557, + 128557 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128558, + 128559 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128560, + 128563 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128564, + 128564 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128565, + 128576 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128577, + 128578 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128579, + 128580 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128581, + 128591 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128592, + 128639 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128640, + 128709 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128710, + 128719 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128720, + 128720 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128721, + 128735 + ], + "disallowed" + ], + [ + [ + 128736, + 128748 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128749, + 128751 + ], + "disallowed" + ], + [ + [ + 128752, + 128755 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128756, + 128767 + ], + "disallowed" + ], + [ + [ + 128768, + 128883 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128884, + 128895 + ], + "disallowed" + ], + [ + [ + 128896, + 128980 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 128981, + 129023 + ], + "disallowed" + ], + [ + [ + 129024, + 129035 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 129036, + 129039 + ], + "disallowed" + ], + [ + [ + 129040, + 129095 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 129096, + 129103 + ], + "disallowed" + ], + [ + [ + 129104, + 129113 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 129114, + 129119 + ], + "disallowed" + ], + [ + [ + 129120, + 129159 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 129160, + 129167 + ], + "disallowed" + ], + [ + [ + 129168, + 129197 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 129198, + 129295 + ], + "disallowed" + ], + [ + [ + 129296, + 129304 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 129305, + 129407 + ], + "disallowed" + ], + [ + [ + 129408, + 129412 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 129413, + 129471 + ], + "disallowed" + ], + [ + [ + 129472, + 129472 + ], + "valid", + [ + ], + "NV8" + ], + [ + [ + 129473, + 131069 + ], + "disallowed" + ], + [ + [ + 131070, + 131071 + ], + "disallowed" + ], + [ + [ + 131072, + 173782 + ], + "valid" + ], + [ + [ + 173783, + 173823 + ], + "disallowed" + ], + [ + [ + 173824, + 177972 + ], + "valid" + ], + [ + [ + 177973, + 177983 + ], + "disallowed" + ], + [ + [ + 177984, + 178205 + ], + "valid" + ], + [ + [ + 178206, + 178207 + ], + "disallowed" + ], + [ + [ + 178208, + 183969 + ], + "valid" + ], + [ + [ + 183970, + 194559 + ], + "disallowed" + ], + [ + [ + 194560, + 194560 + ], + "mapped", + [ + 20029 + ] + ], + [ + [ + 194561, + 194561 + ], + "mapped", + [ + 20024 + ] + ], + [ + [ + 194562, + 194562 + ], + "mapped", + [ + 20033 + ] + ], + [ + [ + 194563, + 194563 + ], + "mapped", + [ + 131362 + ] + ], + [ + [ + 194564, + 194564 + ], + "mapped", + [ + 20320 + ] + ], + [ + [ + 194565, + 194565 + ], + "mapped", + [ + 20398 + ] + ], + [ + [ + 194566, + 194566 + ], + "mapped", + [ + 20411 + ] + ], + [ + [ + 194567, + 194567 + ], + "mapped", + [ + 20482 + ] + ], + [ + [ + 194568, + 194568 + ], + "mapped", + [ + 20602 + ] + ], + [ + [ + 194569, + 194569 + ], + "mapped", + [ + 20633 + ] + ], + [ + [ + 194570, + 194570 + ], + "mapped", + [ + 20711 + ] + ], + [ + [ + 194571, + 194571 + ], + "mapped", + [ + 20687 + ] + ], + [ + [ + 194572, + 194572 + ], + "mapped", + [ + 13470 + ] + ], + [ + [ + 194573, + 194573 + ], + "mapped", + [ + 132666 + ] + ], + [ + [ + 194574, + 194574 + ], + "mapped", + [ + 20813 + ] + ], + [ + [ + 194575, + 194575 + ], + "mapped", + [ + 20820 + ] + ], + [ + [ + 194576, + 194576 + ], + "mapped", + [ + 20836 + ] + ], + [ + [ + 194577, + 194577 + ], + "mapped", + [ + 20855 + ] + ], + [ + [ + 194578, + 194578 + ], + "mapped", + [ + 132380 + ] + ], + [ + [ + 194579, + 194579 + ], + "mapped", + [ + 13497 + ] + ], + [ + [ + 194580, + 194580 + ], + "mapped", + [ + 20839 + ] + ], + [ + [ + 194581, + 194581 + ], + "mapped", + [ + 20877 + ] + ], + [ + [ + 194582, + 194582 + ], + "mapped", + [ + 132427 + ] + ], + [ + [ + 194583, + 194583 + ], + "mapped", + [ + 20887 + ] + ], + [ + [ + 194584, + 194584 + ], + "mapped", + [ + 20900 + ] + ], + [ + [ + 194585, + 194585 + ], + "mapped", + [ + 20172 + ] + ], + [ + [ + 194586, + 194586 + ], + "mapped", + [ + 20908 + ] + ], + [ + [ + 194587, + 194587 + ], + "mapped", + [ + 20917 + ] + ], + [ + [ + 194588, + 194588 + ], + "mapped", + [ + 168415 + ] + ], + [ + [ + 194589, + 194589 + ], + "mapped", + [ + 20981 + ] + ], + [ + [ + 194590, + 194590 + ], + "mapped", + [ + 20995 + ] + ], + [ + [ + 194591, + 194591 + ], + "mapped", + [ + 13535 + ] + ], + [ + [ + 194592, + 194592 + ], + "mapped", + [ + 21051 + ] + ], + [ + [ + 194593, + 194593 + ], + "mapped", + [ + 21062 + ] + ], + [ + [ + 194594, + 194594 + ], + "mapped", + [ + 21106 + ] + ], + [ + [ + 194595, + 194595 + ], + "mapped", + [ + 21111 + ] + ], + [ + [ + 194596, + 194596 + ], + "mapped", + [ + 13589 + ] + ], + [ + [ + 194597, + 194597 + ], + "mapped", + [ + 21191 + ] + ], + [ + [ + 194598, + 194598 + ], + "mapped", + [ + 21193 + ] + ], + [ + [ + 194599, + 194599 + ], + "mapped", + [ + 21220 + ] + ], + [ + [ + 194600, + 194600 + ], + "mapped", + [ + 21242 + ] + ], + [ + [ + 194601, + 194601 + ], + "mapped", + [ + 21253 + ] + ], + [ + [ + 194602, + 194602 + ], + "mapped", + [ + 21254 + ] + ], + [ + [ + 194603, + 194603 + ], + "mapped", + [ + 21271 + ] + ], + [ + [ + 194604, + 194604 + ], + "mapped", + [ + 21321 + ] + ], + [ + [ + 194605, + 194605 + ], + "mapped", + [ + 21329 + ] + ], + [ + [ + 194606, + 194606 + ], + "mapped", + [ + 21338 + ] + ], + [ + [ + 194607, + 194607 + ], + "mapped", + [ + 21363 + ] + ], + [ + [ + 194608, + 194608 + ], + "mapped", + [ + 21373 + ] + ], + [ + [ + 194609, + 194611 + ], + "mapped", + [ + 21375 + ] + ], + [ + [ + 194612, + 194612 + ], + "mapped", + [ + 133676 + ] + ], + [ + [ + 194613, + 194613 + ], + "mapped", + [ + 28784 + ] + ], + [ + [ + 194614, + 194614 + ], + "mapped", + [ + 21450 + ] + ], + [ + [ + 194615, + 194615 + ], + "mapped", + [ + 21471 + ] + ], + [ + [ + 194616, + 194616 + ], + "mapped", + [ + 133987 + ] + ], + [ + [ + 194617, + 194617 + ], + "mapped", + [ + 21483 + ] + ], + [ + [ + 194618, + 194618 + ], + "mapped", + [ + 21489 + ] + ], + [ + [ + 194619, + 194619 + ], + "mapped", + [ + 21510 + ] + ], + [ + [ + 194620, + 194620 + ], + "mapped", + [ + 21662 + ] + ], + [ + [ + 194621, + 194621 + ], + "mapped", + [ + 21560 + ] + ], + [ + [ + 194622, + 194622 + ], + "mapped", + [ + 21576 + ] + ], + [ + [ + 194623, + 194623 + ], + "mapped", + [ + 21608 + ] + ], + [ + [ + 194624, + 194624 + ], + "mapped", + [ + 21666 + ] + ], + [ + [ + 194625, + 194625 + ], + "mapped", + [ + 21750 + ] + ], + [ + [ + 194626, + 194626 + ], + "mapped", + [ + 21776 + ] + ], + [ + [ + 194627, + 194627 + ], + "mapped", + [ + 21843 + ] + ], + [ + [ + 194628, + 194628 + ], + "mapped", + [ + 21859 + ] + ], + [ + [ + 194629, + 194630 + ], + "mapped", + [ + 21892 + ] + ], + [ + [ + 194631, + 194631 + ], + "mapped", + [ + 21913 + ] + ], + [ + [ + 194632, + 194632 + ], + "mapped", + [ + 21931 + ] + ], + [ + [ + 194633, + 194633 + ], + "mapped", + [ + 21939 + ] + ], + [ + [ + 194634, + 194634 + ], + "mapped", + [ + 21954 + ] + ], + [ + [ + 194635, + 194635 + ], + "mapped", + [ + 22294 + ] + ], + [ + [ + 194636, + 194636 + ], + "mapped", + [ + 22022 + ] + ], + [ + [ + 194637, + 194637 + ], + "mapped", + [ + 22295 + ] + ], + [ + [ + 194638, + 194638 + ], + "mapped", + [ + 22097 + ] + ], + [ + [ + 194639, + 194639 + ], + "mapped", + [ + 22132 + ] + ], + [ + [ + 194640, + 194640 + ], + "mapped", + [ + 20999 + ] + ], + [ + [ + 194641, + 194641 + ], + "mapped", + [ + 22766 + ] + ], + [ + [ + 194642, + 194642 + ], + "mapped", + [ + 22478 + ] + ], + [ + [ + 194643, + 194643 + ], + "mapped", + [ + 22516 + ] + ], + [ + [ + 194644, + 194644 + ], + "mapped", + [ + 22541 + ] + ], + [ + [ + 194645, + 194645 + ], + "mapped", + [ + 22411 + ] + ], + [ + [ + 194646, + 194646 + ], + "mapped", + [ + 22578 + ] + ], + [ + [ + 194647, + 194647 + ], + "mapped", + [ + 22577 + ] + ], + [ + [ + 194648, + 194648 + ], + "mapped", + [ + 22700 + ] + ], + [ + [ + 194649, + 194649 + ], + "mapped", + [ + 136420 + ] + ], + [ + [ + 194650, + 194650 + ], + "mapped", + [ + 22770 + ] + ], + [ + [ + 194651, + 194651 + ], + "mapped", + [ + 22775 + ] + ], + [ + [ + 194652, + 194652 + ], + "mapped", + [ + 22790 + ] + ], + [ + [ + 194653, + 194653 + ], + "mapped", + [ + 22810 + ] + ], + [ + [ + 194654, + 194654 + ], + "mapped", + [ + 22818 + ] + ], + [ + [ + 194655, + 194655 + ], + "mapped", + [ + 22882 + ] + ], + [ + [ + 194656, + 194656 + ], + "mapped", + [ + 136872 + ] + ], + [ + [ + 194657, + 194657 + ], + "mapped", + [ + 136938 + ] + ], + [ + [ + 194658, + 194658 + ], + "mapped", + [ + 23020 + ] + ], + [ + [ + 194659, + 194659 + ], + "mapped", + [ + 23067 + ] + ], + [ + [ + 194660, + 194660 + ], + "mapped", + [ + 23079 + ] + ], + [ + [ + 194661, + 194661 + ], + "mapped", + [ + 23000 + ] + ], + [ + [ + 194662, + 194662 + ], + "mapped", + [ + 23142 + ] + ], + [ + [ + 194663, + 194663 + ], + "mapped", + [ + 14062 + ] + ], + [ + [ + 194664, + 194664 + ], + "disallowed" + ], + [ + [ + 194665, + 194665 + ], + "mapped", + [ + 23304 + ] + ], + [ + [ + 194666, + 194667 + ], + "mapped", + [ + 23358 + ] + ], + [ + [ + 194668, + 194668 + ], + "mapped", + [ + 137672 + ] + ], + [ + [ + 194669, + 194669 + ], + "mapped", + [ + 23491 + ] + ], + [ + [ + 194670, + 194670 + ], + "mapped", + [ + 23512 + ] + ], + [ + [ + 194671, + 194671 + ], + "mapped", + [ + 23527 + ] + ], + [ + [ + 194672, + 194672 + ], + "mapped", + [ + 23539 + ] + ], + [ + [ + 194673, + 194673 + ], + "mapped", + [ + 138008 + ] + ], + [ + [ + 194674, + 194674 + ], + "mapped", + [ + 23551 + ] + ], + [ + [ + 194675, + 194675 + ], + "mapped", + [ + 23558 + ] + ], + [ + [ + 194676, + 194676 + ], + "disallowed" + ], + [ + [ + 194677, + 194677 + ], + "mapped", + [ + 23586 + ] + ], + [ + [ + 194678, + 194678 + ], + "mapped", + [ + 14209 + ] + ], + [ + [ + 194679, + 194679 + ], + "mapped", + [ + 23648 + ] + ], + [ + [ + 194680, + 194680 + ], + "mapped", + [ + 23662 + ] + ], + [ + [ + 194681, + 194681 + ], + "mapped", + [ + 23744 + ] + ], + [ + [ + 194682, + 194682 + ], + "mapped", + [ + 23693 + ] + ], + [ + [ + 194683, + 194683 + ], + "mapped", + [ + 138724 + ] + ], + [ + [ + 194684, + 194684 + ], + "mapped", + [ + 23875 + ] + ], + [ + [ + 194685, + 194685 + ], + "mapped", + [ + 138726 + ] + ], + [ + [ + 194686, + 194686 + ], + "mapped", + [ + 23918 + ] + ], + [ + [ + 194687, + 194687 + ], + "mapped", + [ + 23915 + ] + ], + [ + [ + 194688, + 194688 + ], + "mapped", + [ + 23932 + ] + ], + [ + [ + 194689, + 194689 + ], + "mapped", + [ + 24033 + ] + ], + [ + [ + 194690, + 194690 + ], + "mapped", + [ + 24034 + ] + ], + [ + [ + 194691, + 194691 + ], + "mapped", + [ + 14383 + ] + ], + [ + [ + 194692, + 194692 + ], + "mapped", + [ + 24061 + ] + ], + [ + [ + 194693, + 194693 + ], + "mapped", + [ + 24104 + ] + ], + [ + [ + 194694, + 194694 + ], + "mapped", + [ + 24125 + ] + ], + [ + [ + 194695, + 194695 + ], + "mapped", + [ + 24169 + ] + ], + [ + [ + 194696, + 194696 + ], + "mapped", + [ + 14434 + ] + ], + [ + [ + 194697, + 194697 + ], + "mapped", + [ + 139651 + ] + ], + [ + [ + 194698, + 194698 + ], + "mapped", + [ + 14460 + ] + ], + [ + [ + 194699, + 194699 + ], + "mapped", + [ + 24240 + ] + ], + [ + [ + 194700, + 194700 + ], + "mapped", + [ + 24243 + ] + ], + [ + [ + 194701, + 194701 + ], + "mapped", + [ + 24246 + ] + ], + [ + [ + 194702, + 194702 + ], + "mapped", + [ + 24266 + ] + ], + [ + [ + 194703, + 194703 + ], + "mapped", + [ + 172946 + ] + ], + [ + [ + 194704, + 194704 + ], + "mapped", + [ + 24318 + ] + ], + [ + [ + 194705, + 194706 + ], + "mapped", + [ + 140081 + ] + ], + [ + [ + 194707, + 194707 + ], + "mapped", + [ + 33281 + ] + ], + [ + [ + 194708, + 194709 + ], + "mapped", + [ + 24354 + ] + ], + [ + [ + 194710, + 194710 + ], + "mapped", + [ + 14535 + ] + ], + [ + [ + 194711, + 194711 + ], + "mapped", + [ + 144056 + ] + ], + [ + [ + 194712, + 194712 + ], + "mapped", + [ + 156122 + ] + ], + [ + [ + 194713, + 194713 + ], + "mapped", + [ + 24418 + ] + ], + [ + [ + 194714, + 194714 + ], + "mapped", + [ + 24427 + ] + ], + [ + [ + 194715, + 194715 + ], + "mapped", + [ + 14563 + ] + ], + [ + [ + 194716, + 194716 + ], + "mapped", + [ + 24474 + ] + ], + [ + [ + 194717, + 194717 + ], + "mapped", + [ + 24525 + ] + ], + [ + [ + 194718, + 194718 + ], + "mapped", + [ + 24535 + ] + ], + [ + [ + 194719, + 194719 + ], + "mapped", + [ + 24569 + ] + ], + [ + [ + 194720, + 194720 + ], + "mapped", + [ + 24705 + ] + ], + [ + [ + 194721, + 194721 + ], + "mapped", + [ + 14650 + ] + ], + [ + [ + 194722, + 194722 + ], + "mapped", + [ + 14620 + ] + ], + [ + [ + 194723, + 194723 + ], + "mapped", + [ + 24724 + ] + ], + [ + [ + 194724, + 194724 + ], + "mapped", + [ + 141012 + ] + ], + [ + [ + 194725, + 194725 + ], + "mapped", + [ + 24775 + ] + ], + [ + [ + 194726, + 194726 + ], + "mapped", + [ + 24904 + ] + ], + [ + [ + 194727, + 194727 + ], + "mapped", + [ + 24908 + ] + ], + [ + [ + 194728, + 194728 + ], + "mapped", + [ + 24910 + ] + ], + [ + [ + 194729, + 194729 + ], + "mapped", + [ + 24908 + ] + ], + [ + [ + 194730, + 194730 + ], + "mapped", + [ + 24954 + ] + ], + [ + [ + 194731, + 194731 + ], + "mapped", + [ + 24974 + ] + ], + [ + [ + 194732, + 194732 + ], + "mapped", + [ + 25010 + ] + ], + [ + [ + 194733, + 194733 + ], + "mapped", + [ + 24996 + ] + ], + [ + [ + 194734, + 194734 + ], + "mapped", + [ + 25007 + ] + ], + [ + [ + 194735, + 194735 + ], + "mapped", + [ + 25054 + ] + ], + [ + [ + 194736, + 194736 + ], + "mapped", + [ + 25074 + ] + ], + [ + [ + 194737, + 194737 + ], + "mapped", + [ + 25078 + ] + ], + [ + [ + 194738, + 194738 + ], + "mapped", + [ + 25104 + ] + ], + [ + [ + 194739, + 194739 + ], + "mapped", + [ + 25115 + ] + ], + [ + [ + 194740, + 194740 + ], + "mapped", + [ + 25181 + ] + ], + [ + [ + 194741, + 194741 + ], + "mapped", + [ + 25265 + ] + ], + [ + [ + 194742, + 194742 + ], + "mapped", + [ + 25300 + ] + ], + [ + [ + 194743, + 194743 + ], + "mapped", + [ + 25424 + ] + ], + [ + [ + 194744, + 194744 + ], + "mapped", + [ + 142092 + ] + ], + [ + [ + 194745, + 194745 + ], + "mapped", + [ + 25405 + ] + ], + [ + [ + 194746, + 194746 + ], + "mapped", + [ + 25340 + ] + ], + [ + [ + 194747, + 194747 + ], + "mapped", + [ + 25448 + ] + ], + [ + [ + 194748, + 194748 + ], + "mapped", + [ + 25475 + ] + ], + [ + [ + 194749, + 194749 + ], + "mapped", + [ + 25572 + ] + ], + [ + [ + 194750, + 194750 + ], + "mapped", + [ + 142321 + ] + ], + [ + [ + 194751, + 194751 + ], + "mapped", + [ + 25634 + ] + ], + [ + [ + 194752, + 194752 + ], + "mapped", + [ + 25541 + ] + ], + [ + [ + 194753, + 194753 + ], + "mapped", + [ + 25513 + ] + ], + [ + [ + 194754, + 194754 + ], + "mapped", + [ + 14894 + ] + ], + [ + [ + 194755, + 194755 + ], + "mapped", + [ + 25705 + ] + ], + [ + [ + 194756, + 194756 + ], + "mapped", + [ + 25726 + ] + ], + [ + [ + 194757, + 194757 + ], + "mapped", + [ + 25757 + ] + ], + [ + [ + 194758, + 194758 + ], + "mapped", + [ + 25719 + ] + ], + [ + [ + 194759, + 194759 + ], + "mapped", + [ + 14956 + ] + ], + [ + [ + 194760, + 194760 + ], + "mapped", + [ + 25935 + ] + ], + [ + [ + 194761, + 194761 + ], + "mapped", + [ + 25964 + ] + ], + [ + [ + 194762, + 194762 + ], + "mapped", + [ + 143370 + ] + ], + [ + [ + 194763, + 194763 + ], + "mapped", + [ + 26083 + ] + ], + [ + [ + 194764, + 194764 + ], + "mapped", + [ + 26360 + ] + ], + [ + [ + 194765, + 194765 + ], + "mapped", + [ + 26185 + ] + ], + [ + [ + 194766, + 194766 + ], + "mapped", + [ + 15129 + ] + ], + [ + [ + 194767, + 194767 + ], + "mapped", + [ + 26257 + ] + ], + [ + [ + 194768, + 194768 + ], + "mapped", + [ + 15112 + ] + ], + [ + [ + 194769, + 194769 + ], + "mapped", + [ + 15076 + ] + ], + [ + [ + 194770, + 194770 + ], + "mapped", + [ + 20882 + ] + ], + [ + [ + 194771, + 194771 + ], + "mapped", + [ + 20885 + ] + ], + [ + [ + 194772, + 194772 + ], + "mapped", + [ + 26368 + ] + ], + [ + [ + 194773, + 194773 + ], + "mapped", + [ + 26268 + ] + ], + [ + [ + 194774, + 194774 + ], + "mapped", + [ + 32941 + ] + ], + [ + [ + 194775, + 194775 + ], + "mapped", + [ + 17369 + ] + ], + [ + [ + 194776, + 194776 + ], + "mapped", + [ + 26391 + ] + ], + [ + [ + 194777, + 194777 + ], + "mapped", + [ + 26395 + ] + ], + [ + [ + 194778, + 194778 + ], + "mapped", + [ + 26401 + ] + ], + [ + [ + 194779, + 194779 + ], + "mapped", + [ + 26462 + ] + ], + [ + [ + 194780, + 194780 + ], + "mapped", + [ + 26451 + ] + ], + [ + [ + 194781, + 194781 + ], + "mapped", + [ + 144323 + ] + ], + [ + [ + 194782, + 194782 + ], + "mapped", + [ + 15177 + ] + ], + [ + [ + 194783, + 194783 + ], + "mapped", + [ + 26618 + ] + ], + [ + [ + 194784, + 194784 + ], + "mapped", + [ + 26501 + ] + ], + [ + [ + 194785, + 194785 + ], + "mapped", + [ + 26706 + ] + ], + [ + [ + 194786, + 194786 + ], + "mapped", + [ + 26757 + ] + ], + [ + [ + 194787, + 194787 + ], + "mapped", + [ + 144493 + ] + ], + [ + [ + 194788, + 194788 + ], + "mapped", + [ + 26766 + ] + ], + [ + [ + 194789, + 194789 + ], + "mapped", + [ + 26655 + ] + ], + [ + [ + 194790, + 194790 + ], + "mapped", + [ + 26900 + ] + ], + [ + [ + 194791, + 194791 + ], + "mapped", + [ + 15261 + ] + ], + [ + [ + 194792, + 194792 + ], + "mapped", + [ + 26946 + ] + ], + [ + [ + 194793, + 194793 + ], + "mapped", + [ + 27043 + ] + ], + [ + [ + 194794, + 194794 + ], + "mapped", + [ + 27114 + ] + ], + [ + [ + 194795, + 194795 + ], + "mapped", + [ + 27304 + ] + ], + [ + [ + 194796, + 194796 + ], + "mapped", + [ + 145059 + ] + ], + [ + [ + 194797, + 194797 + ], + "mapped", + [ + 27355 + ] + ], + [ + [ + 194798, + 194798 + ], + "mapped", + [ + 15384 + ] + ], + [ + [ + 194799, + 194799 + ], + "mapped", + [ + 27425 + ] + ], + [ + [ + 194800, + 194800 + ], + "mapped", + [ + 145575 + ] + ], + [ + [ + 194801, + 194801 + ], + "mapped", + [ + 27476 + ] + ], + [ + [ + 194802, + 194802 + ], + "mapped", + [ + 15438 + ] + ], + [ + [ + 194803, + 194803 + ], + "mapped", + [ + 27506 + ] + ], + [ + [ + 194804, + 194804 + ], + "mapped", + [ + 27551 + ] + ], + [ + [ + 194805, + 194805 + ], + "mapped", + [ + 27578 + ] + ], + [ + [ + 194806, + 194806 + ], + "mapped", + [ + 27579 + ] + ], + [ + [ + 194807, + 194807 + ], + "mapped", + [ + 146061 + ] + ], + [ + [ + 194808, + 194808 + ], + "mapped", + [ + 138507 + ] + ], + [ + [ + 194809, + 194809 + ], + "mapped", + [ + 146170 + ] + ], + [ + [ + 194810, + 194810 + ], + "mapped", + [ + 27726 + ] + ], + [ + [ + 194811, + 194811 + ], + "mapped", + [ + 146620 + ] + ], + [ + [ + 194812, + 194812 + ], + "mapped", + [ + 27839 + ] + ], + [ + [ + 194813, + 194813 + ], + "mapped", + [ + 27853 + ] + ], + [ + [ + 194814, + 194814 + ], + "mapped", + [ + 27751 + ] + ], + [ + [ + 194815, + 194815 + ], + "mapped", + [ + 27926 + ] + ], + [ + [ + 194816, + 194816 + ], + "mapped", + [ + 27966 + ] + ], + [ + [ + 194817, + 194817 + ], + "mapped", + [ + 28023 + ] + ], + [ + [ + 194818, + 194818 + ], + "mapped", + [ + 27969 + ] + ], + [ + [ + 194819, + 194819 + ], + "mapped", + [ + 28009 + ] + ], + [ + [ + 194820, + 194820 + ], + "mapped", + [ + 28024 + ] + ], + [ + [ + 194821, + 194821 + ], + "mapped", + [ + 28037 + ] + ], + [ + [ + 194822, + 194822 + ], + "mapped", + [ + 146718 + ] + ], + [ + [ + 194823, + 194823 + ], + "mapped", + [ + 27956 + ] + ], + [ + [ + 194824, + 194824 + ], + "mapped", + [ + 28207 + ] + ], + [ + [ + 194825, + 194825 + ], + "mapped", + [ + 28270 + ] + ], + [ + [ + 194826, + 194826 + ], + "mapped", + [ + 15667 + ] + ], + [ + [ + 194827, + 194827 + ], + "mapped", + [ + 28363 + ] + ], + [ + [ + 194828, + 194828 + ], + "mapped", + [ + 28359 + ] + ], + [ + [ + 194829, + 194829 + ], + "mapped", + [ + 147153 + ] + ], + [ + [ + 194830, + 194830 + ], + "mapped", + [ + 28153 + ] + ], + [ + [ + 194831, + 194831 + ], + "mapped", + [ + 28526 + ] + ], + [ + [ + 194832, + 194832 + ], + "mapped", + [ + 147294 + ] + ], + [ + [ + 194833, + 194833 + ], + "mapped", + [ + 147342 + ] + ], + [ + [ + 194834, + 194834 + ], + "mapped", + [ + 28614 + ] + ], + [ + [ + 194835, + 194835 + ], + "mapped", + [ + 28729 + ] + ], + [ + [ + 194836, + 194836 + ], + "mapped", + [ + 28702 + ] + ], + [ + [ + 194837, + 194837 + ], + "mapped", + [ + 28699 + ] + ], + [ + [ + 194838, + 194838 + ], + "mapped", + [ + 15766 + ] + ], + [ + [ + 194839, + 194839 + ], + "mapped", + [ + 28746 + ] + ], + [ + [ + 194840, + 194840 + ], + "mapped", + [ + 28797 + ] + ], + [ + [ + 194841, + 194841 + ], + "mapped", + [ + 28791 + ] + ], + [ + [ + 194842, + 194842 + ], + "mapped", + [ + 28845 + ] + ], + [ + [ + 194843, + 194843 + ], + "mapped", + [ + 132389 + ] + ], + [ + [ + 194844, + 194844 + ], + "mapped", + [ + 28997 + ] + ], + [ + [ + 194845, + 194845 + ], + "mapped", + [ + 148067 + ] + ], + [ + [ + 194846, + 194846 + ], + "mapped", + [ + 29084 + ] + ], + [ + [ + 194847, + 194847 + ], + "disallowed" + ], + [ + [ + 194848, + 194848 + ], + "mapped", + [ + 29224 + ] + ], + [ + [ + 194849, + 194849 + ], + "mapped", + [ + 29237 + ] + ], + [ + [ + 194850, + 194850 + ], + "mapped", + [ + 29264 + ] + ], + [ + [ + 194851, + 194851 + ], + "mapped", + [ + 149000 + ] + ], + [ + [ + 194852, + 194852 + ], + "mapped", + [ + 29312 + ] + ], + [ + [ + 194853, + 194853 + ], + "mapped", + [ + 29333 + ] + ], + [ + [ + 194854, + 194854 + ], + "mapped", + [ + 149301 + ] + ], + [ + [ + 194855, + 194855 + ], + "mapped", + [ + 149524 + ] + ], + [ + [ + 194856, + 194856 + ], + "mapped", + [ + 29562 + ] + ], + [ + [ + 194857, + 194857 + ], + "mapped", + [ + 29579 + ] + ], + [ + [ + 194858, + 194858 + ], + "mapped", + [ + 16044 + ] + ], + [ + [ + 194859, + 194859 + ], + "mapped", + [ + 29605 + ] + ], + [ + [ + 194860, + 194861 + ], + "mapped", + [ + 16056 + ] + ], + [ + [ + 194862, + 194862 + ], + "mapped", + [ + 29767 + ] + ], + [ + [ + 194863, + 194863 + ], + "mapped", + [ + 29788 + ] + ], + [ + [ + 194864, + 194864 + ], + "mapped", + [ + 29809 + ] + ], + [ + [ + 194865, + 194865 + ], + "mapped", + [ + 29829 + ] + ], + [ + [ + 194866, + 194866 + ], + "mapped", + [ + 29898 + ] + ], + [ + [ + 194867, + 194867 + ], + "mapped", + [ + 16155 + ] + ], + [ + [ + 194868, + 194868 + ], + "mapped", + [ + 29988 + ] + ], + [ + [ + 194869, + 194869 + ], + "mapped", + [ + 150582 + ] + ], + [ + [ + 194870, + 194870 + ], + "mapped", + [ + 30014 + ] + ], + [ + [ + 194871, + 194871 + ], + "mapped", + [ + 150674 + ] + ], + [ + [ + 194872, + 194872 + ], + "mapped", + [ + 30064 + ] + ], + [ + [ + 194873, + 194873 + ], + "mapped", + [ + 139679 + ] + ], + [ + [ + 194874, + 194874 + ], + "mapped", + [ + 30224 + ] + ], + [ + [ + 194875, + 194875 + ], + "mapped", + [ + 151457 + ] + ], + [ + [ + 194876, + 194876 + ], + "mapped", + [ + 151480 + ] + ], + [ + [ + 194877, + 194877 + ], + "mapped", + [ + 151620 + ] + ], + [ + [ + 194878, + 194878 + ], + "mapped", + [ + 16380 + ] + ], + [ + [ + 194879, + 194879 + ], + "mapped", + [ + 16392 + ] + ], + [ + [ + 194880, + 194880 + ], + "mapped", + [ + 30452 + ] + ], + [ + [ + 194881, + 194881 + ], + "mapped", + [ + 151795 + ] + ], + [ + [ + 194882, + 194882 + ], + "mapped", + [ + 151794 + ] + ], + [ + [ + 194883, + 194883 + ], + "mapped", + [ + 151833 + ] + ], + [ + [ + 194884, + 194884 + ], + "mapped", + [ + 151859 + ] + ], + [ + [ + 194885, + 194885 + ], + "mapped", + [ + 30494 + ] + ], + [ + [ + 194886, + 194887 + ], + "mapped", + [ + 30495 + ] + ], + [ + [ + 194888, + 194888 + ], + "mapped", + [ + 30538 + ] + ], + [ + [ + 194889, + 194889 + ], + "mapped", + [ + 16441 + ] + ], + [ + [ + 194890, + 194890 + ], + "mapped", + [ + 30603 + ] + ], + [ + [ + 194891, + 194891 + ], + "mapped", + [ + 16454 + ] + ], + [ + [ + 194892, + 194892 + ], + "mapped", + [ + 16534 + ] + ], + [ + [ + 194893, + 194893 + ], + "mapped", + [ + 152605 + ] + ], + [ + [ + 194894, + 194894 + ], + "mapped", + [ + 30798 + ] + ], + [ + [ + 194895, + 194895 + ], + "mapped", + [ + 30860 + ] + ], + [ + [ + 194896, + 194896 + ], + "mapped", + [ + 30924 + ] + ], + [ + [ + 194897, + 194897 + ], + "mapped", + [ + 16611 + ] + ], + [ + [ + 194898, + 194898 + ], + "mapped", + [ + 153126 + ] + ], + [ + [ + 194899, + 194899 + ], + "mapped", + [ + 31062 + ] + ], + [ + [ + 194900, + 194900 + ], + "mapped", + [ + 153242 + ] + ], + [ + [ + 194901, + 194901 + ], + "mapped", + [ + 153285 + ] + ], + [ + [ + 194902, + 194902 + ], + "mapped", + [ + 31119 + ] + ], + [ + [ + 194903, + 194903 + ], + "mapped", + [ + 31211 + ] + ], + [ + [ + 194904, + 194904 + ], + "mapped", + [ + 16687 + ] + ], + [ + [ + 194905, + 194905 + ], + "mapped", + [ + 31296 + ] + ], + [ + [ + 194906, + 194906 + ], + "mapped", + [ + 31306 + ] + ], + [ + [ + 194907, + 194907 + ], + "mapped", + [ + 31311 + ] + ], + [ + [ + 194908, + 194908 + ], + "mapped", + [ + 153980 + ] + ], + [ + [ + 194909, + 194910 + ], + "mapped", + [ + 154279 + ] + ], + [ + [ + 194911, + 194911 + ], + "disallowed" + ], + [ + [ + 194912, + 194912 + ], + "mapped", + [ + 16898 + ] + ], + [ + [ + 194913, + 194913 + ], + "mapped", + [ + 154539 + ] + ], + [ + [ + 194914, + 194914 + ], + "mapped", + [ + 31686 + ] + ], + [ + [ + 194915, + 194915 + ], + "mapped", + [ + 31689 + ] + ], + [ + [ + 194916, + 194916 + ], + "mapped", + [ + 16935 + ] + ], + [ + [ + 194917, + 194917 + ], + "mapped", + [ + 154752 + ] + ], + [ + [ + 194918, + 194918 + ], + "mapped", + [ + 31954 + ] + ], + [ + [ + 194919, + 194919 + ], + "mapped", + [ + 17056 + ] + ], + [ + [ + 194920, + 194920 + ], + "mapped", + [ + 31976 + ] + ], + [ + [ + 194921, + 194921 + ], + "mapped", + [ + 31971 + ] + ], + [ + [ + 194922, + 194922 + ], + "mapped", + [ + 32000 + ] + ], + [ + [ + 194923, + 194923 + ], + "mapped", + [ + 155526 + ] + ], + [ + [ + 194924, + 194924 + ], + "mapped", + [ + 32099 + ] + ], + [ + [ + 194925, + 194925 + ], + "mapped", + [ + 17153 + ] + ], + [ + [ + 194926, + 194926 + ], + "mapped", + [ + 32199 + ] + ], + [ + [ + 194927, + 194927 + ], + "mapped", + [ + 32258 + ] + ], + [ + [ + 194928, + 194928 + ], + "mapped", + [ + 32325 + ] + ], + [ + [ + 194929, + 194929 + ], + "mapped", + [ + 17204 + ] + ], + [ + [ + 194930, + 194930 + ], + "mapped", + [ + 156200 + ] + ], + [ + [ + 194931, + 194931 + ], + "mapped", + [ + 156231 + ] + ], + [ + [ + 194932, + 194932 + ], + "mapped", + [ + 17241 + ] + ], + [ + [ + 194933, + 194933 + ], + "mapped", + [ + 156377 + ] + ], + [ + [ + 194934, + 194934 + ], + "mapped", + [ + 32634 + ] + ], + [ + [ + 194935, + 194935 + ], + "mapped", + [ + 156478 + ] + ], + [ + [ + 194936, + 194936 + ], + "mapped", + [ + 32661 + ] + ], + [ + [ + 194937, + 194937 + ], + "mapped", + [ + 32762 + ] + ], + [ + [ + 194938, + 194938 + ], + "mapped", + [ + 32773 + ] + ], + [ + [ + 194939, + 194939 + ], + "mapped", + [ + 156890 + ] + ], + [ + [ + 194940, + 194940 + ], + "mapped", + [ + 156963 + ] + ], + [ + [ + 194941, + 194941 + ], + "mapped", + [ + 32864 + ] + ], + [ + [ + 194942, + 194942 + ], + "mapped", + [ + 157096 + ] + ], + [ + [ + 194943, + 194943 + ], + "mapped", + [ + 32880 + ] + ], + [ + [ + 194944, + 194944 + ], + "mapped", + [ + 144223 + ] + ], + [ + [ + 194945, + 194945 + ], + "mapped", + [ + 17365 + ] + ], + [ + [ + 194946, + 194946 + ], + "mapped", + [ + 32946 + ] + ], + [ + [ + 194947, + 194947 + ], + "mapped", + [ + 33027 + ] + ], + [ + [ + 194948, + 194948 + ], + "mapped", + [ + 17419 + ] + ], + [ + [ + 194949, + 194949 + ], + "mapped", + [ + 33086 + ] + ], + [ + [ + 194950, + 194950 + ], + "mapped", + [ + 23221 + ] + ], + [ + [ + 194951, + 194951 + ], + "mapped", + [ + 157607 + ] + ], + [ + [ + 194952, + 194952 + ], + "mapped", + [ + 157621 + ] + ], + [ + [ + 194953, + 194953 + ], + "mapped", + [ + 144275 + ] + ], + [ + [ + 194954, + 194954 + ], + "mapped", + [ + 144284 + ] + ], + [ + [ + 194955, + 194955 + ], + "mapped", + [ + 33281 + ] + ], + [ + [ + 194956, + 194956 + ], + "mapped", + [ + 33284 + ] + ], + [ + [ + 194957, + 194957 + ], + "mapped", + [ + 36766 + ] + ], + [ + [ + 194958, + 194958 + ], + "mapped", + [ + 17515 + ] + ], + [ + [ + 194959, + 194959 + ], + "mapped", + [ + 33425 + ] + ], + [ + [ + 194960, + 194960 + ], + "mapped", + [ + 33419 + ] + ], + [ + [ + 194961, + 194961 + ], + "mapped", + [ + 33437 + ] + ], + [ + [ + 194962, + 194962 + ], + "mapped", + [ + 21171 + ] + ], + [ + [ + 194963, + 194963 + ], + "mapped", + [ + 33457 + ] + ], + [ + [ + 194964, + 194964 + ], + "mapped", + [ + 33459 + ] + ], + [ + [ + 194965, + 194965 + ], + "mapped", + [ + 33469 + ] + ], + [ + [ + 194966, + 194966 + ], + "mapped", + [ + 33510 + ] + ], + [ + [ + 194967, + 194967 + ], + "mapped", + [ + 158524 + ] + ], + [ + [ + 194968, + 194968 + ], + "mapped", + [ + 33509 + ] + ], + [ + [ + 194969, + 194969 + ], + "mapped", + [ + 33565 + ] + ], + [ + [ + 194970, + 194970 + ], + "mapped", + [ + 33635 + ] + ], + [ + [ + 194971, + 194971 + ], + "mapped", + [ + 33709 + ] + ], + [ + [ + 194972, + 194972 + ], + "mapped", + [ + 33571 + ] + ], + [ + [ + 194973, + 194973 + ], + "mapped", + [ + 33725 + ] + ], + [ + [ + 194974, + 194974 + ], + "mapped", + [ + 33767 + ] + ], + [ + [ + 194975, + 194975 + ], + "mapped", + [ + 33879 + ] + ], + [ + [ + 194976, + 194976 + ], + "mapped", + [ + 33619 + ] + ], + [ + [ + 194977, + 194977 + ], + "mapped", + [ + 33738 + ] + ], + [ + [ + 194978, + 194978 + ], + "mapped", + [ + 33740 + ] + ], + [ + [ + 194979, + 194979 + ], + "mapped", + [ + 33756 + ] + ], + [ + [ + 194980, + 194980 + ], + "mapped", + [ + 158774 + ] + ], + [ + [ + 194981, + 194981 + ], + "mapped", + [ + 159083 + ] + ], + [ + [ + 194982, + 194982 + ], + "mapped", + [ + 158933 + ] + ], + [ + [ + 194983, + 194983 + ], + "mapped", + [ + 17707 + ] + ], + [ + [ + 194984, + 194984 + ], + "mapped", + [ + 34033 + ] + ], + [ + [ + 194985, + 194985 + ], + "mapped", + [ + 34035 + ] + ], + [ + [ + 194986, + 194986 + ], + "mapped", + [ + 34070 + ] + ], + [ + [ + 194987, + 194987 + ], + "mapped", + [ + 160714 + ] + ], + [ + [ + 194988, + 194988 + ], + "mapped", + [ + 34148 + ] + ], + [ + [ + 194989, + 194989 + ], + "mapped", + [ + 159532 + ] + ], + [ + [ + 194990, + 194990 + ], + "mapped", + [ + 17757 + ] + ], + [ + [ + 194991, + 194991 + ], + "mapped", + [ + 17761 + ] + ], + [ + [ + 194992, + 194992 + ], + "mapped", + [ + 159665 + ] + ], + [ + [ + 194993, + 194993 + ], + "mapped", + [ + 159954 + ] + ], + [ + [ + 194994, + 194994 + ], + "mapped", + [ + 17771 + ] + ], + [ + [ + 194995, + 194995 + ], + "mapped", + [ + 34384 + ] + ], + [ + [ + 194996, + 194996 + ], + "mapped", + [ + 34396 + ] + ], + [ + [ + 194997, + 194997 + ], + "mapped", + [ + 34407 + ] + ], + [ + [ + 194998, + 194998 + ], + "mapped", + [ + 34409 + ] + ], + [ + [ + 194999, + 194999 + ], + "mapped", + [ + 34473 + ] + ], + [ + [ + 195000, + 195000 + ], + "mapped", + [ + 34440 + ] + ], + [ + [ + 195001, + 195001 + ], + "mapped", + [ + 34574 + ] + ], + [ + [ + 195002, + 195002 + ], + "mapped", + [ + 34530 + ] + ], + [ + [ + 195003, + 195003 + ], + "mapped", + [ + 34681 + ] + ], + [ + [ + 195004, + 195004 + ], + "mapped", + [ + 34600 + ] + ], + [ + [ + 195005, + 195005 + ], + "mapped", + [ + 34667 + ] + ], + [ + [ + 195006, + 195006 + ], + "mapped", + [ + 34694 + ] + ], + [ + [ + 195007, + 195007 + ], + "disallowed" + ], + [ + [ + 195008, + 195008 + ], + "mapped", + [ + 34785 + ] + ], + [ + [ + 195009, + 195009 + ], + "mapped", + [ + 34817 + ] + ], + [ + [ + 195010, + 195010 + ], + "mapped", + [ + 17913 + ] + ], + [ + [ + 195011, + 195011 + ], + "mapped", + [ + 34912 + ] + ], + [ + [ + 195012, + 195012 + ], + "mapped", + [ + 34915 + ] + ], + [ + [ + 195013, + 195013 + ], + "mapped", + [ + 161383 + ] + ], + [ + [ + 195014, + 195014 + ], + "mapped", + [ + 35031 + ] + ], + [ + [ + 195015, + 195015 + ], + "mapped", + [ + 35038 + ] + ], + [ + [ + 195016, + 195016 + ], + "mapped", + [ + 17973 + ] + ], + [ + [ + 195017, + 195017 + ], + "mapped", + [ + 35066 + ] + ], + [ + [ + 195018, + 195018 + ], + "mapped", + [ + 13499 + ] + ], + [ + [ + 195019, + 195019 + ], + "mapped", + [ + 161966 + ] + ], + [ + [ + 195020, + 195020 + ], + "mapped", + [ + 162150 + ] + ], + [ + [ + 195021, + 195021 + ], + "mapped", + [ + 18110 + ] + ], + [ + [ + 195022, + 195022 + ], + "mapped", + [ + 18119 + ] + ], + [ + [ + 195023, + 195023 + ], + "mapped", + [ + 35488 + ] + ], + [ + [ + 195024, + 195024 + ], + "mapped", + [ + 35565 + ] + ], + [ + [ + 195025, + 195025 + ], + "mapped", + [ + 35722 + ] + ], + [ + [ + 195026, + 195026 + ], + "mapped", + [ + 35925 + ] + ], + [ + [ + 195027, + 195027 + ], + "mapped", + [ + 162984 + ] + ], + [ + [ + 195028, + 195028 + ], + "mapped", + [ + 36011 + ] + ], + [ + [ + 195029, + 195029 + ], + "mapped", + [ + 36033 + ] + ], + [ + [ + 195030, + 195030 + ], + "mapped", + [ + 36123 + ] + ], + [ + [ + 195031, + 195031 + ], + "mapped", + [ + 36215 + ] + ], + [ + [ + 195032, + 195032 + ], + "mapped", + [ + 163631 + ] + ], + [ + [ + 195033, + 195033 + ], + "mapped", + [ + 133124 + ] + ], + [ + [ + 195034, + 195034 + ], + "mapped", + [ + 36299 + ] + ], + [ + [ + 195035, + 195035 + ], + "mapped", + [ + 36284 + ] + ], + [ + [ + 195036, + 195036 + ], + "mapped", + [ + 36336 + ] + ], + [ + [ + 195037, + 195037 + ], + "mapped", + [ + 133342 + ] + ], + [ + [ + 195038, + 195038 + ], + "mapped", + [ + 36564 + ] + ], + [ + [ + 195039, + 195039 + ], + "mapped", + [ + 36664 + ] + ], + [ + [ + 195040, + 195040 + ], + "mapped", + [ + 165330 + ] + ], + [ + [ + 195041, + 195041 + ], + "mapped", + [ + 165357 + ] + ], + [ + [ + 195042, + 195042 + ], + "mapped", + [ + 37012 + ] + ], + [ + [ + 195043, + 195043 + ], + "mapped", + [ + 37105 + ] + ], + [ + [ + 195044, + 195044 + ], + "mapped", + [ + 37137 + ] + ], + [ + [ + 195045, + 195045 + ], + "mapped", + [ + 165678 + ] + ], + [ + [ + 195046, + 195046 + ], + "mapped", + [ + 37147 + ] + ], + [ + [ + 195047, + 195047 + ], + "mapped", + [ + 37432 + ] + ], + [ + [ + 195048, + 195048 + ], + "mapped", + [ + 37591 + ] + ], + [ + [ + 195049, + 195049 + ], + "mapped", + [ + 37592 + ] + ], + [ + [ + 195050, + 195050 + ], + "mapped", + [ + 37500 + ] + ], + [ + [ + 195051, + 195051 + ], + "mapped", + [ + 37881 + ] + ], + [ + [ + 195052, + 195052 + ], + "mapped", + [ + 37909 + ] + ], + [ + [ + 195053, + 195053 + ], + "mapped", + [ + 166906 + ] + ], + [ + [ + 195054, + 195054 + ], + "mapped", + [ + 38283 + ] + ], + [ + [ + 195055, + 195055 + ], + "mapped", + [ + 18837 + ] + ], + [ + [ + 195056, + 195056 + ], + "mapped", + [ + 38327 + ] + ], + [ + [ + 195057, + 195057 + ], + "mapped", + [ + 167287 + ] + ], + [ + [ + 195058, + 195058 + ], + "mapped", + [ + 18918 + ] + ], + [ + [ + 195059, + 195059 + ], + "mapped", + [ + 38595 + ] + ], + [ + [ + 195060, + 195060 + ], + "mapped", + [ + 23986 + ] + ], + [ + [ + 195061, + 195061 + ], + "mapped", + [ + 38691 + ] + ], + [ + [ + 195062, + 195062 + ], + "mapped", + [ + 168261 + ] + ], + [ + [ + 195063, + 195063 + ], + "mapped", + [ + 168474 + ] + ], + [ + [ + 195064, + 195064 + ], + "mapped", + [ + 19054 + ] + ], + [ + [ + 195065, + 195065 + ], + "mapped", + [ + 19062 + ] + ], + [ + [ + 195066, + 195066 + ], + "mapped", + [ + 38880 + ] + ], + [ + [ + 195067, + 195067 + ], + "mapped", + [ + 168970 + ] + ], + [ + [ + 195068, + 195068 + ], + "mapped", + [ + 19122 + ] + ], + [ + [ + 195069, + 195069 + ], + "mapped", + [ + 169110 + ] + ], + [ + [ + 195070, + 195071 + ], + "mapped", + [ + 38923 + ] + ], + [ + [ + 195072, + 195072 + ], + "mapped", + [ + 38953 + ] + ], + [ + [ + 195073, + 195073 + ], + "mapped", + [ + 169398 + ] + ], + [ + [ + 195074, + 195074 + ], + "mapped", + [ + 39138 + ] + ], + [ + [ + 195075, + 195075 + ], + "mapped", + [ + 19251 + ] + ], + [ + [ + 195076, + 195076 + ], + "mapped", + [ + 39209 + ] + ], + [ + [ + 195077, + 195077 + ], + "mapped", + [ + 39335 + ] + ], + [ + [ + 195078, + 195078 + ], + "mapped", + [ + 39362 + ] + ], + [ + [ + 195079, + 195079 + ], + "mapped", + [ + 39422 + ] + ], + [ + [ + 195080, + 195080 + ], + "mapped", + [ + 19406 + ] + ], + [ + [ + 195081, + 195081 + ], + "mapped", + [ + 170800 + ] + ], + [ + [ + 195082, + 195082 + ], + "mapped", + [ + 39698 + ] + ], + [ + [ + 195083, + 195083 + ], + "mapped", + [ + 40000 + ] + ], + [ + [ + 195084, + 195084 + ], + "mapped", + [ + 40189 + ] + ], + [ + [ + 195085, + 195085 + ], + "mapped", + [ + 19662 + ] + ], + [ + [ + 195086, + 195086 + ], + "mapped", + [ + 19693 + ] + ], + [ + [ + 195087, + 195087 + ], + "mapped", + [ + 40295 + ] + ], + [ + [ + 195088, + 195088 + ], + "mapped", + [ + 172238 + ] + ], + [ + [ + 195089, + 195089 + ], + "mapped", + [ + 19704 + ] + ], + [ + [ + 195090, + 195090 + ], + "mapped", + [ + 172293 + ] + ], + [ + [ + 195091, + 195091 + ], + "mapped", + [ + 172558 + ] + ], + [ + [ + 195092, + 195092 + ], + "mapped", + [ + 172689 + ] + ], + [ + [ + 195093, + 195093 + ], + "mapped", + [ + 40635 + ] + ], + [ + [ + 195094, + 195094 + ], + "mapped", + [ + 19798 + ] + ], + [ + [ + 195095, + 195095 + ], + "mapped", + [ + 40697 + ] + ], + [ + [ + 195096, + 195096 + ], + "mapped", + [ + 40702 + ] + ], + [ + [ + 195097, + 195097 + ], + "mapped", + [ + 40709 + ] + ], + [ + [ + 195098, + 195098 + ], + "mapped", + [ + 40719 + ] + ], + [ + [ + 195099, + 195099 + ], + "mapped", + [ + 40726 + ] + ], + [ + [ + 195100, + 195100 + ], + "mapped", + [ + 40763 + ] + ], + [ + [ + 195101, + 195101 + ], + "mapped", + [ + 173568 + ] + ], + [ + [ + 195102, + 196605 + ], + "disallowed" + ], + [ + [ + 196606, + 196607 + ], + "disallowed" + ], + [ + [ + 196608, + 262141 + ], + "disallowed" + ], + [ + [ + 262142, + 262143 + ], + "disallowed" + ], + [ + [ + 262144, + 327677 + ], + "disallowed" + ], + [ + [ + 327678, + 327679 + ], + "disallowed" + ], + [ + [ + 327680, + 393213 + ], + "disallowed" + ], + [ + [ + 393214, + 393215 + ], + "disallowed" + ], + [ + [ + 393216, + 458749 + ], + "disallowed" + ], + [ + [ + 458750, + 458751 + ], + "disallowed" + ], + [ + [ + 458752, + 524285 + ], + "disallowed" + ], + [ + [ + 524286, + 524287 + ], + "disallowed" + ], + [ + [ + 524288, + 589821 + ], + "disallowed" + ], + [ + [ + 589822, + 589823 + ], + "disallowed" + ], + [ + [ + 589824, + 655357 + ], + "disallowed" + ], + [ + [ + 655358, + 655359 + ], + "disallowed" + ], + [ + [ + 655360, + 720893 + ], + "disallowed" + ], + [ + [ + 720894, + 720895 + ], + "disallowed" + ], + [ + [ + 720896, + 786429 + ], + "disallowed" + ], + [ + [ + 786430, + 786431 + ], + "disallowed" + ], + [ + [ + 786432, + 851965 + ], + "disallowed" + ], + [ + [ + 851966, + 851967 + ], + "disallowed" + ], + [ + [ + 851968, + 917501 + ], + "disallowed" + ], + [ + [ + 917502, + 917503 + ], + "disallowed" + ], + [ + [ + 917504, + 917504 + ], + "disallowed" + ], + [ + [ + 917505, + 917505 + ], + "disallowed" + ], + [ + [ + 917506, + 917535 + ], + "disallowed" + ], + [ + [ + 917536, + 917631 + ], + "disallowed" + ], + [ + [ + 917632, + 917759 + ], + "disallowed" + ], + [ + [ + 917760, + 917999 + ], + "ignored" + ], + [ + [ + 918000, + 983037 + ], + "disallowed" + ], + [ + [ + 983038, + 983039 + ], + "disallowed" + ], + [ + [ + 983040, + 1048573 + ], + "disallowed" + ], + [ + [ + 1048574, + 1048575 + ], + "disallowed" + ], + [ + [ + 1048576, + 1114109 + ], + "disallowed" + ], + [ + [ + 1114110, + 1114111 + ], + "disallowed" + ] +]; + +var punycode = require$$0$5; +var mappingTable = require$$1; + +var PROCESSING_OPTIONS = { + TRANSITIONAL: 0, + NONTRANSITIONAL: 1 +}; + +function normalize(str) { // fix bug in v8 + return str.split('\u0000').map(function (s) { return s.normalize('NFC'); }).join('\u0000'); +} + +function findStatus(val) { + var start = 0; + var end = mappingTable.length - 1; + + while (start <= end) { + var mid = Math.floor((start + end) / 2); + + var target = mappingTable[mid]; + if (target[0][0] <= val && target[0][1] >= val) { + return target; + } else if (target[0][0] > val) { + end = mid - 1; + } else { + start = mid + 1; + } + } + + return null; +} + +var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; + +function countSymbols(string) { + return string + // replace every surrogate pair with a BMP symbol + .replace(regexAstralSymbols, '_') + // then get the length + .length; +} + +function mapChars(domain_name, useSTD3, processing_option) { + var hasError = false; + var processed = ""; + + var len = countSymbols(domain_name); + for (var i = 0; i < len; ++i) { + var codePoint = domain_name.codePointAt(i); + var status = findStatus(codePoint); + + switch (status[1]) { + case "disallowed": + hasError = true; + processed += String.fromCodePoint(codePoint); + break; + case "ignored": + break; + case "mapped": + processed += String.fromCodePoint.apply(String, status[2]); + break; + case "deviation": + if (processing_option === PROCESSING_OPTIONS.TRANSITIONAL) { + processed += String.fromCodePoint.apply(String, status[2]); + } else { + processed += String.fromCodePoint(codePoint); + } + break; + case "valid": + processed += String.fromCodePoint(codePoint); + break; + case "disallowed_STD3_mapped": + if (useSTD3) { + hasError = true; + processed += String.fromCodePoint(codePoint); + } else { + processed += String.fromCodePoint.apply(String, status[2]); + } + break; + case "disallowed_STD3_valid": + if (useSTD3) { + hasError = true; + } + + processed += String.fromCodePoint(codePoint); + break; + } + } + + return { + string: processed, + error: hasError + }; +} + +var combiningMarksRegex = /[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08E4-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C03\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D01-\u0D03\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u18A9\u1920-\u192B\u1930-\u193B\u19B0-\u19C0\u19C8\u19C9\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF8\u1CF9\u1DC0-\u1DF5\u1DFC-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C4\uA8E0-\uA8F1\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2D]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC7F-\uDC82\uDCB0-\uDCBA\uDD00-\uDD02\uDD27-\uDD34\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDE2C-\uDE37\uDEDF-\uDEEA\uDF01-\uDF03\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDE30-\uDE40\uDEAB-\uDEB7]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF51-\uDF7E\uDF8F-\uDF92]|\uD82F[\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD83A[\uDCD0-\uDCD6]|\uDB40[\uDD00-\uDDEF]/; + +function validateLabel(label, processing_option) { + if (label.substr(0, 4) === "xn--") { + label = punycode.toUnicode(label); + PROCESSING_OPTIONS.NONTRANSITIONAL; + } + + var error = false; + + if (normalize(label) !== label || + (label[3] === "-" && label[4] === "-") || + label[0] === "-" || label[label.length - 1] === "-" || + label.indexOf(".") !== -1 || + label.search(combiningMarksRegex) === 0) { + error = true; + } + + var len = countSymbols(label); + for (var i = 0; i < len; ++i) { + var status = findStatus(label.codePointAt(i)); + if ((processing === PROCESSING_OPTIONS.TRANSITIONAL && status[1] !== "valid") || + (processing === PROCESSING_OPTIONS.NONTRANSITIONAL && + status[1] !== "valid" && status[1] !== "deviation")) { + error = true; + break; + } + } + + return { + label: label, + error: error + }; +} + +function processing(domain_name, useSTD3, processing_option) { + var result = mapChars(domain_name, useSTD3, processing_option); + result.string = normalize(result.string); + + var labels = result.string.split("."); + for (var i = 0; i < labels.length; ++i) { + try { + var validation = validateLabel(labels[i]); + labels[i] = validation.label; + result.error = result.error || validation.error; + } catch(e) { + result.error = true; + } + } + + return { + string: labels.join("."), + error: result.error + }; +} + +tr46.toASCII = function(domain_name, useSTD3, processing_option, verifyDnsLength) { + var result = processing(domain_name, useSTD3, processing_option); + var labels = result.string.split("."); + labels = labels.map(function(l) { + try { + return punycode.toASCII(l); + } catch(e) { + result.error = true; + return l; + } + }); + + if (verifyDnsLength) { + var total = labels.slice(0, labels.length - 1).join(".").length; + if (total.length > 253 || total.length === 0) { + result.error = true; + } + + for (var i=0; i < labels.length; ++i) { + if (labels.length > 63 || labels.length === 0) { + result.error = true; + break; + } + } + } + + if (result.error) return null; + return labels.join("."); +}; + +tr46.toUnicode = function(domain_name, useSTD3) { + var result = processing(domain_name, useSTD3, PROCESSING_OPTIONS.NONTRANSITIONAL); + + return { + domain: result.string, + error: result.error + }; +}; + +tr46.PROCESSING_OPTIONS = PROCESSING_OPTIONS; + +(function (module) { + const punycode = require$$0$5; + const tr46$1 = tr46; + + const specialSchemes = { + ftp: 21, + file: null, + gopher: 70, + http: 80, + https: 443, + ws: 80, + wss: 443 + }; + + const failure = Symbol("failure"); + + function countSymbols(str) { + return punycode.ucs2.decode(str).length; + } + + function at(input, idx) { + const c = input[idx]; + return isNaN(c) ? undefined : String.fromCodePoint(c); + } + + function isASCIIDigit(c) { + return c >= 0x30 && c <= 0x39; + } + + function isASCIIAlpha(c) { + return (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A); + } + + function isASCIIAlphanumeric(c) { + return isASCIIAlpha(c) || isASCIIDigit(c); + } + + function isASCIIHex(c) { + return isASCIIDigit(c) || (c >= 0x41 && c <= 0x46) || (c >= 0x61 && c <= 0x66); + } + + function isSingleDot(buffer) { + return buffer === "." || buffer.toLowerCase() === "%2e"; + } + + function isDoubleDot(buffer) { + buffer = buffer.toLowerCase(); + return buffer === ".." || buffer === "%2e." || buffer === ".%2e" || buffer === "%2e%2e"; + } + + function isWindowsDriveLetterCodePoints(cp1, cp2) { + return isASCIIAlpha(cp1) && (cp2 === 58 || cp2 === 124); + } + + function isWindowsDriveLetterString(string) { + return string.length === 2 && isASCIIAlpha(string.codePointAt(0)) && (string[1] === ":" || string[1] === "|"); + } + + function isNormalizedWindowsDriveLetterString(string) { + return string.length === 2 && isASCIIAlpha(string.codePointAt(0)) && string[1] === ":"; + } + + function containsForbiddenHostCodePoint(string) { + return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|\?|@|\[|\\|\]/) !== -1; + } + + function containsForbiddenHostCodePointExcludingPercent(string) { + return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|\?|@|\[|\\|\]/) !== -1; + } + + function isSpecialScheme(scheme) { + return specialSchemes[scheme] !== undefined; + } + + function isSpecial(url) { + return isSpecialScheme(url.scheme); + } + + function defaultPort(scheme) { + return specialSchemes[scheme]; + } + + function percentEncode(c) { + let hex = c.toString(16).toUpperCase(); + if (hex.length === 1) { + hex = "0" + hex; + } + + return "%" + hex; + } + + function utf8PercentEncode(c) { + const buf = new Buffer(c); + + let str = ""; + + for (let i = 0; i < buf.length; ++i) { + str += percentEncode(buf[i]); + } + + return str; + } + + function utf8PercentDecode(str) { + const input = new Buffer(str); + const output = []; + for (let i = 0; i < input.length; ++i) { + if (input[i] !== 37) { + output.push(input[i]); + } else if (input[i] === 37 && isASCIIHex(input[i + 1]) && isASCIIHex(input[i + 2])) { + output.push(parseInt(input.slice(i + 1, i + 3).toString(), 16)); + i += 2; + } else { + output.push(input[i]); + } + } + return new Buffer(output).toString(); + } + + function isC0ControlPercentEncode(c) { + return c <= 0x1F || c > 0x7E; + } + + const extraPathPercentEncodeSet = new Set([32, 34, 35, 60, 62, 63, 96, 123, 125]); + function isPathPercentEncode(c) { + return isC0ControlPercentEncode(c) || extraPathPercentEncodeSet.has(c); + } + + const extraUserinfoPercentEncodeSet = + new Set([47, 58, 59, 61, 64, 91, 92, 93, 94, 124]); + function isUserinfoPercentEncode(c) { + return isPathPercentEncode(c) || extraUserinfoPercentEncodeSet.has(c); + } + + function percentEncodeChar(c, encodeSetPredicate) { + const cStr = String.fromCodePoint(c); + + if (encodeSetPredicate(c)) { + return utf8PercentEncode(cStr); + } + + return cStr; + } + + function parseIPv4Number(input) { + let R = 10; + + if (input.length >= 2 && input.charAt(0) === "0" && input.charAt(1).toLowerCase() === "x") { + input = input.substring(2); + R = 16; + } else if (input.length >= 2 && input.charAt(0) === "0") { + input = input.substring(1); + R = 8; + } + + if (input === "") { + return 0; + } + + const regex = R === 10 ? /[^0-9]/ : (R === 16 ? /[^0-9A-Fa-f]/ : /[^0-7]/); + if (regex.test(input)) { + return failure; + } + + return parseInt(input, R); + } + + function parseIPv4(input) { + const parts = input.split("."); + if (parts[parts.length - 1] === "") { + if (parts.length > 1) { + parts.pop(); + } + } + + if (parts.length > 4) { + return input; + } + + const numbers = []; + for (const part of parts) { + if (part === "") { + return input; + } + const n = parseIPv4Number(part); + if (n === failure) { + return input; + } + + numbers.push(n); + } + + for (let i = 0; i < numbers.length - 1; ++i) { + if (numbers[i] > 255) { + return failure; + } + } + if (numbers[numbers.length - 1] >= Math.pow(256, 5 - numbers.length)) { + return failure; + } + + let ipv4 = numbers.pop(); + let counter = 0; + + for (const n of numbers) { + ipv4 += n * Math.pow(256, 3 - counter); + ++counter; + } + + return ipv4; + } + + function serializeIPv4(address) { + let output = ""; + let n = address; + + for (let i = 1; i <= 4; ++i) { + output = String(n % 256) + output; + if (i !== 4) { + output = "." + output; + } + n = Math.floor(n / 256); + } + + return output; + } + + function parseIPv6(input) { + const address = [0, 0, 0, 0, 0, 0, 0, 0]; + let pieceIndex = 0; + let compress = null; + let pointer = 0; + + input = punycode.ucs2.decode(input); + + if (input[pointer] === 58) { + if (input[pointer + 1] !== 58) { + return failure; + } + + pointer += 2; + ++pieceIndex; + compress = pieceIndex; + } + + while (pointer < input.length) { + if (pieceIndex === 8) { + return failure; + } + + if (input[pointer] === 58) { + if (compress !== null) { + return failure; + } + ++pointer; + ++pieceIndex; + compress = pieceIndex; + continue; + } + + let value = 0; + let length = 0; + + while (length < 4 && isASCIIHex(input[pointer])) { + value = value * 0x10 + parseInt(at(input, pointer), 16); + ++pointer; + ++length; + } + + if (input[pointer] === 46) { + if (length === 0) { + return failure; + } + + pointer -= length; + + if (pieceIndex > 6) { + return failure; + } + + let numbersSeen = 0; + + while (input[pointer] !== undefined) { + let ipv4Piece = null; + + if (numbersSeen > 0) { + if (input[pointer] === 46 && numbersSeen < 4) { + ++pointer; + } else { + return failure; + } + } + + if (!isASCIIDigit(input[pointer])) { + return failure; + } + + while (isASCIIDigit(input[pointer])) { + const number = parseInt(at(input, pointer)); + if (ipv4Piece === null) { + ipv4Piece = number; + } else if (ipv4Piece === 0) { + return failure; + } else { + ipv4Piece = ipv4Piece * 10 + number; + } + if (ipv4Piece > 255) { + return failure; + } + ++pointer; + } + + address[pieceIndex] = address[pieceIndex] * 0x100 + ipv4Piece; + + ++numbersSeen; + + if (numbersSeen === 2 || numbersSeen === 4) { + ++pieceIndex; + } + } + + if (numbersSeen !== 4) { + return failure; + } + + break; + } else if (input[pointer] === 58) { + ++pointer; + if (input[pointer] === undefined) { + return failure; + } + } else if (input[pointer] !== undefined) { + return failure; + } + + address[pieceIndex] = value; + ++pieceIndex; + } + + if (compress !== null) { + let swaps = pieceIndex - compress; + pieceIndex = 7; + while (pieceIndex !== 0 && swaps > 0) { + const temp = address[compress + swaps - 1]; + address[compress + swaps - 1] = address[pieceIndex]; + address[pieceIndex] = temp; + --pieceIndex; + --swaps; + } + } else if (compress === null && pieceIndex !== 8) { + return failure; + } + + return address; + } + + function serializeIPv6(address) { + let output = ""; + const seqResult = findLongestZeroSequence(address); + const compress = seqResult.idx; + let ignore0 = false; + + for (let pieceIndex = 0; pieceIndex <= 7; ++pieceIndex) { + if (ignore0 && address[pieceIndex] === 0) { + continue; + } else if (ignore0) { + ignore0 = false; + } + + if (compress === pieceIndex) { + const separator = pieceIndex === 0 ? "::" : ":"; + output += separator; + ignore0 = true; + continue; + } + + output += address[pieceIndex].toString(16); + + if (pieceIndex !== 7) { + output += ":"; + } + } + + return output; + } + + function parseHost(input, isSpecialArg) { + if (input[0] === "[") { + if (input[input.length - 1] !== "]") { + return failure; + } + + return parseIPv6(input.substring(1, input.length - 1)); + } + + if (!isSpecialArg) { + return parseOpaqueHost(input); + } + + const domain = utf8PercentDecode(input); + const asciiDomain = tr46$1.toASCII(domain, false, tr46$1.PROCESSING_OPTIONS.NONTRANSITIONAL, false); + if (asciiDomain === null) { + return failure; + } + + if (containsForbiddenHostCodePoint(asciiDomain)) { + return failure; + } + + const ipv4Host = parseIPv4(asciiDomain); + if (typeof ipv4Host === "number" || ipv4Host === failure) { + return ipv4Host; + } + + return asciiDomain; + } + + function parseOpaqueHost(input) { + if (containsForbiddenHostCodePointExcludingPercent(input)) { + return failure; + } + + let output = ""; + const decoded = punycode.ucs2.decode(input); + for (let i = 0; i < decoded.length; ++i) { + output += percentEncodeChar(decoded[i], isC0ControlPercentEncode); + } + return output; + } + + function findLongestZeroSequence(arr) { + let maxIdx = null; + let maxLen = 1; // only find elements > 1 + let currStart = null; + let currLen = 0; + + for (let i = 0; i < arr.length; ++i) { + if (arr[i] !== 0) { + if (currLen > maxLen) { + maxIdx = currStart; + maxLen = currLen; + } + + currStart = null; + currLen = 0; + } else { + if (currStart === null) { + currStart = i; + } + ++currLen; + } + } + + // if trailing zeros + if (currLen > maxLen) { + maxIdx = currStart; + maxLen = currLen; + } + + return { + idx: maxIdx, + len: maxLen + }; + } + + function serializeHost(host) { + if (typeof host === "number") { + return serializeIPv4(host); + } + + // IPv6 serializer + if (host instanceof Array) { + return "[" + serializeIPv6(host) + "]"; + } + + return host; + } + + function trimControlChars(url) { + return url.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/g, ""); + } + + function trimTabAndNewline(url) { + return url.replace(/\u0009|\u000A|\u000D/g, ""); + } + + function shortenPath(url) { + const path = url.path; + if (path.length === 0) { + return; + } + if (url.scheme === "file" && path.length === 1 && isNormalizedWindowsDriveLetter(path[0])) { + return; + } + + path.pop(); + } + + function includesCredentials(url) { + return url.username !== "" || url.password !== ""; + } + + function cannotHaveAUsernamePasswordPort(url) { + return url.host === null || url.host === "" || url.cannotBeABaseURL || url.scheme === "file"; + } + + function isNormalizedWindowsDriveLetter(string) { + return /^[A-Za-z]:$/.test(string); + } + + function URLStateMachine(input, base, encodingOverride, url, stateOverride) { + this.pointer = 0; + this.input = input; + this.base = base || null; + this.encodingOverride = encodingOverride || "utf-8"; + this.stateOverride = stateOverride; + this.url = url; + this.failure = false; + this.parseError = false; + + if (!this.url) { + this.url = { + scheme: "", + username: "", + password: "", + host: null, + port: null, + path: [], + query: null, + fragment: null, + + cannotBeABaseURL: false + }; + + const res = trimControlChars(this.input); + if (res !== this.input) { + this.parseError = true; + } + this.input = res; + } + + const res = trimTabAndNewline(this.input); + if (res !== this.input) { + this.parseError = true; + } + this.input = res; + + this.state = stateOverride || "scheme start"; + + this.buffer = ""; + this.atFlag = false; + this.arrFlag = false; + this.passwordTokenSeenFlag = false; + + this.input = punycode.ucs2.decode(this.input); + + for (; this.pointer <= this.input.length; ++this.pointer) { + const c = this.input[this.pointer]; + const cStr = isNaN(c) ? undefined : String.fromCodePoint(c); + + // exec state machine + const ret = this["parse " + this.state](c, cStr); + if (!ret) { + break; // terminate algorithm + } else if (ret === failure) { + this.failure = true; + break; + } + } + } + + URLStateMachine.prototype["parse scheme start"] = function parseSchemeStart(c, cStr) { + if (isASCIIAlpha(c)) { + this.buffer += cStr.toLowerCase(); + this.state = "scheme"; + } else if (!this.stateOverride) { + this.state = "no scheme"; + --this.pointer; + } else { + this.parseError = true; + return failure; + } + + return true; + }; + + URLStateMachine.prototype["parse scheme"] = function parseScheme(c, cStr) { + if (isASCIIAlphanumeric(c) || c === 43 || c === 45 || c === 46) { + this.buffer += cStr.toLowerCase(); + } else if (c === 58) { + if (this.stateOverride) { + if (isSpecial(this.url) && !isSpecialScheme(this.buffer)) { + return false; + } + + if (!isSpecial(this.url) && isSpecialScheme(this.buffer)) { + return false; + } + + if ((includesCredentials(this.url) || this.url.port !== null) && this.buffer === "file") { + return false; + } + + if (this.url.scheme === "file" && (this.url.host === "" || this.url.host === null)) { + return false; + } + } + this.url.scheme = this.buffer; + this.buffer = ""; + if (this.stateOverride) { + return false; + } + if (this.url.scheme === "file") { + if (this.input[this.pointer + 1] !== 47 || this.input[this.pointer + 2] !== 47) { + this.parseError = true; + } + this.state = "file"; + } else if (isSpecial(this.url) && this.base !== null && this.base.scheme === this.url.scheme) { + this.state = "special relative or authority"; + } else if (isSpecial(this.url)) { + this.state = "special authority slashes"; + } else if (this.input[this.pointer + 1] === 47) { + this.state = "path or authority"; + ++this.pointer; + } else { + this.url.cannotBeABaseURL = true; + this.url.path.push(""); + this.state = "cannot-be-a-base-URL path"; + } + } else if (!this.stateOverride) { + this.buffer = ""; + this.state = "no scheme"; + this.pointer = -1; + } else { + this.parseError = true; + return failure; + } + + return true; + }; + + URLStateMachine.prototype["parse no scheme"] = function parseNoScheme(c) { + if (this.base === null || (this.base.cannotBeABaseURL && c !== 35)) { + return failure; + } else if (this.base.cannotBeABaseURL && c === 35) { + this.url.scheme = this.base.scheme; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + this.url.fragment = ""; + this.url.cannotBeABaseURL = true; + this.state = "fragment"; + } else if (this.base.scheme === "file") { + this.state = "file"; + --this.pointer; + } else { + this.state = "relative"; + --this.pointer; + } + + return true; + }; + + URLStateMachine.prototype["parse special relative or authority"] = function parseSpecialRelativeOrAuthority(c) { + if (c === 47 && this.input[this.pointer + 1] === 47) { + this.state = "special authority ignore slashes"; + ++this.pointer; + } else { + this.parseError = true; + this.state = "relative"; + --this.pointer; + } + + return true; + }; + + URLStateMachine.prototype["parse path or authority"] = function parsePathOrAuthority(c) { + if (c === 47) { + this.state = "authority"; + } else { + this.state = "path"; + --this.pointer; + } + + return true; + }; + + URLStateMachine.prototype["parse relative"] = function parseRelative(c) { + this.url.scheme = this.base.scheme; + if (isNaN(c)) { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + } else if (c === 47) { + this.state = "relative slash"; + } else if (c === 63) { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.url.path = this.base.path.slice(); + this.url.query = ""; + this.state = "query"; + } else if (c === 35) { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + this.url.fragment = ""; + this.state = "fragment"; + } else if (isSpecial(this.url) && c === 92) { + this.parseError = true; + this.state = "relative slash"; + } else { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.url.path = this.base.path.slice(0, this.base.path.length - 1); + + this.state = "path"; + --this.pointer; + } + + return true; + }; + + URLStateMachine.prototype["parse relative slash"] = function parseRelativeSlash(c) { + if (isSpecial(this.url) && (c === 47 || c === 92)) { + if (c === 92) { + this.parseError = true; + } + this.state = "special authority ignore slashes"; + } else if (c === 47) { + this.state = "authority"; + } else { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.state = "path"; + --this.pointer; + } + + return true; + }; + + URLStateMachine.prototype["parse special authority slashes"] = function parseSpecialAuthoritySlashes(c) { + if (c === 47 && this.input[this.pointer + 1] === 47) { + this.state = "special authority ignore slashes"; + ++this.pointer; + } else { + this.parseError = true; + this.state = "special authority ignore slashes"; + --this.pointer; + } + + return true; + }; + + URLStateMachine.prototype["parse special authority ignore slashes"] = function parseSpecialAuthorityIgnoreSlashes(c) { + if (c !== 47 && c !== 92) { + this.state = "authority"; + --this.pointer; + } else { + this.parseError = true; + } + + return true; + }; + + URLStateMachine.prototype["parse authority"] = function parseAuthority(c, cStr) { + if (c === 64) { + this.parseError = true; + if (this.atFlag) { + this.buffer = "%40" + this.buffer; + } + this.atFlag = true; + + // careful, this is based on buffer and has its own pointer (this.pointer != pointer) and inner chars + const len = countSymbols(this.buffer); + for (let pointer = 0; pointer < len; ++pointer) { + const codePoint = this.buffer.codePointAt(pointer); + + if (codePoint === 58 && !this.passwordTokenSeenFlag) { + this.passwordTokenSeenFlag = true; + continue; + } + const encodedCodePoints = percentEncodeChar(codePoint, isUserinfoPercentEncode); + if (this.passwordTokenSeenFlag) { + this.url.password += encodedCodePoints; + } else { + this.url.username += encodedCodePoints; + } + } + this.buffer = ""; + } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || + (isSpecial(this.url) && c === 92)) { + if (this.atFlag && this.buffer === "") { + this.parseError = true; + return failure; + } + this.pointer -= countSymbols(this.buffer) + 1; + this.buffer = ""; + this.state = "host"; + } else { + this.buffer += cStr; + } + + return true; + }; + + URLStateMachine.prototype["parse hostname"] = + URLStateMachine.prototype["parse host"] = function parseHostName(c, cStr) { + if (this.stateOverride && this.url.scheme === "file") { + --this.pointer; + this.state = "file host"; + } else if (c === 58 && !this.arrFlag) { + if (this.buffer === "") { + this.parseError = true; + return failure; + } + + const host = parseHost(this.buffer, isSpecial(this.url)); + if (host === failure) { + return failure; + } + + this.url.host = host; + this.buffer = ""; + this.state = "port"; + if (this.stateOverride === "hostname") { + return false; + } + } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || + (isSpecial(this.url) && c === 92)) { + --this.pointer; + if (isSpecial(this.url) && this.buffer === "") { + this.parseError = true; + return failure; + } else if (this.stateOverride && this.buffer === "" && + (includesCredentials(this.url) || this.url.port !== null)) { + this.parseError = true; + return false; + } + + const host = parseHost(this.buffer, isSpecial(this.url)); + if (host === failure) { + return failure; + } + + this.url.host = host; + this.buffer = ""; + this.state = "path start"; + if (this.stateOverride) { + return false; + } + } else { + if (c === 91) { + this.arrFlag = true; + } else if (c === 93) { + this.arrFlag = false; + } + this.buffer += cStr; + } + + return true; + }; + + URLStateMachine.prototype["parse port"] = function parsePort(c, cStr) { + if (isASCIIDigit(c)) { + this.buffer += cStr; + } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || + (isSpecial(this.url) && c === 92) || + this.stateOverride) { + if (this.buffer !== "") { + const port = parseInt(this.buffer); + if (port > Math.pow(2, 16) - 1) { + this.parseError = true; + return failure; + } + this.url.port = port === defaultPort(this.url.scheme) ? null : port; + this.buffer = ""; + } + if (this.stateOverride) { + return false; + } + this.state = "path start"; + --this.pointer; + } else { + this.parseError = true; + return failure; + } + + return true; + }; + + const fileOtherwiseCodePoints = new Set([47, 92, 63, 35]); + + URLStateMachine.prototype["parse file"] = function parseFile(c) { + this.url.scheme = "file"; + + if (c === 47 || c === 92) { + if (c === 92) { + this.parseError = true; + } + this.state = "file slash"; + } else if (this.base !== null && this.base.scheme === "file") { + if (isNaN(c)) { + this.url.host = this.base.host; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + } else if (c === 63) { + this.url.host = this.base.host; + this.url.path = this.base.path.slice(); + this.url.query = ""; + this.state = "query"; + } else if (c === 35) { + this.url.host = this.base.host; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + this.url.fragment = ""; + this.state = "fragment"; + } else { + if (this.input.length - this.pointer - 1 === 0 || // remaining consists of 0 code points + !isWindowsDriveLetterCodePoints(c, this.input[this.pointer + 1]) || + (this.input.length - this.pointer - 1 >= 2 && // remaining has at least 2 code points + !fileOtherwiseCodePoints.has(this.input[this.pointer + 2]))) { + this.url.host = this.base.host; + this.url.path = this.base.path.slice(); + shortenPath(this.url); + } else { + this.parseError = true; + } + + this.state = "path"; + --this.pointer; + } + } else { + this.state = "path"; + --this.pointer; + } + + return true; + }; + + URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) { + if (c === 47 || c === 92) { + if (c === 92) { + this.parseError = true; + } + this.state = "file host"; + } else { + if (this.base !== null && this.base.scheme === "file") { + if (isNormalizedWindowsDriveLetterString(this.base.path[0])) { + this.url.path.push(this.base.path[0]); + } else { + this.url.host = this.base.host; + } + } + this.state = "path"; + --this.pointer; + } + + return true; + }; + + URLStateMachine.prototype["parse file host"] = function parseFileHost(c, cStr) { + if (isNaN(c) || c === 47 || c === 92 || c === 63 || c === 35) { + --this.pointer; + if (!this.stateOverride && isWindowsDriveLetterString(this.buffer)) { + this.parseError = true; + this.state = "path"; + } else if (this.buffer === "") { + this.url.host = ""; + if (this.stateOverride) { + return false; + } + this.state = "path start"; + } else { + let host = parseHost(this.buffer, isSpecial(this.url)); + if (host === failure) { + return failure; + } + if (host === "localhost") { + host = ""; + } + this.url.host = host; + + if (this.stateOverride) { + return false; + } + + this.buffer = ""; + this.state = "path start"; + } + } else { + this.buffer += cStr; + } + + return true; + }; + + URLStateMachine.prototype["parse path start"] = function parsePathStart(c) { + if (isSpecial(this.url)) { + if (c === 92) { + this.parseError = true; + } + this.state = "path"; + + if (c !== 47 && c !== 92) { + --this.pointer; + } + } else if (!this.stateOverride && c === 63) { + this.url.query = ""; + this.state = "query"; + } else if (!this.stateOverride && c === 35) { + this.url.fragment = ""; + this.state = "fragment"; + } else if (c !== undefined) { + this.state = "path"; + if (c !== 47) { + --this.pointer; + } + } + + return true; + }; + + URLStateMachine.prototype["parse path"] = function parsePath(c) { + if (isNaN(c) || c === 47 || (isSpecial(this.url) && c === 92) || + (!this.stateOverride && (c === 63 || c === 35))) { + if (isSpecial(this.url) && c === 92) { + this.parseError = true; + } + + if (isDoubleDot(this.buffer)) { + shortenPath(this.url); + if (c !== 47 && !(isSpecial(this.url) && c === 92)) { + this.url.path.push(""); + } + } else if (isSingleDot(this.buffer) && c !== 47 && + !(isSpecial(this.url) && c === 92)) { + this.url.path.push(""); + } else if (!isSingleDot(this.buffer)) { + if (this.url.scheme === "file" && this.url.path.length === 0 && isWindowsDriveLetterString(this.buffer)) { + if (this.url.host !== "" && this.url.host !== null) { + this.parseError = true; + this.url.host = ""; + } + this.buffer = this.buffer[0] + ":"; + } + this.url.path.push(this.buffer); + } + this.buffer = ""; + if (this.url.scheme === "file" && (c === undefined || c === 63 || c === 35)) { + while (this.url.path.length > 1 && this.url.path[0] === "") { + this.parseError = true; + this.url.path.shift(); + } + } + if (c === 63) { + this.url.query = ""; + this.state = "query"; + } + if (c === 35) { + this.url.fragment = ""; + this.state = "fragment"; + } + } else { + // TODO: If c is not a URL code point and not "%", parse error. + + if (c === 37 && + (!isASCIIHex(this.input[this.pointer + 1]) || + !isASCIIHex(this.input[this.pointer + 2]))) { + this.parseError = true; + } + + this.buffer += percentEncodeChar(c, isPathPercentEncode); + } + + return true; + }; + + URLStateMachine.prototype["parse cannot-be-a-base-URL path"] = function parseCannotBeABaseURLPath(c) { + if (c === 63) { + this.url.query = ""; + this.state = "query"; + } else if (c === 35) { + this.url.fragment = ""; + this.state = "fragment"; + } else { + // TODO: Add: not a URL code point + if (!isNaN(c) && c !== 37) { + this.parseError = true; + } + + if (c === 37 && + (!isASCIIHex(this.input[this.pointer + 1]) || + !isASCIIHex(this.input[this.pointer + 2]))) { + this.parseError = true; + } + + if (!isNaN(c)) { + this.url.path[0] = this.url.path[0] + percentEncodeChar(c, isC0ControlPercentEncode); + } + } + + return true; + }; + + URLStateMachine.prototype["parse query"] = function parseQuery(c, cStr) { + if (isNaN(c) || (!this.stateOverride && c === 35)) { + if (!isSpecial(this.url) || this.url.scheme === "ws" || this.url.scheme === "wss") { + this.encodingOverride = "utf-8"; + } + + const buffer = new Buffer(this.buffer); // TODO: Use encoding override instead + for (let i = 0; i < buffer.length; ++i) { + if (buffer[i] < 0x21 || buffer[i] > 0x7E || buffer[i] === 0x22 || buffer[i] === 0x23 || + buffer[i] === 0x3C || buffer[i] === 0x3E) { + this.url.query += percentEncode(buffer[i]); + } else { + this.url.query += String.fromCodePoint(buffer[i]); + } + } + + this.buffer = ""; + if (c === 35) { + this.url.fragment = ""; + this.state = "fragment"; + } + } else { + // TODO: If c is not a URL code point and not "%", parse error. + if (c === 37 && + (!isASCIIHex(this.input[this.pointer + 1]) || + !isASCIIHex(this.input[this.pointer + 2]))) { + this.parseError = true; + } + + this.buffer += cStr; + } + + return true; + }; + + URLStateMachine.prototype["parse fragment"] = function parseFragment(c) { + if (isNaN(c)) ; else if (c === 0x0) { + this.parseError = true; + } else { + // TODO: If c is not a URL code point and not "%", parse error. + if (c === 37 && + (!isASCIIHex(this.input[this.pointer + 1]) || + !isASCIIHex(this.input[this.pointer + 2]))) { + this.parseError = true; + } + + this.url.fragment += percentEncodeChar(c, isC0ControlPercentEncode); + } + + return true; + }; + + function serializeURL(url, excludeFragment) { + let output = url.scheme + ":"; + if (url.host !== null) { + output += "//"; + + if (url.username !== "" || url.password !== "") { + output += url.username; + if (url.password !== "") { + output += ":" + url.password; + } + output += "@"; + } + + output += serializeHost(url.host); + + if (url.port !== null) { + output += ":" + url.port; + } + } else if (url.host === null && url.scheme === "file") { + output += "//"; + } + + if (url.cannotBeABaseURL) { + output += url.path[0]; + } else { + for (const string of url.path) { + output += "/" + string; + } + } + + if (url.query !== null) { + output += "?" + url.query; + } + + if (!excludeFragment && url.fragment !== null) { + output += "#" + url.fragment; + } + + return output; + } + + function serializeOrigin(tuple) { + let result = tuple.scheme + "://"; + result += serializeHost(tuple.host); + + if (tuple.port !== null) { + result += ":" + tuple.port; + } + + return result; + } + + module.exports.serializeURL = serializeURL; + + module.exports.serializeURLOrigin = function (url) { + // https://url.spec.whatwg.org/#concept-url-origin + switch (url.scheme) { + case "blob": + try { + return module.exports.serializeURLOrigin(module.exports.parseURL(url.path[0])); + } catch (e) { + // serializing an opaque origin returns "null" + return "null"; + } + case "ftp": + case "gopher": + case "http": + case "https": + case "ws": + case "wss": + return serializeOrigin({ + scheme: url.scheme, + host: url.host, + port: url.port + }); + case "file": + // spec says "exercise to the reader", chrome says "file://" + return "file://"; + default: + // serializing an opaque origin returns "null" + return "null"; + } + }; + + module.exports.basicURLParse = function (input, options) { + if (options === undefined) { + options = {}; + } + + const usm = new URLStateMachine(input, options.baseURL, options.encodingOverride, options.url, options.stateOverride); + if (usm.failure) { + return "failure"; + } + + return usm.url; + }; + + module.exports.setTheUsername = function (url, username) { + url.username = ""; + const decoded = punycode.ucs2.decode(username); + for (let i = 0; i < decoded.length; ++i) { + url.username += percentEncodeChar(decoded[i], isUserinfoPercentEncode); + } + }; + + module.exports.setThePassword = function (url, password) { + url.password = ""; + const decoded = punycode.ucs2.decode(password); + for (let i = 0; i < decoded.length; ++i) { + url.password += percentEncodeChar(decoded[i], isUserinfoPercentEncode); + } + }; + + module.exports.serializeHost = serializeHost; + + module.exports.cannotHaveAUsernamePasswordPort = cannotHaveAUsernamePasswordPort; + + module.exports.serializeInteger = function (integer) { + return String(integer); + }; + + module.exports.parseURL = function (input, options) { + if (options === undefined) { + options = {}; + } + + // We don't handle blobs, so this just delegates: + return module.exports.basicURLParse(input, { baseURL: options.baseURL, encodingOverride: options.encodingOverride }); + }; +} (urlStateMachine)); + +var urlStateMachineExports = urlStateMachine.exports; + +const usm = urlStateMachineExports; + +URLImpl.implementation = class URLImpl { + constructor(constructorArgs) { + const url = constructorArgs[0]; + const base = constructorArgs[1]; + + let parsedBase = null; + if (base !== undefined) { + parsedBase = usm.basicURLParse(base); + if (parsedBase === "failure") { + throw new TypeError("Invalid base URL"); + } + } + + const parsedURL = usm.basicURLParse(url, { baseURL: parsedBase }); + if (parsedURL === "failure") { + throw new TypeError("Invalid URL"); + } + + this._url = parsedURL; + + // TODO: query stuff + } + + get href() { + return usm.serializeURL(this._url); + } + + set href(v) { + const parsedURL = usm.basicURLParse(v); + if (parsedURL === "failure") { + throw new TypeError("Invalid URL"); + } + + this._url = parsedURL; + } + + get origin() { + return usm.serializeURLOrigin(this._url); + } + + get protocol() { + return this._url.scheme + ":"; + } + + set protocol(v) { + usm.basicURLParse(v + ":", { url: this._url, stateOverride: "scheme start" }); + } + + get username() { + return this._url.username; + } + + set username(v) { + if (usm.cannotHaveAUsernamePasswordPort(this._url)) { + return; + } + + usm.setTheUsername(this._url, v); + } + + get password() { + return this._url.password; + } + + set password(v) { + if (usm.cannotHaveAUsernamePasswordPort(this._url)) { + return; + } + + usm.setThePassword(this._url, v); + } + + get host() { + const url = this._url; + + if (url.host === null) { + return ""; + } + + if (url.port === null) { + return usm.serializeHost(url.host); + } + + return usm.serializeHost(url.host) + ":" + usm.serializeInteger(url.port); + } + + set host(v) { + if (this._url.cannotBeABaseURL) { + return; + } + + usm.basicURLParse(v, { url: this._url, stateOverride: "host" }); + } + + get hostname() { + if (this._url.host === null) { + return ""; + } + + return usm.serializeHost(this._url.host); + } + + set hostname(v) { + if (this._url.cannotBeABaseURL) { + return; + } + + usm.basicURLParse(v, { url: this._url, stateOverride: "hostname" }); + } + + get port() { + if (this._url.port === null) { + return ""; + } + + return usm.serializeInteger(this._url.port); + } + + set port(v) { + if (usm.cannotHaveAUsernamePasswordPort(this._url)) { + return; + } + + if (v === "") { + this._url.port = null; + } else { + usm.basicURLParse(v, { url: this._url, stateOverride: "port" }); + } + } + + get pathname() { + if (this._url.cannotBeABaseURL) { + return this._url.path[0]; + } + + if (this._url.path.length === 0) { + return ""; + } + + return "/" + this._url.path.join("/"); + } + + set pathname(v) { + if (this._url.cannotBeABaseURL) { + return; + } + + this._url.path = []; + usm.basicURLParse(v, { url: this._url, stateOverride: "path start" }); + } + + get search() { + if (this._url.query === null || this._url.query === "") { + return ""; + } + + return "?" + this._url.query; + } + + set search(v) { + // TODO: query stuff + + const url = this._url; + + if (v === "") { + url.query = null; + return; + } + + const input = v[0] === "?" ? v.substring(1) : v; + url.query = ""; + usm.basicURLParse(input, { url, stateOverride: "query" }); + } + + get hash() { + if (this._url.fragment === null || this._url.fragment === "") { + return ""; + } + + return "#" + this._url.fragment; + } + + set hash(v) { + if (v === "") { + this._url.fragment = null; + return; + } + + const input = v[0] === "#" ? v.substring(1) : v; + this._url.fragment = ""; + usm.basicURLParse(input, { url: this._url, stateOverride: "fragment" }); + } + + toJSON() { + return this.href; + } +}; + +(function (module) { + + const conversions = lib$3; + const utils = utilsExports; + const Impl = URLImpl; + + const impl = utils.implSymbol; + + function URL(url) { + if (!this || this[impl] || !(this instanceof URL)) { + throw new TypeError("Failed to construct 'URL': Please use the 'new' operator, this DOM object constructor cannot be called as a function."); + } + if (arguments.length < 1) { + throw new TypeError("Failed to construct 'URL': 1 argument required, but only " + arguments.length + " present."); + } + const args = []; + for (let i = 0; i < arguments.length && i < 2; ++i) { + args[i] = arguments[i]; + } + args[0] = conversions["USVString"](args[0]); + if (args[1] !== undefined) { + args[1] = conversions["USVString"](args[1]); + } + + module.exports.setup(this, args); + } + + URL.prototype.toJSON = function toJSON() { + if (!this || !module.exports.is(this)) { + throw new TypeError("Illegal invocation"); + } + const args = []; + for (let i = 0; i < arguments.length && i < 0; ++i) { + args[i] = arguments[i]; + } + return this[impl].toJSON.apply(this[impl], args); + }; + Object.defineProperty(URL.prototype, "href", { + get() { + return this[impl].href; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].href = V; + }, + enumerable: true, + configurable: true + }); + + URL.prototype.toString = function () { + if (!this || !module.exports.is(this)) { + throw new TypeError("Illegal invocation"); + } + return this.href; + }; + + Object.defineProperty(URL.prototype, "origin", { + get() { + return this[impl].origin; + }, + enumerable: true, + configurable: true + }); + + Object.defineProperty(URL.prototype, "protocol", { + get() { + return this[impl].protocol; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].protocol = V; + }, + enumerable: true, + configurable: true + }); + + Object.defineProperty(URL.prototype, "username", { + get() { + return this[impl].username; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].username = V; + }, + enumerable: true, + configurable: true + }); + + Object.defineProperty(URL.prototype, "password", { + get() { + return this[impl].password; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].password = V; + }, + enumerable: true, + configurable: true + }); + + Object.defineProperty(URL.prototype, "host", { + get() { + return this[impl].host; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].host = V; + }, + enumerable: true, + configurable: true + }); + + Object.defineProperty(URL.prototype, "hostname", { + get() { + return this[impl].hostname; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].hostname = V; + }, + enumerable: true, + configurable: true + }); + + Object.defineProperty(URL.prototype, "port", { + get() { + return this[impl].port; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].port = V; + }, + enumerable: true, + configurable: true + }); + + Object.defineProperty(URL.prototype, "pathname", { + get() { + return this[impl].pathname; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].pathname = V; + }, + enumerable: true, + configurable: true + }); + + Object.defineProperty(URL.prototype, "search", { + get() { + return this[impl].search; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].search = V; + }, + enumerable: true, + configurable: true + }); + + Object.defineProperty(URL.prototype, "hash", { + get() { + return this[impl].hash; + }, + set(V) { + V = conversions["USVString"](V); + this[impl].hash = V; + }, + enumerable: true, + configurable: true + }); + + + module.exports = { + is(obj) { + return !!obj && obj[impl] instanceof Impl.implementation; + }, + create(constructorArgs, privateData) { + let obj = Object.create(URL.prototype); + this.setup(obj, constructorArgs, privateData); + return obj; + }, + setup(obj, constructorArgs, privateData) { + if (!privateData) privateData = {}; + privateData.wrapper = obj; + + obj[impl] = new Impl.implementation(constructorArgs, privateData); + obj[impl][utils.wrapperSymbol] = obj; + }, + interface: URL, + expose: { + Window: { URL: URL }, + Worker: { URL: URL } + } + }; +} (URL$2)); + +var URLExports = URL$2.exports; + +publicApi.URL = URLExports.interface; +publicApi.serializeURL = urlStateMachineExports.serializeURL; +publicApi.serializeURLOrigin = urlStateMachineExports.serializeURLOrigin; +publicApi.basicURLParse = urlStateMachineExports.basicURLParse; +publicApi.setTheUsername = urlStateMachineExports.setTheUsername; +publicApi.setThePassword = urlStateMachineExports.setThePassword; +publicApi.serializeHost = urlStateMachineExports.serializeHost; +publicApi.serializeInteger = urlStateMachineExports.serializeInteger; +publicApi.parseURL = urlStateMachineExports.parseURL; + +// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js + +// fix for "Readable" isn't a named export issue +const Readable = Stream.Readable; + +const BUFFER = Symbol('buffer'); +const TYPE = Symbol('type'); + +let Blob$1 = class Blob { + constructor() { + this[TYPE] = ''; + + const blobParts = arguments[0]; + const options = arguments[1]; + + const buffers = []; + let size = 0; + + if (blobParts) { + const a = blobParts; + const length = Number(a.length); + for (let i = 0; i < length; i++) { + const element = a[i]; + let buffer; + if (element instanceof Buffer) { + buffer = element; + } else if (ArrayBuffer.isView(element)) { + buffer = Buffer.from(element.buffer, element.byteOffset, element.byteLength); + } else if (element instanceof ArrayBuffer) { + buffer = Buffer.from(element); + } else if (element instanceof Blob) { + buffer = element[BUFFER]; + } else { + buffer = Buffer.from(typeof element === 'string' ? element : String(element)); + } + size += buffer.length; + buffers.push(buffer); + } + } + + this[BUFFER] = Buffer.concat(buffers); + + let type = options && options.type !== undefined && String(options.type).toLowerCase(); + if (type && !/[^\u0020-\u007E]/.test(type)) { + this[TYPE] = type; + } + } + get size() { + return this[BUFFER].length; + } + get type() { + return this[TYPE]; + } + text() { + return Promise.resolve(this[BUFFER].toString()); + } + arrayBuffer() { + const buf = this[BUFFER]; + const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + return Promise.resolve(ab); + } + stream() { + const readable = new Readable(); + readable._read = function () {}; + readable.push(this[BUFFER]); + readable.push(null); + return readable; + } + toString() { + return '[object Blob]'; + } + slice() { + const size = this.size; + + const start = arguments[0]; + const end = arguments[1]; + let relativeStart, relativeEnd; + if (start === undefined) { + relativeStart = 0; + } else if (start < 0) { + relativeStart = Math.max(size + start, 0); + } else { + relativeStart = Math.min(start, size); + } + if (end === undefined) { + relativeEnd = size; + } else if (end < 0) { + relativeEnd = Math.max(size + end, 0); + } else { + relativeEnd = Math.min(end, size); + } + const span = Math.max(relativeEnd - relativeStart, 0); + + const buffer = this[BUFFER]; + const slicedBuffer = buffer.slice(relativeStart, relativeStart + span); + const blob = new Blob([], { type: arguments[2] }); + blob[BUFFER] = slicedBuffer; + return blob; + } +}; + +Object.defineProperties(Blob$1.prototype, { + size: { enumerable: true }, + type: { enumerable: true }, + slice: { enumerable: true } +}); + +Object.defineProperty(Blob$1.prototype, Symbol.toStringTag, { + value: 'Blob', + writable: false, + enumerable: false, + configurable: true +}); + +/** + * fetch-error.js + * + * FetchError interface for operational errors + */ + +/** + * Create FetchError instance + * + * @param String message Error message for human + * @param String type Error type for machine + * @param String systemError For Node.js system error + * @return FetchError + */ +function FetchError(message, type, systemError) { + Error.call(this, message); + + this.message = message; + this.type = type; + + // when err.type is `system`, err.code contains system error code + if (systemError) { + this.code = this.errno = systemError.code; + } + + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} + +FetchError.prototype = Object.create(Error.prototype); +FetchError.prototype.constructor = FetchError; +FetchError.prototype.name = 'FetchError'; + +let convert; +try { + convert = require('encoding').convert; +} catch (e) {} + +const INTERNALS = Symbol('Body internals'); + +// fix an issue where "PassThrough" isn't a named export for node <10 +const PassThrough = Stream.PassThrough; + +/** + * Body mixin + * + * Ref: https://fetch.spec.whatwg.org/#body + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +function Body(body) { + var _this = this; + + var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, + _ref$size = _ref.size; + + let size = _ref$size === undefined ? 0 : _ref$size; + var _ref$timeout = _ref.timeout; + let timeout = _ref$timeout === undefined ? 0 : _ref$timeout; + + if (body == null) { + // body is undefined or null + body = null; + } else if (isURLSearchParams(body)) { + // body is a URLSearchParams + body = Buffer.from(body.toString()); + } else if (isBlob(body)) ; else if (Buffer.isBuffer(body)) ; else if (Object.prototype.toString.call(body) === '[object ArrayBuffer]') { + // body is ArrayBuffer + body = Buffer.from(body); + } else if (ArrayBuffer.isView(body)) { + // body is ArrayBufferView + body = Buffer.from(body.buffer, body.byteOffset, body.byteLength); + } else if (body instanceof Stream) ; else { + // none of the above + // coerce to string then buffer + body = Buffer.from(String(body)); + } + this[INTERNALS] = { + body, + disturbed: false, + error: null + }; + this.size = size; + this.timeout = timeout; + + if (body instanceof Stream) { + body.on('error', function (err) { + const error = err.name === 'AbortError' ? err : new FetchError(`Invalid response body while trying to fetch ${_this.url}: ${err.message}`, 'system', err); + _this[INTERNALS].error = error; + }); + } +} + +Body.prototype = { + get body() { + return this[INTERNALS].body; + }, + + get bodyUsed() { + return this[INTERNALS].disturbed; + }, + + /** + * Decode response as ArrayBuffer + * + * @return Promise + */ + arrayBuffer() { + return consumeBody.call(this).then(function (buf) { + return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); + }); + }, + + /** + * Return raw response as Blob + * + * @return Promise + */ + blob() { + let ct = this.headers && this.headers.get('content-type') || ''; + return consumeBody.call(this).then(function (buf) { + return Object.assign( + // Prevent copying + new Blob$1([], { + type: ct.toLowerCase() + }), { + [BUFFER]: buf + }); + }); + }, + + /** + * Decode response as json + * + * @return Promise + */ + json() { + var _this2 = this; + + return consumeBody.call(this).then(function (buffer) { + try { + return JSON.parse(buffer.toString()); + } catch (err) { + return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json')); + } + }); + }, + + /** + * Decode response as text + * + * @return Promise + */ + text() { + return consumeBody.call(this).then(function (buffer) { + return buffer.toString(); + }); + }, + + /** + * Decode response as buffer (non-spec api) + * + * @return Promise + */ + buffer() { + return consumeBody.call(this); + }, + + /** + * Decode response as text, while automatically detecting the encoding and + * trying to decode to UTF-8 (non-spec api) + * + * @return Promise + */ + textConverted() { + var _this3 = this; + + return consumeBody.call(this).then(function (buffer) { + return convertBody(buffer, _this3.headers); + }); + } +}; + +// In browsers, all properties are enumerable. +Object.defineProperties(Body.prototype, { + body: { enumerable: true }, + bodyUsed: { enumerable: true }, + arrayBuffer: { enumerable: true }, + blob: { enumerable: true }, + json: { enumerable: true }, + text: { enumerable: true } +}); + +Body.mixIn = function (proto) { + for (const name of Object.getOwnPropertyNames(Body.prototype)) { + // istanbul ignore else: future proof + if (!(name in proto)) { + const desc = Object.getOwnPropertyDescriptor(Body.prototype, name); + Object.defineProperty(proto, name, desc); + } + } +}; + +/** + * Consume and convert an entire Body to a Buffer. + * + * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body + * + * @return Promise + */ +function consumeBody() { + var _this4 = this; + + if (this[INTERNALS].disturbed) { + return Body.Promise.reject(new TypeError(`body used already for: ${this.url}`)); + } + + this[INTERNALS].disturbed = true; + + if (this[INTERNALS].error) { + return Body.Promise.reject(this[INTERNALS].error); + } + + let body = this.body; + + // body is null + if (body === null) { + return Body.Promise.resolve(Buffer.alloc(0)); + } + + // body is blob + if (isBlob(body)) { + body = body.stream(); + } + + // body is buffer + if (Buffer.isBuffer(body)) { + return Body.Promise.resolve(body); + } + + // istanbul ignore if: should never happen + if (!(body instanceof Stream)) { + return Body.Promise.resolve(Buffer.alloc(0)); + } + + // body is stream + // get ready to actually consume the body + let accum = []; + let accumBytes = 0; + let abort = false; + + return new Body.Promise(function (resolve, reject) { + let resTimeout; + + // allow timeout on slow response body + if (_this4.timeout) { + resTimeout = setTimeout(function () { + abort = true; + reject(new FetchError(`Response timeout while trying to fetch ${_this4.url} (over ${_this4.timeout}ms)`, 'body-timeout')); + }, _this4.timeout); + } + + // handle stream errors + body.on('error', function (err) { + if (err.name === 'AbortError') { + // if the request was aborted, reject with this Error + abort = true; + reject(err); + } else { + // other errors, such as incorrect content-encoding + reject(new FetchError(`Invalid response body while trying to fetch ${_this4.url}: ${err.message}`, 'system', err)); + } + }); + + body.on('data', function (chunk) { + if (abort || chunk === null) { + return; + } + + if (_this4.size && accumBytes + chunk.length > _this4.size) { + abort = true; + reject(new FetchError(`content size at ${_this4.url} over limit: ${_this4.size}`, 'max-size')); + return; + } + + accumBytes += chunk.length; + accum.push(chunk); + }); + + body.on('end', function () { + if (abort) { + return; + } + + clearTimeout(resTimeout); + + try { + resolve(Buffer.concat(accum, accumBytes)); + } catch (err) { + // handle streams that have accumulated too much data (issue #414) + reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, 'system', err)); + } + }); + }); +} + +/** + * Detect buffer encoding and convert to target encoding + * ref: http://www.w3.org/TR/2011/WD-html5-20110113/parsing.html#determining-the-character-encoding + * + * @param Buffer buffer Incoming buffer + * @param String encoding Target encoding + * @return String + */ +function convertBody(buffer, headers) { + if (typeof convert !== 'function') { + throw new Error('The package `encoding` must be installed to use the textConverted() function'); + } + + const ct = headers.get('content-type'); + let charset = 'utf-8'; + let res, str; + + // header + if (ct) { + res = /charset=([^;]*)/i.exec(ct); + } + + // no charset in content type, peek at response body for at most 1024 bytes + str = buffer.slice(0, 1024).toString(); + + // html5 + if (!res && str) { + res = / 0 && arguments[0] !== undefined ? arguments[0] : undefined; + + this[MAP] = Object.create(null); + + if (init instanceof Headers) { + const rawHeaders = init.raw(); + const headerNames = Object.keys(rawHeaders); + + for (const headerName of headerNames) { + for (const value of rawHeaders[headerName]) { + this.append(headerName, value); + } + } + + return; + } + + // We don't worry about converting prop to ByteString here as append() + // will handle it. + if (init == null) ; else if (typeof init === 'object') { + const method = init[Symbol.iterator]; + if (method != null) { + if (typeof method !== 'function') { + throw new TypeError('Header pairs must be iterable'); + } + + // sequence> + // Note: per spec we have to first exhaust the lists then process them + const pairs = []; + for (const pair of init) { + if (typeof pair !== 'object' || typeof pair[Symbol.iterator] !== 'function') { + throw new TypeError('Each header pair must be iterable'); + } + pairs.push(Array.from(pair)); + } + + for (const pair of pairs) { + if (pair.length !== 2) { + throw new TypeError('Each header pair must be a name/value tuple'); + } + this.append(pair[0], pair[1]); + } + } else { + // record + for (const key of Object.keys(init)) { + const value = init[key]; + this.append(key, value); + } + } + } else { + throw new TypeError('Provided initializer must be an object'); + } + } + + /** + * Return combined header value given name + * + * @param String name Header name + * @return Mixed + */ + get(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key === undefined) { + return null; + } + + return this[MAP][key].join(', '); + } + + /** + * Iterate over all headers + * + * @param Function callback Executed for each item with parameters (value, name, thisArg) + * @param Boolean thisArg `this` context for callback function + * @return Void + */ + forEach(callback) { + let thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; + + let pairs = getHeaders(this); + let i = 0; + while (i < pairs.length) { + var _pairs$i = pairs[i]; + const name = _pairs$i[0], + value = _pairs$i[1]; + + callback.call(thisArg, value, name, this); + pairs = getHeaders(this); + i++; + } + } + + /** + * Overwrite header values given name + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + set(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + this[MAP][key !== undefined ? key : name] = [value]; + } + + /** + * Append a value onto existing header + * + * @param String name Header name + * @param String value Header value + * @return Void + */ + append(name, value) { + name = `${name}`; + value = `${value}`; + validateName(name); + validateValue(value); + const key = find(this[MAP], name); + if (key !== undefined) { + this[MAP][key].push(value); + } else { + this[MAP][name] = [value]; + } + } + + /** + * Check for header name existence + * + * @param String name Header name + * @return Boolean + */ + has(name) { + name = `${name}`; + validateName(name); + return find(this[MAP], name) !== undefined; + } + + /** + * Delete all header values given name + * + * @param String name Header name + * @return Void + */ + delete(name) { + name = `${name}`; + validateName(name); + const key = find(this[MAP], name); + if (key !== undefined) { + delete this[MAP][key]; + } + } + + /** + * Return raw headers (non-spec api) + * + * @return Object + */ + raw() { + return this[MAP]; + } + + /** + * Get an iterator on keys. + * + * @return Iterator + */ + keys() { + return createHeadersIterator(this, 'key'); + } + + /** + * Get an iterator on values. + * + * @return Iterator + */ + values() { + return createHeadersIterator(this, 'value'); + } + + /** + * Get an iterator on entries. + * + * This is the default iterator of the Headers object. + * + * @return Iterator + */ + [Symbol.iterator]() { + return createHeadersIterator(this, 'key+value'); + } +} +Headers.prototype.entries = Headers.prototype[Symbol.iterator]; + +Object.defineProperty(Headers.prototype, Symbol.toStringTag, { + value: 'Headers', + writable: false, + enumerable: false, + configurable: true +}); + +Object.defineProperties(Headers.prototype, { + get: { enumerable: true }, + forEach: { enumerable: true }, + set: { enumerable: true }, + append: { enumerable: true }, + has: { enumerable: true }, + delete: { enumerable: true }, + keys: { enumerable: true }, + values: { enumerable: true }, + entries: { enumerable: true } +}); + +function getHeaders(headers) { + let kind = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key+value'; + + const keys = Object.keys(headers[MAP]).sort(); + return keys.map(kind === 'key' ? function (k) { + return k.toLowerCase(); + } : kind === 'value' ? function (k) { + return headers[MAP][k].join(', '); + } : function (k) { + return [k.toLowerCase(), headers[MAP][k].join(', ')]; + }); +} + +const INTERNAL = Symbol('internal'); + +function createHeadersIterator(target, kind) { + const iterator = Object.create(HeadersIteratorPrototype); + iterator[INTERNAL] = { + target, + kind, + index: 0 + }; + return iterator; +} + +const HeadersIteratorPrototype = Object.setPrototypeOf({ + next() { + // istanbul ignore if + if (!this || Object.getPrototypeOf(this) !== HeadersIteratorPrototype) { + throw new TypeError('Value of `this` is not a HeadersIterator'); + } + + var _INTERNAL = this[INTERNAL]; + const target = _INTERNAL.target, + kind = _INTERNAL.kind, + index = _INTERNAL.index; + + const values = getHeaders(target, kind); + const len = values.length; + if (index >= len) { + return { + value: undefined, + done: true + }; + } + + this[INTERNAL].index = index + 1; + + return { + value: values[index], + done: false + }; + } +}, Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))); + +Object.defineProperty(HeadersIteratorPrototype, Symbol.toStringTag, { + value: 'HeadersIterator', + writable: false, + enumerable: false, + configurable: true +}); + +/** + * Export the Headers object in a form that Node.js can consume. + * + * @param Headers headers + * @return Object + */ +function exportNodeCompatibleHeaders(headers) { + const obj = Object.assign({ __proto__: null }, headers[MAP]); + + // http.request() only supports string as Host header. This hack makes + // specifying custom Host header possible. + const hostHeaderKey = find(headers[MAP], 'Host'); + if (hostHeaderKey !== undefined) { + obj[hostHeaderKey] = obj[hostHeaderKey][0]; + } + + return obj; +} + +/** + * Create a Headers object from an object of headers, ignoring those that do + * not conform to HTTP grammar productions. + * + * @param Object obj Object of headers + * @return Headers + */ +function createHeadersLenient(obj) { + const headers = new Headers(); + for (const name of Object.keys(obj)) { + if (invalidTokenRegex.test(name)) { + continue; + } + if (Array.isArray(obj[name])) { + for (const val of obj[name]) { + if (invalidHeaderCharRegex.test(val)) { + continue; + } + if (headers[MAP][name] === undefined) { + headers[MAP][name] = [val]; + } else { + headers[MAP][name].push(val); + } + } + } else if (!invalidHeaderCharRegex.test(obj[name])) { + headers[MAP][name] = [obj[name]]; + } + } + return headers; +} + +const INTERNALS$1 = Symbol('Response internals'); + +// fix an issue where "STATUS_CODES" aren't a named export for node <10 +const STATUS_CODES = http$2.STATUS_CODES; + +/** + * Response class + * + * @param Stream body Readable stream + * @param Object opts Response options + * @return Void + */ +class Response { + constructor() { + let body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + Body.call(this, body, opts); + + const status = opts.status || 200; + const headers = new Headers(opts.headers); + + if (body != null && !headers.has('Content-Type')) { + const contentType = extractContentType(body); + if (contentType) { + headers.append('Content-Type', contentType); + } + } + + this[INTERNALS$1] = { + url: opts.url, + status, + statusText: opts.statusText || STATUS_CODES[status], + headers, + counter: opts.counter + }; + } + + get url() { + return this[INTERNALS$1].url || ''; + } + + get status() { + return this[INTERNALS$1].status; + } + + /** + * Convenience property representing if the request ended normally + */ + get ok() { + return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300; + } + + get redirected() { + return this[INTERNALS$1].counter > 0; + } + + get statusText() { + return this[INTERNALS$1].statusText; + } + + get headers() { + return this[INTERNALS$1].headers; + } + + /** + * Clone this response + * + * @return Response + */ + clone() { + return new Response(clone(this), { + url: this.url, + status: this.status, + statusText: this.statusText, + headers: this.headers, + ok: this.ok, + redirected: this.redirected + }); + } +} + +Body.mixIn(Response.prototype); + +Object.defineProperties(Response.prototype, { + url: { enumerable: true }, + status: { enumerable: true }, + ok: { enumerable: true }, + redirected: { enumerable: true }, + statusText: { enumerable: true }, + headers: { enumerable: true }, + clone: { enumerable: true } +}); + +Object.defineProperty(Response.prototype, Symbol.toStringTag, { + value: 'Response', + writable: false, + enumerable: false, + configurable: true +}); + +const INTERNALS$2 = Symbol('Request internals'); +const URL$1 = Url.URL || publicApi.URL; + +// fix an issue where "format", "parse" aren't a named export for node <10 +const parse_url = Url.parse; +const format_url = Url.format; + +/** + * Wrapper around `new URL` to handle arbitrary URLs + * + * @param {string} urlStr + * @return {void} + */ +function parseURL(urlStr) { + /* + Check whether the URL is absolute or not + Scheme: https://tools.ietf.org/html/rfc3986#section-3.1 + Absolute URL: https://tools.ietf.org/html/rfc3986#section-4.3 + */ + if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) { + urlStr = new URL$1(urlStr).toString(); + } + + // Fallback to old implementation for arbitrary URLs + return parse_url(urlStr); +} + +const streamDestructionSupported = 'destroy' in Stream.Readable.prototype; + +/** + * Check if a value is an instance of Request. + * + * @param Mixed input + * @return Boolean + */ +function isRequest(input) { + return typeof input === 'object' && typeof input[INTERNALS$2] === 'object'; +} + +function isAbortSignal(signal) { + const proto = signal && typeof signal === 'object' && Object.getPrototypeOf(signal); + return !!(proto && proto.constructor.name === 'AbortSignal'); +} + +/** + * Request class + * + * @param Mixed input Url or Request instance + * @param Object init Custom options + * @return Void + */ +class Request { + constructor(input) { + let init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + let parsedURL; + + // normalize input + if (!isRequest(input)) { + if (input && input.href) { + // in order to support Node.js' Url objects; though WHATWG's URL objects + // will fall into this branch also (since their `toString()` will return + // `href` property anyway) + parsedURL = parseURL(input.href); + } else { + // coerce input to a string before attempting to parse + parsedURL = parseURL(`${input}`); + } + input = {}; + } else { + parsedURL = parseURL(input.url); + } + + let method = init.method || input.method || 'GET'; + method = method.toUpperCase(); + + if ((init.body != null || isRequest(input) && input.body !== null) && (method === 'GET' || method === 'HEAD')) { + throw new TypeError('Request with GET/HEAD method cannot have body'); + } + + let inputBody = init.body != null ? init.body : isRequest(input) && input.body !== null ? clone(input) : null; + + Body.call(this, inputBody, { + timeout: init.timeout || input.timeout || 0, + size: init.size || input.size || 0 + }); + + const headers = new Headers(init.headers || input.headers || {}); + + if (inputBody != null && !headers.has('Content-Type')) { + const contentType = extractContentType(inputBody); + if (contentType) { + headers.append('Content-Type', contentType); + } + } + + let signal = isRequest(input) ? input.signal : null; + if ('signal' in init) signal = init.signal; + + if (signal != null && !isAbortSignal(signal)) { + throw new TypeError('Expected signal to be an instanceof AbortSignal'); + } + + this[INTERNALS$2] = { + method, + redirect: init.redirect || input.redirect || 'follow', + headers, + parsedURL, + signal + }; + + // node-fetch-only options + this.follow = init.follow !== undefined ? init.follow : input.follow !== undefined ? input.follow : 20; + this.compress = init.compress !== undefined ? init.compress : input.compress !== undefined ? input.compress : true; + this.counter = init.counter || input.counter || 0; + this.agent = init.agent || input.agent; + } + + get method() { + return this[INTERNALS$2].method; + } + + get url() { + return format_url(this[INTERNALS$2].parsedURL); + } + + get headers() { + return this[INTERNALS$2].headers; + } + + get redirect() { + return this[INTERNALS$2].redirect; + } + + get signal() { + return this[INTERNALS$2].signal; + } + + /** + * Clone this request + * + * @return Request + */ + clone() { + return new Request(this); + } +} + +Body.mixIn(Request.prototype); + +Object.defineProperty(Request.prototype, Symbol.toStringTag, { + value: 'Request', + writable: false, + enumerable: false, + configurable: true +}); + +Object.defineProperties(Request.prototype, { + method: { enumerable: true }, + url: { enumerable: true }, + headers: { enumerable: true }, + redirect: { enumerable: true }, + clone: { enumerable: true }, + signal: { enumerable: true } +}); + +/** + * Convert a Request to Node.js http request options. + * + * @param Request A Request instance + * @return Object The options object to be passed to http.request + */ +function getNodeRequestOptions(request) { + const parsedURL = request[INTERNALS$2].parsedURL; + const headers = new Headers(request[INTERNALS$2].headers); + + // fetch step 1.3 + if (!headers.has('Accept')) { + headers.set('Accept', '*/*'); + } + + // Basic fetch + if (!parsedURL.protocol || !parsedURL.hostname) { + throw new TypeError('Only absolute URLs are supported'); + } + + if (!/^https?:$/.test(parsedURL.protocol)) { + throw new TypeError('Only HTTP(S) protocols are supported'); + } + + if (request.signal && request.body instanceof Stream.Readable && !streamDestructionSupported) { + throw new Error('Cancellation of streamed requests with AbortSignal is not supported in node < 8'); + } + + // HTTP-network-or-cache fetch steps 2.4-2.7 + let contentLengthValue = null; + if (request.body == null && /^(POST|PUT)$/i.test(request.method)) { + contentLengthValue = '0'; + } + if (request.body != null) { + const totalBytes = getTotalBytes(request); + if (typeof totalBytes === 'number') { + contentLengthValue = String(totalBytes); + } + } + if (contentLengthValue) { + headers.set('Content-Length', contentLengthValue); + } + + // HTTP-network-or-cache fetch step 2.11 + if (!headers.has('User-Agent')) { + headers.set('User-Agent', 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'); + } + + // HTTP-network-or-cache fetch step 2.15 + if (request.compress && !headers.has('Accept-Encoding')) { + headers.set('Accept-Encoding', 'gzip,deflate'); + } + + let agent = request.agent; + if (typeof agent === 'function') { + agent = agent(parsedURL); + } + + // HTTP-network fetch step 4.2 + // chunked encoding is handled by Node.js + + return Object.assign({}, parsedURL, { + method: request.method, + headers: exportNodeCompatibleHeaders(headers), + agent + }); +} + +/** + * abort-error.js + * + * AbortError interface for cancelled requests + */ + +/** + * Create AbortError instance + * + * @param String message Error message for human + * @return AbortError + */ +function AbortError(message) { + Error.call(this, message); + + this.type = 'aborted'; + this.message = message; + + // hide custom error implementation details from end-users + Error.captureStackTrace(this, this.constructor); +} + +AbortError.prototype = Object.create(Error.prototype); +AbortError.prototype.constructor = AbortError; +AbortError.prototype.name = 'AbortError'; + +const URL$1$1 = Url.URL || publicApi.URL; + +// fix an issue where "PassThrough", "resolve" aren't a named export for node <10 +const PassThrough$1 = Stream.PassThrough; + +const isDomainOrSubdomain = function isDomainOrSubdomain(destination, original) { + const orig = new URL$1$1(original).hostname; + const dest = new URL$1$1(destination).hostname; + + return orig === dest || orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest); +}; + +/** + * isSameProtocol reports whether the two provided URLs use the same protocol. + * + * Both domains must already be in canonical form. + * @param {string|URL} original + * @param {string|URL} destination + */ +const isSameProtocol = function isSameProtocol(destination, original) { + const orig = new URL$1$1(original).protocol; + const dest = new URL$1$1(destination).protocol; + + return orig === dest; +}; + +/** + * Fetch function + * + * @param Mixed url Absolute url or Request instance + * @param Object opts Fetch options + * @return Promise + */ +function fetch$2(url, opts) { + + // allow custom promise + if (!fetch$2.Promise) { + throw new Error('native promise missing, set fetch.Promise to your favorite alternative'); + } + + Body.Promise = fetch$2.Promise; + + // wrap http.request into fetch + return new fetch$2.Promise(function (resolve, reject) { + // build request object + const request = new Request(url, opts); + const options = getNodeRequestOptions(request); + + const send = (options.protocol === 'https:' ? https$2 : http$2).request; + const signal = request.signal; + + let response = null; + + const abort = function abort() { + let error = new AbortError('The user aborted a request.'); + reject(error); + if (request.body && request.body instanceof Stream.Readable) { + destroyStream(request.body, error); + } + if (!response || !response.body) return; + response.body.emit('error', error); + }; + + if (signal && signal.aborted) { + abort(); + return; + } + + const abortAndFinalize = function abortAndFinalize() { + abort(); + finalize(); + }; + + // send request + const req = send(options); + let reqTimeout; + + if (signal) { + signal.addEventListener('abort', abortAndFinalize); + } + + function finalize() { + req.abort(); + if (signal) signal.removeEventListener('abort', abortAndFinalize); + clearTimeout(reqTimeout); + } + + if (request.timeout) { + req.once('socket', function (socket) { + reqTimeout = setTimeout(function () { + reject(new FetchError(`network timeout at: ${request.url}`, 'request-timeout')); + finalize(); + }, request.timeout); + }); + } + + req.on('error', function (err) { + reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err)); + + if (response && response.body) { + destroyStream(response.body, err); + } + + finalize(); + }); + + fixResponseChunkedTransferBadEnding(req, function (err) { + if (signal && signal.aborted) { + return; + } + + if (response && response.body) { + destroyStream(response.body, err); + } + }); + + /* c8 ignore next 18 */ + if (parseInt(process.version.substring(1)) < 14) { + // Before Node.js 14, pipeline() does not fully support async iterators and does not always + // properly handle when the socket close/end events are out of order. + req.on('socket', function (s) { + s.addListener('close', function (hadError) { + // if a data listener is still present we didn't end cleanly + const hasDataListener = s.listenerCount('data') > 0; + + // if end happened before close but the socket didn't emit an error, do it now + if (response && hasDataListener && !hadError && !(signal && signal.aborted)) { + const err = new Error('Premature close'); + err.code = 'ERR_STREAM_PREMATURE_CLOSE'; + response.body.emit('error', err); + } + }); + }); + } + + req.on('response', function (res) { + clearTimeout(reqTimeout); + + const headers = createHeadersLenient(res.headers); + + // HTTP fetch step 5 + if (fetch$2.isRedirect(res.statusCode)) { + // HTTP fetch step 5.2 + const location = headers.get('Location'); + + // HTTP fetch step 5.3 + let locationURL = null; + try { + locationURL = location === null ? null : new URL$1$1(location, request.url).toString(); + } catch (err) { + // error here can only be invalid URL in Location: header + // do not throw when options.redirect == manual + // let the user extract the errorneous redirect URL + if (request.redirect !== 'manual') { + reject(new FetchError(`uri requested responds with an invalid redirect URL: ${location}`, 'invalid-redirect')); + finalize(); + return; + } + } + + // HTTP fetch step 5.5 + switch (request.redirect) { + case 'error': + reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect')); + finalize(); + return; + case 'manual': + // node-fetch-specific step: make manual redirect a bit easier to use by setting the Location header value to the resolved URL. + if (locationURL !== null) { + // handle corrupted header + try { + headers.set('Location', locationURL); + } catch (err) { + // istanbul ignore next: nodejs server prevent invalid response headers, we can't test this through normal request + reject(err); + } + } + break; + case 'follow': + // HTTP-redirect fetch step 2 + if (locationURL === null) { + break; + } + + // HTTP-redirect fetch step 5 + if (request.counter >= request.follow) { + reject(new FetchError(`maximum redirect reached at: ${request.url}`, 'max-redirect')); + finalize(); + return; + } + + // HTTP-redirect fetch step 6 (counter increment) + // Create a new Request object. + const requestOpts = { + headers: new Headers(request.headers), + follow: request.follow, + counter: request.counter + 1, + agent: request.agent, + compress: request.compress, + method: request.method, + body: request.body, + signal: request.signal, + timeout: request.timeout, + size: request.size + }; + + if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) { + for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) { + requestOpts.headers.delete(name); + } + } + + // HTTP-redirect fetch step 9 + if (res.statusCode !== 303 && request.body && getTotalBytes(request) === null) { + reject(new FetchError('Cannot follow redirect with body being a readable stream', 'unsupported-redirect')); + finalize(); + return; + } + + // HTTP-redirect fetch step 11 + if (res.statusCode === 303 || (res.statusCode === 301 || res.statusCode === 302) && request.method === 'POST') { + requestOpts.method = 'GET'; + requestOpts.body = undefined; + requestOpts.headers.delete('content-length'); + } + + // HTTP-redirect fetch step 15 + resolve(fetch$2(new Request(locationURL, requestOpts))); + finalize(); + return; + } + } + + // prepare response + res.once('end', function () { + if (signal) signal.removeEventListener('abort', abortAndFinalize); + }); + let body = res.pipe(new PassThrough$1()); + + const response_options = { + url: request.url, + status: res.statusCode, + statusText: res.statusMessage, + headers: headers, + size: request.size, + timeout: request.timeout, + counter: request.counter + }; + + // HTTP-network fetch step 12.1.1.3 + const codings = headers.get('Content-Encoding'); + + // HTTP-network fetch step 12.1.1.4: handle content codings + + // in following scenarios we ignore compression support + // 1. compression support is disabled + // 2. HEAD request + // 3. no Content-Encoding header + // 4. no content response (204) + // 5. content not modified response (304) + if (!request.compress || request.method === 'HEAD' || codings === null || res.statusCode === 204 || res.statusCode === 304) { + response = new Response(body, response_options); + resolve(response); + return; + } + + // For Node v6+ + // Be less strict when decoding compressed responses, since sometimes + // servers send slightly invalid responses that are still accepted + // by common browsers. + // Always using Z_SYNC_FLUSH is what cURL does. + const zlibOptions = { + flush: zlib$1.Z_SYNC_FLUSH, + finishFlush: zlib$1.Z_SYNC_FLUSH + }; + + // for gzip + if (codings == 'gzip' || codings == 'x-gzip') { + body = body.pipe(zlib$1.createGunzip(zlibOptions)); + response = new Response(body, response_options); + resolve(response); + return; + } + + // for deflate + if (codings == 'deflate' || codings == 'x-deflate') { + // handle the infamous raw deflate response from old servers + // a hack for old IIS and Apache servers + const raw = res.pipe(new PassThrough$1()); + raw.once('data', function (chunk) { + // see http://stackoverflow.com/questions/37519828 + if ((chunk[0] & 0x0F) === 0x08) { + body = body.pipe(zlib$1.createInflate()); + } else { + body = body.pipe(zlib$1.createInflateRaw()); + } + response = new Response(body, response_options); + resolve(response); + }); + raw.on('end', function () { + // some old IIS servers return zero-length OK deflate responses, so 'data' is never emitted. + if (!response) { + response = new Response(body, response_options); + resolve(response); + } + }); + return; + } + + // for br + if (codings == 'br' && typeof zlib$1.createBrotliDecompress === 'function') { + body = body.pipe(zlib$1.createBrotliDecompress()); + response = new Response(body, response_options); + resolve(response); + return; + } + + // otherwise, use response as-is + response = new Response(body, response_options); + resolve(response); + }); + + writeToStream(req, request); + }); +} +function fixResponseChunkedTransferBadEnding(request, errorCallback) { + let socket; + + request.on('socket', function (s) { + socket = s; + }); + + request.on('response', function (response) { + const headers = response.headers; + + if (headers['transfer-encoding'] === 'chunked' && !headers['content-length']) { + response.once('close', function (hadError) { + // tests for socket presence, as in some situations the + // the 'socket' event is not triggered for the request + // (happens in deno), avoids `TypeError` + // if a data listener is still present we didn't end cleanly + const hasDataListener = socket && socket.listenerCount('data') > 0; + + if (hasDataListener && !hadError) { + const err = new Error('Premature close'); + err.code = 'ERR_STREAM_PREMATURE_CLOSE'; + errorCallback(err); + } + }); + } + }); +} + +function destroyStream(stream, err) { + if (stream.destroy) { + stream.destroy(err); + } else { + // node < 8 + stream.emit('error', err); + stream.end(); + } +} + +/** + * Redirect code matching + * + * @param Number code Status code + * @return Boolean + */ +fetch$2.isRedirect = function (code) { + return code === 301 || code === 302 || code === 303 || code === 307 || code === 308; +}; + +// expose Promise +fetch$2.Promise = global.Promise; + +var lib$2 = /*#__PURE__*/Object.freeze({ + __proto__: null, + AbortError: AbortError, + FetchError: FetchError, + Headers: Headers, + Request: Request, + Response: Response, + default: fetch$2 +}); + +var require$$0 = /*@__PURE__*/getAugmentedNamespace(lib$2); + +(function (module, exports) { + const nodeFetch = require$$0; + const realFetch = nodeFetch.default || nodeFetch; + + const fetch = function (url, options) { + // Support schemaless URIs on the server for parity with the browser. + // Ex: //github.com/ -> https://github.com/ + if (/^\/\//.test(url)) { + url = 'https:' + url; + } + return realFetch.call(this, url, options) + }; + + fetch.ponyfill = true; + + module.exports = exports = fetch; + exports.fetch = fetch; + exports.Headers = nodeFetch.Headers; + exports.Request = nodeFetch.Request; + exports.Response = nodeFetch.Response; + + // Needed for TypeScript consumers without esModuleInterop. + exports.default = fetch; +} (nodePonyfill, nodePonyfill.exports)); + +var nodePonyfillExports = nodePonyfill.exports; +var crossFetch = /*@__PURE__*/getDefaultExportFromCjs(nodePonyfillExports); + +var dist$3 = {}; + +var src = {exports: {}}; + +var browser = {exports: {}}; + +/** + * Helpers. + */ + +var ms; +var hasRequiredMs; + +function requireMs () { + if (hasRequiredMs) return ms; + hasRequiredMs = 1; + var s = 1000; + var m = s * 60; + var h = m * 60; + var d = h * 24; + var w = d * 7; + var y = d * 365.25; + + /** + * Parse or format the given `val`. + * + * Options: + * + * - `long` verbose formatting [false] + * + * @param {String|Number} val + * @param {Object} [options] + * @throws {Error} throw an error if val is not a non-empty string or a number + * @return {String|Number} + * @api public + */ + + ms = function(val, options) { + options = options || {}; + var type = typeof val; + if (type === 'string' && val.length > 0) { + return parse(val); + } else if (type === 'number' && isFinite(val)) { + return options.long ? fmtLong(val) : fmtShort(val); + } + throw new Error( + 'val is not a non-empty string or a valid number. val=' + + JSON.stringify(val) + ); + }; + + /** + * Parse the given `str` and return milliseconds. + * + * @param {String} str + * @return {Number} + * @api private + */ + + function parse(str) { + str = String(str); + if (str.length > 100) { + return; + } + var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( + str + ); + if (!match) { + return; + } + var n = parseFloat(match[1]); + var type = (match[2] || 'ms').toLowerCase(); + switch (type) { + case 'years': + case 'year': + case 'yrs': + case 'yr': + case 'y': + return n * y; + case 'weeks': + case 'week': + case 'w': + return n * w; + case 'days': + case 'day': + case 'd': + return n * d; + case 'hours': + case 'hour': + case 'hrs': + case 'hr': + case 'h': + return n * h; + case 'minutes': + case 'minute': + case 'mins': + case 'min': + case 'm': + return n * m; + case 'seconds': + case 'second': + case 'secs': + case 'sec': + case 's': + return n * s; + case 'milliseconds': + case 'millisecond': + case 'msecs': + case 'msec': + case 'ms': + return n; + default: + return undefined; + } + } + + /** + * Short format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + + function fmtShort(ms) { + var msAbs = Math.abs(ms); + if (msAbs >= d) { + return Math.round(ms / d) + 'd'; + } + if (msAbs >= h) { + return Math.round(ms / h) + 'h'; + } + if (msAbs >= m) { + return Math.round(ms / m) + 'm'; + } + if (msAbs >= s) { + return Math.round(ms / s) + 's'; + } + return ms + 'ms'; + } + + /** + * Long format for `ms`. + * + * @param {Number} ms + * @return {String} + * @api private + */ + + function fmtLong(ms) { + var msAbs = Math.abs(ms); + if (msAbs >= d) { + return plural(ms, msAbs, d, 'day'); + } + if (msAbs >= h) { + return plural(ms, msAbs, h, 'hour'); + } + if (msAbs >= m) { + return plural(ms, msAbs, m, 'minute'); + } + if (msAbs >= s) { + return plural(ms, msAbs, s, 'second'); + } + return ms + ' ms'; + } + + /** + * Pluralization helper. + */ + + function plural(ms, msAbs, n, name) { + var isPlural = msAbs >= n * 1.5; + return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); + } + return ms; +} + +var common$3; +var hasRequiredCommon; + +function requireCommon () { + if (hasRequiredCommon) return common$3; + hasRequiredCommon = 1; + /** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + */ + + function setup(env) { + createDebug.debug = createDebug; + createDebug.default = createDebug; + createDebug.coerce = coerce; + createDebug.disable = disable; + createDebug.enable = enable; + createDebug.enabled = enabled; + createDebug.humanize = requireMs(); + createDebug.destroy = destroy; + + Object.keys(env).forEach(key => { + createDebug[key] = env[key]; + }); + + /** + * The currently active debug mode names, and names to skip. + */ + + createDebug.names = []; + createDebug.skips = []; + + /** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + createDebug.formatters = {}; + + /** + * Selects a color for a debug namespace + * @param {String} namespace The namespace string for the debug instance to be colored + * @return {Number|String} An ANSI color code for the given namespace + * @api private + */ + function selectColor(namespace) { + let hash = 0; + + for (let i = 0; i < namespace.length; i++) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } + + return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; + } + createDebug.selectColor = selectColor; + + /** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + function createDebug(namespace) { + let prevTime; + let enableOverride = null; + let namespacesCache; + let enabledCache; + + function debug(...args) { + // Disabled? + if (!debug.enabled) { + return; + } + + const self = debug; + + // Set `diff` timestamp + const curr = Number(new Date()); + const ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; + + args[0] = createDebug.coerce(args[0]); + + if (typeof args[0] !== 'string') { + // Anything else let's inspect with %O + args.unshift('%O'); + } + + // Apply any `formatters` transformations + let index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { + // If we encounter an escaped % then don't increase the array index + if (match === '%%') { + return '%'; + } + index++; + const formatter = createDebug.formatters[format]; + if (typeof formatter === 'function') { + const val = args[index]; + match = formatter.call(self, val); + + // Now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); + + // Apply env-specific formatting (colors, etc.) + createDebug.formatArgs.call(self, args); + + const logFn = self.log || createDebug.log; + logFn.apply(self, args); + } + + debug.namespace = namespace; + debug.useColors = createDebug.useColors(); + debug.color = createDebug.selectColor(namespace); + debug.extend = extend; + debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. + + Object.defineProperty(debug, 'enabled', { + enumerable: true, + configurable: false, + get: () => { + if (enableOverride !== null) { + return enableOverride; + } + if (namespacesCache !== createDebug.namespaces) { + namespacesCache = createDebug.namespaces; + enabledCache = createDebug.enabled(namespace); + } + + return enabledCache; + }, + set: v => { + enableOverride = v; + } + }); + + // Env-specific initialization logic for debug instances + if (typeof createDebug.init === 'function') { + createDebug.init(debug); + } + + return debug; + } + + function extend(namespace, delimiter) { + const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); + newDebug.log = this.log; + return newDebug; + } + + /** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + function enable(namespaces) { + createDebug.save(namespaces); + createDebug.namespaces = namespaces; + + createDebug.names = []; + createDebug.skips = []; + + let i; + const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); + const len = split.length; + + for (i = 0; i < len; i++) { + if (!split[i]) { + // ignore empty strings + continue; + } + + namespaces = split[i].replace(/\*/g, '.*?'); + + if (namespaces[0] === '-') { + createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); + } else { + createDebug.names.push(new RegExp('^' + namespaces + '$')); + } + } + } + + /** + * Disable debug output. + * + * @return {String} namespaces + * @api public + */ + function disable() { + const namespaces = [ + ...createDebug.names.map(toNamespace), + ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) + ].join(','); + createDebug.enable(''); + return namespaces; + } + + /** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + function enabled(name) { + if (name[name.length - 1] === '*') { + return true; + } + + let i; + let len; + + for (i = 0, len = createDebug.skips.length; i < len; i++) { + if (createDebug.skips[i].test(name)) { + return false; + } + } + + for (i = 0, len = createDebug.names.length; i < len; i++) { + if (createDebug.names[i].test(name)) { + return true; + } + } + + return false; + } + + /** + * Convert regexp to namespace + * + * @param {RegExp} regxep + * @return {String} namespace + * @api private + */ + function toNamespace(regexp) { + return regexp.toString() + .substring(2, regexp.toString().length - 2) + .replace(/\.\*\?$/, '*'); + } + + /** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + function coerce(val) { + if (val instanceof Error) { + return val.stack || val.message; + } + return val; + } + + /** + * XXX DO NOT USE. This is a temporary stub function. + * XXX It WILL be removed in the next major release. + */ + function destroy() { + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); + } + + createDebug.enable(createDebug.load()); + + return createDebug; + } + + common$3 = setup; + return common$3; +} + +/* eslint-env browser */ + +var hasRequiredBrowser; + +function requireBrowser () { + if (hasRequiredBrowser) return browser.exports; + hasRequiredBrowser = 1; + (function (module, exports) { + /** + * This is the web browser implementation of `debug()`. + */ + + exports.formatArgs = formatArgs; + exports.save = save; + exports.load = load; + exports.useColors = useColors; + exports.storage = localstorage(); + exports.destroy = (() => { + let warned = false; + + return () => { + if (!warned) { + warned = true; + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); + } + }; + })(); + + /** + * Colors. + */ + + exports.colors = [ + '#0000CC', + '#0000FF', + '#0033CC', + '#0033FF', + '#0066CC', + '#0066FF', + '#0099CC', + '#0099FF', + '#00CC00', + '#00CC33', + '#00CC66', + '#00CC99', + '#00CCCC', + '#00CCFF', + '#3300CC', + '#3300FF', + '#3333CC', + '#3333FF', + '#3366CC', + '#3366FF', + '#3399CC', + '#3399FF', + '#33CC00', + '#33CC33', + '#33CC66', + '#33CC99', + '#33CCCC', + '#33CCFF', + '#6600CC', + '#6600FF', + '#6633CC', + '#6633FF', + '#66CC00', + '#66CC33', + '#9900CC', + '#9900FF', + '#9933CC', + '#9933FF', + '#99CC00', + '#99CC33', + '#CC0000', + '#CC0033', + '#CC0066', + '#CC0099', + '#CC00CC', + '#CC00FF', + '#CC3300', + '#CC3333', + '#CC3366', + '#CC3399', + '#CC33CC', + '#CC33FF', + '#CC6600', + '#CC6633', + '#CC9900', + '#CC9933', + '#CCCC00', + '#CCCC33', + '#FF0000', + '#FF0033', + '#FF0066', + '#FF0099', + '#FF00CC', + '#FF00FF', + '#FF3300', + '#FF3333', + '#FF3366', + '#FF3399', + '#FF33CC', + '#FF33FF', + '#FF6600', + '#FF6633', + '#FF9900', + '#FF9933', + '#FFCC00', + '#FFCC33' + ]; + + /** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ + + // eslint-disable-next-line complexity + function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { + return true; + } + + // Internet Explorer and Edge do not support colors. + if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { + return false; + } + + // Is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || + // Is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || + // Is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || + // Double check webkit in userAgent just in case we are in a worker + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); + } + + /** + * Colorize log arguments if enabled. + * + * @api public + */ + + function formatArgs(args) { + args[0] = (this.useColors ? '%c' : '') + + this.namespace + + (this.useColors ? ' %c' : ' ') + + args[0] + + (this.useColors ? '%c ' : ' ') + + '+' + module.exports.humanize(this.diff); + + if (!this.useColors) { + return; + } + + const c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit'); + + // The final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + let index = 0; + let lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, match => { + if (match === '%%') { + return; + } + index++; + if (match === '%c') { + // We only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); + + args.splice(lastC, 0, c); + } + + /** + * Invokes `console.debug()` when available. + * No-op when `console.debug` is not a "function". + * If `console.debug` is not available, falls back + * to `console.log`. + * + * @api public + */ + exports.log = console.debug || console.log || (() => {}); + + /** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + function save(namespaces) { + try { + if (namespaces) { + exports.storage.setItem('debug', namespaces); + } else { + exports.storage.removeItem('debug'); + } + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } + } + + /** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + function load() { + let r; + try { + r = exports.storage.getItem('debug'); + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } + + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG; + } + + return r; + } + + /** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ + + function localstorage() { + try { + // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context + // The Browser also has localStorage in the global context. + return localStorage; + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } + } + + module.exports = requireCommon()(exports); + + const {formatters} = module.exports; + + /** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ + + formatters.j = function (v) { + try { + return JSON.stringify(v); + } catch (error) { + return '[UnexpectedJSONParseError]: ' + error.message; + } + }; + } (browser, browser.exports)); + return browser.exports; +} + +var node$1 = {exports: {}}; + +var hasFlag; +var hasRequiredHasFlag; + +function requireHasFlag () { + if (hasRequiredHasFlag) return hasFlag; + hasRequiredHasFlag = 1; + hasFlag = (flag, argv) => { + argv = argv || process.argv; + const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); + const pos = argv.indexOf(prefix + flag); + const terminatorPos = argv.indexOf('--'); + return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos); + }; + return hasFlag; +} + +var supportsColor_1; +var hasRequiredSupportsColor; + +function requireSupportsColor () { + if (hasRequiredSupportsColor) return supportsColor_1; + hasRequiredSupportsColor = 1; + const os = require$$0$2; + const hasFlag = requireHasFlag(); + + const env = process.env; + + let forceColor; + if (hasFlag('no-color') || + hasFlag('no-colors') || + hasFlag('color=false')) { + forceColor = false; + } else if (hasFlag('color') || + hasFlag('colors') || + hasFlag('color=true') || + hasFlag('color=always')) { + forceColor = true; + } + if ('FORCE_COLOR' in env) { + forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0; + } + + function translateLevel(level) { + if (level === 0) { + return false; + } + + return { + level, + hasBasic: true, + has256: level >= 2, + has16m: level >= 3 + }; + } + + function supportsColor(stream) { + if (forceColor === false) { + return 0; + } + + if (hasFlag('color=16m') || + hasFlag('color=full') || + hasFlag('color=truecolor')) { + return 3; + } + + if (hasFlag('color=256')) { + return 2; + } + + if (stream && !stream.isTTY && forceColor !== true) { + return 0; + } + + const min = forceColor ? 1 : 0; + + if (process.platform === 'win32') { + // Node.js 7.5.0 is the first version of Node.js to include a patch to + // libuv that enables 256 color output on Windows. Anything earlier and it + // won't work. However, here we target Node.js 8 at minimum as it is an LTS + // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows + // release that supports 256 colors. Windows 10 build 14931 is the first release + // that supports 16m/TrueColor. + const osRelease = os.release().split('.'); + if ( + Number(process.versions.node.split('.')[0]) >= 8 && + Number(osRelease[0]) >= 10 && + Number(osRelease[2]) >= 10586 + ) { + return Number(osRelease[2]) >= 14931 ? 3 : 2; + } + + return 1; + } + + if ('CI' in env) { + if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') { + return 1; + } + + return min; + } + + if ('TEAMCITY_VERSION' in env) { + return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; + } + + if (env.COLORTERM === 'truecolor') { + return 3; + } + + if ('TERM_PROGRAM' in env) { + const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); + + switch (env.TERM_PROGRAM) { + case 'iTerm.app': + return version >= 3 ? 3 : 2; + case 'Apple_Terminal': + return 2; + // No default + } + } + + if (/-256(color)?$/i.test(env.TERM)) { + return 2; + } + + if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { + return 1; + } + + if ('COLORTERM' in env) { + return 1; + } + + if (env.TERM === 'dumb') { + return min; + } + + return min; + } + + function getSupportLevel(stream) { + const level = supportsColor(stream); + return translateLevel(level); + } + + supportsColor_1 = { + supportsColor: getSupportLevel, + stdout: getSupportLevel(process.stdout), + stderr: getSupportLevel(process.stderr) + }; + return supportsColor_1; +} + +/** + * Module dependencies. + */ + +var hasRequiredNode$1; + +function requireNode$1 () { + if (hasRequiredNode$1) return node$1.exports; + hasRequiredNode$1 = 1; + (function (module, exports) { + const tty = require$$0$6; + const util = require$$1$2; + + /** + * This is the Node.js implementation of `debug()`. + */ + + exports.init = init; + exports.log = log; + exports.formatArgs = formatArgs; + exports.save = save; + exports.load = load; + exports.useColors = useColors; + exports.destroy = util.deprecate( + () => {}, + 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.' + ); + + /** + * Colors. + */ + + exports.colors = [6, 2, 3, 4, 5, 1]; + + try { + // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json) + // eslint-disable-next-line import/no-extraneous-dependencies + const supportsColor = requireSupportsColor(); + + if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) { + exports.colors = [ + 20, + 21, + 26, + 27, + 32, + 33, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 56, + 57, + 62, + 63, + 68, + 69, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 92, + 93, + 98, + 99, + 112, + 113, + 128, + 129, + 134, + 135, + 148, + 149, + 160, + 161, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 171, + 172, + 173, + 178, + 179, + 184, + 185, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 203, + 204, + 205, + 206, + 207, + 208, + 209, + 214, + 215, + 220, + 221 + ]; + } + } catch (error) { + // Swallow - we only care if `supports-color` is available; it doesn't have to be. + } + + /** + * Build up the default `inspectOpts` object from the environment variables. + * + * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js + */ + + exports.inspectOpts = Object.keys(process.env).filter(key => { + return /^debug_/i.test(key); + }).reduce((obj, key) => { + // Camel-case + const prop = key + .substring(6) + .toLowerCase() + .replace(/_([a-z])/g, (_, k) => { + return k.toUpperCase(); + }); + + // Coerce string value into JS value + let val = process.env[key]; + if (/^(yes|on|true|enabled)$/i.test(val)) { + val = true; + } else if (/^(no|off|false|disabled)$/i.test(val)) { + val = false; + } else if (val === 'null') { + val = null; + } else { + val = Number(val); + } + + obj[prop] = val; + return obj; + }, {}); + + /** + * Is stdout a TTY? Colored output is enabled when `true`. + */ + + function useColors() { + return 'colors' in exports.inspectOpts ? + Boolean(exports.inspectOpts.colors) : + tty.isatty(process.stderr.fd); + } + + /** + * Adds ANSI color escape codes if enabled. + * + * @api public + */ + + function formatArgs(args) { + const {namespace: name, useColors} = this; + + if (useColors) { + const c = this.color; + const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c); + const prefix = ` ${colorCode};1m${name} \u001B[0m`; + + args[0] = prefix + args[0].split('\n').join('\n' + prefix); + args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m'); + } else { + args[0] = getDate() + name + ' ' + args[0]; + } + } + + function getDate() { + if (exports.inspectOpts.hideDate) { + return ''; + } + return new Date().toISOString() + ' '; + } + + /** + * Invokes `util.format()` with the specified arguments and writes to stderr. + */ + + function log(...args) { + return process.stderr.write(util.format(...args) + '\n'); + } + + /** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + function save(namespaces) { + if (namespaces) { + process.env.DEBUG = namespaces; + } else { + // If you set a process.env field to null or undefined, it gets cast to the + // string 'null' or 'undefined'. Just delete instead. + delete process.env.DEBUG; + } + } + + /** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + + function load() { + return process.env.DEBUG; + } + + /** + * Init logic for `debug` instances. + * + * Create a new `inspectOpts` object in case `useColors` is set + * differently for a particular `debug` instance. + */ + + function init(debug) { + debug.inspectOpts = {}; + + const keys = Object.keys(exports.inspectOpts); + for (let i = 0; i < keys.length; i++) { + debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]]; + } + } + + module.exports = requireCommon()(exports); + + const {formatters} = module.exports; + + /** + * Map %o to `util.inspect()`, all on a single line. + */ + + formatters.o = function (v) { + this.inspectOpts.colors = this.useColors; + return util.inspect(v, this.inspectOpts) + .split('\n') + .map(str => str.trim()) + .join(' '); + }; + + /** + * Map %O to `util.inspect()`, allowing multiple lines if needed. + */ + + formatters.O = function (v) { + this.inspectOpts.colors = this.useColors; + return util.inspect(v, this.inspectOpts); + }; + } (node$1, node$1.exports)); + return node$1.exports; +} + +/** + * Detect Electron renderer / nwjs process, which is node, but we should + * treat as a browser. + */ + +if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) { + src.exports = requireBrowser(); +} else { + src.exports = requireNode$1(); +} + +var srcExports = src.exports; + +var dist$2 = {}; + +var helpers$3 = {}; + +var __createBinding$6 = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault$6 = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar$6 = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding$6(result, mod, k); + __setModuleDefault$6(result, mod); + return result; +}; +Object.defineProperty(helpers$3, "__esModule", { value: true }); +helpers$3.req = helpers$3.json = helpers$3.toBuffer = void 0; +const http = __importStar$6(http$2); +const https = __importStar$6(https$2); +async function toBuffer$1(stream) { + let length = 0; + const chunks = []; + for await (const chunk of stream) { + length += chunk.length; + chunks.push(chunk); + } + return Buffer.concat(chunks, length); +} +helpers$3.toBuffer = toBuffer$1; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +async function json(stream) { + const buf = await toBuffer$1(stream); + const str = buf.toString('utf8'); + try { + return JSON.parse(str); + } + catch (_err) { + const err = _err; + err.message += ` (input: ${str})`; + throw err; + } +} +helpers$3.json = json; +function req(url, opts = {}) { + const href = typeof url === 'string' ? url : url.href; + const req = (href.startsWith('https:') ? https : http).request(url, opts); + const promise = new Promise((resolve, reject) => { + req + .once('response', resolve) + .once('error', reject) + .end(); + }); + req.then = promise.then.bind(promise); + return req; +} +helpers$3.req = req; + +(function (exports) { + var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); + }) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + })); + var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); + }) : function(o, v) { + o["default"] = v; + }); + var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; + }; + var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.Agent = void 0; + const net = __importStar(require$$0$4); + const http = __importStar(http$2); + const https_1 = https$2; + __exportStar(helpers$3, exports); + const INTERNAL = Symbol('AgentBaseInternalState'); + class Agent extends http.Agent { + constructor(opts) { + super(opts); + this[INTERNAL] = {}; + } + /** + * Determine whether this is an `http` or `https` request. + */ + isSecureEndpoint(options) { + if (options) { + // First check the `secureEndpoint` property explicitly, since this + // means that a parent `Agent` is "passing through" to this instance. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (typeof options.secureEndpoint === 'boolean') { + return options.secureEndpoint; + } + // If no explicit `secure` endpoint, check if `protocol` property is + // set. This will usually be the case since using a full string URL + // or `URL` instance should be the most common usage. + if (typeof options.protocol === 'string') { + return options.protocol === 'https:'; + } + } + // Finally, if no `protocol` property was set, then fall back to + // checking the stack trace of the current call stack, and try to + // detect the "https" module. + const { stack } = new Error(); + if (typeof stack !== 'string') + return false; + return stack + .split('\n') + .some((l) => l.indexOf('(https.js:') !== -1 || + l.indexOf('node:https:') !== -1); + } + // In order to support async signatures in `connect()` and Node's native + // connection pooling in `http.Agent`, the array of sockets for each origin + // has to be updated synchronously. This is so the length of the array is + // accurate when `addRequest()` is next called. We achieve this by creating a + // fake socket and adding it to `sockets[origin]` and incrementing + // `totalSocketCount`. + incrementSockets(name) { + // If `maxSockets` and `maxTotalSockets` are both Infinity then there is no + // need to create a fake socket because Node.js native connection pooling + // will never be invoked. + if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) { + return null; + } + // All instances of `sockets` are expected TypeScript errors. The + // alternative is to add it as a private property of this class but that + // will break TypeScript subclassing. + if (!this.sockets[name]) { + // @ts-expect-error `sockets` is readonly in `@types/node` + this.sockets[name] = []; + } + const fakeSocket = new net.Socket({ writable: false }); + this.sockets[name].push(fakeSocket); + // @ts-expect-error `totalSocketCount` isn't defined in `@types/node` + this.totalSocketCount++; + return fakeSocket; + } + decrementSockets(name, socket) { + if (!this.sockets[name] || socket === null) { + return; + } + const sockets = this.sockets[name]; + const index = sockets.indexOf(socket); + if (index !== -1) { + sockets.splice(index, 1); + // @ts-expect-error `totalSocketCount` isn't defined in `@types/node` + this.totalSocketCount--; + if (sockets.length === 0) { + // @ts-expect-error `sockets` is readonly in `@types/node` + delete this.sockets[name]; + } + } + } + // In order to properly update the socket pool, we need to call `getName()` on + // the core `https.Agent` if it is a secureEndpoint. + getName(options) { + const secureEndpoint = typeof options.secureEndpoint === 'boolean' + ? options.secureEndpoint + : this.isSecureEndpoint(options); + if (secureEndpoint) { + // @ts-expect-error `getName()` isn't defined in `@types/node` + return https_1.Agent.prototype.getName.call(this, options); + } + // @ts-expect-error `getName()` isn't defined in `@types/node` + return super.getName(options); + } + createSocket(req, options, cb) { + const connectOpts = { + ...options, + secureEndpoint: this.isSecureEndpoint(options), + }; + const name = this.getName(connectOpts); + const fakeSocket = this.incrementSockets(name); + Promise.resolve() + .then(() => this.connect(req, connectOpts)) + .then((socket) => { + this.decrementSockets(name, fakeSocket); + if (socket instanceof http.Agent) { + // @ts-expect-error `addRequest()` isn't defined in `@types/node` + return socket.addRequest(req, connectOpts); + } + this[INTERNAL].currentSocket = socket; + // @ts-expect-error `createSocket()` isn't defined in `@types/node` + super.createSocket(req, options, cb); + }, (err) => { + this.decrementSockets(name, fakeSocket); + cb(err); + }); + } + createConnection() { + const socket = this[INTERNAL].currentSocket; + this[INTERNAL].currentSocket = undefined; + if (!socket) { + throw new Error('No socket was returned in the `connect()` function'); + } + return socket; + } + get defaultPort() { + return (this[INTERNAL].defaultPort ?? + (this.protocol === 'https:' ? 443 : 80)); + } + set defaultPort(v) { + if (this[INTERNAL]) { + this[INTERNAL].defaultPort = v; + } + } + get protocol() { + return (this[INTERNAL].protocol ?? + (this.isSecureEndpoint() ? 'https:' : 'http:')); + } + set protocol(v) { + if (this[INTERNAL]) { + this[INTERNAL].protocol = v; + } + } + } + exports.Agent = Agent; + +} (dist$2)); + +var __createBinding$5 = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault$5 = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar$5 = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding$5(result, mod, k); + __setModuleDefault$5(result, mod); + return result; +}; +var __importDefault$5 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(dist$3, "__esModule", { value: true }); +var HttpProxyAgent_1 = dist$3.HttpProxyAgent = void 0; +const net$3 = __importStar$5(require$$0$4); +const tls$2 = __importStar$5(require$$1$3); +const debug_1$3 = __importDefault$5(srcExports); +const events_1 = require$$0$3; +const agent_base_1$2 = dist$2; +const url_1$2 = Url; +const debug$3 = (0, debug_1$3.default)('http-proxy-agent'); +/** + * The `HttpProxyAgent` implements an HTTP Agent subclass that connects + * to the specified "HTTP proxy server" in order to proxy HTTP requests. + */ +class HttpProxyAgent extends agent_base_1$2.Agent { + constructor(proxy, opts) { + super(opts); + this.proxy = typeof proxy === 'string' ? new url_1$2.URL(proxy) : proxy; + this.proxyHeaders = opts?.headers ?? {}; + debug$3('Creating new HttpProxyAgent instance: %o', this.proxy.href); + // Trim off the brackets from IPv6 addresses + const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, ''); + const port = this.proxy.port + ? parseInt(this.proxy.port, 10) + : this.proxy.protocol === 'https:' + ? 443 + : 80; + this.connectOpts = { + ...(opts ? omit$2(opts, 'headers') : null), + host, + port, + }; + } + addRequest(req, opts) { + req._header = null; + this.setRequestProps(req, opts); + // @ts-expect-error `addRequest()` isn't defined in `@types/node` + super.addRequest(req, opts); + } + setRequestProps(req, opts) { + const { proxy } = this; + const protocol = opts.secureEndpoint ? 'https:' : 'http:'; + const hostname = req.getHeader('host') || 'localhost'; + const base = `${protocol}//${hostname}`; + const url = new url_1$2.URL(req.path, base); + if (opts.port !== 80) { + url.port = String(opts.port); + } + // Change the `http.ClientRequest` instance's "path" field + // to the absolute path of the URL that will be requested. + req.path = String(url); + // Inject the `Proxy-Authorization` header if necessary. + const headers = typeof this.proxyHeaders === 'function' + ? this.proxyHeaders() + : { ...this.proxyHeaders }; + if (proxy.username || proxy.password) { + const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`; + headers['Proxy-Authorization'] = `Basic ${Buffer.from(auth).toString('base64')}`; + } + if (!headers['Proxy-Connection']) { + headers['Proxy-Connection'] = this.keepAlive + ? 'Keep-Alive' + : 'close'; + } + for (const name of Object.keys(headers)) { + const value = headers[name]; + if (value) { + req.setHeader(name, value); + } + } + } + async connect(req, opts) { + req._header = null; + if (!req.path.includes('://')) { + this.setRequestProps(req, opts); + } + // At this point, the http ClientRequest's internal `_header` field + // might have already been set. If this is the case then we'll need + // to re-generate the string since we just changed the `req.path`. + let first; + let endOfHeaders; + debug$3('Regenerating stored HTTP header string for request'); + req._implicitHeader(); + if (req.outputData && req.outputData.length > 0) { + debug$3('Patching connection write() output buffer with updated header'); + first = req.outputData[0].data; + endOfHeaders = first.indexOf('\r\n\r\n') + 4; + req.outputData[0].data = + req._header + first.substring(endOfHeaders); + debug$3('Output buffer: %o', req.outputData[0].data); + } + // Create a socket connection to the proxy server. + let socket; + if (this.proxy.protocol === 'https:') { + debug$3('Creating `tls.Socket`: %o', this.connectOpts); + socket = tls$2.connect(this.connectOpts); + } + else { + debug$3('Creating `net.Socket`: %o', this.connectOpts); + socket = net$3.connect(this.connectOpts); + } + // Wait for the socket's `connect` event, so that this `callback()` + // function throws instead of the `http` request machinery. This is + // important for i.e. `PacProxyAgent` which determines a failed proxy + // connection via the `callback()` function throwing. + await (0, events_1.once)(socket, 'connect'); + return socket; + } +} +HttpProxyAgent.protocols = ['http', 'https']; +HttpProxyAgent_1 = dist$3.HttpProxyAgent = HttpProxyAgent; +function omit$2(obj, ...keys) { + const ret = {}; + let key; + for (key in obj) { + if (!keys.includes(key)) { + ret[key] = obj[key]; + } + } + return ret; +} + +var dist$1 = {}; + +var parseProxyResponse$1 = {}; + +var __importDefault$4 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(parseProxyResponse$1, "__esModule", { value: true }); +parseProxyResponse$1.parseProxyResponse = void 0; +const debug_1$2 = __importDefault$4(srcExports); +const debug$2 = (0, debug_1$2.default)('https-proxy-agent:parse-proxy-response'); +function parseProxyResponse(socket) { + return new Promise((resolve, reject) => { + // we need to buffer any HTTP traffic that happens with the proxy before we get + // the CONNECT response, so that if the response is anything other than an "200" + // response code, then we can re-play the "data" events on the socket once the + // HTTP parser is hooked up... + let buffersLength = 0; + const buffers = []; + function read() { + const b = socket.read(); + if (b) + ondata(b); + else + socket.once('readable', read); + } + function cleanup() { + socket.removeListener('end', onend); + socket.removeListener('error', onerror); + socket.removeListener('readable', read); + } + function onend() { + cleanup(); + debug$2('onend'); + reject(new Error('Proxy connection ended before receiving CONNECT response')); + } + function onerror(err) { + cleanup(); + debug$2('onerror %o', err); + reject(err); + } + function ondata(b) { + buffers.push(b); + buffersLength += b.length; + const buffered = Buffer.concat(buffers, buffersLength); + const endOfHeaders = buffered.indexOf('\r\n\r\n'); + if (endOfHeaders === -1) { + // keep buffering + debug$2('have not received end of HTTP headers yet...'); + read(); + return; + } + const headerParts = buffered + .slice(0, endOfHeaders) + .toString('ascii') + .split('\r\n'); + const firstLine = headerParts.shift(); + if (!firstLine) { + socket.destroy(); + return reject(new Error('No header received from proxy CONNECT response')); + } + const firstLineParts = firstLine.split(' '); + const statusCode = +firstLineParts[1]; + const statusText = firstLineParts.slice(2).join(' '); + const headers = {}; + for (const header of headerParts) { + if (!header) + continue; + const firstColon = header.indexOf(':'); + if (firstColon === -1) { + socket.destroy(); + return reject(new Error(`Invalid header from proxy CONNECT response: "${header}"`)); + } + const key = header.slice(0, firstColon).toLowerCase(); + const value = header.slice(firstColon + 1).trimStart(); + const current = headers[key]; + if (typeof current === 'string') { + headers[key] = [current, value]; + } + else if (Array.isArray(current)) { + current.push(value); + } + else { + headers[key] = value; + } + } + debug$2('got proxy server response: %o %o', firstLine, headers); + cleanup(); + resolve({ + connect: { + statusCode, + statusText, + headers, + }, + buffered, + }); + } + socket.on('error', onerror); + socket.on('end', onend); + read(); + }); +} +parseProxyResponse$1.parseProxyResponse = parseProxyResponse; + +var __createBinding$4 = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault$4 = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar$4 = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding$4(result, mod, k); + __setModuleDefault$4(result, mod); + return result; +}; +var __importDefault$3 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(dist$1, "__esModule", { value: true }); +var HttpsProxyAgent_1 = dist$1.HttpsProxyAgent = void 0; +const net$2 = __importStar$4(require$$0$4); +const tls$1 = __importStar$4(require$$1$3); +const assert_1 = __importDefault$3(assert$6); +const debug_1$1 = __importDefault$3(srcExports); +const agent_base_1$1 = dist$2; +const url_1$1 = Url; +const parse_proxy_response_1 = parseProxyResponse$1; +const debug$1 = (0, debug_1$1.default)('https-proxy-agent'); +/** + * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to + * the specified "HTTP(s) proxy server" in order to proxy HTTPS requests. + * + * Outgoing HTTP requests are first tunneled through the proxy server using the + * `CONNECT` HTTP request method to establish a connection to the proxy server, + * and then the proxy server connects to the destination target and issues the + * HTTP request from the proxy server. + * + * `https:` requests have their socket connection upgraded to TLS once + * the connection to the proxy server has been established. + */ +class HttpsProxyAgent extends agent_base_1$1.Agent { + constructor(proxy, opts) { + super(opts); + this.options = { path: undefined }; + this.proxy = typeof proxy === 'string' ? new url_1$1.URL(proxy) : proxy; + this.proxyHeaders = opts?.headers ?? {}; + debug$1('Creating new HttpsProxyAgent instance: %o', this.proxy.href); + // Trim off the brackets from IPv6 addresses + const host = (this.proxy.hostname || this.proxy.host).replace(/^\[|\]$/g, ''); + const port = this.proxy.port + ? parseInt(this.proxy.port, 10) + : this.proxy.protocol === 'https:' + ? 443 + : 80; + this.connectOpts = { + // Attempt to negotiate http/1.1 for proxy servers that support http/2 + ALPNProtocols: ['http/1.1'], + ...(opts ? omit$1(opts, 'headers') : null), + host, + port, + }; + } + /** + * Called when the node-core HTTP client library is creating a + * new HTTP request. + */ + async connect(req, opts) { + const { proxy } = this; + if (!opts.host) { + throw new TypeError('No "host" provided'); + } + // Create a socket connection to the proxy server. + let socket; + if (proxy.protocol === 'https:') { + debug$1('Creating `tls.Socket`: %o', this.connectOpts); + const servername = this.connectOpts.servername || this.connectOpts.host; + socket = tls$1.connect({ + ...this.connectOpts, + servername: servername && net$2.isIP(servername) ? undefined : servername, + }); + } + else { + debug$1('Creating `net.Socket`: %o', this.connectOpts); + socket = net$2.connect(this.connectOpts); + } + const headers = typeof this.proxyHeaders === 'function' + ? this.proxyHeaders() + : { ...this.proxyHeaders }; + const host = net$2.isIPv6(opts.host) ? `[${opts.host}]` : opts.host; + let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r\n`; + // Inject the `Proxy-Authorization` header if necessary. + if (proxy.username || proxy.password) { + const auth = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`; + headers['Proxy-Authorization'] = `Basic ${Buffer.from(auth).toString('base64')}`; + } + headers.Host = `${host}:${opts.port}`; + if (!headers['Proxy-Connection']) { + headers['Proxy-Connection'] = this.keepAlive + ? 'Keep-Alive' + : 'close'; + } + for (const name of Object.keys(headers)) { + payload += `${name}: ${headers[name]}\r\n`; + } + const proxyResponsePromise = (0, parse_proxy_response_1.parseProxyResponse)(socket); + socket.write(`${payload}\r\n`); + const { connect, buffered } = await proxyResponsePromise; + req.emit('proxyConnect', connect); + this.emit('proxyConnect', connect, req); + if (connect.statusCode === 200) { + req.once('socket', resume); + if (opts.secureEndpoint) { + // The proxy is connecting to a TLS server, so upgrade + // this socket connection to a TLS connection. + debug$1('Upgrading socket connection to TLS'); + const servername = opts.servername || opts.host; + return tls$1.connect({ + ...omit$1(opts, 'host', 'path', 'port'), + socket, + servername: net$2.isIP(servername) ? undefined : servername, + }); + } + return socket; + } + // Some other status code that's not 200... need to re-play the HTTP + // header "data" events onto the socket once the HTTP machinery is + // attached so that the node core `http` can parse and handle the + // error status code. + // Close the original socket, and a new "fake" socket is returned + // instead, so that the proxy doesn't get the HTTP request + // written to it (which may contain `Authorization` headers or other + // sensitive data). + // + // See: https://hackerone.com/reports/541502 + socket.destroy(); + const fakeSocket = new net$2.Socket({ writable: false }); + fakeSocket.readable = true; + // Need to wait for the "socket" event to re-play the "data" events. + req.once('socket', (s) => { + debug$1('Replaying proxy buffer for failed request'); + (0, assert_1.default)(s.listenerCount('data') > 0); + // Replay the "buffered" Buffer onto the fake `socket`, since at + // this point the HTTP module machinery has been hooked up for + // the user. + s.push(buffered); + s.push(null); + }); + return fakeSocket; + } +} +HttpsProxyAgent.protocols = ['http', 'https']; +HttpsProxyAgent_1 = dist$1.HttpsProxyAgent = HttpsProxyAgent; +function resume(socket) { + socket.resume(); +} +function omit$1(obj, ...keys) { + const ret = {}; + let key; + for (key in obj) { + if (!keys.includes(key)) { + ret[key] = obj[key]; + } + } + return ret; +} + +var dist = {}; + +var build$1 = {}; + +var socksclient = {}; + +var smartbuffer = {}; + +var utils$e = {}; + +Object.defineProperty(utils$e, "__esModule", { value: true }); +const buffer_1 = require$$0$7; +/** + * Error strings + */ +const ERRORS$1 = { + INVALID_ENCODING: 'Invalid encoding provided. Please specify a valid encoding the internal Node.js Buffer supports.', + INVALID_SMARTBUFFER_SIZE: 'Invalid size provided. Size must be a valid integer greater than zero.', + INVALID_SMARTBUFFER_BUFFER: 'Invalid Buffer provided in SmartBufferOptions.', + INVALID_SMARTBUFFER_OBJECT: 'Invalid SmartBufferOptions object supplied to SmartBuffer constructor or factory methods.', + INVALID_OFFSET: 'An invalid offset value was provided.', + INVALID_OFFSET_NON_NUMBER: 'An invalid offset value was provided. A numeric value is required.', + INVALID_LENGTH: 'An invalid length value was provided.', + INVALID_LENGTH_NON_NUMBER: 'An invalid length value was provived. A numeric value is required.', + INVALID_TARGET_OFFSET: 'Target offset is beyond the bounds of the internal SmartBuffer data.', + INVALID_TARGET_LENGTH: 'Specified length value moves cursor beyong the bounds of the internal SmartBuffer data.', + INVALID_READ_BEYOND_BOUNDS: 'Attempted to read beyond the bounds of the managed data.', + INVALID_WRITE_BEYOND_BOUNDS: 'Attempted to write beyond the bounds of the managed data.' +}; +utils$e.ERRORS = ERRORS$1; +/** + * Checks if a given encoding is a valid Buffer encoding. (Throws an exception if check fails) + * + * @param { String } encoding The encoding string to check. + */ +function checkEncoding(encoding) { + if (!buffer_1.Buffer.isEncoding(encoding)) { + throw new Error(ERRORS$1.INVALID_ENCODING); + } +} +utils$e.checkEncoding = checkEncoding; +/** + * Checks if a given number is a finite integer. (Throws an exception if check fails) + * + * @param { Number } value The number value to check. + */ +function isFiniteInteger(value) { + return typeof value === 'number' && isFinite(value) && isInteger$1(value); +} +utils$e.isFiniteInteger = isFiniteInteger; +/** + * Checks if an offset/length value is valid. (Throws an exception if check fails) + * + * @param value The value to check. + * @param offset True if checking an offset, false if checking a length. + */ +function checkOffsetOrLengthValue(value, offset) { + if (typeof value === 'number') { + // Check for non finite/non integers + if (!isFiniteInteger(value) || value < 0) { + throw new Error(offset ? ERRORS$1.INVALID_OFFSET : ERRORS$1.INVALID_LENGTH); + } + } + else { + throw new Error(offset ? ERRORS$1.INVALID_OFFSET_NON_NUMBER : ERRORS$1.INVALID_LENGTH_NON_NUMBER); + } +} +/** + * Checks if a length value is valid. (Throws an exception if check fails) + * + * @param { Number } length The value to check. + */ +function checkLengthValue(length) { + checkOffsetOrLengthValue(length, false); +} +utils$e.checkLengthValue = checkLengthValue; +/** + * Checks if a offset value is valid. (Throws an exception if check fails) + * + * @param { Number } offset The value to check. + */ +function checkOffsetValue(offset) { + checkOffsetOrLengthValue(offset, true); +} +utils$e.checkOffsetValue = checkOffsetValue; +/** + * Checks if a target offset value is out of bounds. (Throws an exception if check fails) + * + * @param { Number } offset The offset value to check. + * @param { SmartBuffer } buff The SmartBuffer instance to check against. + */ +function checkTargetOffset(offset, buff) { + if (offset < 0 || offset > buff.length) { + throw new Error(ERRORS$1.INVALID_TARGET_OFFSET); + } +} +utils$e.checkTargetOffset = checkTargetOffset; +/** + * Determines whether a given number is a integer. + * @param value The number to check. + */ +function isInteger$1(value) { + return typeof value === 'number' && isFinite(value) && Math.floor(value) === value; +} +/** + * Throws if Node.js version is too low to support bigint + */ +function bigIntAndBufferInt64Check(bufferMethod) { + if (typeof BigInt === 'undefined') { + throw new Error('Platform does not support JS BigInt type.'); + } + if (typeof buffer_1.Buffer.prototype[bufferMethod] === 'undefined') { + throw new Error(`Platform does not support Buffer.prototype.${bufferMethod}.`); + } +} +utils$e.bigIntAndBufferInt64Check = bigIntAndBufferInt64Check; + +Object.defineProperty(smartbuffer, "__esModule", { value: true }); +const utils_1 = utils$e; +// The default Buffer size if one is not provided. +const DEFAULT_SMARTBUFFER_SIZE = 4096; +// The default string encoding to use for reading/writing strings. +const DEFAULT_SMARTBUFFER_ENCODING = 'utf8'; +class SmartBuffer { + /** + * Creates a new SmartBuffer instance. + * + * @param options { SmartBufferOptions } The SmartBufferOptions to apply to this instance. + */ + constructor(options) { + this.length = 0; + this._encoding = DEFAULT_SMARTBUFFER_ENCODING; + this._writeOffset = 0; + this._readOffset = 0; + if (SmartBuffer.isSmartBufferOptions(options)) { + // Checks for encoding + if (options.encoding) { + utils_1.checkEncoding(options.encoding); + this._encoding = options.encoding; + } + // Checks for initial size length + if (options.size) { + if (utils_1.isFiniteInteger(options.size) && options.size > 0) { + this._buff = Buffer.allocUnsafe(options.size); + } + else { + throw new Error(utils_1.ERRORS.INVALID_SMARTBUFFER_SIZE); + } + // Check for initial Buffer + } + else if (options.buff) { + if (Buffer.isBuffer(options.buff)) { + this._buff = options.buff; + this.length = options.buff.length; + } + else { + throw new Error(utils_1.ERRORS.INVALID_SMARTBUFFER_BUFFER); + } + } + else { + this._buff = Buffer.allocUnsafe(DEFAULT_SMARTBUFFER_SIZE); + } + } + else { + // If something was passed but it's not a SmartBufferOptions object + if (typeof options !== 'undefined') { + throw new Error(utils_1.ERRORS.INVALID_SMARTBUFFER_OBJECT); + } + // Otherwise default to sane options + this._buff = Buffer.allocUnsafe(DEFAULT_SMARTBUFFER_SIZE); + } + } + /** + * Creates a new SmartBuffer instance with the provided internal Buffer size and optional encoding. + * + * @param size { Number } The size of the internal Buffer. + * @param encoding { String } The BufferEncoding to use for strings. + * + * @return { SmartBuffer } + */ + static fromSize(size, encoding) { + return new this({ + size: size, + encoding: encoding + }); + } + /** + * Creates a new SmartBuffer instance with the provided Buffer and optional encoding. + * + * @param buffer { Buffer } The Buffer to use as the internal Buffer value. + * @param encoding { String } The BufferEncoding to use for strings. + * + * @return { SmartBuffer } + */ + static fromBuffer(buff, encoding) { + return new this({ + buff: buff, + encoding: encoding + }); + } + /** + * Creates a new SmartBuffer instance with the provided SmartBufferOptions options. + * + * @param options { SmartBufferOptions } The options to use when creating the SmartBuffer instance. + */ + static fromOptions(options) { + return new this(options); + } + /** + * Type checking function that determines if an object is a SmartBufferOptions object. + */ + static isSmartBufferOptions(options) { + const castOptions = options; + return (castOptions && + (castOptions.encoding !== undefined || castOptions.size !== undefined || castOptions.buff !== undefined)); + } + // Signed integers + /** + * Reads an Int8 value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { Number } + */ + readInt8(offset) { + return this._readNumberValue(Buffer.prototype.readInt8, 1, offset); + } + /** + * Reads an Int16BE value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { Number } + */ + readInt16BE(offset) { + return this._readNumberValue(Buffer.prototype.readInt16BE, 2, offset); + } + /** + * Reads an Int16LE value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { Number } + */ + readInt16LE(offset) { + return this._readNumberValue(Buffer.prototype.readInt16LE, 2, offset); + } + /** + * Reads an Int32BE value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { Number } + */ + readInt32BE(offset) { + return this._readNumberValue(Buffer.prototype.readInt32BE, 4, offset); + } + /** + * Reads an Int32LE value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { Number } + */ + readInt32LE(offset) { + return this._readNumberValue(Buffer.prototype.readInt32LE, 4, offset); + } + /** + * Reads a BigInt64BE value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { BigInt } + */ + readBigInt64BE(offset) { + utils_1.bigIntAndBufferInt64Check('readBigInt64BE'); + return this._readNumberValue(Buffer.prototype.readBigInt64BE, 8, offset); + } + /** + * Reads a BigInt64LE value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { BigInt } + */ + readBigInt64LE(offset) { + utils_1.bigIntAndBufferInt64Check('readBigInt64LE'); + return this._readNumberValue(Buffer.prototype.readBigInt64LE, 8, offset); + } + /** + * Writes an Int8 value to the current write position (or at optional offset). + * + * @param value { Number } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeInt8(value, offset) { + this._writeNumberValue(Buffer.prototype.writeInt8, 1, value, offset); + return this; + } + /** + * Inserts an Int8 value at the given offset value. + * + * @param value { Number } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertInt8(value, offset) { + return this._insertNumberValue(Buffer.prototype.writeInt8, 1, value, offset); + } + /** + * Writes an Int16BE value to the current write position (or at optional offset). + * + * @param value { Number } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeInt16BE(value, offset) { + return this._writeNumberValue(Buffer.prototype.writeInt16BE, 2, value, offset); + } + /** + * Inserts an Int16BE value at the given offset value. + * + * @param value { Number } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertInt16BE(value, offset) { + return this._insertNumberValue(Buffer.prototype.writeInt16BE, 2, value, offset); + } + /** + * Writes an Int16LE value to the current write position (or at optional offset). + * + * @param value { Number } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeInt16LE(value, offset) { + return this._writeNumberValue(Buffer.prototype.writeInt16LE, 2, value, offset); + } + /** + * Inserts an Int16LE value at the given offset value. + * + * @param value { Number } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertInt16LE(value, offset) { + return this._insertNumberValue(Buffer.prototype.writeInt16LE, 2, value, offset); + } + /** + * Writes an Int32BE value to the current write position (or at optional offset). + * + * @param value { Number } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeInt32BE(value, offset) { + return this._writeNumberValue(Buffer.prototype.writeInt32BE, 4, value, offset); + } + /** + * Inserts an Int32BE value at the given offset value. + * + * @param value { Number } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertInt32BE(value, offset) { + return this._insertNumberValue(Buffer.prototype.writeInt32BE, 4, value, offset); + } + /** + * Writes an Int32LE value to the current write position (or at optional offset). + * + * @param value { Number } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeInt32LE(value, offset) { + return this._writeNumberValue(Buffer.prototype.writeInt32LE, 4, value, offset); + } + /** + * Inserts an Int32LE value at the given offset value. + * + * @param value { Number } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertInt32LE(value, offset) { + return this._insertNumberValue(Buffer.prototype.writeInt32LE, 4, value, offset); + } + /** + * Writes a BigInt64BE value to the current write position (or at optional offset). + * + * @param value { BigInt } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeBigInt64BE(value, offset) { + utils_1.bigIntAndBufferInt64Check('writeBigInt64BE'); + return this._writeNumberValue(Buffer.prototype.writeBigInt64BE, 8, value, offset); + } + /** + * Inserts a BigInt64BE value at the given offset value. + * + * @param value { BigInt } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertBigInt64BE(value, offset) { + utils_1.bigIntAndBufferInt64Check('writeBigInt64BE'); + return this._insertNumberValue(Buffer.prototype.writeBigInt64BE, 8, value, offset); + } + /** + * Writes a BigInt64LE value to the current write position (or at optional offset). + * + * @param value { BigInt } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeBigInt64LE(value, offset) { + utils_1.bigIntAndBufferInt64Check('writeBigInt64LE'); + return this._writeNumberValue(Buffer.prototype.writeBigInt64LE, 8, value, offset); + } + /** + * Inserts a Int64LE value at the given offset value. + * + * @param value { BigInt } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertBigInt64LE(value, offset) { + utils_1.bigIntAndBufferInt64Check('writeBigInt64LE'); + return this._insertNumberValue(Buffer.prototype.writeBigInt64LE, 8, value, offset); + } + // Unsigned Integers + /** + * Reads an UInt8 value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { Number } + */ + readUInt8(offset) { + return this._readNumberValue(Buffer.prototype.readUInt8, 1, offset); + } + /** + * Reads an UInt16BE value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { Number } + */ + readUInt16BE(offset) { + return this._readNumberValue(Buffer.prototype.readUInt16BE, 2, offset); + } + /** + * Reads an UInt16LE value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { Number } + */ + readUInt16LE(offset) { + return this._readNumberValue(Buffer.prototype.readUInt16LE, 2, offset); + } + /** + * Reads an UInt32BE value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { Number } + */ + readUInt32BE(offset) { + return this._readNumberValue(Buffer.prototype.readUInt32BE, 4, offset); + } + /** + * Reads an UInt32LE value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { Number } + */ + readUInt32LE(offset) { + return this._readNumberValue(Buffer.prototype.readUInt32LE, 4, offset); + } + /** + * Reads a BigUInt64BE value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { BigInt } + */ + readBigUInt64BE(offset) { + utils_1.bigIntAndBufferInt64Check('readBigUInt64BE'); + return this._readNumberValue(Buffer.prototype.readBigUInt64BE, 8, offset); + } + /** + * Reads a BigUInt64LE value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { BigInt } + */ + readBigUInt64LE(offset) { + utils_1.bigIntAndBufferInt64Check('readBigUInt64LE'); + return this._readNumberValue(Buffer.prototype.readBigUInt64LE, 8, offset); + } + /** + * Writes an UInt8 value to the current write position (or at optional offset). + * + * @param value { Number } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeUInt8(value, offset) { + return this._writeNumberValue(Buffer.prototype.writeUInt8, 1, value, offset); + } + /** + * Inserts an UInt8 value at the given offset value. + * + * @param value { Number } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertUInt8(value, offset) { + return this._insertNumberValue(Buffer.prototype.writeUInt8, 1, value, offset); + } + /** + * Writes an UInt16BE value to the current write position (or at optional offset). + * + * @param value { Number } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeUInt16BE(value, offset) { + return this._writeNumberValue(Buffer.prototype.writeUInt16BE, 2, value, offset); + } + /** + * Inserts an UInt16BE value at the given offset value. + * + * @param value { Number } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertUInt16BE(value, offset) { + return this._insertNumberValue(Buffer.prototype.writeUInt16BE, 2, value, offset); + } + /** + * Writes an UInt16LE value to the current write position (or at optional offset). + * + * @param value { Number } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeUInt16LE(value, offset) { + return this._writeNumberValue(Buffer.prototype.writeUInt16LE, 2, value, offset); + } + /** + * Inserts an UInt16LE value at the given offset value. + * + * @param value { Number } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertUInt16LE(value, offset) { + return this._insertNumberValue(Buffer.prototype.writeUInt16LE, 2, value, offset); + } + /** + * Writes an UInt32BE value to the current write position (or at optional offset). + * + * @param value { Number } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeUInt32BE(value, offset) { + return this._writeNumberValue(Buffer.prototype.writeUInt32BE, 4, value, offset); + } + /** + * Inserts an UInt32BE value at the given offset value. + * + * @param value { Number } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertUInt32BE(value, offset) { + return this._insertNumberValue(Buffer.prototype.writeUInt32BE, 4, value, offset); + } + /** + * Writes an UInt32LE value to the current write position (or at optional offset). + * + * @param value { Number } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeUInt32LE(value, offset) { + return this._writeNumberValue(Buffer.prototype.writeUInt32LE, 4, value, offset); + } + /** + * Inserts an UInt32LE value at the given offset value. + * + * @param value { Number } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertUInt32LE(value, offset) { + return this._insertNumberValue(Buffer.prototype.writeUInt32LE, 4, value, offset); + } + /** + * Writes a BigUInt64BE value to the current write position (or at optional offset). + * + * @param value { Number } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeBigUInt64BE(value, offset) { + utils_1.bigIntAndBufferInt64Check('writeBigUInt64BE'); + return this._writeNumberValue(Buffer.prototype.writeBigUInt64BE, 8, value, offset); + } + /** + * Inserts a BigUInt64BE value at the given offset value. + * + * @param value { Number } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertBigUInt64BE(value, offset) { + utils_1.bigIntAndBufferInt64Check('writeBigUInt64BE'); + return this._insertNumberValue(Buffer.prototype.writeBigUInt64BE, 8, value, offset); + } + /** + * Writes a BigUInt64LE value to the current write position (or at optional offset). + * + * @param value { Number } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeBigUInt64LE(value, offset) { + utils_1.bigIntAndBufferInt64Check('writeBigUInt64LE'); + return this._writeNumberValue(Buffer.prototype.writeBigUInt64LE, 8, value, offset); + } + /** + * Inserts a BigUInt64LE value at the given offset value. + * + * @param value { Number } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertBigUInt64LE(value, offset) { + utils_1.bigIntAndBufferInt64Check('writeBigUInt64LE'); + return this._insertNumberValue(Buffer.prototype.writeBigUInt64LE, 8, value, offset); + } + // Floating Point + /** + * Reads an FloatBE value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { Number } + */ + readFloatBE(offset) { + return this._readNumberValue(Buffer.prototype.readFloatBE, 4, offset); + } + /** + * Reads an FloatLE value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { Number } + */ + readFloatLE(offset) { + return this._readNumberValue(Buffer.prototype.readFloatLE, 4, offset); + } + /** + * Writes a FloatBE value to the current write position (or at optional offset). + * + * @param value { Number } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeFloatBE(value, offset) { + return this._writeNumberValue(Buffer.prototype.writeFloatBE, 4, value, offset); + } + /** + * Inserts a FloatBE value at the given offset value. + * + * @param value { Number } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertFloatBE(value, offset) { + return this._insertNumberValue(Buffer.prototype.writeFloatBE, 4, value, offset); + } + /** + * Writes a FloatLE value to the current write position (or at optional offset). + * + * @param value { Number } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeFloatLE(value, offset) { + return this._writeNumberValue(Buffer.prototype.writeFloatLE, 4, value, offset); + } + /** + * Inserts a FloatLE value at the given offset value. + * + * @param value { Number } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertFloatLE(value, offset) { + return this._insertNumberValue(Buffer.prototype.writeFloatLE, 4, value, offset); + } + // Double Floating Point + /** + * Reads an DoublEBE value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { Number } + */ + readDoubleBE(offset) { + return this._readNumberValue(Buffer.prototype.readDoubleBE, 8, offset); + } + /** + * Reads an DoubleLE value from the current read position or an optionally provided offset. + * + * @param offset { Number } The offset to read data from (optional) + * @return { Number } + */ + readDoubleLE(offset) { + return this._readNumberValue(Buffer.prototype.readDoubleLE, 8, offset); + } + /** + * Writes a DoubleBE value to the current write position (or at optional offset). + * + * @param value { Number } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeDoubleBE(value, offset) { + return this._writeNumberValue(Buffer.prototype.writeDoubleBE, 8, value, offset); + } + /** + * Inserts a DoubleBE value at the given offset value. + * + * @param value { Number } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertDoubleBE(value, offset) { + return this._insertNumberValue(Buffer.prototype.writeDoubleBE, 8, value, offset); + } + /** + * Writes a DoubleLE value to the current write position (or at optional offset). + * + * @param value { Number } The value to write. + * @param offset { Number } The offset to write the value at. + * + * @return this + */ + writeDoubleLE(value, offset) { + return this._writeNumberValue(Buffer.prototype.writeDoubleLE, 8, value, offset); + } + /** + * Inserts a DoubleLE value at the given offset value. + * + * @param value { Number } The value to insert. + * @param offset { Number } The offset to insert the value at. + * + * @return this + */ + insertDoubleLE(value, offset) { + return this._insertNumberValue(Buffer.prototype.writeDoubleLE, 8, value, offset); + } + // Strings + /** + * Reads a String from the current read position. + * + * @param arg1 { Number | String } The number of bytes to read as a String, or the BufferEncoding to use for + * the string (Defaults to instance level encoding). + * @param encoding { String } The BufferEncoding to use for the string (Defaults to instance level encoding). + * + * @return { String } + */ + readString(arg1, encoding) { + let lengthVal; + // Length provided + if (typeof arg1 === 'number') { + utils_1.checkLengthValue(arg1); + lengthVal = Math.min(arg1, this.length - this._readOffset); + } + else { + encoding = arg1; + lengthVal = this.length - this._readOffset; + } + // Check encoding + if (typeof encoding !== 'undefined') { + utils_1.checkEncoding(encoding); + } + const value = this._buff.slice(this._readOffset, this._readOffset + lengthVal).toString(encoding || this._encoding); + this._readOffset += lengthVal; + return value; + } + /** + * Inserts a String + * + * @param value { String } The String value to insert. + * @param offset { Number } The offset to insert the string at. + * @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding). + * + * @return this + */ + insertString(value, offset, encoding) { + utils_1.checkOffsetValue(offset); + return this._handleString(value, true, offset, encoding); + } + /** + * Writes a String + * + * @param value { String } The String value to write. + * @param arg2 { Number | String } The offset to write the string at, or the BufferEncoding to use. + * @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding). + * + * @return this + */ + writeString(value, arg2, encoding) { + return this._handleString(value, false, arg2, encoding); + } + /** + * Reads a null-terminated String from the current read position. + * + * @param encoding { String } The BufferEncoding to use for the string (Defaults to instance level encoding). + * + * @return { String } + */ + readStringNT(encoding) { + if (typeof encoding !== 'undefined') { + utils_1.checkEncoding(encoding); + } + // Set null character position to the end SmartBuffer instance. + let nullPos = this.length; + // Find next null character (if one is not found, default from above is used) + for (let i = this._readOffset; i < this.length; i++) { + if (this._buff[i] === 0x00) { + nullPos = i; + break; + } + } + // Read string value + const value = this._buff.slice(this._readOffset, nullPos); + // Increment internal Buffer read offset + this._readOffset = nullPos + 1; + return value.toString(encoding || this._encoding); + } + /** + * Inserts a null-terminated String. + * + * @param value { String } The String value to write. + * @param arg2 { Number | String } The offset to write the string to, or the BufferEncoding to use. + * @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding). + * + * @return this + */ + insertStringNT(value, offset, encoding) { + utils_1.checkOffsetValue(offset); + // Write Values + this.insertString(value, offset, encoding); + this.insertUInt8(0x00, offset + value.length); + return this; + } + /** + * Writes a null-terminated String. + * + * @param value { String } The String value to write. + * @param arg2 { Number | String } The offset to write the string to, or the BufferEncoding to use. + * @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding). + * + * @return this + */ + writeStringNT(value, arg2, encoding) { + // Write Values + this.writeString(value, arg2, encoding); + this.writeUInt8(0x00, typeof arg2 === 'number' ? arg2 + value.length : this.writeOffset); + return this; + } + // Buffers + /** + * Reads a Buffer from the internal read position. + * + * @param length { Number } The length of data to read as a Buffer. + * + * @return { Buffer } + */ + readBuffer(length) { + if (typeof length !== 'undefined') { + utils_1.checkLengthValue(length); + } + const lengthVal = typeof length === 'number' ? length : this.length; + const endPoint = Math.min(this.length, this._readOffset + lengthVal); + // Read buffer value + const value = this._buff.slice(this._readOffset, endPoint); + // Increment internal Buffer read offset + this._readOffset = endPoint; + return value; + } + /** + * Writes a Buffer to the current write position. + * + * @param value { Buffer } The Buffer to write. + * @param offset { Number } The offset to write the Buffer to. + * + * @return this + */ + insertBuffer(value, offset) { + utils_1.checkOffsetValue(offset); + return this._handleBuffer(value, true, offset); + } + /** + * Writes a Buffer to the current write position. + * + * @param value { Buffer } The Buffer to write. + * @param offset { Number } The offset to write the Buffer to. + * + * @return this + */ + writeBuffer(value, offset) { + return this._handleBuffer(value, false, offset); + } + /** + * Reads a null-terminated Buffer from the current read poisiton. + * + * @return { Buffer } + */ + readBufferNT() { + // Set null character position to the end SmartBuffer instance. + let nullPos = this.length; + // Find next null character (if one is not found, default from above is used) + for (let i = this._readOffset; i < this.length; i++) { + if (this._buff[i] === 0x00) { + nullPos = i; + break; + } + } + // Read value + const value = this._buff.slice(this._readOffset, nullPos); + // Increment internal Buffer read offset + this._readOffset = nullPos + 1; + return value; + } + /** + * Inserts a null-terminated Buffer. + * + * @param value { Buffer } The Buffer to write. + * @param offset { Number } The offset to write the Buffer to. + * + * @return this + */ + insertBufferNT(value, offset) { + utils_1.checkOffsetValue(offset); + // Write Values + this.insertBuffer(value, offset); + this.insertUInt8(0x00, offset + value.length); + return this; + } + /** + * Writes a null-terminated Buffer. + * + * @param value { Buffer } The Buffer to write. + * @param offset { Number } The offset to write the Buffer to. + * + * @return this + */ + writeBufferNT(value, offset) { + // Checks for valid numberic value; + if (typeof offset !== 'undefined') { + utils_1.checkOffsetValue(offset); + } + // Write Values + this.writeBuffer(value, offset); + this.writeUInt8(0x00, typeof offset === 'number' ? offset + value.length : this._writeOffset); + return this; + } + /** + * Clears the SmartBuffer instance to its original empty state. + */ + clear() { + this._writeOffset = 0; + this._readOffset = 0; + this.length = 0; + return this; + } + /** + * Gets the remaining data left to be read from the SmartBuffer instance. + * + * @return { Number } + */ + remaining() { + return this.length - this._readOffset; + } + /** + * Gets the current read offset value of the SmartBuffer instance. + * + * @return { Number } + */ + get readOffset() { + return this._readOffset; + } + /** + * Sets the read offset value of the SmartBuffer instance. + * + * @param offset { Number } - The offset value to set. + */ + set readOffset(offset) { + utils_1.checkOffsetValue(offset); + // Check for bounds. + utils_1.checkTargetOffset(offset, this); + this._readOffset = offset; + } + /** + * Gets the current write offset value of the SmartBuffer instance. + * + * @return { Number } + */ + get writeOffset() { + return this._writeOffset; + } + /** + * Sets the write offset value of the SmartBuffer instance. + * + * @param offset { Number } - The offset value to set. + */ + set writeOffset(offset) { + utils_1.checkOffsetValue(offset); + // Check for bounds. + utils_1.checkTargetOffset(offset, this); + this._writeOffset = offset; + } + /** + * Gets the currently set string encoding of the SmartBuffer instance. + * + * @return { BufferEncoding } The string Buffer encoding currently set. + */ + get encoding() { + return this._encoding; + } + /** + * Sets the string encoding of the SmartBuffer instance. + * + * @param encoding { BufferEncoding } The string Buffer encoding to set. + */ + set encoding(encoding) { + utils_1.checkEncoding(encoding); + this._encoding = encoding; + } + /** + * Gets the underlying internal Buffer. (This includes unmanaged data in the Buffer) + * + * @return { Buffer } The Buffer value. + */ + get internalBuffer() { + return this._buff; + } + /** + * Gets the value of the internal managed Buffer (Includes managed data only) + * + * @param { Buffer } + */ + toBuffer() { + return this._buff.slice(0, this.length); + } + /** + * Gets the String value of the internal managed Buffer + * + * @param encoding { String } The BufferEncoding to display the Buffer as (defaults to instance level encoding). + */ + toString(encoding) { + const encodingVal = typeof encoding === 'string' ? encoding : this._encoding; + // Check for invalid encoding. + utils_1.checkEncoding(encodingVal); + return this._buff.toString(encodingVal, 0, this.length); + } + /** + * Destroys the SmartBuffer instance. + */ + destroy() { + this.clear(); + return this; + } + /** + * Handles inserting and writing strings. + * + * @param value { String } The String value to insert. + * @param isInsert { Boolean } True if inserting a string, false if writing. + * @param arg2 { Number | String } The offset to insert the string at, or the BufferEncoding to use. + * @param encoding { String } The BufferEncoding to use for writing strings (defaults to instance encoding). + */ + _handleString(value, isInsert, arg3, encoding) { + let offsetVal = this._writeOffset; + let encodingVal = this._encoding; + // Check for offset + if (typeof arg3 === 'number') { + offsetVal = arg3; + // Check for encoding + } + else if (typeof arg3 === 'string') { + utils_1.checkEncoding(arg3); + encodingVal = arg3; + } + // Check for encoding (third param) + if (typeof encoding === 'string') { + utils_1.checkEncoding(encoding); + encodingVal = encoding; + } + // Calculate bytelength of string. + const byteLength = Buffer.byteLength(value, encodingVal); + // Ensure there is enough internal Buffer capacity. + if (isInsert) { + this.ensureInsertable(byteLength, offsetVal); + } + else { + this._ensureWriteable(byteLength, offsetVal); + } + // Write value + this._buff.write(value, offsetVal, byteLength, encodingVal); + // Increment internal Buffer write offset; + if (isInsert) { + this._writeOffset += byteLength; + } + else { + // If an offset was given, check to see if we wrote beyond the current writeOffset. + if (typeof arg3 === 'number') { + this._writeOffset = Math.max(this._writeOffset, offsetVal + byteLength); + } + else { + // If no offset was given, we wrote to the end of the SmartBuffer so increment writeOffset. + this._writeOffset += byteLength; + } + } + return this; + } + /** + * Handles writing or insert of a Buffer. + * + * @param value { Buffer } The Buffer to write. + * @param offset { Number } The offset to write the Buffer to. + */ + _handleBuffer(value, isInsert, offset) { + const offsetVal = typeof offset === 'number' ? offset : this._writeOffset; + // Ensure there is enough internal Buffer capacity. + if (isInsert) { + this.ensureInsertable(value.length, offsetVal); + } + else { + this._ensureWriteable(value.length, offsetVal); + } + // Write buffer value + value.copy(this._buff, offsetVal); + // Increment internal Buffer write offset; + if (isInsert) { + this._writeOffset += value.length; + } + else { + // If an offset was given, check to see if we wrote beyond the current writeOffset. + if (typeof offset === 'number') { + this._writeOffset = Math.max(this._writeOffset, offsetVal + value.length); + } + else { + // If no offset was given, we wrote to the end of the SmartBuffer so increment writeOffset. + this._writeOffset += value.length; + } + } + return this; + } + /** + * Ensures that the internal Buffer is large enough to read data. + * + * @param length { Number } The length of the data that needs to be read. + * @param offset { Number } The offset of the data that needs to be read. + */ + ensureReadable(length, offset) { + // Offset value defaults to managed read offset. + let offsetVal = this._readOffset; + // If an offset was provided, use it. + if (typeof offset !== 'undefined') { + // Checks for valid numberic value; + utils_1.checkOffsetValue(offset); + // Overide with custom offset. + offsetVal = offset; + } + // Checks if offset is below zero, or the offset+length offset is beyond the total length of the managed data. + if (offsetVal < 0 || offsetVal + length > this.length) { + throw new Error(utils_1.ERRORS.INVALID_READ_BEYOND_BOUNDS); + } + } + /** + * Ensures that the internal Buffer is large enough to insert data. + * + * @param dataLength { Number } The length of the data that needs to be written. + * @param offset { Number } The offset of the data to be written. + */ + ensureInsertable(dataLength, offset) { + // Checks for valid numberic value; + utils_1.checkOffsetValue(offset); + // Ensure there is enough internal Buffer capacity. + this._ensureCapacity(this.length + dataLength); + // If an offset was provided and its not the very end of the buffer, copy data into appropriate location in regards to the offset. + if (offset < this.length) { + this._buff.copy(this._buff, offset + dataLength, offset, this._buff.length); + } + // Adjust tracked smart buffer length + if (offset + dataLength > this.length) { + this.length = offset + dataLength; + } + else { + this.length += dataLength; + } + } + /** + * Ensures that the internal Buffer is large enough to write data. + * + * @param dataLength { Number } The length of the data that needs to be written. + * @param offset { Number } The offset of the data to be written (defaults to writeOffset). + */ + _ensureWriteable(dataLength, offset) { + const offsetVal = typeof offset === 'number' ? offset : this._writeOffset; + // Ensure enough capacity to write data. + this._ensureCapacity(offsetVal + dataLength); + // Adjust SmartBuffer length (if offset + length is larger than managed length, adjust length) + if (offsetVal + dataLength > this.length) { + this.length = offsetVal + dataLength; + } + } + /** + * Ensures that the internal Buffer is large enough to write at least the given amount of data. + * + * @param minLength { Number } The minimum length of the data needs to be written. + */ + _ensureCapacity(minLength) { + const oldLength = this._buff.length; + if (minLength > oldLength) { + let data = this._buff; + let newLength = (oldLength * 3) / 2 + 1; + if (newLength < minLength) { + newLength = minLength; + } + this._buff = Buffer.allocUnsafe(newLength); + data.copy(this._buff, 0, 0, oldLength); + } + } + /** + * Reads a numeric number value using the provided function. + * + * @typeparam T { number | bigint } The type of the value to be read + * + * @param func { Function(offset: number) => number } The function to read data on the internal Buffer with. + * @param byteSize { Number } The number of bytes read. + * @param offset { Number } The offset to read from (optional). When this is not provided, the managed readOffset is used instead. + * + * @returns { T } the number value + */ + _readNumberValue(func, byteSize, offset) { + this.ensureReadable(byteSize, offset); + // Call Buffer.readXXXX(); + const value = func.call(this._buff, typeof offset === 'number' ? offset : this._readOffset); + // Adjust internal read offset if an optional read offset was not provided. + if (typeof offset === 'undefined') { + this._readOffset += byteSize; + } + return value; + } + /** + * Inserts a numeric number value based on the given offset and value. + * + * @typeparam T { number | bigint } The type of the value to be written + * + * @param func { Function(offset: T, offset?) => number} The function to write data on the internal Buffer with. + * @param byteSize { Number } The number of bytes written. + * @param value { T } The number value to write. + * @param offset { Number } the offset to write the number at (REQUIRED). + * + * @returns SmartBuffer this buffer + */ + _insertNumberValue(func, byteSize, value, offset) { + // Check for invalid offset values. + utils_1.checkOffsetValue(offset); + // Ensure there is enough internal Buffer capacity. (raw offset is passed) + this.ensureInsertable(byteSize, offset); + // Call buffer.writeXXXX(); + func.call(this._buff, value, offset); + // Adjusts internally managed write offset. + this._writeOffset += byteSize; + return this; + } + /** + * Writes a numeric number value based on the given offset and value. + * + * @typeparam T { number | bigint } The type of the value to be written + * + * @param func { Function(offset: T, offset?) => number} The function to write data on the internal Buffer with. + * @param byteSize { Number } The number of bytes written. + * @param value { T } The number value to write. + * @param offset { Number } the offset to write the number at (REQUIRED). + * + * @returns SmartBuffer this buffer + */ + _writeNumberValue(func, byteSize, value, offset) { + // If an offset was provided, validate it. + if (typeof offset === 'number') { + // Check if we're writing beyond the bounds of the managed data. + if (offset < 0) { + throw new Error(utils_1.ERRORS.INVALID_WRITE_BEYOND_BOUNDS); + } + utils_1.checkOffsetValue(offset); + } + // Default to writeOffset if no offset value was given. + const offsetVal = typeof offset === 'number' ? offset : this._writeOffset; + // Ensure there is enough internal Buffer capacity. (raw offset is passed) + this._ensureWriteable(byteSize, offsetVal); + func.call(this._buff, value, offsetVal); + // If an offset was given, check to see if we wrote beyond the current writeOffset. + if (typeof offset === 'number') { + this._writeOffset = Math.max(this._writeOffset, offsetVal + byteSize); + } + else { + // If no numeric offset was given, we wrote to the end of the SmartBuffer so increment writeOffset. + this._writeOffset += byteSize; + } + return this; + } +} +smartbuffer.SmartBuffer = SmartBuffer; + +var constants$3 = {}; + +Object.defineProperty(constants$3, "__esModule", { value: true }); +constants$3.SOCKS5_NO_ACCEPTABLE_AUTH = constants$3.SOCKS5_CUSTOM_AUTH_END = constants$3.SOCKS5_CUSTOM_AUTH_START = constants$3.SOCKS_INCOMING_PACKET_SIZES = constants$3.SocksClientState = constants$3.Socks5Response = constants$3.Socks5HostType = constants$3.Socks5Auth = constants$3.Socks4Response = constants$3.SocksCommand = constants$3.ERRORS = constants$3.DEFAULT_TIMEOUT = void 0; +const DEFAULT_TIMEOUT = 30000; +constants$3.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT; +// prettier-ignore +const ERRORS = { + InvalidSocksCommand: 'An invalid SOCKS command was provided. Valid options are connect, bind, and associate.', + InvalidSocksCommandForOperation: 'An invalid SOCKS command was provided. Only a subset of commands are supported for this operation.', + InvalidSocksCommandChain: 'An invalid SOCKS command was provided. Chaining currently only supports the connect command.', + InvalidSocksClientOptionsDestination: 'An invalid destination host was provided.', + InvalidSocksClientOptionsExistingSocket: 'An invalid existing socket was provided. This should be an instance of stream.Duplex.', + InvalidSocksClientOptionsProxy: 'Invalid SOCKS proxy details were provided.', + InvalidSocksClientOptionsTimeout: 'An invalid timeout value was provided. Please enter a value above 0 (in ms).', + InvalidSocksClientOptionsProxiesLength: 'At least two socks proxies must be provided for chaining.', + InvalidSocksClientOptionsCustomAuthRange: 'Custom auth must be a value between 0x80 and 0xFE.', + InvalidSocksClientOptionsCustomAuthOptions: 'When a custom_auth_method is provided, custom_auth_request_handler, custom_auth_response_size, and custom_auth_response_handler must also be provided and valid.', + NegotiationError: 'Negotiation error', + SocketClosed: 'Socket closed', + ProxyConnectionTimedOut: 'Proxy connection timed out', + InternalError: 'SocksClient internal error (this should not happen)', + InvalidSocks4HandshakeResponse: 'Received invalid Socks4 handshake response', + Socks4ProxyRejectedConnection: 'Socks4 Proxy rejected connection', + InvalidSocks4IncomingConnectionResponse: 'Socks4 invalid incoming connection response', + Socks4ProxyRejectedIncomingBoundConnection: 'Socks4 Proxy rejected incoming bound connection', + InvalidSocks5InitialHandshakeResponse: 'Received invalid Socks5 initial handshake response', + InvalidSocks5IntiailHandshakeSocksVersion: 'Received invalid Socks5 initial handshake (invalid socks version)', + InvalidSocks5InitialHandshakeNoAcceptedAuthType: 'Received invalid Socks5 initial handshake (no accepted authentication type)', + InvalidSocks5InitialHandshakeUnknownAuthType: 'Received invalid Socks5 initial handshake (unknown authentication type)', + Socks5AuthenticationFailed: 'Socks5 Authentication failed', + InvalidSocks5FinalHandshake: 'Received invalid Socks5 final handshake response', + InvalidSocks5FinalHandshakeRejected: 'Socks5 proxy rejected connection', + InvalidSocks5IncomingConnectionResponse: 'Received invalid Socks5 incoming connection response', + Socks5ProxyRejectedIncomingBoundConnection: 'Socks5 Proxy rejected incoming bound connection', +}; +constants$3.ERRORS = ERRORS; +const SOCKS_INCOMING_PACKET_SIZES = { + Socks5InitialHandshakeResponse: 2, + Socks5UserPassAuthenticationResponse: 2, + // Command response + incoming connection (bind) + Socks5ResponseHeader: 5, // We need at least 5 to read the hostname length, then we wait for the address+port information. + Socks5ResponseIPv4: 10, // 4 header + 4 ip + 2 port + Socks5ResponseIPv6: 22, // 4 header + 16 ip + 2 port + Socks5ResponseHostname: (hostNameLength) => hostNameLength + 7, // 4 header + 1 host length + host + 2 port + // Command response + incoming connection (bind) + Socks4Response: 8, // 2 header + 2 port + 4 ip +}; +constants$3.SOCKS_INCOMING_PACKET_SIZES = SOCKS_INCOMING_PACKET_SIZES; +var SocksCommand; +(function (SocksCommand) { + SocksCommand[SocksCommand["connect"] = 1] = "connect"; + SocksCommand[SocksCommand["bind"] = 2] = "bind"; + SocksCommand[SocksCommand["associate"] = 3] = "associate"; +})(SocksCommand || (constants$3.SocksCommand = SocksCommand = {})); +var Socks4Response; +(function (Socks4Response) { + Socks4Response[Socks4Response["Granted"] = 90] = "Granted"; + Socks4Response[Socks4Response["Failed"] = 91] = "Failed"; + Socks4Response[Socks4Response["Rejected"] = 92] = "Rejected"; + Socks4Response[Socks4Response["RejectedIdent"] = 93] = "RejectedIdent"; +})(Socks4Response || (constants$3.Socks4Response = Socks4Response = {})); +var Socks5Auth; +(function (Socks5Auth) { + Socks5Auth[Socks5Auth["NoAuth"] = 0] = "NoAuth"; + Socks5Auth[Socks5Auth["GSSApi"] = 1] = "GSSApi"; + Socks5Auth[Socks5Auth["UserPass"] = 2] = "UserPass"; +})(Socks5Auth || (constants$3.Socks5Auth = Socks5Auth = {})); +const SOCKS5_CUSTOM_AUTH_START = 0x80; +constants$3.SOCKS5_CUSTOM_AUTH_START = SOCKS5_CUSTOM_AUTH_START; +const SOCKS5_CUSTOM_AUTH_END = 0xfe; +constants$3.SOCKS5_CUSTOM_AUTH_END = SOCKS5_CUSTOM_AUTH_END; +const SOCKS5_NO_ACCEPTABLE_AUTH = 0xff; +constants$3.SOCKS5_NO_ACCEPTABLE_AUTH = SOCKS5_NO_ACCEPTABLE_AUTH; +var Socks5Response; +(function (Socks5Response) { + Socks5Response[Socks5Response["Granted"] = 0] = "Granted"; + Socks5Response[Socks5Response["Failure"] = 1] = "Failure"; + Socks5Response[Socks5Response["NotAllowed"] = 2] = "NotAllowed"; + Socks5Response[Socks5Response["NetworkUnreachable"] = 3] = "NetworkUnreachable"; + Socks5Response[Socks5Response["HostUnreachable"] = 4] = "HostUnreachable"; + Socks5Response[Socks5Response["ConnectionRefused"] = 5] = "ConnectionRefused"; + Socks5Response[Socks5Response["TTLExpired"] = 6] = "TTLExpired"; + Socks5Response[Socks5Response["CommandNotSupported"] = 7] = "CommandNotSupported"; + Socks5Response[Socks5Response["AddressNotSupported"] = 8] = "AddressNotSupported"; +})(Socks5Response || (constants$3.Socks5Response = Socks5Response = {})); +var Socks5HostType; +(function (Socks5HostType) { + Socks5HostType[Socks5HostType["IPv4"] = 1] = "IPv4"; + Socks5HostType[Socks5HostType["Hostname"] = 3] = "Hostname"; + Socks5HostType[Socks5HostType["IPv6"] = 4] = "IPv6"; +})(Socks5HostType || (constants$3.Socks5HostType = Socks5HostType = {})); +var SocksClientState; +(function (SocksClientState) { + SocksClientState[SocksClientState["Created"] = 0] = "Created"; + SocksClientState[SocksClientState["Connecting"] = 1] = "Connecting"; + SocksClientState[SocksClientState["Connected"] = 2] = "Connected"; + SocksClientState[SocksClientState["SentInitialHandshake"] = 3] = "SentInitialHandshake"; + SocksClientState[SocksClientState["ReceivedInitialHandshakeResponse"] = 4] = "ReceivedInitialHandshakeResponse"; + SocksClientState[SocksClientState["SentAuthentication"] = 5] = "SentAuthentication"; + SocksClientState[SocksClientState["ReceivedAuthenticationResponse"] = 6] = "ReceivedAuthenticationResponse"; + SocksClientState[SocksClientState["SentFinalHandshake"] = 7] = "SentFinalHandshake"; + SocksClientState[SocksClientState["ReceivedFinalResponse"] = 8] = "ReceivedFinalResponse"; + SocksClientState[SocksClientState["BoundWaitingForConnection"] = 9] = "BoundWaitingForConnection"; + SocksClientState[SocksClientState["Established"] = 10] = "Established"; + SocksClientState[SocksClientState["Disconnected"] = 11] = "Disconnected"; + SocksClientState[SocksClientState["Error"] = 99] = "Error"; +})(SocksClientState || (constants$3.SocksClientState = SocksClientState = {})); + +var helpers$2 = {}; + +var util$1 = {}; + +Object.defineProperty(util$1, "__esModule", { value: true }); +util$1.shuffleArray = util$1.SocksClientError = void 0; +/** + * Error wrapper for SocksClient + */ +class SocksClientError extends Error { + constructor(message, options) { + super(message); + this.options = options; + } +} +util$1.SocksClientError = SocksClientError; +/** + * Shuffles a given array. + * @param array The array to shuffle. + */ +function shuffleArray(array) { + for (let i = array.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [array[i], array[j]] = [array[j], array[i]]; + } +} +util$1.shuffleArray = shuffleArray; + +var ipAddress = {}; + +var ipv4 = {}; + +var common$2 = {}; + +Object.defineProperty(common$2, "__esModule", { value: true }); +common$2.isCorrect = common$2.isInSubnet = void 0; +function isInSubnet(address) { + if (this.subnetMask < address.subnetMask) { + return false; + } + if (this.mask(address.subnetMask) === address.mask()) { + return true; + } + return false; +} +common$2.isInSubnet = isInSubnet; +function isCorrect(defaultBits) { + return function () { + if (this.addressMinusSuffix !== this.correctForm()) { + return false; + } + if (this.subnetMask === defaultBits && !this.parsedSubnet) { + return true; + } + return this.parsedSubnet === String(this.subnetMask); + }; +} +common$2.isCorrect = isCorrect; + +var constants$2 = {}; + +Object.defineProperty(constants$2, "__esModule", { value: true }); +constants$2.RE_SUBNET_STRING = constants$2.RE_ADDRESS = constants$2.GROUPS = constants$2.BITS = void 0; +constants$2.BITS = 32; +constants$2.GROUPS = 4; +constants$2.RE_ADDRESS = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g; +constants$2.RE_SUBNET_STRING = /\/\d{1,2}$/; + +var addressError = {}; + +Object.defineProperty(addressError, "__esModule", { value: true }); +addressError.AddressError = void 0; +class AddressError extends Error { + constructor(message, parseMessage) { + super(message); + this.name = 'AddressError'; + if (parseMessage !== null) { + this.parseMessage = parseMessage; + } + } +} +addressError.AddressError = AddressError; + +var jsbn = {exports: {}}; + +(function (module, exports) { + (function(){ + + // Copyright (c) 2005 Tom Wu + // All Rights Reserved. + // See "LICENSE" for details. + + // Basic JavaScript BN library - subset useful for RSA encryption. + + // Bits per digit + var dbits; + + // JavaScript engine analysis + var canary = 0xdeadbeefcafe; + var j_lm = ((canary&0xffffff)==0xefcafe); + + // (public) Constructor + function BigInteger(a,b,c) { + if(a != null) + if("number" == typeof a) this.fromNumber(a,b,c); + else if(b == null && "string" != typeof a) this.fromString(a,256); + else this.fromString(a,b); + } + + // return new, unset BigInteger + function nbi() { return new BigInteger(null); } + + // am: Compute w_j += (x*this_i), propagate carries, + // c is initial carry, returns final carry. + // c < 3*dvalue, x < 2*dvalue, this_i < dvalue + // We need to select the fastest one that works in this environment. + + // am1: use a single mult and divide to get the high bits, + // max digit bits should be 26 because + // max internal value = 2*dvalue^2-2*dvalue (< 2^53) + function am1(i,x,w,j,c,n) { + while(--n >= 0) { + var v = x*this[i++]+w[j]+c; + c = Math.floor(v/0x4000000); + w[j++] = v&0x3ffffff; + } + return c; + } + // am2 avoids a big mult-and-extract completely. + // Max digit bits should be <= 30 because we do bitwise ops + // on values up to 2*hdvalue^2-hdvalue-1 (< 2^31) + function am2(i,x,w,j,c,n) { + var xl = x&0x7fff, xh = x>>15; + while(--n >= 0) { + var l = this[i]&0x7fff; + var h = this[i++]>>15; + var m = xh*l+h*xl; + l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff); + c = (l>>>30)+(m>>>15)+xh*h+(c>>>30); + w[j++] = l&0x3fffffff; + } + return c; + } + // Alternately, set max digit bits to 28 since some + // browsers slow down when dealing with 32-bit numbers. + function am3(i,x,w,j,c,n) { + var xl = x&0x3fff, xh = x>>14; + while(--n >= 0) { + var l = this[i]&0x3fff; + var h = this[i++]>>14; + var m = xh*l+h*xl; + l = xl*l+((m&0x3fff)<<14)+w[j]+c; + c = (l>>28)+(m>>14)+xh*h; + w[j++] = l&0xfffffff; + } + return c; + } + var inBrowser = typeof navigator !== "undefined"; + if(inBrowser && j_lm && (navigator.appName == "Microsoft Internet Explorer")) { + BigInteger.prototype.am = am2; + dbits = 30; + } + else if(inBrowser && j_lm && (navigator.appName != "Netscape")) { + BigInteger.prototype.am = am1; + dbits = 26; + } + else { // Mozilla/Netscape seems to prefer am3 + BigInteger.prototype.am = am3; + dbits = 28; + } + + BigInteger.prototype.DB = dbits; + BigInteger.prototype.DM = ((1<= 0; --i) r[i] = this[i]; + r.t = this.t; + r.s = this.s; + } + + // (protected) set from integer value x, -DV <= x < DV + function bnpFromInt(x) { + this.t = 1; + this.s = (x<0)?-1:0; + if(x > 0) this[0] = x; + else if(x < -1) this[0] = x+this.DV; + else this.t = 0; + } + + // return bigint initialized to value + function nbv(i) { var r = nbi(); r.fromInt(i); return r; } + + // (protected) set from string and radix + function bnpFromString(s,b) { + var k; + if(b == 16) k = 4; + else if(b == 8) k = 3; + else if(b == 256) k = 8; // byte array + else if(b == 2) k = 1; + else if(b == 32) k = 5; + else if(b == 4) k = 2; + else { this.fromRadix(s,b); return; } + this.t = 0; + this.s = 0; + var i = s.length, mi = false, sh = 0; + while(--i >= 0) { + var x = (k==8)?s[i]&0xff:intAt(s,i); + if(x < 0) { + if(s.charAt(i) == "-") mi = true; + continue; + } + mi = false; + if(sh == 0) + this[this.t++] = x; + else if(sh+k > this.DB) { + this[this.t-1] |= (x&((1<<(this.DB-sh))-1))<>(this.DB-sh)); + } + else + this[this.t-1] |= x<= this.DB) sh -= this.DB; + } + if(k == 8 && (s[0]&0x80) != 0) { + this.s = -1; + if(sh > 0) this[this.t-1] |= ((1<<(this.DB-sh))-1)< 0 && this[this.t-1] == c) --this.t; + } + + // (public) return string representation in given radix + function bnToString(b) { + if(this.s < 0) return "-"+this.negate().toString(b); + var k; + if(b == 16) k = 4; + else if(b == 8) k = 3; + else if(b == 2) k = 1; + else if(b == 32) k = 5; + else if(b == 4) k = 2; + else return this.toRadix(b); + var km = (1< 0) { + if(p < this.DB && (d = this[i]>>p) > 0) { m = true; r = int2char(d); } + while(i >= 0) { + if(p < k) { + d = (this[i]&((1<>(p+=this.DB-k); + } + else { + d = (this[i]>>(p-=k))&km; + if(p <= 0) { p += this.DB; --i; } + } + if(d > 0) m = true; + if(m) r += int2char(d); + } + } + return m?r:"0"; + } + + // (public) -this + function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; } + + // (public) |this| + function bnAbs() { return (this.s<0)?this.negate():this; } + + // (public) return + if this > a, - if this < a, 0 if equal + function bnCompareTo(a) { + var r = this.s-a.s; + if(r != 0) return r; + var i = this.t; + r = i-a.t; + if(r != 0) return (this.s<0)?-r:r; + while(--i >= 0) if((r=this[i]-a[i]) != 0) return r; + return 0; + } + + // returns bit length of the integer x + function nbits(x) { + var r = 1, t; + if((t=x>>>16) != 0) { x = t; r += 16; } + if((t=x>>8) != 0) { x = t; r += 8; } + if((t=x>>4) != 0) { x = t; r += 4; } + if((t=x>>2) != 0) { x = t; r += 2; } + if((t=x>>1) != 0) { x = t; r += 1; } + return r; + } + + // (public) return the number of bits in "this" + function bnBitLength() { + if(this.t <= 0) return 0; + return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM)); + } + + // (protected) r = this << n*DB + function bnpDLShiftTo(n,r) { + var i; + for(i = this.t-1; i >= 0; --i) r[i+n] = this[i]; + for(i = n-1; i >= 0; --i) r[i] = 0; + r.t = this.t+n; + r.s = this.s; + } + + // (protected) r = this >> n*DB + function bnpDRShiftTo(n,r) { + for(var i = n; i < this.t; ++i) r[i-n] = this[i]; + r.t = Math.max(this.t-n,0); + r.s = this.s; + } + + // (protected) r = this << n + function bnpLShiftTo(n,r) { + var bs = n%this.DB; + var cbs = this.DB-bs; + var bm = (1<= 0; --i) { + r[i+ds+1] = (this[i]>>cbs)|c; + c = (this[i]&bm)<= 0; --i) r[i] = 0; + r[ds] = c; + r.t = this.t+ds+1; + r.s = this.s; + r.clamp(); + } + + // (protected) r = this >> n + function bnpRShiftTo(n,r) { + r.s = this.s; + var ds = Math.floor(n/this.DB); + if(ds >= this.t) { r.t = 0; return; } + var bs = n%this.DB; + var cbs = this.DB-bs; + var bm = (1<>bs; + for(var i = ds+1; i < this.t; ++i) { + r[i-ds-1] |= (this[i]&bm)<>bs; + } + if(bs > 0) r[this.t-ds-1] |= (this.s&bm)<>= this.DB; + } + if(a.t < this.t) { + c -= a.s; + while(i < this.t) { + c += this[i]; + r[i++] = c&this.DM; + c >>= this.DB; + } + c += this.s; + } + else { + c += this.s; + while(i < a.t) { + c -= a[i]; + r[i++] = c&this.DM; + c >>= this.DB; + } + c -= a.s; + } + r.s = (c<0)?-1:0; + if(c < -1) r[i++] = this.DV+c; + else if(c > 0) r[i++] = c; + r.t = i; + r.clamp(); + } + + // (protected) r = this * a, r != this,a (HAC 14.12) + // "this" should be the larger one if appropriate. + function bnpMultiplyTo(a,r) { + var x = this.abs(), y = a.abs(); + var i = x.t; + r.t = i+y.t; + while(--i >= 0) r[i] = 0; + for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t); + r.s = 0; + r.clamp(); + if(this.s != a.s) BigInteger.ZERO.subTo(r,r); + } + + // (protected) r = this^2, r != this (HAC 14.16) + function bnpSquareTo(r) { + var x = this.abs(); + var i = r.t = 2*x.t; + while(--i >= 0) r[i] = 0; + for(i = 0; i < x.t-1; ++i) { + var c = x.am(i,x[i],r,2*i,0,1); + if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) { + r[i+x.t] -= x.DV; + r[i+x.t+1] = 1; + } + } + if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1); + r.s = 0; + r.clamp(); + } + + // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20) + // r != q, this != m. q or r may be null. + function bnpDivRemTo(m,q,r) { + var pm = m.abs(); + if(pm.t <= 0) return; + var pt = this.abs(); + if(pt.t < pm.t) { + if(q != null) q.fromInt(0); + if(r != null) this.copyTo(r); + return; + } + if(r == null) r = nbi(); + var y = nbi(), ts = this.s, ms = m.s; + var nsh = this.DB-nbits(pm[pm.t-1]); // normalize modulus + if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); } + else { pm.copyTo(y); pt.copyTo(r); } + var ys = y.t; + var y0 = y[ys-1]; + if(y0 == 0) return; + var yt = y0*(1<1)?y[ys-2]>>this.F2:0); + var d1 = this.FV/yt, d2 = (1<= 0) { + r[r.t++] = 1; + r.subTo(t,r); + } + BigInteger.ONE.dlShiftTo(ys,t); + t.subTo(y,y); // "negative" y so we can replace sub with am later + while(y.t < ys) y[y.t++] = 0; + while(--j >= 0) { + // Estimate quotient digit + var qd = (r[--i]==y0)?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2); + if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out + y.dlShiftTo(j,t); + r.subTo(t,r); + while(r[i] < --qd) r.subTo(t,r); + } + } + if(q != null) { + r.drShiftTo(ys,q); + if(ts != ms) BigInteger.ZERO.subTo(q,q); + } + r.t = ys; + r.clamp(); + if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder + if(ts < 0) BigInteger.ZERO.subTo(r,r); + } + + // (public) this mod a + function bnMod(a) { + var r = nbi(); + this.abs().divRemTo(a,null,r); + if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r); + return r; + } + + // Modular reduction using "classic" algorithm + function Classic(m) { this.m = m; } + function cConvert(x) { + if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m); + else return x; + } + function cRevert(x) { return x; } + function cReduce(x) { x.divRemTo(this.m,null,x); } + function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } + function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); } + + Classic.prototype.convert = cConvert; + Classic.prototype.revert = cRevert; + Classic.prototype.reduce = cReduce; + Classic.prototype.mulTo = cMulTo; + Classic.prototype.sqrTo = cSqrTo; + + // (protected) return "-1/this % 2^DB"; useful for Mont. reduction + // justification: + // xy == 1 (mod m) + // xy = 1+km + // xy(2-xy) = (1+km)(1-km) + // x[y(2-xy)] = 1-k^2m^2 + // x[y(2-xy)] == 1 (mod m^2) + // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2 + // should reduce x and y(2-xy) by m^2 at each step to keep size bounded. + // JS multiply "overflows" differently from C/C++, so care is needed here. + function bnpInvDigit() { + if(this.t < 1) return 0; + var x = this[0]; + if((x&1) == 0) return 0; + var y = x&3; // y == 1/x mod 2^2 + y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4 + y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8 + y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16 + // last step - calculate inverse mod DV directly; + // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints + y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits + // we really want the negative inverse, and -DV < y < DV + return (y>0)?this.DV-y:-y; + } + + // Montgomery reduction + function Montgomery(m) { + this.m = m; + this.mp = m.invDigit(); + this.mpl = this.mp&0x7fff; + this.mph = this.mp>>15; + this.um = (1<<(m.DB-15))-1; + this.mt2 = 2*m.t; + } + + // xR mod m + function montConvert(x) { + var r = nbi(); + x.abs().dlShiftTo(this.m.t,r); + r.divRemTo(this.m,null,r); + if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r); + return r; + } + + // x/R mod m + function montRevert(x) { + var r = nbi(); + x.copyTo(r); + this.reduce(r); + return r; + } + + // x = x/R mod m (HAC 14.32) + function montReduce(x) { + while(x.t <= this.mt2) // pad x so am has enough room later + x[x.t++] = 0; + for(var i = 0; i < this.m.t; ++i) { + // faster way of calculating u0 = x[i]*mp mod DV + var j = x[i]&0x7fff; + var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM; + // use am to combine the multiply-shift-add into one call + j = i+this.m.t; + x[j] += this.m.am(0,u0,x,i,0,this.m.t); + // propagate carry + while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; } + } + x.clamp(); + x.drShiftTo(this.m.t,x); + if(x.compareTo(this.m) >= 0) x.subTo(this.m,x); + } + + // r = "x^2/R mod m"; x != r + function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); } + + // r = "xy/R mod m"; x,y != r + function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } + + Montgomery.prototype.convert = montConvert; + Montgomery.prototype.revert = montRevert; + Montgomery.prototype.reduce = montReduce; + Montgomery.prototype.mulTo = montMulTo; + Montgomery.prototype.sqrTo = montSqrTo; + + // (protected) true iff this is even + function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; } + + // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79) + function bnpExp(e,z) { + if(e > 0xffffffff || e < 1) return BigInteger.ONE; + var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1; + g.copyTo(r); + while(--i >= 0) { + z.sqrTo(r,r2); + if((e&(1< 0) z.mulTo(r2,g,r); + else { var t = r; r = r2; r2 = t; } + } + return z.revert(r); + } + + // (public) this^e % m, 0 <= e < 2^32 + function bnModPowInt(e,m) { + var z; + if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m); + return this.exp(e,z); + } + + // protected + BigInteger.prototype.copyTo = bnpCopyTo; + BigInteger.prototype.fromInt = bnpFromInt; + BigInteger.prototype.fromString = bnpFromString; + BigInteger.prototype.clamp = bnpClamp; + BigInteger.prototype.dlShiftTo = bnpDLShiftTo; + BigInteger.prototype.drShiftTo = bnpDRShiftTo; + BigInteger.prototype.lShiftTo = bnpLShiftTo; + BigInteger.prototype.rShiftTo = bnpRShiftTo; + BigInteger.prototype.subTo = bnpSubTo; + BigInteger.prototype.multiplyTo = bnpMultiplyTo; + BigInteger.prototype.squareTo = bnpSquareTo; + BigInteger.prototype.divRemTo = bnpDivRemTo; + BigInteger.prototype.invDigit = bnpInvDigit; + BigInteger.prototype.isEven = bnpIsEven; + BigInteger.prototype.exp = bnpExp; + + // public + BigInteger.prototype.toString = bnToString; + BigInteger.prototype.negate = bnNegate; + BigInteger.prototype.abs = bnAbs; + BigInteger.prototype.compareTo = bnCompareTo; + BigInteger.prototype.bitLength = bnBitLength; + BigInteger.prototype.mod = bnMod; + BigInteger.prototype.modPowInt = bnModPowInt; + + // "constants" + BigInteger.ZERO = nbv(0); + BigInteger.ONE = nbv(1); + + // Copyright (c) 2005-2009 Tom Wu + // All Rights Reserved. + // See "LICENSE" for details. + + // Extended JavaScript BN functions, required for RSA private ops. + + // Version 1.1: new BigInteger("0", 10) returns "proper" zero + // Version 1.2: square() API, isProbablePrime fix + + // (public) + function bnClone() { var r = nbi(); this.copyTo(r); return r; } + + // (public) return value as integer + function bnIntValue() { + if(this.s < 0) { + if(this.t == 1) return this[0]-this.DV; + else if(this.t == 0) return -1; + } + else if(this.t == 1) return this[0]; + else if(this.t == 0) return 0; + // assumes 16 < DB < 32 + return ((this[1]&((1<<(32-this.DB))-1))<>24; } + + // (public) return value as short (assumes DB>=16) + function bnShortValue() { return (this.t==0)?this.s:(this[0]<<16)>>16; } + + // (protected) return x s.t. r^x < DV + function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); } + + // (public) 0 if this == 0, 1 if this > 0 + function bnSigNum() { + if(this.s < 0) return -1; + else if(this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0; + else return 1; + } + + // (protected) convert to radix string + function bnpToRadix(b) { + if(b == null) b = 10; + if(this.signum() == 0 || b < 2 || b > 36) return "0"; + var cs = this.chunkSize(b); + var a = Math.pow(b,cs); + var d = nbv(a), y = nbi(), z = nbi(), r = ""; + this.divRemTo(d,y,z); + while(y.signum() > 0) { + r = (a+z.intValue()).toString(b).substr(1) + r; + y.divRemTo(d,y,z); + } + return z.intValue().toString(b) + r; + } + + // (protected) convert from radix string + function bnpFromRadix(s,b) { + this.fromInt(0); + if(b == null) b = 10; + var cs = this.chunkSize(b); + var d = Math.pow(b,cs), mi = false, j = 0, w = 0; + for(var i = 0; i < s.length; ++i) { + var x = intAt(s,i); + if(x < 0) { + if(s.charAt(i) == "-" && this.signum() == 0) mi = true; + continue; + } + w = b*w+x; + if(++j >= cs) { + this.dMultiply(d); + this.dAddOffset(w,0); + j = 0; + w = 0; + } + } + if(j > 0) { + this.dMultiply(Math.pow(b,j)); + this.dAddOffset(w,0); + } + if(mi) BigInteger.ZERO.subTo(this,this); + } + + // (protected) alternate constructor + function bnpFromNumber(a,b,c) { + if("number" == typeof b) { + // new BigInteger(int,int,RNG) + if(a < 2) this.fromInt(1); + else { + this.fromNumber(a,c); + if(!this.testBit(a-1)) // force MSB set + this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this); + if(this.isEven()) this.dAddOffset(1,0); // force odd + while(!this.isProbablePrime(b)) { + this.dAddOffset(2,0); + if(this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a-1),this); + } + } + } + else { + // new BigInteger(int,RNG) + var x = new Array(), t = a&7; + x.length = (a>>3)+1; + b.nextBytes(x); + if(t > 0) x[0] &= ((1< 0) { + if(p < this.DB && (d = this[i]>>p) != (this.s&this.DM)>>p) + r[k++] = d|(this.s<<(this.DB-p)); + while(i >= 0) { + if(p < 8) { + d = (this[i]&((1<>(p+=this.DB-8); + } + else { + d = (this[i]>>(p-=8))&0xff; + if(p <= 0) { p += this.DB; --i; } + } + if((d&0x80) != 0) d |= -256; + if(k == 0 && (this.s&0x80) != (d&0x80)) ++k; + if(k > 0 || d != this.s) r[k++] = d; + } + } + return r; + } + + function bnEquals(a) { return(this.compareTo(a)==0); } + function bnMin(a) { return (this.compareTo(a)<0)?this:a; } + function bnMax(a) { return (this.compareTo(a)>0)?this:a; } + + // (protected) r = this op a (bitwise) + function bnpBitwiseTo(a,op,r) { + var i, f, m = Math.min(a.t,this.t); + for(i = 0; i < m; ++i) r[i] = op(this[i],a[i]); + if(a.t < this.t) { + f = a.s&this.DM; + for(i = m; i < this.t; ++i) r[i] = op(this[i],f); + r.t = this.t; + } + else { + f = this.s&this.DM; + for(i = m; i < a.t; ++i) r[i] = op(f,a[i]); + r.t = a.t; + } + r.s = op(this.s,a.s); + r.clamp(); + } + + // (public) this & a + function op_and(x,y) { return x&y; } + function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; } + + // (public) this | a + function op_or(x,y) { return x|y; } + function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; } + + // (public) this ^ a + function op_xor(x,y) { return x^y; } + function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; } + + // (public) this & ~a + function op_andnot(x,y) { return x&~y; } + function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; } + + // (public) ~this + function bnNot() { + var r = nbi(); + for(var i = 0; i < this.t; ++i) r[i] = this.DM&~this[i]; + r.t = this.t; + r.s = ~this.s; + return r; + } + + // (public) this << n + function bnShiftLeft(n) { + var r = nbi(); + if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r); + return r; + } + + // (public) this >> n + function bnShiftRight(n) { + var r = nbi(); + if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r); + return r; + } + + // return index of lowest 1-bit in x, x < 2^31 + function lbit(x) { + if(x == 0) return -1; + var r = 0; + if((x&0xffff) == 0) { x >>= 16; r += 16; } + if((x&0xff) == 0) { x >>= 8; r += 8; } + if((x&0xf) == 0) { x >>= 4; r += 4; } + if((x&3) == 0) { x >>= 2; r += 2; } + if((x&1) == 0) ++r; + return r; + } + + // (public) returns index of lowest 1-bit (or -1 if none) + function bnGetLowestSetBit() { + for(var i = 0; i < this.t; ++i) + if(this[i] != 0) return i*this.DB+lbit(this[i]); + if(this.s < 0) return this.t*this.DB; + return -1; + } + + // return number of 1 bits in x + function cbit(x) { + var r = 0; + while(x != 0) { x &= x-1; ++r; } + return r; + } + + // (public) return number of set bits + function bnBitCount() { + var r = 0, x = this.s&this.DM; + for(var i = 0; i < this.t; ++i) r += cbit(this[i]^x); + return r; + } + + // (public) true iff nth bit is set + function bnTestBit(n) { + var j = Math.floor(n/this.DB); + if(j >= this.t) return(this.s!=0); + return((this[j]&(1<<(n%this.DB)))!=0); + } + + // (protected) this op (1<>= this.DB; + } + if(a.t < this.t) { + c += a.s; + while(i < this.t) { + c += this[i]; + r[i++] = c&this.DM; + c >>= this.DB; + } + c += this.s; + } + else { + c += this.s; + while(i < a.t) { + c += a[i]; + r[i++] = c&this.DM; + c >>= this.DB; + } + c += a.s; + } + r.s = (c<0)?-1:0; + if(c > 0) r[i++] = c; + else if(c < -1) r[i++] = this.DV+c; + r.t = i; + r.clamp(); + } + + // (public) this + a + function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; } + + // (public) this - a + function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; } + + // (public) this * a + function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; } + + // (public) this^2 + function bnSquare() { var r = nbi(); this.squareTo(r); return r; } + + // (public) this / a + function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; } + + // (public) this % a + function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; } + + // (public) [this/a,this%a] + function bnDivideAndRemainder(a) { + var q = nbi(), r = nbi(); + this.divRemTo(a,q,r); + return new Array(q,r); + } + + // (protected) this *= n, this >= 0, 1 < n < DV + function bnpDMultiply(n) { + this[this.t] = this.am(0,n-1,this,0,0,this.t); + ++this.t; + this.clamp(); + } + + // (protected) this += n << w words, this >= 0 + function bnpDAddOffset(n,w) { + if(n == 0) return; + while(this.t <= w) this[this.t++] = 0; + this[w] += n; + while(this[w] >= this.DV) { + this[w] -= this.DV; + if(++w >= this.t) this[this.t++] = 0; + ++this[w]; + } + } + + // A "null" reducer + function NullExp() {} + function nNop(x) { return x; } + function nMulTo(x,y,r) { x.multiplyTo(y,r); } + function nSqrTo(x,r) { x.squareTo(r); } + + NullExp.prototype.convert = nNop; + NullExp.prototype.revert = nNop; + NullExp.prototype.mulTo = nMulTo; + NullExp.prototype.sqrTo = nSqrTo; + + // (public) this^e + function bnPow(e) { return this.exp(e,new NullExp()); } + + // (protected) r = lower n words of "this * a", a.t <= n + // "this" should be the larger one if appropriate. + function bnpMultiplyLowerTo(a,n,r) { + var i = Math.min(this.t+a.t,n); + r.s = 0; // assumes a,this >= 0 + r.t = i; + while(i > 0) r[--i] = 0; + var j; + for(j = r.t-this.t; i < j; ++i) r[i+this.t] = this.am(0,a[i],r,i,0,this.t); + for(j = Math.min(a.t,n); i < j; ++i) this.am(0,a[i],r,i,0,n-i); + r.clamp(); + } + + // (protected) r = "this * a" without lower n words, n > 0 + // "this" should be the larger one if appropriate. + function bnpMultiplyUpperTo(a,n,r) { + --n; + var i = r.t = this.t+a.t-n; + r.s = 0; // assumes a,this >= 0 + while(--i >= 0) r[i] = 0; + for(i = Math.max(n-this.t,0); i < a.t; ++i) + r[this.t+i-n] = this.am(n-i,a[i],r,0,0,this.t+i-n); + r.clamp(); + r.drShiftTo(1,r); + } + + // Barrett modular reduction + function Barrett(m) { + // setup Barrett + this.r2 = nbi(); + this.q3 = nbi(); + BigInteger.ONE.dlShiftTo(2*m.t,this.r2); + this.mu = this.r2.divide(m); + this.m = m; + } + + function barrettConvert(x) { + if(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m); + else if(x.compareTo(this.m) < 0) return x; + else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; } + } + + function barrettRevert(x) { return x; } + + // x = x mod m (HAC 14.42) + function barrettReduce(x) { + x.drShiftTo(this.m.t-1,this.r2); + if(x.t > this.m.t+1) { x.t = this.m.t+1; x.clamp(); } + this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3); + this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2); + while(x.compareTo(this.r2) < 0) x.dAddOffset(1,this.m.t+1); + x.subTo(this.r2,x); + while(x.compareTo(this.m) >= 0) x.subTo(this.m,x); + } + + // r = x^2 mod m; x != r + function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); } + + // r = x*y mod m; x,y != r + function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); } + + Barrett.prototype.convert = barrettConvert; + Barrett.prototype.revert = barrettRevert; + Barrett.prototype.reduce = barrettReduce; + Barrett.prototype.mulTo = barrettMulTo; + Barrett.prototype.sqrTo = barrettSqrTo; + + // (public) this^e % m (HAC 14.85) + function bnModPow(e,m) { + var i = e.bitLength(), k, r = nbv(1), z; + if(i <= 0) return r; + else if(i < 18) k = 1; + else if(i < 48) k = 3; + else if(i < 144) k = 4; + else if(i < 768) k = 5; + else k = 6; + if(i < 8) + z = new Classic(m); + else if(m.isEven()) + z = new Barrett(m); + else + z = new Montgomery(m); + + // precomputation + var g = new Array(), n = 3, k1 = k-1, km = (1< 1) { + var g2 = nbi(); + z.sqrTo(g[1],g2); + while(n <= km) { + g[n] = nbi(); + z.mulTo(g2,g[n-2],g[n]); + n += 2; + } + } + + var j = e.t-1, w, is1 = true, r2 = nbi(), t; + i = nbits(e[j])-1; + while(j >= 0) { + if(i >= k1) w = (e[j]>>(i-k1))&km; + else { + w = (e[j]&((1<<(i+1))-1))<<(k1-i); + if(j > 0) w |= e[j-1]>>(this.DB+i-k1); + } + + n = k; + while((w&1) == 0) { w >>= 1; --n; } + if((i -= n) < 0) { i += this.DB; --j; } + if(is1) { // ret == 1, don't bother squaring or multiplying it + g[w].copyTo(r); + is1 = false; + } + else { + while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; } + if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; } + z.mulTo(r2,g[w],r); + } + + while(j >= 0 && (e[j]&(1< 0) { + x.rShiftTo(g,x); + y.rShiftTo(g,y); + } + while(x.signum() > 0) { + if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x); + if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y); + if(x.compareTo(y) >= 0) { + x.subTo(y,x); + x.rShiftTo(1,x); + } + else { + y.subTo(x,y); + y.rShiftTo(1,y); + } + } + if(g > 0) y.lShiftTo(g,y); + return y; + } + + // (protected) this % n, n < 2^26 + function bnpModInt(n) { + if(n <= 0) return 0; + var d = this.DV%n, r = (this.s<0)?n-1:0; + if(this.t > 0) + if(d == 0) r = this[0]%n; + else for(var i = this.t-1; i >= 0; --i) r = (d*r+this[i])%n; + return r; + } + + // (public) 1/this % m (HAC 14.61) + function bnModInverse(m) { + var ac = m.isEven(); + if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO; + var u = m.clone(), v = this.clone(); + var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1); + while(u.signum() != 0) { + while(u.isEven()) { + u.rShiftTo(1,u); + if(ac) { + if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); } + a.rShiftTo(1,a); + } + else if(!b.isEven()) b.subTo(m,b); + b.rShiftTo(1,b); + } + while(v.isEven()) { + v.rShiftTo(1,v); + if(ac) { + if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); } + c.rShiftTo(1,c); + } + else if(!d.isEven()) d.subTo(m,d); + d.rShiftTo(1,d); + } + if(u.compareTo(v) >= 0) { + u.subTo(v,u); + if(ac) a.subTo(c,a); + b.subTo(d,b); + } + else { + v.subTo(u,v); + if(ac) c.subTo(a,c); + d.subTo(b,d); + } + } + if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO; + if(d.compareTo(m) >= 0) return d.subtract(m); + if(d.signum() < 0) d.addTo(m,d); else return d; + if(d.signum() < 0) return d.add(m); else return d; + } + + var lowprimes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997]; + var lplim = (1<<26)/lowprimes[lowprimes.length-1]; + + // (public) test primality with certainty >= 1-.5^t + function bnIsProbablePrime(t) { + var i, x = this.abs(); + if(x.t == 1 && x[0] <= lowprimes[lowprimes.length-1]) { + for(i = 0; i < lowprimes.length; ++i) + if(x[0] == lowprimes[i]) return true; + return false; + } + if(x.isEven()) return false; + i = 1; + while(i < lowprimes.length) { + var m = lowprimes[i], j = i+1; + while(j < lowprimes.length && m < lplim) m *= lowprimes[j++]; + m = x.modInt(m); + while(i < j) if(m%lowprimes[i++] == 0) return false; + } + return x.millerRabin(t); + } + + // (protected) true if probably prime (HAC 4.24, Miller-Rabin) + function bnpMillerRabin(t) { + var n1 = this.subtract(BigInteger.ONE); + var k = n1.getLowestSetBit(); + if(k <= 0) return false; + var r = n1.shiftRight(k); + t = (t+1)>>1; + if(t > lowprimes.length) t = lowprimes.length; + var a = nbi(); + for(var i = 0; i < t; ++i) { + //Pick bases at random, instead of starting at 2 + a.fromInt(lowprimes[Math.floor(Math.random()*lowprimes.length)]); + var y = a.modPow(r,this); + if(y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) { + var j = 1; + while(j++ < k && y.compareTo(n1) != 0) { + y = y.modPowInt(2,this); + if(y.compareTo(BigInteger.ONE) == 0) return false; + } + if(y.compareTo(n1) != 0) return false; + } + } + return true; + } + + // protected + BigInteger.prototype.chunkSize = bnpChunkSize; + BigInteger.prototype.toRadix = bnpToRadix; + BigInteger.prototype.fromRadix = bnpFromRadix; + BigInteger.prototype.fromNumber = bnpFromNumber; + BigInteger.prototype.bitwiseTo = bnpBitwiseTo; + BigInteger.prototype.changeBit = bnpChangeBit; + BigInteger.prototype.addTo = bnpAddTo; + BigInteger.prototype.dMultiply = bnpDMultiply; + BigInteger.prototype.dAddOffset = bnpDAddOffset; + BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo; + BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo; + BigInteger.prototype.modInt = bnpModInt; + BigInteger.prototype.millerRabin = bnpMillerRabin; + + // public + BigInteger.prototype.clone = bnClone; + BigInteger.prototype.intValue = bnIntValue; + BigInteger.prototype.byteValue = bnByteValue; + BigInteger.prototype.shortValue = bnShortValue; + BigInteger.prototype.signum = bnSigNum; + BigInteger.prototype.toByteArray = bnToByteArray; + BigInteger.prototype.equals = bnEquals; + BigInteger.prototype.min = bnMin; + BigInteger.prototype.max = bnMax; + BigInteger.prototype.and = bnAnd; + BigInteger.prototype.or = bnOr; + BigInteger.prototype.xor = bnXor; + BigInteger.prototype.andNot = bnAndNot; + BigInteger.prototype.not = bnNot; + BigInteger.prototype.shiftLeft = bnShiftLeft; + BigInteger.prototype.shiftRight = bnShiftRight; + BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit; + BigInteger.prototype.bitCount = bnBitCount; + BigInteger.prototype.testBit = bnTestBit; + BigInteger.prototype.setBit = bnSetBit; + BigInteger.prototype.clearBit = bnClearBit; + BigInteger.prototype.flipBit = bnFlipBit; + BigInteger.prototype.add = bnAdd; + BigInteger.prototype.subtract = bnSubtract; + BigInteger.prototype.multiply = bnMultiply; + BigInteger.prototype.divide = bnDivide; + BigInteger.prototype.remainder = bnRemainder; + BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder; + BigInteger.prototype.modPow = bnModPow; + BigInteger.prototype.modInverse = bnModInverse; + BigInteger.prototype.pow = bnPow; + BigInteger.prototype.gcd = bnGCD; + BigInteger.prototype.isProbablePrime = bnIsProbablePrime; + + // JSBN-specific extension + BigInteger.prototype.square = bnSquare; + + // Expose the Barrett function + BigInteger.prototype.Barrett = Barrett; + + // BigInteger interfaces not implemented in jsbn: + + // BigInteger(int signum, byte[] magnitude) + // double doubleValue() + // float floatValue() + // int hashCode() + // long longValue() + // static BigInteger valueOf(long val) + + // Random number generator - requires a PRNG backend, e.g. prng4.js + + // For best results, put code like + // + // in your main HTML document. + + var rng_state; + var rng_pool; + var rng_pptr; + + // Mix in a 32-bit integer into the pool + function rng_seed_int(x) { + rng_pool[rng_pptr++] ^= x & 255; + rng_pool[rng_pptr++] ^= (x >> 8) & 255; + rng_pool[rng_pptr++] ^= (x >> 16) & 255; + rng_pool[rng_pptr++] ^= (x >> 24) & 255; + if(rng_pptr >= rng_psize) rng_pptr -= rng_psize; + } + + // Mix in the current time (w/milliseconds) into the pool + function rng_seed_time() { + rng_seed_int(new Date().getTime()); + } + + // Initialize the pool with junk if needed. + if(rng_pool == null) { + rng_pool = new Array(); + rng_pptr = 0; + var t; + if(typeof window !== "undefined" && window.crypto) { + if (window.crypto.getRandomValues) { + // Use webcrypto if available + var ua = new Uint8Array(32); + window.crypto.getRandomValues(ua); + for(t = 0; t < 32; ++t) + rng_pool[rng_pptr++] = ua[t]; + } + else if(navigator.appName == "Netscape" && navigator.appVersion < "5") { + // Extract entropy (256 bits) from NS4 RNG if available + var z = window.crypto.random(32); + for(t = 0; t < z.length; ++t) + rng_pool[rng_pptr++] = z.charCodeAt(t) & 255; + } + } + while(rng_pptr < rng_psize) { // extract some randomness from Math.random() + t = Math.floor(65536 * Math.random()); + rng_pool[rng_pptr++] = t >>> 8; + rng_pool[rng_pptr++] = t & 255; + } + rng_pptr = 0; + rng_seed_time(); + //rng_seed_int(window.screenX); + //rng_seed_int(window.screenY); + } + + function rng_get_byte() { + if(rng_state == null) { + rng_seed_time(); + rng_state = prng_newstate(); + rng_state.init(rng_pool); + for(rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) + rng_pool[rng_pptr] = 0; + rng_pptr = 0; + //rng_pool = null; + } + // TODO: allow reseeding after first request + return rng_state.next(); + } + + function rng_get_bytes(ba) { + var i; + for(i = 0; i < ba.length; ++i) ba[i] = rng_get_byte(); + } + + function SecureRandom() {} + + SecureRandom.prototype.nextBytes = rng_get_bytes; + + // prng4.js - uses Arcfour as a PRNG + + function Arcfour() { + this.i = 0; + this.j = 0; + this.S = new Array(); + } + + // Initialize arcfour context from key, an array of ints, each from [0..255] + function ARC4init(key) { + var i, j, t; + for(i = 0; i < 256; ++i) + this.S[i] = i; + j = 0; + for(i = 0; i < 256; ++i) { + j = (j + this.S[i] + key[i % key.length]) & 255; + t = this.S[i]; + this.S[i] = this.S[j]; + this.S[j] = t; + } + this.i = 0; + this.j = 0; + } + + function ARC4next() { + var t; + this.i = (this.i + 1) & 255; + this.j = (this.j + this.S[this.i]) & 255; + t = this.S[this.i]; + this.S[this.i] = this.S[this.j]; + this.S[this.j] = t; + return this.S[(t + this.S[this.i]) & 255]; + } + + Arcfour.prototype.init = ARC4init; + Arcfour.prototype.next = ARC4next; + + // Plug in your RNG constructor here + function prng_newstate() { + return new Arcfour(); + } + + // Pool size must be a multiple of 4 and greater than 32. + // An array of bytes the size of the pool will be passed to init() + var rng_psize = 256; + + { + module.exports = { + default: BigInteger, + BigInteger: BigInteger, + SecureRandom: SecureRandom, + }; + } + + }).call(commonjsGlobal); +} (jsbn)); + +var jsbnExports = jsbn.exports; + +var sprintf = {}; + +/* global window, exports, define */ + +(function (exports) { + !function() { + + var re = { + not_string: /[^s]/, + not_bool: /[^t]/, + not_type: /[^T]/, + not_primitive: /[^v]/, + number: /[diefg]/, + numeric_arg: /[bcdiefguxX]/, + json: /[j]/, + not_json: /[^j]/, + text: /^[^\x25]+/, + modulo: /^\x25{2}/, + placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/, + key: /^([a-z_][a-z_\d]*)/i, + key_access: /^\.([a-z_][a-z_\d]*)/i, + index_access: /^\[(\d+)\]/, + sign: /^[+-]/ + }; + + function sprintf(key) { + // `arguments` is not an array, but should be fine for this call + return sprintf_format(sprintf_parse(key), arguments) + } + + function vsprintf(fmt, argv) { + return sprintf.apply(null, [fmt].concat(argv || [])) + } + + function sprintf_format(parse_tree, argv) { + var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, ph, pad, pad_character, pad_length, is_positive, sign; + for (i = 0; i < tree_length; i++) { + if (typeof parse_tree[i] === 'string') { + output += parse_tree[i]; + } + else if (typeof parse_tree[i] === 'object') { + ph = parse_tree[i]; // convenience purposes only + if (ph.keys) { // keyword argument + arg = argv[cursor]; + for (k = 0; k < ph.keys.length; k++) { + if (arg == undefined) { + throw new Error(sprintf('[sprintf] Cannot access property "%s" of undefined value "%s"', ph.keys[k], ph.keys[k-1])) + } + arg = arg[ph.keys[k]]; + } + } + else if (ph.param_no) { // positional argument (explicit) + arg = argv[ph.param_no]; + } + else { // positional argument (implicit) + arg = argv[cursor++]; + } + + if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) { + arg = arg(); + } + + if (re.numeric_arg.test(ph.type) && (typeof arg !== 'number' && isNaN(arg))) { + throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg)) + } + + if (re.number.test(ph.type)) { + is_positive = arg >= 0; + } + + switch (ph.type) { + case 'b': + arg = parseInt(arg, 10).toString(2); + break + case 'c': + arg = String.fromCharCode(parseInt(arg, 10)); + break + case 'd': + case 'i': + arg = parseInt(arg, 10); + break + case 'j': + arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0); + break + case 'e': + arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential(); + break + case 'f': + arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg); + break + case 'g': + arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg); + break + case 'o': + arg = (parseInt(arg, 10) >>> 0).toString(8); + break + case 's': + arg = String(arg); + arg = (ph.precision ? arg.substring(0, ph.precision) : arg); + break + case 't': + arg = String(!!arg); + arg = (ph.precision ? arg.substring(0, ph.precision) : arg); + break + case 'T': + arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase(); + arg = (ph.precision ? arg.substring(0, ph.precision) : arg); + break + case 'u': + arg = parseInt(arg, 10) >>> 0; + break + case 'v': + arg = arg.valueOf(); + arg = (ph.precision ? arg.substring(0, ph.precision) : arg); + break + case 'x': + arg = (parseInt(arg, 10) >>> 0).toString(16); + break + case 'X': + arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase(); + break + } + if (re.json.test(ph.type)) { + output += arg; + } + else { + if (re.number.test(ph.type) && (!is_positive || ph.sign)) { + sign = is_positive ? '+' : '-'; + arg = arg.toString().replace(re.sign, ''); + } + else { + sign = ''; + } + pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' '; + pad_length = ph.width - (sign + arg).length; + pad = ph.width ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : ''; + output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg); + } + } + } + return output + } + + var sprintf_cache = Object.create(null); + + function sprintf_parse(fmt) { + if (sprintf_cache[fmt]) { + return sprintf_cache[fmt] + } + + var _fmt = fmt, match, parse_tree = [], arg_names = 0; + while (_fmt) { + if ((match = re.text.exec(_fmt)) !== null) { + parse_tree.push(match[0]); + } + else if ((match = re.modulo.exec(_fmt)) !== null) { + parse_tree.push('%'); + } + else if ((match = re.placeholder.exec(_fmt)) !== null) { + if (match[2]) { + arg_names |= 1; + var field_list = [], replacement_field = match[2], field_match = []; + if ((field_match = re.key.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { + if ((field_match = re.key_access.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + } + else if ((field_match = re.index_access.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + } + else { + throw new SyntaxError('[sprintf] failed to parse named argument key') + } + } + } + else { + throw new SyntaxError('[sprintf] failed to parse named argument key') + } + match[2] = field_list; + } + else { + arg_names |= 2; + } + if (arg_names === 3) { + throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported') + } + + parse_tree.push( + { + placeholder: match[0], + param_no: match[1], + keys: match[2], + sign: match[3], + pad_char: match[4], + align: match[5], + width: match[6], + precision: match[7], + type: match[8] + } + ); + } + else { + throw new SyntaxError('[sprintf] unexpected placeholder') + } + _fmt = _fmt.substring(match[0].length); + } + return sprintf_cache[fmt] = parse_tree + } + + /** + * export to either browser or node.js + */ + /* eslint-disable quote-props */ + { + exports['sprintf'] = sprintf; + exports['vsprintf'] = vsprintf; + } + if (typeof window !== 'undefined') { + window['sprintf'] = sprintf; + window['vsprintf'] = vsprintf; + } + /* eslint-enable quote-props */ + }(); // eslint-disable-line +} (sprintf)); + +/* eslint-disable no-param-reassign */ +var __createBinding$3 = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault$3 = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar$3 = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding$3(result, mod, k); + __setModuleDefault$3(result, mod); + return result; +}; +Object.defineProperty(ipv4, "__esModule", { value: true }); +ipv4.Address4 = void 0; +const common$1 = __importStar$3(common$2); +const constants$1 = __importStar$3(constants$2); +const address_error_1$1 = addressError; +const jsbn_1$1 = jsbnExports; +const sprintf_js_1$3 = sprintf; +/** + * Represents an IPv4 address + * @class Address4 + * @param {string} address - An IPv4 address string + */ +class Address4 { + constructor(address) { + this.groups = constants$1.GROUPS; + this.parsedAddress = []; + this.parsedSubnet = ''; + this.subnet = '/32'; + this.subnetMask = 32; + this.v4 = true; + /** + * Returns true if the address is correct, false otherwise + * @memberof Address4 + * @instance + * @returns {Boolean} + */ + this.isCorrect = common$1.isCorrect(constants$1.BITS); + /** + * Returns true if the given address is in the subnet of the current address + * @memberof Address4 + * @instance + * @returns {boolean} + */ + this.isInSubnet = common$1.isInSubnet; + this.address = address; + const subnet = constants$1.RE_SUBNET_STRING.exec(address); + if (subnet) { + this.parsedSubnet = subnet[0].replace('/', ''); + this.subnetMask = parseInt(this.parsedSubnet, 10); + this.subnet = `/${this.subnetMask}`; + if (this.subnetMask < 0 || this.subnetMask > constants$1.BITS) { + throw new address_error_1$1.AddressError('Invalid subnet mask.'); + } + address = address.replace(constants$1.RE_SUBNET_STRING, ''); + } + this.addressMinusSuffix = address; + this.parsedAddress = this.parse(address); + } + static isValid(address) { + try { + // eslint-disable-next-line no-new + new Address4(address); + return true; + } + catch (e) { + return false; + } + } + /* + * Parses a v4 address + */ + parse(address) { + const groups = address.split('.'); + if (!address.match(constants$1.RE_ADDRESS)) { + throw new address_error_1$1.AddressError('Invalid IPv4 address.'); + } + return groups; + } + /** + * Returns the correct form of an address + * @memberof Address4 + * @instance + * @returns {String} + */ + correctForm() { + return this.parsedAddress.map((part) => parseInt(part, 10)).join('.'); + } + /** + * Converts a hex string to an IPv4 address object + * @memberof Address4 + * @static + * @param {string} hex - a hex string to convert + * @returns {Address4} + */ + static fromHex(hex) { + const padded = hex.replace(/:/g, '').padStart(8, '0'); + const groups = []; + let i; + for (i = 0; i < 8; i += 2) { + const h = padded.slice(i, i + 2); + groups.push(parseInt(h, 16)); + } + return new Address4(groups.join('.')); + } + /** + * Converts an integer into a IPv4 address object + * @memberof Address4 + * @static + * @param {integer} integer - a number to convert + * @returns {Address4} + */ + static fromInteger(integer) { + return Address4.fromHex(integer.toString(16)); + } + /** + * Return an address from in-addr.arpa form + * @memberof Address4 + * @static + * @param {string} arpaFormAddress - an 'in-addr.arpa' form ipv4 address + * @returns {Adress4} + * @example + * var address = Address4.fromArpa(42.2.0.192.in-addr.arpa.) + * address.correctForm(); // '192.0.2.42' + */ + static fromArpa(arpaFormAddress) { + // remove ending ".in-addr.arpa." or just "." + const leader = arpaFormAddress.replace(/(\.in-addr\.arpa)?\.$/, ''); + const address = leader.split('.').reverse().join('.'); + return new Address4(address); + } + /** + * Converts an IPv4 address object to a hex string + * @memberof Address4 + * @instance + * @returns {String} + */ + toHex() { + return this.parsedAddress.map((part) => (0, sprintf_js_1$3.sprintf)('%02x', parseInt(part, 10))).join(':'); + } + /** + * Converts an IPv4 address object to an array of bytes + * @memberof Address4 + * @instance + * @returns {Array} + */ + toArray() { + return this.parsedAddress.map((part) => parseInt(part, 10)); + } + /** + * Converts an IPv4 address object to an IPv6 address group + * @memberof Address4 + * @instance + * @returns {String} + */ + toGroup6() { + const output = []; + let i; + for (i = 0; i < constants$1.GROUPS; i += 2) { + const hex = (0, sprintf_js_1$3.sprintf)('%02x%02x', parseInt(this.parsedAddress[i], 10), parseInt(this.parsedAddress[i + 1], 10)); + output.push((0, sprintf_js_1$3.sprintf)('%x', parseInt(hex, 16))); + } + return output.join(':'); + } + /** + * Returns the address as a BigInteger + * @memberof Address4 + * @instance + * @returns {BigInteger} + */ + bigInteger() { + return new jsbn_1$1.BigInteger(this.parsedAddress.map((n) => (0, sprintf_js_1$3.sprintf)('%02x', parseInt(n, 10))).join(''), 16); + } + /** + * Helper function getting start address. + * @memberof Address4 + * @instance + * @returns {BigInteger} + */ + _startAddress() { + return new jsbn_1$1.BigInteger(this.mask() + '0'.repeat(constants$1.BITS - this.subnetMask), 2); + } + /** + * The first address in the range given by this address' subnet. + * Often referred to as the Network Address. + * @memberof Address4 + * @instance + * @returns {Address4} + */ + startAddress() { + return Address4.fromBigInteger(this._startAddress()); + } + /** + * The first host address in the range given by this address's subnet ie + * the first address after the Network Address + * @memberof Address4 + * @instance + * @returns {Address4} + */ + startAddressExclusive() { + const adjust = new jsbn_1$1.BigInteger('1'); + return Address4.fromBigInteger(this._startAddress().add(adjust)); + } + /** + * Helper function getting end address. + * @memberof Address4 + * @instance + * @returns {BigInteger} + */ + _endAddress() { + return new jsbn_1$1.BigInteger(this.mask() + '1'.repeat(constants$1.BITS - this.subnetMask), 2); + } + /** + * The last address in the range given by this address' subnet + * Often referred to as the Broadcast + * @memberof Address4 + * @instance + * @returns {Address4} + */ + endAddress() { + return Address4.fromBigInteger(this._endAddress()); + } + /** + * The last host address in the range given by this address's subnet ie + * the last address prior to the Broadcast Address + * @memberof Address4 + * @instance + * @returns {Address4} + */ + endAddressExclusive() { + const adjust = new jsbn_1$1.BigInteger('1'); + return Address4.fromBigInteger(this._endAddress().subtract(adjust)); + } + /** + * Converts a BigInteger to a v4 address object + * @memberof Address4 + * @static + * @param {BigInteger} bigInteger - a BigInteger to convert + * @returns {Address4} + */ + static fromBigInteger(bigInteger) { + return Address4.fromInteger(parseInt(bigInteger.toString(), 10)); + } + /** + * Returns the first n bits of the address, defaulting to the + * subnet mask + * @memberof Address4 + * @instance + * @returns {String} + */ + mask(mask) { + if (mask === undefined) { + mask = this.subnetMask; + } + return this.getBitsBase2(0, mask); + } + /** + * Returns the bits in the given range as a base-2 string + * @memberof Address4 + * @instance + * @returns {string} + */ + getBitsBase2(start, end) { + return this.binaryZeroPad().slice(start, end); + } + /** + * Return the reversed ip6.arpa form of the address + * @memberof Address4 + * @param {Object} options + * @param {boolean} options.omitSuffix - omit the "in-addr.arpa" suffix + * @instance + * @returns {String} + */ + reverseForm(options) { + if (!options) { + options = {}; + } + const reversed = this.correctForm().split('.').reverse().join('.'); + if (options.omitSuffix) { + return reversed; + } + return (0, sprintf_js_1$3.sprintf)('%s.in-addr.arpa.', reversed); + } + /** + * Returns true if the given address is a multicast address + * @memberof Address4 + * @instance + * @returns {boolean} + */ + isMulticast() { + return this.isInSubnet(new Address4('224.0.0.0/4')); + } + /** + * Returns a zero-padded base-2 string representation of the address + * @memberof Address4 + * @instance + * @returns {string} + */ + binaryZeroPad() { + return this.bigInteger().toString(2).padStart(constants$1.BITS, '0'); + } + /** + * Groups an IPv4 address for inclusion at the end of an IPv6 address + * @returns {String} + */ + groupForV6() { + const segments = this.parsedAddress; + return this.address.replace(constants$1.RE_ADDRESS, (0, sprintf_js_1$3.sprintf)('%s.%s', segments.slice(0, 2).join('.'), segments.slice(2, 4).join('.'))); + } +} +ipv4.Address4 = Address4; + +var ipv6 = {}; + +var constants = {}; + +Object.defineProperty(constants, "__esModule", { value: true }); +constants.RE_URL_WITH_PORT = constants.RE_URL = constants.RE_ZONE_STRING = constants.RE_SUBNET_STRING = constants.RE_BAD_ADDRESS = constants.RE_BAD_CHARACTERS = constants.TYPES = constants.SCOPES = constants.GROUPS = constants.BITS = void 0; +constants.BITS = 128; +constants.GROUPS = 8; +/** + * Represents IPv6 address scopes + * @memberof Address6 + * @static + */ +constants.SCOPES = { + 0: 'Reserved', + 1: 'Interface local', + 2: 'Link local', + 4: 'Admin local', + 5: 'Site local', + 8: 'Organization local', + 14: 'Global', + 15: 'Reserved', +}; +/** + * Represents IPv6 address types + * @memberof Address6 + * @static + */ +constants.TYPES = { + 'ff01::1/128': 'Multicast (All nodes on this interface)', + 'ff01::2/128': 'Multicast (All routers on this interface)', + 'ff02::1/128': 'Multicast (All nodes on this link)', + 'ff02::2/128': 'Multicast (All routers on this link)', + 'ff05::2/128': 'Multicast (All routers in this site)', + 'ff02::5/128': 'Multicast (OSPFv3 AllSPF routers)', + 'ff02::6/128': 'Multicast (OSPFv3 AllDR routers)', + 'ff02::9/128': 'Multicast (RIP routers)', + 'ff02::a/128': 'Multicast (EIGRP routers)', + 'ff02::d/128': 'Multicast (PIM routers)', + 'ff02::16/128': 'Multicast (MLDv2 reports)', + 'ff01::fb/128': 'Multicast (mDNSv6)', + 'ff02::fb/128': 'Multicast (mDNSv6)', + 'ff05::fb/128': 'Multicast (mDNSv6)', + 'ff02::1:2/128': 'Multicast (All DHCP servers and relay agents on this link)', + 'ff05::1:2/128': 'Multicast (All DHCP servers and relay agents in this site)', + 'ff02::1:3/128': 'Multicast (All DHCP servers on this link)', + 'ff05::1:3/128': 'Multicast (All DHCP servers in this site)', + '::/128': 'Unspecified', + '::1/128': 'Loopback', + 'ff00::/8': 'Multicast', + 'fe80::/10': 'Link-local unicast', +}; +/** + * A regular expression that matches bad characters in an IPv6 address + * @memberof Address6 + * @static + */ +constants.RE_BAD_CHARACTERS = /([^0-9a-f:/%])/gi; +/** + * A regular expression that matches an incorrect IPv6 address + * @memberof Address6 + * @static + */ +constants.RE_BAD_ADDRESS = /([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi; +/** + * A regular expression that matches an IPv6 subnet + * @memberof Address6 + * @static + */ +constants.RE_SUBNET_STRING = /\/\d{1,3}(?=%|$)/; +/** + * A regular expression that matches an IPv6 zone + * @memberof Address6 + * @static + */ +constants.RE_ZONE_STRING = /%.*$/; +constants.RE_URL = new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/); +constants.RE_URL_WITH_PORT = new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/); + +var helpers$1 = {}; + +Object.defineProperty(helpers$1, "__esModule", { value: true }); +helpers$1.simpleGroup = helpers$1.spanLeadingZeroes = helpers$1.spanAll = helpers$1.spanAllZeroes = void 0; +const sprintf_js_1$2 = sprintf; +/** + * @returns {String} the string with all zeroes contained in a + */ +function spanAllZeroes(s) { + return s.replace(/(0+)/g, '$1'); +} +helpers$1.spanAllZeroes = spanAllZeroes; +/** + * @returns {String} the string with each character contained in a + */ +function spanAll(s, offset = 0) { + const letters = s.split(''); + return letters + .map((n, i) => (0, sprintf_js_1$2.sprintf)('%s', n, i + offset, spanAllZeroes(n)) // XXX Use #base-2 .value-0 instead? + ) + .join(''); +} +helpers$1.spanAll = spanAll; +function spanLeadingZeroesSimple(group) { + return group.replace(/^(0+)/, '$1'); +} +/** + * @returns {String} the string with leading zeroes contained in a + */ +function spanLeadingZeroes(address) { + const groups = address.split(':'); + return groups.map((g) => spanLeadingZeroesSimple(g)).join(':'); +} +helpers$1.spanLeadingZeroes = spanLeadingZeroes; +/** + * Groups an address + * @returns {String} a grouped address + */ +function simpleGroup(addressString, offset = 0) { + const groups = addressString.split(':'); + return groups.map((g, i) => { + if (/group-v4/.test(g)) { + return g; + } + return (0, sprintf_js_1$2.sprintf)('%s', i + offset, spanLeadingZeroesSimple(g)); + }); +} +helpers$1.simpleGroup = simpleGroup; + +var regularExpressions = {}; + +var __createBinding$2 = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault$2 = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar$2 = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding$2(result, mod, k); + __setModuleDefault$2(result, mod); + return result; +}; +Object.defineProperty(regularExpressions, "__esModule", { value: true }); +regularExpressions.possibleElisions = regularExpressions.simpleRegularExpression = regularExpressions.ADDRESS_BOUNDARY = regularExpressions.padGroup = regularExpressions.groupPossibilities = void 0; +const v6 = __importStar$2(constants); +const sprintf_js_1$1 = sprintf; +function groupPossibilities(possibilities) { + return (0, sprintf_js_1$1.sprintf)('(%s)', possibilities.join('|')); +} +regularExpressions.groupPossibilities = groupPossibilities; +function padGroup(group) { + if (group.length < 4) { + return (0, sprintf_js_1$1.sprintf)('0{0,%d}%s', 4 - group.length, group); + } + return group; +} +regularExpressions.padGroup = padGroup; +regularExpressions.ADDRESS_BOUNDARY = '[^A-Fa-f0-9:]'; +function simpleRegularExpression(groups) { + const zeroIndexes = []; + groups.forEach((group, i) => { + const groupInteger = parseInt(group, 16); + if (groupInteger === 0) { + zeroIndexes.push(i); + } + }); + // You can technically elide a single 0, this creates the regular expressions + // to match that eventuality + const possibilities = zeroIndexes.map((zeroIndex) => groups + .map((group, i) => { + if (i === zeroIndex) { + const elision = i === 0 || i === v6.GROUPS - 1 ? ':' : ''; + return groupPossibilities([padGroup(group), elision]); + } + return padGroup(group); + }) + .join(':')); + // The simplest case + possibilities.push(groups.map(padGroup).join(':')); + return groupPossibilities(possibilities); +} +regularExpressions.simpleRegularExpression = simpleRegularExpression; +function possibleElisions(elidedGroups, moreLeft, moreRight) { + const left = moreLeft ? '' : ':'; + const right = moreRight ? '' : ':'; + const possibilities = []; + // 1. elision of everything (::) + if (!moreLeft && !moreRight) { + possibilities.push('::'); + } + // 2. complete elision of the middle + if (moreLeft && moreRight) { + possibilities.push(''); + } + if ((moreRight && !moreLeft) || (!moreRight && moreLeft)) { + // 3. complete elision of one side + possibilities.push(':'); + } + // 4. elision from the left side + possibilities.push((0, sprintf_js_1$1.sprintf)('%s(:0{1,4}){1,%d}', left, elidedGroups - 1)); + // 5. elision from the right side + possibilities.push((0, sprintf_js_1$1.sprintf)('(0{1,4}:){1,%d}%s', elidedGroups - 1, right)); + // 6. no elision + possibilities.push((0, sprintf_js_1$1.sprintf)('(0{1,4}:){%d}0{1,4}', elidedGroups - 1)); + // 7. elision (including sloppy elision) from the middle + for (let groups = 1; groups < elidedGroups - 1; groups++) { + for (let position = 1; position < elidedGroups - groups; position++) { + possibilities.push((0, sprintf_js_1$1.sprintf)('(0{1,4}:){%d}:(0{1,4}:){%d}0{1,4}', position, elidedGroups - position - groups - 1)); + } + } + return groupPossibilities(possibilities); +} +regularExpressions.possibleElisions = possibleElisions; + +/* eslint-disable prefer-destructuring */ +/* eslint-disable no-param-reassign */ +var __createBinding$1 = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault$1 = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar$1 = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding$1(result, mod, k); + __setModuleDefault$1(result, mod); + return result; +}; +Object.defineProperty(ipv6, "__esModule", { value: true }); +ipv6.Address6 = void 0; +const common = __importStar$1(common$2); +const constants4 = __importStar$1(constants$2); +const constants6 = __importStar$1(constants); +const helpers = __importStar$1(helpers$1); +const ipv4_1 = ipv4; +const regular_expressions_1 = regularExpressions; +const address_error_1 = addressError; +const jsbn_1 = jsbnExports; +const sprintf_js_1 = sprintf; +function assert$4(condition) { + if (!condition) { + throw new Error('Assertion failed.'); + } +} +function addCommas(number) { + const r = /(\d+)(\d{3})/; + while (r.test(number)) { + number = number.replace(r, '$1,$2'); + } + return number; +} +function spanLeadingZeroes4(n) { + n = n.replace(/^(0{1,})([1-9]+)$/, '$1$2'); + n = n.replace(/^(0{1,})(0)$/, '$1$2'); + return n; +} +/* + * A helper function to compact an array + */ +function compact(address, slice) { + const s1 = []; + const s2 = []; + let i; + for (i = 0; i < address.length; i++) { + if (i < slice[0]) { + s1.push(address[i]); + } + else if (i > slice[1]) { + s2.push(address[i]); + } + } + return s1.concat(['compact']).concat(s2); +} +function paddedHex(octet) { + return (0, sprintf_js_1.sprintf)('%04x', parseInt(octet, 16)); +} +function unsignByte(b) { + // eslint-disable-next-line no-bitwise + return b & 0xff; +} +/** + * Represents an IPv6 address + * @class Address6 + * @param {string} address - An IPv6 address string + * @param {number} [groups=8] - How many octets to parse + * @example + * var address = new Address6('2001::/32'); + */ +class Address6 { + constructor(address, optionalGroups) { + this.addressMinusSuffix = ''; + this.parsedSubnet = ''; + this.subnet = '/128'; + this.subnetMask = 128; + this.v4 = false; + this.zone = ''; + // #region Attributes + /** + * Returns true if the given address is in the subnet of the current address + * @memberof Address6 + * @instance + * @returns {boolean} + */ + this.isInSubnet = common.isInSubnet; + /** + * Returns true if the address is correct, false otherwise + * @memberof Address6 + * @instance + * @returns {boolean} + */ + this.isCorrect = common.isCorrect(constants6.BITS); + if (optionalGroups === undefined) { + this.groups = constants6.GROUPS; + } + else { + this.groups = optionalGroups; + } + this.address = address; + const subnet = constants6.RE_SUBNET_STRING.exec(address); + if (subnet) { + this.parsedSubnet = subnet[0].replace('/', ''); + this.subnetMask = parseInt(this.parsedSubnet, 10); + this.subnet = `/${this.subnetMask}`; + if (Number.isNaN(this.subnetMask) || + this.subnetMask < 0 || + this.subnetMask > constants6.BITS) { + throw new address_error_1.AddressError('Invalid subnet mask.'); + } + address = address.replace(constants6.RE_SUBNET_STRING, ''); + } + else if (/\//.test(address)) { + throw new address_error_1.AddressError('Invalid subnet mask.'); + } + const zone = constants6.RE_ZONE_STRING.exec(address); + if (zone) { + this.zone = zone[0]; + address = address.replace(constants6.RE_ZONE_STRING, ''); + } + this.addressMinusSuffix = address; + this.parsedAddress = this.parse(this.addressMinusSuffix); + } + static isValid(address) { + try { + // eslint-disable-next-line no-new + new Address6(address); + return true; + } + catch (e) { + return false; + } + } + /** + * Convert a BigInteger to a v6 address object + * @memberof Address6 + * @static + * @param {BigInteger} bigInteger - a BigInteger to convert + * @returns {Address6} + * @example + * var bigInteger = new BigInteger('1000000000000'); + * var address = Address6.fromBigInteger(bigInteger); + * address.correctForm(); // '::e8:d4a5:1000' + */ + static fromBigInteger(bigInteger) { + const hex = bigInteger.toString(16).padStart(32, '0'); + const groups = []; + let i; + for (i = 0; i < constants6.GROUPS; i++) { + groups.push(hex.slice(i * 4, (i + 1) * 4)); + } + return new Address6(groups.join(':')); + } + /** + * Convert a URL (with optional port number) to an address object + * @memberof Address6 + * @static + * @param {string} url - a URL with optional port number + * @example + * var addressAndPort = Address6.fromURL('http://[ffff::]:8080/foo/'); + * addressAndPort.address.correctForm(); // 'ffff::' + * addressAndPort.port; // 8080 + */ + static fromURL(url) { + let host; + let port = null; + let result; + // If we have brackets parse them and find a port + if (url.indexOf('[') !== -1 && url.indexOf(']:') !== -1) { + result = constants6.RE_URL_WITH_PORT.exec(url); + if (result === null) { + return { + error: 'failed to parse address with port', + address: null, + port: null, + }; + } + host = result[1]; + port = result[2]; + // If there's a URL extract the address + } + else if (url.indexOf('/') !== -1) { + // Remove the protocol prefix + url = url.replace(/^[a-z0-9]+:\/\//, ''); + // Parse the address + result = constants6.RE_URL.exec(url); + if (result === null) { + return { + error: 'failed to parse address from URL', + address: null, + port: null, + }; + } + host = result[1]; + // Otherwise just assign the URL to the host and let the library parse it + } + else { + host = url; + } + // If there's a port convert it to an integer + if (port) { + port = parseInt(port, 10); + // squelch out of range ports + if (port < 0 || port > 65536) { + port = null; + } + } + else { + // Standardize `undefined` to `null` + port = null; + } + return { + address: new Address6(host), + port, + }; + } + /** + * Create an IPv6-mapped address given an IPv4 address + * @memberof Address6 + * @static + * @param {string} address - An IPv4 address string + * @returns {Address6} + * @example + * var address = Address6.fromAddress4('192.168.0.1'); + * address.correctForm(); // '::ffff:c0a8:1' + * address.to4in6(); // '::ffff:192.168.0.1' + */ + static fromAddress4(address) { + const address4 = new ipv4_1.Address4(address); + const mask6 = constants6.BITS - (constants4.BITS - address4.subnetMask); + return new Address6(`::ffff:${address4.correctForm()}/${mask6}`); + } + /** + * Return an address from ip6.arpa form + * @memberof Address6 + * @static + * @param {string} arpaFormAddress - an 'ip6.arpa' form address + * @returns {Adress6} + * @example + * var address = Address6.fromArpa(e.f.f.f.3.c.2.6.f.f.f.e.6.6.8.e.1.0.6.7.9.4.e.c.0.0.0.0.1.0.0.2.ip6.arpa.) + * address.correctForm(); // '2001:0:ce49:7601:e866:efff:62c3:fffe' + */ + static fromArpa(arpaFormAddress) { + // remove ending ".ip6.arpa." or just "." + let address = arpaFormAddress.replace(/(\.ip6\.arpa)?\.$/, ''); + const semicolonAmount = 7; + // correct ip6.arpa form with ending removed will be 63 characters + if (address.length !== 63) { + throw new address_error_1.AddressError("Invalid 'ip6.arpa' form."); + } + const parts = address.split('.').reverse(); + for (let i = semicolonAmount; i > 0; i--) { + const insertIndex = i * 4; + parts.splice(insertIndex, 0, ':'); + } + address = parts.join(''); + return new Address6(address); + } + /** + * Return the Microsoft UNC transcription of the address + * @memberof Address6 + * @instance + * @returns {String} the Microsoft UNC transcription of the address + */ + microsoftTranscription() { + return (0, sprintf_js_1.sprintf)('%s.ipv6-literal.net', this.correctForm().replace(/:/g, '-')); + } + /** + * Return the first n bits of the address, defaulting to the subnet mask + * @memberof Address6 + * @instance + * @param {number} [mask=subnet] - the number of bits to mask + * @returns {String} the first n bits of the address as a string + */ + mask(mask = this.subnetMask) { + return this.getBitsBase2(0, mask); + } + /** + * Return the number of possible subnets of a given size in the address + * @memberof Address6 + * @instance + * @param {number} [size=128] - the subnet size + * @returns {String} + */ + // TODO: probably useful to have a numeric version of this too + possibleSubnets(subnetSize = 128) { + const availableBits = constants6.BITS - this.subnetMask; + const subnetBits = Math.abs(subnetSize - constants6.BITS); + const subnetPowers = availableBits - subnetBits; + if (subnetPowers < 0) { + return '0'; + } + return addCommas(new jsbn_1.BigInteger('2', 10).pow(subnetPowers).toString(10)); + } + /** + * Helper function getting start address. + * @memberof Address6 + * @instance + * @returns {BigInteger} + */ + _startAddress() { + return new jsbn_1.BigInteger(this.mask() + '0'.repeat(constants6.BITS - this.subnetMask), 2); + } + /** + * The first address in the range given by this address' subnet + * Often referred to as the Network Address. + * @memberof Address6 + * @instance + * @returns {Address6} + */ + startAddress() { + return Address6.fromBigInteger(this._startAddress()); + } + /** + * The first host address in the range given by this address's subnet ie + * the first address after the Network Address + * @memberof Address6 + * @instance + * @returns {Address6} + */ + startAddressExclusive() { + const adjust = new jsbn_1.BigInteger('1'); + return Address6.fromBigInteger(this._startAddress().add(adjust)); + } + /** + * Helper function getting end address. + * @memberof Address6 + * @instance + * @returns {BigInteger} + */ + _endAddress() { + return new jsbn_1.BigInteger(this.mask() + '1'.repeat(constants6.BITS - this.subnetMask), 2); + } + /** + * The last address in the range given by this address' subnet + * Often referred to as the Broadcast + * @memberof Address6 + * @instance + * @returns {Address6} + */ + endAddress() { + return Address6.fromBigInteger(this._endAddress()); + } + /** + * The last host address in the range given by this address's subnet ie + * the last address prior to the Broadcast Address + * @memberof Address6 + * @instance + * @returns {Address6} + */ + endAddressExclusive() { + const adjust = new jsbn_1.BigInteger('1'); + return Address6.fromBigInteger(this._endAddress().subtract(adjust)); + } + /** + * Return the scope of the address + * @memberof Address6 + * @instance + * @returns {String} + */ + getScope() { + let scope = constants6.SCOPES[this.getBits(12, 16).intValue()]; + if (this.getType() === 'Global unicast' && scope !== 'Link local') { + scope = 'Global'; + } + return scope || 'Unknown'; + } + /** + * Return the type of the address + * @memberof Address6 + * @instance + * @returns {String} + */ + getType() { + for (const subnet of Object.keys(constants6.TYPES)) { + if (this.isInSubnet(new Address6(subnet))) { + return constants6.TYPES[subnet]; + } + } + return 'Global unicast'; + } + /** + * Return the bits in the given range as a BigInteger + * @memberof Address6 + * @instance + * @returns {BigInteger} + */ + getBits(start, end) { + return new jsbn_1.BigInteger(this.getBitsBase2(start, end), 2); + } + /** + * Return the bits in the given range as a base-2 string + * @memberof Address6 + * @instance + * @returns {String} + */ + getBitsBase2(start, end) { + return this.binaryZeroPad().slice(start, end); + } + /** + * Return the bits in the given range as a base-16 string + * @memberof Address6 + * @instance + * @returns {String} + */ + getBitsBase16(start, end) { + const length = end - start; + if (length % 4 !== 0) { + throw new Error('Length of bits to retrieve must be divisible by four'); + } + return this.getBits(start, end) + .toString(16) + .padStart(length / 4, '0'); + } + /** + * Return the bits that are set past the subnet mask length + * @memberof Address6 + * @instance + * @returns {String} + */ + getBitsPastSubnet() { + return this.getBitsBase2(this.subnetMask, constants6.BITS); + } + /** + * Return the reversed ip6.arpa form of the address + * @memberof Address6 + * @param {Object} options + * @param {boolean} options.omitSuffix - omit the "ip6.arpa" suffix + * @instance + * @returns {String} + */ + reverseForm(options) { + if (!options) { + options = {}; + } + const characters = Math.floor(this.subnetMask / 4); + const reversed = this.canonicalForm() + .replace(/:/g, '') + .split('') + .slice(0, characters) + .reverse() + .join('.'); + if (characters > 0) { + if (options.omitSuffix) { + return reversed; + } + return (0, sprintf_js_1.sprintf)('%s.ip6.arpa.', reversed); + } + if (options.omitSuffix) { + return ''; + } + return 'ip6.arpa.'; + } + /** + * Return the correct form of the address + * @memberof Address6 + * @instance + * @returns {String} + */ + correctForm() { + let i; + let groups = []; + let zeroCounter = 0; + const zeroes = []; + for (i = 0; i < this.parsedAddress.length; i++) { + const value = parseInt(this.parsedAddress[i], 16); + if (value === 0) { + zeroCounter++; + } + if (value !== 0 && zeroCounter > 0) { + if (zeroCounter > 1) { + zeroes.push([i - zeroCounter, i - 1]); + } + zeroCounter = 0; + } + } + // Do we end with a string of zeroes? + if (zeroCounter > 1) { + zeroes.push([this.parsedAddress.length - zeroCounter, this.parsedAddress.length - 1]); + } + const zeroLengths = zeroes.map((n) => n[1] - n[0] + 1); + if (zeroes.length > 0) { + const index = zeroLengths.indexOf(Math.max(...zeroLengths)); + groups = compact(this.parsedAddress, zeroes[index]); + } + else { + groups = this.parsedAddress; + } + for (i = 0; i < groups.length; i++) { + if (groups[i] !== 'compact') { + groups[i] = parseInt(groups[i], 16).toString(16); + } + } + let correct = groups.join(':'); + correct = correct.replace(/^compact$/, '::'); + correct = correct.replace(/^compact|compact$/, ':'); + correct = correct.replace(/compact/, ''); + return correct; + } + /** + * Return a zero-padded base-2 string representation of the address + * @memberof Address6 + * @instance + * @returns {String} + * @example + * var address = new Address6('2001:4860:4001:803::1011'); + * address.binaryZeroPad(); + * // '0010000000000001010010000110000001000000000000010000100000000011 + * // 0000000000000000000000000000000000000000000000000001000000010001' + */ + binaryZeroPad() { + return this.bigInteger().toString(2).padStart(constants6.BITS, '0'); + } + // TODO: Improve the semantics of this helper function + parse4in6(address) { + const groups = address.split(':'); + const lastGroup = groups.slice(-1)[0]; + const address4 = lastGroup.match(constants4.RE_ADDRESS); + if (address4) { + this.parsedAddress4 = address4[0]; + this.address4 = new ipv4_1.Address4(this.parsedAddress4); + for (let i = 0; i < this.address4.groups; i++) { + if (/^0[0-9]+/.test(this.address4.parsedAddress[i])) { + throw new address_error_1.AddressError("IPv4 addresses can't have leading zeroes.", address.replace(constants4.RE_ADDRESS, this.address4.parsedAddress.map(spanLeadingZeroes4).join('.'))); + } + } + this.v4 = true; + groups[groups.length - 1] = this.address4.toGroup6(); + address = groups.join(':'); + } + return address; + } + // TODO: Make private? + parse(address) { + address = this.parse4in6(address); + const badCharacters = address.match(constants6.RE_BAD_CHARACTERS); + if (badCharacters) { + throw new address_error_1.AddressError((0, sprintf_js_1.sprintf)('Bad character%s detected in address: %s', badCharacters.length > 1 ? 's' : '', badCharacters.join('')), address.replace(constants6.RE_BAD_CHARACTERS, '$1')); + } + const badAddress = address.match(constants6.RE_BAD_ADDRESS); + if (badAddress) { + throw new address_error_1.AddressError((0, sprintf_js_1.sprintf)('Address failed regex: %s', badAddress.join('')), address.replace(constants6.RE_BAD_ADDRESS, '$1')); + } + let groups = []; + const halves = address.split('::'); + if (halves.length === 2) { + let first = halves[0].split(':'); + let last = halves[1].split(':'); + if (first.length === 1 && first[0] === '') { + first = []; + } + if (last.length === 1 && last[0] === '') { + last = []; + } + const remaining = this.groups - (first.length + last.length); + if (!remaining) { + throw new address_error_1.AddressError('Error parsing groups'); + } + this.elidedGroups = remaining; + this.elisionBegin = first.length; + this.elisionEnd = first.length + this.elidedGroups; + groups = groups.concat(first); + for (let i = 0; i < remaining; i++) { + groups.push('0'); + } + groups = groups.concat(last); + } + else if (halves.length === 1) { + groups = address.split(':'); + this.elidedGroups = 0; + } + else { + throw new address_error_1.AddressError('Too many :: groups found'); + } + groups = groups.map((group) => (0, sprintf_js_1.sprintf)('%x', parseInt(group, 16))); + if (groups.length !== this.groups) { + throw new address_error_1.AddressError('Incorrect number of groups found'); + } + return groups; + } + /** + * Return the canonical form of the address + * @memberof Address6 + * @instance + * @returns {String} + */ + canonicalForm() { + return this.parsedAddress.map(paddedHex).join(':'); + } + /** + * Return the decimal form of the address + * @memberof Address6 + * @instance + * @returns {String} + */ + decimal() { + return this.parsedAddress.map((n) => (0, sprintf_js_1.sprintf)('%05d', parseInt(n, 16))).join(':'); + } + /** + * Return the address as a BigInteger + * @memberof Address6 + * @instance + * @returns {BigInteger} + */ + bigInteger() { + return new jsbn_1.BigInteger(this.parsedAddress.map(paddedHex).join(''), 16); + } + /** + * Return the last two groups of this address as an IPv4 address string + * @memberof Address6 + * @instance + * @returns {Address4} + * @example + * var address = new Address6('2001:4860:4001::1825:bf11'); + * address.to4().correctForm(); // '24.37.191.17' + */ + to4() { + const binary = this.binaryZeroPad().split(''); + return ipv4_1.Address4.fromHex(new jsbn_1.BigInteger(binary.slice(96, 128).join(''), 2).toString(16)); + } + /** + * Return the v4-in-v6 form of the address + * @memberof Address6 + * @instance + * @returns {String} + */ + to4in6() { + const address4 = this.to4(); + const address6 = new Address6(this.parsedAddress.slice(0, 6).join(':'), 6); + const correct = address6.correctForm(); + let infix = ''; + if (!/:$/.test(correct)) { + infix = ':'; + } + return correct + infix + address4.address; + } + /** + * Return an object containing the Teredo properties of the address + * @memberof Address6 + * @instance + * @returns {Object} + */ + inspectTeredo() { + /* + - Bits 0 to 31 are set to the Teredo prefix (normally 2001:0000::/32). + - Bits 32 to 63 embed the primary IPv4 address of the Teredo server that + is used. + - Bits 64 to 79 can be used to define some flags. Currently only the + higher order bit is used; it is set to 1 if the Teredo client is + located behind a cone NAT, 0 otherwise. For Microsoft's Windows Vista + and Windows Server 2008 implementations, more bits are used. In those + implementations, the format for these 16 bits is "CRAAAAUG AAAAAAAA", + where "C" remains the "Cone" flag. The "R" bit is reserved for future + use. The "U" bit is for the Universal/Local flag (set to 0). The "G" bit + is Individual/Group flag (set to 0). The A bits are set to a 12-bit + randomly generated number chosen by the Teredo client to introduce + additional protection for the Teredo node against IPv6-based scanning + attacks. + - Bits 80 to 95 contains the obfuscated UDP port number. This is the + port number that is mapped by the NAT to the Teredo client with all + bits inverted. + - Bits 96 to 127 contains the obfuscated IPv4 address. This is the + public IPv4 address of the NAT with all bits inverted. + */ + const prefix = this.getBitsBase16(0, 32); + const udpPort = this.getBits(80, 96).xor(new jsbn_1.BigInteger('ffff', 16)).toString(); + const server4 = ipv4_1.Address4.fromHex(this.getBitsBase16(32, 64)); + const client4 = ipv4_1.Address4.fromHex(this.getBits(96, 128).xor(new jsbn_1.BigInteger('ffffffff', 16)).toString(16)); + const flags = this.getBits(64, 80); + const flagsBase2 = this.getBitsBase2(64, 80); + const coneNat = flags.testBit(15); + const reserved = flags.testBit(14); + const groupIndividual = flags.testBit(8); + const universalLocal = flags.testBit(9); + const nonce = new jsbn_1.BigInteger(flagsBase2.slice(2, 6) + flagsBase2.slice(8, 16), 2).toString(10); + return { + prefix: (0, sprintf_js_1.sprintf)('%s:%s', prefix.slice(0, 4), prefix.slice(4, 8)), + server4: server4.address, + client4: client4.address, + flags: flagsBase2, + coneNat, + microsoft: { + reserved, + universalLocal, + groupIndividual, + nonce, + }, + udpPort, + }; + } + /** + * Return an object containing the 6to4 properties of the address + * @memberof Address6 + * @instance + * @returns {Object} + */ + inspect6to4() { + /* + - Bits 0 to 15 are set to the 6to4 prefix (2002::/16). + - Bits 16 to 48 embed the IPv4 address of the 6to4 gateway that is used. + */ + const prefix = this.getBitsBase16(0, 16); + const gateway = ipv4_1.Address4.fromHex(this.getBitsBase16(16, 48)); + return { + prefix: (0, sprintf_js_1.sprintf)('%s', prefix.slice(0, 4)), + gateway: gateway.address, + }; + } + /** + * Return a v6 6to4 address from a v6 v4inv6 address + * @memberof Address6 + * @instance + * @returns {Address6} + */ + to6to4() { + if (!this.is4()) { + return null; + } + const addr6to4 = [ + '2002', + this.getBitsBase16(96, 112), + this.getBitsBase16(112, 128), + '', + '/16', + ].join(':'); + return new Address6(addr6to4); + } + /** + * Return a byte array + * @memberof Address6 + * @instance + * @returns {Array} + */ + toByteArray() { + const byteArray = this.bigInteger().toByteArray(); + // work around issue where `toByteArray` returns a leading 0 element + if (byteArray.length === 17 && byteArray[0] === 0) { + return byteArray.slice(1); + } + return byteArray; + } + /** + * Return an unsigned byte array + * @memberof Address6 + * @instance + * @returns {Array} + */ + toUnsignedByteArray() { + return this.toByteArray().map(unsignByte); + } + /** + * Convert a byte array to an Address6 object + * @memberof Address6 + * @static + * @returns {Address6} + */ + static fromByteArray(bytes) { + return this.fromUnsignedByteArray(bytes.map(unsignByte)); + } + /** + * Convert an unsigned byte array to an Address6 object + * @memberof Address6 + * @static + * @returns {Address6} + */ + static fromUnsignedByteArray(bytes) { + const BYTE_MAX = new jsbn_1.BigInteger('256', 10); + let result = new jsbn_1.BigInteger('0', 10); + let multiplier = new jsbn_1.BigInteger('1', 10); + for (let i = bytes.length - 1; i >= 0; i--) { + result = result.add(multiplier.multiply(new jsbn_1.BigInteger(bytes[i].toString(10), 10))); + multiplier = multiplier.multiply(BYTE_MAX); + } + return Address6.fromBigInteger(result); + } + /** + * Returns true if the address is in the canonical form, false otherwise + * @memberof Address6 + * @instance + * @returns {boolean} + */ + isCanonical() { + return this.addressMinusSuffix === this.canonicalForm(); + } + /** + * Returns true if the address is a link local address, false otherwise + * @memberof Address6 + * @instance + * @returns {boolean} + */ + isLinkLocal() { + // Zeroes are required, i.e. we can't check isInSubnet with 'fe80::/10' + if (this.getBitsBase2(0, 64) === + '1111111010000000000000000000000000000000000000000000000000000000') { + return true; + } + return false; + } + /** + * Returns true if the address is a multicast address, false otherwise + * @memberof Address6 + * @instance + * @returns {boolean} + */ + isMulticast() { + return this.getType() === 'Multicast'; + } + /** + * Returns true if the address is a v4-in-v6 address, false otherwise + * @memberof Address6 + * @instance + * @returns {boolean} + */ + is4() { + return this.v4; + } + /** + * Returns true if the address is a Teredo address, false otherwise + * @memberof Address6 + * @instance + * @returns {boolean} + */ + isTeredo() { + return this.isInSubnet(new Address6('2001::/32')); + } + /** + * Returns true if the address is a 6to4 address, false otherwise + * @memberof Address6 + * @instance + * @returns {boolean} + */ + is6to4() { + return this.isInSubnet(new Address6('2002::/16')); + } + /** + * Returns true if the address is a loopback address, false otherwise + * @memberof Address6 + * @instance + * @returns {boolean} + */ + isLoopback() { + return this.getType() === 'Loopback'; + } + // #endregion + // #region HTML + /** + * @returns {String} the address in link form with a default port of 80 + */ + href(optionalPort) { + if (optionalPort === undefined) { + optionalPort = ''; + } + else { + optionalPort = (0, sprintf_js_1.sprintf)(':%s', optionalPort); + } + return (0, sprintf_js_1.sprintf)('http://[%s]%s/', this.correctForm(), optionalPort); + } + /** + * @returns {String} a link suitable for conveying the address via a URL hash + */ + link(options) { + if (!options) { + options = {}; + } + if (options.className === undefined) { + options.className = ''; + } + if (options.prefix === undefined) { + options.prefix = '/#address='; + } + if (options.v4 === undefined) { + options.v4 = false; + } + let formFunction = this.correctForm; + if (options.v4) { + formFunction = this.to4in6; + } + if (options.className) { + return (0, sprintf_js_1.sprintf)('%2$s', options.prefix, formFunction.call(this), options.className); + } + return (0, sprintf_js_1.sprintf)('%2$s', options.prefix, formFunction.call(this)); + } + /** + * Groups an address + * @returns {String} + */ + group() { + if (this.elidedGroups === 0) { + // The simple case + return helpers.simpleGroup(this.address).join(':'); + } + assert$4(typeof this.elidedGroups === 'number'); + assert$4(typeof this.elisionBegin === 'number'); + // The elided case + const output = []; + const [left, right] = this.address.split('::'); + if (left.length) { + output.push(...helpers.simpleGroup(left)); + } + else { + output.push(''); + } + const classes = ['hover-group']; + for (let i = this.elisionBegin; i < this.elisionBegin + this.elidedGroups; i++) { + classes.push((0, sprintf_js_1.sprintf)('group-%d', i)); + } + output.push((0, sprintf_js_1.sprintf)('', classes.join(' '))); + if (right.length) { + output.push(...helpers.simpleGroup(right, this.elisionEnd)); + } + else { + output.push(''); + } + if (this.is4()) { + assert$4(this.address4 instanceof ipv4_1.Address4); + output.pop(); + output.push(this.address4.groupForV6()); + } + return output.join(':'); + } + // #endregion + // #region Regular expressions + /** + * Generate a regular expression string that can be used to find or validate + * all variations of this address + * @memberof Address6 + * @instance + * @param {boolean} substringSearch + * @returns {string} + */ + regularExpressionString(substringSearch = false) { + let output = []; + // TODO: revisit why this is necessary + const address6 = new Address6(this.correctForm()); + if (address6.elidedGroups === 0) { + // The simple case + output.push((0, regular_expressions_1.simpleRegularExpression)(address6.parsedAddress)); + } + else if (address6.elidedGroups === constants6.GROUPS) { + // A completely elided address + output.push((0, regular_expressions_1.possibleElisions)(constants6.GROUPS)); + } + else { + // A partially elided address + const halves = address6.address.split('::'); + if (halves[0].length) { + output.push((0, regular_expressions_1.simpleRegularExpression)(halves[0].split(':'))); + } + assert$4(typeof address6.elidedGroups === 'number'); + output.push((0, regular_expressions_1.possibleElisions)(address6.elidedGroups, halves[0].length !== 0, halves[1].length !== 0)); + if (halves[1].length) { + output.push((0, regular_expressions_1.simpleRegularExpression)(halves[1].split(':'))); + } + output = [output.join(':')]; + } + if (!substringSearch) { + output = [ + '(?=^|', + regular_expressions_1.ADDRESS_BOUNDARY, + '|[^\\w\\:])(', + ...output, + ')(?=[^\\w\\:]|', + regular_expressions_1.ADDRESS_BOUNDARY, + '|$)', + ]; + } + return output.join(''); + } + /** + * Generate a regular expression that can be used to find or validate all + * variations of this address. + * @memberof Address6 + * @instance + * @param {boolean} substringSearch + * @returns {RegExp} + */ + regularExpression(substringSearch = false) { + return new RegExp(this.regularExpressionString(substringSearch), 'i'); + } +} +ipv6.Address6 = Address6; + +(function (exports) { + var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); + }) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + })); + var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); + }) : function(o, v) { + o["default"] = v; + }); + var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.v6 = exports.AddressError = exports.Address6 = exports.Address4 = void 0; + const ipv4_1 = ipv4; + Object.defineProperty(exports, "Address4", { enumerable: true, get: function () { return ipv4_1.Address4; } }); + const ipv6_1 = ipv6; + Object.defineProperty(exports, "Address6", { enumerable: true, get: function () { return ipv6_1.Address6; } }); + const address_error_1 = addressError; + Object.defineProperty(exports, "AddressError", { enumerable: true, get: function () { return address_error_1.AddressError; } }); + const helpers = __importStar(helpers$1); + exports.v6 = { helpers }; + +} (ipAddress)); + +Object.defineProperty(helpers$2, "__esModule", { value: true }); +helpers$2.ipToBuffer = helpers$2.int32ToIpv4 = helpers$2.ipv4ToInt32 = helpers$2.validateSocksClientChainOptions = helpers$2.validateSocksClientOptions = void 0; +const util_1$q = util$1; +const constants_1 = constants$3; +const stream$1 = Stream; +const ip_address_1 = ipAddress; +const net$1 = require$$0$4; +/** + * Validates the provided SocksClientOptions + * @param options { SocksClientOptions } + * @param acceptedCommands { string[] } A list of accepted SocksProxy commands. + */ +function validateSocksClientOptions(options, acceptedCommands = ['connect', 'bind', 'associate']) { + // Check SOCKs command option. + if (!constants_1.SocksCommand[options.command]) { + throw new util_1$q.SocksClientError(constants_1.ERRORS.InvalidSocksCommand, options); + } + // Check SocksCommand for acceptable command. + if (acceptedCommands.indexOf(options.command) === -1) { + throw new util_1$q.SocksClientError(constants_1.ERRORS.InvalidSocksCommandForOperation, options); + } + // Check destination + if (!isValidSocksRemoteHost(options.destination)) { + throw new util_1$q.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsDestination, options); + } + // Check SOCKS proxy to use + if (!isValidSocksProxy(options.proxy)) { + throw new util_1$q.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsProxy, options); + } + // Validate custom auth (if set) + validateCustomProxyAuth(options.proxy, options); + // Check timeout + if (options.timeout && !isValidTimeoutValue(options.timeout)) { + throw new util_1$q.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsTimeout, options); + } + // Check existing_socket (if provided) + if (options.existing_socket && + !(options.existing_socket instanceof stream$1.Duplex)) { + throw new util_1$q.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsExistingSocket, options); + } +} +helpers$2.validateSocksClientOptions = validateSocksClientOptions; +/** + * Validates the SocksClientChainOptions + * @param options { SocksClientChainOptions } + */ +function validateSocksClientChainOptions(options) { + // Only connect is supported when chaining. + if (options.command !== 'connect') { + throw new util_1$q.SocksClientError(constants_1.ERRORS.InvalidSocksCommandChain, options); + } + // Check destination + if (!isValidSocksRemoteHost(options.destination)) { + throw new util_1$q.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsDestination, options); + } + // Validate proxies (length) + if (!(options.proxies && + Array.isArray(options.proxies) && + options.proxies.length >= 2)) { + throw new util_1$q.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsProxiesLength, options); + } + // Validate proxies + options.proxies.forEach((proxy) => { + if (!isValidSocksProxy(proxy)) { + throw new util_1$q.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsProxy, options); + } + // Validate custom auth (if set) + validateCustomProxyAuth(proxy, options); + }); + // Check timeout + if (options.timeout && !isValidTimeoutValue(options.timeout)) { + throw new util_1$q.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsTimeout, options); + } +} +helpers$2.validateSocksClientChainOptions = validateSocksClientChainOptions; +function validateCustomProxyAuth(proxy, options) { + if (proxy.custom_auth_method !== undefined) { + // Invalid auth method range + if (proxy.custom_auth_method < constants_1.SOCKS5_CUSTOM_AUTH_START || + proxy.custom_auth_method > constants_1.SOCKS5_CUSTOM_AUTH_END) { + throw new util_1$q.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsCustomAuthRange, options); + } + // Missing custom_auth_request_handler + if (proxy.custom_auth_request_handler === undefined || + typeof proxy.custom_auth_request_handler !== 'function') { + throw new util_1$q.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsCustomAuthOptions, options); + } + // Missing custom_auth_response_size + if (proxy.custom_auth_response_size === undefined) { + throw new util_1$q.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsCustomAuthOptions, options); + } + // Missing/invalid custom_auth_response_handler + if (proxy.custom_auth_response_handler === undefined || + typeof proxy.custom_auth_response_handler !== 'function') { + throw new util_1$q.SocksClientError(constants_1.ERRORS.InvalidSocksClientOptionsCustomAuthOptions, options); + } + } +} +/** + * Validates a SocksRemoteHost + * @param remoteHost { SocksRemoteHost } + */ +function isValidSocksRemoteHost(remoteHost) { + return (remoteHost && + typeof remoteHost.host === 'string' && + typeof remoteHost.port === 'number' && + remoteHost.port >= 0 && + remoteHost.port <= 65535); +} +/** + * Validates a SocksProxy + * @param proxy { SocksProxy } + */ +function isValidSocksProxy(proxy) { + return (proxy && + (typeof proxy.host === 'string' || typeof proxy.ipaddress === 'string') && + typeof proxy.port === 'number' && + proxy.port >= 0 && + proxy.port <= 65535 && + (proxy.type === 4 || proxy.type === 5)); +} +/** + * Validates a timeout value. + * @param value { Number } + */ +function isValidTimeoutValue(value) { + return typeof value === 'number' && value > 0; +} +function ipv4ToInt32(ip) { + const address = new ip_address_1.Address4(ip); + // Convert the IPv4 address parts to an integer + return address.toArray().reduce((acc, part) => (acc << 8) + part, 0); +} +helpers$2.ipv4ToInt32 = ipv4ToInt32; +function int32ToIpv4(int32) { + // Extract each byte (octet) from the 32-bit integer + const octet1 = (int32 >>> 24) & 0xff; + const octet2 = (int32 >>> 16) & 0xff; + const octet3 = (int32 >>> 8) & 0xff; + const octet4 = int32 & 0xff; + // Combine the octets into a string in IPv4 format + return [octet1, octet2, octet3, octet4].join('.'); +} +helpers$2.int32ToIpv4 = int32ToIpv4; +function ipToBuffer(ip) { + if (net$1.isIPv4(ip)) { + // Handle IPv4 addresses + const address = new ip_address_1.Address4(ip); + return Buffer.from(address.toArray()); + } + else if (net$1.isIPv6(ip)) { + // Handle IPv6 addresses + const address = new ip_address_1.Address6(ip); + return Buffer.from(address.toByteArray()); + } + else { + throw new Error('Invalid IP address format'); + } +} +helpers$2.ipToBuffer = ipToBuffer; + +var receivebuffer = {}; + +Object.defineProperty(receivebuffer, "__esModule", { value: true }); +receivebuffer.ReceiveBuffer = void 0; +class ReceiveBuffer { + constructor(size = 4096) { + this.buffer = Buffer.allocUnsafe(size); + this.offset = 0; + this.originalSize = size; + } + get length() { + return this.offset; + } + append(data) { + if (!Buffer.isBuffer(data)) { + throw new Error('Attempted to append a non-buffer instance to ReceiveBuffer.'); + } + if (this.offset + data.length >= this.buffer.length) { + const tmp = this.buffer; + this.buffer = Buffer.allocUnsafe(Math.max(this.buffer.length + this.originalSize, this.buffer.length + data.length)); + tmp.copy(this.buffer); + } + data.copy(this.buffer, this.offset); + return (this.offset += data.length); + } + peek(length) { + if (length > this.offset) { + throw new Error('Attempted to read beyond the bounds of the managed internal data.'); + } + return this.buffer.slice(0, length); + } + get(length) { + if (length > this.offset) { + throw new Error('Attempted to read beyond the bounds of the managed internal data.'); + } + const value = Buffer.allocUnsafe(length); + this.buffer.slice(0, length).copy(value); + this.buffer.copyWithin(0, length, length + this.offset - length); + this.offset -= length; + return value; + } +} +receivebuffer.ReceiveBuffer = ReceiveBuffer; + +(function (exports) { + var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.SocksClientError = exports.SocksClient = void 0; + const events_1 = require$$0$3; + const net = require$$0$4; + const smart_buffer_1 = smartbuffer; + const constants_1 = constants$3; + const helpers_1 = helpers$2; + const receivebuffer_1 = receivebuffer; + const util_1 = util$1; + Object.defineProperty(exports, "SocksClientError", { enumerable: true, get: function () { return util_1.SocksClientError; } }); + const ip_address_1 = ipAddress; + class SocksClient extends events_1.EventEmitter { + constructor(options) { + super(); + this.options = Object.assign({}, options); + // Validate SocksClientOptions + (0, helpers_1.validateSocksClientOptions)(options); + // Default state + this.setState(constants_1.SocksClientState.Created); + } + /** + * Creates a new SOCKS connection. + * + * Note: Supports callbacks and promises. Only supports the connect command. + * @param options { SocksClientOptions } Options. + * @param callback { Function } An optional callback function. + * @returns { Promise } + */ + static createConnection(options, callback) { + return new Promise((resolve, reject) => { + // Validate SocksClientOptions + try { + (0, helpers_1.validateSocksClientOptions)(options, ['connect']); + } + catch (err) { + if (typeof callback === 'function') { + callback(err); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return resolve(err); // Resolves pending promise (prevents memory leaks). + } + else { + return reject(err); + } + } + const client = new SocksClient(options); + client.connect(options.existing_socket); + client.once('established', (info) => { + client.removeAllListeners(); + if (typeof callback === 'function') { + callback(null, info); + resolve(info); // Resolves pending promise (prevents memory leaks). + } + else { + resolve(info); + } + }); + // Error occurred, failed to establish connection. + client.once('error', (err) => { + client.removeAllListeners(); + if (typeof callback === 'function') { + callback(err); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + resolve(err); // Resolves pending promise (prevents memory leaks). + } + else { + reject(err); + } + }); + }); + } + /** + * Creates a new SOCKS connection chain to a destination host through 2 or more SOCKS proxies. + * + * Note: Supports callbacks and promises. Only supports the connect method. + * Note: Implemented via createConnection() factory function. + * @param options { SocksClientChainOptions } Options + * @param callback { Function } An optional callback function. + * @returns { Promise } + */ + static createConnectionChain(options, callback) { + // eslint-disable-next-line no-async-promise-executor + return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { + // Validate SocksClientChainOptions + try { + (0, helpers_1.validateSocksClientChainOptions)(options); + } + catch (err) { + if (typeof callback === 'function') { + callback(err); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return resolve(err); // Resolves pending promise (prevents memory leaks). + } + else { + return reject(err); + } + } + // Shuffle proxies + if (options.randomizeChain) { + (0, util_1.shuffleArray)(options.proxies); + } + try { + let sock; + for (let i = 0; i < options.proxies.length; i++) { + const nextProxy = options.proxies[i]; + // If we've reached the last proxy in the chain, the destination is the actual destination, otherwise it's the next proxy. + const nextDestination = i === options.proxies.length - 1 + ? options.destination + : { + host: options.proxies[i + 1].host || + options.proxies[i + 1].ipaddress, + port: options.proxies[i + 1].port, + }; + // Creates the next connection in the chain. + const result = yield SocksClient.createConnection({ + command: 'connect', + proxy: nextProxy, + destination: nextDestination, + existing_socket: sock, + }); + // If sock is undefined, assign it here. + sock = sock || result.socket; + } + if (typeof callback === 'function') { + callback(null, { socket: sock }); + resolve({ socket: sock }); // Resolves pending promise (prevents memory leaks). + } + else { + resolve({ socket: sock }); + } + } + catch (err) { + if (typeof callback === 'function') { + callback(err); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + resolve(err); // Resolves pending promise (prevents memory leaks). + } + else { + reject(err); + } + } + })); + } + /** + * Creates a SOCKS UDP Frame. + * @param options + */ + static createUDPFrame(options) { + const buff = new smart_buffer_1.SmartBuffer(); + buff.writeUInt16BE(0); + buff.writeUInt8(options.frameNumber || 0); + // IPv4/IPv6/Hostname + if (net.isIPv4(options.remoteHost.host)) { + buff.writeUInt8(constants_1.Socks5HostType.IPv4); + buff.writeUInt32BE((0, helpers_1.ipv4ToInt32)(options.remoteHost.host)); + } + else if (net.isIPv6(options.remoteHost.host)) { + buff.writeUInt8(constants_1.Socks5HostType.IPv6); + buff.writeBuffer((0, helpers_1.ipToBuffer)(options.remoteHost.host)); + } + else { + buff.writeUInt8(constants_1.Socks5HostType.Hostname); + buff.writeUInt8(Buffer.byteLength(options.remoteHost.host)); + buff.writeString(options.remoteHost.host); + } + // Port + buff.writeUInt16BE(options.remoteHost.port); + // Data + buff.writeBuffer(options.data); + return buff.toBuffer(); + } + /** + * Parses a SOCKS UDP frame. + * @param data + */ + static parseUDPFrame(data) { + const buff = smart_buffer_1.SmartBuffer.fromBuffer(data); + buff.readOffset = 2; + const frameNumber = buff.readUInt8(); + const hostType = buff.readUInt8(); + let remoteHost; + if (hostType === constants_1.Socks5HostType.IPv4) { + remoteHost = (0, helpers_1.int32ToIpv4)(buff.readUInt32BE()); + } + else if (hostType === constants_1.Socks5HostType.IPv6) { + remoteHost = ip_address_1.Address6.fromByteArray(Array.from(buff.readBuffer(16))).canonicalForm(); + } + else { + remoteHost = buff.readString(buff.readUInt8()); + } + const remotePort = buff.readUInt16BE(); + return { + frameNumber, + remoteHost: { + host: remoteHost, + port: remotePort, + }, + data: buff.readBuffer(), + }; + } + /** + * Internal state setter. If the SocksClient is in an error state, it cannot be changed to a non error state. + */ + setState(newState) { + if (this.state !== constants_1.SocksClientState.Error) { + this.state = newState; + } + } + /** + * Starts the connection establishment to the proxy and destination. + * @param existingSocket Connected socket to use instead of creating a new one (internal use). + */ + connect(existingSocket) { + this.onDataReceived = (data) => this.onDataReceivedHandler(data); + this.onClose = () => this.onCloseHandler(); + this.onError = (err) => this.onErrorHandler(err); + this.onConnect = () => this.onConnectHandler(); + // Start timeout timer (defaults to 30 seconds) + const timer = setTimeout(() => this.onEstablishedTimeout(), this.options.timeout || constants_1.DEFAULT_TIMEOUT); + // check whether unref is available as it differs from browser to NodeJS (#33) + if (timer.unref && typeof timer.unref === 'function') { + timer.unref(); + } + // If an existing socket is provided, use it to negotiate SOCKS handshake. Otherwise create a new Socket. + if (existingSocket) { + this.socket = existingSocket; + } + else { + this.socket = new net.Socket(); + } + // Attach Socket error handlers. + this.socket.once('close', this.onClose); + this.socket.once('error', this.onError); + this.socket.once('connect', this.onConnect); + this.socket.on('data', this.onDataReceived); + this.setState(constants_1.SocksClientState.Connecting); + this.receiveBuffer = new receivebuffer_1.ReceiveBuffer(); + if (existingSocket) { + this.socket.emit('connect'); + } + else { + this.socket.connect(this.getSocketOptions()); + if (this.options.set_tcp_nodelay !== undefined && + this.options.set_tcp_nodelay !== null) { + this.socket.setNoDelay(!!this.options.set_tcp_nodelay); + } + } + // Listen for established event so we can re-emit any excess data received during handshakes. + this.prependOnceListener('established', (info) => { + setImmediate(() => { + if (this.receiveBuffer.length > 0) { + const excessData = this.receiveBuffer.get(this.receiveBuffer.length); + info.socket.emit('data', excessData); + } + info.socket.resume(); + }); + }); + } + // Socket options (defaults host/port to options.proxy.host/options.proxy.port) + getSocketOptions() { + return Object.assign(Object.assign({}, this.options.socket_options), { host: this.options.proxy.host || this.options.proxy.ipaddress, port: this.options.proxy.port }); + } + /** + * Handles internal Socks timeout callback. + * Note: If the Socks client is not BoundWaitingForConnection or Established, the connection will be closed. + */ + onEstablishedTimeout() { + if (this.state !== constants_1.SocksClientState.Established && + this.state !== constants_1.SocksClientState.BoundWaitingForConnection) { + this.closeSocket(constants_1.ERRORS.ProxyConnectionTimedOut); + } + } + /** + * Handles Socket connect event. + */ + onConnectHandler() { + this.setState(constants_1.SocksClientState.Connected); + // Send initial handshake. + if (this.options.proxy.type === 4) { + this.sendSocks4InitialHandshake(); + } + else { + this.sendSocks5InitialHandshake(); + } + this.setState(constants_1.SocksClientState.SentInitialHandshake); + } + /** + * Handles Socket data event. + * @param data + */ + onDataReceivedHandler(data) { + /* + All received data is appended to a ReceiveBuffer. + This makes sure that all the data we need is received before we attempt to process it. + */ + this.receiveBuffer.append(data); + // Process data that we have. + this.processData(); + } + /** + * Handles processing of the data we have received. + */ + processData() { + // If we have enough data to process the next step in the SOCKS handshake, proceed. + while (this.state !== constants_1.SocksClientState.Established && + this.state !== constants_1.SocksClientState.Error && + this.receiveBuffer.length >= this.nextRequiredPacketBufferSize) { + // Sent initial handshake, waiting for response. + if (this.state === constants_1.SocksClientState.SentInitialHandshake) { + if (this.options.proxy.type === 4) { + // Socks v4 only has one handshake response. + this.handleSocks4FinalHandshakeResponse(); + } + else { + // Socks v5 has two handshakes, handle initial one here. + this.handleInitialSocks5HandshakeResponse(); + } + // Sent auth request for Socks v5, waiting for response. + } + else if (this.state === constants_1.SocksClientState.SentAuthentication) { + this.handleInitialSocks5AuthenticationHandshakeResponse(); + // Sent final Socks v5 handshake, waiting for final response. + } + else if (this.state === constants_1.SocksClientState.SentFinalHandshake) { + this.handleSocks5FinalHandshakeResponse(); + // Socks BIND established. Waiting for remote connection via proxy. + } + else if (this.state === constants_1.SocksClientState.BoundWaitingForConnection) { + if (this.options.proxy.type === 4) { + this.handleSocks4IncomingConnectionResponse(); + } + else { + this.handleSocks5IncomingConnectionResponse(); + } + } + else { + this.closeSocket(constants_1.ERRORS.InternalError); + break; + } + } + } + /** + * Handles Socket close event. + * @param had_error + */ + onCloseHandler() { + this.closeSocket(constants_1.ERRORS.SocketClosed); + } + /** + * Handles Socket error event. + * @param err + */ + onErrorHandler(err) { + this.closeSocket(err.message); + } + /** + * Removes internal event listeners on the underlying Socket. + */ + removeInternalSocketHandlers() { + // Pauses data flow of the socket (this is internally resumed after 'established' is emitted) + this.socket.pause(); + this.socket.removeListener('data', this.onDataReceived); + this.socket.removeListener('close', this.onClose); + this.socket.removeListener('error', this.onError); + this.socket.removeListener('connect', this.onConnect); + } + /** + * Closes and destroys the underlying Socket. Emits an error event. + * @param err { String } An error string to include in error event. + */ + closeSocket(err) { + // Make sure only one 'error' event is fired for the lifetime of this SocksClient instance. + if (this.state !== constants_1.SocksClientState.Error) { + // Set internal state to Error. + this.setState(constants_1.SocksClientState.Error); + // Destroy Socket + this.socket.destroy(); + // Remove internal listeners + this.removeInternalSocketHandlers(); + // Fire 'error' event. + this.emit('error', new util_1.SocksClientError(err, this.options)); + } + } + /** + * Sends initial Socks v4 handshake request. + */ + sendSocks4InitialHandshake() { + const userId = this.options.proxy.userId || ''; + const buff = new smart_buffer_1.SmartBuffer(); + buff.writeUInt8(0x04); + buff.writeUInt8(constants_1.SocksCommand[this.options.command]); + buff.writeUInt16BE(this.options.destination.port); + // Socks 4 (IPv4) + if (net.isIPv4(this.options.destination.host)) { + buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host)); + buff.writeStringNT(userId); + // Socks 4a (hostname) + } + else { + buff.writeUInt8(0x00); + buff.writeUInt8(0x00); + buff.writeUInt8(0x00); + buff.writeUInt8(0x01); + buff.writeStringNT(userId); + buff.writeStringNT(this.options.destination.host); + } + this.nextRequiredPacketBufferSize = + constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks4Response; + this.socket.write(buff.toBuffer()); + } + /** + * Handles Socks v4 handshake response. + * @param data + */ + handleSocks4FinalHandshakeResponse() { + const data = this.receiveBuffer.get(8); + if (data[1] !== constants_1.Socks4Response.Granted) { + this.closeSocket(`${constants_1.ERRORS.Socks4ProxyRejectedConnection} - (${constants_1.Socks4Response[data[1]]})`); + } + else { + // Bind response + if (constants_1.SocksCommand[this.options.command] === constants_1.SocksCommand.bind) { + const buff = smart_buffer_1.SmartBuffer.fromBuffer(data); + buff.readOffset = 2; + const remoteHost = { + port: buff.readUInt16BE(), + host: (0, helpers_1.int32ToIpv4)(buff.readUInt32BE()), + }; + // If host is 0.0.0.0, set to proxy host. + if (remoteHost.host === '0.0.0.0') { + remoteHost.host = this.options.proxy.ipaddress; + } + this.setState(constants_1.SocksClientState.BoundWaitingForConnection); + this.emit('bound', { remoteHost, socket: this.socket }); + // Connect response + } + else { + this.setState(constants_1.SocksClientState.Established); + this.removeInternalSocketHandlers(); + this.emit('established', { socket: this.socket }); + } + } + } + /** + * Handles Socks v4 incoming connection request (BIND) + * @param data + */ + handleSocks4IncomingConnectionResponse() { + const data = this.receiveBuffer.get(8); + if (data[1] !== constants_1.Socks4Response.Granted) { + this.closeSocket(`${constants_1.ERRORS.Socks4ProxyRejectedIncomingBoundConnection} - (${constants_1.Socks4Response[data[1]]})`); + } + else { + const buff = smart_buffer_1.SmartBuffer.fromBuffer(data); + buff.readOffset = 2; + const remoteHost = { + port: buff.readUInt16BE(), + host: (0, helpers_1.int32ToIpv4)(buff.readUInt32BE()), + }; + this.setState(constants_1.SocksClientState.Established); + this.removeInternalSocketHandlers(); + this.emit('established', { remoteHost, socket: this.socket }); + } + } + /** + * Sends initial Socks v5 handshake request. + */ + sendSocks5InitialHandshake() { + const buff = new smart_buffer_1.SmartBuffer(); + // By default we always support no auth. + const supportedAuthMethods = [constants_1.Socks5Auth.NoAuth]; + // We should only tell the proxy we support user/pass auth if auth info is actually provided. + // Note: As of Tor v0.3.5.7+, if user/pass auth is an option from the client, by default it will always take priority. + if (this.options.proxy.userId || this.options.proxy.password) { + supportedAuthMethods.push(constants_1.Socks5Auth.UserPass); + } + // Custom auth method? + if (this.options.proxy.custom_auth_method !== undefined) { + supportedAuthMethods.push(this.options.proxy.custom_auth_method); + } + // Build handshake packet + buff.writeUInt8(0x05); + buff.writeUInt8(supportedAuthMethods.length); + for (const authMethod of supportedAuthMethods) { + buff.writeUInt8(authMethod); + } + this.nextRequiredPacketBufferSize = + constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5InitialHandshakeResponse; + this.socket.write(buff.toBuffer()); + this.setState(constants_1.SocksClientState.SentInitialHandshake); + } + /** + * Handles initial Socks v5 handshake response. + * @param data + */ + handleInitialSocks5HandshakeResponse() { + const data = this.receiveBuffer.get(2); + if (data[0] !== 0x05) { + this.closeSocket(constants_1.ERRORS.InvalidSocks5IntiailHandshakeSocksVersion); + } + else if (data[1] === constants_1.SOCKS5_NO_ACCEPTABLE_AUTH) { + this.closeSocket(constants_1.ERRORS.InvalidSocks5InitialHandshakeNoAcceptedAuthType); + } + else { + // If selected Socks v5 auth method is no auth, send final handshake request. + if (data[1] === constants_1.Socks5Auth.NoAuth) { + this.socks5ChosenAuthType = constants_1.Socks5Auth.NoAuth; + this.sendSocks5CommandRequest(); + // If selected Socks v5 auth method is user/password, send auth handshake. + } + else if (data[1] === constants_1.Socks5Auth.UserPass) { + this.socks5ChosenAuthType = constants_1.Socks5Auth.UserPass; + this.sendSocks5UserPassAuthentication(); + // If selected Socks v5 auth method is the custom_auth_method, send custom handshake. + } + else if (data[1] === this.options.proxy.custom_auth_method) { + this.socks5ChosenAuthType = this.options.proxy.custom_auth_method; + this.sendSocks5CustomAuthentication(); + } + else { + this.closeSocket(constants_1.ERRORS.InvalidSocks5InitialHandshakeUnknownAuthType); + } + } + } + /** + * Sends Socks v5 user & password auth handshake. + * + * Note: No auth and user/pass are currently supported. + */ + sendSocks5UserPassAuthentication() { + const userId = this.options.proxy.userId || ''; + const password = this.options.proxy.password || ''; + const buff = new smart_buffer_1.SmartBuffer(); + buff.writeUInt8(0x01); + buff.writeUInt8(Buffer.byteLength(userId)); + buff.writeString(userId); + buff.writeUInt8(Buffer.byteLength(password)); + buff.writeString(password); + this.nextRequiredPacketBufferSize = + constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5UserPassAuthenticationResponse; + this.socket.write(buff.toBuffer()); + this.setState(constants_1.SocksClientState.SentAuthentication); + } + sendSocks5CustomAuthentication() { + return __awaiter(this, void 0, void 0, function* () { + this.nextRequiredPacketBufferSize = + this.options.proxy.custom_auth_response_size; + this.socket.write(yield this.options.proxy.custom_auth_request_handler()); + this.setState(constants_1.SocksClientState.SentAuthentication); + }); + } + handleSocks5CustomAuthHandshakeResponse(data) { + return __awaiter(this, void 0, void 0, function* () { + return yield this.options.proxy.custom_auth_response_handler(data); + }); + } + handleSocks5AuthenticationNoAuthHandshakeResponse(data) { + return __awaiter(this, void 0, void 0, function* () { + return data[1] === 0x00; + }); + } + handleSocks5AuthenticationUserPassHandshakeResponse(data) { + return __awaiter(this, void 0, void 0, function* () { + return data[1] === 0x00; + }); + } + /** + * Handles Socks v5 auth handshake response. + * @param data + */ + handleInitialSocks5AuthenticationHandshakeResponse() { + return __awaiter(this, void 0, void 0, function* () { + this.setState(constants_1.SocksClientState.ReceivedAuthenticationResponse); + let authResult = false; + if (this.socks5ChosenAuthType === constants_1.Socks5Auth.NoAuth) { + authResult = yield this.handleSocks5AuthenticationNoAuthHandshakeResponse(this.receiveBuffer.get(2)); + } + else if (this.socks5ChosenAuthType === constants_1.Socks5Auth.UserPass) { + authResult = + yield this.handleSocks5AuthenticationUserPassHandshakeResponse(this.receiveBuffer.get(2)); + } + else if (this.socks5ChosenAuthType === this.options.proxy.custom_auth_method) { + authResult = yield this.handleSocks5CustomAuthHandshakeResponse(this.receiveBuffer.get(this.options.proxy.custom_auth_response_size)); + } + if (!authResult) { + this.closeSocket(constants_1.ERRORS.Socks5AuthenticationFailed); + } + else { + this.sendSocks5CommandRequest(); + } + }); + } + /** + * Sends Socks v5 final handshake request. + */ + sendSocks5CommandRequest() { + const buff = new smart_buffer_1.SmartBuffer(); + buff.writeUInt8(0x05); + buff.writeUInt8(constants_1.SocksCommand[this.options.command]); + buff.writeUInt8(0x00); + // ipv4, ipv6, domain? + if (net.isIPv4(this.options.destination.host)) { + buff.writeUInt8(constants_1.Socks5HostType.IPv4); + buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host)); + } + else if (net.isIPv6(this.options.destination.host)) { + buff.writeUInt8(constants_1.Socks5HostType.IPv6); + buff.writeBuffer((0, helpers_1.ipToBuffer)(this.options.destination.host)); + } + else { + buff.writeUInt8(constants_1.Socks5HostType.Hostname); + buff.writeUInt8(this.options.destination.host.length); + buff.writeString(this.options.destination.host); + } + buff.writeUInt16BE(this.options.destination.port); + this.nextRequiredPacketBufferSize = + constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader; + this.socket.write(buff.toBuffer()); + this.setState(constants_1.SocksClientState.SentFinalHandshake); + } + /** + * Handles Socks v5 final handshake response. + * @param data + */ + handleSocks5FinalHandshakeResponse() { + // Peek at available data (we need at least 5 bytes to get the hostname length) + const header = this.receiveBuffer.peek(5); + if (header[0] !== 0x05 || header[1] !== constants_1.Socks5Response.Granted) { + this.closeSocket(`${constants_1.ERRORS.InvalidSocks5FinalHandshakeRejected} - ${constants_1.Socks5Response[header[1]]}`); + } + else { + // Read address type + const addressType = header[3]; + let remoteHost; + let buff; + // IPv4 + if (addressType === constants_1.Socks5HostType.IPv4) { + // Check if data is available. + const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4; + if (this.receiveBuffer.length < dataNeeded) { + this.nextRequiredPacketBufferSize = dataNeeded; + return; + } + buff = smart_buffer_1.SmartBuffer.fromBuffer(this.receiveBuffer.get(dataNeeded).slice(4)); + remoteHost = { + host: (0, helpers_1.int32ToIpv4)(buff.readUInt32BE()), + port: buff.readUInt16BE(), + }; + // If given host is 0.0.0.0, assume remote proxy ip instead. + if (remoteHost.host === '0.0.0.0') { + remoteHost.host = this.options.proxy.ipaddress; + } + // Hostname + } + else if (addressType === constants_1.Socks5HostType.Hostname) { + const hostLength = header[4]; + const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(hostLength); // header + host length + host + port + // Check if data is available. + if (this.receiveBuffer.length < dataNeeded) { + this.nextRequiredPacketBufferSize = dataNeeded; + return; + } + buff = smart_buffer_1.SmartBuffer.fromBuffer(this.receiveBuffer.get(dataNeeded).slice(5)); + remoteHost = { + host: buff.readString(hostLength), + port: buff.readUInt16BE(), + }; + // IPv6 + } + else if (addressType === constants_1.Socks5HostType.IPv6) { + // Check if data is available. + const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6; + if (this.receiveBuffer.length < dataNeeded) { + this.nextRequiredPacketBufferSize = dataNeeded; + return; + } + buff = smart_buffer_1.SmartBuffer.fromBuffer(this.receiveBuffer.get(dataNeeded).slice(4)); + remoteHost = { + host: ip_address_1.Address6.fromByteArray(Array.from(buff.readBuffer(16))).canonicalForm(), + port: buff.readUInt16BE(), + }; + } + // We have everything we need + this.setState(constants_1.SocksClientState.ReceivedFinalResponse); + // If using CONNECT, the client is now in the established state. + if (constants_1.SocksCommand[this.options.command] === constants_1.SocksCommand.connect) { + this.setState(constants_1.SocksClientState.Established); + this.removeInternalSocketHandlers(); + this.emit('established', { remoteHost, socket: this.socket }); + } + else if (constants_1.SocksCommand[this.options.command] === constants_1.SocksCommand.bind) { + /* If using BIND, the Socks client is now in BoundWaitingForConnection state. + This means that the remote proxy server is waiting for a remote connection to the bound port. */ + this.setState(constants_1.SocksClientState.BoundWaitingForConnection); + this.nextRequiredPacketBufferSize = + constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader; + this.emit('bound', { remoteHost, socket: this.socket }); + /* + If using Associate, the Socks client is now Established. And the proxy server is now accepting UDP packets at the + given bound port. This initial Socks TCP connection must remain open for the UDP relay to continue to work. + */ + } + else if (constants_1.SocksCommand[this.options.command] === constants_1.SocksCommand.associate) { + this.setState(constants_1.SocksClientState.Established); + this.removeInternalSocketHandlers(); + this.emit('established', { + remoteHost, + socket: this.socket, + }); + } + } + } + /** + * Handles Socks v5 incoming connection request (BIND). + */ + handleSocks5IncomingConnectionResponse() { + // Peek at available data (we need at least 5 bytes to get the hostname length) + const header = this.receiveBuffer.peek(5); + if (header[0] !== 0x05 || header[1] !== constants_1.Socks5Response.Granted) { + this.closeSocket(`${constants_1.ERRORS.Socks5ProxyRejectedIncomingBoundConnection} - ${constants_1.Socks5Response[header[1]]}`); + } + else { + // Read address type + const addressType = header[3]; + let remoteHost; + let buff; + // IPv4 + if (addressType === constants_1.Socks5HostType.IPv4) { + // Check if data is available. + const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4; + if (this.receiveBuffer.length < dataNeeded) { + this.nextRequiredPacketBufferSize = dataNeeded; + return; + } + buff = smart_buffer_1.SmartBuffer.fromBuffer(this.receiveBuffer.get(dataNeeded).slice(4)); + remoteHost = { + host: (0, helpers_1.int32ToIpv4)(buff.readUInt32BE()), + port: buff.readUInt16BE(), + }; + // If given host is 0.0.0.0, assume remote proxy ip instead. + if (remoteHost.host === '0.0.0.0') { + remoteHost.host = this.options.proxy.ipaddress; + } + // Hostname + } + else if (addressType === constants_1.Socks5HostType.Hostname) { + const hostLength = header[4]; + const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(hostLength); // header + host length + port + // Check if data is available. + if (this.receiveBuffer.length < dataNeeded) { + this.nextRequiredPacketBufferSize = dataNeeded; + return; + } + buff = smart_buffer_1.SmartBuffer.fromBuffer(this.receiveBuffer.get(dataNeeded).slice(5)); + remoteHost = { + host: buff.readString(hostLength), + port: buff.readUInt16BE(), + }; + // IPv6 + } + else if (addressType === constants_1.Socks5HostType.IPv6) { + // Check if data is available. + const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6; + if (this.receiveBuffer.length < dataNeeded) { + this.nextRequiredPacketBufferSize = dataNeeded; + return; + } + buff = smart_buffer_1.SmartBuffer.fromBuffer(this.receiveBuffer.get(dataNeeded).slice(4)); + remoteHost = { + host: ip_address_1.Address6.fromByteArray(Array.from(buff.readBuffer(16))).canonicalForm(), + port: buff.readUInt16BE(), + }; + } + this.setState(constants_1.SocksClientState.Established); + this.removeInternalSocketHandlers(); + this.emit('established', { remoteHost, socket: this.socket }); + } + } + get socksClientOptions() { + return Object.assign({}, this.options); + } + } + exports.SocksClient = SocksClient; + +} (socksclient)); + +(function (exports) { + var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); + }) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; + })); + var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + __exportStar(socksclient, exports); + +} (build$1)); + +var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var __importDefault$2 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(dist, "__esModule", { value: true }); +var SocksProxyAgent_1 = dist.SocksProxyAgent = void 0; +const socks_1 = build$1; +const agent_base_1 = dist$2; +const debug_1 = __importDefault$2(srcExports); +const dns = __importStar(require$$3$1); +const net = __importStar(require$$0$4); +const tls = __importStar(require$$1$3); +const url_1 = Url; +const debug = (0, debug_1.default)('socks-proxy-agent'); +function parseSocksURL(url) { + let lookup = false; + let type = 5; + const host = url.hostname; + // From RFC 1928, Section 3: https://tools.ietf.org/html/rfc1928#section-3 + // "The SOCKS service is conventionally located on TCP port 1080" + const port = parseInt(url.port, 10) || 1080; + // figure out if we want socks v4 or v5, based on the "protocol" used. + // Defaults to 5. + switch (url.protocol.replace(':', '')) { + case 'socks4': + lookup = true; + type = 4; + break; + // pass through + case 'socks4a': + type = 4; + break; + case 'socks5': + lookup = true; + type = 5; + break; + // pass through + case 'socks': // no version specified, default to 5h + type = 5; + break; + case 'socks5h': + type = 5; + break; + default: + throw new TypeError(`A "socks" protocol must be specified! Got: ${String(url.protocol)}`); + } + const proxy = { + host, + port, + type, + }; + if (url.username) { + Object.defineProperty(proxy, 'userId', { + value: decodeURIComponent(url.username), + enumerable: false, + }); + } + if (url.password != null) { + Object.defineProperty(proxy, 'password', { + value: decodeURIComponent(url.password), + enumerable: false, + }); + } + return { lookup, proxy }; +} +class SocksProxyAgent extends agent_base_1.Agent { + constructor(uri, opts) { + super(opts); + const url = typeof uri === 'string' ? new url_1.URL(uri) : uri; + const { proxy, lookup } = parseSocksURL(url); + this.shouldLookup = lookup; + this.proxy = proxy; + this.timeout = opts?.timeout ?? null; + this.socketOptions = opts?.socketOptions ?? null; + } + /** + * Initiates a SOCKS connection to the specified SOCKS proxy server, + * which in turn connects to the specified remote host and port. + */ + async connect(req, opts) { + const { shouldLookup, proxy, timeout } = this; + if (!opts.host) { + throw new Error('No `host` defined!'); + } + let { host } = opts; + const { port, lookup: lookupFn = dns.lookup } = opts; + if (shouldLookup) { + // Client-side DNS resolution for "4" and "5" socks proxy versions. + host = await new Promise((resolve, reject) => { + // Use the request's custom lookup, if one was configured: + lookupFn(host, {}, (err, res) => { + if (err) { + reject(err); + } + else { + resolve(res); + } + }); + }); + } + const socksOpts = { + proxy, + destination: { + host, + port: typeof port === 'number' ? port : parseInt(port, 10), + }, + command: 'connect', + timeout: timeout ?? undefined, + // @ts-expect-error the type supplied by socks for socket_options is wider + // than necessary since socks will always override the host and port + socket_options: this.socketOptions ?? undefined, + }; + const cleanup = (tlsSocket) => { + req.destroy(); + socket.destroy(); + if (tlsSocket) + tlsSocket.destroy(); + }; + debug('Creating socks proxy connection: %o', socksOpts); + const { socket } = await socks_1.SocksClient.createConnection(socksOpts); + debug('Successfully created socks proxy connection'); + if (timeout !== null) { + socket.setTimeout(timeout); + socket.on('timeout', () => cleanup()); + } + if (opts.secureEndpoint) { + // The proxy is connecting to a TLS server, so upgrade + // this socket connection to a TLS connection. + debug('Upgrading socket connection to TLS'); + const servername = opts.servername || opts.host; + const tlsSocket = tls.connect({ + ...omit(opts, 'host', 'path', 'port'), + socket, + servername: net.isIP(servername) ? undefined : servername, + }); + tlsSocket.once('error', (error) => { + debug('Socket TLS error', error.message); + cleanup(tlsSocket); + }); + return tlsSocket; + } + return socket; + } +} +SocksProxyAgent.protocols = [ + 'socks', + 'socks4', + 'socks4a', + 'socks5', + 'socks5h', +]; +SocksProxyAgent_1 = dist.SocksProxyAgent = SocksProxyAgent; +function omit(obj, ...keys) { + const ret = {}; + let key; + for (key in obj) { + if (!keys.includes(key)) { + ret[key] = obj[key]; + } + } + return ret; +} + +var bn = {exports: {}}; + +bn.exports; + +(function (module) { + (function (module, exports) { + + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } + + // Could use `inherits` module, but don't want to move from single file + // architecture yet. + function inherits (ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + + // BN + + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; + } + + this.negative = 0; + this.words = null; + this.length = 0; + + // Reduction context + this.red = null; + + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; + } + + this._init(number || 0, base || 10, endian || 'be'); + } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; + } + + BN.BN = BN; + BN.wordSize = 26; + + var Buffer; + try { + if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') { + Buffer = window.Buffer; + } else { + Buffer = require('buffer').Buffer; + } + } catch (e) { + } + + BN.isBN = function isBN (num) { + if (num instanceof BN) { + return true; + } + + return num !== null && typeof num === 'object' && + num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; + }; + + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; + }; + + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } + + if (typeof number === 'object') { + return this._initArray(number, base, endian); + } + + if (base === 'hex') { + base = 16; + } + assert(base === (base | 0) && base >= 2 && base <= 36); + + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + this.negative = 1; + } + + if (start < number.length) { + if (base === 16) { + this._parseHex(number, start, endian); + } else { + this._parseBase(number, base, start); + if (endian === 'le') { + this._initArray(this.toArray(), base, endian); + } + } + } + }; + + BN.prototype._initNumber = function _initNumber (number, base, endian) { + if (number < 0) { + this.negative = 1; + number = -number; + } + if (number < 0x4000000) { + this.words = [number & 0x3ffffff]; + this.length = 1; + } else if (number < 0x10000000000000) { + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff + ]; + this.length = 2; + } else { + assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff, + 1 + ]; + this.length = 3; + } + + if (endian !== 'le') return; + + // Reverse the bytes + this._initArray(this.toArray(), base, endian); + }; + + BN.prototype._initArray = function _initArray (number, base, endian) { + // Perhaps a Uint8Array + assert(typeof number.length === 'number'); + if (number.length <= 0) { + this.words = [0]; + this.length = 1; + return this; + } + + this.length = Math.ceil(number.length / 3); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + var j, w; + var off = 0; + if (endian === 'be') { + for (i = number.length - 1, j = 0; i >= 0; i -= 3) { + w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } else if (endian === 'le') { + for (i = 0, j = 0; i < number.length; i += 3) { + w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } + return this._strip(); + }; + + function parseHex4Bits (string, index) { + var c = string.charCodeAt(index); + // '0' - '9' + if (c >= 48 && c <= 57) { + return c - 48; + // 'A' - 'F' + } else if (c >= 65 && c <= 70) { + return c - 55; + // 'a' - 'f' + } else if (c >= 97 && c <= 102) { + return c - 87; + } else { + assert(false, 'Invalid character in ' + string); + } + } + + function parseHexByte (string, lowerBound, index) { + var r = parseHex4Bits(string, index); + if (index - 1 >= lowerBound) { + r |= parseHex4Bits(string, index - 1) << 4; + } + return r; + } + + BN.prototype._parseHex = function _parseHex (number, start, endian) { + // Create possibly bigger array to ensure that it fits the number + this.length = Math.ceil((number.length - start) / 6); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + // 24-bits chunks + var off = 0; + var j = 0; + + var w; + if (endian === 'be') { + for (i = number.length - 1; i >= start; i -= 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } else { + var parseLength = number.length - start; + for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) { + w = parseHexByte(number, start, i) << off; + this.words[j] |= w & 0x3ffffff; + if (off >= 18) { + off -= 18; + j += 1; + this.words[j] |= w >>> 26; + } else { + off += 8; + } + } + } + + this._strip(); + }; + + function parseBase (str, start, end, mul) { + var r = 0; + var b = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; + + r *= mul; + + // 'a' + if (c >= 49) { + b = c - 49 + 0xa; + + // 'A' + } else if (c >= 17) { + b = c - 17 + 0xa; + + // '0' - '9' + } else { + b = c; + } + assert(c >= 0 && b < mul, 'Invalid character'); + r += b; + } + return r; + } + + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [0]; + this.length = 1; + + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; + } + limbLen--; + limbPow = (limbPow / base) | 0; + + var total = number.length - start; + var mod = total % limbLen; + var end = Math.min(total, total - mod) + start; + + var word = 0; + for (var i = start; i < end; i += limbLen) { + word = parseBase(number, i, i + limbLen, base); + + this.imuln(limbPow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); + + for (i = 0; i < mod; i++) { + pow *= base; + } + + this.imuln(pow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + + this._strip(); + }; + + BN.prototype.copy = function copy (dest) { + dest.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + dest.words[i] = this.words[i]; + } + dest.length = this.length; + dest.negative = this.negative; + dest.red = this.red; + }; + + function move (dest, src) { + dest.words = src.words; + dest.length = src.length; + dest.negative = src.negative; + dest.red = src.red; + } + + BN.prototype._move = function _move (dest) { + move(dest, this); + }; + + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; + }; + + BN.prototype._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; + }; + + // Remove leading `0` from `this` + BN.prototype._strip = function strip () { + while (this.length > 1 && this.words[this.length - 1] === 0) { + this.length--; + } + return this._normSign(); + }; + + BN.prototype._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; + } + return this; + }; + + // Check Symbol.for because not everywhere where Symbol defined + // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility + if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') { + try { + BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect; + } catch (e) { + BN.prototype.inspect = inspect; + } + } else { + BN.prototype.inspect = inspect; + } + + function inspect () { + return (this.red ? ''; + } + + /* + + var zeros = []; + var groupSizes = []; + var groupBases = []; + + var s = ''; + var i = -1; + while (++i < BN.wordSize) { + zeros[i] = s; + s += '0'; + } + groupSizes[0] = 0; + groupSizes[1] = 0; + groupBases[0] = 0; + groupBases[1] = 0; + var base = 2 - 1; + while (++base < 36 + 1) { + var groupSize = 0; + var groupBase = 1; + while (groupBase < (1 << BN.wordSize) / base) { + groupBase *= base; + groupSize += 1; + } + groupSizes[base] = groupSize; + groupBases[base] = groupBase; + } + + */ + + var zeros = [ + '', + '0', + '00', + '000', + '0000', + '00000', + '000000', + '0000000', + '00000000', + '000000000', + '0000000000', + '00000000000', + '000000000000', + '0000000000000', + '00000000000000', + '000000000000000', + '0000000000000000', + '00000000000000000', + '000000000000000000', + '0000000000000000000', + '00000000000000000000', + '000000000000000000000', + '0000000000000000000000', + '00000000000000000000000', + '000000000000000000000000', + '0000000000000000000000000' + ]; + + var groupSizes = [ + 0, 0, + 25, 16, 12, 11, 10, 9, 8, + 8, 7, 7, 7, 7, 6, 6, + 6, 6, 6, 6, 6, 5, 5, + 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5 + ]; + + var groupBases = [ + 0, 0, + 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, + 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, + 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, + 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, + 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 + ]; + + BN.prototype.toString = function toString (base, padding) { + base = base || 10; + padding = padding | 0 || 1; + + var out; + if (base === 16 || base === 'hex') { + out = ''; + var off = 0; + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = this.words[i]; + var word = (((w << off) | carry) & 0xffffff).toString(16); + carry = (w >>> (24 - off)) & 0xffffff; + off += 2; + if (off >= 26) { + off -= 26; + i--; + } + if (carry !== 0 || i !== this.length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + if (base === (base | 0) && base >= 2 && base <= 36) { + // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); + var groupSize = groupSizes[base]; + // var groupBase = Math.pow(base, groupSize); + var groupBase = groupBases[base]; + out = ''; + var c = this.clone(); + c.negative = 0; + while (!c.isZero()) { + var r = c.modrn(groupBase).toString(base); + c = c.idivn(groupBase); + + if (!c.isZero()) { + out = zeros[groupSize - r.length] + r + out; + } else { + out = r + out; + } + } + if (this.isZero()) { + out = '0' + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + assert(false, 'Base should be between 2 and 36'); + }; + + BN.prototype.toNumber = function toNumber () { + var ret = this.words[0]; + if (this.length === 2) { + ret += this.words[1] * 0x4000000; + } else if (this.length === 3 && this.words[2] === 0x01) { + // NOTE: at this stage it is known that the top bit is set + ret += 0x10000000000000 + (this.words[1] * 0x4000000); + } else if (this.length > 2) { + assert(false, 'Number can only safely store up to 53 bits'); + } + return (this.negative !== 0) ? -ret : ret; + }; + + BN.prototype.toJSON = function toJSON () { + return this.toString(16, 2); + }; + + if (Buffer) { + BN.prototype.toBuffer = function toBuffer (endian, length) { + return this.toArrayLike(Buffer, endian, length); + }; + } + + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); + }; + + var allocate = function allocate (ArrayType, size) { + if (ArrayType.allocUnsafe) { + return ArrayType.allocUnsafe(size); + } + return new ArrayType(size); + }; + + BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { + this._strip(); + + var byteLength = this.byteLength(); + var reqLength = length || Math.max(1, byteLength); + assert(byteLength <= reqLength, 'byte array longer than desired length'); + assert(reqLength > 0, 'Requested array length <= 0'); + + var res = allocate(ArrayType, reqLength); + var postfix = endian === 'le' ? 'LE' : 'BE'; + this['_toArrayLike' + postfix](res, byteLength); + return res; + }; + + BN.prototype._toArrayLikeLE = function _toArrayLikeLE (res, byteLength) { + var position = 0; + var carry = 0; + + for (var i = 0, shift = 0; i < this.length; i++) { + var word = (this.words[i] << shift) | carry; + + res[position++] = word & 0xff; + if (position < res.length) { + res[position++] = (word >> 8) & 0xff; + } + if (position < res.length) { + res[position++] = (word >> 16) & 0xff; + } + + if (shift === 6) { + if (position < res.length) { + res[position++] = (word >> 24) & 0xff; + } + carry = 0; + shift = 0; + } else { + carry = word >>> 24; + shift += 2; + } + } + + if (position < res.length) { + res[position++] = carry; + + while (position < res.length) { + res[position++] = 0; + } + } + }; + + BN.prototype._toArrayLikeBE = function _toArrayLikeBE (res, byteLength) { + var position = res.length - 1; + var carry = 0; + + for (var i = 0, shift = 0; i < this.length; i++) { + var word = (this.words[i] << shift) | carry; + + res[position--] = word & 0xff; + if (position >= 0) { + res[position--] = (word >> 8) & 0xff; + } + if (position >= 0) { + res[position--] = (word >> 16) & 0xff; + } + + if (shift === 6) { + if (position >= 0) { + res[position--] = (word >> 24) & 0xff; + } + carry = 0; + shift = 0; + } else { + carry = word >>> 24; + shift += 2; + } + } + + if (position >= 0) { + res[position--] = carry; + + while (position >= 0) { + res[position--] = 0; + } + } + }; + + if (Math.clz32) { + BN.prototype._countBits = function _countBits (w) { + return 32 - Math.clz32(w); + }; + } else { + BN.prototype._countBits = function _countBits (w) { + var t = w; + var r = 0; + if (t >= 0x1000) { + r += 13; + t >>>= 13; + } + if (t >= 0x40) { + r += 7; + t >>>= 7; + } + if (t >= 0x8) { + r += 4; + t >>>= 4; + } + if (t >= 0x02) { + r += 2; + t >>>= 2; + } + return r + t; + }; + } + + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; + + var t = w; + var r = 0; + if ((t & 0x1fff) === 0) { + r += 13; + t >>>= 13; + } + if ((t & 0x7f) === 0) { + r += 7; + t >>>= 7; + } + if ((t & 0xf) === 0) { + r += 4; + t >>>= 4; + } + if ((t & 0x3) === 0) { + r += 2; + t >>>= 2; + } + if ((t & 0x1) === 0) { + r++; + } + return r; + }; + + // Return number of used bits in a BN + BN.prototype.bitLength = function bitLength () { + var w = this.words[this.length - 1]; + var hi = this._countBits(w); + return (this.length - 1) * 26 + hi; + }; + + function toBitArray (num) { + var w = new Array(num.bitLength()); + + for (var bit = 0; bit < w.length; bit++) { + var off = (bit / 26) | 0; + var wbit = bit % 26; + + w[bit] = (num.words[off] >>> wbit) & 0x01; + } + + return w; + } + + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; + + var r = 0; + for (var i = 0; i < this.length; i++) { + var b = this._zeroBits(this.words[i]); + r += b; + if (b !== 26) break; + } + return r; + }; + + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); + }; + + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + + BN.prototype.isNeg = function isNeg () { + return this.negative !== 0; + }; + + // Return negative clone of `this` + BN.prototype.neg = function neg () { + return this.clone().ineg(); + }; + + BN.prototype.ineg = function ineg () { + if (!this.isZero()) { + this.negative ^= 1; + } + + return this; + }; + + // Or `num` with `this` in-place + BN.prototype.iuor = function iuor (num) { + while (this.length < num.length) { + this.words[this.length++] = 0; + } + + for (var i = 0; i < num.length; i++) { + this.words[i] = this.words[i] | num.words[i]; + } + + return this._strip(); + }; + + BN.prototype.ior = function ior (num) { + assert((this.negative | num.negative) === 0); + return this.iuor(num); + }; + + // Or `num` with `this` + BN.prototype.or = function or (num) { + if (this.length > num.length) return this.clone().ior(num); + return num.clone().ior(this); + }; + + BN.prototype.uor = function uor (num) { + if (this.length > num.length) return this.clone().iuor(num); + return num.clone().iuor(this); + }; + + // And `num` with `this` in-place + BN.prototype.iuand = function iuand (num) { + // b = min-length(num, this) + var b; + if (this.length > num.length) { + b = num; + } else { + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; + } + + this.length = b.length; + + return this._strip(); + }; + + BN.prototype.iand = function iand (num) { + assert((this.negative | num.negative) === 0); + return this.iuand(num); + }; + + // And `num` with `this` + BN.prototype.and = function and (num) { + if (this.length > num.length) return this.clone().iand(num); + return num.clone().iand(this); + }; + + BN.prototype.uand = function uand (num) { + if (this.length > num.length) return this.clone().iuand(num); + return num.clone().iuand(this); + }; + + // Xor `num` with `this` in-place + BN.prototype.iuxor = function iuxor (num) { + // a.length > b.length + var a; + var b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; + } + + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = a.length; + + return this._strip(); + }; + + BN.prototype.ixor = function ixor (num) { + assert((this.negative | num.negative) === 0); + return this.iuxor(num); + }; + + // Xor `num` with `this` + BN.prototype.xor = function xor (num) { + if (this.length > num.length) return this.clone().ixor(num); + return num.clone().ixor(this); + }; + + BN.prototype.uxor = function uxor (num) { + if (this.length > num.length) return this.clone().iuxor(num); + return num.clone().iuxor(this); + }; + + // Not ``this`` with ``width`` bitwidth + BN.prototype.inotn = function inotn (width) { + assert(typeof width === 'number' && width >= 0); + + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + + // Extend the buffer with leading zeroes + this._expand(bytesNeeded); + + if (bitsLeft > 0) { + bytesNeeded--; + } + + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; + } + + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); + } + + // And remove leading zeroes + return this._strip(); + }; + + BN.prototype.notn = function notn (width) { + return this.clone().inotn(width); + }; + + // Set `bit` of `this` + BN.prototype.setn = function setn (bit, val) { + assert(typeof bit === 'number' && bit >= 0); + + var off = (bit / 26) | 0; + var wbit = bit % 26; + + this._expand(off + 1); + + if (val) { + this.words[off] = this.words[off] | (1 << wbit); + } else { + this.words[off] = this.words[off] & ~(1 << wbit); + } + + return this._strip(); + }; + + // Add `num` to `this` in-place + BN.prototype.iadd = function iadd (num) { + var r; + + // negative + positive + if (this.negative !== 0 && num.negative === 0) { + this.negative = 0; + r = this.isub(num); + this.negative ^= 1; + return this._normSign(); + + // positive + negative + } else if (this.negative === 0 && num.negative !== 0) { + num.negative = 0; + r = this.isub(num); + num.negative = 1; + return r._normSign(); + } + + // a.length > b.length + var a, b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) + (b.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + + this.length = a.length; + if (carry !== 0) { + this.words[this.length] = carry; + this.length++; + // Copy the rest of the words + } else if (a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + return this; + }; + + // Add `num` to `this` + BN.prototype.add = function add (num) { + var res; + if (num.negative !== 0 && this.negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && this.negative !== 0) { + this.negative = 0; + res = num.sub(this); + this.negative = 1; + return res; + } + + if (this.length > num.length) return this.clone().iadd(num); + + return num.clone().iadd(this); + }; + + // Subtract `num` from `this` in-place + BN.prototype.isub = function isub (num) { + // this - (-num) = this + num + if (num.negative !== 0) { + num.negative = 0; + var r = this.iadd(num); + num.negative = 1; + return r._normSign(); + + // -this - num = -(this + num) + } else if (this.negative !== 0) { + this.negative = 0; + this.iadd(num); + this.negative = 1; + return this._normSign(); + } + + // At this point both numbers are positive + var cmp = this.cmp(num); + + // Optimization - zeroify + if (cmp === 0) { + this.negative = 0; + this.length = 1; + this.words[0] = 0; + return this; + } + + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) - (b.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + + // Copy rest of the words + if (carry === 0 && i < a.length && a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = Math.max(this.length, i); + + if (a !== this) { + this.negative = 1; + } + + return this._strip(); + }; + + // Subtract `num` from `this` + BN.prototype.sub = function sub (num) { + return this.clone().isub(num); + }; + + function smallMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + var len = (self.length + num.length) | 0; + out.length = len; + len = (len - 1) | 0; + + // Peel one iteration (compiler can't do it, because of code complexity) + var a = self.words[0] | 0; + var b = num.words[0] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + var carry = (r / 0x4000000) | 0; + out.words[0] = lo; + + for (var k = 1; k < len; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = carry >>> 26; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = (k - j) | 0; + a = self.words[i] | 0; + b = num.words[j] | 0; + r = a * b + rword; + ncarry += (r / 0x4000000) | 0; + rword = r & 0x3ffffff; + } + out.words[k] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k] = carry | 0; + } else { + out.length--; + } + + return out._strip(); + } + + // TODO(indutny): it may be reasonable to omit it for users who don't need + // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit + // multiplication (like elliptic secp256k1). + var comb10MulTo = function comb10MulTo (self, num, out) { + var a = self.words; + var b = num.words; + var o = out.words; + var c = 0; + var lo; + var mid; + var hi; + var a0 = a[0] | 0; + var al0 = a0 & 0x1fff; + var ah0 = a0 >>> 13; + var a1 = a[1] | 0; + var al1 = a1 & 0x1fff; + var ah1 = a1 >>> 13; + var a2 = a[2] | 0; + var al2 = a2 & 0x1fff; + var ah2 = a2 >>> 13; + var a3 = a[3] | 0; + var al3 = a3 & 0x1fff; + var ah3 = a3 >>> 13; + var a4 = a[4] | 0; + var al4 = a4 & 0x1fff; + var ah4 = a4 >>> 13; + var a5 = a[5] | 0; + var al5 = a5 & 0x1fff; + var ah5 = a5 >>> 13; + var a6 = a[6] | 0; + var al6 = a6 & 0x1fff; + var ah6 = a6 >>> 13; + var a7 = a[7] | 0; + var al7 = a7 & 0x1fff; + var ah7 = a7 >>> 13; + var a8 = a[8] | 0; + var al8 = a8 & 0x1fff; + var ah8 = a8 >>> 13; + var a9 = a[9] | 0; + var al9 = a9 & 0x1fff; + var ah9 = a9 >>> 13; + var b0 = b[0] | 0; + var bl0 = b0 & 0x1fff; + var bh0 = b0 >>> 13; + var b1 = b[1] | 0; + var bl1 = b1 & 0x1fff; + var bh1 = b1 >>> 13; + var b2 = b[2] | 0; + var bl2 = b2 & 0x1fff; + var bh2 = b2 >>> 13; + var b3 = b[3] | 0; + var bl3 = b3 & 0x1fff; + var bh3 = b3 >>> 13; + var b4 = b[4] | 0; + var bl4 = b4 & 0x1fff; + var bh4 = b4 >>> 13; + var b5 = b[5] | 0; + var bl5 = b5 & 0x1fff; + var bh5 = b5 >>> 13; + var b6 = b[6] | 0; + var bl6 = b6 & 0x1fff; + var bh6 = b6 >>> 13; + var b7 = b[7] | 0; + var bl7 = b7 & 0x1fff; + var bh7 = b7 >>> 13; + var b8 = b[8] | 0; + var bl8 = b8 & 0x1fff; + var bh8 = b8 >>> 13; + var b9 = b[9] | 0; + var bl9 = b9 & 0x1fff; + var bh9 = b9 >>> 13; + + out.negative = self.negative ^ num.negative; + out.length = 19; + /* k = 0 */ + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = (mid + Math.imul(ah0, bl0)) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; + w0 &= 0x3ffffff; + /* k = 1 */ + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = (mid + Math.imul(ah1, bl0)) | 0; + hi = Math.imul(ah1, bh0); + lo = (lo + Math.imul(al0, bl1)) | 0; + mid = (mid + Math.imul(al0, bh1)) | 0; + mid = (mid + Math.imul(ah0, bl1)) | 0; + hi = (hi + Math.imul(ah0, bh1)) | 0; + var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; + w1 &= 0x3ffffff; + /* k = 2 */ + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = (mid + Math.imul(ah2, bl0)) | 0; + hi = Math.imul(ah2, bh0); + lo = (lo + Math.imul(al1, bl1)) | 0; + mid = (mid + Math.imul(al1, bh1)) | 0; + mid = (mid + Math.imul(ah1, bl1)) | 0; + hi = (hi + Math.imul(ah1, bh1)) | 0; + lo = (lo + Math.imul(al0, bl2)) | 0; + mid = (mid + Math.imul(al0, bh2)) | 0; + mid = (mid + Math.imul(ah0, bl2)) | 0; + hi = (hi + Math.imul(ah0, bh2)) | 0; + var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; + w2 &= 0x3ffffff; + /* k = 3 */ + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = (mid + Math.imul(ah3, bl0)) | 0; + hi = Math.imul(ah3, bh0); + lo = (lo + Math.imul(al2, bl1)) | 0; + mid = (mid + Math.imul(al2, bh1)) | 0; + mid = (mid + Math.imul(ah2, bl1)) | 0; + hi = (hi + Math.imul(ah2, bh1)) | 0; + lo = (lo + Math.imul(al1, bl2)) | 0; + mid = (mid + Math.imul(al1, bh2)) | 0; + mid = (mid + Math.imul(ah1, bl2)) | 0; + hi = (hi + Math.imul(ah1, bh2)) | 0; + lo = (lo + Math.imul(al0, bl3)) | 0; + mid = (mid + Math.imul(al0, bh3)) | 0; + mid = (mid + Math.imul(ah0, bl3)) | 0; + hi = (hi + Math.imul(ah0, bh3)) | 0; + var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; + w3 &= 0x3ffffff; + /* k = 4 */ + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = (mid + Math.imul(ah4, bl0)) | 0; + hi = Math.imul(ah4, bh0); + lo = (lo + Math.imul(al3, bl1)) | 0; + mid = (mid + Math.imul(al3, bh1)) | 0; + mid = (mid + Math.imul(ah3, bl1)) | 0; + hi = (hi + Math.imul(ah3, bh1)) | 0; + lo = (lo + Math.imul(al2, bl2)) | 0; + mid = (mid + Math.imul(al2, bh2)) | 0; + mid = (mid + Math.imul(ah2, bl2)) | 0; + hi = (hi + Math.imul(ah2, bh2)) | 0; + lo = (lo + Math.imul(al1, bl3)) | 0; + mid = (mid + Math.imul(al1, bh3)) | 0; + mid = (mid + Math.imul(ah1, bl3)) | 0; + hi = (hi + Math.imul(ah1, bh3)) | 0; + lo = (lo + Math.imul(al0, bl4)) | 0; + mid = (mid + Math.imul(al0, bh4)) | 0; + mid = (mid + Math.imul(ah0, bl4)) | 0; + hi = (hi + Math.imul(ah0, bh4)) | 0; + var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; + w4 &= 0x3ffffff; + /* k = 5 */ + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = (mid + Math.imul(ah5, bl0)) | 0; + hi = Math.imul(ah5, bh0); + lo = (lo + Math.imul(al4, bl1)) | 0; + mid = (mid + Math.imul(al4, bh1)) | 0; + mid = (mid + Math.imul(ah4, bl1)) | 0; + hi = (hi + Math.imul(ah4, bh1)) | 0; + lo = (lo + Math.imul(al3, bl2)) | 0; + mid = (mid + Math.imul(al3, bh2)) | 0; + mid = (mid + Math.imul(ah3, bl2)) | 0; + hi = (hi + Math.imul(ah3, bh2)) | 0; + lo = (lo + Math.imul(al2, bl3)) | 0; + mid = (mid + Math.imul(al2, bh3)) | 0; + mid = (mid + Math.imul(ah2, bl3)) | 0; + hi = (hi + Math.imul(ah2, bh3)) | 0; + lo = (lo + Math.imul(al1, bl4)) | 0; + mid = (mid + Math.imul(al1, bh4)) | 0; + mid = (mid + Math.imul(ah1, bl4)) | 0; + hi = (hi + Math.imul(ah1, bh4)) | 0; + lo = (lo + Math.imul(al0, bl5)) | 0; + mid = (mid + Math.imul(al0, bh5)) | 0; + mid = (mid + Math.imul(ah0, bl5)) | 0; + hi = (hi + Math.imul(ah0, bh5)) | 0; + var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; + w5 &= 0x3ffffff; + /* k = 6 */ + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = (mid + Math.imul(ah6, bl0)) | 0; + hi = Math.imul(ah6, bh0); + lo = (lo + Math.imul(al5, bl1)) | 0; + mid = (mid + Math.imul(al5, bh1)) | 0; + mid = (mid + Math.imul(ah5, bl1)) | 0; + hi = (hi + Math.imul(ah5, bh1)) | 0; + lo = (lo + Math.imul(al4, bl2)) | 0; + mid = (mid + Math.imul(al4, bh2)) | 0; + mid = (mid + Math.imul(ah4, bl2)) | 0; + hi = (hi + Math.imul(ah4, bh2)) | 0; + lo = (lo + Math.imul(al3, bl3)) | 0; + mid = (mid + Math.imul(al3, bh3)) | 0; + mid = (mid + Math.imul(ah3, bl3)) | 0; + hi = (hi + Math.imul(ah3, bh3)) | 0; + lo = (lo + Math.imul(al2, bl4)) | 0; + mid = (mid + Math.imul(al2, bh4)) | 0; + mid = (mid + Math.imul(ah2, bl4)) | 0; + hi = (hi + Math.imul(ah2, bh4)) | 0; + lo = (lo + Math.imul(al1, bl5)) | 0; + mid = (mid + Math.imul(al1, bh5)) | 0; + mid = (mid + Math.imul(ah1, bl5)) | 0; + hi = (hi + Math.imul(ah1, bh5)) | 0; + lo = (lo + Math.imul(al0, bl6)) | 0; + mid = (mid + Math.imul(al0, bh6)) | 0; + mid = (mid + Math.imul(ah0, bl6)) | 0; + hi = (hi + Math.imul(ah0, bh6)) | 0; + var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; + w6 &= 0x3ffffff; + /* k = 7 */ + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = (mid + Math.imul(ah7, bl0)) | 0; + hi = Math.imul(ah7, bh0); + lo = (lo + Math.imul(al6, bl1)) | 0; + mid = (mid + Math.imul(al6, bh1)) | 0; + mid = (mid + Math.imul(ah6, bl1)) | 0; + hi = (hi + Math.imul(ah6, bh1)) | 0; + lo = (lo + Math.imul(al5, bl2)) | 0; + mid = (mid + Math.imul(al5, bh2)) | 0; + mid = (mid + Math.imul(ah5, bl2)) | 0; + hi = (hi + Math.imul(ah5, bh2)) | 0; + lo = (lo + Math.imul(al4, bl3)) | 0; + mid = (mid + Math.imul(al4, bh3)) | 0; + mid = (mid + Math.imul(ah4, bl3)) | 0; + hi = (hi + Math.imul(ah4, bh3)) | 0; + lo = (lo + Math.imul(al3, bl4)) | 0; + mid = (mid + Math.imul(al3, bh4)) | 0; + mid = (mid + Math.imul(ah3, bl4)) | 0; + hi = (hi + Math.imul(ah3, bh4)) | 0; + lo = (lo + Math.imul(al2, bl5)) | 0; + mid = (mid + Math.imul(al2, bh5)) | 0; + mid = (mid + Math.imul(ah2, bl5)) | 0; + hi = (hi + Math.imul(ah2, bh5)) | 0; + lo = (lo + Math.imul(al1, bl6)) | 0; + mid = (mid + Math.imul(al1, bh6)) | 0; + mid = (mid + Math.imul(ah1, bl6)) | 0; + hi = (hi + Math.imul(ah1, bh6)) | 0; + lo = (lo + Math.imul(al0, bl7)) | 0; + mid = (mid + Math.imul(al0, bh7)) | 0; + mid = (mid + Math.imul(ah0, bl7)) | 0; + hi = (hi + Math.imul(ah0, bh7)) | 0; + var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; + w7 &= 0x3ffffff; + /* k = 8 */ + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = (mid + Math.imul(ah8, bl0)) | 0; + hi = Math.imul(ah8, bh0); + lo = (lo + Math.imul(al7, bl1)) | 0; + mid = (mid + Math.imul(al7, bh1)) | 0; + mid = (mid + Math.imul(ah7, bl1)) | 0; + hi = (hi + Math.imul(ah7, bh1)) | 0; + lo = (lo + Math.imul(al6, bl2)) | 0; + mid = (mid + Math.imul(al6, bh2)) | 0; + mid = (mid + Math.imul(ah6, bl2)) | 0; + hi = (hi + Math.imul(ah6, bh2)) | 0; + lo = (lo + Math.imul(al5, bl3)) | 0; + mid = (mid + Math.imul(al5, bh3)) | 0; + mid = (mid + Math.imul(ah5, bl3)) | 0; + hi = (hi + Math.imul(ah5, bh3)) | 0; + lo = (lo + Math.imul(al4, bl4)) | 0; + mid = (mid + Math.imul(al4, bh4)) | 0; + mid = (mid + Math.imul(ah4, bl4)) | 0; + hi = (hi + Math.imul(ah4, bh4)) | 0; + lo = (lo + Math.imul(al3, bl5)) | 0; + mid = (mid + Math.imul(al3, bh5)) | 0; + mid = (mid + Math.imul(ah3, bl5)) | 0; + hi = (hi + Math.imul(ah3, bh5)) | 0; + lo = (lo + Math.imul(al2, bl6)) | 0; + mid = (mid + Math.imul(al2, bh6)) | 0; + mid = (mid + Math.imul(ah2, bl6)) | 0; + hi = (hi + Math.imul(ah2, bh6)) | 0; + lo = (lo + Math.imul(al1, bl7)) | 0; + mid = (mid + Math.imul(al1, bh7)) | 0; + mid = (mid + Math.imul(ah1, bl7)) | 0; + hi = (hi + Math.imul(ah1, bh7)) | 0; + lo = (lo + Math.imul(al0, bl8)) | 0; + mid = (mid + Math.imul(al0, bh8)) | 0; + mid = (mid + Math.imul(ah0, bl8)) | 0; + hi = (hi + Math.imul(ah0, bh8)) | 0; + var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; + w8 &= 0x3ffffff; + /* k = 9 */ + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = (mid + Math.imul(ah9, bl0)) | 0; + hi = Math.imul(ah9, bh0); + lo = (lo + Math.imul(al8, bl1)) | 0; + mid = (mid + Math.imul(al8, bh1)) | 0; + mid = (mid + Math.imul(ah8, bl1)) | 0; + hi = (hi + Math.imul(ah8, bh1)) | 0; + lo = (lo + Math.imul(al7, bl2)) | 0; + mid = (mid + Math.imul(al7, bh2)) | 0; + mid = (mid + Math.imul(ah7, bl2)) | 0; + hi = (hi + Math.imul(ah7, bh2)) | 0; + lo = (lo + Math.imul(al6, bl3)) | 0; + mid = (mid + Math.imul(al6, bh3)) | 0; + mid = (mid + Math.imul(ah6, bl3)) | 0; + hi = (hi + Math.imul(ah6, bh3)) | 0; + lo = (lo + Math.imul(al5, bl4)) | 0; + mid = (mid + Math.imul(al5, bh4)) | 0; + mid = (mid + Math.imul(ah5, bl4)) | 0; + hi = (hi + Math.imul(ah5, bh4)) | 0; + lo = (lo + Math.imul(al4, bl5)) | 0; + mid = (mid + Math.imul(al4, bh5)) | 0; + mid = (mid + Math.imul(ah4, bl5)) | 0; + hi = (hi + Math.imul(ah4, bh5)) | 0; + lo = (lo + Math.imul(al3, bl6)) | 0; + mid = (mid + Math.imul(al3, bh6)) | 0; + mid = (mid + Math.imul(ah3, bl6)) | 0; + hi = (hi + Math.imul(ah3, bh6)) | 0; + lo = (lo + Math.imul(al2, bl7)) | 0; + mid = (mid + Math.imul(al2, bh7)) | 0; + mid = (mid + Math.imul(ah2, bl7)) | 0; + hi = (hi + Math.imul(ah2, bh7)) | 0; + lo = (lo + Math.imul(al1, bl8)) | 0; + mid = (mid + Math.imul(al1, bh8)) | 0; + mid = (mid + Math.imul(ah1, bl8)) | 0; + hi = (hi + Math.imul(ah1, bh8)) | 0; + lo = (lo + Math.imul(al0, bl9)) | 0; + mid = (mid + Math.imul(al0, bh9)) | 0; + mid = (mid + Math.imul(ah0, bl9)) | 0; + hi = (hi + Math.imul(ah0, bh9)) | 0; + var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; + w9 &= 0x3ffffff; + /* k = 10 */ + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = (mid + Math.imul(ah9, bl1)) | 0; + hi = Math.imul(ah9, bh1); + lo = (lo + Math.imul(al8, bl2)) | 0; + mid = (mid + Math.imul(al8, bh2)) | 0; + mid = (mid + Math.imul(ah8, bl2)) | 0; + hi = (hi + Math.imul(ah8, bh2)) | 0; + lo = (lo + Math.imul(al7, bl3)) | 0; + mid = (mid + Math.imul(al7, bh3)) | 0; + mid = (mid + Math.imul(ah7, bl3)) | 0; + hi = (hi + Math.imul(ah7, bh3)) | 0; + lo = (lo + Math.imul(al6, bl4)) | 0; + mid = (mid + Math.imul(al6, bh4)) | 0; + mid = (mid + Math.imul(ah6, bl4)) | 0; + hi = (hi + Math.imul(ah6, bh4)) | 0; + lo = (lo + Math.imul(al5, bl5)) | 0; + mid = (mid + Math.imul(al5, bh5)) | 0; + mid = (mid + Math.imul(ah5, bl5)) | 0; + hi = (hi + Math.imul(ah5, bh5)) | 0; + lo = (lo + Math.imul(al4, bl6)) | 0; + mid = (mid + Math.imul(al4, bh6)) | 0; + mid = (mid + Math.imul(ah4, bl6)) | 0; + hi = (hi + Math.imul(ah4, bh6)) | 0; + lo = (lo + Math.imul(al3, bl7)) | 0; + mid = (mid + Math.imul(al3, bh7)) | 0; + mid = (mid + Math.imul(ah3, bl7)) | 0; + hi = (hi + Math.imul(ah3, bh7)) | 0; + lo = (lo + Math.imul(al2, bl8)) | 0; + mid = (mid + Math.imul(al2, bh8)) | 0; + mid = (mid + Math.imul(ah2, bl8)) | 0; + hi = (hi + Math.imul(ah2, bh8)) | 0; + lo = (lo + Math.imul(al1, bl9)) | 0; + mid = (mid + Math.imul(al1, bh9)) | 0; + mid = (mid + Math.imul(ah1, bl9)) | 0; + hi = (hi + Math.imul(ah1, bh9)) | 0; + var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; + w10 &= 0x3ffffff; + /* k = 11 */ + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = (mid + Math.imul(ah9, bl2)) | 0; + hi = Math.imul(ah9, bh2); + lo = (lo + Math.imul(al8, bl3)) | 0; + mid = (mid + Math.imul(al8, bh3)) | 0; + mid = (mid + Math.imul(ah8, bl3)) | 0; + hi = (hi + Math.imul(ah8, bh3)) | 0; + lo = (lo + Math.imul(al7, bl4)) | 0; + mid = (mid + Math.imul(al7, bh4)) | 0; + mid = (mid + Math.imul(ah7, bl4)) | 0; + hi = (hi + Math.imul(ah7, bh4)) | 0; + lo = (lo + Math.imul(al6, bl5)) | 0; + mid = (mid + Math.imul(al6, bh5)) | 0; + mid = (mid + Math.imul(ah6, bl5)) | 0; + hi = (hi + Math.imul(ah6, bh5)) | 0; + lo = (lo + Math.imul(al5, bl6)) | 0; + mid = (mid + Math.imul(al5, bh6)) | 0; + mid = (mid + Math.imul(ah5, bl6)) | 0; + hi = (hi + Math.imul(ah5, bh6)) | 0; + lo = (lo + Math.imul(al4, bl7)) | 0; + mid = (mid + Math.imul(al4, bh7)) | 0; + mid = (mid + Math.imul(ah4, bl7)) | 0; + hi = (hi + Math.imul(ah4, bh7)) | 0; + lo = (lo + Math.imul(al3, bl8)) | 0; + mid = (mid + Math.imul(al3, bh8)) | 0; + mid = (mid + Math.imul(ah3, bl8)) | 0; + hi = (hi + Math.imul(ah3, bh8)) | 0; + lo = (lo + Math.imul(al2, bl9)) | 0; + mid = (mid + Math.imul(al2, bh9)) | 0; + mid = (mid + Math.imul(ah2, bl9)) | 0; + hi = (hi + Math.imul(ah2, bh9)) | 0; + var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; + w11 &= 0x3ffffff; + /* k = 12 */ + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = (mid + Math.imul(ah9, bl3)) | 0; + hi = Math.imul(ah9, bh3); + lo = (lo + Math.imul(al8, bl4)) | 0; + mid = (mid + Math.imul(al8, bh4)) | 0; + mid = (mid + Math.imul(ah8, bl4)) | 0; + hi = (hi + Math.imul(ah8, bh4)) | 0; + lo = (lo + Math.imul(al7, bl5)) | 0; + mid = (mid + Math.imul(al7, bh5)) | 0; + mid = (mid + Math.imul(ah7, bl5)) | 0; + hi = (hi + Math.imul(ah7, bh5)) | 0; + lo = (lo + Math.imul(al6, bl6)) | 0; + mid = (mid + Math.imul(al6, bh6)) | 0; + mid = (mid + Math.imul(ah6, bl6)) | 0; + hi = (hi + Math.imul(ah6, bh6)) | 0; + lo = (lo + Math.imul(al5, bl7)) | 0; + mid = (mid + Math.imul(al5, bh7)) | 0; + mid = (mid + Math.imul(ah5, bl7)) | 0; + hi = (hi + Math.imul(ah5, bh7)) | 0; + lo = (lo + Math.imul(al4, bl8)) | 0; + mid = (mid + Math.imul(al4, bh8)) | 0; + mid = (mid + Math.imul(ah4, bl8)) | 0; + hi = (hi + Math.imul(ah4, bh8)) | 0; + lo = (lo + Math.imul(al3, bl9)) | 0; + mid = (mid + Math.imul(al3, bh9)) | 0; + mid = (mid + Math.imul(ah3, bl9)) | 0; + hi = (hi + Math.imul(ah3, bh9)) | 0; + var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; + w12 &= 0x3ffffff; + /* k = 13 */ + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = (mid + Math.imul(ah9, bl4)) | 0; + hi = Math.imul(ah9, bh4); + lo = (lo + Math.imul(al8, bl5)) | 0; + mid = (mid + Math.imul(al8, bh5)) | 0; + mid = (mid + Math.imul(ah8, bl5)) | 0; + hi = (hi + Math.imul(ah8, bh5)) | 0; + lo = (lo + Math.imul(al7, bl6)) | 0; + mid = (mid + Math.imul(al7, bh6)) | 0; + mid = (mid + Math.imul(ah7, bl6)) | 0; + hi = (hi + Math.imul(ah7, bh6)) | 0; + lo = (lo + Math.imul(al6, bl7)) | 0; + mid = (mid + Math.imul(al6, bh7)) | 0; + mid = (mid + Math.imul(ah6, bl7)) | 0; + hi = (hi + Math.imul(ah6, bh7)) | 0; + lo = (lo + Math.imul(al5, bl8)) | 0; + mid = (mid + Math.imul(al5, bh8)) | 0; + mid = (mid + Math.imul(ah5, bl8)) | 0; + hi = (hi + Math.imul(ah5, bh8)) | 0; + lo = (lo + Math.imul(al4, bl9)) | 0; + mid = (mid + Math.imul(al4, bh9)) | 0; + mid = (mid + Math.imul(ah4, bl9)) | 0; + hi = (hi + Math.imul(ah4, bh9)) | 0; + var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; + w13 &= 0x3ffffff; + /* k = 14 */ + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = (mid + Math.imul(ah9, bl5)) | 0; + hi = Math.imul(ah9, bh5); + lo = (lo + Math.imul(al8, bl6)) | 0; + mid = (mid + Math.imul(al8, bh6)) | 0; + mid = (mid + Math.imul(ah8, bl6)) | 0; + hi = (hi + Math.imul(ah8, bh6)) | 0; + lo = (lo + Math.imul(al7, bl7)) | 0; + mid = (mid + Math.imul(al7, bh7)) | 0; + mid = (mid + Math.imul(ah7, bl7)) | 0; + hi = (hi + Math.imul(ah7, bh7)) | 0; + lo = (lo + Math.imul(al6, bl8)) | 0; + mid = (mid + Math.imul(al6, bh8)) | 0; + mid = (mid + Math.imul(ah6, bl8)) | 0; + hi = (hi + Math.imul(ah6, bh8)) | 0; + lo = (lo + Math.imul(al5, bl9)) | 0; + mid = (mid + Math.imul(al5, bh9)) | 0; + mid = (mid + Math.imul(ah5, bl9)) | 0; + hi = (hi + Math.imul(ah5, bh9)) | 0; + var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; + w14 &= 0x3ffffff; + /* k = 15 */ + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = (mid + Math.imul(ah9, bl6)) | 0; + hi = Math.imul(ah9, bh6); + lo = (lo + Math.imul(al8, bl7)) | 0; + mid = (mid + Math.imul(al8, bh7)) | 0; + mid = (mid + Math.imul(ah8, bl7)) | 0; + hi = (hi + Math.imul(ah8, bh7)) | 0; + lo = (lo + Math.imul(al7, bl8)) | 0; + mid = (mid + Math.imul(al7, bh8)) | 0; + mid = (mid + Math.imul(ah7, bl8)) | 0; + hi = (hi + Math.imul(ah7, bh8)) | 0; + lo = (lo + Math.imul(al6, bl9)) | 0; + mid = (mid + Math.imul(al6, bh9)) | 0; + mid = (mid + Math.imul(ah6, bl9)) | 0; + hi = (hi + Math.imul(ah6, bh9)) | 0; + var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; + w15 &= 0x3ffffff; + /* k = 16 */ + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = (mid + Math.imul(ah9, bl7)) | 0; + hi = Math.imul(ah9, bh7); + lo = (lo + Math.imul(al8, bl8)) | 0; + mid = (mid + Math.imul(al8, bh8)) | 0; + mid = (mid + Math.imul(ah8, bl8)) | 0; + hi = (hi + Math.imul(ah8, bh8)) | 0; + lo = (lo + Math.imul(al7, bl9)) | 0; + mid = (mid + Math.imul(al7, bh9)) | 0; + mid = (mid + Math.imul(ah7, bl9)) | 0; + hi = (hi + Math.imul(ah7, bh9)) | 0; + var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; + w16 &= 0x3ffffff; + /* k = 17 */ + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = (mid + Math.imul(ah9, bl8)) | 0; + hi = Math.imul(ah9, bh8); + lo = (lo + Math.imul(al8, bl9)) | 0; + mid = (mid + Math.imul(al8, bh9)) | 0; + mid = (mid + Math.imul(ah8, bl9)) | 0; + hi = (hi + Math.imul(ah8, bh9)) | 0; + var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; + w17 &= 0x3ffffff; + /* k = 18 */ + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = (mid + Math.imul(ah9, bl9)) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; + w18 &= 0x3ffffff; + o[0] = w0; + o[1] = w1; + o[2] = w2; + o[3] = w3; + o[4] = w4; + o[5] = w5; + o[6] = w6; + o[7] = w7; + o[8] = w8; + o[9] = w9; + o[10] = w10; + o[11] = w11; + o[12] = w12; + o[13] = w13; + o[14] = w14; + o[15] = w15; + o[16] = w16; + o[17] = w17; + o[18] = w18; + if (c !== 0) { + o[19] = c; + out.length++; + } + return out; + }; + + // Polyfill comb + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + + function bigMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + out.length = self.length + num.length; + + var carry = 0; + var hncarry = 0; + for (var k = 0; k < out.length - 1; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = k - j; + var a = self.words[i] | 0; + var b = num.words[j] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; + lo = (lo + rword) | 0; + rword = lo & 0x3ffffff; + ncarry = (ncarry + (lo >>> 26)) | 0; + + hncarry += ncarry >>> 26; + ncarry &= 0x3ffffff; + } + out.words[k] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k] = carry; + } else { + out.length--; + } + + return out._strip(); + } + + function jumboMulTo (self, num, out) { + // Temporary disable, see https://github.com/indutny/bn.js/issues/211 + // var fftm = new FFTM(); + // return fftm.mulp(self, num, out); + return bigMulTo(self, num, out); + } + + BN.prototype.mulTo = function mulTo (num, out) { + var res; + var len = this.length + num.length; + if (this.length === 10 && num.length === 10) { + res = comb10MulTo(this, num, out); + } else if (len < 63) { + res = smallMulTo(this, num, out); + } else if (len < 1024) { + res = bigMulTo(this, num, out); + } else { + res = jumboMulTo(this, num, out); + } + + return res; + }; + + // Multiply `this` by `num` + BN.prototype.mul = function mul (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return this.mulTo(num, out); + }; + + // Multiply employing FFT + BN.prototype.mulf = function mulf (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return jumboMulTo(this, num, out); + }; + + // In-place Multiplication + BN.prototype.imul = function imul (num) { + return this.clone().mulTo(num, this); + }; + + BN.prototype.imuln = function imuln (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; + + assert(typeof num === 'number'); + assert(num < 0x4000000); + + // Carry + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = (this.words[i] | 0) * num; + var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); + carry >>= 26; + carry += (w / 0x4000000) | 0; + // NOTE: lo is 27bit maximum + carry += lo >>> 26; + this.words[i] = lo & 0x3ffffff; + } + + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + + return isNegNum ? this.ineg() : this; + }; + + BN.prototype.muln = function muln (num) { + return this.clone().imuln(num); + }; + + // `this` * `this` + BN.prototype.sqr = function sqr () { + return this.mul(this); + }; + + // `this` * `this` in-place + BN.prototype.isqr = function isqr () { + return this.imul(this.clone()); + }; + + // Math.pow(`this`, `num`) + BN.prototype.pow = function pow (num) { + var w = toBitArray(num); + if (w.length === 0) return new BN(1); + + // Skip leading zeroes + var res = this; + for (var i = 0; i < w.length; i++, res = res.sqr()) { + if (w[i] !== 0) break; + } + + if (++i < w.length) { + for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { + if (w[i] === 0) continue; + + res = res.mul(q); + } + } + + return res; + }; + + // Shift-left in-place + BN.prototype.iushln = function iushln (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); + var i; + + if (r !== 0) { + var carry = 0; + + for (i = 0; i < this.length; i++) { + var newCarry = this.words[i] & carryMask; + var c = ((this.words[i] | 0) - newCarry) << r; + this.words[i] = c | carry; + carry = newCarry >>> (26 - r); + } + + if (carry) { + this.words[i] = carry; + this.length++; + } + } + + if (s !== 0) { + for (i = this.length - 1; i >= 0; i--) { + this.words[i + s] = this.words[i]; + } + + for (i = 0; i < s; i++) { + this.words[i] = 0; + } + + this.length += s; + } + + return this._strip(); + }; + + BN.prototype.ishln = function ishln (bits) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushln(bits); + }; + + // Shift-right in-place + // NOTE: `hint` is a lowest bit before trailing zeroes + // NOTE: if `extended` is present - it will be filled with destroyed bits + BN.prototype.iushrn = function iushrn (bits, hint, extended) { + assert(typeof bits === 'number' && bits >= 0); + var h; + if (hint) { + h = (hint - (hint % 26)) / 26; + } else { + h = 0; + } + + var r = bits % 26; + var s = Math.min((bits - r) / 26, this.length); + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + var maskedWords = extended; + + h -= s; + h = Math.max(0, h); + + // Extended mode, copy masked part + if (maskedWords) { + for (var i = 0; i < s; i++) { + maskedWords.words[i] = this.words[i]; + } + maskedWords.length = s; + } + + if (s === 0) ; else if (this.length > s) { + this.length -= s; + for (i = 0; i < this.length; i++) { + this.words[i] = this.words[i + s]; + } + } else { + this.words[0] = 0; + this.length = 1; + } + + var carry = 0; + for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { + var word = this.words[i] | 0; + this.words[i] = (carry << (26 - r)) | (word >>> r); + carry = word & mask; + } + + // Push carried bits as a mask + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + + if (this.length === 0) { + this.words[0] = 0; + this.length = 1; + } + + return this._strip(); + }; + + BN.prototype.ishrn = function ishrn (bits, hint, extended) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushrn(bits, hint, extended); + }; + + // Shift-left + BN.prototype.shln = function shln (bits) { + return this.clone().ishln(bits); + }; + + BN.prototype.ushln = function ushln (bits) { + return this.clone().iushln(bits); + }; + + // Shift-right + BN.prototype.shrn = function shrn (bits) { + return this.clone().ishrn(bits); + }; + + BN.prototype.ushrn = function ushrn (bits) { + return this.clone().iushrn(bits); + }; + + // Test if n bit is set + BN.prototype.testn = function testn (bit) { + assert(typeof bit === 'number' && bit >= 0); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) return false; + + // Check bit and return + var w = this.words[s]; + + return !!(w & q); + }; + + // Return only lowers bits of number (in-place) + BN.prototype.imaskn = function imaskn (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + + assert(this.negative === 0, 'imaskn works only with positive numbers'); + + if (this.length <= s) { + return this; + } + + if (r !== 0) { + s++; + } + this.length = Math.min(s, this.length); + + if (r !== 0) { + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + this.words[this.length - 1] &= mask; + } + + return this._strip(); + }; + + // Return only lowers bits of number + BN.prototype.maskn = function maskn (bits) { + return this.clone().imaskn(bits); + }; + + // Add plain number `num` to `this` + BN.prototype.iaddn = function iaddn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.isubn(-num); + + // Possible sign change + if (this.negative !== 0) { + if (this.length === 1 && (this.words[0] | 0) <= num) { + this.words[0] = num - (this.words[0] | 0); + this.negative = 0; + return this; + } + + this.negative = 0; + this.isubn(num); + this.negative = 1; + return this; + } + + // Add without checks + return this._iaddn(num); + }; + + BN.prototype._iaddn = function _iaddn (num) { + this.words[0] += num; + + // Carry + for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { + this.words[i] -= 0x4000000; + if (i === this.length - 1) { + this.words[i + 1] = 1; + } else { + this.words[i + 1]++; + } + } + this.length = Math.max(this.length, i + 1); + + return this; + }; + + // Subtract plain number `num` from `this` + BN.prototype.isubn = function isubn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.iaddn(-num); + + if (this.negative !== 0) { + this.negative = 0; + this.iaddn(num); + this.negative = 1; + return this; + } + + this.words[0] -= num; + + if (this.length === 1 && this.words[0] < 0) { + this.words[0] = -this.words[0]; + this.negative = 1; + } else { + // Carry + for (var i = 0; i < this.length && this.words[i] < 0; i++) { + this.words[i] += 0x4000000; + this.words[i + 1] -= 1; + } + } + + return this._strip(); + }; + + BN.prototype.addn = function addn (num) { + return this.clone().iaddn(num); + }; + + BN.prototype.subn = function subn (num) { + return this.clone().isubn(num); + }; + + BN.prototype.iabs = function iabs () { + this.negative = 0; + + return this; + }; + + BN.prototype.abs = function abs () { + return this.clone().iabs(); + }; + + BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { + var len = num.length + shift; + var i; + + this._expand(len); + + var w; + var carry = 0; + for (i = 0; i < num.length; i++) { + w = (this.words[i + shift] | 0) + carry; + var right = (num.words[i] | 0) * mul; + w -= right & 0x3ffffff; + carry = (w >> 26) - ((right / 0x4000000) | 0); + this.words[i + shift] = w & 0x3ffffff; + } + for (; i < this.length - shift; i++) { + w = (this.words[i + shift] | 0) + carry; + carry = w >> 26; + this.words[i + shift] = w & 0x3ffffff; + } + + if (carry === 0) return this._strip(); + + // Subtraction overflow + assert(carry === -1); + carry = 0; + for (i = 0; i < this.length; i++) { + w = -(this.words[i] | 0) + carry; + carry = w >> 26; + this.words[i] = w & 0x3ffffff; + } + this.negative = 1; + + return this._strip(); + }; + + BN.prototype._wordDiv = function _wordDiv (num, mode) { + var shift = this.length - num.length; + + var a = this.clone(); + var b = num; + + // Normalize + var bhi = b.words[b.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b = b.ushln(shift); + a.iushln(shift); + bhi = b.words[b.length - 1] | 0; + } + + // Initialize quotient + var m = a.length - b.length; + var q; + + if (mode !== 'mod') { + q = new BN(null); + q.length = m + 1; + q.words = new Array(q.length); + for (var i = 0; i < q.length; i++) { + q.words[i] = 0; + } + } + + var diff = a.clone()._ishlnsubmul(b, 1, m); + if (diff.negative === 0) { + a = diff; + if (q) { + q.words[m] = 1; + } + } + + for (var j = m - 1; j >= 0; j--) { + var qj = (a.words[b.length + j] | 0) * 0x4000000 + + (a.words[b.length + j - 1] | 0); + + // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max + // (0x7ffffff) + qj = Math.min((qj / bhi) | 0, 0x3ffffff); + + a._ishlnsubmul(b, qj, j); + while (a.negative !== 0) { + qj--; + a.negative = 0; + a._ishlnsubmul(b, 1, j); + if (!a.isZero()) { + a.negative ^= 1; + } + } + if (q) { + q.words[j] = qj; + } + } + if (q) { + q._strip(); + } + a._strip(); + + // Denormalize + if (mode !== 'div' && shift !== 0) { + a.iushrn(shift); + } + + return { + div: q || null, + mod: a + }; + }; + + // NOTE: 1) `mode` can be set to `mod` to request mod only, + // to `div` to request div only, or be absent to + // request both div & mod + // 2) `positive` is true if unsigned mod is requested + BN.prototype.divmod = function divmod (num, mode, positive) { + assert(!num.isZero()); + + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + + var div, mod, res; + if (this.negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.iadd(num); + } + } + + return { + div: div, + mod: mod + }; + } + + if (this.negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + return { + div: div, + mod: res.mod + }; + } + + if ((this.negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.isub(num); + } + } + + return { + div: res.div, + mod: mod + }; + } + + // Both numbers are positive at this point + + // Strip both numbers to approximate shift value + if (num.length > this.length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this + }; + } + + // Very short reduction + if (num.length === 1) { + if (mode === 'div') { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + + if (mode === 'mod') { + return { + div: null, + mod: new BN(this.modrn(num.words[0])) + }; + } + + return { + div: this.divn(num.words[0]), + mod: new BN(this.modrn(num.words[0])) + }; + } + + return this._wordDiv(num, mode); + }; + + // Find `this` / `num` + BN.prototype.div = function div (num) { + return this.divmod(num, 'div', false).div; + }; + + // Find `this` % `num` + BN.prototype.mod = function mod (num) { + return this.divmod(num, 'mod', false).mod; + }; + + BN.prototype.umod = function umod (num) { + return this.divmod(num, 'mod', true).mod; + }; + + // Find Round(`this` / `num`) + BN.prototype.divRound = function divRound (num) { + var dm = this.divmod(num); + + // Fast case - exact division + if (dm.mod.isZero()) return dm.div; + + var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + + var half = num.ushrn(1); + var r2 = num.andln(1); + var cmp = mod.cmp(half); + + // Round down + if (cmp < 0 || (r2 === 1 && cmp === 0)) return dm.div; + + // Round up + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + + BN.prototype.modrn = function modrn (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; + + assert(num <= 0x3ffffff); + var p = (1 << 26) % num; + + var acc = 0; + for (var i = this.length - 1; i >= 0; i--) { + acc = (p * acc + (this.words[i] | 0)) % num; + } + + return isNegNum ? -acc : acc; + }; + + // WARNING: DEPRECATED + BN.prototype.modn = function modn (num) { + return this.modrn(num); + }; + + // In-place division by number + BN.prototype.idivn = function idivn (num) { + var isNegNum = num < 0; + if (isNegNum) num = -num; + + assert(num <= 0x3ffffff); + + var carry = 0; + for (var i = this.length - 1; i >= 0; i--) { + var w = (this.words[i] | 0) + carry * 0x4000000; + this.words[i] = (w / num) | 0; + carry = w % num; + } + + this._strip(); + return isNegNum ? this.ineg() : this; + }; + + BN.prototype.divn = function divn (num) { + return this.clone().idivn(num); + }; + + BN.prototype.egcd = function egcd (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var x = this; + var y = p.clone(); + + if (x.negative !== 0) { + x = x.umod(p); + } else { + x = x.clone(); + } + + // A * x + B * y = x + var A = new BN(1); + var B = new BN(0); + + // C * x + D * y = y + var C = new BN(0); + var D = new BN(1); + + var g = 0; + + while (x.isEven() && y.isEven()) { + x.iushrn(1); + y.iushrn(1); + ++g; + } + + var yp = y.clone(); + var xp = x.clone(); + + while (!x.isZero()) { + for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + x.iushrn(i); + while (i-- > 0) { + if (A.isOdd() || B.isOdd()) { + A.iadd(yp); + B.isub(xp); + } + + A.iushrn(1); + B.iushrn(1); + } + } + + for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + y.iushrn(j); + while (j-- > 0) { + if (C.isOdd() || D.isOdd()) { + C.iadd(yp); + D.isub(xp); + } + + C.iushrn(1); + D.iushrn(1); + } + } + + if (x.cmp(y) >= 0) { + x.isub(y); + A.isub(C); + B.isub(D); + } else { + y.isub(x); + C.isub(A); + D.isub(B); + } + } + + return { + a: C, + b: D, + gcd: y.iushln(g) + }; + }; + + // This is reduced incarnation of the binary EEA + // above, designated to invert members of the + // _prime_ fields F(p) at a maximal speed + BN.prototype._invmp = function _invmp (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var a = this; + var b = p.clone(); + + if (a.negative !== 0) { + a = a.umod(p); + } else { + a = a.clone(); + } + + var x1 = new BN(1); + var x2 = new BN(0); + + var delta = b.clone(); + + while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { + for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + a.iushrn(i); + while (i-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + + x1.iushrn(1); + } + } + + for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + b.iushrn(j); + while (j-- > 0) { + if (x2.isOdd()) { + x2.iadd(delta); + } + + x2.iushrn(1); + } + } + + if (a.cmp(b) >= 0) { + a.isub(b); + x1.isub(x2); + } else { + b.isub(a); + x2.isub(x1); + } + } + + var res; + if (a.cmpn(1) === 0) { + res = x1; + } else { + res = x2; + } + + if (res.cmpn(0) < 0) { + res.iadd(p); + } + + return res; + }; + + BN.prototype.gcd = function gcd (num) { + if (this.isZero()) return num.abs(); + if (num.isZero()) return this.abs(); + + var a = this.clone(); + var b = num.clone(); + a.negative = 0; + b.negative = 0; + + // Remove common factor of two + for (var shift = 0; a.isEven() && b.isEven(); shift++) { + a.iushrn(1); + b.iushrn(1); + } + + do { + while (a.isEven()) { + a.iushrn(1); + } + while (b.isEven()) { + b.iushrn(1); + } + + var r = a.cmp(b); + if (r < 0) { + // Swap `a` and `b` to make `a` always bigger than `b` + var t = a; + a = b; + b = t; + } else if (r === 0 || b.cmpn(1) === 0) { + break; + } + + a.isub(b); + } while (true); + + return b.iushln(shift); + }; + + // Invert number in the field F(num) + BN.prototype.invm = function invm (num) { + return this.egcd(num).a.umod(num); + }; + + BN.prototype.isEven = function isEven () { + return (this.words[0] & 1) === 0; + }; + + BN.prototype.isOdd = function isOdd () { + return (this.words[0] & 1) === 1; + }; + + // And first word and num + BN.prototype.andln = function andln (num) { + return this.words[0] & num; + }; + + // Increment at the bit position in-line + BN.prototype.bincn = function bincn (bit) { + assert(typeof bit === 'number'); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) { + this._expand(s + 1); + this.words[s] |= q; + return this; + } + + // Add bit and propagate, if needed + var carry = q; + for (var i = s; carry !== 0 && i < this.length; i++) { + var w = this.words[i] | 0; + w += carry; + carry = w >>> 26; + w &= 0x3ffffff; + this.words[i] = w; + } + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + return this; + }; + + BN.prototype.isZero = function isZero () { + return this.length === 1 && this.words[0] === 0; + }; + + BN.prototype.cmpn = function cmpn (num) { + var negative = num < 0; + + if (this.negative !== 0 && !negative) return -1; + if (this.negative === 0 && negative) return 1; + + this._strip(); + + var res; + if (this.length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + + assert(num <= 0x3ffffff, 'Number is too big'); + + var w = this.words[0] | 0; + res = w === num ? 0 : w < num ? -1 : 1; + } + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Compare two numbers and return: + // 1 - if `this` > `num` + // 0 - if `this` == `num` + // -1 - if `this` < `num` + BN.prototype.cmp = function cmp (num) { + if (this.negative !== 0 && num.negative === 0) return -1; + if (this.negative === 0 && num.negative !== 0) return 1; + + var res = this.ucmp(num); + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Unsigned comparison + BN.prototype.ucmp = function ucmp (num) { + // At this point both numbers have the same sign + if (this.length > num.length) return 1; + if (this.length < num.length) return -1; + + var res = 0; + for (var i = this.length - 1; i >= 0; i--) { + var a = this.words[i] | 0; + var b = num.words[i] | 0; + + if (a === b) continue; + if (a < b) { + res = -1; + } else if (a > b) { + res = 1; + } + break; + } + return res; + }; + + BN.prototype.gtn = function gtn (num) { + return this.cmpn(num) === 1; + }; + + BN.prototype.gt = function gt (num) { + return this.cmp(num) === 1; + }; + + BN.prototype.gten = function gten (num) { + return this.cmpn(num) >= 0; + }; + + BN.prototype.gte = function gte (num) { + return this.cmp(num) >= 0; + }; + + BN.prototype.ltn = function ltn (num) { + return this.cmpn(num) === -1; + }; + + BN.prototype.lt = function lt (num) { + return this.cmp(num) === -1; + }; + + BN.prototype.lten = function lten (num) { + return this.cmpn(num) <= 0; + }; + + BN.prototype.lte = function lte (num) { + return this.cmp(num) <= 0; + }; + + BN.prototype.eqn = function eqn (num) { + return this.cmpn(num) === 0; + }; + + BN.prototype.eq = function eq (num) { + return this.cmp(num) === 0; + }; + + // + // A reduce context, could be using montgomery or something better, depending + // on the `m` itself. + // + BN.red = function red (num) { + return new Red(num); + }; + + BN.prototype.toRed = function toRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + assert(this.negative === 0, 'red works only with positives'); + return ctx.convertTo(this)._forceRed(ctx); + }; + + BN.prototype.fromRed = function fromRed () { + assert(this.red, 'fromRed works only with numbers in reduction context'); + return this.red.convertFrom(this); + }; + + BN.prototype._forceRed = function _forceRed (ctx) { + this.red = ctx; + return this; + }; + + BN.prototype.forceRed = function forceRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + return this._forceRed(ctx); + }; + + BN.prototype.redAdd = function redAdd (num) { + assert(this.red, 'redAdd works only with red numbers'); + return this.red.add(this, num); + }; + + BN.prototype.redIAdd = function redIAdd (num) { + assert(this.red, 'redIAdd works only with red numbers'); + return this.red.iadd(this, num); + }; + + BN.prototype.redSub = function redSub (num) { + assert(this.red, 'redSub works only with red numbers'); + return this.red.sub(this, num); + }; + + BN.prototype.redISub = function redISub (num) { + assert(this.red, 'redISub works only with red numbers'); + return this.red.isub(this, num); + }; + + BN.prototype.redShl = function redShl (num) { + assert(this.red, 'redShl works only with red numbers'); + return this.red.shl(this, num); + }; + + BN.prototype.redMul = function redMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.mul(this, num); + }; + + BN.prototype.redIMul = function redIMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.imul(this, num); + }; + + BN.prototype.redSqr = function redSqr () { + assert(this.red, 'redSqr works only with red numbers'); + this.red._verify1(this); + return this.red.sqr(this); + }; + + BN.prototype.redISqr = function redISqr () { + assert(this.red, 'redISqr works only with red numbers'); + this.red._verify1(this); + return this.red.isqr(this); + }; + + // Square root over p + BN.prototype.redSqrt = function redSqrt () { + assert(this.red, 'redSqrt works only with red numbers'); + this.red._verify1(this); + return this.red.sqrt(this); + }; + + BN.prototype.redInvm = function redInvm () { + assert(this.red, 'redInvm works only with red numbers'); + this.red._verify1(this); + return this.red.invm(this); + }; + + // Return negative clone of `this` % `red modulo` + BN.prototype.redNeg = function redNeg () { + assert(this.red, 'redNeg works only with red numbers'); + this.red._verify1(this); + return this.red.neg(this); + }; + + BN.prototype.redPow = function redPow (num) { + assert(this.red && !num.red, 'redPow(normalNum)'); + this.red._verify1(this); + return this.red.pow(this, num); + }; + + // Prime numbers with efficient reduction + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + + // Pseudo-Mersenne prime + function MPrime (name, p) { + // P = 2 ^ N - K + this.name = name; + this.p = new BN(p, 16); + this.n = this.p.bitLength(); + this.k = new BN(1).iushln(this.n).isub(this.p); + + this.tmp = this._tmp(); + } + + MPrime.prototype._tmp = function _tmp () { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil(this.n / 13)); + return tmp; + }; + + MPrime.prototype.ireduce = function ireduce (num) { + // Assumes that `num` is less than `P^2` + // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) + var r = num; + var rlen; + + do { + this.split(r, this.tmp); + r = this.imulK(r); + r = r.iadd(this.tmp); + rlen = r.bitLength(); + } while (rlen > this.n); + + var cmp = rlen < this.n ? -1 : r.ucmp(this.p); + if (cmp === 0) { + r.words[0] = 0; + r.length = 1; + } else if (cmp > 0) { + r.isub(this.p); + } else { + if (r.strip !== undefined) { + // r is a BN v4 instance + r.strip(); + } else { + // r is a BN v5 instance + r._strip(); + } + } + + return r; + }; + + MPrime.prototype.split = function split (input, out) { + input.iushrn(this.n, 0, out); + }; + + MPrime.prototype.imulK = function imulK (num) { + return num.imul(this.k); + }; + + function K256 () { + MPrime.call( + this, + 'k256', + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); + } + inherits(K256, MPrime); + + K256.prototype.split = function split (input, output) { + // 256 = 9 * 26 + 22 + var mask = 0x3fffff; + + var outLen = Math.min(input.length, 9); + for (var i = 0; i < outLen; i++) { + output.words[i] = input.words[i]; + } + output.length = outLen; + + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + + // Shift by 9 limbs + var prev = input.words[9]; + output.words[output.length++] = prev & mask; + + for (i = 10; i < input.length; i++) { + var next = input.words[i] | 0; + input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); + prev = next; + } + prev >>>= 22; + input.words[i - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + + K256.prototype.imulK = function imulK (num) { + // K = 0x1000003d1 = [ 0x40, 0x3d1 ] + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + + // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 + var lo = 0; + for (var i = 0; i < num.length; i++) { + var w = num.words[i] | 0; + lo += w * 0x3d1; + num.words[i] = lo & 0x3ffffff; + lo = w * 0x40 + ((lo / 0x4000000) | 0); + } + + // Fast length reduction + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + + function P224 () { + MPrime.call( + this, + 'p224', + 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + } + inherits(P224, MPrime); + + function P192 () { + MPrime.call( + this, + 'p192', + 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + } + inherits(P192, MPrime); + + function P25519 () { + // 2 ^ 255 - 19 + MPrime.call( + this, + '25519', + '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + } + inherits(P25519, MPrime); + + P25519.prototype.imulK = function imulK (num) { + // K = 0x13 + var carry = 0; + for (var i = 0; i < num.length; i++) { + var hi = (num.words[i] | 0) * 0x13 + carry; + var lo = hi & 0x3ffffff; + hi >>>= 26; + + num.words[i] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + + // Exported mostly for testing purposes, use plain name instead + BN._prime = function prime (name) { + // Cached version of prime + if (primes[name]) return primes[name]; + + var prime; + if (name === 'k256') { + prime = new K256(); + } else if (name === 'p224') { + prime = new P224(); + } else if (name === 'p192') { + prime = new P192(); + } else if (name === 'p25519') { + prime = new P25519(); + } else { + throw new Error('Unknown prime ' + name); + } + primes[name] = prime; + + return prime; + }; + + // + // Base reduction engine + // + function Red (m) { + if (typeof m === 'string') { + var prime = BN._prime(m); + this.m = prime.p; + this.prime = prime; + } else { + assert(m.gtn(1), 'modulus must be greater than 1'); + this.m = m; + this.prime = null; + } + } + + Red.prototype._verify1 = function _verify1 (a) { + assert(a.negative === 0, 'red works only with positives'); + assert(a.red, 'red works only with red numbers'); + }; + + Red.prototype._verify2 = function _verify2 (a, b) { + assert((a.negative | b.negative) === 0, 'red works only with positives'); + assert(a.red && a.red === b.red, + 'red works only with red numbers'); + }; + + Red.prototype.imod = function imod (a) { + if (this.prime) return this.prime.ireduce(a)._forceRed(this); + + move(a, a.umod(this.m)._forceRed(this)); + return a; + }; + + Red.prototype.neg = function neg (a) { + if (a.isZero()) { + return a.clone(); + } + + return this.m.sub(a)._forceRed(this); + }; + + Red.prototype.add = function add (a, b) { + this._verify2(a, b); + + var res = a.add(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.iadd = function iadd (a, b) { + this._verify2(a, b); + + var res = a.iadd(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res; + }; + + Red.prototype.sub = function sub (a, b) { + this._verify2(a, b); + + var res = a.sub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.isub = function isub (a, b) { + this._verify2(a, b); + + var res = a.isub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res; + }; + + Red.prototype.shl = function shl (a, num) { + this._verify1(a); + return this.imod(a.ushln(num)); + }; + + Red.prototype.imul = function imul (a, b) { + this._verify2(a, b); + return this.imod(a.imul(b)); + }; + + Red.prototype.mul = function mul (a, b) { + this._verify2(a, b); + return this.imod(a.mul(b)); + }; + + Red.prototype.isqr = function isqr (a) { + return this.imul(a, a.clone()); + }; + + Red.prototype.sqr = function sqr (a) { + return this.mul(a, a); + }; + + Red.prototype.sqrt = function sqrt (a) { + if (a.isZero()) return a.clone(); + + var mod3 = this.m.andln(3); + assert(mod3 % 2 === 1); + + // Fast case + if (mod3 === 3) { + var pow = this.m.add(new BN(1)).iushrn(2); + return this.pow(a, pow); + } + + // Tonelli-Shanks algorithm (Totally unoptimized and slow) + // + // Find Q and S, that Q * 2 ^ S = (P - 1) + var q = this.m.subn(1); + var s = 0; + while (!q.isZero() && q.andln(1) === 0) { + s++; + q.iushrn(1); + } + assert(!q.isZero()); + + var one = new BN(1).toRed(this); + var nOne = one.redNeg(); + + // Find quadratic non-residue + // NOTE: Max is such because of generalized Riemann hypothesis. + var lpow = this.m.subn(1).iushrn(1); + var z = this.m.bitLength(); + z = new BN(2 * z * z).toRed(this); + + while (this.pow(z, lpow).cmp(nOne) !== 0) { + z.redIAdd(nOne); + } + + var c = this.pow(z, q); + var r = this.pow(a, q.addn(1).iushrn(1)); + var t = this.pow(a, q); + var m = s; + while (t.cmp(one) !== 0) { + var tmp = t; + for (var i = 0; tmp.cmp(one) !== 0; i++) { + tmp = tmp.redSqr(); + } + assert(i < m); + var b = this.pow(c, new BN(1).iushln(m - i - 1)); + + r = r.redMul(b); + c = b.redSqr(); + t = t.redMul(c); + m = i; + } + + return r; + }; + + Red.prototype.invm = function invm (a) { + var inv = a._invmp(this.m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + + Red.prototype.pow = function pow (a, num) { + if (num.isZero()) return new BN(1).toRed(this); + if (num.cmpn(1) === 0) return a.clone(); + + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this); + wnd[1] = a; + for (var i = 2; i < wnd.length; i++) { + wnd[i] = this.mul(wnd[i - 1], a); + } + + var res = wnd[0]; + var current = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + + for (i = num.length - 1; i >= 0; i--) { + var word = num.words[i]; + for (var j = start - 1; j >= 0; j--) { + var bit = (word >> j) & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + + if (bit === 0 && current === 0) { + currentLen = 0; + continue; + } + + current <<= 1; + current |= bit; + currentLen++; + if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; + + res = this.mul(res, wnd[current]); + currentLen = 0; + current = 0; + } + start = 26; + } + + return res; + }; + + Red.prototype.convertTo = function convertTo (num) { + var r = num.umod(this.m); + + return r === num ? r.clone() : r; + }; + + Red.prototype.convertFrom = function convertFrom (num) { + var res = num.clone(); + res.red = null; + return res; + }; + + // + // Montgomery method engine + // + + BN.mont = function mont (num) { + return new Mont(num); + }; + + function Mont (m) { + Red.call(this, m); + + this.shift = this.m.bitLength(); + if (this.shift % 26 !== 0) { + this.shift += 26 - (this.shift % 26); + } + + this.r = new BN(1).iushln(this.shift); + this.r2 = this.imod(this.r.sqr()); + this.rinv = this.r._invmp(this.m); + + this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); + this.minv = this.minv.umod(this.r); + this.minv = this.r.sub(this.minv); + } + inherits(Mont, Red); + + Mont.prototype.convertTo = function convertTo (num) { + return this.imod(num.ushln(this.shift)); + }; + + Mont.prototype.convertFrom = function convertFrom (num) { + var r = this.imod(num.mul(this.rinv)); + r.red = null; + return r; + }; + + Mont.prototype.imul = function imul (a, b) { + if (a.isZero() || b.isZero()) { + a.words[0] = 0; + a.length = 1; + return a; + } + + var t = a.imul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.mul = function mul (a, b) { + if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); + + var t = a.mul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.invm = function invm (a) { + // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R + var res = this.imod(a._invmp(this.m).mul(this.r2)); + return res._forceRed(this); + }; + })(module, commonjsGlobal); +} (bn)); + +var bnExports = bn.exports; +var BN = /*@__PURE__*/getDefaultExportFromCjs(bnExports); + +BigInt.prototype.toJSON = function() { + return this.toString(); +}; +const isNode = !process.browser && typeof globalThis.window === "undefined"; +const chunk = (arr, size) => [...Array(Math.ceil(arr.length / size))].map((_, i) => arr.slice(size * i, size + size * i)); +function sleep$1(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} +function validateUrl(url, protocols) { + try { + const parsedUrl = new Url.URL(url); + if (protocols && protocols.length) { + return protocols.map((p) => p.toLowerCase()).includes(parsedUrl.protocol); + } + return true; + } catch (e) { + return false; + } +} +function bytesToHex(bytes) { + return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join(""); +} +function bytesToBN(bytes) { + return BigInt(bytesToHex(bytes)); +} +function bnToBytes(bigint) { + let hexString = typeof bigint === "bigint" ? bigint.toString(16) : bigint; + if (hexString.startsWith("0x")) { + hexString = hexString.replace("0x", ""); + } + if (hexString.length % 2 !== 0) { + hexString = "0" + hexString; + } + return Uint8Array.from(hexString.match(/.{1,2}/g).map((byte) => parseInt(byte, 16))); +} +function leBuff2Int(bytes) { + return new BN(bytes, 16, "le"); +} +function leInt2Buff$3(bigint) { + return Uint8Array.from(new BN(bigint).toArray("le", 31)); +} +function toFixedHex(numberish, length = 32) { + return "0x" + BigInt(numberish).toString(16).padStart(length * 2, "0"); +} +function rBigInt(nbytes = 31) { + return bytesToBN(crypto.getRandomValues(new Uint8Array(nbytes))); +} +function substring(str, length = 10) { + if (str.length < length * 2) { + return str; + } + return `${str.substring(0, length)}...${str.substring(str.length - length)}`; +} + +var __async$e = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +function multicall(Multicall2, calls) { + return __async$e(this, null, function* () { + const calldata = calls.map((call) => { + var _a, _b, _c; + const target = ((_a = call.contract) == null ? void 0 : _a.target) || call.address; + const callInterface = ((_b = call.contract) == null ? void 0 : _b.interface) || call.interface; + return { + target, + callData: callInterface.encodeFunctionData(call.name, call.params), + allowFailure: (_c = call.allowFailure) != null ? _c : false + }; + }); + const returnData = yield Multicall2.aggregate3.staticCall(calldata); + const res = returnData.map((call, i) => { + var _a; + const callInterface = ((_a = calls[i].contract) == null ? void 0 : _a.interface) || calls[i].interface; + const [result, data] = call; + const decodeResult = result && data && data !== "0x" ? callInterface.decodeFunctionResult(calls[i].name, data) : null; + return !decodeResult ? null : decodeResult.length === 1 ? decodeResult[0] : decodeResult; + }); + return res; + }); +} + +var __defProp$4 = Object.defineProperty; +var __defProps$4 = Object.defineProperties; +var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols; +var __getProtoOf$1 = Object.getPrototypeOf; +var __hasOwnProp$4 = Object.prototype.hasOwnProperty; +var __propIsEnum$4 = Object.prototype.propertyIsEnumerable; +var __reflectGet$1 = Reflect.get; +var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues$4 = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp$4.call(b, prop)) + __defNormalProp$4(a, prop, b[prop]); + if (__getOwnPropSymbols$4) + for (var prop of __getOwnPropSymbols$4(b)) { + if (__propIsEnum$4.call(b, prop)) + __defNormalProp$4(a, prop, b[prop]); + } + return a; +}; +var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b)); +var __superGet$1 = (cls, obj, key) => __reflectGet$1(__getProtoOf$1(cls), key, obj); +var __async$d = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +const defaultUserAgent = "Mozilla/5.0 (Windows NT 10.0; rv:109.0) Gecko/20100101 Firefox/115.0"; +const fetch$1 = crossFetch; +function getHttpAgent({ + fetchUrl, + proxyUrl, + torPort, + retry +}) { + if (torPort) { + return new SocksProxyAgent_1(`socks5h://tor${retry}@127.0.0.1:${torPort}`); + } + if (!proxyUrl) { + return; + } + const isHttps = fetchUrl.includes("https://"); + if (proxyUrl.includes("socks://") || proxyUrl.includes("socks4://") || proxyUrl.includes("socks5://")) { + return new SocksProxyAgent_1(proxyUrl); + } + if (proxyUrl.includes("http://") || proxyUrl.includes("https://")) { + if (isHttps) { + return new HttpsProxyAgent_1(proxyUrl); + } + return new HttpProxyAgent_1(proxyUrl); + } +} +function fetchData(_0) { + return __async$d(this, arguments, function* (url, options = {}) { + var _a, _b, _c; + const MAX_RETRY = (_a = options.maxRetry) != null ? _a : 3; + const RETRY_ON = (_b = options.retryOn) != null ? _b : 500; + const userAgent = (_c = options.userAgent) != null ? _c : defaultUserAgent; + let retry = 0; + let errorObject; + if (!options.method) { + if (!options.body) { + options.method = "GET"; + } else { + options.method = "POST"; + } + } + if (!options.headers) { + options.headers = {}; + } + if (isNode && !options.headers["User-Agent"]) { + options.headers["User-Agent"] = userAgent; + } + while (retry < MAX_RETRY + 1) { + let timeout; + if (!options.signal && options.timeout) { + const controller = new AbortController(); + options.signal = controller.signal; + timeout = setTimeout(() => { + controller.abort(); + }, options.timeout); + } + if (!options.agent && isNode && (options.proxy || options.torPort)) { + options.agent = getHttpAgent({ + fetchUrl: url, + proxyUrl: options.proxy, + torPort: options.torPort, + retry + }); + } + if (options.debug && typeof options.debug === "function") { + options.debug("request", { + url, + retry, + errorObject, + options + }); + } + try { + const resp = yield fetch$1(url, { + method: options.method, + headers: options.headers, + body: options.body, + redirect: options.redirect, + signal: options.signal, + agent: options.agent + }); + if (options.debug && typeof options.debug === "function") { + options.debug("response", resp); + } + if (!resp.ok) { + const errMsg = `Request to ${url} failed with error code ${resp.status}: +` + (yield resp.text()); + throw new Error(errMsg); + } + if (options.returnResponse) { + return resp; + } + const contentType = resp.headers.get("content-type"); + if (contentType == null ? void 0 : contentType.includes("application/json")) { + return yield resp.json(); + } + if (contentType == null ? void 0 : contentType.includes("text")) { + return yield resp.text(); + } + return resp; + } catch (error) { + if (timeout) { + clearTimeout(timeout); + } + errorObject = error; + retry++; + yield sleep$1(RETRY_ON); + } finally { + if (timeout) { + clearTimeout(timeout); + } + } + } + if (options.debug && typeof options.debug === "function") { + options.debug("error", errorObject); + } + throw errorObject; + }); +} +const fetchGetUrlFunc = (options = {}) => (req, _signal) => __async$d(void 0, null, function* () { + let signal; + if (_signal) { + const controller = new AbortController(); + signal = controller.signal; + _signal.addListener(() => { + controller.abort(); + }); + } + const init = __spreadProps$4(__spreadValues$4({}, options), { + method: req.method || "POST", + headers: req.headers, + body: req.body || void 0, + signal, + returnResponse: true + }); + const resp = yield fetchData(req.url, init); + const headers = {}; + resp.headers.forEach((value, key) => { + headers[key.toLowerCase()] = value; + }); + const respBody = yield resp.arrayBuffer(); + const body = respBody == null ? null : new Uint8Array(respBody); + return { + statusCode: resp.status, + statusMessage: resp.statusText, + headers, + body + }; +}); +const oracleMapper = /* @__PURE__ */ new Map(); +const multicallMapper = /* @__PURE__ */ new Map(); +function getGasOraclePlugin(networkKey, fetchOptions) { + const gasStationApi = (fetchOptions == null ? void 0 : fetchOptions.gasStationApi) || "https://gasstation.polygon.technology/v2"; + return new FetchUrlFeeDataNetworkPlugin(gasStationApi, (fetchFeeData, provider, request) => __async$d(this, null, function* () { + if (!oracleMapper.has(networkKey)) { + oracleMapper.set(networkKey, GasPriceOracle__factory.connect(fetchOptions == null ? void 0 : fetchOptions.gasPriceOracle, provider)); + } + if (!multicallMapper.has(networkKey)) { + multicallMapper.set( + networkKey, + Multicall__factory.connect("0xcA11bde05977b3631167028862bE2a173976CA11", provider) + ); + } + const Oracle = oracleMapper.get(networkKey); + const Multicall2 = multicallMapper.get(networkKey); + const [timestamp, heartbeat, feePerGas, priorityFeePerGas] = yield multicall(Multicall2, [ + { + contract: Oracle, + name: "timestamp" + }, + { + contract: Oracle, + name: "heartbeat" + }, + { + contract: Oracle, + name: "maxFeePerGas" + }, + { + contract: Oracle, + name: "maxPriorityFeePerGas" + } + ]); + const isOutdated = Number(timestamp) <= Date.now() / 1e3 - Number(heartbeat); + if (!isOutdated) { + const maxPriorityFeePerGas = priorityFeePerGas * BigInt(13) / BigInt(10); + const maxFeePerGas = feePerGas * BigInt(2) + maxPriorityFeePerGas; + return { + gasPrice: maxFeePerGas, + maxFeePerGas, + maxPriorityFeePerGas + }; + } + const fetchReq = new FetchRequest(gasStationApi); + fetchReq.getUrlFunc = fetchGetUrlFunc(fetchOptions); + if (isNode) { + fetchReq.setHeader("User-Agent", "ethers"); + } + const [ + { + bodyJson: { fast } + }, + { gasPrice } + ] = yield Promise.all([fetchReq.send(), fetchFeeData()]); + return { + gasPrice, + maxFeePerGas: parseUnits$1(`${fast.maxFee}`, 9), + maxPriorityFeePerGas: parseUnits$1(`${fast.maxPriorityFee}`, 9) + }; + })); +} +function getProviderWithNetId(netId, rpcUrl, config, fetchOptions) { + const { networkName, reverseRecordsContract, gasPriceOracleContract, gasStationApi, pollInterval } = config; + const hasEns = Boolean(reverseRecordsContract); + const fetchReq = new FetchRequest(rpcUrl); + fetchReq.getUrlFunc = fetchGetUrlFunc(fetchOptions); + const staticNetwork = new Network(networkName, netId); + if (hasEns) { + staticNetwork.attachPlugin(new EnsPlugin(null, Number(netId))); + } + staticNetwork.attachPlugin(new GasCostPlugin()); + if (gasPriceOracleContract) { + staticNetwork.attachPlugin( + getGasOraclePlugin(`${netId}_${rpcUrl}`, { + gasPriceOracle: gasPriceOracleContract, + gasStationApi + }) + ); + } + const provider = new JsonRpcProvider(fetchReq, staticNetwork, { + staticNetwork + }); + provider.pollingInterval = (fetchOptions == null ? void 0 : fetchOptions.pollingInterval) || pollInterval * 1e3; + return provider; +} +const populateTransaction = (signer, tx) => __async$d(void 0, null, function* () { + const provider = signer.provider; + if (!tx.from) { + tx.from = signer.address; + } else if (tx.from !== signer.address) { + const errMsg = `populateTransaction: signer mismatch for tx, wants ${tx.from} have ${signer.address}`; + throw new Error(errMsg); + } + const [feeData, nonce] = yield Promise.all([ + (() => __async$d(void 0, null, function* () { + if (tx.maxFeePerGas && tx.maxPriorityFeePerGas) { + return new FeeData(null, BigInt(tx.maxFeePerGas), BigInt(tx.maxPriorityFeePerGas)); + } + if (tx.gasPrice) { + return new FeeData(BigInt(tx.gasPrice), null, null); + } + const fetchedFeeData = yield provider.getFeeData(); + if (fetchedFeeData.maxFeePerGas && fetchedFeeData.maxPriorityFeePerGas) { + return new FeeData( + null, + fetchedFeeData.maxFeePerGas * (BigInt(1e4) + BigInt(signer.gasPriceBump)) / BigInt(1e4), + fetchedFeeData.maxPriorityFeePerGas + ); + } else { + return new FeeData( + fetchedFeeData.gasPrice * (BigInt(1e4) + BigInt(signer.gasPriceBump)) / BigInt(1e4), + null, + null + ); + } + }))(), + (() => __async$d(void 0, null, function* () { + if (tx.nonce) { + return tx.nonce; + } + let fetchedNonce = yield provider.getTransactionCount(signer.address, "pending"); + if (signer.bumpNonce && signer.nonce && signer.nonce >= fetchedNonce) { + console.log( + `populateTransaction: bumping nonce from ${fetchedNonce} to ${fetchedNonce + 1} for ${signer.address}` + ); + fetchedNonce++; + } + return fetchedNonce; + }))() + ]); + tx.nonce = nonce; + if (feeData.maxFeePerGas && feeData.maxPriorityFeePerGas) { + tx.maxFeePerGas = feeData.maxFeePerGas; + tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; + if (!tx.type) { + tx.type = 2; + } + delete tx.gasPrice; + } else if (feeData.gasPrice) { + tx.gasPrice = feeData.gasPrice; + if (!tx.type) { + tx.type = 0; + } + delete tx.maxFeePerGas; + delete tx.maxPriorityFeePerGas; + } + tx.gasLimit = tx.gasLimit || (yield (() => __async$d(void 0, null, function* () { + try { + const gasLimit = yield provider.estimateGas(tx); + return gasLimit === BigInt(21e3) ? gasLimit : gasLimit * (BigInt(1e4) + BigInt(signer.gasLimitBump)) / BigInt(1e4); + } catch (err) { + if (signer.gasFailover) { + console.log("populateTransaction: warning gas estimation failed falling back to 3M gas"); + return BigInt("3000000"); + } + throw err; + } + }))()); + return tx; +}); +class TornadoWallet extends Wallet { + constructor(key, provider, { gasPriceBump, gasLimitBump, gasFailover, bumpNonce } = {}) { + super(key, provider); + this.gasPriceBump = gasPriceBump != null ? gasPriceBump : 1e3; + this.gasLimitBump = gasLimitBump != null ? gasLimitBump : 3e3; + this.gasFailover = gasFailover != null ? gasFailover : false; + this.bumpNonce = bumpNonce != null ? bumpNonce : false; + } + static fromMnemonic(mneomnic, provider, index = 0, options) { + const defaultPath = `m/44'/60'/0'/0/${index}`; + const { privateKey } = HDNodeWallet.fromPhrase(mneomnic, void 0, defaultPath); + return new TornadoWallet(privateKey, provider, options); + } + populateTransaction(tx) { + return __async$d(this, null, function* () { + const txObject = yield populateTransaction(this, tx); + this.nonce = txObject.nonce; + return __superGet$1(TornadoWallet.prototype, this, "populateTransaction").call(this, txObject); + }); + } +} +class TornadoVoidSigner extends VoidSigner { + constructor(address, provider, { gasPriceBump, gasLimitBump, gasFailover, bumpNonce } = {}) { + super(address, provider); + this.gasPriceBump = gasPriceBump != null ? gasPriceBump : 1e3; + this.gasLimitBump = gasLimitBump != null ? gasLimitBump : 3e3; + this.gasFailover = gasFailover != null ? gasFailover : false; + this.bumpNonce = bumpNonce != null ? bumpNonce : false; + } + populateTransaction(tx) { + return __async$d(this, null, function* () { + const txObject = yield populateTransaction(this, tx); + this.nonce = txObject.nonce; + return __superGet$1(TornadoVoidSigner.prototype, this, "populateTransaction").call(this, txObject); + }); + } +} + +const GET_STATISTIC = ` + query getStatistic($currency: String!, $amount: String!, $first: Int, $orderBy: BigInt, $orderDirection: String) { + deposits(first: $first, orderBy: $orderBy, orderDirection: $orderDirection, where: { currency: $currency, amount: $amount }) { + index + timestamp + blockNumber + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const _META = ` + query getMeta { + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const GET_REGISTERED = ` + query getRegistered($first: Int, $fromBlock: Int) { + relayers(first: $first, orderBy: blockRegistration, orderDirection: asc, where: { + blockRegistration_gte: $fromBlock + }) { + id + address + ensName + blockRegistration + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const GET_DEPOSITS = ` + query getDeposits($currency: String!, $amount: String!, $first: Int, $fromBlock: Int) { + deposits(first: $first, orderBy: index, orderDirection: asc, where: { + amount: $amount, + currency: $currency, + blockNumber_gte: $fromBlock + }) { + id + blockNumber + commitment + index + timestamp + from + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const GET_WITHDRAWALS = ` + query getWithdrawals($currency: String!, $amount: String!, $first: Int, $fromBlock: Int!) { + withdrawals(first: $first, orderBy: blockNumber, orderDirection: asc, where: { + currency: $currency, + amount: $amount, + blockNumber_gte: $fromBlock + }) { + id + blockNumber + nullifier + to + fee + timestamp + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const GET_NOTE_ACCOUNTS = ` + query getNoteAccount($address: String!) { + noteAccounts(where: { address: $address }) { + id + index + address + encryptedAccount + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const GET_ENCRYPTED_NOTES = ` + query getEncryptedNotes($first: Int, $fromBlock: Int) { + encryptedNotes(first: $first, orderBy: blockNumber, orderDirection: asc, where: { blockNumber_gte: $fromBlock }) { + blockNumber + index + transactionHash + encryptedNote + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; + +var __defProp$3 = Object.defineProperty; +var __defProps$3 = Object.defineProperties; +var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols; +var __hasOwnProp$3 = Object.prototype.hasOwnProperty; +var __propIsEnum$3 = Object.prototype.propertyIsEnumerable; +var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues$3 = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp$3.call(b, prop)) + __defNormalProp$3(a, prop, b[prop]); + if (__getOwnPropSymbols$3) + for (var prop of __getOwnPropSymbols$3(b)) { + if (__propIsEnum$3.call(b, prop)) + __defNormalProp$3(a, prop, b[prop]); + } + return a; +}; +var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b)); +var __async$c = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +const isEmptyArray = (arr) => !Array.isArray(arr) || !arr.length; +const first = 1e3; +function queryGraph(_0) { + return __async$c(this, arguments, function* ({ + graphApi, + subgraphName, + query, + variables, + fetchDataOptions: fetchDataOptions2 + }) { + var _a; + const graphUrl = `${graphApi}/subgraphs/name/${subgraphName}`; + const { data, errors } = yield fetchData(graphUrl, __spreadProps$3(__spreadValues$3({}, fetchDataOptions2), { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + query, + variables + }) + })); + if (errors) { + throw new Error(JSON.stringify(errors)); + } + if ((_a = data == null ? void 0 : data._meta) == null ? void 0 : _a.hasIndexingErrors) { + throw new Error("Subgraph has indexing errors"); + } + return data; + }); +} +function getStatistic(_0) { + return __async$c(this, arguments, function* ({ + graphApi, + subgraphName, + currency, + amount, + fetchDataOptions: fetchDataOptions2 + }) { + try { + const { + deposits, + _meta: { + block: { number: lastSyncBlock } + } + } = yield queryGraph({ + graphApi, + subgraphName, + query: GET_STATISTIC, + variables: { + currency, + first: 10, + orderBy: "index", + orderDirection: "desc", + amount + }, + fetchDataOptions: fetchDataOptions2 + }); + const events = deposits.map((e) => ({ + timestamp: Number(e.timestamp), + leafIndex: Number(e.index), + blockNumber: Number(e.blockNumber) + })).reverse(); + const [lastEvent] = events.slice(-1); + return { + events, + lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock + }; + } catch (err) { + console.log("Error from getStatistic query"); + console.log(err); + return { + events: [], + lastSyncBlock: null + }; + } + }); +} +function getMeta(_0) { + return __async$c(this, arguments, function* ({ graphApi, subgraphName, fetchDataOptions: fetchDataOptions2 }) { + try { + const { + _meta: { + block: { number: lastSyncBlock }, + hasIndexingErrors + } + } = yield queryGraph({ + graphApi, + subgraphName, + query: _META, + fetchDataOptions: fetchDataOptions2 + }); + return { + lastSyncBlock, + hasIndexingErrors + }; + } catch (err) { + console.log("Error from getMeta query"); + console.log(err); + return { + lastSyncBlock: null, + hasIndexingErrors: null + }; + } + }); +} +function getRegisters({ + graphApi, + subgraphName, + fromBlock, + fetchDataOptions: fetchDataOptions2 +}) { + return queryGraph({ + graphApi, + subgraphName, + query: GET_REGISTERED, + variables: { + first, + fromBlock + }, + fetchDataOptions: fetchDataOptions2 + }); +} +function getAllRegisters(_0) { + return __async$c(this, arguments, function* ({ + graphApi, + subgraphName, + fromBlock, + fetchDataOptions: fetchDataOptions2, + onProgress + }) { + try { + const events = []; + let lastSyncBlock = fromBlock; + while (true) { + let { + relayers: result2, + _meta: { + // eslint-disable-next-line prefer-const + block: { number: currentBlock } + } + } = yield getRegisters({ graphApi, subgraphName, fromBlock, fetchDataOptions: fetchDataOptions2 }); + lastSyncBlock = currentBlock; + if (isEmptyArray(result2)) { + break; + } + const [firstEvent] = result2; + const [lastEvent] = result2.slice(-1); + if (typeof onProgress === "function") { + onProgress({ + type: "Registers", + fromBlock: Number(firstEvent.blockRegistration), + toBlock: Number(lastEvent.blockRegistration), + count: result2.length + }); + } + if (result2.length < 900) { + events.push(...result2); + break; + } + result2 = result2.filter(({ blockRegistration }) => blockRegistration !== lastEvent.blockRegistration); + fromBlock = Number(lastEvent.blockRegistration); + events.push(...result2); + } + if (!events.length) { + return { + events: [], + lastSyncBlock + }; + } + const result = events.map(({ id, address, ensName, blockRegistration }) => { + const [transactionHash, logIndex] = id.split("-"); + return { + blockNumber: Number(blockRegistration), + logIndex: Number(logIndex), + transactionHash, + ensName, + relayerAddress: getAddress(address) + }; + }); + return { + events: result, + lastSyncBlock + }; + } catch (err) { + console.log("Error from getAllRegisters query"); + console.log(err); + return { events: [], lastSyncBlock: fromBlock }; + } + }); +} +function getDeposits({ + graphApi, + subgraphName, + currency, + amount, + fromBlock, + fetchDataOptions: fetchDataOptions2 +}) { + return queryGraph({ + graphApi, + subgraphName, + query: GET_DEPOSITS, + variables: { + currency, + amount, + first, + fromBlock + }, + fetchDataOptions: fetchDataOptions2 + }); +} +function getAllDeposits(_0) { + return __async$c(this, arguments, function* ({ + graphApi, + subgraphName, + currency, + amount, + fromBlock, + fetchDataOptions: fetchDataOptions2, + onProgress + }) { + try { + const events = []; + let lastSyncBlock = fromBlock; + while (true) { + let { + deposits: result2, + _meta: { + // eslint-disable-next-line prefer-const + block: { number: currentBlock } + } + } = yield getDeposits({ graphApi, subgraphName, currency, amount, fromBlock, fetchDataOptions: fetchDataOptions2 }); + lastSyncBlock = currentBlock; + if (isEmptyArray(result2)) { + break; + } + const [firstEvent] = result2; + const [lastEvent2] = result2.slice(-1); + if (typeof onProgress === "function") { + onProgress({ + type: "Deposits", + fromBlock: Number(firstEvent.blockNumber), + toBlock: Number(lastEvent2.blockNumber), + count: result2.length + }); + } + if (result2.length < 900) { + events.push(...result2); + break; + } + result2 = result2.filter(({ blockNumber }) => blockNumber !== lastEvent2.blockNumber); + fromBlock = Number(lastEvent2.blockNumber); + events.push(...result2); + } + if (!events.length) { + return { + events: [], + lastSyncBlock + }; + } + const result = events.map(({ id, blockNumber, commitment, index, timestamp, from }) => { + const [transactionHash, logIndex] = id.split("-"); + return { + blockNumber: Number(blockNumber), + logIndex: Number(logIndex), + transactionHash, + commitment, + leafIndex: Number(index), + timestamp: Number(timestamp), + from: getAddress(from) + }; + }); + const [lastEvent] = result.slice(-1); + return { + events: result, + lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock + }; + } catch (err) { + console.log("Error from getAllDeposits query"); + console.log(err); + return { + events: [], + lastSyncBlock: fromBlock + }; + } + }); +} +function getWithdrawals({ + graphApi, + subgraphName, + currency, + amount, + fromBlock, + fetchDataOptions: fetchDataOptions2 +}) { + return queryGraph({ + graphApi, + subgraphName, + query: GET_WITHDRAWALS, + variables: { + currency, + amount, + first, + fromBlock + }, + fetchDataOptions: fetchDataOptions2 + }); +} +function getAllWithdrawals(_0) { + return __async$c(this, arguments, function* ({ + graphApi, + subgraphName, + currency, + amount, + fromBlock, + fetchDataOptions: fetchDataOptions2, + onProgress + }) { + try { + const events = []; + let lastSyncBlock = fromBlock; + while (true) { + let { + withdrawals: result2, + _meta: { + // eslint-disable-next-line prefer-const + block: { number: currentBlock } + } + } = yield getWithdrawals({ graphApi, subgraphName, currency, amount, fromBlock, fetchDataOptions: fetchDataOptions2 }); + lastSyncBlock = currentBlock; + if (isEmptyArray(result2)) { + break; + } + const [firstEvent] = result2; + const [lastEvent2] = result2.slice(-1); + if (typeof onProgress === "function") { + onProgress({ + type: "Withdrawals", + fromBlock: Number(firstEvent.blockNumber), + toBlock: Number(lastEvent2.blockNumber), + count: result2.length + }); + } + if (result2.length < 900) { + events.push(...result2); + break; + } + result2 = result2.filter(({ blockNumber }) => blockNumber !== lastEvent2.blockNumber); + fromBlock = Number(lastEvent2.blockNumber); + events.push(...result2); + } + if (!events.length) { + return { + events: [], + lastSyncBlock + }; + } + const result = events.map(({ id, blockNumber, nullifier, to, fee, timestamp }) => { + const [transactionHash, logIndex] = id.split("-"); + return { + blockNumber: Number(blockNumber), + logIndex: Number(logIndex), + transactionHash, + nullifierHash: nullifier, + to: getAddress(to), + fee, + timestamp: Number(timestamp) + }; + }); + const [lastEvent] = result.slice(-1); + return { + events: result, + lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock + }; + } catch (err) { + console.log("Error from getAllWithdrawals query"); + console.log(err); + return { + events: [], + lastSyncBlock: fromBlock + }; + } + }); +} +function getNoteAccounts(_0) { + return __async$c(this, arguments, function* ({ + graphApi, + subgraphName, + address, + fetchDataOptions: fetchDataOptions2 + }) { + try { + const { + noteAccounts: events, + _meta: { + block: { number: lastSyncBlock } + } + } = yield queryGraph({ + graphApi, + subgraphName, + query: GET_NOTE_ACCOUNTS, + variables: { + address + }, + fetchDataOptions: fetchDataOptions2 + }); + return { + events, + lastSyncBlock + }; + } catch (err) { + console.log("Error from getNoteAccounts query"); + console.log(err); + return { + events: [], + lastSyncBlock: null + }; + } + }); +} +function getEncryptedNotes({ + graphApi, + subgraphName, + fromBlock, + fetchDataOptions: fetchDataOptions2 +}) { + return queryGraph({ + graphApi, + subgraphName, + query: GET_ENCRYPTED_NOTES, + variables: { + first, + fromBlock + }, + fetchDataOptions: fetchDataOptions2 + }); +} +function getAllEncryptedNotes(_0) { + return __async$c(this, arguments, function* ({ + graphApi, + subgraphName, + fromBlock, + fetchDataOptions: fetchDataOptions2, + onProgress + }) { + try { + const events = []; + let lastSyncBlock = fromBlock; + while (true) { + let { + encryptedNotes: result2, + _meta: { + // eslint-disable-next-line prefer-const + block: { number: currentBlock } + } + } = yield getEncryptedNotes({ graphApi, subgraphName, fromBlock, fetchDataOptions: fetchDataOptions2 }); + lastSyncBlock = currentBlock; + if (isEmptyArray(result2)) { + break; + } + const [firstEvent] = result2; + const [lastEvent2] = result2.slice(-1); + if (typeof onProgress === "function") { + onProgress({ + type: "EncryptedNotes", + fromBlock: Number(firstEvent.blockNumber), + toBlock: Number(lastEvent2.blockNumber), + count: result2.length + }); + } + if (result2.length < 900) { + events.push(...result2); + break; + } + result2 = result2.filter(({ blockNumber }) => blockNumber !== lastEvent2.blockNumber); + fromBlock = Number(lastEvent2.blockNumber); + events.push(...result2); + } + if (!events.length) { + return { + events: [], + lastSyncBlock + }; + } + const result = events.map((e) => ({ + blockNumber: Number(e.blockNumber), + logIndex: Number(e.index), + transactionHash: e.transactionHash, + encryptedNote: e.encryptedNote + })); + const [lastEvent] = result.slice(-1); + return { + events: result, + lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock + }; + } catch (err) { + console.log("Error from getAllEncryptedNotes query"); + console.log(err); + return { + events: [], + lastSyncBlock: fromBlock + }; + } + }); +} + +var graph = /*#__PURE__*/Object.freeze({ + __proto__: null, + GET_DEPOSITS: GET_DEPOSITS, + GET_ENCRYPTED_NOTES: GET_ENCRYPTED_NOTES, + GET_NOTE_ACCOUNTS: GET_NOTE_ACCOUNTS, + GET_REGISTERED: GET_REGISTERED, + GET_STATISTIC: GET_STATISTIC, + GET_WITHDRAWALS: GET_WITHDRAWALS, + _META: _META, + getAllDeposits: getAllDeposits, + getAllEncryptedNotes: getAllEncryptedNotes, + getAllRegisters: getAllRegisters, + getAllWithdrawals: getAllWithdrawals, + getDeposits: getDeposits, + getEncryptedNotes: getEncryptedNotes, + getMeta: getMeta, + getNoteAccounts: getNoteAccounts, + getRegisters: getRegisters, + getStatistic: getStatistic, + getWithdrawals: getWithdrawals, + queryGraph: queryGraph +}); + +var __async$b = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +class BatchBlockService { + constructor({ + provider, + onProgress, + concurrencySize = 10, + batchSize = 10, + shouldRetry = true, + retryMax = 5, + retryOn = 500 + }) { + this.provider = provider; + this.onProgress = onProgress; + this.concurrencySize = concurrencySize; + this.batchSize = batchSize; + this.shouldRetry = shouldRetry; + this.retryMax = retryMax; + this.retryOn = retryOn; + } + getBlock(blockTag) { + return __async$b(this, null, function* () { + const blockObject = yield this.provider.getBlock(blockTag); + if (!blockObject) { + const errMsg = `No block for ${blockTag}`; + throw new Error(errMsg); + } + return blockObject; + }); + } + createBatchRequest(batchArray) { + return batchArray.map((blocks, index) => __async$b(this, null, function* () { + yield sleep$1(20 * index); + return (() => __async$b(this, null, function* () { + let retries = 0; + let err; + while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) { + try { + return yield Promise.all(blocks.map((b) => this.getBlock(b))); + } catch (e) { + retries++; + err = e; + yield sleep$1(this.retryOn); + } + } + throw err; + }))(); + })); + } + getBatchBlocks(blocks) { + return __async$b(this, null, function* () { + let blockCount = 0; + const results = []; + for (const chunks of chunk(blocks, this.concurrencySize * this.batchSize)) { + const chunksResult = (yield Promise.all(this.createBatchRequest(chunk(chunks, this.batchSize)))).flat(); + results.push(...chunksResult); + blockCount += chunks.length; + if (typeof this.onProgress === "function") { + this.onProgress({ + percentage: blockCount / blocks.length, + currentIndex: blockCount, + totalIndex: blocks.length + }); + } + } + return results; + }); + } +} +class BatchTransactionService { + constructor({ + provider, + onProgress, + concurrencySize = 10, + batchSize = 10, + shouldRetry = true, + retryMax = 5, + retryOn = 500 + }) { + this.provider = provider; + this.onProgress = onProgress; + this.concurrencySize = concurrencySize; + this.batchSize = batchSize; + this.shouldRetry = shouldRetry; + this.retryMax = retryMax; + this.retryOn = retryOn; + } + getTransaction(txHash) { + return __async$b(this, null, function* () { + const txObject = yield this.provider.getTransaction(txHash); + if (!txObject) { + const errMsg = `No transaction for ${txHash}`; + throw new Error(errMsg); + } + return txObject; + }); + } + createBatchRequest(batchArray) { + return batchArray.map((txs, index) => __async$b(this, null, function* () { + yield sleep$1(20 * index); + return (() => __async$b(this, null, function* () { + let retries = 0; + let err; + while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) { + try { + return yield Promise.all(txs.map((tx) => this.getTransaction(tx))); + } catch (e) { + retries++; + err = e; + yield sleep$1(this.retryOn); + } + } + throw err; + }))(); + })); + } + getBatchTransactions(txs) { + return __async$b(this, null, function* () { + let txCount = 0; + const results = []; + for (const chunks of chunk(txs, this.concurrencySize * this.batchSize)) { + const chunksResult = (yield Promise.all(this.createBatchRequest(chunk(chunks, this.batchSize)))).flat(); + results.push(...chunksResult); + txCount += chunks.length; + if (typeof this.onProgress === "function") { + this.onProgress({ percentage: txCount / txs.length, currentIndex: txCount, totalIndex: txs.length }); + } + } + return results; + }); + } +} +class BatchEventsService { + constructor({ + provider, + contract, + onProgress, + concurrencySize = 10, + blocksPerRequest = 2e3, + shouldRetry = true, + retryMax = 5, + retryOn = 500 + }) { + this.provider = provider; + this.contract = contract; + this.onProgress = onProgress; + this.concurrencySize = concurrencySize; + this.blocksPerRequest = blocksPerRequest; + this.shouldRetry = shouldRetry; + this.retryMax = retryMax; + this.retryOn = retryOn; + } + getPastEvents(_0) { + return __async$b(this, arguments, function* ({ fromBlock, toBlock, type }) { + let err; + let retries = 0; + while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) { + try { + return yield this.contract.queryFilter(type, fromBlock, toBlock); + } catch (e) { + err = e; + retries++; + if (e.message.includes("after last accepted block")) { + const acceptedBlock = parseInt(e.message.split("after last accepted block ")[1]); + toBlock = acceptedBlock; + } + yield sleep$1(this.retryOn); + } + } + throw err; + }); + } + createBatchRequest(batchArray) { + return batchArray.map((event, index) => __async$b(this, null, function* () { + yield sleep$1(20 * index); + return this.getPastEvents(event); + })); + } + getBatchEvents(_0) { + return __async$b(this, arguments, function* ({ fromBlock, toBlock, type = "*" }) { + if (!toBlock) { + toBlock = yield this.provider.getBlockNumber(); + } + const eventsToSync = []; + for (let i = fromBlock; i < toBlock; i += this.blocksPerRequest) { + const j = i + this.blocksPerRequest - 1 > toBlock ? toBlock : i + this.blocksPerRequest - 1; + eventsToSync.push({ fromBlock: i, toBlock: j, type }); + } + const events = []; + const eventChunk = chunk(eventsToSync, this.concurrencySize); + let chunkCount = 0; + for (const chunk2 of eventChunk) { + chunkCount++; + const fetchedEvents = (yield Promise.all(this.createBatchRequest(chunk2))).flat(); + events.push(...fetchedEvents); + if (typeof this.onProgress === "function") { + this.onProgress({ + percentage: chunkCount / eventChunk.length, + type, + fromBlock: chunk2[0].fromBlock, + toBlock: chunk2[chunk2.length - 1].toBlock, + count: fetchedEvents.length + }); + } + } + return events; + }); + } +} + +var __defProp$2 = Object.defineProperty; +var __defProps$2 = Object.defineProperties; +var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp$2 = Object.prototype.hasOwnProperty; +var __propIsEnum$2 = Object.prototype.propertyIsEnumerable; +var __reflectGet = Reflect.get; +var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues$2 = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp$2.call(b, prop)) + __defNormalProp$2(a, prop, b[prop]); + if (__getOwnPropSymbols$2) + for (var prop of __getOwnPropSymbols$2(b)) { + if (__propIsEnum$2.call(b, prop)) + __defNormalProp$2(a, prop, b[prop]); + } + return a; +}; +var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b)); +var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj); +var __async$a = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +const DEPOSIT = "deposit"; +class BaseEventsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + contract, + type = "", + deployedBlock = 0, + fetchDataOptions: fetchDataOptions2 + }) { + this.netId = netId; + this.provider = provider; + this.graphApi = graphApi; + this.subgraphName = subgraphName; + this.fetchDataOptions = fetchDataOptions2; + this.contract = contract; + this.type = type; + this.deployedBlock = deployedBlock; + this.batchEventsService = new BatchEventsService({ + provider, + contract, + onProgress: this.updateEventProgress + }); + } + getInstanceName() { + return ""; + } + getType() { + return this.type || ""; + } + getGraphMethod() { + return ""; + } + getGraphParams() { + return { + graphApi: this.graphApi || "", + subgraphName: this.subgraphName || "", + fetchDataOptions: this.fetchDataOptions, + onProgress: this.updateGraphProgress + }; + } + /* eslint-disable @typescript-eslint/no-unused-vars */ + updateEventProgress({ percentage, type, fromBlock, toBlock, count }) { + } + updateBlockProgress({ percentage, currentIndex, totalIndex }) { + } + updateTransactionProgress({ percentage, currentIndex, totalIndex }) { + } + updateGraphProgress({ type, fromBlock, toBlock, count }) { + } + /* eslint-enable @typescript-eslint/no-unused-vars */ + formatEvents(events) { + return __async$a(this, null, function* () { + return yield new Promise((resolve) => resolve(events)); + }); + } + /** + * Get saved or cached events + */ + getEventsFromDB() { + return __async$a(this, null, function* () { + return { + events: [], + lastBlock: null + }; + }); + } + getEventsFromCache() { + return __async$a(this, null, function* () { + return { + events: [], + lastBlock: null + }; + }); + } + getSavedEvents() { + return __async$a(this, null, function* () { + let cachedEvents = yield this.getEventsFromDB(); + if (!cachedEvents || !cachedEvents.events.length) { + cachedEvents = yield this.getEventsFromCache(); + } + return cachedEvents; + }); + } + /** + * Get latest events + */ + getEventsFromGraph(_0) { + return __async$a(this, arguments, function* ({ + fromBlock, + methodName = "" + }) { + if (!this.graphApi || !this.subgraphName) { + return { + events: [], + lastBlock: fromBlock + }; + } + const { events, lastSyncBlock } = yield graph[methodName || this.getGraphMethod()](__spreadValues$2({ + fromBlock + }, this.getGraphParams())); + return { + events, + lastBlock: lastSyncBlock + }; + }); + } + getEventsFromRpc(_0) { + return __async$a(this, arguments, function* ({ + fromBlock, + toBlock + }) { + try { + if (!toBlock) { + toBlock = yield this.provider.getBlockNumber(); + } + if (fromBlock >= toBlock) { + return { + events: [], + lastBlock: toBlock + }; + } + this.updateEventProgress({ percentage: 0, type: this.getType() }); + const events = yield this.formatEvents( + yield this.batchEventsService.getBatchEvents({ fromBlock, toBlock, type: this.getType() }) + ); + if (!events.length) { + return { + events, + lastBlock: toBlock + }; + } + return { + events, + lastBlock: toBlock + }; + } catch (err) { + console.log(err); + return { + events: [], + lastBlock: fromBlock + }; + } + }); + } + getLatestEvents(_0) { + return __async$a(this, arguments, function* ({ fromBlock }) { + const allEvents = []; + const graphEvents = yield this.getEventsFromGraph({ fromBlock }); + const lastSyncBlock = graphEvents.lastBlock && graphEvents.lastBlock >= fromBlock ? graphEvents.lastBlock : fromBlock; + const rpcEvents = yield this.getEventsFromRpc({ fromBlock: lastSyncBlock }); + allEvents.push(...graphEvents.events); + allEvents.push(...rpcEvents.events); + const lastBlock = rpcEvents ? rpcEvents.lastBlock : allEvents[allEvents.length - 1] ? allEvents[allEvents.length - 1].blockNumber : fromBlock; + return { + events: allEvents, + lastBlock + }; + }); + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + validateEvents({ events, lastBlock }) { + } + /** + * Handle saving events + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + saveEvents(_0) { + return __async$a(this, arguments, function* ({ events, lastBlock }) { + }); + } + /** + * Trigger saving and receiving latest events + */ + updateEvents() { + return __async$a(this, null, function* () { + const savedEvents = yield this.getSavedEvents(); + let fromBlock = this.deployedBlock; + if (savedEvents && savedEvents.lastBlock) { + fromBlock = savedEvents.lastBlock + 1; + } + const newEvents = yield this.getLatestEvents({ fromBlock }); + const eventSet = /* @__PURE__ */ new Set(); + let allEvents = []; + allEvents.push(...savedEvents.events); + allEvents.push(...newEvents.events); + allEvents = allEvents.sort((a, b) => { + if (a.blockNumber === b.blockNumber) { + return a.logIndex - b.logIndex; + } + return a.blockNumber - b.blockNumber; + }).filter(({ transactionHash, logIndex }) => { + const eventKey = `${transactionHash}_${logIndex}`; + const hasEvent = eventSet.has(eventKey); + eventSet.add(eventKey); + return !hasEvent; + }); + const lastBlock = newEvents ? newEvents.lastBlock : allEvents[allEvents.length - 1] ? allEvents[allEvents.length - 1].blockNumber : null; + this.validateEvents({ events: allEvents, lastBlock }); + yield this.saveEvents({ events: allEvents, lastBlock }); + return { + events: allEvents, + lastBlock + }; + }); + } +} +class BaseDepositsService extends BaseEventsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Tornado, + type, + amount, + currency, + deployedBlock, + fetchDataOptions: fetchDataOptions2 + }) { + super({ netId, provider, graphApi, subgraphName, contract: Tornado, type, deployedBlock, fetchDataOptions: fetchDataOptions2 }); + this.amount = amount; + this.currency = currency; + this.batchTransactionService = new BatchTransactionService({ + provider, + onProgress: this.updateTransactionProgress + }); + this.batchBlockService = new BatchBlockService({ + provider, + onProgress: this.updateBlockProgress + }); + } + getInstanceName() { + return `${this.getType().toLowerCase()}s_${this.netId}_${this.currency}_${this.amount}`; + } + getGraphMethod() { + return `getAll${this.getType()}s`; + } + getGraphParams() { + return { + graphApi: this.graphApi || "", + subgraphName: this.subgraphName || "", + amount: this.amount, + currency: this.currency, + fetchDataOptions: this.fetchDataOptions, + onProgress: this.updateGraphProgress + }; + } + formatEvents(events) { + return __async$a(this, null, function* () { + const type = this.getType().toLowerCase(); + if (type === DEPOSIT) { + const formattedEvents = events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { + const { commitment, leafIndex, timestamp } = args; + return { + blockNumber, + logIndex, + transactionHash, + commitment, + leafIndex: Number(leafIndex), + timestamp: Number(timestamp) + }; + }); + const txs = yield this.batchTransactionService.getBatchTransactions([ + ...new Set(formattedEvents.map(({ transactionHash }) => transactionHash)) + ]); + return formattedEvents.map((event) => { + const { from } = txs.find(({ hash }) => hash === event.transactionHash); + return __spreadProps$2(__spreadValues$2({}, event), { + from + }); + }); + } else { + const formattedEvents = events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { + const { nullifierHash, to, fee } = args; + return { + blockNumber, + logIndex, + transactionHash, + nullifierHash: String(nullifierHash), + to: getAddress(to), + fee: String(fee) + }; + }); + const blocks = yield this.batchBlockService.getBatchBlocks([ + ...new Set(formattedEvents.map(({ blockNumber }) => blockNumber)) + ]); + return formattedEvents.map((event) => { + const { timestamp } = blocks.find(({ number }) => number === event.blockNumber); + return __spreadProps$2(__spreadValues$2({}, event), { + timestamp + }); + }); + } + }); + } + validateEvents({ events }) { + if (events.length && this.getType().toLowerCase() === DEPOSIT) { + const lastEvent = events[events.length - 1]; + if (lastEvent.leafIndex !== events.length - 1) { + const errMsg = `Deposit events invalid wants ${events.length - 1} leafIndex have ${lastEvent.leafIndex}`; + throw new Error(errMsg); + } + } + } +} +class BaseEncryptedNotesService extends BaseEventsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Router, + deployedBlock, + fetchDataOptions: fetchDataOptions2 + }) { + super({ netId, provider, graphApi, subgraphName, contract: Router, deployedBlock, fetchDataOptions: fetchDataOptions2 }); + } + getInstanceName() { + return `encrypted_notes_${this.netId}`; + } + getType() { + return "EncryptedNote"; + } + getGraphMethod() { + return "getAllEncryptedNotes"; + } + formatEvents(events) { + return __async$a(this, null, function* () { + return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { + const { encryptedNote } = args; + if (encryptedNote) { + const eventObjects = { + blockNumber, + logIndex, + transactionHash + }; + return __spreadProps$2(__spreadValues$2({}, eventObjects), { + encryptedNote + }); + } + }).filter((e) => e); + }); + } +} +class BaseGovernanceService extends BaseEventsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Governance, + deployedBlock, + fetchDataOptions: fetchDataOptions2 + }) { + super({ netId, provider, graphApi, subgraphName, contract: Governance, deployedBlock, fetchDataOptions: fetchDataOptions2 }); + this.batchTransactionService = new BatchTransactionService({ + provider, + onProgress: this.updateTransactionProgress + }); + } + getInstanceName() { + return `governance_${this.netId}`; + } + getType() { + return "*"; + } + getGraphMethod() { + return "governanceEvents"; + } + formatEvents(events) { + return __async$a(this, null, function* () { + const formattedEvents = events.map(({ blockNumber, index: logIndex, transactionHash, args, eventName: event }) => { + const eventObjects = { + blockNumber, + logIndex, + transactionHash, + event + }; + if (event === "ProposalCreated") { + const { id, proposer, target, startTime, endTime, description } = args; + return __spreadProps$2(__spreadValues$2({}, eventObjects), { + id, + proposer, + target, + startTime, + endTime, + description + }); + } + if (event === "Voted") { + const { proposalId, voter, support, votes } = args; + return __spreadProps$2(__spreadValues$2({}, eventObjects), { + proposalId, + voter, + support, + votes + }); + } + if (event === "Delegated") { + const { account, to: delegateTo } = args; + return __spreadProps$2(__spreadValues$2({}, eventObjects), { + account, + delegateTo + }); + } + if (event === "Undelegated") { + const { account, from: delegateFrom } = args; + return __spreadProps$2(__spreadValues$2({}, eventObjects), { + account, + delegateFrom + }); + } + }).filter((e) => e); + const votedEvents = formattedEvents.map((event, index) => __spreadProps$2(__spreadValues$2({}, event), { index })).filter(({ event }) => event === "Voted"); + if (votedEvents.length) { + this.updateTransactionProgress({ percentage: 0 }); + const txs = yield this.batchTransactionService.getBatchTransactions([ + ...new Set(votedEvents.map(({ transactionHash }) => transactionHash)) + ]); + votedEvents.forEach((event) => { + let { data: input, from } = txs.find((t) => t.hash === event.transactionHash); + if (!input || input.length > 2048) { + input = ""; + } + formattedEvents[event.index].from = from; + formattedEvents[event.index].input = input; + }); + } + return formattedEvents; + }); + } + getEventsFromGraph(_0) { + return __async$a(this, arguments, function* ({ fromBlock }) { + if (!this.graphApi || this.graphApi.includes("api.thegraph.com")) { + return { + events: [], + lastBlock: fromBlock + }; + } + return __superGet(BaseGovernanceService.prototype, this, "getEventsFromGraph").call(this, { fromBlock }); + }); + } +} +class BaseRegistryService extends BaseEventsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + RelayerRegistry, + deployedBlock, + fetchDataOptions: fetchDataOptions2 + }) { + super({ netId, provider, graphApi, subgraphName, contract: RelayerRegistry, deployedBlock, fetchDataOptions: fetchDataOptions2 }); + } + getInstanceName() { + return `registered_${this.netId}`; + } + // Name of type used for events + getType() { + return "RelayerRegistered"; + } + // Name of method used for graph + getGraphMethod() { + return "getAllRegisters"; + } + formatEvents(events) { + return __async$a(this, null, function* () { + return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { + const eventObjects = { + blockNumber, + logIndex, + transactionHash + }; + return __spreadProps$2(__spreadValues$2({}, eventObjects), { + ensName: args.ensName, + relayerAddress: args.relayerAddress + }); + }); + }); + } + fetchRelayers() { + return __async$a(this, null, function* () { + return (yield this.updateEvents()).events; + }); + } +} + +// DEFLATE is a complex format; to read this code, you should probably check the RFC first: +// https://tools.ietf.org/html/rfc1951 +// You may also wish to take a look at the guide I made about this program: +// https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad +// Some of the following code is similar to that of UZIP.js: +// https://github.com/photopea/UZIP.js +// However, the vast majority of the codebase has diverged from UZIP.js to increase performance and reduce bundle size. +// Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint +// is better for memory in most engines (I *think*). +var ch2 = {}; +var wk = (function (c, id, msg, transfer, cb) { + var w = new Worker(ch2[id] || (ch2[id] = URL.createObjectURL(new Blob([ + c + ';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})' + ], { type: 'text/javascript' })))); + w.onmessage = function (e) { + var d = e.data, ed = d.$e$; + if (ed) { + var err = new Error(ed[0]); + err['code'] = ed[1]; + err.stack = ed[2]; + cb(err, null); + } + else + cb(null, d); + }; + w.postMessage(msg, transfer); + return w; +}); + +// aliases for shorter compressed code (most minifers don't do this) +var u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array; +// fixed length extra bits +var fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, /* unused */ 0, 0, /* impossible */ 0]); +// fixed distance extra bits +var fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, /* unused */ 0, 0]); +// code length index map +var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]); +// get base, reverse index map from extra bits +var freb = function (eb, start) { + var b = new u16(31); + for (var i = 0; i < 31; ++i) { + b[i] = start += 1 << eb[i - 1]; + } + // numbers here are at max 18 bits + var r = new i32(b[30]); + for (var i = 1; i < 30; ++i) { + for (var j = b[i]; j < b[i + 1]; ++j) { + r[j] = ((j - b[i]) << 5) | i; + } + } + return { b: b, r: r }; +}; +var _a = freb(fleb, 2), fl = _a.b, revfl = _a.r; +// we can ignore the fact that the other numbers are wrong; they never happen anyway +fl[28] = 258, revfl[258] = 28; +var _b = freb(fdeb, 0), fd = _b.b, revfd = _b.r; +// map of value to reverse (assuming 16 bits) +var rev = new u16(32768); +for (var i = 0; i < 32768; ++i) { + // reverse table algorithm from SO + var x = ((i & 0xAAAA) >> 1) | ((i & 0x5555) << 1); + x = ((x & 0xCCCC) >> 2) | ((x & 0x3333) << 2); + x = ((x & 0xF0F0) >> 4) | ((x & 0x0F0F) << 4); + rev[i] = (((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8)) >> 1; +} +// create huffman tree from u8 "map": index -> code length for code index +// mb (max bits) must be at most 15 +// TODO: optimize/split up? +var hMap = (function (cd, mb, r) { + var s = cd.length; + // index + var i = 0; + // u16 "map": index -> # of codes with bit length = index + var l = new u16(mb); + // length of cd must be 288 (total # of codes) + for (; i < s; ++i) { + if (cd[i]) + ++l[cd[i] - 1]; + } + // u16 "map": index -> minimum code for bit length = index + var le = new u16(mb); + for (i = 1; i < mb; ++i) { + le[i] = (le[i - 1] + l[i - 1]) << 1; + } + var co; + if (r) { + // u16 "map": index -> number of actual bits, symbol for code + co = new u16(1 << mb); + // bits to remove for reverser + var rvb = 15 - mb; + for (i = 0; i < s; ++i) { + // ignore 0 lengths + if (cd[i]) { + // num encoding both symbol and bits read + var sv = (i << 4) | cd[i]; + // free bits + var r_1 = mb - cd[i]; + // start value + var v = le[cd[i] - 1]++ << r_1; + // m is end value + for (var m = v | ((1 << r_1) - 1); v <= m; ++v) { + // every 16 bit value starting with the code yields the same result + co[rev[v] >> rvb] = sv; + } + } + } + } + else { + co = new u16(s); + for (i = 0; i < s; ++i) { + if (cd[i]) { + co[i] = rev[le[cd[i] - 1]++] >> (15 - cd[i]); + } + } + } + return co; +}); +// fixed length tree +var flt = new u8(288); +for (var i = 0; i < 144; ++i) + flt[i] = 8; +for (var i = 144; i < 256; ++i) + flt[i] = 9; +for (var i = 256; i < 280; ++i) + flt[i] = 7; +for (var i = 280; i < 288; ++i) + flt[i] = 8; +// fixed distance tree +var fdt = new u8(32); +for (var i = 0; i < 32; ++i) + fdt[i] = 5; +// fixed length map +var flm = /*#__PURE__*/ hMap(flt, 9, 0), flrm = /*#__PURE__*/ hMap(flt, 9, 1); +// fixed distance map +var fdm = /*#__PURE__*/ hMap(fdt, 5, 0), fdrm = /*#__PURE__*/ hMap(fdt, 5, 1); +// find max of array +var max = function (a) { + var m = a[0]; + for (var i = 1; i < a.length; ++i) { + if (a[i] > m) + m = a[i]; + } + return m; +}; +// read d, starting at bit p and mask with m +var bits$3 = function (d, p, m) { + var o = (p / 8) | 0; + return ((d[o] | (d[o + 1] << 8)) >> (p & 7)) & m; +}; +// read d, starting at bit p continuing for at least 16 bits +var bits16 = function (d, p) { + var o = (p / 8) | 0; + return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >> (p & 7)); +}; +// get end of byte +var shft = function (p) { return ((p + 7) / 8) | 0; }; +// typed array slice - allows garbage collector to free original reference, +// while being more compatible than .slice +var slc = function (v, s, e) { + if (s == null || s < 0) + s = 0; + if (e == null || e > v.length) + e = v.length; + // can't use .constructor in case user-supplied + return new u8(v.subarray(s, e)); +}; +// error codes +var ec = [ + 'unexpected EOF', + 'invalid block type', + 'invalid length/literal', + 'invalid distance', + 'stream finished', + 'no stream handler', + , + 'no callback', + 'invalid UTF-8 data', + 'extra field too long', + 'date not in range 1980-2099', + 'filename too long', + 'stream finishing', + 'invalid zip data' + // determined by unknown compression method +]; +var err = function (ind, msg, nt) { + var e = new Error(msg || ec[ind]); + e.code = ind; + if (Error.captureStackTrace) + Error.captureStackTrace(e, err); + if (!nt) + throw e; + return e; +}; +// expands raw DEFLATE data +var inflt = function (dat, st, buf, dict) { + // source length dict length + var sl = dat.length, dl = dict ? dict.length : 0; + if (!sl || st.f && !st.l) + return buf || new u8(0); + var noBuf = !buf; + // have to estimate size + var resize = noBuf || st.i != 2; + // no state + var noSt = st.i; + // Assumes roughly 33% compression ratio average + if (noBuf) + buf = new u8(sl * 3); + // ensure buffer can fit at least l elements + var cbuf = function (l) { + var bl = buf.length; + // need to increase size to fit + if (l > bl) { + // Double or set to necessary, whichever is greater + var nbuf = new u8(Math.max(bl * 2, l)); + nbuf.set(buf); + buf = nbuf; + } + }; + // last chunk bitpos bytes + var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n; + // total bits + var tbts = sl * 8; + do { + if (!lm) { + // BFINAL - this is only 1 when last chunk is next + final = bits$3(dat, pos, 1); + // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman + var type = bits$3(dat, pos + 1, 3); + pos += 3; + if (!type) { + // go to end of byte boundary + var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l; + if (t > sl) { + if (noSt) + err(0); + break; + } + // ensure size + if (resize) + cbuf(bt + l); + // Copy over uncompressed data + buf.set(dat.subarray(s, t), bt); + // Get new bitpos, update byte count + st.b = bt += l, st.p = pos = t * 8, st.f = final; + continue; + } + else if (type == 1) + lm = flrm, dm = fdrm, lbt = 9, dbt = 5; + else if (type == 2) { + // literal lengths + var hLit = bits$3(dat, pos, 31) + 257, hcLen = bits$3(dat, pos + 10, 15) + 4; + var tl = hLit + bits$3(dat, pos + 5, 31) + 1; + pos += 14; + // length+distance tree + var ldt = new u8(tl); + // code length tree + var clt = new u8(19); + for (var i = 0; i < hcLen; ++i) { + // use index map to get real code + clt[clim[i]] = bits$3(dat, pos + i * 3, 7); + } + pos += hcLen * 3; + // code lengths bits + var clb = max(clt), clbmsk = (1 << clb) - 1; + // code lengths map + var clm = hMap(clt, clb, 1); + for (var i = 0; i < tl;) { + var r = clm[bits$3(dat, pos, clbmsk)]; + // bits read + pos += r & 15; + // symbol + var s = r >> 4; + // code length to copy + if (s < 16) { + ldt[i++] = s; + } + else { + // copy count + var c = 0, n = 0; + if (s == 16) + n = 3 + bits$3(dat, pos, 3), pos += 2, c = ldt[i - 1]; + else if (s == 17) + n = 3 + bits$3(dat, pos, 7), pos += 3; + else if (s == 18) + n = 11 + bits$3(dat, pos, 127), pos += 7; + while (n--) + ldt[i++] = c; + } + } + // length tree distance tree + var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit); + // max length bits + lbt = max(lt); + // max dist bits + dbt = max(dt); + lm = hMap(lt, lbt, 1); + dm = hMap(dt, dbt, 1); + } + else + err(1); + if (pos > tbts) { + if (noSt) + err(0); + break; + } + } + // Make sure the buffer can hold this + the largest possible addition + // Maximum chunk size (practically, theoretically infinite) is 2^17 + if (resize) + cbuf(bt + 131072); + var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1; + var lpos = pos; + for (;; lpos = pos) { + // bits read, code + var c = lm[bits16(dat, pos) & lms], sym = c >> 4; + pos += c & 15; + if (pos > tbts) { + if (noSt) + err(0); + break; + } + if (!c) + err(2); + if (sym < 256) + buf[bt++] = sym; + else if (sym == 256) { + lpos = pos, lm = null; + break; + } + else { + var add = sym - 254; + // no extra bits needed if less + if (sym > 264) { + // index + var i = sym - 257, b = fleb[i]; + add = bits$3(dat, pos, (1 << b) - 1) + fl[i]; + pos += b; + } + // dist + var d = dm[bits16(dat, pos) & dms], dsym = d >> 4; + if (!d) + err(3); + pos += d & 15; + var dt = fd[dsym]; + if (dsym > 3) { + var b = fdeb[dsym]; + dt += bits16(dat, pos) & (1 << b) - 1, pos += b; + } + if (pos > tbts) { + if (noSt) + err(0); + break; + } + if (resize) + cbuf(bt + 131072); + var end = bt + add; + if (bt < dt) { + var shift = dl - dt, dend = Math.min(dt, end); + if (shift + bt < 0) + err(3); + for (; bt < dend; ++bt) + buf[bt] = dict[shift + bt]; + } + for (; bt < end; ++bt) + buf[bt] = buf[bt - dt]; + } + } + st.l = lm, st.p = lpos, st.b = bt, st.f = final; + if (lm) + final = 1, st.m = lbt, st.d = dm, st.n = dbt; + } while (!final); + // don't reallocate for streams or user buffers + return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt); +}; +// starting at p, write the minimum number of bits that can hold v to d +var wbits = function (d, p, v) { + v <<= p & 7; + var o = (p / 8) | 0; + d[o] |= v; + d[o + 1] |= v >> 8; +}; +// starting at p, write the minimum number of bits (>8) that can hold v to d +var wbits16 = function (d, p, v) { + v <<= p & 7; + var o = (p / 8) | 0; + d[o] |= v; + d[o + 1] |= v >> 8; + d[o + 2] |= v >> 16; +}; +// creates code lengths from a frequency table +var hTree = function (d, mb) { + // Need extra info to make a tree + var t = []; + for (var i = 0; i < d.length; ++i) { + if (d[i]) + t.push({ s: i, f: d[i] }); + } + var s = t.length; + var t2 = t.slice(); + if (!s) + return { t: et, l: 0 }; + if (s == 1) { + var v = new u8(t[0].s + 1); + v[t[0].s] = 1; + return { t: v, l: 1 }; + } + t.sort(function (a, b) { return a.f - b.f; }); + // after i2 reaches last ind, will be stopped + // freq must be greater than largest possible number of symbols + t.push({ s: -1, f: 25001 }); + var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2; + t[0] = { s: -1, f: l.f + r.f, l: l, r: r }; + // efficient algorithm from UZIP.js + // i0 is lookbehind, i2 is lookahead - after processing two low-freq + // symbols that combined have high freq, will start processing i2 (high-freq, + // non-composite) symbols instead + // see https://reddit.com/r/photopea/comments/ikekht/uzipjs_questions/ + while (i1 != s - 1) { + l = t[t[i0].f < t[i2].f ? i0++ : i2++]; + r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++]; + t[i1++] = { s: -1, f: l.f + r.f, l: l, r: r }; + } + var maxSym = t2[0].s; + for (var i = 1; i < s; ++i) { + if (t2[i].s > maxSym) + maxSym = t2[i].s; + } + // code lengths + var tr = new u16(maxSym + 1); + // max bits in tree + var mbt = ln(t[i1 - 1], tr, 0); + if (mbt > mb) { + // more algorithms from UZIP.js + // TODO: find out how this code works (debt) + // ind debt + var i = 0, dt = 0; + // left cost + var lft = mbt - mb, cst = 1 << lft; + t2.sort(function (a, b) { return tr[b.s] - tr[a.s] || a.f - b.f; }); + for (; i < s; ++i) { + var i2_1 = t2[i].s; + if (tr[i2_1] > mb) { + dt += cst - (1 << (mbt - tr[i2_1])); + tr[i2_1] = mb; + } + else + break; + } + dt >>= lft; + while (dt > 0) { + var i2_2 = t2[i].s; + if (tr[i2_2] < mb) + dt -= 1 << (mb - tr[i2_2]++ - 1); + else + ++i; + } + for (; i >= 0 && dt; --i) { + var i2_3 = t2[i].s; + if (tr[i2_3] == mb) { + --tr[i2_3]; + ++dt; + } + } + mbt = mb; + } + return { t: new u8(tr), l: mbt }; +}; +// get the max length and assign length codes +var ln = function (n, l, d) { + return n.s == -1 + ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1)) + : (l[n.s] = d); +}; +// length codes generation +var lc = function (c) { + var s = c.length; + // Note that the semicolon was intentional + while (s && !c[--s]) + ; + var cl = new u16(++s); + // ind num streak + var cli = 0, cln = c[0], cls = 1; + var w = function (v) { cl[cli++] = v; }; + for (var i = 1; i <= s; ++i) { + if (c[i] == cln && i != s) + ++cls; + else { + if (!cln && cls > 2) { + for (; cls > 138; cls -= 138) + w(32754); + if (cls > 2) { + w(cls > 10 ? ((cls - 11) << 5) | 28690 : ((cls - 3) << 5) | 12305); + cls = 0; + } + } + else if (cls > 3) { + w(cln), --cls; + for (; cls > 6; cls -= 6) + w(8304); + if (cls > 2) + w(((cls - 3) << 5) | 8208), cls = 0; + } + while (cls--) + w(cln); + cls = 1; + cln = c[i]; + } + } + return { c: cl.subarray(0, cli), n: s }; +}; +// calculate the length of output from tree, code lengths +var clen = function (cf, cl) { + var l = 0; + for (var i = 0; i < cl.length; ++i) + l += cf[i] * cl[i]; + return l; +}; +// writes a fixed block +// returns the new bit pos +var wfblk = function (out, pos, dat) { + // no need to write 00 as type: TypedArray defaults to 0 + var s = dat.length; + var o = shft(pos + 2); + out[o] = s & 255; + out[o + 1] = s >> 8; + out[o + 2] = out[o] ^ 255; + out[o + 3] = out[o + 1] ^ 255; + for (var i = 0; i < s; ++i) + out[o + i + 4] = dat[i]; + return (o + 4 + s) * 8; +}; +// writes a block +var wblk = function (dat, out, final, syms, lf, df, eb, li, bs, bl, p) { + wbits(out, p++, final); + ++lf[256]; + var _a = hTree(lf, 15), dlt = _a.t, mlb = _a.l; + var _b = hTree(df, 15), ddt = _b.t, mdb = _b.l; + var _c = lc(dlt), lclt = _c.c, nlc = _c.n; + var _d = lc(ddt), lcdt = _d.c, ndc = _d.n; + var lcfreq = new u16(19); + for (var i = 0; i < lclt.length; ++i) + ++lcfreq[lclt[i] & 31]; + for (var i = 0; i < lcdt.length; ++i) + ++lcfreq[lcdt[i] & 31]; + var _e = hTree(lcfreq, 7), lct = _e.t, mlcb = _e.l; + var nlcc = 19; + for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc) + ; + var flen = (bl + 5) << 3; + var ftlen = clen(lf, flt) + clen(df, fdt) + eb; + var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18]; + if (bs >= 0 && flen <= ftlen && flen <= dtlen) + return wfblk(out, p, dat.subarray(bs, bs + bl)); + var lm, ll, dm, dl; + wbits(out, p, 1 + (dtlen < ftlen)), p += 2; + if (dtlen < ftlen) { + lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt; + var llm = hMap(lct, mlcb, 0); + wbits(out, p, nlc - 257); + wbits(out, p + 5, ndc - 1); + wbits(out, p + 10, nlcc - 4); + p += 14; + for (var i = 0; i < nlcc; ++i) + wbits(out, p + 3 * i, lct[clim[i]]); + p += 3 * nlcc; + var lcts = [lclt, lcdt]; + for (var it = 0; it < 2; ++it) { + var clct = lcts[it]; + for (var i = 0; i < clct.length; ++i) { + var len = clct[i] & 31; + wbits(out, p, llm[len]), p += lct[len]; + if (len > 15) + wbits(out, p, (clct[i] >> 5) & 127), p += clct[i] >> 12; + } + } + } + else { + lm = flm, ll = flt, dm = fdm, dl = fdt; + } + for (var i = 0; i < li; ++i) { + var sym = syms[i]; + if (sym > 255) { + var len = (sym >> 18) & 31; + wbits16(out, p, lm[len + 257]), p += ll[len + 257]; + if (len > 7) + wbits(out, p, (sym >> 23) & 31), p += fleb[len]; + var dst = sym & 31; + wbits16(out, p, dm[dst]), p += dl[dst]; + if (dst > 3) + wbits16(out, p, (sym >> 5) & 8191), p += fdeb[dst]; + } + else { + wbits16(out, p, lm[sym]), p += ll[sym]; + } + } + wbits16(out, p, lm[256]); + return p + ll[256]; +}; +// deflate options (nice << 13) | chain +var deo = /*#__PURE__*/ new i32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]); +// empty +var et = /*#__PURE__*/ new u8(0); +// compresses data into a raw DEFLATE buffer +var dflt = function (dat, lvl, plvl, pre, post, st) { + var s = st.z || dat.length; + var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7000)) + post); + // writing to this writes to the output buffer + var w = o.subarray(pre, o.length - post); + var lst = st.l; + var pos = (st.r || 0) & 7; + if (lvl) { + if (pos) + w[0] = st.r >> 3; + var opt = deo[lvl - 1]; + var n = opt >> 13, c = opt & 8191; + var msk_1 = (1 << plvl) - 1; + // prev 2-byte val map curr 2-byte val map + var prev = st.p || new u16(32768), head = st.h || new u16(msk_1 + 1); + var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1; + var hsh = function (i) { return (dat[i] ^ (dat[i + 1] << bs1_1) ^ (dat[i + 2] << bs2_1)) & msk_1; }; + // 24576 is an arbitrary number of maximum symbols per block + // 424 buffer for last block + var syms = new i32(25000); + // length/literal freq distance freq + var lf = new u16(288), df = new u16(32); + // l/lcnt exbits index l/lind waitdx blkpos + var lc_1 = 0, eb = 0, i = st.i || 0, li = 0, wi = st.w || 0, bs = 0; + for (; i + 2 < s; ++i) { + // hash value + var hv = hsh(i); + // index mod 32768 previous index mod + var imod = i & 32767, pimod = head[hv]; + prev[imod] = pimod; + head[hv] = imod; + // We always should modify head and prev, but only add symbols if + // this data is not yet processed ("wait" for wait index) + if (wi <= i) { + // bytes remaining + var rem = s - i; + if ((lc_1 > 7000 || li > 24576) && (rem > 423 || !lst)) { + pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos); + li = lc_1 = eb = 0, bs = i; + for (var j = 0; j < 286; ++j) + lf[j] = 0; + for (var j = 0; j < 30; ++j) + df[j] = 0; + } + // len dist chain + var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767; + if (rem > 2 && hv == hsh(i - dif)) { + var maxn = Math.min(n, rem) - 1; + var maxd = Math.min(32767, i); + // max possible length + // not capped at dif because decompressors implement "rolling" index population + var ml = Math.min(258, rem); + while (dif <= maxd && --ch_1 && imod != pimod) { + if (dat[i + l] == dat[i + l - dif]) { + var nl = 0; + for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl) + ; + if (nl > l) { + l = nl, d = dif; + // break out early when we reach "nice" (we are satisfied enough) + if (nl > maxn) + break; + // now, find the rarest 2-byte sequence within this + // length of literals and search for that instead. + // Much faster than just using the start + var mmd = Math.min(dif, nl - 2); + var md = 0; + for (var j = 0; j < mmd; ++j) { + var ti = i - dif + j & 32767; + var pti = prev[ti]; + var cd = ti - pti & 32767; + if (cd > md) + md = cd, pimod = ti; + } + } + } + // check the previous match + imod = pimod, pimod = prev[imod]; + dif += imod - pimod & 32767; + } + } + // d will be nonzero only when a match was found + if (d) { + // store both dist and len data in one int32 + // Make sure this is recognized as a len/dist with 28th bit (2^28) + syms[li++] = 268435456 | (revfl[l] << 18) | revfd[d]; + var lin = revfl[l] & 31, din = revfd[d] & 31; + eb += fleb[lin] + fdeb[din]; + ++lf[257 + lin]; + ++df[din]; + wi = i + l; + ++lc_1; + } + else { + syms[li++] = dat[i]; + ++lf[dat[i]]; + } + } + } + for (i = Math.max(i, wi); i < s; ++i) { + syms[li++] = dat[i]; + ++lf[dat[i]]; + } + pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos); + if (!lst) { + st.r = (pos & 7) | w[(pos / 8) | 0] << 3; + // shft(pos) now 1 less if pos & 7 != 0 + pos -= 7; + st.h = head, st.p = prev, st.i = i, st.w = wi; + } + } + else { + for (var i = st.w || 0; i < s + lst; i += 65535) { + // end + var e = i + 65535; + if (e >= s) { + // write final block + w[(pos / 8) | 0] = lst; + e = s; + } + pos = wfblk(w, pos + 1, dat.subarray(i, e)); + } + st.i = s; + } + return slc(o, 0, pre + shft(pos) + post); +}; +// CRC32 table +var crct = /*#__PURE__*/ (function () { + var t = new Int32Array(256); + for (var i = 0; i < 256; ++i) { + var c = i, k = 9; + while (--k) + c = ((c & 1) && -306674912) ^ (c >>> 1); + t[i] = c; + } + return t; +})(); +// CRC32 +var crc = function () { + var c = -1; + return { + p: function (d) { + // closures have awful performance + var cr = c; + for (var i = 0; i < d.length; ++i) + cr = crct[(cr & 255) ^ d[i]] ^ (cr >>> 8); + c = cr; + }, + d: function () { return ~c; } + }; +}; +// deflate with opts +var dopt = function (dat, opt, pre, post, st) { + if (!st) { + st = { l: 1 }; + if (opt.dictionary) { + var dict = opt.dictionary.subarray(-32768); + var newDat = new u8(dict.length + dat.length); + newDat.set(dict); + newDat.set(dat, dict.length); + dat = newDat; + st.w = dict.length; + } + } + return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? (st.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20) : (12 + opt.mem), pre, post, st); +}; +// Walmart object spread +var mrg = function (a, b) { + var o = {}; + for (var k in a) + o[k] = a[k]; + for (var k in b) + o[k] = b[k]; + return o; +}; +// worker clone +// This is possibly the craziest part of the entire codebase, despite how simple it may seem. +// The only parameter to this function is a closure that returns an array of variables outside of the function scope. +// We're going to try to figure out the variable names used in the closure as strings because that is crucial for workerization. +// We will return an object mapping of true variable name to value (basically, the current scope as a JS object). +// The reason we can't just use the original variable names is minifiers mangling the toplevel scope. +// This took me three weeks to figure out how to do. +var wcln = function (fn, fnStr, td) { + var dt = fn(); + var st = fn.toString(); + var ks = st.slice(st.indexOf('[') + 1, st.lastIndexOf(']')).replace(/\s+/g, '').split(','); + for (var i = 0; i < dt.length; ++i) { + var v = dt[i], k = ks[i]; + if (typeof v == 'function') { + fnStr += ';' + k + '='; + var st_1 = v.toString(); + if (v.prototype) { + // for global objects + if (st_1.indexOf('[native code]') != -1) { + var spInd = st_1.indexOf(' ', 8) + 1; + fnStr += st_1.slice(spInd, st_1.indexOf('(', spInd)); + } + else { + fnStr += st_1; + for (var t in v.prototype) + fnStr += ';' + k + '.prototype.' + t + '=' + v.prototype[t].toString(); + } + } + else + fnStr += st_1; + } + else + td[k] = v; + } + return fnStr; +}; +var ch = []; +// clone bufs +var cbfs = function (v) { + var tl = []; + for (var k in v) { + if (v[k].buffer) { + tl.push((v[k] = new v[k].constructor(v[k])).buffer); + } + } + return tl; +}; +// use a worker to execute code +var wrkr = function (fns, init, id, cb) { + if (!ch[id]) { + var fnStr = '', td_1 = {}, m = fns.length - 1; + for (var i = 0; i < m; ++i) + fnStr = wcln(fns[i], fnStr, td_1); + ch[id] = { c: wcln(fns[m], fnStr, td_1), e: td_1 }; + } + var td = mrg({}, ch[id].e); + return wk(ch[id].c + ';onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=' + init.toString() + '}', id, td, cbfs(td), cb); +}; +// base async inflate fn +var bInflt = function () { return [u8, u16, i32, fleb, fdeb, clim, fl, fd, flrm, fdrm, rev, ec, hMap, max, bits$3, bits16, shft, slc, err, inflt, inflateSync, pbf, gopt]; }; +var bDflt = function () { return [u8, u16, i32, fleb, fdeb, clim, revfl, revfd, flm, flt, fdm, fdt, rev, deo, et, hMap, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, shft, slc, dflt, dopt, deflateSync, pbf]; }; +// post buf +var pbf = function (msg) { return postMessage(msg, [msg.buffer]); }; +// get opts +var gopt = function (o) { return o && { + out: o.size && new u8(o.size), + dictionary: o.dictionary +}; }; +// async helper +var cbify = function (dat, opts, fns, init, id, cb) { + var w = wrkr(fns, init, id, function (err, dat) { + w.terminate(); + cb(err, dat); + }); + w.postMessage([dat, opts], opts.consume ? [dat.buffer] : []); + return function () { w.terminate(); }; +}; +// read 2 bytes +var b2 = function (d, b) { return d[b] | (d[b + 1] << 8); }; +// read 4 bytes +var b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16) | (d[b + 3] << 24)) >>> 0; }; +var b8 = function (d, b) { return b4(d, b) + (b4(d, b + 4) * 4294967296); }; +// write bytes +var wbytes = function (d, b, v) { + for (; v; ++b) + d[b] = v, v >>>= 8; +}; +function deflate(data, opts, cb) { + if (!cb) + cb = opts, opts = {}; + if (typeof cb != 'function') + err(7); + return cbify(data, opts, [ + bDflt, + ], function (ev) { return pbf(deflateSync(ev.data[0], ev.data[1])); }, 0, cb); +} +/** + * Compresses data with DEFLATE without any wrapper + * @param data The data to compress + * @param opts The compression options + * @returns The deflated version of the data + */ +function deflateSync(data, opts) { + return dopt(data, opts || {}, 0, 0); +} +function inflate(data, opts, cb) { + if (!cb) + cb = opts, opts = {}; + if (typeof cb != 'function') + err(7); + return cbify(data, opts, [ + bInflt + ], function (ev) { return pbf(inflateSync(ev.data[0], gopt(ev.data[1]))); }, 1, cb); +} +/** + * Expands DEFLATE data with no wrapper + * @param data The data to decompress + * @param opts The decompression options + * @returns The decompressed version of the data + */ +function inflateSync(data, opts) { + return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary); +} +// flatten a directory structure +var fltn = function (d, p, t, o) { + for (var k in d) { + var val = d[k], n = p + k, op = o; + if (Array.isArray(val)) + op = mrg(o, val[1]), val = val[0]; + if (val instanceof u8) + t[n] = [val, op]; + else { + t[n += '/'] = [new u8(0), op]; + fltn(val, n, t, o); + } + } +}; +// text encoder +var te = typeof TextEncoder != 'undefined' && /*#__PURE__*/ new TextEncoder(); +// text decoder +var td = typeof TextDecoder != 'undefined' && /*#__PURE__*/ new TextDecoder(); +// text decoder stream +var tds = 0; +try { + td.decode(et, { stream: true }); + tds = 1; +} +catch (e) { } +// decode UTF8 +var dutf8 = function (d) { + for (var r = '', i = 0;;) { + var c = d[i++]; + var eb = (c > 127) + (c > 223) + (c > 239); + if (i + eb > d.length) + return { s: r, r: slc(d, i - 1) }; + if (!eb) + r += String.fromCharCode(c); + else if (eb == 3) { + c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63)) - 65536, + r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023)); + } + else if (eb & 1) + r += String.fromCharCode((c & 31) << 6 | (d[i++] & 63)); + else + r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63)); + } +}; +/** + * Converts a string into a Uint8Array for use with compression/decompression methods + * @param str The string to encode + * @param latin1 Whether or not to interpret the data as Latin-1. This should + * not need to be true unless decoding a binary string. + * @returns The string encoded in UTF-8/Latin-1 binary + */ +function strToU8(str, latin1) { + if (latin1) { + var ar_1 = new u8(str.length); + for (var i = 0; i < str.length; ++i) + ar_1[i] = str.charCodeAt(i); + return ar_1; + } + if (te) + return te.encode(str); + var l = str.length; + var ar = new u8(str.length + (str.length >> 1)); + var ai = 0; + var w = function (v) { ar[ai++] = v; }; + for (var i = 0; i < l; ++i) { + if (ai + 5 > ar.length) { + var n = new u8(ai + 8 + ((l - i) << 1)); + n.set(ar); + ar = n; + } + var c = str.charCodeAt(i); + if (c < 128 || latin1) + w(c); + else if (c < 2048) + w(192 | (c >> 6)), w(128 | (c & 63)); + else if (c > 55295 && c < 57344) + c = 65536 + (c & 1023 << 10) | (str.charCodeAt(++i) & 1023), + w(240 | (c >> 18)), w(128 | ((c >> 12) & 63)), w(128 | ((c >> 6) & 63)), w(128 | (c & 63)); + else + w(224 | (c >> 12)), w(128 | ((c >> 6) & 63)), w(128 | (c & 63)); + } + return slc(ar, 0, ai); +} +/** + * Converts a Uint8Array to a string + * @param dat The data to decode to string + * @param latin1 Whether or not to interpret the data as Latin-1. This should + * not need to be true unless encoding to binary string. + * @returns The original UTF-8/Latin-1 string + */ +function strFromU8(dat, latin1) { + if (latin1) { + var r = ''; + for (var i = 0; i < dat.length; i += 16384) + r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384)); + return r; + } + else if (td) { + return td.decode(dat); + } + else { + var _a = dutf8(dat), s = _a.s, r = _a.r; + if (r.length) + err(8); + return s; + } +} +// skip local zip header +var slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); }; +// read zip header +var zh = function (d, b, z) { + var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl, bs = b4(d, b + 20); + var _a = z && bs == 4294967295 ? z64e(d, es) : [bs, b4(d, b + 24), b4(d, b + 42)], sc = _a[0], su = _a[1], off = _a[2]; + return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off]; +}; +// read zip64 extra field +var z64e = function (d, b) { + for (; b2(d, b) != 1; b += 4 + b2(d, b + 2)) + ; + return [b8(d, b + 12), b8(d, b + 4), b8(d, b + 20)]; +}; +// extra field length +var exfl = function (ex) { + var le = 0; + if (ex) { + for (var k in ex) { + var l = ex[k].length; + if (l > 65535) + err(9); + le += l + 4; + } + } + return le; +}; +// write zip header +var wzh = function (d, b, f, fn, u, c, ce, co) { + var fl = fn.length, ex = f.extra, col = co && co.length; + var exl = exfl(ex); + wbytes(d, b, ce != null ? 0x2014B50 : 0x4034B50), b += 4; + if (ce != null) + d[b++] = 20, d[b++] = f.os; + d[b] = 20, b += 2; // spec compliance? what's that? + d[b++] = (f.flag << 1) | (c < 0 && 8), d[b++] = u && 8; + d[b++] = f.compression & 255, d[b++] = f.compression >> 8; + var dt = new Date(f.mtime == null ? Date.now() : f.mtime), y = dt.getFullYear() - 1980; + if (y < 0 || y > 119) + err(10); + wbytes(d, b, (y << 25) | ((dt.getMonth() + 1) << 21) | (dt.getDate() << 16) | (dt.getHours() << 11) | (dt.getMinutes() << 5) | (dt.getSeconds() >> 1)), b += 4; + if (c != -1) { + wbytes(d, b, f.crc); + wbytes(d, b + 4, c < 0 ? -c - 2 : c); + wbytes(d, b + 8, f.size); + } + wbytes(d, b + 12, fl); + wbytes(d, b + 14, exl), b += 16; + if (ce != null) { + wbytes(d, b, col); + wbytes(d, b + 6, f.attrs); + wbytes(d, b + 10, ce), b += 14; + } + d.set(fn, b); + b += fl; + if (exl) { + for (var k in ex) { + var exf = ex[k], l = exf.length; + wbytes(d, b, +k); + wbytes(d, b + 2, l); + d.set(exf, b + 4), b += 4 + l; + } + } + if (col) + d.set(co, b), b += col; + return b; +}; +// write zip footer (end of central directory) +var wzf = function (o, b, c, d, e) { + wbytes(o, b, 0x6054B50); // skip disk + wbytes(o, b + 8, c); + wbytes(o, b + 10, c); + wbytes(o, b + 12, d); + wbytes(o, b + 16, e); +}; +function zip(data, opts, cb) { + if (!cb) + cb = opts, opts = {}; + if (typeof cb != 'function') + err(7); + var r = {}; + fltn(data, '', r, opts); + var k = Object.keys(r); + var lft = k.length, o = 0, tot = 0; + var slft = lft, files = new Array(lft); + var term = []; + var tAll = function () { + for (var i = 0; i < term.length; ++i) + term[i](); + }; + var cbd = function (a, b) { + mt(function () { cb(a, b); }); + }; + mt(function () { cbd = cb; }); + var cbf = function () { + var out = new u8(tot + 22), oe = o, cdl = tot - o; + tot = 0; + for (var i = 0; i < slft; ++i) { + var f = files[i]; + try { + var l = f.c.length; + wzh(out, tot, f, f.f, f.u, l); + var badd = 30 + f.f.length + exfl(f.extra); + var loc = tot + badd; + out.set(f.c, loc); + wzh(out, o, f, f.f, f.u, l, tot, f.m), o += 16 + badd + (f.m ? f.m.length : 0), tot = loc + l; + } + catch (e) { + return cbd(e, null); + } + } + wzf(out, o, files.length, cdl, oe); + cbd(null, out); + }; + if (!lft) + cbf(); + var _loop_1 = function (i) { + var fn = k[i]; + var _a = r[fn], file = _a[0], p = _a[1]; + var c = crc(), size = file.length; + c.p(file); + var f = strToU8(fn), s = f.length; + var com = p.comment, m = com && strToU8(com), ms = m && m.length; + var exl = exfl(p.extra); + var compression = p.level == 0 ? 0 : 8; + var cbl = function (e, d) { + if (e) { + tAll(); + cbd(e, null); + } + else { + var l = d.length; + files[i] = mrg(p, { + size: size, + crc: c.d(), + c: d, + f: f, + m: m, + u: s != fn.length || (m && (com.length != ms)), + compression: compression + }); + o += 30 + s + exl + l; + tot += 76 + 2 * (s + exl) + (ms || 0) + l; + if (!--lft) + cbf(); + } + }; + if (s > 65535) + cbl(err(11, 0, 1), null); + if (!compression) + cbl(null, file); + else if (size < 160000) { + try { + cbl(null, deflateSync(file, p)); + } + catch (e) { + cbl(e, null); + } + } + else + term.push(deflate(file, p, cbl)); + }; + // Cannot use lft because it can decrease + for (var i = 0; i < slft; ++i) { + _loop_1(i); + } + return tAll; +} +var mt = typeof queueMicrotask == 'function' ? queueMicrotask : typeof setTimeout == 'function' ? setTimeout : function (fn) { fn(); }; +function unzip(data, opts, cb) { + if (!cb) + cb = opts, opts = {}; + if (typeof cb != 'function') + err(7); + var term = []; + var tAll = function () { + for (var i = 0; i < term.length; ++i) + term[i](); + }; + var files = {}; + var cbd = function (a, b) { + mt(function () { cb(a, b); }); + }; + mt(function () { cbd = cb; }); + var e = data.length - 22; + for (; b4(data, e) != 0x6054B50; --e) { + if (!e || data.length - e > 65558) { + cbd(err(13, 0, 1), null); + return tAll; + } + } + var lft = b2(data, e + 8); + if (lft) { + var c = lft; + var o = b4(data, e + 16); + var z = o == 4294967295 || c == 65535; + if (z) { + var ze = b4(data, e - 12); + z = b4(data, ze) == 0x6064B50; + if (z) { + c = lft = b4(data, ze + 32); + o = b4(data, ze + 48); + } + } + var fltr = opts && opts.filter; + var _loop_3 = function (i) { + var _a = zh(data, o, z), c_1 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off); + o = no; + var cbl = function (e, d) { + if (e) { + tAll(); + cbd(e, null); + } + else { + if (d) + files[fn] = d; + if (!--lft) + cbd(null, files); + } + }; + if (!fltr || fltr({ + name: fn, + size: sc, + originalSize: su, + compression: c_1 + })) { + if (!c_1) + cbl(null, slc(data, b, b + sc)); + else if (c_1 == 8) { + var infl = data.subarray(b, b + sc); + // Synchronously decompress under 512KB, or barely-compressed data + if (su < 524288 || sc > 0.8 * su) { + try { + cbl(null, inflateSync(infl, { out: new u8(su) })); + } + catch (e) { + cbl(e, null); + } + } + else + term.push(inflate(infl, { size: su }, cbl)); + } + else + cbl(err(14, 'unknown compression type ' + c_1, 1), null); + } + else + cbl(null, null); + }; + for (var i = 0; i < c; ++i) { + _loop_3(i); + } + } + else + cbd(null, {}); + return tAll; +} + +var __async$9 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +function existsAsync(fileOrDir) { + return __async$9(this, null, function* () { + try { + yield promises.stat(fileOrDir); + return true; + } catch (e) { + return false; + } + }); +} +function zipAsync(file) { + return new Promise((res, rej) => { + zip(file, { mtime: /* @__PURE__ */ new Date("1/1/1980") }, (err, data) => { + if (err) { + rej(err); + return; + } + res(data); + }); + }); +} +function unzipAsync(data) { + return new Promise((res, rej) => { + unzip(data, {}, (err, data2) => { + if (err) { + rej(err); + return; + } + res(data2); + }); + }); +} +function saveEvents(_0) { + return __async$9(this, arguments, function* ({ + name, + userDirectory, + events + }) { + const fileName = `${name}.json`.toLowerCase(); + const filePath = path$3.join(userDirectory, fileName); + const stringEvents = JSON.stringify(events, null, 2) + "\n"; + const payload = yield zipAsync({ + [fileName]: new TextEncoder().encode(stringEvents) + }); + if (!(yield existsAsync(userDirectory))) { + yield promises.mkdir(userDirectory, { recursive: true }); + } + yield promises.writeFile(filePath + ".zip", payload); + yield promises.writeFile(filePath, stringEvents); + }); +} +function loadSavedEvents(_0) { + return __async$9(this, arguments, function* ({ + name, + userDirectory, + deployedBlock + }) { + const filePath = path$3.join(userDirectory, `${name}.json`.toLowerCase()); + if (!(yield existsAsync(filePath))) { + return { + events: [], + lastBlock: null + }; + } + try { + const events = JSON.parse(yield promises.readFile(filePath, { encoding: "utf8" })); + return { + events, + lastBlock: events && events.length ? events[events.length - 1].blockNumber : deployedBlock + }; + } catch (err) { + console.log("Method loadSavedEvents has error"); + console.log(err); + return { + events: [], + lastBlock: deployedBlock + }; + } + }); +} +function download(_0) { + return __async$9(this, arguments, function* ({ name, cacheDirectory }) { + const fileName = `${name}.json`.toLowerCase(); + const zipName = `${fileName}.zip`; + const zipPath = path$3.join(cacheDirectory, zipName); + const data = yield promises.readFile(zipPath); + const { [fileName]: content } = yield unzipAsync(data); + return new TextDecoder().decode(content); + }); +} +function loadCachedEvents(_0) { + return __async$9(this, arguments, function* ({ + name, + cacheDirectory, + deployedBlock + }) { + try { + const module = yield download({ cacheDirectory, name }); + if (module) { + const events = JSON.parse(module); + const lastBlock = events && events.length ? events[events.length - 1].blockNumber : deployedBlock; + return { + events, + lastBlock + }; + } + return { + events: [], + lastBlock: deployedBlock + }; + } catch (err) { + console.log("Method loadCachedEvents has error"); + console.log(err); + return { + events: [], + lastBlock: deployedBlock + }; + } + }); +} + +var __async$8 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +class NodeDepositsService extends BaseDepositsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Tornado, + type, + amount, + currency, + deployedBlock, + fetchDataOptions, + cacheDirectory, + userDirectory + }) { + super({ + netId, + provider, + graphApi, + subgraphName, + Tornado, + type, + amount, + currency, + deployedBlock, + fetchDataOptions + }); + this.cacheDirectory = cacheDirectory; + this.userDirectory = userDirectory; + } + updateEventProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} +`); + } + } + } + updateTransactionProgress({ currentIndex, totalIndex }) { + if (totalIndex) { + console.log(`Fetched ${currentIndex} deposit txs of ${totalIndex}`); + } + } + updateBlockProgress({ currentIndex, totalIndex }) { + if (totalIndex) { + console.log(`Fetched ${currentIndex} withdrawal blocks of ${totalIndex}`); + } + } + updateGraphProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events from graph node count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} +`); + } + } + } + getEventsFromDB() { + return __async$8(this, null, function* () { + if (!this.userDirectory) { + console.log( + "Updating events for", + this.amount, + this.currency.toUpperCase(), + `${this.getType().toLowerCase()}s +` + ); + console.log(`savedEvents count - ${0}`); + console.log(`savedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const savedEvents = yield loadSavedEvents({ + name: this.getInstanceName(), + userDirectory: this.userDirectory, + deployedBlock: this.deployedBlock + }); + console.log("Updating events for", this.amount, this.currency.toUpperCase(), `${this.getType().toLowerCase()}s +`); + console.log(`savedEvents count - ${savedEvents.events.length}`); + console.log(`savedEvents lastBlock - ${savedEvents.lastBlock} +`); + return savedEvents; + }); + } + getEventsFromCache() { + return __async$8(this, null, function* () { + if (!this.cacheDirectory) { + console.log(`cachedEvents count - ${0}`); + console.log(`cachedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const cachedEvents = yield loadCachedEvents({ + name: this.getInstanceName(), + cacheDirectory: this.cacheDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`cachedEvents count - ${cachedEvents.events.length}`); + console.log(`cachedEvents lastBlock - ${cachedEvents.lastBlock} +`); + return cachedEvents; + }); + } + saveEvents(_0) { + return __async$8(this, arguments, function* ({ events, lastBlock }) { + const instanceName = this.getInstanceName(); + console.log("\ntotalEvents count - ", events.length); + console.log( + `totalEvents lastBlock - ${events[events.length - 1] ? events[events.length - 1].blockNumber : lastBlock} +` + ); + const eventTable = new Table(); + eventTable.push( + [{ colSpan: 2, content: `${this.getType()}s`, hAlign: "center" }], + ["Instance", `${this.netId} chain ${this.amount} ${this.currency.toUpperCase()}`], + ["Anonymity set", `${events.length} equal user ${this.getType().toLowerCase()}s`], + [{ colSpan: 2, content: `Latest ${this.getType().toLowerCase()}s` }], + ...events.slice(events.length - 10).reverse().map(({ timestamp }, index) => { + const eventIndex = events.length - index; + const eventTime = moment.unix(timestamp).fromNow(); + return [eventIndex, eventTime]; + }) + ); + console.log(eventTable.toString() + "\n"); + if (this.userDirectory) { + yield saveEvents({ + name: instanceName, + userDirectory: this.userDirectory, + events + }); + } + }); + } +} +class NodeEncryptedNotesService extends BaseEncryptedNotesService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Router, + deployedBlock, + fetchDataOptions, + cacheDirectory, + userDirectory + }) { + super({ + netId, + provider, + graphApi, + subgraphName, + Router, + deployedBlock, + fetchDataOptions + }); + this.cacheDirectory = cacheDirectory; + this.userDirectory = userDirectory; + } + updateEventProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} +`); + } + } + } + updateGraphProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events from graph node count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} +`); + } + } + } + getEventsFromDB() { + return __async$8(this, null, function* () { + if (!this.userDirectory) { + console.log(`Updating events for ${this.netId} chain encrypted events +`); + console.log(`savedEvents count - ${0}`); + console.log(`savedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const savedEvents = yield loadSavedEvents({ + name: this.getInstanceName(), + userDirectory: this.userDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`Updating events for ${this.netId} chain encrypted events +`); + console.log(`savedEvents count - ${savedEvents.events.length}`); + console.log(`savedEvents lastBlock - ${savedEvents.lastBlock} +`); + return savedEvents; + }); + } + getEventsFromCache() { + return __async$8(this, null, function* () { + if (!this.cacheDirectory) { + console.log(`cachedEvents count - ${0}`); + console.log(`cachedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const cachedEvents = yield loadCachedEvents({ + name: this.getInstanceName(), + cacheDirectory: this.cacheDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`cachedEvents count - ${cachedEvents.events.length}`); + console.log(`cachedEvents lastBlock - ${cachedEvents.lastBlock} +`); + return cachedEvents; + }); + } + saveEvents(_0) { + return __async$8(this, arguments, function* ({ events, lastBlock }) { + const instanceName = this.getInstanceName(); + console.log("\ntotalEvents count - ", events.length); + console.log( + `totalEvents lastBlock - ${events[events.length - 1] ? events[events.length - 1].blockNumber : lastBlock} +` + ); + const eventTable = new Table(); + eventTable.push( + [{ colSpan: 2, content: "Encrypted Notes", hAlign: "center" }], + ["Network", `${this.netId} chain`], + ["Events", `${events.length} events`], + [{ colSpan: 2, content: "Latest events" }], + ...events.slice(events.length - 10).reverse().map(({ blockNumber }, index) => { + const eventIndex = events.length - index; + return [eventIndex, blockNumber]; + }) + ); + console.log(eventTable.toString() + "\n"); + if (this.userDirectory) { + yield saveEvents({ + name: instanceName, + userDirectory: this.userDirectory, + events + }); + } + }); + } +} +class NodeGovernanceService extends BaseGovernanceService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Governance, + deployedBlock, + fetchDataOptions, + cacheDirectory, + userDirectory + }) { + super({ + netId, + provider, + graphApi, + subgraphName, + Governance, + deployedBlock, + fetchDataOptions + }); + this.cacheDirectory = cacheDirectory; + this.userDirectory = userDirectory; + } + updateEventProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} +`); + } + } + } + updateGraphProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events from graph node count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} +`); + } + } + } + updateTransactionProgress({ currentIndex, totalIndex }) { + if (totalIndex) { + console.log(`Fetched ${currentIndex} governance txs of ${totalIndex}`); + } + } + getEventsFromDB() { + return __async$8(this, null, function* () { + if (!this.userDirectory) { + console.log(`Updating events for ${this.netId} chain governance events +`); + console.log(`savedEvents count - ${0}`); + console.log(`savedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const savedEvents = yield loadSavedEvents({ + name: this.getInstanceName(), + userDirectory: this.userDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`Updating events for ${this.netId} chain governance events +`); + console.log(`savedEvents count - ${savedEvents.events.length}`); + console.log(`savedEvents lastBlock - ${savedEvents.lastBlock} +`); + return savedEvents; + }); + } + getEventsFromCache() { + return __async$8(this, null, function* () { + if (!this.cacheDirectory) { + console.log(`cachedEvents count - ${0}`); + console.log(`cachedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const cachedEvents = yield loadCachedEvents({ + name: this.getInstanceName(), + cacheDirectory: this.cacheDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`cachedEvents count - ${cachedEvents.events.length}`); + console.log(`cachedEvents lastBlock - ${cachedEvents.lastBlock} +`); + return cachedEvents; + }); + } + saveEvents(_0) { + return __async$8(this, arguments, function* ({ events, lastBlock }) { + const instanceName = this.getInstanceName(); + console.log("\ntotalEvents count - ", events.length); + console.log( + `totalEvents lastBlock - ${events[events.length - 1] ? events[events.length - 1].blockNumber : lastBlock} +` + ); + const eventTable = new Table(); + eventTable.push( + [{ colSpan: 2, content: "Governance Events", hAlign: "center" }], + ["Network", `${this.netId} chain`], + ["Events", `${events.length} events`], + [{ colSpan: 2, content: "Latest events" }], + ...events.slice(events.length - 10).reverse().map(({ blockNumber }, index) => { + const eventIndex = events.length - index; + return [eventIndex, blockNumber]; + }) + ); + console.log(eventTable.toString() + "\n"); + if (this.userDirectory) { + yield saveEvents({ + name: instanceName, + userDirectory: this.userDirectory, + events + }); + } + }); + } +} +class NodeRegistryService extends BaseRegistryService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + RelayerRegistry, + deployedBlock, + fetchDataOptions, + cacheDirectory, + userDirectory + }) { + super({ + netId, + provider, + graphApi, + subgraphName, + RelayerRegistry, + deployedBlock, + fetchDataOptions + }); + this.cacheDirectory = cacheDirectory; + this.userDirectory = userDirectory; + } + updateEventProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} +`); + } + } + } + updateGraphProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events from graph node count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} +`); + } + } + } + getEventsFromDB() { + return __async$8(this, null, function* () { + if (!this.userDirectory) { + console.log(`Updating events for ${this.netId} chain registry events +`); + console.log(`savedEvents count - ${0}`); + console.log(`savedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const savedEvents = yield loadSavedEvents({ + name: this.getInstanceName(), + userDirectory: this.userDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`Updating events for ${this.netId} chain registry events +`); + console.log(`savedEvents count - ${savedEvents.events.length}`); + console.log(`savedEvents lastBlock - ${savedEvents.lastBlock} +`); + return savedEvents; + }); + } + getEventsFromCache() { + return __async$8(this, null, function* () { + if (!this.cacheDirectory) { + console.log(`cachedEvents count - ${0}`); + console.log(`cachedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const cachedEvents = yield loadCachedEvents({ + name: this.getInstanceName(), + cacheDirectory: this.cacheDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`cachedEvents count - ${cachedEvents.events.length}`); + console.log(`cachedEvents lastBlock - ${cachedEvents.lastBlock} +`); + return cachedEvents; + }); + } + saveEvents(_0) { + return __async$8(this, arguments, function* ({ events, lastBlock }) { + const instanceName = this.getInstanceName(); + console.log("\ntotalEvents count - ", events.length); + console.log( + `totalEvents lastBlock - ${events[events.length - 1] ? events[events.length - 1].blockNumber : lastBlock} +` + ); + const eventTable = new Table(); + eventTable.push( + [{ colSpan: 2, content: "Registered Relayers", hAlign: "center" }], + ["Network", `${this.netId} chain`], + ["Events", `${events.length} events`], + [{ colSpan: 2, content: "Latest events" }], + ...events.slice(events.length - 10).reverse().map(({ blockNumber }, index) => { + const eventIndex = events.length - index; + return [eventIndex, blockNumber]; + }) + ); + console.log(eventTable.toString() + "\n"); + if (this.userDirectory) { + yield saveEvents({ + name: instanceName, + userDirectory: this.userDirectory, + events + }); + } + }); + } +} + +var ajv$1 = {exports: {}}; + +var core$2 = {}; + +var validate = {}; + +var boolSchema = {}; + +var errors$1 = {}; + +var codegen = {}; + +var code$1 = {}; + +(function (exports) { + Object.defineProperty(exports, "__esModule", { value: true }); + exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0; + class _CodeOrName { + } + exports._CodeOrName = _CodeOrName; + exports.IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i; + class Name extends _CodeOrName { + constructor(s) { + super(); + if (!exports.IDENTIFIER.test(s)) + throw new Error("CodeGen: name must be a valid identifier"); + this.str = s; + } + toString() { + return this.str; + } + emptyStr() { + return false; + } + get names() { + return { [this.str]: 1 }; + } + } + exports.Name = Name; + class _Code extends _CodeOrName { + constructor(code) { + super(); + this._items = typeof code === "string" ? [code] : code; + } + toString() { + return this.str; + } + emptyStr() { + if (this._items.length > 1) + return false; + const item = this._items[0]; + return item === "" || item === '""'; + } + get str() { + var _a; + return ((_a = this._str) !== null && _a !== void 0 ? _a : (this._str = this._items.reduce((s, c) => `${s}${c}`, ""))); + } + get names() { + var _a; + return ((_a = this._names) !== null && _a !== void 0 ? _a : (this._names = this._items.reduce((names, c) => { + if (c instanceof Name) + names[c.str] = (names[c.str] || 0) + 1; + return names; + }, {}))); + } + } + exports._Code = _Code; + exports.nil = new _Code(""); + function _(strs, ...args) { + const code = [strs[0]]; + let i = 0; + while (i < args.length) { + addCodeArg(code, args[i]); + code.push(strs[++i]); + } + return new _Code(code); + } + exports._ = _; + const plus = new _Code("+"); + function str(strs, ...args) { + const expr = [safeStringify(strs[0])]; + let i = 0; + while (i < args.length) { + expr.push(plus); + addCodeArg(expr, args[i]); + expr.push(plus, safeStringify(strs[++i])); + } + optimize(expr); + return new _Code(expr); + } + exports.str = str; + function addCodeArg(code, arg) { + if (arg instanceof _Code) + code.push(...arg._items); + else if (arg instanceof Name) + code.push(arg); + else + code.push(interpolate(arg)); + } + exports.addCodeArg = addCodeArg; + function optimize(expr) { + let i = 1; + while (i < expr.length - 1) { + if (expr[i] === plus) { + const res = mergeExprItems(expr[i - 1], expr[i + 1]); + if (res !== undefined) { + expr.splice(i - 1, 3, res); + continue; + } + expr[i++] = "+"; + } + i++; + } + } + function mergeExprItems(a, b) { + if (b === '""') + return a; + if (a === '""') + return b; + if (typeof a == "string") { + if (b instanceof Name || a[a.length - 1] !== '"') + return; + if (typeof b != "string") + return `${a.slice(0, -1)}${b}"`; + if (b[0] === '"') + return a.slice(0, -1) + b.slice(1); + return; + } + if (typeof b == "string" && b[0] === '"' && !(a instanceof Name)) + return `"${a}${b.slice(1)}`; + return; + } + function strConcat(c1, c2) { + return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str `${c1}${c2}`; + } + exports.strConcat = strConcat; + // TODO do not allow arrays here + function interpolate(x) { + return typeof x == "number" || typeof x == "boolean" || x === null + ? x + : safeStringify(Array.isArray(x) ? x.join(",") : x); + } + function stringify(x) { + return new _Code(safeStringify(x)); + } + exports.stringify = stringify; + function safeStringify(x) { + return JSON.stringify(x) + .replace(/\u2028/g, "\\u2028") + .replace(/\u2029/g, "\\u2029"); + } + exports.safeStringify = safeStringify; + function getProperty(key) { + return typeof key == "string" && exports.IDENTIFIER.test(key) ? new _Code(`.${key}`) : _ `[${key}]`; + } + exports.getProperty = getProperty; + //Does best effort to format the name properly + function getEsmExportName(key) { + if (typeof key == "string" && exports.IDENTIFIER.test(key)) { + return new _Code(`${key}`); + } + throw new Error(`CodeGen: invalid export name: ${key}, use explicit $id name mapping`); + } + exports.getEsmExportName = getEsmExportName; + function regexpCode(rx) { + return new _Code(rx.toString()); + } + exports.regexpCode = regexpCode; + +} (code$1)); + +var scope = {}; + +(function (exports) { + Object.defineProperty(exports, "__esModule", { value: true }); + exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = void 0; + const code_1 = code$1; + class ValueError extends Error { + constructor(name) { + super(`CodeGen: "code" for ${name} not defined`); + this.value = name.value; + } + } + var UsedValueState; + (function (UsedValueState) { + UsedValueState[UsedValueState["Started"] = 0] = "Started"; + UsedValueState[UsedValueState["Completed"] = 1] = "Completed"; + })(UsedValueState = exports.UsedValueState || (exports.UsedValueState = {})); + exports.varKinds = { + const: new code_1.Name("const"), + let: new code_1.Name("let"), + var: new code_1.Name("var"), + }; + class Scope { + constructor({ prefixes, parent } = {}) { + this._names = {}; + this._prefixes = prefixes; + this._parent = parent; + } + toName(nameOrPrefix) { + return nameOrPrefix instanceof code_1.Name ? nameOrPrefix : this.name(nameOrPrefix); + } + name(prefix) { + return new code_1.Name(this._newName(prefix)); + } + _newName(prefix) { + const ng = this._names[prefix] || this._nameGroup(prefix); + return `${prefix}${ng.index++}`; + } + _nameGroup(prefix) { + var _a, _b; + if (((_b = (_a = this._parent) === null || _a === void 0 ? void 0 : _a._prefixes) === null || _b === void 0 ? void 0 : _b.has(prefix)) || (this._prefixes && !this._prefixes.has(prefix))) { + throw new Error(`CodeGen: prefix "${prefix}" is not allowed in this scope`); + } + return (this._names[prefix] = { prefix, index: 0 }); + } + } + exports.Scope = Scope; + class ValueScopeName extends code_1.Name { + constructor(prefix, nameStr) { + super(nameStr); + this.prefix = prefix; + } + setValue(value, { property, itemIndex }) { + this.value = value; + this.scopePath = (0, code_1._) `.${new code_1.Name(property)}[${itemIndex}]`; + } + } + exports.ValueScopeName = ValueScopeName; + const line = (0, code_1._) `\n`; + class ValueScope extends Scope { + constructor(opts) { + super(opts); + this._values = {}; + this._scope = opts.scope; + this.opts = { ...opts, _n: opts.lines ? line : code_1.nil }; + } + get() { + return this._scope; + } + name(prefix) { + return new ValueScopeName(prefix, this._newName(prefix)); + } + value(nameOrPrefix, value) { + var _a; + if (value.ref === undefined) + throw new Error("CodeGen: ref must be passed in value"); + const name = this.toName(nameOrPrefix); + const { prefix } = name; + const valueKey = (_a = value.key) !== null && _a !== void 0 ? _a : value.ref; + let vs = this._values[prefix]; + if (vs) { + const _name = vs.get(valueKey); + if (_name) + return _name; + } + else { + vs = this._values[prefix] = new Map(); + } + vs.set(valueKey, name); + const s = this._scope[prefix] || (this._scope[prefix] = []); + const itemIndex = s.length; + s[itemIndex] = value.ref; + name.setValue(value, { property: prefix, itemIndex }); + return name; + } + getValue(prefix, keyOrRef) { + const vs = this._values[prefix]; + if (!vs) + return; + return vs.get(keyOrRef); + } + scopeRefs(scopeName, values = this._values) { + return this._reduceValues(values, (name) => { + if (name.scopePath === undefined) + throw new Error(`CodeGen: name "${name}" has no value`); + return (0, code_1._) `${scopeName}${name.scopePath}`; + }); + } + scopeCode(values = this._values, usedValues, getCode) { + return this._reduceValues(values, (name) => { + if (name.value === undefined) + throw new Error(`CodeGen: name "${name}" has no value`); + return name.value.code; + }, usedValues, getCode); + } + _reduceValues(values, valueCode, usedValues = {}, getCode) { + let code = code_1.nil; + for (const prefix in values) { + const vs = values[prefix]; + if (!vs) + continue; + const nameSet = (usedValues[prefix] = usedValues[prefix] || new Map()); + vs.forEach((name) => { + if (nameSet.has(name)) + return; + nameSet.set(name, UsedValueState.Started); + let c = valueCode(name); + if (c) { + const def = this.opts.es5 ? exports.varKinds.var : exports.varKinds.const; + code = (0, code_1._) `${code}${def} ${name} = ${c};${this.opts._n}`; + } + else if ((c = getCode === null || getCode === void 0 ? void 0 : getCode(name))) { + code = (0, code_1._) `${code}${c}${this.opts._n}`; + } + else { + throw new ValueError(name); + } + nameSet.set(name, UsedValueState.Completed); + }); + } + return code; + } + } + exports.ValueScope = ValueScope; + +} (scope)); + +(function (exports) { + Object.defineProperty(exports, "__esModule", { value: true }); + exports.or = exports.and = exports.not = exports.CodeGen = exports.operators = exports.varKinds = exports.ValueScopeName = exports.ValueScope = exports.Scope = exports.Name = exports.regexpCode = exports.stringify = exports.getProperty = exports.nil = exports.strConcat = exports.str = exports._ = void 0; + const code_1 = code$1; + const scope_1 = scope; + var code_2 = code$1; + Object.defineProperty(exports, "_", { enumerable: true, get: function () { return code_2._; } }); + Object.defineProperty(exports, "str", { enumerable: true, get: function () { return code_2.str; } }); + Object.defineProperty(exports, "strConcat", { enumerable: true, get: function () { return code_2.strConcat; } }); + Object.defineProperty(exports, "nil", { enumerable: true, get: function () { return code_2.nil; } }); + Object.defineProperty(exports, "getProperty", { enumerable: true, get: function () { return code_2.getProperty; } }); + Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return code_2.stringify; } }); + Object.defineProperty(exports, "regexpCode", { enumerable: true, get: function () { return code_2.regexpCode; } }); + Object.defineProperty(exports, "Name", { enumerable: true, get: function () { return code_2.Name; } }); + var scope_2 = scope; + Object.defineProperty(exports, "Scope", { enumerable: true, get: function () { return scope_2.Scope; } }); + Object.defineProperty(exports, "ValueScope", { enumerable: true, get: function () { return scope_2.ValueScope; } }); + Object.defineProperty(exports, "ValueScopeName", { enumerable: true, get: function () { return scope_2.ValueScopeName; } }); + Object.defineProperty(exports, "varKinds", { enumerable: true, get: function () { return scope_2.varKinds; } }); + exports.operators = { + GT: new code_1._Code(">"), + GTE: new code_1._Code(">="), + LT: new code_1._Code("<"), + LTE: new code_1._Code("<="), + EQ: new code_1._Code("==="), + NEQ: new code_1._Code("!=="), + NOT: new code_1._Code("!"), + OR: new code_1._Code("||"), + AND: new code_1._Code("&&"), + ADD: new code_1._Code("+"), + }; + class Node { + optimizeNodes() { + return this; + } + optimizeNames(_names, _constants) { + return this; + } + } + class Def extends Node { + constructor(varKind, name, rhs) { + super(); + this.varKind = varKind; + this.name = name; + this.rhs = rhs; + } + render({ es5, _n }) { + const varKind = es5 ? scope_1.varKinds.var : this.varKind; + const rhs = this.rhs === undefined ? "" : ` = ${this.rhs}`; + return `${varKind} ${this.name}${rhs};` + _n; + } + optimizeNames(names, constants) { + if (!names[this.name.str]) + return; + if (this.rhs) + this.rhs = optimizeExpr(this.rhs, names, constants); + return this; + } + get names() { + return this.rhs instanceof code_1._CodeOrName ? this.rhs.names : {}; + } + } + class Assign extends Node { + constructor(lhs, rhs, sideEffects) { + super(); + this.lhs = lhs; + this.rhs = rhs; + this.sideEffects = sideEffects; + } + render({ _n }) { + return `${this.lhs} = ${this.rhs};` + _n; + } + optimizeNames(names, constants) { + if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects) + return; + this.rhs = optimizeExpr(this.rhs, names, constants); + return this; + } + get names() { + const names = this.lhs instanceof code_1.Name ? {} : { ...this.lhs.names }; + return addExprNames(names, this.rhs); + } + } + class AssignOp extends Assign { + constructor(lhs, op, rhs, sideEffects) { + super(lhs, rhs, sideEffects); + this.op = op; + } + render({ _n }) { + return `${this.lhs} ${this.op}= ${this.rhs};` + _n; + } + } + class Label extends Node { + constructor(label) { + super(); + this.label = label; + this.names = {}; + } + render({ _n }) { + return `${this.label}:` + _n; + } + } + class Break extends Node { + constructor(label) { + super(); + this.label = label; + this.names = {}; + } + render({ _n }) { + const label = this.label ? ` ${this.label}` : ""; + return `break${label};` + _n; + } + } + class Throw extends Node { + constructor(error) { + super(); + this.error = error; + } + render({ _n }) { + return `throw ${this.error};` + _n; + } + get names() { + return this.error.names; + } + } + class AnyCode extends Node { + constructor(code) { + super(); + this.code = code; + } + render({ _n }) { + return `${this.code};` + _n; + } + optimizeNodes() { + return `${this.code}` ? this : undefined; + } + optimizeNames(names, constants) { + this.code = optimizeExpr(this.code, names, constants); + return this; + } + get names() { + return this.code instanceof code_1._CodeOrName ? this.code.names : {}; + } + } + class ParentNode extends Node { + constructor(nodes = []) { + super(); + this.nodes = nodes; + } + render(opts) { + return this.nodes.reduce((code, n) => code + n.render(opts), ""); + } + optimizeNodes() { + const { nodes } = this; + let i = nodes.length; + while (i--) { + const n = nodes[i].optimizeNodes(); + if (Array.isArray(n)) + nodes.splice(i, 1, ...n); + else if (n) + nodes[i] = n; + else + nodes.splice(i, 1); + } + return nodes.length > 0 ? this : undefined; + } + optimizeNames(names, constants) { + const { nodes } = this; + let i = nodes.length; + while (i--) { + // iterating backwards improves 1-pass optimization + const n = nodes[i]; + if (n.optimizeNames(names, constants)) + continue; + subtractNames(names, n.names); + nodes.splice(i, 1); + } + return nodes.length > 0 ? this : undefined; + } + get names() { + return this.nodes.reduce((names, n) => addNames(names, n.names), {}); + } + } + class BlockNode extends ParentNode { + render(opts) { + return "{" + opts._n + super.render(opts) + "}" + opts._n; + } + } + class Root extends ParentNode { + } + class Else extends BlockNode { + } + Else.kind = "else"; + class If extends BlockNode { + constructor(condition, nodes) { + super(nodes); + this.condition = condition; + } + render(opts) { + let code = `if(${this.condition})` + super.render(opts); + if (this.else) + code += "else " + this.else.render(opts); + return code; + } + optimizeNodes() { + super.optimizeNodes(); + const cond = this.condition; + if (cond === true) + return this.nodes; // else is ignored here + let e = this.else; + if (e) { + const ns = e.optimizeNodes(); + e = this.else = Array.isArray(ns) ? new Else(ns) : ns; + } + if (e) { + if (cond === false) + return e instanceof If ? e : e.nodes; + if (this.nodes.length) + return this; + return new If(not(cond), e instanceof If ? [e] : e.nodes); + } + if (cond === false || !this.nodes.length) + return undefined; + return this; + } + optimizeNames(names, constants) { + var _a; + this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants); + if (!(super.optimizeNames(names, constants) || this.else)) + return; + this.condition = optimizeExpr(this.condition, names, constants); + return this; + } + get names() { + const names = super.names; + addExprNames(names, this.condition); + if (this.else) + addNames(names, this.else.names); + return names; + } + } + If.kind = "if"; + class For extends BlockNode { + } + For.kind = "for"; + class ForLoop extends For { + constructor(iteration) { + super(); + this.iteration = iteration; + } + render(opts) { + return `for(${this.iteration})` + super.render(opts); + } + optimizeNames(names, constants) { + if (!super.optimizeNames(names, constants)) + return; + this.iteration = optimizeExpr(this.iteration, names, constants); + return this; + } + get names() { + return addNames(super.names, this.iteration.names); + } + } + class ForRange extends For { + constructor(varKind, name, from, to) { + super(); + this.varKind = varKind; + this.name = name; + this.from = from; + this.to = to; + } + render(opts) { + const varKind = opts.es5 ? scope_1.varKinds.var : this.varKind; + const { name, from, to } = this; + return `for(${varKind} ${name}=${from}; ${name}<${to}; ${name}++)` + super.render(opts); + } + get names() { + const names = addExprNames(super.names, this.from); + return addExprNames(names, this.to); + } + } + class ForIter extends For { + constructor(loop, varKind, name, iterable) { + super(); + this.loop = loop; + this.varKind = varKind; + this.name = name; + this.iterable = iterable; + } + render(opts) { + return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts); + } + optimizeNames(names, constants) { + if (!super.optimizeNames(names, constants)) + return; + this.iterable = optimizeExpr(this.iterable, names, constants); + return this; + } + get names() { + return addNames(super.names, this.iterable.names); + } + } + class Func extends BlockNode { + constructor(name, args, async) { + super(); + this.name = name; + this.args = args; + this.async = async; + } + render(opts) { + const _async = this.async ? "async " : ""; + return `${_async}function ${this.name}(${this.args})` + super.render(opts); + } + } + Func.kind = "func"; + class Return extends ParentNode { + render(opts) { + return "return " + super.render(opts); + } + } + Return.kind = "return"; + class Try extends BlockNode { + render(opts) { + let code = "try" + super.render(opts); + if (this.catch) + code += this.catch.render(opts); + if (this.finally) + code += this.finally.render(opts); + return code; + } + optimizeNodes() { + var _a, _b; + super.optimizeNodes(); + (_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNodes(); + (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes(); + return this; + } + optimizeNames(names, constants) { + var _a, _b; + super.optimizeNames(names, constants); + (_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants); + (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants); + return this; + } + get names() { + const names = super.names; + if (this.catch) + addNames(names, this.catch.names); + if (this.finally) + addNames(names, this.finally.names); + return names; + } + } + class Catch extends BlockNode { + constructor(error) { + super(); + this.error = error; + } + render(opts) { + return `catch(${this.error})` + super.render(opts); + } + } + Catch.kind = "catch"; + class Finally extends BlockNode { + render(opts) { + return "finally" + super.render(opts); + } + } + Finally.kind = "finally"; + class CodeGen { + constructor(extScope, opts = {}) { + this._values = {}; + this._blockStarts = []; + this._constants = {}; + this.opts = { ...opts, _n: opts.lines ? "\n" : "" }; + this._extScope = extScope; + this._scope = new scope_1.Scope({ parent: extScope }); + this._nodes = [new Root()]; + } + toString() { + return this._root.render(this.opts); + } + // returns unique name in the internal scope + name(prefix) { + return this._scope.name(prefix); + } + // reserves unique name in the external scope + scopeName(prefix) { + return this._extScope.name(prefix); + } + // reserves unique name in the external scope and assigns value to it + scopeValue(prefixOrName, value) { + const name = this._extScope.value(prefixOrName, value); + const vs = this._values[name.prefix] || (this._values[name.prefix] = new Set()); + vs.add(name); + return name; + } + getScopeValue(prefix, keyOrRef) { + return this._extScope.getValue(prefix, keyOrRef); + } + // return code that assigns values in the external scope to the names that are used internally + // (same names that were returned by gen.scopeName or gen.scopeValue) + scopeRefs(scopeName) { + return this._extScope.scopeRefs(scopeName, this._values); + } + scopeCode() { + return this._extScope.scopeCode(this._values); + } + _def(varKind, nameOrPrefix, rhs, constant) { + const name = this._scope.toName(nameOrPrefix); + if (rhs !== undefined && constant) + this._constants[name.str] = rhs; + this._leafNode(new Def(varKind, name, rhs)); + return name; + } + // `const` declaration (`var` in es5 mode) + const(nameOrPrefix, rhs, _constant) { + return this._def(scope_1.varKinds.const, nameOrPrefix, rhs, _constant); + } + // `let` declaration with optional assignment (`var` in es5 mode) + let(nameOrPrefix, rhs, _constant) { + return this._def(scope_1.varKinds.let, nameOrPrefix, rhs, _constant); + } + // `var` declaration with optional assignment + var(nameOrPrefix, rhs, _constant) { + return this._def(scope_1.varKinds.var, nameOrPrefix, rhs, _constant); + } + // assignment code + assign(lhs, rhs, sideEffects) { + return this._leafNode(new Assign(lhs, rhs, sideEffects)); + } + // `+=` code + add(lhs, rhs) { + return this._leafNode(new AssignOp(lhs, exports.operators.ADD, rhs)); + } + // appends passed SafeExpr to code or executes Block + code(c) { + if (typeof c == "function") + c(); + else if (c !== code_1.nil) + this._leafNode(new AnyCode(c)); + return this; + } + // returns code for object literal for the passed argument list of key-value pairs + object(...keyValues) { + const code = ["{"]; + for (const [key, value] of keyValues) { + if (code.length > 1) + code.push(","); + code.push(key); + if (key !== value || this.opts.es5) { + code.push(":"); + (0, code_1.addCodeArg)(code, value); + } + } + code.push("}"); + return new code_1._Code(code); + } + // `if` clause (or statement if `thenBody` and, optionally, `elseBody` are passed) + if(condition, thenBody, elseBody) { + this._blockNode(new If(condition)); + if (thenBody && elseBody) { + this.code(thenBody).else().code(elseBody).endIf(); + } + else if (thenBody) { + this.code(thenBody).endIf(); + } + else if (elseBody) { + throw new Error('CodeGen: "else" body without "then" body'); + } + return this; + } + // `else if` clause - invalid without `if` or after `else` clauses + elseIf(condition) { + return this._elseNode(new If(condition)); + } + // `else` clause - only valid after `if` or `else if` clauses + else() { + return this._elseNode(new Else()); + } + // end `if` statement (needed if gen.if was used only with condition) + endIf() { + return this._endBlockNode(If, Else); + } + _for(node, forBody) { + this._blockNode(node); + if (forBody) + this.code(forBody).endFor(); + return this; + } + // a generic `for` clause (or statement if `forBody` is passed) + for(iteration, forBody) { + return this._for(new ForLoop(iteration), forBody); + } + // `for` statement for a range of values + forRange(nameOrPrefix, from, to, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.let) { + const name = this._scope.toName(nameOrPrefix); + return this._for(new ForRange(varKind, name, from, to), () => forBody(name)); + } + // `for-of` statement (in es5 mode replace with a normal for loop) + forOf(nameOrPrefix, iterable, forBody, varKind = scope_1.varKinds.const) { + const name = this._scope.toName(nameOrPrefix); + if (this.opts.es5) { + const arr = iterable instanceof code_1.Name ? iterable : this.var("_arr", iterable); + return this.forRange("_i", 0, (0, code_1._) `${arr}.length`, (i) => { + this.var(name, (0, code_1._) `${arr}[${i}]`); + forBody(name); + }); + } + return this._for(new ForIter("of", varKind, name, iterable), () => forBody(name)); + } + // `for-in` statement. + // With option `ownProperties` replaced with a `for-of` loop for object keys + forIn(nameOrPrefix, obj, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.const) { + if (this.opts.ownProperties) { + return this.forOf(nameOrPrefix, (0, code_1._) `Object.keys(${obj})`, forBody); + } + const name = this._scope.toName(nameOrPrefix); + return this._for(new ForIter("in", varKind, name, obj), () => forBody(name)); + } + // end `for` loop + endFor() { + return this._endBlockNode(For); + } + // `label` statement + label(label) { + return this._leafNode(new Label(label)); + } + // `break` statement + break(label) { + return this._leafNode(new Break(label)); + } + // `return` statement + return(value) { + const node = new Return(); + this._blockNode(node); + this.code(value); + if (node.nodes.length !== 1) + throw new Error('CodeGen: "return" should have one node'); + return this._endBlockNode(Return); + } + // `try` statement + try(tryBody, catchCode, finallyCode) { + if (!catchCode && !finallyCode) + throw new Error('CodeGen: "try" without "catch" and "finally"'); + const node = new Try(); + this._blockNode(node); + this.code(tryBody); + if (catchCode) { + const error = this.name("e"); + this._currNode = node.catch = new Catch(error); + catchCode(error); + } + if (finallyCode) { + this._currNode = node.finally = new Finally(); + this.code(finallyCode); + } + return this._endBlockNode(Catch, Finally); + } + // `throw` statement + throw(error) { + return this._leafNode(new Throw(error)); + } + // start self-balancing block + block(body, nodeCount) { + this._blockStarts.push(this._nodes.length); + if (body) + this.code(body).endBlock(nodeCount); + return this; + } + // end the current self-balancing block + endBlock(nodeCount) { + const len = this._blockStarts.pop(); + if (len === undefined) + throw new Error("CodeGen: not in self-balancing block"); + const toClose = this._nodes.length - len; + if (toClose < 0 || (nodeCount !== undefined && toClose !== nodeCount)) { + throw new Error(`CodeGen: wrong number of nodes: ${toClose} vs ${nodeCount} expected`); + } + this._nodes.length = len; + return this; + } + // `function` heading (or definition if funcBody is passed) + func(name, args = code_1.nil, async, funcBody) { + this._blockNode(new Func(name, args, async)); + if (funcBody) + this.code(funcBody).endFunc(); + return this; + } + // end function definition + endFunc() { + return this._endBlockNode(Func); + } + optimize(n = 1) { + while (n-- > 0) { + this._root.optimizeNodes(); + this._root.optimizeNames(this._root.names, this._constants); + } + } + _leafNode(node) { + this._currNode.nodes.push(node); + return this; + } + _blockNode(node) { + this._currNode.nodes.push(node); + this._nodes.push(node); + } + _endBlockNode(N1, N2) { + const n = this._currNode; + if (n instanceof N1 || (N2 && n instanceof N2)) { + this._nodes.pop(); + return this; + } + throw new Error(`CodeGen: not in block "${N2 ? `${N1.kind}/${N2.kind}` : N1.kind}"`); + } + _elseNode(node) { + const n = this._currNode; + if (!(n instanceof If)) { + throw new Error('CodeGen: "else" without "if"'); + } + this._currNode = n.else = node; + return this; + } + get _root() { + return this._nodes[0]; + } + get _currNode() { + const ns = this._nodes; + return ns[ns.length - 1]; + } + set _currNode(node) { + const ns = this._nodes; + ns[ns.length - 1] = node; + } + } + exports.CodeGen = CodeGen; + function addNames(names, from) { + for (const n in from) + names[n] = (names[n] || 0) + (from[n] || 0); + return names; + } + function addExprNames(names, from) { + return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names; + } + function optimizeExpr(expr, names, constants) { + if (expr instanceof code_1.Name) + return replaceName(expr); + if (!canOptimize(expr)) + return expr; + return new code_1._Code(expr._items.reduce((items, c) => { + if (c instanceof code_1.Name) + c = replaceName(c); + if (c instanceof code_1._Code) + items.push(...c._items); + else + items.push(c); + return items; + }, [])); + function replaceName(n) { + const c = constants[n.str]; + if (c === undefined || names[n.str] !== 1) + return n; + delete names[n.str]; + return c; + } + function canOptimize(e) { + return (e instanceof code_1._Code && + e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants[c.str] !== undefined)); + } + } + function subtractNames(names, from) { + for (const n in from) + names[n] = (names[n] || 0) - (from[n] || 0); + } + function not(x) { + return typeof x == "boolean" || typeof x == "number" || x === null ? !x : (0, code_1._) `!${par(x)}`; + } + exports.not = not; + const andCode = mappend(exports.operators.AND); + // boolean AND (&&) expression with the passed arguments + function and(...args) { + return args.reduce(andCode); + } + exports.and = and; + const orCode = mappend(exports.operators.OR); + // boolean OR (||) expression with the passed arguments + function or(...args) { + return args.reduce(orCode); + } + exports.or = or; + function mappend(op) { + return (x, y) => (x === code_1.nil ? y : y === code_1.nil ? x : (0, code_1._) `${par(x)} ${op} ${par(y)}`); + } + function par(x) { + return x instanceof code_1.Name ? x : (0, code_1._) `(${x})`; + } + +} (codegen)); + +var util = {}; + +(function (exports) { + Object.defineProperty(exports, "__esModule", { value: true }); + exports.checkStrictMode = exports.getErrorPath = exports.Type = exports.useFunc = exports.setEvaluated = exports.evaluatedPropsToName = exports.mergeEvaluated = exports.eachItem = exports.unescapeJsonPointer = exports.escapeJsonPointer = exports.escapeFragment = exports.unescapeFragment = exports.schemaRefOrVal = exports.schemaHasRulesButRef = exports.schemaHasRules = exports.checkUnknownRules = exports.alwaysValidSchema = exports.toHash = void 0; + const codegen_1 = codegen; + const code_1 = code$1; + // TODO refactor to use Set + function toHash(arr) { + const hash = {}; + for (const item of arr) + hash[item] = true; + return hash; + } + exports.toHash = toHash; + function alwaysValidSchema(it, schema) { + if (typeof schema == "boolean") + return schema; + if (Object.keys(schema).length === 0) + return true; + checkUnknownRules(it, schema); + return !schemaHasRules(schema, it.self.RULES.all); + } + exports.alwaysValidSchema = alwaysValidSchema; + function checkUnknownRules(it, schema = it.schema) { + const { opts, self } = it; + if (!opts.strictSchema) + return; + if (typeof schema === "boolean") + return; + const rules = self.RULES.keywords; + for (const key in schema) { + if (!rules[key]) + checkStrictMode(it, `unknown keyword: "${key}"`); + } + } + exports.checkUnknownRules = checkUnknownRules; + function schemaHasRules(schema, rules) { + if (typeof schema == "boolean") + return !schema; + for (const key in schema) + if (rules[key]) + return true; + return false; + } + exports.schemaHasRules = schemaHasRules; + function schemaHasRulesButRef(schema, RULES) { + if (typeof schema == "boolean") + return !schema; + for (const key in schema) + if (key !== "$ref" && RULES.all[key]) + return true; + return false; + } + exports.schemaHasRulesButRef = schemaHasRulesButRef; + function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword, $data) { + if (!$data) { + if (typeof schema == "number" || typeof schema == "boolean") + return schema; + if (typeof schema == "string") + return (0, codegen_1._) `${schema}`; + } + return (0, codegen_1._) `${topSchemaRef}${schemaPath}${(0, codegen_1.getProperty)(keyword)}`; + } + exports.schemaRefOrVal = schemaRefOrVal; + function unescapeFragment(str) { + return unescapeJsonPointer(decodeURIComponent(str)); + } + exports.unescapeFragment = unescapeFragment; + function escapeFragment(str) { + return encodeURIComponent(escapeJsonPointer(str)); + } + exports.escapeFragment = escapeFragment; + function escapeJsonPointer(str) { + if (typeof str == "number") + return `${str}`; + return str.replace(/~/g, "~0").replace(/\//g, "~1"); + } + exports.escapeJsonPointer = escapeJsonPointer; + function unescapeJsonPointer(str) { + return str.replace(/~1/g, "/").replace(/~0/g, "~"); + } + exports.unescapeJsonPointer = unescapeJsonPointer; + function eachItem(xs, f) { + if (Array.isArray(xs)) { + for (const x of xs) + f(x); + } + else { + f(xs); + } + } + exports.eachItem = eachItem; + function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName, }) { + return (gen, from, to, toName) => { + const res = to === undefined + ? from + : to instanceof codegen_1.Name + ? (from instanceof codegen_1.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) + : from instanceof codegen_1.Name + ? (mergeToName(gen, to, from), from) + : mergeValues(from, to); + return toName === codegen_1.Name && !(res instanceof codegen_1.Name) ? resultToName(gen, res) : res; + }; + } + exports.mergeEvaluated = { + props: makeMergeEvaluated({ + mergeNames: (gen, from, to) => gen.if((0, codegen_1._) `${to} !== true && ${from} !== undefined`, () => { + gen.if((0, codegen_1._) `${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1._) `${to} || {}`).code((0, codegen_1._) `Object.assign(${to}, ${from})`)); + }), + mergeToName: (gen, from, to) => gen.if((0, codegen_1._) `${to} !== true`, () => { + if (from === true) { + gen.assign(to, true); + } + else { + gen.assign(to, (0, codegen_1._) `${to} || {}`); + setEvaluated(gen, to, from); + } + }), + mergeValues: (from, to) => (from === true ? true : { ...from, ...to }), + resultToName: evaluatedPropsToName, + }), + items: makeMergeEvaluated({ + mergeNames: (gen, from, to) => gen.if((0, codegen_1._) `${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1._) `${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)), + mergeToName: (gen, from, to) => gen.if((0, codegen_1._) `${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1._) `${to} > ${from} ? ${to} : ${from}`)), + mergeValues: (from, to) => (from === true ? true : Math.max(from, to)), + resultToName: (gen, items) => gen.var("items", items), + }), + }; + function evaluatedPropsToName(gen, ps) { + if (ps === true) + return gen.var("props", true); + const props = gen.var("props", (0, codegen_1._) `{}`); + if (ps !== undefined) + setEvaluated(gen, props, ps); + return props; + } + exports.evaluatedPropsToName = evaluatedPropsToName; + function setEvaluated(gen, props, ps) { + Object.keys(ps).forEach((p) => gen.assign((0, codegen_1._) `${props}${(0, codegen_1.getProperty)(p)}`, true)); + } + exports.setEvaluated = setEvaluated; + const snippets = {}; + function useFunc(gen, f) { + return gen.scopeValue("func", { + ref: f, + code: snippets[f.code] || (snippets[f.code] = new code_1._Code(f.code)), + }); + } + exports.useFunc = useFunc; + var Type; + (function (Type) { + Type[Type["Num"] = 0] = "Num"; + Type[Type["Str"] = 1] = "Str"; + })(Type = exports.Type || (exports.Type = {})); + function getErrorPath(dataProp, dataPropType, jsPropertySyntax) { + // let path + if (dataProp instanceof codegen_1.Name) { + const isNumber = dataPropType === Type.Num; + return jsPropertySyntax + ? isNumber + ? (0, codegen_1._) `"[" + ${dataProp} + "]"` + : (0, codegen_1._) `"['" + ${dataProp} + "']"` + : isNumber + ? (0, codegen_1._) `"/" + ${dataProp}` + : (0, codegen_1._) `"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`; // TODO maybe use global escapePointer + } + return jsPropertySyntax ? (0, codegen_1.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp); + } + exports.getErrorPath = getErrorPath; + function checkStrictMode(it, msg, mode = it.opts.strictSchema) { + if (!mode) + return; + msg = `strict mode: ${msg}`; + if (mode === true) + throw new Error(msg); + it.self.logger.warn(msg); + } + exports.checkStrictMode = checkStrictMode; + +} (util)); + +var names$1 = {}; + +Object.defineProperty(names$1, "__esModule", { value: true }); +const codegen_1$t = codegen; +const names = { + // validation function arguments + data: new codegen_1$t.Name("data"), + // args passed from referencing schema + valCxt: new codegen_1$t.Name("valCxt"), + instancePath: new codegen_1$t.Name("instancePath"), + parentData: new codegen_1$t.Name("parentData"), + parentDataProperty: new codegen_1$t.Name("parentDataProperty"), + rootData: new codegen_1$t.Name("rootData"), + dynamicAnchors: new codegen_1$t.Name("dynamicAnchors"), + // function scoped variables + vErrors: new codegen_1$t.Name("vErrors"), + errors: new codegen_1$t.Name("errors"), + this: new codegen_1$t.Name("this"), + // "globals" + self: new codegen_1$t.Name("self"), + scope: new codegen_1$t.Name("scope"), + // JTD serialize/parse name for JSON string and position + json: new codegen_1$t.Name("json"), + jsonPos: new codegen_1$t.Name("jsonPos"), + jsonLen: new codegen_1$t.Name("jsonLen"), + jsonPart: new codegen_1$t.Name("jsonPart"), +}; +names$1.default = names; + +(function (exports) { + Object.defineProperty(exports, "__esModule", { value: true }); + exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = void 0; + const codegen_1 = codegen; + const util_1 = util; + const names_1 = names$1; + exports.keywordError = { + message: ({ keyword }) => (0, codegen_1.str) `must pass "${keyword}" keyword validation`, + }; + exports.keyword$DataError = { + message: ({ keyword, schemaType }) => schemaType + ? (0, codegen_1.str) `"${keyword}" keyword must be ${schemaType} ($data)` + : (0, codegen_1.str) `"${keyword}" keyword is invalid ($data)`, + }; + function reportError(cxt, error = exports.keywordError, errorPaths, overrideAllErrors) { + const { it } = cxt; + const { gen, compositeRule, allErrors } = it; + const errObj = errorObjectCode(cxt, error, errorPaths); + if (overrideAllErrors !== null && overrideAllErrors !== void 0 ? overrideAllErrors : (compositeRule || allErrors)) { + addError(gen, errObj); + } + else { + returnErrors(it, (0, codegen_1._) `[${errObj}]`); + } + } + exports.reportError = reportError; + function reportExtraError(cxt, error = exports.keywordError, errorPaths) { + const { it } = cxt; + const { gen, compositeRule, allErrors } = it; + const errObj = errorObjectCode(cxt, error, errorPaths); + addError(gen, errObj); + if (!(compositeRule || allErrors)) { + returnErrors(it, names_1.default.vErrors); + } + } + exports.reportExtraError = reportExtraError; + function resetErrorsCount(gen, errsCount) { + gen.assign(names_1.default.errors, errsCount); + gen.if((0, codegen_1._) `${names_1.default.vErrors} !== null`, () => gen.if(errsCount, () => gen.assign((0, codegen_1._) `${names_1.default.vErrors}.length`, errsCount), () => gen.assign(names_1.default.vErrors, null))); + } + exports.resetErrorsCount = resetErrorsCount; + function extendErrors({ gen, keyword, schemaValue, data, errsCount, it, }) { + /* istanbul ignore if */ + if (errsCount === undefined) + throw new Error("ajv implementation error"); + const err = gen.name("err"); + gen.forRange("i", errsCount, names_1.default.errors, (i) => { + gen.const(err, (0, codegen_1._) `${names_1.default.vErrors}[${i}]`); + gen.if((0, codegen_1._) `${err}.instancePath === undefined`, () => gen.assign((0, codegen_1._) `${err}.instancePath`, (0, codegen_1.strConcat)(names_1.default.instancePath, it.errorPath))); + gen.assign((0, codegen_1._) `${err}.schemaPath`, (0, codegen_1.str) `${it.errSchemaPath}/${keyword}`); + if (it.opts.verbose) { + gen.assign((0, codegen_1._) `${err}.schema`, schemaValue); + gen.assign((0, codegen_1._) `${err}.data`, data); + } + }); + } + exports.extendErrors = extendErrors; + function addError(gen, errObj) { + const err = gen.const("err", errObj); + gen.if((0, codegen_1._) `${names_1.default.vErrors} === null`, () => gen.assign(names_1.default.vErrors, (0, codegen_1._) `[${err}]`), (0, codegen_1._) `${names_1.default.vErrors}.push(${err})`); + gen.code((0, codegen_1._) `${names_1.default.errors}++`); + } + function returnErrors(it, errs) { + const { gen, validateName, schemaEnv } = it; + if (schemaEnv.$async) { + gen.throw((0, codegen_1._) `new ${it.ValidationError}(${errs})`); + } + else { + gen.assign((0, codegen_1._) `${validateName}.errors`, errs); + gen.return(false); + } + } + const E = { + keyword: new codegen_1.Name("keyword"), + schemaPath: new codegen_1.Name("schemaPath"), + params: new codegen_1.Name("params"), + propertyName: new codegen_1.Name("propertyName"), + message: new codegen_1.Name("message"), + schema: new codegen_1.Name("schema"), + parentSchema: new codegen_1.Name("parentSchema"), + }; + function errorObjectCode(cxt, error, errorPaths) { + const { createErrors } = cxt.it; + if (createErrors === false) + return (0, codegen_1._) `{}`; + return errorObject(cxt, error, errorPaths); + } + function errorObject(cxt, error, errorPaths = {}) { + const { gen, it } = cxt; + const keyValues = [ + errorInstancePath(it, errorPaths), + errorSchemaPath(cxt, errorPaths), + ]; + extraErrorProps(cxt, error, keyValues); + return gen.object(...keyValues); + } + function errorInstancePath({ errorPath }, { instancePath }) { + const instPath = instancePath + ? (0, codegen_1.str) `${errorPath}${(0, util_1.getErrorPath)(instancePath, util_1.Type.Str)}` + : errorPath; + return [names_1.default.instancePath, (0, codegen_1.strConcat)(names_1.default.instancePath, instPath)]; + } + function errorSchemaPath({ keyword, it: { errSchemaPath } }, { schemaPath, parentSchema }) { + let schPath = parentSchema ? errSchemaPath : (0, codegen_1.str) `${errSchemaPath}/${keyword}`; + if (schemaPath) { + schPath = (0, codegen_1.str) `${schPath}${(0, util_1.getErrorPath)(schemaPath, util_1.Type.Str)}`; + } + return [E.schemaPath, schPath]; + } + function extraErrorProps(cxt, { params, message }, keyValues) { + const { keyword, data, schemaValue, it } = cxt; + const { opts, propertyName, topSchemaRef, schemaPath } = it; + keyValues.push([E.keyword, keyword], [E.params, typeof params == "function" ? params(cxt) : params || (0, codegen_1._) `{}`]); + if (opts.messages) { + keyValues.push([E.message, typeof message == "function" ? message(cxt) : message]); + } + if (opts.verbose) { + keyValues.push([E.schema, schemaValue], [E.parentSchema, (0, codegen_1._) `${topSchemaRef}${schemaPath}`], [names_1.default.data, data]); + } + if (propertyName) + keyValues.push([E.propertyName, propertyName]); + } + +} (errors$1)); + +Object.defineProperty(boolSchema, "__esModule", { value: true }); +boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0; +const errors_1$2 = errors$1; +const codegen_1$s = codegen; +const names_1$6 = names$1; +const boolError = { + message: "boolean schema is false", +}; +function topBoolOrEmptySchema(it) { + const { gen, schema, validateName } = it; + if (schema === false) { + falseSchemaError(it, false); + } + else if (typeof schema == "object" && schema.$async === true) { + gen.return(names_1$6.default.data); + } + else { + gen.assign((0, codegen_1$s._) `${validateName}.errors`, null); + gen.return(true); + } +} +boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema; +function boolOrEmptySchema(it, valid) { + const { gen, schema } = it; + if (schema === false) { + gen.var(valid, false); // TODO var + falseSchemaError(it); + } + else { + gen.var(valid, true); // TODO var + } +} +boolSchema.boolOrEmptySchema = boolOrEmptySchema; +function falseSchemaError(it, overrideAllErrors) { + const { gen, data } = it; + // TODO maybe some other interface should be used for non-keyword validation errors... + const cxt = { + gen, + keyword: "false schema", + data, + schema: false, + schemaCode: false, + schemaValue: false, + params: {}, + it, + }; + (0, errors_1$2.reportError)(cxt, boolError, undefined, overrideAllErrors); +} + +var dataType = {}; + +var rules = {}; + +Object.defineProperty(rules, "__esModule", { value: true }); +rules.getRules = rules.isJSONType = void 0; +const _jsonTypes = ["string", "number", "integer", "boolean", "null", "object", "array"]; +const jsonTypes = new Set(_jsonTypes); +function isJSONType(x) { + return typeof x == "string" && jsonTypes.has(x); +} +rules.isJSONType = isJSONType; +function getRules() { + const groups = { + number: { type: "number", rules: [] }, + string: { type: "string", rules: [] }, + array: { type: "array", rules: [] }, + object: { type: "object", rules: [] }, + }; + return { + types: { ...groups, integer: true, boolean: true, null: true }, + rules: [{ rules: [] }, groups.number, groups.string, groups.array, groups.object], + post: { rules: [] }, + all: {}, + keywords: {}, + }; +} +rules.getRules = getRules; + +var applicability = {}; + +Object.defineProperty(applicability, "__esModule", { value: true }); +applicability.shouldUseRule = applicability.shouldUseGroup = applicability.schemaHasRulesForType = void 0; +function schemaHasRulesForType({ schema, self }, type) { + const group = self.RULES.types[type]; + return group && group !== true && shouldUseGroup(schema, group); +} +applicability.schemaHasRulesForType = schemaHasRulesForType; +function shouldUseGroup(schema, group) { + return group.rules.some((rule) => shouldUseRule(schema, rule)); +} +applicability.shouldUseGroup = shouldUseGroup; +function shouldUseRule(schema, rule) { + var _a; + return (schema[rule.keyword] !== undefined || + ((_a = rule.definition.implements) === null || _a === void 0 ? void 0 : _a.some((kwd) => schema[kwd] !== undefined))); +} +applicability.shouldUseRule = shouldUseRule; + +(function (exports) { + Object.defineProperty(exports, "__esModule", { value: true }); + exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = void 0; + const rules_1 = rules; + const applicability_1 = applicability; + const errors_1 = errors$1; + const codegen_1 = codegen; + const util_1 = util; + var DataType; + (function (DataType) { + DataType[DataType["Correct"] = 0] = "Correct"; + DataType[DataType["Wrong"] = 1] = "Wrong"; + })(DataType = exports.DataType || (exports.DataType = {})); + function getSchemaTypes(schema) { + const types = getJSONTypes(schema.type); + const hasNull = types.includes("null"); + if (hasNull) { + if (schema.nullable === false) + throw new Error("type: null contradicts nullable: false"); + } + else { + if (!types.length && schema.nullable !== undefined) { + throw new Error('"nullable" cannot be used without "type"'); + } + if (schema.nullable === true) + types.push("null"); + } + return types; + } + exports.getSchemaTypes = getSchemaTypes; + function getJSONTypes(ts) { + const types = Array.isArray(ts) ? ts : ts ? [ts] : []; + if (types.every(rules_1.isJSONType)) + return types; + throw new Error("type must be JSONType or JSONType[]: " + types.join(",")); + } + exports.getJSONTypes = getJSONTypes; + function coerceAndCheckDataType(it, types) { + const { gen, data, opts } = it; + const coerceTo = coerceToTypes(types, opts.coerceTypes); + const checkTypes = types.length > 0 && + !(coerceTo.length === 0 && types.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types[0])); + if (checkTypes) { + const wrongType = checkDataTypes(types, data, opts.strictNumbers, DataType.Wrong); + gen.if(wrongType, () => { + if (coerceTo.length) + coerceData(it, types, coerceTo); + else + reportTypeError(it); + }); + } + return checkTypes; + } + exports.coerceAndCheckDataType = coerceAndCheckDataType; + const COERCIBLE = new Set(["string", "number", "integer", "boolean", "null"]); + function coerceToTypes(types, coerceTypes) { + return coerceTypes + ? types.filter((t) => COERCIBLE.has(t) || (coerceTypes === "array" && t === "array")) + : []; + } + function coerceData(it, types, coerceTo) { + const { gen, data, opts } = it; + const dataType = gen.let("dataType", (0, codegen_1._) `typeof ${data}`); + const coerced = gen.let("coerced", (0, codegen_1._) `undefined`); + if (opts.coerceTypes === "array") { + gen.if((0, codegen_1._) `${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen + .assign(data, (0, codegen_1._) `${data}[0]`) + .assign(dataType, (0, codegen_1._) `typeof ${data}`) + .if(checkDataTypes(types, data, opts.strictNumbers), () => gen.assign(coerced, data))); + } + gen.if((0, codegen_1._) `${coerced} !== undefined`); + for (const t of coerceTo) { + if (COERCIBLE.has(t) || (t === "array" && opts.coerceTypes === "array")) { + coerceSpecificType(t); + } + } + gen.else(); + reportTypeError(it); + gen.endIf(); + gen.if((0, codegen_1._) `${coerced} !== undefined`, () => { + gen.assign(data, coerced); + assignParentData(it, coerced); + }); + function coerceSpecificType(t) { + switch (t) { + case "string": + gen + .elseIf((0, codegen_1._) `${dataType} == "number" || ${dataType} == "boolean"`) + .assign(coerced, (0, codegen_1._) `"" + ${data}`) + .elseIf((0, codegen_1._) `${data} === null`) + .assign(coerced, (0, codegen_1._) `""`); + return; + case "number": + gen + .elseIf((0, codegen_1._) `${dataType} == "boolean" || ${data} === null + || (${dataType} == "string" && ${data} && ${data} == +${data})`) + .assign(coerced, (0, codegen_1._) `+${data}`); + return; + case "integer": + gen + .elseIf((0, codegen_1._) `${dataType} === "boolean" || ${data} === null + || (${dataType} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`) + .assign(coerced, (0, codegen_1._) `+${data}`); + return; + case "boolean": + gen + .elseIf((0, codegen_1._) `${data} === "false" || ${data} === 0 || ${data} === null`) + .assign(coerced, false) + .elseIf((0, codegen_1._) `${data} === "true" || ${data} === 1`) + .assign(coerced, true); + return; + case "null": + gen.elseIf((0, codegen_1._) `${data} === "" || ${data} === 0 || ${data} === false`); + gen.assign(coerced, null); + return; + case "array": + gen + .elseIf((0, codegen_1._) `${dataType} === "string" || ${dataType} === "number" + || ${dataType} === "boolean" || ${data} === null`) + .assign(coerced, (0, codegen_1._) `[${data}]`); + } + } + } + function assignParentData({ gen, parentData, parentDataProperty }, expr) { + // TODO use gen.property + gen.if((0, codegen_1._) `${parentData} !== undefined`, () => gen.assign((0, codegen_1._) `${parentData}[${parentDataProperty}]`, expr)); + } + function checkDataType(dataType, data, strictNums, correct = DataType.Correct) { + const EQ = correct === DataType.Correct ? codegen_1.operators.EQ : codegen_1.operators.NEQ; + let cond; + switch (dataType) { + case "null": + return (0, codegen_1._) `${data} ${EQ} null`; + case "array": + cond = (0, codegen_1._) `Array.isArray(${data})`; + break; + case "object": + cond = (0, codegen_1._) `${data} && typeof ${data} == "object" && !Array.isArray(${data})`; + break; + case "integer": + cond = numCond((0, codegen_1._) `!(${data} % 1) && !isNaN(${data})`); + break; + case "number": + cond = numCond(); + break; + default: + return (0, codegen_1._) `typeof ${data} ${EQ} ${dataType}`; + } + return correct === DataType.Correct ? cond : (0, codegen_1.not)(cond); + function numCond(_cond = codegen_1.nil) { + return (0, codegen_1.and)((0, codegen_1._) `typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1._) `isFinite(${data})` : codegen_1.nil); + } + } + exports.checkDataType = checkDataType; + function checkDataTypes(dataTypes, data, strictNums, correct) { + if (dataTypes.length === 1) { + return checkDataType(dataTypes[0], data, strictNums, correct); + } + let cond; + const types = (0, util_1.toHash)(dataTypes); + if (types.array && types.object) { + const notObj = (0, codegen_1._) `typeof ${data} != "object"`; + cond = types.null ? notObj : (0, codegen_1._) `!${data} || ${notObj}`; + delete types.null; + delete types.array; + delete types.object; + } + else { + cond = codegen_1.nil; + } + if (types.number) + delete types.integer; + for (const t in types) + cond = (0, codegen_1.and)(cond, checkDataType(t, data, strictNums, correct)); + return cond; + } + exports.checkDataTypes = checkDataTypes; + const typeError = { + message: ({ schema }) => `must be ${schema}`, + params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1._) `{type: ${schema}}` : (0, codegen_1._) `{type: ${schemaValue}}`, + }; + function reportTypeError(it) { + const cxt = getTypeErrorContext(it); + (0, errors_1.reportError)(cxt, typeError); + } + exports.reportTypeError = reportTypeError; + function getTypeErrorContext(it) { + const { gen, data, schema } = it; + const schemaCode = (0, util_1.schemaRefOrVal)(it, schema, "type"); + return { + gen, + keyword: "type", + data, + schema: schema.type, + schemaCode, + schemaValue: schemaCode, + parentSchema: schema, + params: {}, + it, + }; + } + +} (dataType)); + +var defaults = {}; + +Object.defineProperty(defaults, "__esModule", { value: true }); +defaults.assignDefaults = void 0; +const codegen_1$r = codegen; +const util_1$p = util; +function assignDefaults(it, ty) { + const { properties, items } = it.schema; + if (ty === "object" && properties) { + for (const key in properties) { + assignDefault(it, key, properties[key].default); + } + } + else if (ty === "array" && Array.isArray(items)) { + items.forEach((sch, i) => assignDefault(it, i, sch.default)); + } +} +defaults.assignDefaults = assignDefaults; +function assignDefault(it, prop, defaultValue) { + const { gen, compositeRule, data, opts } = it; + if (defaultValue === undefined) + return; + const childData = (0, codegen_1$r._) `${data}${(0, codegen_1$r.getProperty)(prop)}`; + if (compositeRule) { + (0, util_1$p.checkStrictMode)(it, `default is ignored for: ${childData}`); + return; + } + let condition = (0, codegen_1$r._) `${childData} === undefined`; + if (opts.useDefaults === "empty") { + condition = (0, codegen_1$r._) `${condition} || ${childData} === null || ${childData} === ""`; + } + // `${childData} === undefined` + + // (opts.useDefaults === "empty" ? ` || ${childData} === null || ${childData} === ""` : "") + gen.if(condition, (0, codegen_1$r._) `${childData} = ${(0, codegen_1$r.stringify)(defaultValue)}`); +} + +var keyword = {}; + +var code = {}; + +Object.defineProperty(code, "__esModule", { value: true }); +code.validateUnion = code.validateArray = code.usePattern = code.callValidateCode = code.schemaProperties = code.allSchemaProperties = code.noPropertyInData = code.propertyInData = code.isOwnProperty = code.hasPropFunc = code.reportMissingProp = code.checkMissingProp = code.checkReportMissingProp = void 0; +const codegen_1$q = codegen; +const util_1$o = util; +const names_1$5 = names$1; +const util_2$1 = util; +function checkReportMissingProp(cxt, prop) { + const { gen, data, it } = cxt; + gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => { + cxt.setParams({ missingProperty: (0, codegen_1$q._) `${prop}` }, true); + cxt.error(); + }); +} +code.checkReportMissingProp = checkReportMissingProp; +function checkMissingProp({ gen, data, it: { opts } }, properties, missing) { + return (0, codegen_1$q.or)(...properties.map((prop) => (0, codegen_1$q.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1$q._) `${missing} = ${prop}`))); +} +code.checkMissingProp = checkMissingProp; +function reportMissingProp(cxt, missing) { + cxt.setParams({ missingProperty: missing }, true); + cxt.error(); +} +code.reportMissingProp = reportMissingProp; +function hasPropFunc(gen) { + return gen.scopeValue("func", { + // eslint-disable-next-line @typescript-eslint/unbound-method + ref: Object.prototype.hasOwnProperty, + code: (0, codegen_1$q._) `Object.prototype.hasOwnProperty`, + }); +} +code.hasPropFunc = hasPropFunc; +function isOwnProperty(gen, data, property) { + return (0, codegen_1$q._) `${hasPropFunc(gen)}.call(${data}, ${property})`; +} +code.isOwnProperty = isOwnProperty; +function propertyInData(gen, data, property, ownProperties) { + const cond = (0, codegen_1$q._) `${data}${(0, codegen_1$q.getProperty)(property)} !== undefined`; + return ownProperties ? (0, codegen_1$q._) `${cond} && ${isOwnProperty(gen, data, property)}` : cond; +} +code.propertyInData = propertyInData; +function noPropertyInData(gen, data, property, ownProperties) { + const cond = (0, codegen_1$q._) `${data}${(0, codegen_1$q.getProperty)(property)} === undefined`; + return ownProperties ? (0, codegen_1$q.or)(cond, (0, codegen_1$q.not)(isOwnProperty(gen, data, property))) : cond; +} +code.noPropertyInData = noPropertyInData; +function allSchemaProperties(schemaMap) { + return schemaMap ? Object.keys(schemaMap).filter((p) => p !== "__proto__") : []; +} +code.allSchemaProperties = allSchemaProperties; +function schemaProperties(it, schemaMap) { + return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$o.alwaysValidSchema)(it, schemaMap[p])); +} +code.schemaProperties = schemaProperties; +function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) { + const dataAndSchema = passSchema ? (0, codegen_1$q._) `${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data; + const valCxt = [ + [names_1$5.default.instancePath, (0, codegen_1$q.strConcat)(names_1$5.default.instancePath, errorPath)], + [names_1$5.default.parentData, it.parentData], + [names_1$5.default.parentDataProperty, it.parentDataProperty], + [names_1$5.default.rootData, names_1$5.default.rootData], + ]; + if (it.opts.dynamicRef) + valCxt.push([names_1$5.default.dynamicAnchors, names_1$5.default.dynamicAnchors]); + const args = (0, codegen_1$q._) `${dataAndSchema}, ${gen.object(...valCxt)}`; + return context !== codegen_1$q.nil ? (0, codegen_1$q._) `${func}.call(${context}, ${args})` : (0, codegen_1$q._) `${func}(${args})`; +} +code.callValidateCode = callValidateCode; +const newRegExp = (0, codegen_1$q._) `new RegExp`; +function usePattern({ gen, it: { opts } }, pattern) { + const u = opts.unicodeRegExp ? "u" : ""; + const { regExp } = opts.code; + const rx = regExp(pattern, u); + return gen.scopeValue("pattern", { + key: rx.toString(), + ref: rx, + code: (0, codegen_1$q._) `${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern}, ${u})`, + }); +} +code.usePattern = usePattern; +function validateArray(cxt) { + const { gen, data, keyword, it } = cxt; + const valid = gen.name("valid"); + if (it.allErrors) { + const validArr = gen.let("valid", true); + validateItems(() => gen.assign(validArr, false)); + return validArr; + } + gen.var(valid, true); + validateItems(() => gen.break()); + return valid; + function validateItems(notValid) { + const len = gen.const("len", (0, codegen_1$q._) `${data}.length`); + gen.forRange("i", 0, len, (i) => { + cxt.subschema({ + keyword, + dataProp: i, + dataPropType: util_1$o.Type.Num, + }, valid); + gen.if((0, codegen_1$q.not)(valid), notValid); + }); + } +} +code.validateArray = validateArray; +function validateUnion(cxt) { + const { gen, schema, keyword, it } = cxt; + /* istanbul ignore if */ + if (!Array.isArray(schema)) + throw new Error("ajv implementation error"); + const alwaysValid = schema.some((sch) => (0, util_1$o.alwaysValidSchema)(it, sch)); + if (alwaysValid && !it.opts.unevaluated) + return; + const valid = gen.let("valid", false); + const schValid = gen.name("_valid"); + gen.block(() => schema.forEach((_sch, i) => { + const schCxt = cxt.subschema({ + keyword, + schemaProp: i, + compositeRule: true, + }, schValid); + gen.assign(valid, (0, codegen_1$q._) `${valid} || ${schValid}`); + const merged = cxt.mergeValidEvaluated(schCxt, schValid); + // can short-circuit if `unevaluatedProperties/Items` not supported (opts.unevaluated !== true) + // or if all properties and items were evaluated (it.props === true && it.items === true) + if (!merged) + gen.if((0, codegen_1$q.not)(valid)); + })); + cxt.result(valid, () => cxt.reset(), () => cxt.error(true)); +} +code.validateUnion = validateUnion; + +Object.defineProperty(keyword, "__esModule", { value: true }); +keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0; +const codegen_1$p = codegen; +const names_1$4 = names$1; +const code_1$9 = code; +const errors_1$1 = errors$1; +function macroKeywordCode(cxt, def) { + const { gen, keyword, schema, parentSchema, it } = cxt; + const macroSchema = def.macro.call(it.self, schema, parentSchema, it); + const schemaRef = useKeyword(gen, keyword, macroSchema); + if (it.opts.validateSchema !== false) + it.self.validateSchema(macroSchema, true); + const valid = gen.name("valid"); + cxt.subschema({ + schema: macroSchema, + schemaPath: codegen_1$p.nil, + errSchemaPath: `${it.errSchemaPath}/${keyword}`, + topSchemaRef: schemaRef, + compositeRule: true, + }, valid); + cxt.pass(valid, () => cxt.error(true)); +} +keyword.macroKeywordCode = macroKeywordCode; +function funcKeywordCode(cxt, def) { + var _a; + const { gen, keyword, schema, parentSchema, $data, it } = cxt; + checkAsyncKeyword(it, def); + const validate = !$data && def.compile ? def.compile.call(it.self, schema, parentSchema, it) : def.validate; + const validateRef = useKeyword(gen, keyword, validate); + const valid = gen.let("valid"); + cxt.block$data(valid, validateKeyword); + cxt.ok((_a = def.valid) !== null && _a !== void 0 ? _a : valid); + function validateKeyword() { + if (def.errors === false) { + assignValid(); + if (def.modifying) + modifyData(cxt); + reportErrs(() => cxt.error()); + } + else { + const ruleErrs = def.async ? validateAsync() : validateSync(); + if (def.modifying) + modifyData(cxt); + reportErrs(() => addErrs(cxt, ruleErrs)); + } + } + function validateAsync() { + const ruleErrs = gen.let("ruleErrs", null); + gen.try(() => assignValid((0, codegen_1$p._) `await `), (e) => gen.assign(valid, false).if((0, codegen_1$p._) `${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1$p._) `${e}.errors`), () => gen.throw(e))); + return ruleErrs; + } + function validateSync() { + const validateErrs = (0, codegen_1$p._) `${validateRef}.errors`; + gen.assign(validateErrs, null); + assignValid(codegen_1$p.nil); + return validateErrs; + } + function assignValid(_await = def.async ? (0, codegen_1$p._) `await ` : codegen_1$p.nil) { + const passCxt = it.opts.passContext ? names_1$4.default.this : names_1$4.default.self; + const passSchema = !(("compile" in def && !$data) || def.schema === false); + gen.assign(valid, (0, codegen_1$p._) `${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying); + } + function reportErrs(errors) { + var _a; + gen.if((0, codegen_1$p.not)((_a = def.valid) !== null && _a !== void 0 ? _a : valid), errors); + } +} +keyword.funcKeywordCode = funcKeywordCode; +function modifyData(cxt) { + const { gen, data, it } = cxt; + gen.if(it.parentData, () => gen.assign(data, (0, codegen_1$p._) `${it.parentData}[${it.parentDataProperty}]`)); +} +function addErrs(cxt, errs) { + const { gen } = cxt; + gen.if((0, codegen_1$p._) `Array.isArray(${errs})`, () => { + gen + .assign(names_1$4.default.vErrors, (0, codegen_1$p._) `${names_1$4.default.vErrors} === null ? ${errs} : ${names_1$4.default.vErrors}.concat(${errs})`) + .assign(names_1$4.default.errors, (0, codegen_1$p._) `${names_1$4.default.vErrors}.length`); + (0, errors_1$1.extendErrors)(cxt); + }, () => cxt.error()); +} +function checkAsyncKeyword({ schemaEnv }, def) { + if (def.async && !schemaEnv.$async) + throw new Error("async keyword in sync schema"); +} +function useKeyword(gen, keyword, result) { + if (result === undefined) + throw new Error(`keyword "${keyword}" failed to compile`); + return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$p.stringify)(result) }); +} +function validSchemaType(schema, schemaType, allowUndefined = false) { + // TODO add tests + return (!schemaType.length || + schemaType.some((st) => st === "array" + ? Array.isArray(schema) + : st === "object" + ? schema && typeof schema == "object" && !Array.isArray(schema) + : typeof schema == st || (allowUndefined && typeof schema == "undefined"))); +} +keyword.validSchemaType = validSchemaType; +function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def, keyword) { + /* istanbul ignore if */ + if (Array.isArray(def.keyword) ? !def.keyword.includes(keyword) : def.keyword !== keyword) { + throw new Error("ajv implementation error"); + } + const deps = def.dependencies; + if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) { + throw new Error(`parent schema must have dependencies of ${keyword}: ${deps.join(",")}`); + } + if (def.validateSchema) { + const valid = def.validateSchema(schema[keyword]); + if (!valid) { + const msg = `keyword "${keyword}" value is invalid at path "${errSchemaPath}": ` + + self.errorsText(def.validateSchema.errors); + if (opts.validateSchema === "log") + self.logger.error(msg); + else + throw new Error(msg); + } + } +} +keyword.validateKeywordUsage = validateKeywordUsage; + +var subschema = {}; + +Object.defineProperty(subschema, "__esModule", { value: true }); +subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0; +const codegen_1$o = codegen; +const util_1$n = util; +function getSubschema(it, { keyword, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) { + if (keyword !== undefined && schema !== undefined) { + throw new Error('both "keyword" and "schema" passed, only one allowed'); + } + if (keyword !== undefined) { + const sch = it.schema[keyword]; + return schemaProp === undefined + ? { + schema: sch, + schemaPath: (0, codegen_1$o._) `${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword)}`, + errSchemaPath: `${it.errSchemaPath}/${keyword}`, + } + : { + schema: sch[schemaProp], + schemaPath: (0, codegen_1$o._) `${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword)}${(0, codegen_1$o.getProperty)(schemaProp)}`, + errSchemaPath: `${it.errSchemaPath}/${keyword}/${(0, util_1$n.escapeFragment)(schemaProp)}`, + }; + } + if (schema !== undefined) { + if (schemaPath === undefined || errSchemaPath === undefined || topSchemaRef === undefined) { + throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"'); + } + return { + schema, + schemaPath, + topSchemaRef, + errSchemaPath, + }; + } + throw new Error('either "keyword" or "schema" must be passed'); +} +subschema.getSubschema = getSubschema; +function extendSubschemaData(subschema, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) { + if (data !== undefined && dataProp !== undefined) { + throw new Error('both "data" and "dataProp" passed, only one allowed'); + } + const { gen } = it; + if (dataProp !== undefined) { + const { errorPath, dataPathArr, opts } = it; + const nextData = gen.let("data", (0, codegen_1$o._) `${it.data}${(0, codegen_1$o.getProperty)(dataProp)}`, true); + dataContextProps(nextData); + subschema.errorPath = (0, codegen_1$o.str) `${errorPath}${(0, util_1$n.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`; + subschema.parentDataProperty = (0, codegen_1$o._) `${dataProp}`; + subschema.dataPathArr = [...dataPathArr, subschema.parentDataProperty]; + } + if (data !== undefined) { + const nextData = data instanceof codegen_1$o.Name ? data : gen.let("data", data, true); // replaceable if used once? + dataContextProps(nextData); + if (propertyName !== undefined) + subschema.propertyName = propertyName; + // TODO something is possibly wrong here with not changing parentDataProperty and not appending dataPathArr + } + if (dataTypes) + subschema.dataTypes = dataTypes; + function dataContextProps(_nextData) { + subschema.data = _nextData; + subschema.dataLevel = it.dataLevel + 1; + subschema.dataTypes = []; + it.definedProperties = new Set(); + subschema.parentData = it.data; + subschema.dataNames = [...it.dataNames, _nextData]; + } +} +subschema.extendSubschemaData = extendSubschemaData; +function extendSubschemaMode(subschema, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) { + if (compositeRule !== undefined) + subschema.compositeRule = compositeRule; + if (createErrors !== undefined) + subschema.createErrors = createErrors; + if (allErrors !== undefined) + subschema.allErrors = allErrors; + subschema.jtdDiscriminator = jtdDiscriminator; // not inherited + subschema.jtdMetadata = jtdMetadata; // not inherited +} +subschema.extendSubschemaMode = extendSubschemaMode; + +var resolve$1 = {}; + +// do not edit .js files directly - edit src/index.jst + + + +var fastDeepEqual = function equal(a, b) { + if (a === b) return true; + + if (a && b && typeof a == 'object' && typeof b == 'object') { + if (a.constructor !== b.constructor) return false; + + var length, i, keys; + if (Array.isArray(a)) { + length = a.length; + if (length != b.length) return false; + for (i = length; i-- !== 0;) + if (!equal(a[i], b[i])) return false; + return true; + } + + + + if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags; + if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf(); + if (a.toString !== Object.prototype.toString) return a.toString() === b.toString(); + + keys = Object.keys(a); + length = keys.length; + if (length !== Object.keys(b).length) return false; + + for (i = length; i-- !== 0;) + if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; + + for (i = length; i-- !== 0;) { + var key = keys[i]; + + if (!equal(a[key], b[key])) return false; + } + + return true; + } + + // true if both NaN, false otherwise + return a!==a && b!==b; +}; + +var jsonSchemaTraverse = {exports: {}}; + +var traverse$1 = jsonSchemaTraverse.exports = function (schema, opts, cb) { + // Legacy support for v0.3.1 and earlier. + if (typeof opts == 'function') { + cb = opts; + opts = {}; + } + + cb = opts.cb || cb; + var pre = (typeof cb == 'function') ? cb : cb.pre || function() {}; + var post = cb.post || function() {}; + + _traverse(opts, pre, post, schema, '', schema); +}; + + +traverse$1.keywords = { + additionalItems: true, + items: true, + contains: true, + additionalProperties: true, + propertyNames: true, + not: true, + if: true, + then: true, + else: true +}; + +traverse$1.arrayKeywords = { + items: true, + allOf: true, + anyOf: true, + oneOf: true +}; + +traverse$1.propsKeywords = { + $defs: true, + definitions: true, + properties: true, + patternProperties: true, + dependencies: true +}; + +traverse$1.skipKeywords = { + default: true, + enum: true, + const: true, + required: true, + maximum: true, + minimum: true, + exclusiveMaximum: true, + exclusiveMinimum: true, + multipleOf: true, + maxLength: true, + minLength: true, + pattern: true, + format: true, + maxItems: true, + minItems: true, + uniqueItems: true, + maxProperties: true, + minProperties: true +}; + + +function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) { + if (schema && typeof schema == 'object' && !Array.isArray(schema)) { + pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex); + for (var key in schema) { + var sch = schema[key]; + if (Array.isArray(sch)) { + if (key in traverse$1.arrayKeywords) { + for (var i=0; i (count += countKeys(sch))); + } + if (count === Infinity) + return Infinity; + } + return count; +} +function getFullPath(resolver, id = "", normalize) { + if (normalize !== false) + id = normalizeId(id); + const p = resolver.parse(id); + return _getFullPath(resolver, p); +} +resolve$1.getFullPath = getFullPath; +function _getFullPath(resolver, p) { + const serialized = resolver.serialize(p); + return serialized.split("#")[0] + "#"; +} +resolve$1._getFullPath = _getFullPath; +const TRAILING_SLASH_HASH = /#\/?$/; +function normalizeId(id) { + return id ? id.replace(TRAILING_SLASH_HASH, "") : ""; +} +resolve$1.normalizeId = normalizeId; +function resolveUrl(resolver, baseId, id) { + id = normalizeId(id); + return resolver.resolve(baseId, id); +} +resolve$1.resolveUrl = resolveUrl; +const ANCHOR = /^[a-z_][-a-z0-9._]*$/i; +function getSchemaRefs(schema, baseId) { + if (typeof schema == "boolean") + return {}; + const { schemaId, uriResolver } = this.opts; + const schId = normalizeId(schema[schemaId] || baseId); + const baseIds = { "": schId }; + const pathPrefix = getFullPath(uriResolver, schId, false); + const localRefs = {}; + const schemaRefs = new Set(); + traverse(schema, { allKeys: true }, (sch, jsonPtr, _, parentJsonPtr) => { + if (parentJsonPtr === undefined) + return; + const fullPath = pathPrefix + jsonPtr; + let baseId = baseIds[parentJsonPtr]; + if (typeof sch[schemaId] == "string") + baseId = addRef.call(this, sch[schemaId]); + addAnchor.call(this, sch.$anchor); + addAnchor.call(this, sch.$dynamicAnchor); + baseIds[jsonPtr] = baseId; + function addRef(ref) { + // eslint-disable-next-line @typescript-eslint/unbound-method + const _resolve = this.opts.uriResolver.resolve; + ref = normalizeId(baseId ? _resolve(baseId, ref) : ref); + if (schemaRefs.has(ref)) + throw ambiguos(ref); + schemaRefs.add(ref); + let schOrRef = this.refs[ref]; + if (typeof schOrRef == "string") + schOrRef = this.refs[schOrRef]; + if (typeof schOrRef == "object") { + checkAmbiguosRef(sch, schOrRef.schema, ref); + } + else if (ref !== normalizeId(fullPath)) { + if (ref[0] === "#") { + checkAmbiguosRef(sch, localRefs[ref], ref); + localRefs[ref] = sch; + } + else { + this.refs[ref] = fullPath; + } + } + return ref; + } + function addAnchor(anchor) { + if (typeof anchor == "string") { + if (!ANCHOR.test(anchor)) + throw new Error(`invalid anchor "${anchor}"`); + addRef.call(this, `#${anchor}`); + } + } + }); + return localRefs; + function checkAmbiguosRef(sch1, sch2, ref) { + if (sch2 !== undefined && !equal$2(sch1, sch2)) + throw ambiguos(ref); + } + function ambiguos(ref) { + return new Error(`reference "${ref}" resolves to more than one schema`); + } +} +resolve$1.getSchemaRefs = getSchemaRefs; + +Object.defineProperty(validate, "__esModule", { value: true }); +validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0; +const boolSchema_1 = boolSchema; +const dataType_1$1 = dataType; +const applicability_1 = applicability; +const dataType_2 = dataType; +const defaults_1 = defaults; +const keyword_1 = keyword; +const subschema_1 = subschema; +const codegen_1$n = codegen; +const names_1$3 = names$1; +const resolve_1$2 = resolve$1; +const util_1$l = util; +const errors_1 = errors$1; +// schema compilation - generates validation function, subschemaCode (below) is used for subschemas +function validateFunctionCode(it) { + if (isSchemaObj(it)) { + checkKeywords(it); + if (schemaCxtHasRules(it)) { + topSchemaObjCode(it); + return; + } + } + validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it)); +} +validate.validateFunctionCode = validateFunctionCode; +function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) { + if (opts.code.es5) { + gen.func(validateName, (0, codegen_1$n._) `${names_1$3.default.data}, ${names_1$3.default.valCxt}`, schemaEnv.$async, () => { + gen.code((0, codegen_1$n._) `"use strict"; ${funcSourceUrl(schema, opts)}`); + destructureValCxtES5(gen, opts); + gen.code(body); + }); + } + else { + gen.func(validateName, (0, codegen_1$n._) `${names_1$3.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body)); + } +} +function destructureValCxt(opts) { + return (0, codegen_1$n._) `{${names_1$3.default.instancePath}="", ${names_1$3.default.parentData}, ${names_1$3.default.parentDataProperty}, ${names_1$3.default.rootData}=${names_1$3.default.data}${opts.dynamicRef ? (0, codegen_1$n._) `, ${names_1$3.default.dynamicAnchors}={}` : codegen_1$n.nil}}={}`; +} +function destructureValCxtES5(gen, opts) { + gen.if(names_1$3.default.valCxt, () => { + gen.var(names_1$3.default.instancePath, (0, codegen_1$n._) `${names_1$3.default.valCxt}.${names_1$3.default.instancePath}`); + gen.var(names_1$3.default.parentData, (0, codegen_1$n._) `${names_1$3.default.valCxt}.${names_1$3.default.parentData}`); + gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._) `${names_1$3.default.valCxt}.${names_1$3.default.parentDataProperty}`); + gen.var(names_1$3.default.rootData, (0, codegen_1$n._) `${names_1$3.default.valCxt}.${names_1$3.default.rootData}`); + if (opts.dynamicRef) + gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._) `${names_1$3.default.valCxt}.${names_1$3.default.dynamicAnchors}`); + }, () => { + gen.var(names_1$3.default.instancePath, (0, codegen_1$n._) `""`); + gen.var(names_1$3.default.parentData, (0, codegen_1$n._) `undefined`); + gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._) `undefined`); + gen.var(names_1$3.default.rootData, names_1$3.default.data); + if (opts.dynamicRef) + gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._) `{}`); + }); +} +function topSchemaObjCode(it) { + const { schema, opts, gen } = it; + validateFunction(it, () => { + if (opts.$comment && schema.$comment) + commentKeyword(it); + checkNoDefault(it); + gen.let(names_1$3.default.vErrors, null); + gen.let(names_1$3.default.errors, 0); + if (opts.unevaluated) + resetEvaluated(it); + typeAndKeywords(it); + returnResults(it); + }); + return; +} +function resetEvaluated(it) { + // TODO maybe some hook to execute it in the end to check whether props/items are Name, as in assignEvaluated + const { gen, validateName } = it; + it.evaluated = gen.const("evaluated", (0, codegen_1$n._) `${validateName}.evaluated`); + gen.if((0, codegen_1$n._) `${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$n._) `${it.evaluated}.props`, (0, codegen_1$n._) `undefined`)); + gen.if((0, codegen_1$n._) `${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$n._) `${it.evaluated}.items`, (0, codegen_1$n._) `undefined`)); +} +function funcSourceUrl(schema, opts) { + const schId = typeof schema == "object" && schema[opts.schemaId]; + return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$n._) `/*# sourceURL=${schId} */` : codegen_1$n.nil; +} +// schema compilation - this function is used recursively to generate code for sub-schemas +function subschemaCode(it, valid) { + if (isSchemaObj(it)) { + checkKeywords(it); + if (schemaCxtHasRules(it)) { + subSchemaObjCode(it, valid); + return; + } + } + (0, boolSchema_1.boolOrEmptySchema)(it, valid); +} +function schemaCxtHasRules({ schema, self }) { + if (typeof schema == "boolean") + return !schema; + for (const key in schema) + if (self.RULES.all[key]) + return true; + return false; +} +function isSchemaObj(it) { + return typeof it.schema != "boolean"; +} +function subSchemaObjCode(it, valid) { + const { schema, gen, opts } = it; + if (opts.$comment && schema.$comment) + commentKeyword(it); + updateContext(it); + checkAsyncSchema(it); + const errsCount = gen.const("_errs", names_1$3.default.errors); + typeAndKeywords(it, errsCount); + // TODO var + gen.var(valid, (0, codegen_1$n._) `${errsCount} === ${names_1$3.default.errors}`); +} +function checkKeywords(it) { + (0, util_1$l.checkUnknownRules)(it); + checkRefsAndKeywords(it); +} +function typeAndKeywords(it, errsCount) { + if (it.opts.jtd) + return schemaKeywords(it, [], false, errsCount); + const types = (0, dataType_1$1.getSchemaTypes)(it.schema); + const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types); + schemaKeywords(it, types, !checkedTypes, errsCount); +} +function checkRefsAndKeywords(it) { + const { schema, errSchemaPath, opts, self } = it; + if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$l.schemaHasRulesButRef)(schema, self.RULES)) { + self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`); + } +} +function checkNoDefault(it) { + const { schema, opts } = it; + if (schema.default !== undefined && opts.useDefaults && opts.strictSchema) { + (0, util_1$l.checkStrictMode)(it, "default is ignored in the schema root"); + } +} +function updateContext(it) { + const schId = it.schema[it.opts.schemaId]; + if (schId) + it.baseId = (0, resolve_1$2.resolveUrl)(it.opts.uriResolver, it.baseId, schId); +} +function checkAsyncSchema(it) { + if (it.schema.$async && !it.schemaEnv.$async) + throw new Error("async schema in sync schema"); +} +function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) { + const msg = schema.$comment; + if (opts.$comment === true) { + gen.code((0, codegen_1$n._) `${names_1$3.default.self}.logger.log(${msg})`); + } + else if (typeof opts.$comment == "function") { + const schemaPath = (0, codegen_1$n.str) `${errSchemaPath}/$comment`; + const rootName = gen.scopeValue("root", { ref: schemaEnv.root }); + gen.code((0, codegen_1$n._) `${names_1$3.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`); + } +} +function returnResults(it) { + const { gen, schemaEnv, validateName, ValidationError, opts } = it; + if (schemaEnv.$async) { + // TODO assign unevaluated + gen.if((0, codegen_1$n._) `${names_1$3.default.errors} === 0`, () => gen.return(names_1$3.default.data), () => gen.throw((0, codegen_1$n._) `new ${ValidationError}(${names_1$3.default.vErrors})`)); + } + else { + gen.assign((0, codegen_1$n._) `${validateName}.errors`, names_1$3.default.vErrors); + if (opts.unevaluated) + assignEvaluated(it); + gen.return((0, codegen_1$n._) `${names_1$3.default.errors} === 0`); + } +} +function assignEvaluated({ gen, evaluated, props, items }) { + if (props instanceof codegen_1$n.Name) + gen.assign((0, codegen_1$n._) `${evaluated}.props`, props); + if (items instanceof codegen_1$n.Name) + gen.assign((0, codegen_1$n._) `${evaluated}.items`, items); +} +function schemaKeywords(it, types, typeErrors, errsCount) { + const { gen, schema, data, allErrors, opts, self } = it; + const { RULES } = self; + if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$l.schemaHasRulesButRef)(schema, RULES))) { + gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition)); // TODO typecast + return; + } + if (!opts.jtd) + checkStrictTypes(it, types); + gen.block(() => { + for (const group of RULES.rules) + groupKeywords(group); + groupKeywords(RULES.post); + }); + function groupKeywords(group) { + if (!(0, applicability_1.shouldUseGroup)(schema, group)) + return; + if (group.type) { + gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers)); + iterateKeywords(it, group); + if (types.length === 1 && types[0] === group.type && typeErrors) { + gen.else(); + (0, dataType_2.reportTypeError)(it); + } + gen.endIf(); + } + else { + iterateKeywords(it, group); + } + // TODO make it "ok" call? + if (!allErrors) + gen.if((0, codegen_1$n._) `${names_1$3.default.errors} === ${errsCount || 0}`); + } +} +function iterateKeywords(it, group) { + const { gen, schema, opts: { useDefaults }, } = it; + if (useDefaults) + (0, defaults_1.assignDefaults)(it, group.type); + gen.block(() => { + for (const rule of group.rules) { + if ((0, applicability_1.shouldUseRule)(schema, rule)) { + keywordCode(it, rule.keyword, rule.definition, group.type); + } + } + }); +} +function checkStrictTypes(it, types) { + if (it.schemaEnv.meta || !it.opts.strictTypes) + return; + checkContextTypes(it, types); + if (!it.opts.allowUnionTypes) + checkMultipleTypes(it, types); + checkKeywordTypes(it, it.dataTypes); +} +function checkContextTypes(it, types) { + if (!types.length) + return; + if (!it.dataTypes.length) { + it.dataTypes = types; + return; + } + types.forEach((t) => { + if (!includesType(it.dataTypes, t)) { + strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`); + } + }); + narrowSchemaTypes(it, types); +} +function checkMultipleTypes(it, ts) { + if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) { + strictTypesError(it, "use allowUnionTypes to allow union type keyword"); + } +} +function checkKeywordTypes(it, ts) { + const rules = it.self.RULES.all; + for (const keyword in rules) { + const rule = rules[keyword]; + if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) { + const { type } = rule.definition; + if (type.length && !type.some((t) => hasApplicableType(ts, t))) { + strictTypesError(it, `missing type "${type.join(",")}" for keyword "${keyword}"`); + } + } + } +} +function hasApplicableType(schTs, kwdT) { + return schTs.includes(kwdT) || (kwdT === "number" && schTs.includes("integer")); +} +function includesType(ts, t) { + return ts.includes(t) || (t === "integer" && ts.includes("number")); +} +function narrowSchemaTypes(it, withTypes) { + const ts = []; + for (const t of it.dataTypes) { + if (includesType(withTypes, t)) + ts.push(t); + else if (withTypes.includes("integer") && t === "number") + ts.push("integer"); + } + it.dataTypes = ts; +} +function strictTypesError(it, msg) { + const schemaPath = it.schemaEnv.baseId + it.errSchemaPath; + msg += ` at "${schemaPath}" (strictTypes)`; + (0, util_1$l.checkStrictMode)(it, msg, it.opts.strictTypes); +} +class KeywordCxt { + constructor(it, def, keyword) { + (0, keyword_1.validateKeywordUsage)(it, def, keyword); + this.gen = it.gen; + this.allErrors = it.allErrors; + this.keyword = keyword; + this.data = it.data; + this.schema = it.schema[keyword]; + this.$data = def.$data && it.opts.$data && this.schema && this.schema.$data; + this.schemaValue = (0, util_1$l.schemaRefOrVal)(it, this.schema, keyword, this.$data); + this.schemaType = def.schemaType; + this.parentSchema = it.schema; + this.params = {}; + this.it = it; + this.def = def; + if (this.$data) { + this.schemaCode = it.gen.const("vSchema", getData(this.$data, it)); + } + else { + this.schemaCode = this.schemaValue; + if (!(0, keyword_1.validSchemaType)(this.schema, def.schemaType, def.allowUndefined)) { + throw new Error(`${keyword} value must be ${JSON.stringify(def.schemaType)}`); + } + } + if ("code" in def ? def.trackErrors : def.errors !== false) { + this.errsCount = it.gen.const("_errs", names_1$3.default.errors); + } + } + result(condition, successAction, failAction) { + this.failResult((0, codegen_1$n.not)(condition), successAction, failAction); + } + failResult(condition, successAction, failAction) { + this.gen.if(condition); + if (failAction) + failAction(); + else + this.error(); + if (successAction) { + this.gen.else(); + successAction(); + if (this.allErrors) + this.gen.endIf(); + } + else { + if (this.allErrors) + this.gen.endIf(); + else + this.gen.else(); + } + } + pass(condition, failAction) { + this.failResult((0, codegen_1$n.not)(condition), undefined, failAction); + } + fail(condition) { + if (condition === undefined) { + this.error(); + if (!this.allErrors) + this.gen.if(false); // this branch will be removed by gen.optimize + return; + } + this.gen.if(condition); + this.error(); + if (this.allErrors) + this.gen.endIf(); + else + this.gen.else(); + } + fail$data(condition) { + if (!this.$data) + return this.fail(condition); + const { schemaCode } = this; + this.fail((0, codegen_1$n._) `${schemaCode} !== undefined && (${(0, codegen_1$n.or)(this.invalid$data(), condition)})`); + } + error(append, errorParams, errorPaths) { + if (errorParams) { + this.setParams(errorParams); + this._error(append, errorPaths); + this.setParams({}); + return; + } + this._error(append, errorPaths); + } + _error(append, errorPaths) { + (append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths); + } + $dataError() { + (0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError); + } + reset() { + if (this.errsCount === undefined) + throw new Error('add "trackErrors" to keyword definition'); + (0, errors_1.resetErrorsCount)(this.gen, this.errsCount); + } + ok(cond) { + if (!this.allErrors) + this.gen.if(cond); + } + setParams(obj, assign) { + if (assign) + Object.assign(this.params, obj); + else + this.params = obj; + } + block$data(valid, codeBlock, $dataValid = codegen_1$n.nil) { + this.gen.block(() => { + this.check$data(valid, $dataValid); + codeBlock(); + }); + } + check$data(valid = codegen_1$n.nil, $dataValid = codegen_1$n.nil) { + if (!this.$data) + return; + const { gen, schemaCode, schemaType, def } = this; + gen.if((0, codegen_1$n.or)((0, codegen_1$n._) `${schemaCode} === undefined`, $dataValid)); + if (valid !== codegen_1$n.nil) + gen.assign(valid, true); + if (schemaType.length || def.validateSchema) { + gen.elseIf(this.invalid$data()); + this.$dataError(); + if (valid !== codegen_1$n.nil) + gen.assign(valid, false); + } + gen.else(); + } + invalid$data() { + const { gen, schemaCode, schemaType, def, it } = this; + return (0, codegen_1$n.or)(wrong$DataType(), invalid$DataSchema()); + function wrong$DataType() { + if (schemaType.length) { + /* istanbul ignore if */ + if (!(schemaCode instanceof codegen_1$n.Name)) + throw new Error("ajv implementation error"); + const st = Array.isArray(schemaType) ? schemaType : [schemaType]; + return (0, codegen_1$n._) `${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`; + } + return codegen_1$n.nil; + } + function invalid$DataSchema() { + if (def.validateSchema) { + const validateSchemaRef = gen.scopeValue("validate$data", { ref: def.validateSchema }); // TODO value.code for standalone + return (0, codegen_1$n._) `!${validateSchemaRef}(${schemaCode})`; + } + return codegen_1$n.nil; + } + } + subschema(appl, valid) { + const subschema = (0, subschema_1.getSubschema)(this.it, appl); + (0, subschema_1.extendSubschemaData)(subschema, this.it, appl); + (0, subschema_1.extendSubschemaMode)(subschema, appl); + const nextContext = { ...this.it, ...subschema, items: undefined, props: undefined }; + subschemaCode(nextContext, valid); + return nextContext; + } + mergeEvaluated(schemaCxt, toName) { + const { it, gen } = this; + if (!it.opts.unevaluated) + return; + if (it.props !== true && schemaCxt.props !== undefined) { + it.props = util_1$l.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName); + } + if (it.items !== true && schemaCxt.items !== undefined) { + it.items = util_1$l.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName); + } + } + mergeValidEvaluated(schemaCxt, valid) { + const { it, gen } = this; + if (it.opts.unevaluated && (it.props !== true || it.items !== true)) { + gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1$n.Name)); + return true; + } + } +} +validate.KeywordCxt = KeywordCxt; +function keywordCode(it, keyword, def, ruleType) { + const cxt = new KeywordCxt(it, def, keyword); + if ("code" in def) { + def.code(cxt, ruleType); + } + else if (cxt.$data && def.validate) { + (0, keyword_1.funcKeywordCode)(cxt, def); + } + else if ("macro" in def) { + (0, keyword_1.macroKeywordCode)(cxt, def); + } + else if (def.compile || def.validate) { + (0, keyword_1.funcKeywordCode)(cxt, def); + } +} +const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/; +const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/; +function getData($data, { dataLevel, dataNames, dataPathArr }) { + let jsonPointer; + let data; + if ($data === "") + return names_1$3.default.rootData; + if ($data[0] === "/") { + if (!JSON_POINTER.test($data)) + throw new Error(`Invalid JSON-pointer: ${$data}`); + jsonPointer = $data; + data = names_1$3.default.rootData; + } + else { + const matches = RELATIVE_JSON_POINTER.exec($data); + if (!matches) + throw new Error(`Invalid JSON-pointer: ${$data}`); + const up = +matches[1]; + jsonPointer = matches[2]; + if (jsonPointer === "#") { + if (up >= dataLevel) + throw new Error(errorMsg("property/index", up)); + return dataPathArr[dataLevel - up]; + } + if (up > dataLevel) + throw new Error(errorMsg("data", up)); + data = dataNames[dataLevel - up]; + if (!jsonPointer) + return data; + } + let expr = data; + const segments = jsonPointer.split("/"); + for (const segment of segments) { + if (segment) { + data = (0, codegen_1$n._) `${data}${(0, codegen_1$n.getProperty)((0, util_1$l.unescapeJsonPointer)(segment))}`; + expr = (0, codegen_1$n._) `${expr} && ${data}`; + } + } + return expr; + function errorMsg(pointerType, up) { + return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`; + } +} +validate.getData = getData; + +var validation_error = {}; + +Object.defineProperty(validation_error, "__esModule", { value: true }); +class ValidationError extends Error { + constructor(errors) { + super("validation failed"); + this.errors = errors; + this.ajv = this.validation = true; + } +} +validation_error.default = ValidationError; + +var ref_error = {}; + +Object.defineProperty(ref_error, "__esModule", { value: true }); +const resolve_1$1 = resolve$1; +class MissingRefError extends Error { + constructor(resolver, baseId, ref, msg) { + super(msg || `can't resolve reference ${ref} from id ${baseId}`); + this.missingRef = (0, resolve_1$1.resolveUrl)(resolver, baseId, ref); + this.missingSchema = (0, resolve_1$1.normalizeId)((0, resolve_1$1.getFullPath)(resolver, this.missingRef)); + } +} +ref_error.default = MissingRefError; + +var compile = {}; + +Object.defineProperty(compile, "__esModule", { value: true }); +compile.resolveSchema = compile.getCompilingSchema = compile.resolveRef = compile.compileSchema = compile.SchemaEnv = void 0; +const codegen_1$m = codegen; +const validation_error_1 = validation_error; +const names_1$2 = names$1; +const resolve_1 = resolve$1; +const util_1$k = util; +const validate_1$1 = validate; +class SchemaEnv { + constructor(env) { + var _a; + this.refs = {}; + this.dynamicAnchors = {}; + let schema; + if (typeof env.schema == "object") + schema = env.schema; + this.schema = env.schema; + this.schemaId = env.schemaId; + this.root = env.root || this; + this.baseId = (_a = env.baseId) !== null && _a !== void 0 ? _a : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env.schemaId || "$id"]); + this.schemaPath = env.schemaPath; + this.localRefs = env.localRefs; + this.meta = env.meta; + this.$async = schema === null || schema === void 0 ? void 0 : schema.$async; + this.refs = {}; + } +} +compile.SchemaEnv = SchemaEnv; +// let codeSize = 0 +// let nodeCount = 0 +// Compiles schema in SchemaEnv +function compileSchema(sch) { + // TODO refactor - remove compilations + const _sch = getCompilingSchema.call(this, sch); + if (_sch) + return _sch; + const rootId = (0, resolve_1.getFullPath)(this.opts.uriResolver, sch.root.baseId); // TODO if getFullPath removed 1 tests fails + const { es5, lines } = this.opts.code; + const { ownProperties } = this.opts; + const gen = new codegen_1$m.CodeGen(this.scope, { es5, lines, ownProperties }); + let _ValidationError; + if (sch.$async) { + _ValidationError = gen.scopeValue("Error", { + ref: validation_error_1.default, + code: (0, codegen_1$m._) `require("ajv/dist/runtime/validation_error").default`, + }); + } + const validateName = gen.scopeName("validate"); + sch.validateName = validateName; + const schemaCxt = { + gen, + allErrors: this.opts.allErrors, + data: names_1$2.default.data, + parentData: names_1$2.default.parentData, + parentDataProperty: names_1$2.default.parentDataProperty, + dataNames: [names_1$2.default.data], + dataPathArr: [codegen_1$m.nil], + dataLevel: 0, + dataTypes: [], + definedProperties: new Set(), + topSchemaRef: gen.scopeValue("schema", this.opts.code.source === true + ? { ref: sch.schema, code: (0, codegen_1$m.stringify)(sch.schema) } + : { ref: sch.schema }), + validateName, + ValidationError: _ValidationError, + schema: sch.schema, + schemaEnv: sch, + rootId, + baseId: sch.baseId || rootId, + schemaPath: codegen_1$m.nil, + errSchemaPath: sch.schemaPath || (this.opts.jtd ? "" : "#"), + errorPath: (0, codegen_1$m._) `""`, + opts: this.opts, + self: this, + }; + let sourceCode; + try { + this._compilations.add(sch); + (0, validate_1$1.validateFunctionCode)(schemaCxt); + gen.optimize(this.opts.code.optimize); + // gen.optimize(1) + const validateCode = gen.toString(); + sourceCode = `${gen.scopeRefs(names_1$2.default.scope)}return ${validateCode}`; + // console.log((codeSize += sourceCode.length), (nodeCount += gen.nodeCount)) + if (this.opts.code.process) + sourceCode = this.opts.code.process(sourceCode, sch); + // console.log("\n\n\n *** \n", sourceCode) + const makeValidate = new Function(`${names_1$2.default.self}`, `${names_1$2.default.scope}`, sourceCode); + const validate = makeValidate(this, this.scope.get()); + this.scope.value(validateName, { ref: validate }); + validate.errors = null; + validate.schema = sch.schema; + validate.schemaEnv = sch; + if (sch.$async) + validate.$async = true; + if (this.opts.code.source === true) { + validate.source = { validateName, validateCode, scopeValues: gen._values }; + } + if (this.opts.unevaluated) { + const { props, items } = schemaCxt; + validate.evaluated = { + props: props instanceof codegen_1$m.Name ? undefined : props, + items: items instanceof codegen_1$m.Name ? undefined : items, + dynamicProps: props instanceof codegen_1$m.Name, + dynamicItems: items instanceof codegen_1$m.Name, + }; + if (validate.source) + validate.source.evaluated = (0, codegen_1$m.stringify)(validate.evaluated); + } + sch.validate = validate; + return sch; + } + catch (e) { + delete sch.validate; + delete sch.validateName; + if (sourceCode) + this.logger.error("Error compiling schema, function code:", sourceCode); + // console.log("\n\n\n *** \n", sourceCode, this.opts) + throw e; + } + finally { + this._compilations.delete(sch); + } +} +compile.compileSchema = compileSchema; +function resolveRef(root, baseId, ref) { + var _a; + ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref); + const schOrFunc = root.refs[ref]; + if (schOrFunc) + return schOrFunc; + let _sch = resolve.call(this, root, ref); + if (_sch === undefined) { + const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref]; // TODO maybe localRefs should hold SchemaEnv + const { schemaId } = this.opts; + if (schema) + _sch = new SchemaEnv({ schema, schemaId, root, baseId }); + } + if (_sch === undefined) + return; + return (root.refs[ref] = inlineOrCompile.call(this, _sch)); +} +compile.resolveRef = resolveRef; +function inlineOrCompile(sch) { + if ((0, resolve_1.inlineRef)(sch.schema, this.opts.inlineRefs)) + return sch.schema; + return sch.validate ? sch : compileSchema.call(this, sch); +} +// Index of schema compilation in the currently compiled list +function getCompilingSchema(schEnv) { + for (const sch of this._compilations) { + if (sameSchemaEnv(sch, schEnv)) + return sch; + } +} +compile.getCompilingSchema = getCompilingSchema; +function sameSchemaEnv(s1, s2) { + return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId; +} +// resolve and compile the references ($ref) +// TODO returns AnySchemaObject (if the schema can be inlined) or validation function +function resolve(root, // information about the root schema for the current schema +ref // reference to resolve +) { + let sch; + while (typeof (sch = this.refs[ref]) == "string") + ref = sch; + return sch || this.schemas[ref] || resolveSchema.call(this, root, ref); +} +// Resolve schema, its root and baseId +function resolveSchema(root, // root object with properties schema, refs TODO below SchemaEnv is assigned to it +ref // reference to resolve +) { + const p = this.opts.uriResolver.parse(ref); + const refPath = (0, resolve_1._getFullPath)(this.opts.uriResolver, p); + let baseId = (0, resolve_1.getFullPath)(this.opts.uriResolver, root.baseId, undefined); + // TODO `Object.keys(root.schema).length > 0` should not be needed - but removing breaks 2 tests + if (Object.keys(root.schema).length > 0 && refPath === baseId) { + return getJsonPointer.call(this, p, root); + } + const id = (0, resolve_1.normalizeId)(refPath); + const schOrRef = this.refs[id] || this.schemas[id]; + if (typeof schOrRef == "string") { + const sch = resolveSchema.call(this, root, schOrRef); + if (typeof (sch === null || sch === void 0 ? void 0 : sch.schema) !== "object") + return; + return getJsonPointer.call(this, p, sch); + } + if (typeof (schOrRef === null || schOrRef === void 0 ? void 0 : schOrRef.schema) !== "object") + return; + if (!schOrRef.validate) + compileSchema.call(this, schOrRef); + if (id === (0, resolve_1.normalizeId)(ref)) { + const { schema } = schOrRef; + const { schemaId } = this.opts; + const schId = schema[schemaId]; + if (schId) + baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId); + return new SchemaEnv({ schema, schemaId, root, baseId }); + } + return getJsonPointer.call(this, p, schOrRef); +} +compile.resolveSchema = resolveSchema; +const PREVENT_SCOPE_CHANGE = new Set([ + "properties", + "patternProperties", + "enum", + "dependencies", + "definitions", +]); +function getJsonPointer(parsedRef, { baseId, schema, root }) { + var _a; + if (((_a = parsedRef.fragment) === null || _a === void 0 ? void 0 : _a[0]) !== "/") + return; + for (const part of parsedRef.fragment.slice(1).split("/")) { + if (typeof schema === "boolean") + return; + const partSchema = schema[(0, util_1$k.unescapeFragment)(part)]; + if (partSchema === undefined) + return; + schema = partSchema; + // TODO PREVENT_SCOPE_CHANGE could be defined in keyword def? + const schId = typeof schema === "object" && schema[this.opts.schemaId]; + if (!PREVENT_SCOPE_CHANGE.has(part) && schId) { + baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId); + } + } + let env; + if (typeof schema != "boolean" && schema.$ref && !(0, util_1$k.schemaHasRulesButRef)(schema, this.RULES)) { + const $ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schema.$ref); + env = resolveSchema.call(this, root, $ref); + } + // even though resolution failed we need to return SchemaEnv to throw exception + // so that compileAsync loads missing schema. + const { schemaId } = this.opts; + env = env || new SchemaEnv({ schema, schemaId, root, baseId }); + if (env.schema !== env.root.schema) + return env; + return undefined; +} + +var $id$1 = "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"; +var description = "Meta-schema for $data reference (JSON AnySchema extension proposal)"; +var type$1 = "object"; +var required$1 = [ + "$data" +]; +var properties$2 = { + $data: { + type: "string", + anyOf: [ + { + format: "relative-json-pointer" + }, + { + format: "json-pointer" + } + ] + } +}; +var additionalProperties$1 = false; +var require$$9 = { + $id: $id$1, + description: description, + type: type$1, + required: required$1, + properties: properties$2, + additionalProperties: additionalProperties$1 +}; + +var uri$1 = {}; + +var uri_all = {exports: {}}; + +/** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */ + +(function (module, exports) { + (function (global, factory) { + factory(exports) ; + }(commonjsGlobal, (function (exports) { + function merge() { + for (var _len = arguments.length, sets = Array(_len), _key = 0; _key < _len; _key++) { + sets[_key] = arguments[_key]; + } + + if (sets.length > 1) { + sets[0] = sets[0].slice(0, -1); + var xl = sets.length - 1; + for (var x = 1; x < xl; ++x) { + sets[x] = sets[x].slice(1, -1); + } + sets[xl] = sets[xl].slice(1); + return sets.join(''); + } else { + return sets[0]; + } + } + function subexp(str) { + return "(?:" + str + ")"; + } + function typeOf(o) { + return o === undefined ? "undefined" : o === null ? "null" : Object.prototype.toString.call(o).split(" ").pop().split("]").shift().toLowerCase(); + } + function toUpperCase(str) { + return str.toUpperCase(); + } + function toArray(obj) { + return obj !== undefined && obj !== null ? obj instanceof Array ? obj : typeof obj.length !== "number" || obj.split || obj.setInterval || obj.call ? [obj] : Array.prototype.slice.call(obj) : []; + } + function assign(target, source) { + var obj = target; + if (source) { + for (var key in source) { + obj[key] = source[key]; + } + } + return obj; + } + + function buildExps(isIRI) { + var ALPHA$$ = "[A-Za-z]", + DIGIT$$ = "[0-9]", + HEXDIG$$ = merge(DIGIT$$, "[A-Fa-f]"), + PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)), + //expanded + GEN_DELIMS$$ = "[\\:\\/\\?\\#\\[\\]\\@]", + SUB_DELIMS$$ = "[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]", + RESERVED$$ = merge(GEN_DELIMS$$, SUB_DELIMS$$), + UCSCHAR$$ = isIRI ? "[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]" : "[]", + //subset, excludes bidi control characters + IPRIVATE$$ = isIRI ? "[\\uE000-\\uF8FF]" : "[]", + //subset + UNRESERVED$$ = merge(ALPHA$$, DIGIT$$, "[\\-\\.\\_\\~]", UCSCHAR$$); + subexp(ALPHA$$ + merge(ALPHA$$, DIGIT$$, "[\\+\\-\\.]") + "*"); + subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]")) + "*"); + var DEC_OCTET_RELAXED$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("0?[1-9]" + DIGIT$$) + "|0?0?" + DIGIT$$), + //relaxed parsing rules + IPV4ADDRESS$ = subexp(DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$), + H16$ = subexp(HEXDIG$$ + "{1,4}"), + LS32$ = subexp(subexp(H16$ + "\\:" + H16$) + "|" + IPV4ADDRESS$), + IPV6ADDRESS1$ = subexp(subexp(H16$ + "\\:") + "{6}" + LS32$), + // 6( h16 ":" ) ls32 + IPV6ADDRESS2$ = subexp("\\:\\:" + subexp(H16$ + "\\:") + "{5}" + LS32$), + // "::" 5( h16 ":" ) ls32 + IPV6ADDRESS3$ = subexp(subexp(H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{4}" + LS32$), + //[ h16 ] "::" 4( h16 ":" ) ls32 + IPV6ADDRESS4$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,1}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{3}" + LS32$), + //[ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32 + IPV6ADDRESS5$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,2}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{2}" + LS32$), + //[ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32 + IPV6ADDRESS6$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,3}" + H16$) + "?\\:\\:" + H16$ + "\\:" + LS32$), + //[ *3( h16 ":" ) h16 ] "::" h16 ":" ls32 + IPV6ADDRESS7$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,4}" + H16$) + "?\\:\\:" + LS32$), + //[ *4( h16 ":" ) h16 ] "::" ls32 + IPV6ADDRESS8$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,5}" + H16$) + "?\\:\\:" + H16$), + //[ *5( h16 ":" ) h16 ] "::" h16 + IPV6ADDRESS9$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,6}" + H16$) + "?\\:\\:"), + //[ *6( h16 ":" ) h16 ] "::" + IPV6ADDRESS$ = subexp([IPV6ADDRESS1$, IPV6ADDRESS2$, IPV6ADDRESS3$, IPV6ADDRESS4$, IPV6ADDRESS5$, IPV6ADDRESS6$, IPV6ADDRESS7$, IPV6ADDRESS8$, IPV6ADDRESS9$].join("|")), + ZONEID$ = subexp(subexp(UNRESERVED$$ + "|" + PCT_ENCODED$) + "+"); + //RFC 6874, with relaxed parsing rules + subexp("[vV]" + HEXDIG$$ + "+\\." + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:]") + "+"); + //RFC 6874 + subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$)) + "*"); + var PCHAR$ = subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@]")); + subexp(subexp(PCT_ENCODED$ + "|" + merge(UNRESERVED$$, SUB_DELIMS$$, "[\\@]")) + "+"); + subexp(subexp(PCHAR$ + "|" + merge("[\\/\\?]", IPRIVATE$$)) + "*"); + return { + NOT_SCHEME: new RegExp(merge("[^]", ALPHA$$, DIGIT$$, "[\\+\\-\\.]"), "g"), + NOT_USERINFO: new RegExp(merge("[^\\%\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"), + NOT_HOST: new RegExp(merge("[^\\%\\[\\]\\:]", UNRESERVED$$, SUB_DELIMS$$), "g"), + NOT_PATH: new RegExp(merge("[^\\%\\/\\:\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"), + NOT_PATH_NOSCHEME: new RegExp(merge("[^\\%\\/\\@]", UNRESERVED$$, SUB_DELIMS$$), "g"), + NOT_QUERY: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]", IPRIVATE$$), "g"), + NOT_FRAGMENT: new RegExp(merge("[^\\%]", UNRESERVED$$, SUB_DELIMS$$, "[\\:\\@\\/\\?]"), "g"), + ESCAPE: new RegExp(merge("[^]", UNRESERVED$$, SUB_DELIMS$$), "g"), + UNRESERVED: new RegExp(UNRESERVED$$, "g"), + OTHER_CHARS: new RegExp(merge("[^\\%]", UNRESERVED$$, RESERVED$$), "g"), + PCT_ENCODED: new RegExp(PCT_ENCODED$, "g"), + IPV4ADDRESS: new RegExp("^(" + IPV4ADDRESS$ + ")$"), + IPV6ADDRESS: new RegExp("^\\[?(" + IPV6ADDRESS$ + ")" + subexp(subexp("\\%25|\\%(?!" + HEXDIG$$ + "{2})") + "(" + ZONEID$ + ")") + "?\\]?$") //RFC 6874, with relaxed parsing rules + }; + } + var URI_PROTOCOL = buildExps(false); + + var IRI_PROTOCOL = buildExps(true); + + var slicedToArray = function () { + function sliceIterator(arr, i) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } + + return function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return sliceIterator(arr, i); + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + }(); + + + + + + + + + + + + + + var toConsumableArray = function (arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; + + return arr2; + } else { + return Array.from(arr); + } + }; + + /** Highest positive signed 32-bit float value */ + + var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1 + + /** Bootstring parameters */ + var base = 36; + var tMin = 1; + var tMax = 26; + var skew = 38; + var damp = 700; + var initialBias = 72; + var initialN = 128; // 0x80 + var delimiter = '-'; // '\x2D' + + /** Regular expressions */ + var regexPunycode = /^xn--/; + var regexNonASCII = /[^\0-\x7E]/; // non-ASCII chars + var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators + + /** Error messages */ + var errors = { + 'overflow': 'Overflow: input needs wider integers to process', + 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', + 'invalid-input': 'Invalid input' + }; + + /** Convenience shortcuts */ + var baseMinusTMin = base - tMin; + var floor = Math.floor; + var stringFromCharCode = String.fromCharCode; + + /*--------------------------------------------------------------------------*/ + + /** + * A generic error utility function. + * @private + * @param {String} type The error type. + * @returns {Error} Throws a `RangeError` with the applicable error message. + */ + function error$1(type) { + throw new RangeError(errors[type]); + } + + /** + * A generic `Array#map` utility function. + * @private + * @param {Array} array The array to iterate over. + * @param {Function} callback The function that gets called for every array + * item. + * @returns {Array} A new array of values returned by the callback function. + */ + function map(array, fn) { + var result = []; + var length = array.length; + while (length--) { + result[length] = fn(array[length]); + } + return result; + } + + /** + * A simple `Array#map`-like wrapper to work with domain name strings or email + * addresses. + * @private + * @param {String} domain The domain name or email address. + * @param {Function} callback The function that gets called for every + * character. + * @returns {Array} A new string of characters returned by the callback + * function. + */ + function mapDomain(string, fn) { + var parts = string.split('@'); + var result = ''; + if (parts.length > 1) { + // In email addresses, only the domain name should be punycoded. Leave + // the local part (i.e. everything up to `@`) intact. + result = parts[0] + '@'; + string = parts[1]; + } + // Avoid `split(regex)` for IE8 compatibility. See #17. + string = string.replace(regexSeparators, '\x2E'); + var labels = string.split('.'); + var encoded = map(labels, fn).join('.'); + return result + encoded; + } + + /** + * Creates an array containing the numeric code points of each Unicode + * character in the string. While JavaScript uses UCS-2 internally, + * this function will convert a pair of surrogate halves (each of which + * UCS-2 exposes as separate characters) into a single code point, + * matching UTF-16. + * @see `punycode.ucs2.encode` + * @see + * @memberOf punycode.ucs2 + * @name decode + * @param {String} string The Unicode input string (UCS-2). + * @returns {Array} The new array of code points. + */ + function ucs2decode(string) { + var output = []; + var counter = 0; + var length = string.length; + while (counter < length) { + var value = string.charCodeAt(counter++); + if (value >= 0xD800 && value <= 0xDBFF && counter < length) { + // It's a high surrogate, and there is a next character. + var extra = string.charCodeAt(counter++); + if ((extra & 0xFC00) == 0xDC00) { + // Low surrogate. + output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); + } else { + // It's an unmatched surrogate; only append this code unit, in case the + // next code unit is the high surrogate of a surrogate pair. + output.push(value); + counter--; + } + } else { + output.push(value); + } + } + return output; + } + + /** + * Creates a string based on an array of numeric code points. + * @see `punycode.ucs2.decode` + * @memberOf punycode.ucs2 + * @name encode + * @param {Array} codePoints The array of numeric code points. + * @returns {String} The new Unicode string (UCS-2). + */ + var ucs2encode = function ucs2encode(array) { + return String.fromCodePoint.apply(String, toConsumableArray(array)); + }; + + /** + * Converts a basic code point into a digit/integer. + * @see `digitToBasic()` + * @private + * @param {Number} codePoint The basic numeric code point value. + * @returns {Number} The numeric value of a basic code point (for use in + * representing integers) in the range `0` to `base - 1`, or `base` if + * the code point does not represent a value. + */ + var basicToDigit = function basicToDigit(codePoint) { + if (codePoint - 0x30 < 0x0A) { + return codePoint - 0x16; + } + if (codePoint - 0x41 < 0x1A) { + return codePoint - 0x41; + } + if (codePoint - 0x61 < 0x1A) { + return codePoint - 0x61; + } + return base; + }; + + /** + * Converts a digit/integer into a basic code point. + * @see `basicToDigit()` + * @private + * @param {Number} digit The numeric value of a basic code point. + * @returns {Number} The basic code point whose value (when used for + * representing integers) is `digit`, which needs to be in the range + * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is + * used; else, the lowercase form is used. The behavior is undefined + * if `flag` is non-zero and `digit` has no uppercase form. + */ + var digitToBasic = function digitToBasic(digit, flag) { + // 0..25 map to ASCII a..z or A..Z + // 26..35 map to ASCII 0..9 + return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); + }; + + /** + * Bias adaptation function as per section 3.4 of RFC 3492. + * https://tools.ietf.org/html/rfc3492#section-3.4 + * @private + */ + var adapt = function adapt(delta, numPoints, firstTime) { + var k = 0; + delta = firstTime ? floor(delta / damp) : delta >> 1; + delta += floor(delta / numPoints); + for (; /* no initialization */delta > baseMinusTMin * tMax >> 1; k += base) { + delta = floor(delta / baseMinusTMin); + } + return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); + }; + + /** + * Converts a Punycode string of ASCII-only symbols to a string of Unicode + * symbols. + * @memberOf punycode + * @param {String} input The Punycode string of ASCII-only symbols. + * @returns {String} The resulting string of Unicode symbols. + */ + var decode = function decode(input) { + // Don't use UCS-2. + var output = []; + var inputLength = input.length; + var i = 0; + var n = initialN; + var bias = initialBias; + + // Handle the basic code points: let `basic` be the number of input code + // points before the last delimiter, or `0` if there is none, then copy + // the first basic code points to the output. + + var basic = input.lastIndexOf(delimiter); + if (basic < 0) { + basic = 0; + } + + for (var j = 0; j < basic; ++j) { + // if it's not a basic code point + if (input.charCodeAt(j) >= 0x80) { + error$1('not-basic'); + } + output.push(input.charCodeAt(j)); + } + + // Main decoding loop: start just after the last delimiter if any basic code + // points were copied; start at the beginning otherwise. + + for (var index = basic > 0 ? basic + 1 : 0; index < inputLength;) /* no final expression */{ + + // `index` is the index of the next character to be consumed. + // Decode a generalized variable-length integer into `delta`, + // which gets added to `i`. The overflow checking is easier + // if we increase `i` as we go, then subtract off its starting + // value at the end to obtain `delta`. + var oldi = i; + for (var w = 1, k = base;; /* no condition */k += base) { + + if (index >= inputLength) { + error$1('invalid-input'); + } + + var digit = basicToDigit(input.charCodeAt(index++)); + + if (digit >= base || digit > floor((maxInt - i) / w)) { + error$1('overflow'); + } + + i += digit * w; + var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias; + + if (digit < t) { + break; + } + + var baseMinusT = base - t; + if (w > floor(maxInt / baseMinusT)) { + error$1('overflow'); + } + + w *= baseMinusT; + } + + var out = output.length + 1; + bias = adapt(i - oldi, out, oldi == 0); + + // `i` was supposed to wrap around from `out` to `0`, + // incrementing `n` each time, so we'll fix that now: + if (floor(i / out) > maxInt - n) { + error$1('overflow'); + } + + n += floor(i / out); + i %= out; + + // Insert `n` at position `i` of the output. + output.splice(i++, 0, n); + } + + return String.fromCodePoint.apply(String, output); + }; + + /** + * Converts a string of Unicode symbols (e.g. a domain name label) to a + * Punycode string of ASCII-only symbols. + * @memberOf punycode + * @param {String} input The string of Unicode symbols. + * @returns {String} The resulting Punycode string of ASCII-only symbols. + */ + var encode = function encode(input) { + var output = []; + + // Convert the input in UCS-2 to an array of Unicode code points. + input = ucs2decode(input); + + // Cache the length. + var inputLength = input.length; + + // Initialize the state. + var n = initialN; + var delta = 0; + var bias = initialBias; + + // Handle the basic code points. + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = input[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var _currentValue2 = _step.value; + + if (_currentValue2 < 0x80) { + output.push(stringFromCharCode(_currentValue2)); + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + var basicLength = output.length; + var handledCPCount = basicLength; + + // `handledCPCount` is the number of code points that have been handled; + // `basicLength` is the number of basic code points. + + // Finish the basic string with a delimiter unless it's empty. + if (basicLength) { + output.push(delimiter); + } + + // Main encoding loop: + while (handledCPCount < inputLength) { + + // All non-basic code points < n have been handled already. Find the next + // larger one: + var m = maxInt; + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = input[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var currentValue = _step2.value; + + if (currentValue >= n && currentValue < m) { + m = currentValue; + } + } + + // Increase `delta` enough to advance the decoder's state to , + // but guard against overflow. + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + + var handledCPCountPlusOne = handledCPCount + 1; + if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { + error$1('overflow'); + } + + delta += (m - n) * handledCPCountPlusOne; + n = m; + + var _iteratorNormalCompletion3 = true; + var _didIteratorError3 = false; + var _iteratorError3 = undefined; + + try { + for (var _iterator3 = input[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { + var _currentValue = _step3.value; + + if (_currentValue < n && ++delta > maxInt) { + error$1('overflow'); + } + if (_currentValue == n) { + // Represent delta as a generalized variable-length integer. + var q = delta; + for (var k = base;; /* no condition */k += base) { + var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias; + if (q < t) { + break; + } + var qMinusT = q - t; + var baseMinusT = base - t; + output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))); + q = floor(qMinusT / baseMinusT); + } + + output.push(stringFromCharCode(digitToBasic(q, 0))); + bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); + delta = 0; + ++handledCPCount; + } + } + } catch (err) { + _didIteratorError3 = true; + _iteratorError3 = err; + } finally { + try { + if (!_iteratorNormalCompletion3 && _iterator3.return) { + _iterator3.return(); + } + } finally { + if (_didIteratorError3) { + throw _iteratorError3; + } + } + } + + ++delta; + ++n; + } + return output.join(''); + }; + + /** + * Converts a Punycode string representing a domain name or an email address + * to Unicode. Only the Punycoded parts of the input will be converted, i.e. + * it doesn't matter if you call it on a string that has already been + * converted to Unicode. + * @memberOf punycode + * @param {String} input The Punycoded domain name or email address to + * convert to Unicode. + * @returns {String} The Unicode representation of the given Punycode + * string. + */ + var toUnicode = function toUnicode(input) { + return mapDomain(input, function (string) { + return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string; + }); + }; + + /** + * Converts a Unicode string representing a domain name or an email address to + * Punycode. Only the non-ASCII parts of the domain name will be converted, + * i.e. it doesn't matter if you call it with a domain that's already in + * ASCII. + * @memberOf punycode + * @param {String} input The domain name or email address to convert, as a + * Unicode string. + * @returns {String} The Punycode representation of the given domain name or + * email address. + */ + var toASCII = function toASCII(input) { + return mapDomain(input, function (string) { + return regexNonASCII.test(string) ? 'xn--' + encode(string) : string; + }); + }; + + /*--------------------------------------------------------------------------*/ + + /** Define the public API */ + var punycode = { + /** + * A string representing the current Punycode.js version number. + * @memberOf punycode + * @type String + */ + 'version': '2.1.0', + /** + * An object of methods to convert from JavaScript's internal character + * representation (UCS-2) to Unicode code points, and back. + * @see + * @memberOf punycode + * @type Object + */ + 'ucs2': { + 'decode': ucs2decode, + 'encode': ucs2encode + }, + 'decode': decode, + 'encode': encode, + 'toASCII': toASCII, + 'toUnicode': toUnicode + }; + + /** + * URI.js + * + * @fileoverview An RFC 3986 compliant, scheme extendable URI parsing/validating/resolving library for JavaScript. + * @author Gary Court + * @see http://github.com/garycourt/uri-js + */ + /** + * Copyright 2011 Gary Court. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY GARY COURT ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARY COURT OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of Gary Court. + */ + var SCHEMES = {}; + function pctEncChar(chr) { + var c = chr.charCodeAt(0); + var e = void 0; + if (c < 16) e = "%0" + c.toString(16).toUpperCase();else if (c < 128) e = "%" + c.toString(16).toUpperCase();else if (c < 2048) e = "%" + (c >> 6 | 192).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();else e = "%" + (c >> 12 | 224).toString(16).toUpperCase() + "%" + (c >> 6 & 63 | 128).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase(); + return e; + } + function pctDecChars(str) { + var newStr = ""; + var i = 0; + var il = str.length; + while (i < il) { + var c = parseInt(str.substr(i + 1, 2), 16); + if (c < 128) { + newStr += String.fromCharCode(c); + i += 3; + } else if (c >= 194 && c < 224) { + if (il - i >= 6) { + var c2 = parseInt(str.substr(i + 4, 2), 16); + newStr += String.fromCharCode((c & 31) << 6 | c2 & 63); + } else { + newStr += str.substr(i, 6); + } + i += 6; + } else if (c >= 224) { + if (il - i >= 9) { + var _c = parseInt(str.substr(i + 4, 2), 16); + var c3 = parseInt(str.substr(i + 7, 2), 16); + newStr += String.fromCharCode((c & 15) << 12 | (_c & 63) << 6 | c3 & 63); + } else { + newStr += str.substr(i, 9); + } + i += 9; + } else { + newStr += str.substr(i, 3); + i += 3; + } + } + return newStr; + } + function _normalizeComponentEncoding(components, protocol) { + function decodeUnreserved(str) { + var decStr = pctDecChars(str); + return !decStr.match(protocol.UNRESERVED) ? str : decStr; + } + if (components.scheme) components.scheme = String(components.scheme).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_SCHEME, ""); + if (components.userinfo !== undefined) components.userinfo = String(components.userinfo).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_USERINFO, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase); + if (components.host !== undefined) components.host = String(components.host).replace(protocol.PCT_ENCODED, decodeUnreserved).toLowerCase().replace(protocol.NOT_HOST, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase); + if (components.path !== undefined) components.path = String(components.path).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(components.scheme ? protocol.NOT_PATH : protocol.NOT_PATH_NOSCHEME, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase); + if (components.query !== undefined) components.query = String(components.query).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_QUERY, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase); + if (components.fragment !== undefined) components.fragment = String(components.fragment).replace(protocol.PCT_ENCODED, decodeUnreserved).replace(protocol.NOT_FRAGMENT, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase); + return components; + } + + function _stripLeadingZeros(str) { + return str.replace(/^0*(.*)/, "$1") || "0"; + } + function _normalizeIPv4(host, protocol) { + var matches = host.match(protocol.IPV4ADDRESS) || []; + + var _matches = slicedToArray(matches, 2), + address = _matches[1]; + + if (address) { + return address.split(".").map(_stripLeadingZeros).join("."); + } else { + return host; + } + } + function _normalizeIPv6(host, protocol) { + var matches = host.match(protocol.IPV6ADDRESS) || []; + + var _matches2 = slicedToArray(matches, 3), + address = _matches2[1], + zone = _matches2[2]; + + if (address) { + var _address$toLowerCase$ = address.toLowerCase().split('::').reverse(), + _address$toLowerCase$2 = slicedToArray(_address$toLowerCase$, 2), + last = _address$toLowerCase$2[0], + first = _address$toLowerCase$2[1]; + + var firstFields = first ? first.split(":").map(_stripLeadingZeros) : []; + var lastFields = last.split(":").map(_stripLeadingZeros); + var isLastFieldIPv4Address = protocol.IPV4ADDRESS.test(lastFields[lastFields.length - 1]); + var fieldCount = isLastFieldIPv4Address ? 7 : 8; + var lastFieldsStart = lastFields.length - fieldCount; + var fields = Array(fieldCount); + for (var x = 0; x < fieldCount; ++x) { + fields[x] = firstFields[x] || lastFields[lastFieldsStart + x] || ''; + } + if (isLastFieldIPv4Address) { + fields[fieldCount - 1] = _normalizeIPv4(fields[fieldCount - 1], protocol); + } + var allZeroFields = fields.reduce(function (acc, field, index) { + if (!field || field === "0") { + var lastLongest = acc[acc.length - 1]; + if (lastLongest && lastLongest.index + lastLongest.length === index) { + lastLongest.length++; + } else { + acc.push({ index: index, length: 1 }); + } + } + return acc; + }, []); + var longestZeroFields = allZeroFields.sort(function (a, b) { + return b.length - a.length; + })[0]; + var newHost = void 0; + if (longestZeroFields && longestZeroFields.length > 1) { + var newFirst = fields.slice(0, longestZeroFields.index); + var newLast = fields.slice(longestZeroFields.index + longestZeroFields.length); + newHost = newFirst.join(":") + "::" + newLast.join(":"); + } else { + newHost = fields.join(":"); + } + if (zone) { + newHost += "%" + zone; + } + return newHost; + } else { + return host; + } + } + var URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i; + var NO_MATCH_IS_UNDEFINED = "".match(/(){0}/)[1] === undefined; + function parse(uriString) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + var components = {}; + var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL; + if (options.reference === "suffix") uriString = (options.scheme ? options.scheme + ":" : "") + "//" + uriString; + var matches = uriString.match(URI_PARSE); + if (matches) { + if (NO_MATCH_IS_UNDEFINED) { + //store each component + components.scheme = matches[1]; + components.userinfo = matches[3]; + components.host = matches[4]; + components.port = parseInt(matches[5], 10); + components.path = matches[6] || ""; + components.query = matches[7]; + components.fragment = matches[8]; + //fix port number + if (isNaN(components.port)) { + components.port = matches[5]; + } + } else { + //IE FIX for improper RegExp matching + //store each component + components.scheme = matches[1] || undefined; + components.userinfo = uriString.indexOf("@") !== -1 ? matches[3] : undefined; + components.host = uriString.indexOf("//") !== -1 ? matches[4] : undefined; + components.port = parseInt(matches[5], 10); + components.path = matches[6] || ""; + components.query = uriString.indexOf("?") !== -1 ? matches[7] : undefined; + components.fragment = uriString.indexOf("#") !== -1 ? matches[8] : undefined; + //fix port number + if (isNaN(components.port)) { + components.port = uriString.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/) ? matches[4] : undefined; + } + } + if (components.host) { + //normalize IP hosts + components.host = _normalizeIPv6(_normalizeIPv4(components.host, protocol), protocol); + } + //determine reference type + if (components.scheme === undefined && components.userinfo === undefined && components.host === undefined && components.port === undefined && !components.path && components.query === undefined) { + components.reference = "same-document"; + } else if (components.scheme === undefined) { + components.reference = "relative"; + } else if (components.fragment === undefined) { + components.reference = "absolute"; + } else { + components.reference = "uri"; + } + //check for reference errors + if (options.reference && options.reference !== "suffix" && options.reference !== components.reference) { + components.error = components.error || "URI is not a " + options.reference + " reference."; + } + //find scheme handler + var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()]; + //check if scheme can't handle IRIs + if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) { + //if host component is a domain name + if (components.host && (options.domainHost || schemeHandler && schemeHandler.domainHost)) { + //convert Unicode IDN -> ASCII IDN + try { + components.host = punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()); + } catch (e) { + components.error = components.error || "Host's domain name can not be converted to ASCII via punycode: " + e; + } + } + //convert IRI -> URI + _normalizeComponentEncoding(components, URI_PROTOCOL); + } else { + //normalize encodings + _normalizeComponentEncoding(components, protocol); + } + //perform scheme specific parsing + if (schemeHandler && schemeHandler.parse) { + schemeHandler.parse(components, options); + } + } else { + components.error = components.error || "URI can not be parsed."; + } + return components; + } + + function _recomposeAuthority(components, options) { + var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL; + var uriTokens = []; + if (components.userinfo !== undefined) { + uriTokens.push(components.userinfo); + uriTokens.push("@"); + } + if (components.host !== undefined) { + //normalize IP hosts, add brackets and escape zone separator for IPv6 + uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, function (_, $1, $2) { + return "[" + $1 + ($2 ? "%25" + $2 : "") + "]"; + })); + } + if (typeof components.port === "number" || typeof components.port === "string") { + uriTokens.push(":"); + uriTokens.push(String(components.port)); + } + return uriTokens.length ? uriTokens.join("") : undefined; + } + + var RDS1 = /^\.\.?\//; + var RDS2 = /^\/\.(\/|$)/; + var RDS3 = /^\/\.\.(\/|$)/; + var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/; + function removeDotSegments(input) { + var output = []; + while (input.length) { + if (input.match(RDS1)) { + input = input.replace(RDS1, ""); + } else if (input.match(RDS2)) { + input = input.replace(RDS2, "/"); + } else if (input.match(RDS3)) { + input = input.replace(RDS3, "/"); + output.pop(); + } else if (input === "." || input === "..") { + input = ""; + } else { + var im = input.match(RDS5); + if (im) { + var s = im[0]; + input = input.slice(s.length); + output.push(s); + } else { + throw new Error("Unexpected dot segment condition"); + } + } + } + return output.join(""); + } + + function serialize(components) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + + var protocol = options.iri ? IRI_PROTOCOL : URI_PROTOCOL; + var uriTokens = []; + //find scheme handler + var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()]; + //perform scheme specific serialization + if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options); + if (components.host) { + //if host component is an IPv6 address + if (protocol.IPV6ADDRESS.test(components.host)) ; + //TODO: normalize IPv6 address as per RFC 5952 + + //if host component is a domain name + else if (options.domainHost || schemeHandler && schemeHandler.domainHost) { + //convert IDN via punycode + try { + components.host = !options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host); + } catch (e) { + components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e; + } + } + } + //normalize encoding + _normalizeComponentEncoding(components, protocol); + if (options.reference !== "suffix" && components.scheme) { + uriTokens.push(components.scheme); + uriTokens.push(":"); + } + var authority = _recomposeAuthority(components, options); + if (authority !== undefined) { + if (options.reference !== "suffix") { + uriTokens.push("//"); + } + uriTokens.push(authority); + if (components.path && components.path.charAt(0) !== "/") { + uriTokens.push("/"); + } + } + if (components.path !== undefined) { + var s = components.path; + if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) { + s = removeDotSegments(s); + } + if (authority === undefined) { + s = s.replace(/^\/\//, "/%2F"); //don't allow the path to start with "//" + } + uriTokens.push(s); + } + if (components.query !== undefined) { + uriTokens.push("?"); + uriTokens.push(components.query); + } + if (components.fragment !== undefined) { + uriTokens.push("#"); + uriTokens.push(components.fragment); + } + return uriTokens.join(""); //merge tokens into a string + } + + function resolveComponents(base, relative) { + var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + var skipNormalization = arguments[3]; + + var target = {}; + if (!skipNormalization) { + base = parse(serialize(base, options), options); //normalize base components + relative = parse(serialize(relative, options), options); //normalize relative components + } + options = options || {}; + if (!options.tolerant && relative.scheme) { + target.scheme = relative.scheme; + //target.authority = relative.authority; + target.userinfo = relative.userinfo; + target.host = relative.host; + target.port = relative.port; + target.path = removeDotSegments(relative.path || ""); + target.query = relative.query; + } else { + if (relative.userinfo !== undefined || relative.host !== undefined || relative.port !== undefined) { + //target.authority = relative.authority; + target.userinfo = relative.userinfo; + target.host = relative.host; + target.port = relative.port; + target.path = removeDotSegments(relative.path || ""); + target.query = relative.query; + } else { + if (!relative.path) { + target.path = base.path; + if (relative.query !== undefined) { + target.query = relative.query; + } else { + target.query = base.query; + } + } else { + if (relative.path.charAt(0) === "/") { + target.path = removeDotSegments(relative.path); + } else { + if ((base.userinfo !== undefined || base.host !== undefined || base.port !== undefined) && !base.path) { + target.path = "/" + relative.path; + } else if (!base.path) { + target.path = relative.path; + } else { + target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path; + } + target.path = removeDotSegments(target.path); + } + target.query = relative.query; + } + //target.authority = base.authority; + target.userinfo = base.userinfo; + target.host = base.host; + target.port = base.port; + } + target.scheme = base.scheme; + } + target.fragment = relative.fragment; + return target; + } + + function resolve(baseURI, relativeURI, options) { + var schemelessOptions = assign({ scheme: 'null' }, options); + return serialize(resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions); + } + + function normalize(uri, options) { + if (typeof uri === "string") { + uri = serialize(parse(uri, options), options); + } else if (typeOf(uri) === "object") { + uri = parse(serialize(uri, options), options); + } + return uri; + } + + function equal(uriA, uriB, options) { + if (typeof uriA === "string") { + uriA = serialize(parse(uriA, options), options); + } else if (typeOf(uriA) === "object") { + uriA = serialize(uriA, options); + } + if (typeof uriB === "string") { + uriB = serialize(parse(uriB, options), options); + } else if (typeOf(uriB) === "object") { + uriB = serialize(uriB, options); + } + return uriA === uriB; + } + + function escapeComponent(str, options) { + return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.ESCAPE : IRI_PROTOCOL.ESCAPE, pctEncChar); + } + + function unescapeComponent(str, options) { + return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.PCT_ENCODED : IRI_PROTOCOL.PCT_ENCODED, pctDecChars); + } + + var handler = { + scheme: "http", + domainHost: true, + parse: function parse(components, options) { + //report missing host + if (!components.host) { + components.error = components.error || "HTTP URIs must have a host."; + } + return components; + }, + serialize: function serialize(components, options) { + var secure = String(components.scheme).toLowerCase() === "https"; + //normalize the default port + if (components.port === (secure ? 443 : 80) || components.port === "") { + components.port = undefined; + } + //normalize the empty path + if (!components.path) { + components.path = "/"; + } + //NOTE: We do not parse query strings for HTTP URIs + //as WWW Form Url Encoded query strings are part of the HTML4+ spec, + //and not the HTTP spec. + return components; + } + }; + + var handler$1 = { + scheme: "https", + domainHost: handler.domainHost, + parse: handler.parse, + serialize: handler.serialize + }; + + function isSecure(wsComponents) { + return typeof wsComponents.secure === 'boolean' ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss"; + } + //RFC 6455 + var handler$2 = { + scheme: "ws", + domainHost: true, + parse: function parse(components, options) { + var wsComponents = components; + //indicate if the secure flag is set + wsComponents.secure = isSecure(wsComponents); + //construct resouce name + wsComponents.resourceName = (wsComponents.path || '/') + (wsComponents.query ? '?' + wsComponents.query : ''); + wsComponents.path = undefined; + wsComponents.query = undefined; + return wsComponents; + }, + serialize: function serialize(wsComponents, options) { + //normalize the default port + if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") { + wsComponents.port = undefined; + } + //ensure scheme matches secure flag + if (typeof wsComponents.secure === 'boolean') { + wsComponents.scheme = wsComponents.secure ? 'wss' : 'ws'; + wsComponents.secure = undefined; + } + //reconstruct path from resource name + if (wsComponents.resourceName) { + var _wsComponents$resourc = wsComponents.resourceName.split('?'), + _wsComponents$resourc2 = slicedToArray(_wsComponents$resourc, 2), + path = _wsComponents$resourc2[0], + query = _wsComponents$resourc2[1]; + + wsComponents.path = path && path !== '/' ? path : undefined; + wsComponents.query = query; + wsComponents.resourceName = undefined; + } + //forbid fragment component + wsComponents.fragment = undefined; + return wsComponents; + } + }; + + var handler$3 = { + scheme: "wss", + domainHost: handler$2.domainHost, + parse: handler$2.parse, + serialize: handler$2.serialize + }; + + var O = {}; + //RFC 3986 + var UNRESERVED$$ = "[A-Za-z0-9\\-\\.\\_\\~" + ("\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF" ) + "]"; + var HEXDIG$$ = "[0-9A-Fa-f]"; //case-insensitive + var PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$)); //expanded + //RFC 5322, except these symbols as per RFC 6068: @ : / ? # [ ] & ; = + //const ATEXT$$ = "[A-Za-z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]"; + //const WSP$$ = "[\\x20\\x09]"; + //const OBS_QTEXT$$ = "[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7F]"; //(%d1-8 / %d11-12 / %d14-31 / %d127) + //const QTEXT$$ = merge("[\\x21\\x23-\\x5B\\x5D-\\x7E]", OBS_QTEXT$$); //%d33 / %d35-91 / %d93-126 / obs-qtext + //const VCHAR$$ = "[\\x21-\\x7E]"; + //const WSP$$ = "[\\x20\\x09]"; + //const OBS_QP$ = subexp("\\\\" + merge("[\\x00\\x0D\\x0A]", OBS_QTEXT$$)); //%d0 / CR / LF / obs-qtext + //const FWS$ = subexp(subexp(WSP$$ + "*" + "\\x0D\\x0A") + "?" + WSP$$ + "+"); + //const QUOTED_PAIR$ = subexp(subexp("\\\\" + subexp(VCHAR$$ + "|" + WSP$$)) + "|" + OBS_QP$); + //const QUOTED_STRING$ = subexp('\\"' + subexp(FWS$ + "?" + QCONTENT$) + "*" + FWS$ + "?" + '\\"'); + var ATEXT$$ = "[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]"; + var QTEXT$$ = "[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]"; + var VCHAR$$ = merge(QTEXT$$, "[\\\"\\\\]"); + var SOME_DELIMS$$ = "[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]"; + var UNRESERVED = new RegExp(UNRESERVED$$, "g"); + var PCT_ENCODED = new RegExp(PCT_ENCODED$, "g"); + var NOT_LOCAL_PART = new RegExp(merge("[^]", ATEXT$$, "[\\.]", '[\\"]', VCHAR$$), "g"); + var NOT_HFNAME = new RegExp(merge("[^]", UNRESERVED$$, SOME_DELIMS$$), "g"); + var NOT_HFVALUE = NOT_HFNAME; + function decodeUnreserved(str) { + var decStr = pctDecChars(str); + return !decStr.match(UNRESERVED) ? str : decStr; + } + var handler$4 = { + scheme: "mailto", + parse: function parse$$1(components, options) { + var mailtoComponents = components; + var to = mailtoComponents.to = mailtoComponents.path ? mailtoComponents.path.split(",") : []; + mailtoComponents.path = undefined; + if (mailtoComponents.query) { + var unknownHeaders = false; + var headers = {}; + var hfields = mailtoComponents.query.split("&"); + for (var x = 0, xl = hfields.length; x < xl; ++x) { + var hfield = hfields[x].split("="); + switch (hfield[0]) { + case "to": + var toAddrs = hfield[1].split(","); + for (var _x = 0, _xl = toAddrs.length; _x < _xl; ++_x) { + to.push(toAddrs[_x]); + } + break; + case "subject": + mailtoComponents.subject = unescapeComponent(hfield[1], options); + break; + case "body": + mailtoComponents.body = unescapeComponent(hfield[1], options); + break; + default: + unknownHeaders = true; + headers[unescapeComponent(hfield[0], options)] = unescapeComponent(hfield[1], options); + break; + } + } + if (unknownHeaders) mailtoComponents.headers = headers; + } + mailtoComponents.query = undefined; + for (var _x2 = 0, _xl2 = to.length; _x2 < _xl2; ++_x2) { + var addr = to[_x2].split("@"); + addr[0] = unescapeComponent(addr[0]); + if (!options.unicodeSupport) { + //convert Unicode IDN -> ASCII IDN + try { + addr[1] = punycode.toASCII(unescapeComponent(addr[1], options).toLowerCase()); + } catch (e) { + mailtoComponents.error = mailtoComponents.error || "Email address's domain name can not be converted to ASCII via punycode: " + e; + } + } else { + addr[1] = unescapeComponent(addr[1], options).toLowerCase(); + } + to[_x2] = addr.join("@"); + } + return mailtoComponents; + }, + serialize: function serialize$$1(mailtoComponents, options) { + var components = mailtoComponents; + var to = toArray(mailtoComponents.to); + if (to) { + for (var x = 0, xl = to.length; x < xl; ++x) { + var toAddr = String(to[x]); + var atIdx = toAddr.lastIndexOf("@"); + var localPart = toAddr.slice(0, atIdx).replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_LOCAL_PART, pctEncChar); + var domain = toAddr.slice(atIdx + 1); + //convert IDN via punycode + try { + domain = !options.iri ? punycode.toASCII(unescapeComponent(domain, options).toLowerCase()) : punycode.toUnicode(domain); + } catch (e) { + components.error = components.error || "Email address's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e; + } + to[x] = localPart + "@" + domain; + } + components.path = to.join(","); + } + var headers = mailtoComponents.headers = mailtoComponents.headers || {}; + if (mailtoComponents.subject) headers["subject"] = mailtoComponents.subject; + if (mailtoComponents.body) headers["body"] = mailtoComponents.body; + var fields = []; + for (var name in headers) { + if (headers[name] !== O[name]) { + fields.push(name.replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFNAME, pctEncChar) + "=" + headers[name].replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFVALUE, pctEncChar)); + } + } + if (fields.length) { + components.query = fields.join("&"); + } + return components; + } + }; + + var URN_PARSE = /^([^\:]+)\:(.*)/; + //RFC 2141 + var handler$5 = { + scheme: "urn", + parse: function parse$$1(components, options) { + var matches = components.path && components.path.match(URN_PARSE); + var urnComponents = components; + if (matches) { + var scheme = options.scheme || urnComponents.scheme || "urn"; + var nid = matches[1].toLowerCase(); + var nss = matches[2]; + var urnScheme = scheme + ":" + (options.nid || nid); + var schemeHandler = SCHEMES[urnScheme]; + urnComponents.nid = nid; + urnComponents.nss = nss; + urnComponents.path = undefined; + if (schemeHandler) { + urnComponents = schemeHandler.parse(urnComponents, options); + } + } else { + urnComponents.error = urnComponents.error || "URN can not be parsed."; + } + return urnComponents; + }, + serialize: function serialize$$1(urnComponents, options) { + var scheme = options.scheme || urnComponents.scheme || "urn"; + var nid = urnComponents.nid; + var urnScheme = scheme + ":" + (options.nid || nid); + var schemeHandler = SCHEMES[urnScheme]; + if (schemeHandler) { + urnComponents = schemeHandler.serialize(urnComponents, options); + } + var uriComponents = urnComponents; + var nss = urnComponents.nss; + uriComponents.path = (nid || options.nid) + ":" + nss; + return uriComponents; + } + }; + + var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/; + //RFC 4122 + var handler$6 = { + scheme: "urn:uuid", + parse: function parse(urnComponents, options) { + var uuidComponents = urnComponents; + uuidComponents.uuid = uuidComponents.nss; + uuidComponents.nss = undefined; + if (!options.tolerant && (!uuidComponents.uuid || !uuidComponents.uuid.match(UUID))) { + uuidComponents.error = uuidComponents.error || "UUID is not valid."; + } + return uuidComponents; + }, + serialize: function serialize(uuidComponents, options) { + var urnComponents = uuidComponents; + //normalize UUID + urnComponents.nss = (uuidComponents.uuid || "").toLowerCase(); + return urnComponents; + } + }; + + SCHEMES[handler.scheme] = handler; + SCHEMES[handler$1.scheme] = handler$1; + SCHEMES[handler$2.scheme] = handler$2; + SCHEMES[handler$3.scheme] = handler$3; + SCHEMES[handler$4.scheme] = handler$4; + SCHEMES[handler$5.scheme] = handler$5; + SCHEMES[handler$6.scheme] = handler$6; + + exports.SCHEMES = SCHEMES; + exports.pctEncChar = pctEncChar; + exports.pctDecChars = pctDecChars; + exports.parse = parse; + exports.removeDotSegments = removeDotSegments; + exports.serialize = serialize; + exports.resolveComponents = resolveComponents; + exports.resolve = resolve; + exports.normalize = normalize; + exports.equal = equal; + exports.escapeComponent = escapeComponent; + exports.unescapeComponent = unescapeComponent; + + Object.defineProperty(exports, '__esModule', { value: true }); + + }))); + +} (uri_all, uri_all.exports)); + +var uri_allExports = uri_all.exports; + +Object.defineProperty(uri$1, "__esModule", { value: true }); +const uri = uri_allExports; +uri.code = 'require("ajv/dist/runtime/uri").default'; +uri$1.default = uri; + +(function (exports) { + Object.defineProperty(exports, "__esModule", { value: true }); + exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0; + var validate_1 = validate; + Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function () { return validate_1.KeywordCxt; } }); + var codegen_1 = codegen; + Object.defineProperty(exports, "_", { enumerable: true, get: function () { return codegen_1._; } }); + Object.defineProperty(exports, "str", { enumerable: true, get: function () { return codegen_1.str; } }); + Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return codegen_1.stringify; } }); + Object.defineProperty(exports, "nil", { enumerable: true, get: function () { return codegen_1.nil; } }); + Object.defineProperty(exports, "Name", { enumerable: true, get: function () { return codegen_1.Name; } }); + Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function () { return codegen_1.CodeGen; } }); + const validation_error_1 = validation_error; + const ref_error_1 = ref_error; + const rules_1 = rules; + const compile_1 = compile; + const codegen_2 = codegen; + const resolve_1 = resolve$1; + const dataType_1 = dataType; + const util_1 = util; + const $dataRefSchema = require$$9; + const uri_1 = uri$1; + const defaultRegExp = (str, flags) => new RegExp(str, flags); + defaultRegExp.code = "new RegExp"; + const META_IGNORE_OPTIONS = ["removeAdditional", "useDefaults", "coerceTypes"]; + const EXT_SCOPE_NAMES = new Set([ + "validate", + "serialize", + "parse", + "wrapper", + "root", + "schema", + "keyword", + "pattern", + "formats", + "validate$data", + "func", + "obj", + "Error", + ]); + const removedOptions = { + errorDataPath: "", + format: "`validateFormats: false` can be used instead.", + nullable: '"nullable" keyword is supported by default.', + jsonPointers: "Deprecated jsPropertySyntax can be used instead.", + extendRefs: "Deprecated ignoreKeywordsWithRef can be used instead.", + missingRefs: "Pass empty schema with $id that should be ignored to ajv.addSchema.", + processCode: "Use option `code: {process: (code, schemaEnv: object) => string}`", + sourceCode: "Use option `code: {source: true}`", + strictDefaults: "It is default now, see option `strict`.", + strictKeywords: "It is default now, see option `strict`.", + uniqueItems: '"uniqueItems" keyword is always validated.', + unknownFormats: "Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).", + cache: "Map is used as cache, schema object as key.", + serialize: "Map is used as cache, schema object as key.", + ajvErrors: "It is default now.", + }; + const deprecatedOptions = { + ignoreKeywordsWithRef: "", + jsPropertySyntax: "", + unicode: '"minLength"/"maxLength" account for unicode characters by default.', + }; + const MAX_EXPRESSION = 200; + // eslint-disable-next-line complexity + function requiredOptions(o) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0; + const s = o.strict; + const _optz = (_a = o.code) === null || _a === void 0 ? void 0 : _a.optimize; + const optimize = _optz === true || _optz === undefined ? 1 : _optz || 0; + const regExp = (_c = (_b = o.code) === null || _b === void 0 ? void 0 : _b.regExp) !== null && _c !== void 0 ? _c : defaultRegExp; + const uriResolver = (_d = o.uriResolver) !== null && _d !== void 0 ? _d : uri_1.default; + return { + strictSchema: (_f = (_e = o.strictSchema) !== null && _e !== void 0 ? _e : s) !== null && _f !== void 0 ? _f : true, + strictNumbers: (_h = (_g = o.strictNumbers) !== null && _g !== void 0 ? _g : s) !== null && _h !== void 0 ? _h : true, + strictTypes: (_k = (_j = o.strictTypes) !== null && _j !== void 0 ? _j : s) !== null && _k !== void 0 ? _k : "log", + strictTuples: (_m = (_l = o.strictTuples) !== null && _l !== void 0 ? _l : s) !== null && _m !== void 0 ? _m : "log", + strictRequired: (_p = (_o = o.strictRequired) !== null && _o !== void 0 ? _o : s) !== null && _p !== void 0 ? _p : false, + code: o.code ? { ...o.code, optimize, regExp } : { optimize, regExp }, + loopRequired: (_q = o.loopRequired) !== null && _q !== void 0 ? _q : MAX_EXPRESSION, + loopEnum: (_r = o.loopEnum) !== null && _r !== void 0 ? _r : MAX_EXPRESSION, + meta: (_s = o.meta) !== null && _s !== void 0 ? _s : true, + messages: (_t = o.messages) !== null && _t !== void 0 ? _t : true, + inlineRefs: (_u = o.inlineRefs) !== null && _u !== void 0 ? _u : true, + schemaId: (_v = o.schemaId) !== null && _v !== void 0 ? _v : "$id", + addUsedSchema: (_w = o.addUsedSchema) !== null && _w !== void 0 ? _w : true, + validateSchema: (_x = o.validateSchema) !== null && _x !== void 0 ? _x : true, + validateFormats: (_y = o.validateFormats) !== null && _y !== void 0 ? _y : true, + unicodeRegExp: (_z = o.unicodeRegExp) !== null && _z !== void 0 ? _z : true, + int32range: (_0 = o.int32range) !== null && _0 !== void 0 ? _0 : true, + uriResolver: uriResolver, + }; + } + class Ajv { + constructor(opts = {}) { + this.schemas = {}; + this.refs = {}; + this.formats = {}; + this._compilations = new Set(); + this._loading = {}; + this._cache = new Map(); + opts = this.opts = { ...opts, ...requiredOptions(opts) }; + const { es5, lines } = this.opts.code; + this.scope = new codegen_2.ValueScope({ scope: {}, prefixes: EXT_SCOPE_NAMES, es5, lines }); + this.logger = getLogger(opts.logger); + const formatOpt = opts.validateFormats; + opts.validateFormats = false; + this.RULES = (0, rules_1.getRules)(); + checkOptions.call(this, removedOptions, opts, "NOT SUPPORTED"); + checkOptions.call(this, deprecatedOptions, opts, "DEPRECATED", "warn"); + this._metaOpts = getMetaSchemaOptions.call(this); + if (opts.formats) + addInitialFormats.call(this); + this._addVocabularies(); + this._addDefaultMetaSchema(); + if (opts.keywords) + addInitialKeywords.call(this, opts.keywords); + if (typeof opts.meta == "object") + this.addMetaSchema(opts.meta); + addInitialSchemas.call(this); + opts.validateFormats = formatOpt; + } + _addVocabularies() { + this.addKeyword("$async"); + } + _addDefaultMetaSchema() { + const { $data, meta, schemaId } = this.opts; + let _dataRefSchema = $dataRefSchema; + if (schemaId === "id") { + _dataRefSchema = { ...$dataRefSchema }; + _dataRefSchema.id = _dataRefSchema.$id; + delete _dataRefSchema.$id; + } + if (meta && $data) + this.addMetaSchema(_dataRefSchema, _dataRefSchema[schemaId], false); + } + defaultMeta() { + const { meta, schemaId } = this.opts; + return (this.opts.defaultMeta = typeof meta == "object" ? meta[schemaId] || meta : undefined); + } + validate(schemaKeyRef, // key, ref or schema object + data // to be validated + ) { + let v; + if (typeof schemaKeyRef == "string") { + v = this.getSchema(schemaKeyRef); + if (!v) + throw new Error(`no schema with key or ref "${schemaKeyRef}"`); + } + else { + v = this.compile(schemaKeyRef); + } + const valid = v(data); + if (!("$async" in v)) + this.errors = v.errors; + return valid; + } + compile(schema, _meta) { + const sch = this._addSchema(schema, _meta); + return (sch.validate || this._compileSchemaEnv(sch)); + } + compileAsync(schema, meta) { + if (typeof this.opts.loadSchema != "function") { + throw new Error("options.loadSchema should be a function"); + } + const { loadSchema } = this.opts; + return runCompileAsync.call(this, schema, meta); + async function runCompileAsync(_schema, _meta) { + await loadMetaSchema.call(this, _schema.$schema); + const sch = this._addSchema(_schema, _meta); + return sch.validate || _compileAsync.call(this, sch); + } + async function loadMetaSchema($ref) { + if ($ref && !this.getSchema($ref)) { + await runCompileAsync.call(this, { $ref }, true); + } + } + async function _compileAsync(sch) { + try { + return this._compileSchemaEnv(sch); + } + catch (e) { + if (!(e instanceof ref_error_1.default)) + throw e; + checkLoaded.call(this, e); + await loadMissingSchema.call(this, e.missingSchema); + return _compileAsync.call(this, sch); + } + } + function checkLoaded({ missingSchema: ref, missingRef }) { + if (this.refs[ref]) { + throw new Error(`AnySchema ${ref} is loaded but ${missingRef} cannot be resolved`); + } + } + async function loadMissingSchema(ref) { + const _schema = await _loadSchema.call(this, ref); + if (!this.refs[ref]) + await loadMetaSchema.call(this, _schema.$schema); + if (!this.refs[ref]) + this.addSchema(_schema, ref, meta); + } + async function _loadSchema(ref) { + const p = this._loading[ref]; + if (p) + return p; + try { + return await (this._loading[ref] = loadSchema(ref)); + } + finally { + delete this._loading[ref]; + } + } + } + // Adds schema to the instance + addSchema(schema, // If array is passed, `key` will be ignored + key, // Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`. + _meta, // true if schema is a meta-schema. Used internally, addMetaSchema should be used instead. + _validateSchema = this.opts.validateSchema // false to skip schema validation. Used internally, option validateSchema should be used instead. + ) { + if (Array.isArray(schema)) { + for (const sch of schema) + this.addSchema(sch, undefined, _meta, _validateSchema); + return this; + } + let id; + if (typeof schema === "object") { + const { schemaId } = this.opts; + id = schema[schemaId]; + if (id !== undefined && typeof id != "string") { + throw new Error(`schema ${schemaId} must be string`); + } + } + key = (0, resolve_1.normalizeId)(key || id); + this._checkUnique(key); + this.schemas[key] = this._addSchema(schema, _meta, key, _validateSchema, true); + return this; + } + // Add schema that will be used to validate other schemas + // options in META_IGNORE_OPTIONS are alway set to false + addMetaSchema(schema, key, // schema key + _validateSchema = this.opts.validateSchema // false to skip schema validation, can be used to override validateSchema option for meta-schema + ) { + this.addSchema(schema, key, true, _validateSchema); + return this; + } + // Validate schema against its meta-schema + validateSchema(schema, throwOrLogError) { + if (typeof schema == "boolean") + return true; + let $schema; + $schema = schema.$schema; + if ($schema !== undefined && typeof $schema != "string") { + throw new Error("$schema must be a string"); + } + $schema = $schema || this.opts.defaultMeta || this.defaultMeta(); + if (!$schema) { + this.logger.warn("meta-schema not available"); + this.errors = null; + return true; + } + const valid = this.validate($schema, schema); + if (!valid && throwOrLogError) { + const message = "schema is invalid: " + this.errorsText(); + if (this.opts.validateSchema === "log") + this.logger.error(message); + else + throw new Error(message); + } + return valid; + } + // Get compiled schema by `key` or `ref`. + // (`key` that was passed to `addSchema` or full schema reference - `schema.$id` or resolved id) + getSchema(keyRef) { + let sch; + while (typeof (sch = getSchEnv.call(this, keyRef)) == "string") + keyRef = sch; + if (sch === undefined) { + const { schemaId } = this.opts; + const root = new compile_1.SchemaEnv({ schema: {}, schemaId }); + sch = compile_1.resolveSchema.call(this, root, keyRef); + if (!sch) + return; + this.refs[keyRef] = sch; + } + return (sch.validate || this._compileSchemaEnv(sch)); + } + // Remove cached schema(s). + // If no parameter is passed all schemas but meta-schemas are removed. + // If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed. + // Even if schema is referenced by other schemas it still can be removed as other schemas have local references. + removeSchema(schemaKeyRef) { + if (schemaKeyRef instanceof RegExp) { + this._removeAllSchemas(this.schemas, schemaKeyRef); + this._removeAllSchemas(this.refs, schemaKeyRef); + return this; + } + switch (typeof schemaKeyRef) { + case "undefined": + this._removeAllSchemas(this.schemas); + this._removeAllSchemas(this.refs); + this._cache.clear(); + return this; + case "string": { + const sch = getSchEnv.call(this, schemaKeyRef); + if (typeof sch == "object") + this._cache.delete(sch.schema); + delete this.schemas[schemaKeyRef]; + delete this.refs[schemaKeyRef]; + return this; + } + case "object": { + const cacheKey = schemaKeyRef; + this._cache.delete(cacheKey); + let id = schemaKeyRef[this.opts.schemaId]; + if (id) { + id = (0, resolve_1.normalizeId)(id); + delete this.schemas[id]; + delete this.refs[id]; + } + return this; + } + default: + throw new Error("ajv.removeSchema: invalid parameter"); + } + } + // add "vocabulary" - a collection of keywords + addVocabulary(definitions) { + for (const def of definitions) + this.addKeyword(def); + return this; + } + addKeyword(kwdOrDef, def // deprecated + ) { + let keyword; + if (typeof kwdOrDef == "string") { + keyword = kwdOrDef; + if (typeof def == "object") { + this.logger.warn("these parameters are deprecated, see docs for addKeyword"); + def.keyword = keyword; + } + } + else if (typeof kwdOrDef == "object" && def === undefined) { + def = kwdOrDef; + keyword = def.keyword; + if (Array.isArray(keyword) && !keyword.length) { + throw new Error("addKeywords: keyword must be string or non-empty array"); + } + } + else { + throw new Error("invalid addKeywords parameters"); + } + checkKeyword.call(this, keyword, def); + if (!def) { + (0, util_1.eachItem)(keyword, (kwd) => addRule.call(this, kwd)); + return this; + } + keywordMetaschema.call(this, def); + const definition = { + ...def, + type: (0, dataType_1.getJSONTypes)(def.type), + schemaType: (0, dataType_1.getJSONTypes)(def.schemaType), + }; + (0, util_1.eachItem)(keyword, definition.type.length === 0 + ? (k) => addRule.call(this, k, definition) + : (k) => definition.type.forEach((t) => addRule.call(this, k, definition, t))); + return this; + } + getKeyword(keyword) { + const rule = this.RULES.all[keyword]; + return typeof rule == "object" ? rule.definition : !!rule; + } + // Remove keyword + removeKeyword(keyword) { + // TODO return type should be Ajv + const { RULES } = this; + delete RULES.keywords[keyword]; + delete RULES.all[keyword]; + for (const group of RULES.rules) { + const i = group.rules.findIndex((rule) => rule.keyword === keyword); + if (i >= 0) + group.rules.splice(i, 1); + } + return this; + } + // Add format + addFormat(name, format) { + if (typeof format == "string") + format = new RegExp(format); + this.formats[name] = format; + return this; + } + errorsText(errors = this.errors, // optional array of validation errors + { separator = ", ", dataVar = "data" } = {} // optional options with properties `separator` and `dataVar` + ) { + if (!errors || errors.length === 0) + return "No errors"; + return errors + .map((e) => `${dataVar}${e.instancePath} ${e.message}`) + .reduce((text, msg) => text + separator + msg); + } + $dataMetaSchema(metaSchema, keywordsJsonPointers) { + const rules = this.RULES.all; + metaSchema = JSON.parse(JSON.stringify(metaSchema)); + for (const jsonPointer of keywordsJsonPointers) { + const segments = jsonPointer.split("/").slice(1); // first segment is an empty string + let keywords = metaSchema; + for (const seg of segments) + keywords = keywords[seg]; + for (const key in rules) { + const rule = rules[key]; + if (typeof rule != "object") + continue; + const { $data } = rule.definition; + const schema = keywords[key]; + if ($data && schema) + keywords[key] = schemaOrData(schema); + } + } + return metaSchema; + } + _removeAllSchemas(schemas, regex) { + for (const keyRef in schemas) { + const sch = schemas[keyRef]; + if (!regex || regex.test(keyRef)) { + if (typeof sch == "string") { + delete schemas[keyRef]; + } + else if (sch && !sch.meta) { + this._cache.delete(sch.schema); + delete schemas[keyRef]; + } + } + } + } + _addSchema(schema, meta, baseId, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) { + let id; + const { schemaId } = this.opts; + if (typeof schema == "object") { + id = schema[schemaId]; + } + else { + if (this.opts.jtd) + throw new Error("schema must be object"); + else if (typeof schema != "boolean") + throw new Error("schema must be object or boolean"); + } + let sch = this._cache.get(schema); + if (sch !== undefined) + return sch; + baseId = (0, resolve_1.normalizeId)(id || baseId); + const localRefs = resolve_1.getSchemaRefs.call(this, schema, baseId); + sch = new compile_1.SchemaEnv({ schema, schemaId, meta, baseId, localRefs }); + this._cache.set(sch.schema, sch); + if (addSchema && !baseId.startsWith("#")) { + // TODO atm it is allowed to overwrite schemas without id (instead of not adding them) + if (baseId) + this._checkUnique(baseId); + this.refs[baseId] = sch; + } + if (validateSchema) + this.validateSchema(schema, true); + return sch; + } + _checkUnique(id) { + if (this.schemas[id] || this.refs[id]) { + throw new Error(`schema with key or id "${id}" already exists`); + } + } + _compileSchemaEnv(sch) { + if (sch.meta) + this._compileMetaSchema(sch); + else + compile_1.compileSchema.call(this, sch); + /* istanbul ignore if */ + if (!sch.validate) + throw new Error("ajv implementation error"); + return sch.validate; + } + _compileMetaSchema(sch) { + const currentOpts = this.opts; + this.opts = this._metaOpts; + try { + compile_1.compileSchema.call(this, sch); + } + finally { + this.opts = currentOpts; + } + } + } + exports.default = Ajv; + Ajv.ValidationError = validation_error_1.default; + Ajv.MissingRefError = ref_error_1.default; + function checkOptions(checkOpts, options, msg, log = "error") { + for (const key in checkOpts) { + const opt = key; + if (opt in options) + this.logger[log](`${msg}: option ${key}. ${checkOpts[opt]}`); + } + } + function getSchEnv(keyRef) { + keyRef = (0, resolve_1.normalizeId)(keyRef); // TODO tests fail without this line + return this.schemas[keyRef] || this.refs[keyRef]; + } + function addInitialSchemas() { + const optsSchemas = this.opts.schemas; + if (!optsSchemas) + return; + if (Array.isArray(optsSchemas)) + this.addSchema(optsSchemas); + else + for (const key in optsSchemas) + this.addSchema(optsSchemas[key], key); + } + function addInitialFormats() { + for (const name in this.opts.formats) { + const format = this.opts.formats[name]; + if (format) + this.addFormat(name, format); + } + } + function addInitialKeywords(defs) { + if (Array.isArray(defs)) { + this.addVocabulary(defs); + return; + } + this.logger.warn("keywords option as map is deprecated, pass array"); + for (const keyword in defs) { + const def = defs[keyword]; + if (!def.keyword) + def.keyword = keyword; + this.addKeyword(def); + } + } + function getMetaSchemaOptions() { + const metaOpts = { ...this.opts }; + for (const opt of META_IGNORE_OPTIONS) + delete metaOpts[opt]; + return metaOpts; + } + const noLogs = { log() { }, warn() { }, error() { } }; + function getLogger(logger) { + if (logger === false) + return noLogs; + if (logger === undefined) + return console; + if (logger.log && logger.warn && logger.error) + return logger; + throw new Error("logger must implement log, warn and error methods"); + } + const KEYWORD_NAME = /^[a-z_$][a-z0-9_$:-]*$/i; + function checkKeyword(keyword, def) { + const { RULES } = this; + (0, util_1.eachItem)(keyword, (kwd) => { + if (RULES.keywords[kwd]) + throw new Error(`Keyword ${kwd} is already defined`); + if (!KEYWORD_NAME.test(kwd)) + throw new Error(`Keyword ${kwd} has invalid name`); + }); + if (!def) + return; + if (def.$data && !("code" in def || "validate" in def)) { + throw new Error('$data keyword must have "code" or "validate" function'); + } + } + function addRule(keyword, definition, dataType) { + var _a; + const post = definition === null || definition === void 0 ? void 0 : definition.post; + if (dataType && post) + throw new Error('keyword with "post" flag cannot have "type"'); + const { RULES } = this; + let ruleGroup = post ? RULES.post : RULES.rules.find(({ type: t }) => t === dataType); + if (!ruleGroup) { + ruleGroup = { type: dataType, rules: [] }; + RULES.rules.push(ruleGroup); + } + RULES.keywords[keyword] = true; + if (!definition) + return; + const rule = { + keyword, + definition: { + ...definition, + type: (0, dataType_1.getJSONTypes)(definition.type), + schemaType: (0, dataType_1.getJSONTypes)(definition.schemaType), + }, + }; + if (definition.before) + addBeforeRule.call(this, ruleGroup, rule, definition.before); + else + ruleGroup.rules.push(rule); + RULES.all[keyword] = rule; + (_a = definition.implements) === null || _a === void 0 ? void 0 : _a.forEach((kwd) => this.addKeyword(kwd)); + } + function addBeforeRule(ruleGroup, rule, before) { + const i = ruleGroup.rules.findIndex((_rule) => _rule.keyword === before); + if (i >= 0) { + ruleGroup.rules.splice(i, 0, rule); + } + else { + ruleGroup.rules.push(rule); + this.logger.warn(`rule ${before} is not defined`); + } + } + function keywordMetaschema(def) { + let { metaSchema } = def; + if (metaSchema === undefined) + return; + if (def.$data && this.opts.$data) + metaSchema = schemaOrData(metaSchema); + def.validateSchema = this.compile(metaSchema, true); + } + const $dataRef = { + $ref: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#", + }; + function schemaOrData(schema) { + return { anyOf: [schema, $dataRef] }; + } + +} (core$2)); + +var draft7 = {}; + +var core$1 = {}; + +var id = {}; + +Object.defineProperty(id, "__esModule", { value: true }); +const def$s = { + keyword: "id", + code() { + throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID'); + }, +}; +id.default = def$s; + +var ref = {}; + +Object.defineProperty(ref, "__esModule", { value: true }); +ref.callRef = ref.getValidate = void 0; +const ref_error_1 = ref_error; +const code_1$8 = code; +const codegen_1$l = codegen; +const names_1$1 = names$1; +const compile_1$1 = compile; +const util_1$j = util; +const def$r = { + keyword: "$ref", + schemaType: "string", + code(cxt) { + const { gen, schema: $ref, it } = cxt; + const { baseId, schemaEnv: env, validateName, opts, self } = it; + const { root } = env; + if (($ref === "#" || $ref === "#/") && baseId === root.baseId) + return callRootRef(); + const schOrEnv = compile_1$1.resolveRef.call(self, root, baseId, $ref); + if (schOrEnv === undefined) + throw new ref_error_1.default(it.opts.uriResolver, baseId, $ref); + if (schOrEnv instanceof compile_1$1.SchemaEnv) + return callValidate(schOrEnv); + return inlineRefSchema(schOrEnv); + function callRootRef() { + if (env === root) + return callRef(cxt, validateName, env, env.$async); + const rootName = gen.scopeValue("root", { ref: root }); + return callRef(cxt, (0, codegen_1$l._) `${rootName}.validate`, root, root.$async); + } + function callValidate(sch) { + const v = getValidate(cxt, sch); + callRef(cxt, v, sch, sch.$async); + } + function inlineRefSchema(sch) { + const schName = gen.scopeValue("schema", opts.code.source === true ? { ref: sch, code: (0, codegen_1$l.stringify)(sch) } : { ref: sch }); + const valid = gen.name("valid"); + const schCxt = cxt.subschema({ + schema: sch, + dataTypes: [], + schemaPath: codegen_1$l.nil, + topSchemaRef: schName, + errSchemaPath: $ref, + }, valid); + cxt.mergeEvaluated(schCxt); + cxt.ok(valid); + } + }, +}; +function getValidate(cxt, sch) { + const { gen } = cxt; + return sch.validate + ? gen.scopeValue("validate", { ref: sch.validate }) + : (0, codegen_1$l._) `${gen.scopeValue("wrapper", { ref: sch })}.validate`; +} +ref.getValidate = getValidate; +function callRef(cxt, v, sch, $async) { + const { gen, it } = cxt; + const { allErrors, schemaEnv: env, opts } = it; + const passCxt = opts.passContext ? names_1$1.default.this : codegen_1$l.nil; + if ($async) + callAsyncRef(); + else + callSyncRef(); + function callAsyncRef() { + if (!env.$async) + throw new Error("async schema referenced by sync schema"); + const valid = gen.let("valid"); + gen.try(() => { + gen.code((0, codegen_1$l._) `await ${(0, code_1$8.callValidateCode)(cxt, v, passCxt)}`); + addEvaluatedFrom(v); // TODO will not work with async, it has to be returned with the result + if (!allErrors) + gen.assign(valid, true); + }, (e) => { + gen.if((0, codegen_1$l._) `!(${e} instanceof ${it.ValidationError})`, () => gen.throw(e)); + addErrorsFrom(e); + if (!allErrors) + gen.assign(valid, false); + }); + cxt.ok(valid); + } + function callSyncRef() { + cxt.result((0, code_1$8.callValidateCode)(cxt, v, passCxt), () => addEvaluatedFrom(v), () => addErrorsFrom(v)); + } + function addErrorsFrom(source) { + const errs = (0, codegen_1$l._) `${source}.errors`; + gen.assign(names_1$1.default.vErrors, (0, codegen_1$l._) `${names_1$1.default.vErrors} === null ? ${errs} : ${names_1$1.default.vErrors}.concat(${errs})`); // TODO tagged + gen.assign(names_1$1.default.errors, (0, codegen_1$l._) `${names_1$1.default.vErrors}.length`); + } + function addEvaluatedFrom(source) { + var _a; + if (!it.opts.unevaluated) + return; + const schEvaluated = (_a = sch === null || sch === void 0 ? void 0 : sch.validate) === null || _a === void 0 ? void 0 : _a.evaluated; + // TODO refactor + if (it.props !== true) { + if (schEvaluated && !schEvaluated.dynamicProps) { + if (schEvaluated.props !== undefined) { + it.props = util_1$j.mergeEvaluated.props(gen, schEvaluated.props, it.props); + } + } + else { + const props = gen.var("props", (0, codegen_1$l._) `${source}.evaluated.props`); + it.props = util_1$j.mergeEvaluated.props(gen, props, it.props, codegen_1$l.Name); + } + } + if (it.items !== true) { + if (schEvaluated && !schEvaluated.dynamicItems) { + if (schEvaluated.items !== undefined) { + it.items = util_1$j.mergeEvaluated.items(gen, schEvaluated.items, it.items); + } + } + else { + const items = gen.var("items", (0, codegen_1$l._) `${source}.evaluated.items`); + it.items = util_1$j.mergeEvaluated.items(gen, items, it.items, codegen_1$l.Name); + } + } + } +} +ref.callRef = callRef; +ref.default = def$r; + +Object.defineProperty(core$1, "__esModule", { value: true }); +const id_1 = id; +const ref_1 = ref; +const core = [ + "$schema", + "$id", + "$defs", + "$vocabulary", + { keyword: "$comment" }, + "definitions", + id_1.default, + ref_1.default, +]; +core$1.default = core; + +var validation$1 = {}; + +var limitNumber = {}; + +Object.defineProperty(limitNumber, "__esModule", { value: true }); +const codegen_1$k = codegen; +const ops = codegen_1$k.operators; +const KWDs = { + maximum: { okStr: "<=", ok: ops.LTE, fail: ops.GT }, + minimum: { okStr: ">=", ok: ops.GTE, fail: ops.LT }, + exclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE }, + exclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE }, +}; +const error$i = { + message: ({ keyword, schemaCode }) => (0, codegen_1$k.str) `must be ${KWDs[keyword].okStr} ${schemaCode}`, + params: ({ keyword, schemaCode }) => (0, codegen_1$k._) `{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`, +}; +const def$q = { + keyword: Object.keys(KWDs), + type: "number", + schemaType: "number", + $data: true, + error: error$i, + code(cxt) { + const { keyword, data, schemaCode } = cxt; + cxt.fail$data((0, codegen_1$k._) `${data} ${KWDs[keyword].fail} ${schemaCode} || isNaN(${data})`); + }, +}; +limitNumber.default = def$q; + +var multipleOf = {}; + +Object.defineProperty(multipleOf, "__esModule", { value: true }); +const codegen_1$j = codegen; +const error$h = { + message: ({ schemaCode }) => (0, codegen_1$j.str) `must be multiple of ${schemaCode}`, + params: ({ schemaCode }) => (0, codegen_1$j._) `{multipleOf: ${schemaCode}}`, +}; +const def$p = { + keyword: "multipleOf", + type: "number", + schemaType: "number", + $data: true, + error: error$h, + code(cxt) { + const { gen, data, schemaCode, it } = cxt; + // const bdt = bad$DataType(schemaCode, def.schemaType, $data) + const prec = it.opts.multipleOfPrecision; + const res = gen.let("res"); + const invalid = prec + ? (0, codegen_1$j._) `Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}` + : (0, codegen_1$j._) `${res} !== parseInt(${res})`; + cxt.fail$data((0, codegen_1$j._) `(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid}))`); + }, +}; +multipleOf.default = def$p; + +var limitLength = {}; + +var ucs2length$1 = {}; + +Object.defineProperty(ucs2length$1, "__esModule", { value: true }); +// https://mathiasbynens.be/notes/javascript-encoding +// https://github.com/bestiejs/punycode.js - punycode.ucs2.decode +function ucs2length(str) { + const len = str.length; + let length = 0; + let pos = 0; + let value; + while (pos < len) { + length++; + value = str.charCodeAt(pos++); + if (value >= 0xd800 && value <= 0xdbff && pos < len) { + // high surrogate, and there is a next character + value = str.charCodeAt(pos); + if ((value & 0xfc00) === 0xdc00) + pos++; // low surrogate + } + } + return length; +} +ucs2length$1.default = ucs2length; +ucs2length.code = 'require("ajv/dist/runtime/ucs2length").default'; + +Object.defineProperty(limitLength, "__esModule", { value: true }); +const codegen_1$i = codegen; +const util_1$i = util; +const ucs2length_1 = ucs2length$1; +const error$g = { + message({ keyword, schemaCode }) { + const comp = keyword === "maxLength" ? "more" : "fewer"; + return (0, codegen_1$i.str) `must NOT have ${comp} than ${schemaCode} characters`; + }, + params: ({ schemaCode }) => (0, codegen_1$i._) `{limit: ${schemaCode}}`, +}; +const def$o = { + keyword: ["maxLength", "minLength"], + type: "string", + schemaType: "number", + $data: true, + error: error$g, + code(cxt) { + const { keyword, data, schemaCode, it } = cxt; + const op = keyword === "maxLength" ? codegen_1$i.operators.GT : codegen_1$i.operators.LT; + const len = it.opts.unicode === false ? (0, codegen_1$i._) `${data}.length` : (0, codegen_1$i._) `${(0, util_1$i.useFunc)(cxt.gen, ucs2length_1.default)}(${data})`; + cxt.fail$data((0, codegen_1$i._) `${len} ${op} ${schemaCode}`); + }, +}; +limitLength.default = def$o; + +var pattern = {}; + +Object.defineProperty(pattern, "__esModule", { value: true }); +const code_1$7 = code; +const codegen_1$h = codegen; +const error$f = { + message: ({ schemaCode }) => (0, codegen_1$h.str) `must match pattern "${schemaCode}"`, + params: ({ schemaCode }) => (0, codegen_1$h._) `{pattern: ${schemaCode}}`, +}; +const def$n = { + keyword: "pattern", + type: "string", + schemaType: "string", + $data: true, + error: error$f, + code(cxt) { + const { data, $data, schema, schemaCode, it } = cxt; + // TODO regexp should be wrapped in try/catchs + const u = it.opts.unicodeRegExp ? "u" : ""; + const regExp = $data ? (0, codegen_1$h._) `(new RegExp(${schemaCode}, ${u}))` : (0, code_1$7.usePattern)(cxt, schema); + cxt.fail$data((0, codegen_1$h._) `!${regExp}.test(${data})`); + }, +}; +pattern.default = def$n; + +var limitProperties = {}; + +Object.defineProperty(limitProperties, "__esModule", { value: true }); +const codegen_1$g = codegen; +const error$e = { + message({ keyword, schemaCode }) { + const comp = keyword === "maxProperties" ? "more" : "fewer"; + return (0, codegen_1$g.str) `must NOT have ${comp} than ${schemaCode} properties`; + }, + params: ({ schemaCode }) => (0, codegen_1$g._) `{limit: ${schemaCode}}`, +}; +const def$m = { + keyword: ["maxProperties", "minProperties"], + type: "object", + schemaType: "number", + $data: true, + error: error$e, + code(cxt) { + const { keyword, data, schemaCode } = cxt; + const op = keyword === "maxProperties" ? codegen_1$g.operators.GT : codegen_1$g.operators.LT; + cxt.fail$data((0, codegen_1$g._) `Object.keys(${data}).length ${op} ${schemaCode}`); + }, +}; +limitProperties.default = def$m; + +var required = {}; + +Object.defineProperty(required, "__esModule", { value: true }); +const code_1$6 = code; +const codegen_1$f = codegen; +const util_1$h = util; +const error$d = { + message: ({ params: { missingProperty } }) => (0, codegen_1$f.str) `must have required property '${missingProperty}'`, + params: ({ params: { missingProperty } }) => (0, codegen_1$f._) `{missingProperty: ${missingProperty}}`, +}; +const def$l = { + keyword: "required", + type: "object", + schemaType: "array", + $data: true, + error: error$d, + code(cxt) { + const { gen, schema, schemaCode, data, $data, it } = cxt; + const { opts } = it; + if (!$data && schema.length === 0) + return; + const useLoop = schema.length >= opts.loopRequired; + if (it.allErrors) + allErrorsMode(); + else + exitOnErrorMode(); + if (opts.strictRequired) { + const props = cxt.parentSchema.properties; + const { definedProperties } = cxt.it; + for (const requiredKey of schema) { + if ((props === null || props === void 0 ? void 0 : props[requiredKey]) === undefined && !definedProperties.has(requiredKey)) { + const schemaPath = it.schemaEnv.baseId + it.errSchemaPath; + const msg = `required property "${requiredKey}" is not defined at "${schemaPath}" (strictRequired)`; + (0, util_1$h.checkStrictMode)(it, msg, it.opts.strictRequired); + } + } + } + function allErrorsMode() { + if (useLoop || $data) { + cxt.block$data(codegen_1$f.nil, loopAllRequired); + } + else { + for (const prop of schema) { + (0, code_1$6.checkReportMissingProp)(cxt, prop); + } + } + } + function exitOnErrorMode() { + const missing = gen.let("missing"); + if (useLoop || $data) { + const valid = gen.let("valid", true); + cxt.block$data(valid, () => loopUntilMissing(missing, valid)); + cxt.ok(valid); + } + else { + gen.if((0, code_1$6.checkMissingProp)(cxt, schema, missing)); + (0, code_1$6.reportMissingProp)(cxt, missing); + gen.else(); + } + } + function loopAllRequired() { + gen.forOf("prop", schemaCode, (prop) => { + cxt.setParams({ missingProperty: prop }); + gen.if((0, code_1$6.noPropertyInData)(gen, data, prop, opts.ownProperties), () => cxt.error()); + }); + } + function loopUntilMissing(missing, valid) { + cxt.setParams({ missingProperty: missing }); + gen.forOf(missing, schemaCode, () => { + gen.assign(valid, (0, code_1$6.propertyInData)(gen, data, missing, opts.ownProperties)); + gen.if((0, codegen_1$f.not)(valid), () => { + cxt.error(); + gen.break(); + }); + }, codegen_1$f.nil); + } + }, +}; +required.default = def$l; + +var limitItems = {}; + +Object.defineProperty(limitItems, "__esModule", { value: true }); +const codegen_1$e = codegen; +const error$c = { + message({ keyword, schemaCode }) { + const comp = keyword === "maxItems" ? "more" : "fewer"; + return (0, codegen_1$e.str) `must NOT have ${comp} than ${schemaCode} items`; + }, + params: ({ schemaCode }) => (0, codegen_1$e._) `{limit: ${schemaCode}}`, +}; +const def$k = { + keyword: ["maxItems", "minItems"], + type: "array", + schemaType: "number", + $data: true, + error: error$c, + code(cxt) { + const { keyword, data, schemaCode } = cxt; + const op = keyword === "maxItems" ? codegen_1$e.operators.GT : codegen_1$e.operators.LT; + cxt.fail$data((0, codegen_1$e._) `${data}.length ${op} ${schemaCode}`); + }, +}; +limitItems.default = def$k; + +var uniqueItems = {}; + +var equal$1 = {}; + +Object.defineProperty(equal$1, "__esModule", { value: true }); +// https://github.com/ajv-validator/ajv/issues/889 +const equal = fastDeepEqual; +equal.code = 'require("ajv/dist/runtime/equal").default'; +equal$1.default = equal; + +Object.defineProperty(uniqueItems, "__esModule", { value: true }); +const dataType_1 = dataType; +const codegen_1$d = codegen; +const util_1$g = util; +const equal_1$2 = equal$1; +const error$b = { + message: ({ params: { i, j } }) => (0, codegen_1$d.str) `must NOT have duplicate items (items ## ${j} and ${i} are identical)`, + params: ({ params: { i, j } }) => (0, codegen_1$d._) `{i: ${i}, j: ${j}}`, +}; +const def$j = { + keyword: "uniqueItems", + type: "array", + schemaType: "boolean", + $data: true, + error: error$b, + code(cxt) { + const { gen, data, $data, schema, parentSchema, schemaCode, it } = cxt; + if (!$data && !schema) + return; + const valid = gen.let("valid"); + const itemTypes = parentSchema.items ? (0, dataType_1.getSchemaTypes)(parentSchema.items) : []; + cxt.block$data(valid, validateUniqueItems, (0, codegen_1$d._) `${schemaCode} === false`); + cxt.ok(valid); + function validateUniqueItems() { + const i = gen.let("i", (0, codegen_1$d._) `${data}.length`); + const j = gen.let("j"); + cxt.setParams({ i, j }); + gen.assign(valid, true); + gen.if((0, codegen_1$d._) `${i} > 1`, () => (canOptimize() ? loopN : loopN2)(i, j)); + } + function canOptimize() { + return itemTypes.length > 0 && !itemTypes.some((t) => t === "object" || t === "array"); + } + function loopN(i, j) { + const item = gen.name("item"); + const wrongType = (0, dataType_1.checkDataTypes)(itemTypes, item, it.opts.strictNumbers, dataType_1.DataType.Wrong); + const indices = gen.const("indices", (0, codegen_1$d._) `{}`); + gen.for((0, codegen_1$d._) `;${i}--;`, () => { + gen.let(item, (0, codegen_1$d._) `${data}[${i}]`); + gen.if(wrongType, (0, codegen_1$d._) `continue`); + if (itemTypes.length > 1) + gen.if((0, codegen_1$d._) `typeof ${item} == "string"`, (0, codegen_1$d._) `${item} += "_"`); + gen + .if((0, codegen_1$d._) `typeof ${indices}[${item}] == "number"`, () => { + gen.assign(j, (0, codegen_1$d._) `${indices}[${item}]`); + cxt.error(); + gen.assign(valid, false).break(); + }) + .code((0, codegen_1$d._) `${indices}[${item}] = ${i}`); + }); + } + function loopN2(i, j) { + const eql = (0, util_1$g.useFunc)(gen, equal_1$2.default); + const outer = gen.name("outer"); + gen.label(outer).for((0, codegen_1$d._) `;${i}--;`, () => gen.for((0, codegen_1$d._) `${j} = ${i}; ${j}--;`, () => gen.if((0, codegen_1$d._) `${eql}(${data}[${i}], ${data}[${j}])`, () => { + cxt.error(); + gen.assign(valid, false).break(outer); + }))); + } + }, +}; +uniqueItems.default = def$j; + +var _const = {}; + +Object.defineProperty(_const, "__esModule", { value: true }); +const codegen_1$c = codegen; +const util_1$f = util; +const equal_1$1 = equal$1; +const error$a = { + message: "must be equal to constant", + params: ({ schemaCode }) => (0, codegen_1$c._) `{allowedValue: ${schemaCode}}`, +}; +const def$i = { + keyword: "const", + $data: true, + error: error$a, + code(cxt) { + const { gen, data, $data, schemaCode, schema } = cxt; + if ($data || (schema && typeof schema == "object")) { + cxt.fail$data((0, codegen_1$c._) `!${(0, util_1$f.useFunc)(gen, equal_1$1.default)}(${data}, ${schemaCode})`); + } + else { + cxt.fail((0, codegen_1$c._) `${schema} !== ${data}`); + } + }, +}; +_const.default = def$i; + +var _enum = {}; + +Object.defineProperty(_enum, "__esModule", { value: true }); +const codegen_1$b = codegen; +const util_1$e = util; +const equal_1 = equal$1; +const error$9 = { + message: "must be equal to one of the allowed values", + params: ({ schemaCode }) => (0, codegen_1$b._) `{allowedValues: ${schemaCode}}`, +}; +const def$h = { + keyword: "enum", + schemaType: "array", + $data: true, + error: error$9, + code(cxt) { + const { gen, data, $data, schema, schemaCode, it } = cxt; + if (!$data && schema.length === 0) + throw new Error("enum must have non-empty array"); + const useLoop = schema.length >= it.opts.loopEnum; + let eql; + const getEql = () => (eql !== null && eql !== void 0 ? eql : (eql = (0, util_1$e.useFunc)(gen, equal_1.default))); + let valid; + if (useLoop || $data) { + valid = gen.let("valid"); + cxt.block$data(valid, loopEnum); + } + else { + /* istanbul ignore if */ + if (!Array.isArray(schema)) + throw new Error("ajv implementation error"); + const vSchema = gen.const("vSchema", schemaCode); + valid = (0, codegen_1$b.or)(...schema.map((_x, i) => equalCode(vSchema, i))); + } + cxt.pass(valid); + function loopEnum() { + gen.assign(valid, false); + gen.forOf("v", schemaCode, (v) => gen.if((0, codegen_1$b._) `${getEql()}(${data}, ${v})`, () => gen.assign(valid, true).break())); + } + function equalCode(vSchema, i) { + const sch = schema[i]; + return typeof sch === "object" && sch !== null + ? (0, codegen_1$b._) `${getEql()}(${data}, ${vSchema}[${i}])` + : (0, codegen_1$b._) `${data} === ${sch}`; + } + }, +}; +_enum.default = def$h; + +Object.defineProperty(validation$1, "__esModule", { value: true }); +const limitNumber_1 = limitNumber; +const multipleOf_1 = multipleOf; +const limitLength_1 = limitLength; +const pattern_1 = pattern; +const limitProperties_1 = limitProperties; +const required_1 = required; +const limitItems_1 = limitItems; +const uniqueItems_1 = uniqueItems; +const const_1 = _const; +const enum_1 = _enum; +const validation = [ + // number + limitNumber_1.default, + multipleOf_1.default, + // string + limitLength_1.default, + pattern_1.default, + // object + limitProperties_1.default, + required_1.default, + // array + limitItems_1.default, + uniqueItems_1.default, + // any + { keyword: "type", schemaType: ["string", "array"] }, + { keyword: "nullable", schemaType: "boolean" }, + const_1.default, + enum_1.default, +]; +validation$1.default = validation; + +var applicator = {}; + +var additionalItems = {}; + +Object.defineProperty(additionalItems, "__esModule", { value: true }); +additionalItems.validateAdditionalItems = void 0; +const codegen_1$a = codegen; +const util_1$d = util; +const error$8 = { + message: ({ params: { len } }) => (0, codegen_1$a.str) `must NOT have more than ${len} items`, + params: ({ params: { len } }) => (0, codegen_1$a._) `{limit: ${len}}`, +}; +const def$g = { + keyword: "additionalItems", + type: "array", + schemaType: ["boolean", "object"], + before: "uniqueItems", + error: error$8, + code(cxt) { + const { parentSchema, it } = cxt; + const { items } = parentSchema; + if (!Array.isArray(items)) { + (0, util_1$d.checkStrictMode)(it, '"additionalItems" is ignored when "items" is not an array of schemas'); + return; + } + validateAdditionalItems(cxt, items); + }, +}; +function validateAdditionalItems(cxt, items) { + const { gen, schema, data, keyword, it } = cxt; + it.items = true; + const len = gen.const("len", (0, codegen_1$a._) `${data}.length`); + if (schema === false) { + cxt.setParams({ len: items.length }); + cxt.pass((0, codegen_1$a._) `${len} <= ${items.length}`); + } + else if (typeof schema == "object" && !(0, util_1$d.alwaysValidSchema)(it, schema)) { + const valid = gen.var("valid", (0, codegen_1$a._) `${len} <= ${items.length}`); // TODO var + gen.if((0, codegen_1$a.not)(valid), () => validateItems(valid)); + cxt.ok(valid); + } + function validateItems(valid) { + gen.forRange("i", items.length, len, (i) => { + cxt.subschema({ keyword, dataProp: i, dataPropType: util_1$d.Type.Num }, valid); + if (!it.allErrors) + gen.if((0, codegen_1$a.not)(valid), () => gen.break()); + }); + } +} +additionalItems.validateAdditionalItems = validateAdditionalItems; +additionalItems.default = def$g; + +var prefixItems = {}; + +var items = {}; + +Object.defineProperty(items, "__esModule", { value: true }); +items.validateTuple = void 0; +const codegen_1$9 = codegen; +const util_1$c = util; +const code_1$5 = code; +const def$f = { + keyword: "items", + type: "array", + schemaType: ["object", "array", "boolean"], + before: "uniqueItems", + code(cxt) { + const { schema, it } = cxt; + if (Array.isArray(schema)) + return validateTuple(cxt, "additionalItems", schema); + it.items = true; + if ((0, util_1$c.alwaysValidSchema)(it, schema)) + return; + cxt.ok((0, code_1$5.validateArray)(cxt)); + }, +}; +function validateTuple(cxt, extraItems, schArr = cxt.schema) { + const { gen, parentSchema, data, keyword, it } = cxt; + checkStrictTuple(parentSchema); + if (it.opts.unevaluated && schArr.length && it.items !== true) { + it.items = util_1$c.mergeEvaluated.items(gen, schArr.length, it.items); + } + const valid = gen.name("valid"); + const len = gen.const("len", (0, codegen_1$9._) `${data}.length`); + schArr.forEach((sch, i) => { + if ((0, util_1$c.alwaysValidSchema)(it, sch)) + return; + gen.if((0, codegen_1$9._) `${len} > ${i}`, () => cxt.subschema({ + keyword, + schemaProp: i, + dataProp: i, + }, valid)); + cxt.ok(valid); + }); + function checkStrictTuple(sch) { + const { opts, errSchemaPath } = it; + const l = schArr.length; + const fullTuple = l === sch.minItems && (l === sch.maxItems || sch[extraItems] === false); + if (opts.strictTuples && !fullTuple) { + const msg = `"${keyword}" is ${l}-tuple, but minItems or maxItems/${extraItems} are not specified or different at path "${errSchemaPath}"`; + (0, util_1$c.checkStrictMode)(it, msg, opts.strictTuples); + } + } +} +items.validateTuple = validateTuple; +items.default = def$f; + +Object.defineProperty(prefixItems, "__esModule", { value: true }); +const items_1$1 = items; +const def$e = { + keyword: "prefixItems", + type: "array", + schemaType: ["array"], + before: "uniqueItems", + code: (cxt) => (0, items_1$1.validateTuple)(cxt, "items"), +}; +prefixItems.default = def$e; + +var items2020 = {}; + +Object.defineProperty(items2020, "__esModule", { value: true }); +const codegen_1$8 = codegen; +const util_1$b = util; +const code_1$4 = code; +const additionalItems_1$1 = additionalItems; +const error$7 = { + message: ({ params: { len } }) => (0, codegen_1$8.str) `must NOT have more than ${len} items`, + params: ({ params: { len } }) => (0, codegen_1$8._) `{limit: ${len}}`, +}; +const def$d = { + keyword: "items", + type: "array", + schemaType: ["object", "boolean"], + before: "uniqueItems", + error: error$7, + code(cxt) { + const { schema, parentSchema, it } = cxt; + const { prefixItems } = parentSchema; + it.items = true; + if ((0, util_1$b.alwaysValidSchema)(it, schema)) + return; + if (prefixItems) + (0, additionalItems_1$1.validateAdditionalItems)(cxt, prefixItems); + else + cxt.ok((0, code_1$4.validateArray)(cxt)); + }, +}; +items2020.default = def$d; + +var contains = {}; + +Object.defineProperty(contains, "__esModule", { value: true }); +const codegen_1$7 = codegen; +const util_1$a = util; +const error$6 = { + message: ({ params: { min, max } }) => max === undefined + ? (0, codegen_1$7.str) `must contain at least ${min} valid item(s)` + : (0, codegen_1$7.str) `must contain at least ${min} and no more than ${max} valid item(s)`, + params: ({ params: { min, max } }) => max === undefined ? (0, codegen_1$7._) `{minContains: ${min}}` : (0, codegen_1$7._) `{minContains: ${min}, maxContains: ${max}}`, +}; +const def$c = { + keyword: "contains", + type: "array", + schemaType: ["object", "boolean"], + before: "uniqueItems", + trackErrors: true, + error: error$6, + code(cxt) { + const { gen, schema, parentSchema, data, it } = cxt; + let min; + let max; + const { minContains, maxContains } = parentSchema; + if (it.opts.next) { + min = minContains === undefined ? 1 : minContains; + max = maxContains; + } + else { + min = 1; + } + const len = gen.const("len", (0, codegen_1$7._) `${data}.length`); + cxt.setParams({ min, max }); + if (max === undefined && min === 0) { + (0, util_1$a.checkStrictMode)(it, `"minContains" == 0 without "maxContains": "contains" keyword ignored`); + return; + } + if (max !== undefined && min > max) { + (0, util_1$a.checkStrictMode)(it, `"minContains" > "maxContains" is always invalid`); + cxt.fail(); + return; + } + if ((0, util_1$a.alwaysValidSchema)(it, schema)) { + let cond = (0, codegen_1$7._) `${len} >= ${min}`; + if (max !== undefined) + cond = (0, codegen_1$7._) `${cond} && ${len} <= ${max}`; + cxt.pass(cond); + return; + } + it.items = true; + const valid = gen.name("valid"); + if (max === undefined && min === 1) { + validateItems(valid, () => gen.if(valid, () => gen.break())); + } + else if (min === 0) { + gen.let(valid, true); + if (max !== undefined) + gen.if((0, codegen_1$7._) `${data}.length > 0`, validateItemsWithCount); + } + else { + gen.let(valid, false); + validateItemsWithCount(); + } + cxt.result(valid, () => cxt.reset()); + function validateItemsWithCount() { + const schValid = gen.name("_valid"); + const count = gen.let("count", 0); + validateItems(schValid, () => gen.if(schValid, () => checkLimits(count))); + } + function validateItems(_valid, block) { + gen.forRange("i", 0, len, (i) => { + cxt.subschema({ + keyword: "contains", + dataProp: i, + dataPropType: util_1$a.Type.Num, + compositeRule: true, + }, _valid); + block(); + }); + } + function checkLimits(count) { + gen.code((0, codegen_1$7._) `${count}++`); + if (max === undefined) { + gen.if((0, codegen_1$7._) `${count} >= ${min}`, () => gen.assign(valid, true).break()); + } + else { + gen.if((0, codegen_1$7._) `${count} > ${max}`, () => gen.assign(valid, false).break()); + if (min === 1) + gen.assign(valid, true); + else + gen.if((0, codegen_1$7._) `${count} >= ${min}`, () => gen.assign(valid, true)); + } + } + }, +}; +contains.default = def$c; + +var dependencies = {}; + +(function (exports) { + Object.defineProperty(exports, "__esModule", { value: true }); + exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = void 0; + const codegen_1 = codegen; + const util_1 = util; + const code_1 = code; + exports.error = { + message: ({ params: { property, depsCount, deps } }) => { + const property_ies = depsCount === 1 ? "property" : "properties"; + return (0, codegen_1.str) `must have ${property_ies} ${deps} when property ${property} is present`; + }, + params: ({ params: { property, depsCount, deps, missingProperty } }) => (0, codegen_1._) `{property: ${property}, + missingProperty: ${missingProperty}, + depsCount: ${depsCount}, + deps: ${deps}}`, // TODO change to reference + }; + const def = { + keyword: "dependencies", + type: "object", + schemaType: "object", + error: exports.error, + code(cxt) { + const [propDeps, schDeps] = splitDependencies(cxt); + validatePropertyDeps(cxt, propDeps); + validateSchemaDeps(cxt, schDeps); + }, + }; + function splitDependencies({ schema }) { + const propertyDeps = {}; + const schemaDeps = {}; + for (const key in schema) { + if (key === "__proto__") + continue; + const deps = Array.isArray(schema[key]) ? propertyDeps : schemaDeps; + deps[key] = schema[key]; + } + return [propertyDeps, schemaDeps]; + } + function validatePropertyDeps(cxt, propertyDeps = cxt.schema) { + const { gen, data, it } = cxt; + if (Object.keys(propertyDeps).length === 0) + return; + const missing = gen.let("missing"); + for (const prop in propertyDeps) { + const deps = propertyDeps[prop]; + if (deps.length === 0) + continue; + const hasProperty = (0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties); + cxt.setParams({ + property: prop, + depsCount: deps.length, + deps: deps.join(", "), + }); + if (it.allErrors) { + gen.if(hasProperty, () => { + for (const depProp of deps) { + (0, code_1.checkReportMissingProp)(cxt, depProp); + } + }); + } + else { + gen.if((0, codegen_1._) `${hasProperty} && (${(0, code_1.checkMissingProp)(cxt, deps, missing)})`); + (0, code_1.reportMissingProp)(cxt, missing); + gen.else(); + } + } + } + exports.validatePropertyDeps = validatePropertyDeps; + function validateSchemaDeps(cxt, schemaDeps = cxt.schema) { + const { gen, data, keyword, it } = cxt; + const valid = gen.name("valid"); + for (const prop in schemaDeps) { + if ((0, util_1.alwaysValidSchema)(it, schemaDeps[prop])) + continue; + gen.if((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties), () => { + const schCxt = cxt.subschema({ keyword, schemaProp: prop }, valid); + cxt.mergeValidEvaluated(schCxt, valid); + }, () => gen.var(valid, true) // TODO var + ); + cxt.ok(valid); + } + } + exports.validateSchemaDeps = validateSchemaDeps; + exports.default = def; + +} (dependencies)); + +var propertyNames = {}; + +Object.defineProperty(propertyNames, "__esModule", { value: true }); +const codegen_1$6 = codegen; +const util_1$9 = util; +const error$5 = { + message: "property name must be valid", + params: ({ params }) => (0, codegen_1$6._) `{propertyName: ${params.propertyName}}`, +}; +const def$b = { + keyword: "propertyNames", + type: "object", + schemaType: ["object", "boolean"], + error: error$5, + code(cxt) { + const { gen, schema, data, it } = cxt; + if ((0, util_1$9.alwaysValidSchema)(it, schema)) + return; + const valid = gen.name("valid"); + gen.forIn("key", data, (key) => { + cxt.setParams({ propertyName: key }); + cxt.subschema({ + keyword: "propertyNames", + data: key, + dataTypes: ["string"], + propertyName: key, + compositeRule: true, + }, valid); + gen.if((0, codegen_1$6.not)(valid), () => { + cxt.error(true); + if (!it.allErrors) + gen.break(); + }); + }); + cxt.ok(valid); + }, +}; +propertyNames.default = def$b; + +var additionalProperties = {}; + +Object.defineProperty(additionalProperties, "__esModule", { value: true }); +const code_1$3 = code; +const codegen_1$5 = codegen; +const names_1 = names$1; +const util_1$8 = util; +const error$4 = { + message: "must NOT have additional properties", + params: ({ params }) => (0, codegen_1$5._) `{additionalProperty: ${params.additionalProperty}}`, +}; +const def$a = { + keyword: "additionalProperties", + type: ["object"], + schemaType: ["boolean", "object"], + allowUndefined: true, + trackErrors: true, + error: error$4, + code(cxt) { + const { gen, schema, parentSchema, data, errsCount, it } = cxt; + /* istanbul ignore if */ + if (!errsCount) + throw new Error("ajv implementation error"); + const { allErrors, opts } = it; + it.props = true; + if (opts.removeAdditional !== "all" && (0, util_1$8.alwaysValidSchema)(it, schema)) + return; + const props = (0, code_1$3.allSchemaProperties)(parentSchema.properties); + const patProps = (0, code_1$3.allSchemaProperties)(parentSchema.patternProperties); + checkAdditionalProperties(); + cxt.ok((0, codegen_1$5._) `${errsCount} === ${names_1.default.errors}`); + function checkAdditionalProperties() { + gen.forIn("key", data, (key) => { + if (!props.length && !patProps.length) + additionalPropertyCode(key); + else + gen.if(isAdditional(key), () => additionalPropertyCode(key)); + }); + } + function isAdditional(key) { + let definedProp; + if (props.length > 8) { + // TODO maybe an option instead of hard-coded 8? + const propsSchema = (0, util_1$8.schemaRefOrVal)(it, parentSchema.properties, "properties"); + definedProp = (0, code_1$3.isOwnProperty)(gen, propsSchema, key); + } + else if (props.length) { + definedProp = (0, codegen_1$5.or)(...props.map((p) => (0, codegen_1$5._) `${key} === ${p}`)); + } + else { + definedProp = codegen_1$5.nil; + } + if (patProps.length) { + definedProp = (0, codegen_1$5.or)(definedProp, ...patProps.map((p) => (0, codegen_1$5._) `${(0, code_1$3.usePattern)(cxt, p)}.test(${key})`)); + } + return (0, codegen_1$5.not)(definedProp); + } + function deleteAdditional(key) { + gen.code((0, codegen_1$5._) `delete ${data}[${key}]`); + } + function additionalPropertyCode(key) { + if (opts.removeAdditional === "all" || (opts.removeAdditional && schema === false)) { + deleteAdditional(key); + return; + } + if (schema === false) { + cxt.setParams({ additionalProperty: key }); + cxt.error(); + if (!allErrors) + gen.break(); + return; + } + if (typeof schema == "object" && !(0, util_1$8.alwaysValidSchema)(it, schema)) { + const valid = gen.name("valid"); + if (opts.removeAdditional === "failing") { + applyAdditionalSchema(key, valid, false); + gen.if((0, codegen_1$5.not)(valid), () => { + cxt.reset(); + deleteAdditional(key); + }); + } + else { + applyAdditionalSchema(key, valid); + if (!allErrors) + gen.if((0, codegen_1$5.not)(valid), () => gen.break()); + } + } + } + function applyAdditionalSchema(key, valid, errors) { + const subschema = { + keyword: "additionalProperties", + dataProp: key, + dataPropType: util_1$8.Type.Str, + }; + if (errors === false) { + Object.assign(subschema, { + compositeRule: true, + createErrors: false, + allErrors: false, + }); + } + cxt.subschema(subschema, valid); + } + }, +}; +additionalProperties.default = def$a; + +var properties$1 = {}; + +Object.defineProperty(properties$1, "__esModule", { value: true }); +const validate_1 = validate; +const code_1$2 = code; +const util_1$7 = util; +const additionalProperties_1$1 = additionalProperties; +const def$9 = { + keyword: "properties", + type: "object", + schemaType: "object", + code(cxt) { + const { gen, schema, parentSchema, data, it } = cxt; + if (it.opts.removeAdditional === "all" && parentSchema.additionalProperties === undefined) { + additionalProperties_1$1.default.code(new validate_1.KeywordCxt(it, additionalProperties_1$1.default, "additionalProperties")); + } + const allProps = (0, code_1$2.allSchemaProperties)(schema); + for (const prop of allProps) { + it.definedProperties.add(prop); + } + if (it.opts.unevaluated && allProps.length && it.props !== true) { + it.props = util_1$7.mergeEvaluated.props(gen, (0, util_1$7.toHash)(allProps), it.props); + } + const properties = allProps.filter((p) => !(0, util_1$7.alwaysValidSchema)(it, schema[p])); + if (properties.length === 0) + return; + const valid = gen.name("valid"); + for (const prop of properties) { + if (hasDefault(prop)) { + applyPropertySchema(prop); + } + else { + gen.if((0, code_1$2.propertyInData)(gen, data, prop, it.opts.ownProperties)); + applyPropertySchema(prop); + if (!it.allErrors) + gen.else().var(valid, true); + gen.endIf(); + } + cxt.it.definedProperties.add(prop); + cxt.ok(valid); + } + function hasDefault(prop) { + return it.opts.useDefaults && !it.compositeRule && schema[prop].default !== undefined; + } + function applyPropertySchema(prop) { + cxt.subschema({ + keyword: "properties", + schemaProp: prop, + dataProp: prop, + }, valid); + } + }, +}; +properties$1.default = def$9; + +var patternProperties = {}; + +Object.defineProperty(patternProperties, "__esModule", { value: true }); +const code_1$1 = code; +const codegen_1$4 = codegen; +const util_1$6 = util; +const util_2 = util; +const def$8 = { + keyword: "patternProperties", + type: "object", + schemaType: "object", + code(cxt) { + const { gen, schema, data, parentSchema, it } = cxt; + const { opts } = it; + const patterns = (0, code_1$1.allSchemaProperties)(schema); + const alwaysValidPatterns = patterns.filter((p) => (0, util_1$6.alwaysValidSchema)(it, schema[p])); + if (patterns.length === 0 || + (alwaysValidPatterns.length === patterns.length && + (!it.opts.unevaluated || it.props === true))) { + return; + } + const checkProperties = opts.strictSchema && !opts.allowMatchingProperties && parentSchema.properties; + const valid = gen.name("valid"); + if (it.props !== true && !(it.props instanceof codegen_1$4.Name)) { + it.props = (0, util_2.evaluatedPropsToName)(gen, it.props); + } + const { props } = it; + validatePatternProperties(); + function validatePatternProperties() { + for (const pat of patterns) { + if (checkProperties) + checkMatchingProperties(pat); + if (it.allErrors) { + validateProperties(pat); + } + else { + gen.var(valid, true); // TODO var + validateProperties(pat); + gen.if(valid); + } + } + } + function checkMatchingProperties(pat) { + for (const prop in checkProperties) { + if (new RegExp(pat).test(prop)) { + (0, util_1$6.checkStrictMode)(it, `property ${prop} matches pattern ${pat} (use allowMatchingProperties)`); + } + } + } + function validateProperties(pat) { + gen.forIn("key", data, (key) => { + gen.if((0, codegen_1$4._) `${(0, code_1$1.usePattern)(cxt, pat)}.test(${key})`, () => { + const alwaysValid = alwaysValidPatterns.includes(pat); + if (!alwaysValid) { + cxt.subschema({ + keyword: "patternProperties", + schemaProp: pat, + dataProp: key, + dataPropType: util_2.Type.Str, + }, valid); + } + if (it.opts.unevaluated && props !== true) { + gen.assign((0, codegen_1$4._) `${props}[${key}]`, true); + } + else if (!alwaysValid && !it.allErrors) { + // can short-circuit if `unevaluatedProperties` is not supported (opts.next === false) + // or if all properties were evaluated (props === true) + gen.if((0, codegen_1$4.not)(valid), () => gen.break()); + } + }); + }); + } + }, +}; +patternProperties.default = def$8; + +var not = {}; + +Object.defineProperty(not, "__esModule", { value: true }); +const util_1$5 = util; +const def$7 = { + keyword: "not", + schemaType: ["object", "boolean"], + trackErrors: true, + code(cxt) { + const { gen, schema, it } = cxt; + if ((0, util_1$5.alwaysValidSchema)(it, schema)) { + cxt.fail(); + return; + } + const valid = gen.name("valid"); + cxt.subschema({ + keyword: "not", + compositeRule: true, + createErrors: false, + allErrors: false, + }, valid); + cxt.failResult(valid, () => cxt.reset(), () => cxt.error()); + }, + error: { message: "must NOT be valid" }, +}; +not.default = def$7; + +var anyOf = {}; + +Object.defineProperty(anyOf, "__esModule", { value: true }); +const code_1 = code; +const def$6 = { + keyword: "anyOf", + schemaType: "array", + trackErrors: true, + code: code_1.validateUnion, + error: { message: "must match a schema in anyOf" }, +}; +anyOf.default = def$6; + +var oneOf = {}; + +Object.defineProperty(oneOf, "__esModule", { value: true }); +const codegen_1$3 = codegen; +const util_1$4 = util; +const error$3 = { + message: "must match exactly one schema in oneOf", + params: ({ params }) => (0, codegen_1$3._) `{passingSchemas: ${params.passing}}`, +}; +const def$5 = { + keyword: "oneOf", + schemaType: "array", + trackErrors: true, + error: error$3, + code(cxt) { + const { gen, schema, parentSchema, it } = cxt; + /* istanbul ignore if */ + if (!Array.isArray(schema)) + throw new Error("ajv implementation error"); + if (it.opts.discriminator && parentSchema.discriminator) + return; + const schArr = schema; + const valid = gen.let("valid", false); + const passing = gen.let("passing", null); + const schValid = gen.name("_valid"); + cxt.setParams({ passing }); + // TODO possibly fail straight away (with warning or exception) if there are two empty always valid schemas + gen.block(validateOneOf); + cxt.result(valid, () => cxt.reset(), () => cxt.error(true)); + function validateOneOf() { + schArr.forEach((sch, i) => { + let schCxt; + if ((0, util_1$4.alwaysValidSchema)(it, sch)) { + gen.var(schValid, true); + } + else { + schCxt = cxt.subschema({ + keyword: "oneOf", + schemaProp: i, + compositeRule: true, + }, schValid); + } + if (i > 0) { + gen + .if((0, codegen_1$3._) `${schValid} && ${valid}`) + .assign(valid, false) + .assign(passing, (0, codegen_1$3._) `[${passing}, ${i}]`) + .else(); + } + gen.if(schValid, () => { + gen.assign(valid, true); + gen.assign(passing, i); + if (schCxt) + cxt.mergeEvaluated(schCxt, codegen_1$3.Name); + }); + }); + } + }, +}; +oneOf.default = def$5; + +var allOf = {}; + +Object.defineProperty(allOf, "__esModule", { value: true }); +const util_1$3 = util; +const def$4 = { + keyword: "allOf", + schemaType: "array", + code(cxt) { + const { gen, schema, it } = cxt; + /* istanbul ignore if */ + if (!Array.isArray(schema)) + throw new Error("ajv implementation error"); + const valid = gen.name("valid"); + schema.forEach((sch, i) => { + if ((0, util_1$3.alwaysValidSchema)(it, sch)) + return; + const schCxt = cxt.subschema({ keyword: "allOf", schemaProp: i }, valid); + cxt.ok(valid); + cxt.mergeEvaluated(schCxt); + }); + }, +}; +allOf.default = def$4; + +var _if = {}; + +Object.defineProperty(_if, "__esModule", { value: true }); +const codegen_1$2 = codegen; +const util_1$2 = util; +const error$2 = { + message: ({ params }) => (0, codegen_1$2.str) `must match "${params.ifClause}" schema`, + params: ({ params }) => (0, codegen_1$2._) `{failingKeyword: ${params.ifClause}}`, +}; +const def$3 = { + keyword: "if", + schemaType: ["object", "boolean"], + trackErrors: true, + error: error$2, + code(cxt) { + const { gen, parentSchema, it } = cxt; + if (parentSchema.then === undefined && parentSchema.else === undefined) { + (0, util_1$2.checkStrictMode)(it, '"if" without "then" and "else" is ignored'); + } + const hasThen = hasSchema(it, "then"); + const hasElse = hasSchema(it, "else"); + if (!hasThen && !hasElse) + return; + const valid = gen.let("valid", true); + const schValid = gen.name("_valid"); + validateIf(); + cxt.reset(); + if (hasThen && hasElse) { + const ifClause = gen.let("ifClause"); + cxt.setParams({ ifClause }); + gen.if(schValid, validateClause("then", ifClause), validateClause("else", ifClause)); + } + else if (hasThen) { + gen.if(schValid, validateClause("then")); + } + else { + gen.if((0, codegen_1$2.not)(schValid), validateClause("else")); + } + cxt.pass(valid, () => cxt.error(true)); + function validateIf() { + const schCxt = cxt.subschema({ + keyword: "if", + compositeRule: true, + createErrors: false, + allErrors: false, + }, schValid); + cxt.mergeEvaluated(schCxt); + } + function validateClause(keyword, ifClause) { + return () => { + const schCxt = cxt.subschema({ keyword }, schValid); + gen.assign(valid, schValid); + cxt.mergeValidEvaluated(schCxt, valid); + if (ifClause) + gen.assign(ifClause, (0, codegen_1$2._) `${keyword}`); + else + cxt.setParams({ ifClause: keyword }); + }; + } + }, +}; +function hasSchema(it, keyword) { + const schema = it.schema[keyword]; + return schema !== undefined && !(0, util_1$2.alwaysValidSchema)(it, schema); +} +_if.default = def$3; + +var thenElse = {}; + +Object.defineProperty(thenElse, "__esModule", { value: true }); +const util_1$1 = util; +const def$2 = { + keyword: ["then", "else"], + schemaType: ["object", "boolean"], + code({ keyword, parentSchema, it }) { + if (parentSchema.if === undefined) + (0, util_1$1.checkStrictMode)(it, `"${keyword}" without "if" is ignored`); + }, +}; +thenElse.default = def$2; + +Object.defineProperty(applicator, "__esModule", { value: true }); +const additionalItems_1 = additionalItems; +const prefixItems_1 = prefixItems; +const items_1 = items; +const items2020_1 = items2020; +const contains_1 = contains; +const dependencies_1 = dependencies; +const propertyNames_1 = propertyNames; +const additionalProperties_1 = additionalProperties; +const properties_1 = properties$1; +const patternProperties_1 = patternProperties; +const not_1 = not; +const anyOf_1 = anyOf; +const oneOf_1 = oneOf; +const allOf_1 = allOf; +const if_1 = _if; +const thenElse_1 = thenElse; +function getApplicator(draft2020 = false) { + const applicator = [ + // any + not_1.default, + anyOf_1.default, + oneOf_1.default, + allOf_1.default, + if_1.default, + thenElse_1.default, + // object + propertyNames_1.default, + additionalProperties_1.default, + dependencies_1.default, + properties_1.default, + patternProperties_1.default, + ]; + // array + if (draft2020) + applicator.push(prefixItems_1.default, items2020_1.default); + else + applicator.push(additionalItems_1.default, items_1.default); + applicator.push(contains_1.default); + return applicator; +} +applicator.default = getApplicator; + +var format$2 = {}; + +var format$1 = {}; + +Object.defineProperty(format$1, "__esModule", { value: true }); +const codegen_1$1 = codegen; +const error$1 = { + message: ({ schemaCode }) => (0, codegen_1$1.str) `must match format "${schemaCode}"`, + params: ({ schemaCode }) => (0, codegen_1$1._) `{format: ${schemaCode}}`, +}; +const def$1 = { + keyword: "format", + type: ["number", "string"], + schemaType: "string", + $data: true, + error: error$1, + code(cxt, ruleType) { + const { gen, data, $data, schema, schemaCode, it } = cxt; + const { opts, errSchemaPath, schemaEnv, self } = it; + if (!opts.validateFormats) + return; + if ($data) + validate$DataFormat(); + else + validateFormat(); + function validate$DataFormat() { + const fmts = gen.scopeValue("formats", { + ref: self.formats, + code: opts.code.formats, + }); + const fDef = gen.const("fDef", (0, codegen_1$1._) `${fmts}[${schemaCode}]`); + const fType = gen.let("fType"); + const format = gen.let("format"); + // TODO simplify + gen.if((0, codegen_1$1._) `typeof ${fDef} == "object" && !(${fDef} instanceof RegExp)`, () => gen.assign(fType, (0, codegen_1$1._) `${fDef}.type || "string"`).assign(format, (0, codegen_1$1._) `${fDef}.validate`), () => gen.assign(fType, (0, codegen_1$1._) `"string"`).assign(format, fDef)); + cxt.fail$data((0, codegen_1$1.or)(unknownFmt(), invalidFmt())); + function unknownFmt() { + if (opts.strictSchema === false) + return codegen_1$1.nil; + return (0, codegen_1$1._) `${schemaCode} && !${format}`; + } + function invalidFmt() { + const callFormat = schemaEnv.$async + ? (0, codegen_1$1._) `(${fDef}.async ? await ${format}(${data}) : ${format}(${data}))` + : (0, codegen_1$1._) `${format}(${data})`; + const validData = (0, codegen_1$1._) `(typeof ${format} == "function" ? ${callFormat} : ${format}.test(${data}))`; + return (0, codegen_1$1._) `${format} && ${format} !== true && ${fType} === ${ruleType} && !${validData}`; + } + } + function validateFormat() { + const formatDef = self.formats[schema]; + if (!formatDef) { + unknownFormat(); + return; + } + if (formatDef === true) + return; + const [fmtType, format, fmtRef] = getFormat(formatDef); + if (fmtType === ruleType) + cxt.pass(validCondition()); + function unknownFormat() { + if (opts.strictSchema === false) { + self.logger.warn(unknownMsg()); + return; + } + throw new Error(unknownMsg()); + function unknownMsg() { + return `unknown format "${schema}" ignored in schema at path "${errSchemaPath}"`; + } + } + function getFormat(fmtDef) { + const code = fmtDef instanceof RegExp + ? (0, codegen_1$1.regexpCode)(fmtDef) + : opts.code.formats + ? (0, codegen_1$1._) `${opts.code.formats}${(0, codegen_1$1.getProperty)(schema)}` + : undefined; + const fmt = gen.scopeValue("formats", { key: schema, ref: fmtDef, code }); + if (typeof fmtDef == "object" && !(fmtDef instanceof RegExp)) { + return [fmtDef.type || "string", fmtDef.validate, (0, codegen_1$1._) `${fmt}.validate`]; + } + return ["string", fmtDef, fmt]; + } + function validCondition() { + if (typeof formatDef == "object" && !(formatDef instanceof RegExp) && formatDef.async) { + if (!schemaEnv.$async) + throw new Error("async format in sync schema"); + return (0, codegen_1$1._) `await ${fmtRef}(${data})`; + } + return typeof format == "function" ? (0, codegen_1$1._) `${fmtRef}(${data})` : (0, codegen_1$1._) `${fmtRef}.test(${data})`; + } + } + }, +}; +format$1.default = def$1; + +Object.defineProperty(format$2, "__esModule", { value: true }); +const format_1$1 = format$1; +const format = [format_1$1.default]; +format$2.default = format; + +var metadata = {}; + +Object.defineProperty(metadata, "__esModule", { value: true }); +metadata.contentVocabulary = metadata.metadataVocabulary = void 0; +metadata.metadataVocabulary = [ + "title", + "description", + "default", + "deprecated", + "readOnly", + "writeOnly", + "examples", +]; +metadata.contentVocabulary = [ + "contentMediaType", + "contentEncoding", + "contentSchema", +]; + +Object.defineProperty(draft7, "__esModule", { value: true }); +const core_1 = core$1; +const validation_1 = validation$1; +const applicator_1 = applicator; +const format_1 = format$2; +const metadata_1 = metadata; +const draft7Vocabularies = [ + core_1.default, + validation_1.default, + (0, applicator_1.default)(), + format_1.default, + metadata_1.metadataVocabulary, + metadata_1.contentVocabulary, +]; +draft7.default = draft7Vocabularies; + +var discriminator = {}; + +var types = {}; + +(function (exports) { + Object.defineProperty(exports, "__esModule", { value: true }); + exports.DiscrError = void 0; + (function (DiscrError) { + DiscrError["Tag"] = "tag"; + DiscrError["Mapping"] = "mapping"; + })(exports.DiscrError || (exports.DiscrError = {})); + +} (types)); + +Object.defineProperty(discriminator, "__esModule", { value: true }); +const codegen_1 = codegen; +const types_1 = types; +const compile_1 = compile; +const util_1 = util; +const error = { + message: ({ params: { discrError, tagName } }) => discrError === types_1.DiscrError.Tag + ? `tag "${tagName}" must be string` + : `value of tag "${tagName}" must be in oneOf`, + params: ({ params: { discrError, tag, tagName } }) => (0, codegen_1._) `{error: ${discrError}, tag: ${tagName}, tagValue: ${tag}}`, +}; +const def = { + keyword: "discriminator", + type: "object", + schemaType: "object", + error, + code(cxt) { + const { gen, data, schema, parentSchema, it } = cxt; + const { oneOf } = parentSchema; + if (!it.opts.discriminator) { + throw new Error("discriminator: requires discriminator option"); + } + const tagName = schema.propertyName; + if (typeof tagName != "string") + throw new Error("discriminator: requires propertyName"); + if (schema.mapping) + throw new Error("discriminator: mapping is not supported"); + if (!oneOf) + throw new Error("discriminator: requires oneOf keyword"); + const valid = gen.let("valid", false); + const tag = gen.const("tag", (0, codegen_1._) `${data}${(0, codegen_1.getProperty)(tagName)}`); + gen.if((0, codegen_1._) `typeof ${tag} == "string"`, () => validateMapping(), () => cxt.error(false, { discrError: types_1.DiscrError.Tag, tag, tagName })); + cxt.ok(valid); + function validateMapping() { + const mapping = getMapping(); + gen.if(false); + for (const tagValue in mapping) { + gen.elseIf((0, codegen_1._) `${tag} === ${tagValue}`); + gen.assign(valid, applyTagSchema(mapping[tagValue])); + } + gen.else(); + cxt.error(false, { discrError: types_1.DiscrError.Mapping, tag, tagName }); + gen.endIf(); + } + function applyTagSchema(schemaProp) { + const _valid = gen.name("valid"); + const schCxt = cxt.subschema({ keyword: "oneOf", schemaProp }, _valid); + cxt.mergeEvaluated(schCxt, codegen_1.Name); + return _valid; + } + function getMapping() { + var _a; + const oneOfMapping = {}; + const topRequired = hasRequired(parentSchema); + let tagRequired = true; + for (let i = 0; i < oneOf.length; i++) { + let sch = oneOf[i]; + if ((sch === null || sch === void 0 ? void 0 : sch.$ref) && !(0, util_1.schemaHasRulesButRef)(sch, it.self.RULES)) { + sch = compile_1.resolveRef.call(it.self, it.schemaEnv.root, it.baseId, sch === null || sch === void 0 ? void 0 : sch.$ref); + if (sch instanceof compile_1.SchemaEnv) + sch = sch.schema; + } + const propSch = (_a = sch === null || sch === void 0 ? void 0 : sch.properties) === null || _a === void 0 ? void 0 : _a[tagName]; + if (typeof propSch != "object") { + throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${tagName}"`); + } + tagRequired = tagRequired && (topRequired || hasRequired(sch)); + addMappings(propSch, i); + } + if (!tagRequired) + throw new Error(`discriminator: "${tagName}" must be required`); + return oneOfMapping; + function hasRequired({ required }) { + return Array.isArray(required) && required.includes(tagName); + } + function addMappings(sch, i) { + if (sch.const) { + addMapping(sch.const, i); + } + else if (sch.enum) { + for (const tagValue of sch.enum) { + addMapping(tagValue, i); + } + } + else { + throw new Error(`discriminator: "properties/${tagName}" must have "const" or "enum"`); + } + } + function addMapping(tagValue, i) { + if (typeof tagValue != "string" || tagValue in oneOfMapping) { + throw new Error(`discriminator: "${tagName}" values must be unique strings`); + } + oneOfMapping[tagValue] = i; + } + } + }, +}; +discriminator.default = def; + +var $schema = "http://json-schema.org/draft-07/schema#"; +var $id = "http://json-schema.org/draft-07/schema#"; +var title = "Core schema meta-schema"; +var definitions = { + schemaArray: { + type: "array", + minItems: 1, + items: { + $ref: "#" + } + }, + nonNegativeInteger: { + type: "integer", + minimum: 0 + }, + nonNegativeIntegerDefault0: { + allOf: [ + { + $ref: "#/definitions/nonNegativeInteger" + }, + { + "default": 0 + } + ] + }, + simpleTypes: { + "enum": [ + "array", + "boolean", + "integer", + "null", + "number", + "object", + "string" + ] + }, + stringArray: { + type: "array", + items: { + type: "string" + }, + uniqueItems: true, + "default": [ + ] + } +}; +var type = [ + "object", + "boolean" +]; +var properties = { + $id: { + type: "string", + format: "uri-reference" + }, + $schema: { + type: "string", + format: "uri" + }, + $ref: { + type: "string", + format: "uri-reference" + }, + $comment: { + type: "string" + }, + title: { + type: "string" + }, + description: { + type: "string" + }, + "default": true, + readOnly: { + type: "boolean", + "default": false + }, + examples: { + type: "array", + items: true + }, + multipleOf: { + type: "number", + exclusiveMinimum: 0 + }, + maximum: { + type: "number" + }, + exclusiveMaximum: { + type: "number" + }, + minimum: { + type: "number" + }, + exclusiveMinimum: { + type: "number" + }, + maxLength: { + $ref: "#/definitions/nonNegativeInteger" + }, + minLength: { + $ref: "#/definitions/nonNegativeIntegerDefault0" + }, + pattern: { + type: "string", + format: "regex" + }, + additionalItems: { + $ref: "#" + }, + items: { + anyOf: [ + { + $ref: "#" + }, + { + $ref: "#/definitions/schemaArray" + } + ], + "default": true + }, + maxItems: { + $ref: "#/definitions/nonNegativeInteger" + }, + minItems: { + $ref: "#/definitions/nonNegativeIntegerDefault0" + }, + uniqueItems: { + type: "boolean", + "default": false + }, + contains: { + $ref: "#" + }, + maxProperties: { + $ref: "#/definitions/nonNegativeInteger" + }, + minProperties: { + $ref: "#/definitions/nonNegativeIntegerDefault0" + }, + required: { + $ref: "#/definitions/stringArray" + }, + additionalProperties: { + $ref: "#" + }, + definitions: { + type: "object", + additionalProperties: { + $ref: "#" + }, + "default": { + } + }, + properties: { + type: "object", + additionalProperties: { + $ref: "#" + }, + "default": { + } + }, + patternProperties: { + type: "object", + additionalProperties: { + $ref: "#" + }, + propertyNames: { + format: "regex" + }, + "default": { + } + }, + dependencies: { + type: "object", + additionalProperties: { + anyOf: [ + { + $ref: "#" + }, + { + $ref: "#/definitions/stringArray" + } + ] + } + }, + propertyNames: { + $ref: "#" + }, + "const": true, + "enum": { + type: "array", + items: true, + minItems: 1, + uniqueItems: true + }, + type: { + anyOf: [ + { + $ref: "#/definitions/simpleTypes" + }, + { + type: "array", + items: { + $ref: "#/definitions/simpleTypes" + }, + minItems: 1, + uniqueItems: true + } + ] + }, + format: { + type: "string" + }, + contentMediaType: { + type: "string" + }, + contentEncoding: { + type: "string" + }, + "if": { + $ref: "#" + }, + then: { + $ref: "#" + }, + "else": { + $ref: "#" + }, + allOf: { + $ref: "#/definitions/schemaArray" + }, + anyOf: { + $ref: "#/definitions/schemaArray" + }, + oneOf: { + $ref: "#/definitions/schemaArray" + }, + not: { + $ref: "#" + } +}; +var require$$3 = { + $schema: $schema, + $id: $id, + title: title, + definitions: definitions, + type: type, + properties: properties, + "default": true +}; + +(function (module, exports) { + Object.defineProperty(exports, "__esModule", { value: true }); + exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0; + const core_1 = core$2; + const draft7_1 = draft7; + const discriminator_1 = discriminator; + const draft7MetaSchema = require$$3; + const META_SUPPORT_DATA = ["/properties"]; + const META_SCHEMA_ID = "http://json-schema.org/draft-07/schema"; + class Ajv extends core_1.default { + _addVocabularies() { + super._addVocabularies(); + draft7_1.default.forEach((v) => this.addVocabulary(v)); + if (this.opts.discriminator) + this.addKeyword(discriminator_1.default); + } + _addDefaultMetaSchema() { + super._addDefaultMetaSchema(); + if (!this.opts.meta) + return; + const metaSchema = this.opts.$data + ? this.$dataMetaSchema(draft7MetaSchema, META_SUPPORT_DATA) + : draft7MetaSchema; + this.addMetaSchema(metaSchema, META_SCHEMA_ID, false); + this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID; + } + defaultMeta() { + return (this.opts.defaultMeta = + super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined)); + } + } + module.exports = exports = Ajv; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.default = Ajv; + var validate_1 = validate; + Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function () { return validate_1.KeywordCxt; } }); + var codegen_1 = codegen; + Object.defineProperty(exports, "_", { enumerable: true, get: function () { return codegen_1._; } }); + Object.defineProperty(exports, "str", { enumerable: true, get: function () { return codegen_1.str; } }); + Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return codegen_1.stringify; } }); + Object.defineProperty(exports, "nil", { enumerable: true, get: function () { return codegen_1.nil; } }); + Object.defineProperty(exports, "Name", { enumerable: true, get: function () { return codegen_1.Name; } }); + Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function () { return codegen_1.CodeGen; } }); + var validation_error_1 = validation_error; + Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return validation_error_1.default; } }); + var ref_error_1 = ref_error; + Object.defineProperty(exports, "MissingRefError", { enumerable: true, get: function () { return ref_error_1.default; } }); + +} (ajv$1, ajv$1.exports)); + +var ajvExports = ajv$1.exports; +var Ajv = /*@__PURE__*/getDefaultExportFromCjs(ajvExports); + +const addressType = { type: "string", pattern: "^0x[a-fA-F0-9]{40}$" }; +const bnType = { type: "string", BN: true }; +const statusSchema = { + type: "object", + properties: { + rewardAccount: addressType, + gasPrices: { + type: "object", + properties: { + fast: { type: "number" }, + additionalProperties: { type: "number" } + }, + required: ["fast"] + }, + netId: { type: "integer" }, + tornadoServiceFee: { type: "number", maximum: 20, minimum: 0 }, + latestBlock: { type: "number" }, + version: { type: "string" }, + health: { + type: "object", + properties: { + status: { const: "true" }, + error: { type: "string" } + }, + required: ["status"] + }, + currentQueue: { type: "number" } + }, + required: ["rewardAccount", "instances", "netId", "tornadoServiceFee", "version", "health"] +}; +function getStatusSchema(netId, config) { + const { tokens, optionalTokens = [], nativeCurrency } = config; + const schema = JSON.parse(JSON.stringify(statusSchema)); + const instances = Object.keys(tokens).reduce( + (acc, token) => { + const { instanceAddress, tokenAddress, symbol, decimals, optionalInstances = [] } = tokens[token]; + const amounts = Object.keys(instanceAddress); + const instanceProperties = { + type: "object", + properties: { + instanceAddress: { + type: "object", + properties: amounts.reduce((acc2, cur) => { + acc2[cur] = addressType; + return acc2; + }, {}), + required: amounts.filter((amount) => !optionalInstances.includes(amount)) + }, + decimals: { enum: [decimals] } + }, + required: ["instanceAddress", "decimals"].concat( + tokenAddress ? ["tokenAddress"] : [], + symbol ? ["symbol"] : [] + ) + }; + if (tokenAddress) { + instanceProperties.properties.tokenAddress = addressType; + } + if (symbol) { + instanceProperties.properties.symbol = { enum: [symbol] }; + } + acc.properties[token] = instanceProperties; + if (!optionalTokens.includes(token)) { + acc.required.push(token); + } + return acc; + }, + { + type: "object", + properties: {}, + required: [] + } + ); + schema.properties.instances = instances; + if (Number(netId) === 1) { + const _tokens = Object.keys(tokens).filter((t) => t !== nativeCurrency); + const ethPrices = { + type: "object", + properties: _tokens.reduce((acc, token) => { + acc[token] = bnType; + return acc; + }, {}) + // required: _tokens + }; + schema.properties.ethPrices = ethPrices; + } + return schema; +} + +const jobsSchema = { + type: "object", + properties: { + error: { type: "string" }, + id: { type: "string" }, + type: { type: "string" }, + status: { type: "string" }, + contract: { type: "string" }, + proof: { type: "string" }, + args: { + type: "array", + items: { type: "string" } + }, + txHash: { type: "string" }, + confirmations: { type: "number" }, + failedReason: { type: "string" } + }, + required: ["id", "status"] +}; + +const ajv = new Ajv({ allErrors: true }); +ajv.addKeyword({ + keyword: "BN", + // eslint-disable-next-line @typescript-eslint/no-explicit-any + validate: (schema, data) => { + try { + BigInt(data); + return true; + } catch (e) { + return false; + } + }, + errors: true +}); + +/* global BigInt */ +const hexLen = [ 0, 1, 2, 2, 3, 3, 3, 3, 4 ,4 ,4 ,4 ,4 ,4 ,4 ,4]; + +function fromString$2(s, radix) { + if ((!radix)||(radix==10)) { + return BigInt(s); + } else if (radix==16) { + if (s.slice(0,2) == "0x") { + return BigInt(s); + } else { + return BigInt("0x"+s); + } + } +} + +const e$2 = fromString$2; + +function fromArray$2(a, radix) { + let acc =BigInt(0); + radix = BigInt(radix); + for (let i=0; i> BigInt(n); +} + +const shl$2 = shiftLeft$2; +const shr$2 = shiftRight$2; + +function isOdd$2(a) { + return (BigInt(a) & BigInt(1)) == BigInt(1); +} + + +function naf$2(n) { + let E = BigInt(n); + const res = []; + while (E) { + if (E & BigInt(1)) { + const z = 2 - Number(E % BigInt(4)); + res.push( z ); + E = E - BigInt(z); + } else { + res.push( 0 ); + } + E = E >> BigInt(1); + } + return res; +} + + +function bits$2(n) { + let E = BigInt(n); + const res = []; + while (E) { + if (E & BigInt(1)) { + res.push(1); + } else { + res.push( 0 ); + } + E = E >> BigInt(1); + } + return res; +} + +function toNumber$3(s) { + if (s>BigInt(Number.MAX_SAFE_INTEGER )) { + throw new Error("Number too big"); + } + return Number(s); +} + +function toArray$2(s, radix) { + const res = []; + let rem = BigInt(s); + radix = BigInt(radix); + while (rem) { + res.unshift( Number(rem % radix)); + rem = rem / radix; + } + return res; +} + + +function add$2(a, b) { + return BigInt(a) + BigInt(b); +} + +function sub$2(a, b) { + return BigInt(a) - BigInt(b); +} + +function neg$2(a) { + return -BigInt(a); +} + +function mul$2(a, b) { + return BigInt(a) * BigInt(b); +} + +function square$2(a) { + return BigInt(a) * BigInt(a); +} + +function pow$2(a, b) { + return BigInt(a) ** BigInt(b); +} + +function exp$2(a, b) { + return BigInt(a) ** BigInt(b); +} + +function abs$2(a) { + return BigInt(a) >= 0 ? BigInt(a) : -BigInt(a); +} + +function div$2(a, b) { + return BigInt(a) / BigInt(b); +} + +function mod$2(a, b) { + return BigInt(a) % BigInt(b); +} + +function eq$2(a, b) { + return BigInt(a) == BigInt(b); +} + +function neq$2(a, b) { + return BigInt(a) != BigInt(b); +} + +function lt$2(a, b) { + return BigInt(a) < BigInt(b); +} + +function gt$2(a, b) { + return BigInt(a) > BigInt(b); +} + +function leq$2(a, b) { + return BigInt(a) <= BigInt(b); +} + +function geq$2(a, b) { + return BigInt(a) >= BigInt(b); +} + +function band$2(a, b) { + return BigInt(a) & BigInt(b); +} + +function bor$2(a, b) { + return BigInt(a) | BigInt(b); +} + +function bxor$2(a, b) { + return BigInt(a) ^ BigInt(b); +} + +function land$2(a, b) { + return BigInt(a) && BigInt(b); +} + +function lor$2(a, b) { + return BigInt(a) || BigInt(b); +} + +function lnot$2(a) { + return !BigInt(a); +} + +var Scalar_native = /*#__PURE__*/Object.freeze({ + __proto__: null, + abs: abs$2, + add: add$2, + band: band$2, + bitLength: bitLength$2, + bits: bits$2, + bor: bor$2, + bxor: bxor$2, + div: div$2, + e: e$2, + eq: eq$2, + exp: exp$2, + fromArray: fromArray$2, + fromString: fromString$2, + geq: geq$2, + gt: gt$2, + isNegative: isNegative$2, + isOdd: isOdd$2, + isZero: isZero$2, + land: land$2, + leq: leq$2, + lnot: lnot$2, + lor: lor$2, + lt: lt$2, + mod: mod$2, + mul: mul$2, + naf: naf$2, + neg: neg$2, + neq: neq$2, + pow: pow$2, + shiftLeft: shiftLeft$2, + shiftRight: shiftRight$2, + shl: shl$2, + shr: shr$2, + square: square$2, + sub: sub$2, + toArray: toArray$2, + toNumber: toNumber$3 +}); + +var BigInteger$1 = {exports: {}}; + +(function (module) { + var bigInt = (function (undefined$1) { + + var BASE = 1e7, + LOG_BASE = 7, + MAX_INT = 9007199254740992, + MAX_INT_ARR = smallToArray(MAX_INT), + DEFAULT_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz"; + + var supportsNativeBigInt = typeof BigInt === "function"; + + function Integer(v, radix, alphabet, caseSensitive) { + if (typeof v === "undefined") return Integer[0]; + if (typeof radix !== "undefined") return +radix === 10 && !alphabet ? parseValue(v) : parseBase(v, radix, alphabet, caseSensitive); + return parseValue(v); + } + + function BigInteger(value, sign) { + this.value = value; + this.sign = sign; + this.isSmall = false; + } + BigInteger.prototype = Object.create(Integer.prototype); + + function SmallInteger(value) { + this.value = value; + this.sign = value < 0; + this.isSmall = true; + } + SmallInteger.prototype = Object.create(Integer.prototype); + + function NativeBigInt(value) { + this.value = value; + } + NativeBigInt.prototype = Object.create(Integer.prototype); + + function isPrecise(n) { + return -MAX_INT < n && n < MAX_INT; + } + + function smallToArray(n) { // For performance reasons doesn't reference BASE, need to change this function if BASE changes + if (n < 1e7) + return [n]; + if (n < 1e14) + return [n % 1e7, Math.floor(n / 1e7)]; + return [n % 1e7, Math.floor(n / 1e7) % 1e7, Math.floor(n / 1e14)]; + } + + function arrayToSmall(arr) { // If BASE changes this function may need to change + trim(arr); + var length = arr.length; + if (length < 4 && compareAbs(arr, MAX_INT_ARR) < 0) { + switch (length) { + case 0: return 0; + case 1: return arr[0]; + case 2: return arr[0] + arr[1] * BASE; + default: return arr[0] + (arr[1] + arr[2] * BASE) * BASE; + } + } + return arr; + } + + function trim(v) { + var i = v.length; + while (v[--i] === 0); + v.length = i + 1; + } + + function createArray(length) { // function shamelessly stolen from Yaffle's library https://github.com/Yaffle/BigInteger + var x = new Array(length); + var i = -1; + while (++i < length) { + x[i] = 0; + } + return x; + } + + function truncate(n) { + if (n > 0) return Math.floor(n); + return Math.ceil(n); + } + + function add(a, b) { // assumes a and b are arrays with a.length >= b.length + var l_a = a.length, + l_b = b.length, + r = new Array(l_a), + carry = 0, + base = BASE, + sum, i; + for (i = 0; i < l_b; i++) { + sum = a[i] + b[i] + carry; + carry = sum >= base ? 1 : 0; + r[i] = sum - carry * base; + } + while (i < l_a) { + sum = a[i] + carry; + carry = sum === base ? 1 : 0; + r[i++] = sum - carry * base; + } + if (carry > 0) r.push(carry); + return r; + } + + function addAny(a, b) { + if (a.length >= b.length) return add(a, b); + return add(b, a); + } + + function addSmall(a, carry) { // assumes a is array, carry is number with 0 <= carry < MAX_INT + var l = a.length, + r = new Array(l), + base = BASE, + sum, i; + for (i = 0; i < l; i++) { + sum = a[i] - base + carry; + carry = Math.floor(sum / base); + r[i] = sum - carry * base; + carry += 1; + } + while (carry > 0) { + r[i++] = carry % base; + carry = Math.floor(carry / base); + } + return r; + } + + BigInteger.prototype.add = function (v) { + var n = parseValue(v); + if (this.sign !== n.sign) { + return this.subtract(n.negate()); + } + var a = this.value, b = n.value; + if (n.isSmall) { + return new BigInteger(addSmall(a, Math.abs(b)), this.sign); + } + return new BigInteger(addAny(a, b), this.sign); + }; + BigInteger.prototype.plus = BigInteger.prototype.add; + + SmallInteger.prototype.add = function (v) { + var n = parseValue(v); + var a = this.value; + if (a < 0 !== n.sign) { + return this.subtract(n.negate()); + } + var b = n.value; + if (n.isSmall) { + if (isPrecise(a + b)) return new SmallInteger(a + b); + b = smallToArray(Math.abs(b)); + } + return new BigInteger(addSmall(b, Math.abs(a)), a < 0); + }; + SmallInteger.prototype.plus = SmallInteger.prototype.add; + + NativeBigInt.prototype.add = function (v) { + return new NativeBigInt(this.value + parseValue(v).value); + }; + NativeBigInt.prototype.plus = NativeBigInt.prototype.add; + + function subtract(a, b) { // assumes a and b are arrays with a >= b + var a_l = a.length, + b_l = b.length, + r = new Array(a_l), + borrow = 0, + base = BASE, + i, difference; + for (i = 0; i < b_l; i++) { + difference = a[i] - borrow - b[i]; + if (difference < 0) { + difference += base; + borrow = 1; + } else borrow = 0; + r[i] = difference; + } + for (i = b_l; i < a_l; i++) { + difference = a[i] - borrow; + if (difference < 0) difference += base; + else { + r[i++] = difference; + break; + } + r[i] = difference; + } + for (; i < a_l; i++) { + r[i] = a[i]; + } + trim(r); + return r; + } + + function subtractAny(a, b, sign) { + var value; + if (compareAbs(a, b) >= 0) { + value = subtract(a, b); + } else { + value = subtract(b, a); + sign = !sign; + } + value = arrayToSmall(value); + if (typeof value === "number") { + if (sign) value = -value; + return new SmallInteger(value); + } + return new BigInteger(value, sign); + } + + function subtractSmall(a, b, sign) { // assumes a is array, b is number with 0 <= b < MAX_INT + var l = a.length, + r = new Array(l), + carry = -b, + base = BASE, + i, difference; + for (i = 0; i < l; i++) { + difference = a[i] + carry; + carry = Math.floor(difference / base); + difference %= base; + r[i] = difference < 0 ? difference + base : difference; + } + r = arrayToSmall(r); + if (typeof r === "number") { + if (sign) r = -r; + return new SmallInteger(r); + } return new BigInteger(r, sign); + } + + BigInteger.prototype.subtract = function (v) { + var n = parseValue(v); + if (this.sign !== n.sign) { + return this.add(n.negate()); + } + var a = this.value, b = n.value; + if (n.isSmall) + return subtractSmall(a, Math.abs(b), this.sign); + return subtractAny(a, b, this.sign); + }; + BigInteger.prototype.minus = BigInteger.prototype.subtract; + + SmallInteger.prototype.subtract = function (v) { + var n = parseValue(v); + var a = this.value; + if (a < 0 !== n.sign) { + return this.add(n.negate()); + } + var b = n.value; + if (n.isSmall) { + return new SmallInteger(a - b); + } + return subtractSmall(b, Math.abs(a), a >= 0); + }; + SmallInteger.prototype.minus = SmallInteger.prototype.subtract; + + NativeBigInt.prototype.subtract = function (v) { + return new NativeBigInt(this.value - parseValue(v).value); + }; + NativeBigInt.prototype.minus = NativeBigInt.prototype.subtract; + + BigInteger.prototype.negate = function () { + return new BigInteger(this.value, !this.sign); + }; + SmallInteger.prototype.negate = function () { + var sign = this.sign; + var small = new SmallInteger(-this.value); + small.sign = !sign; + return small; + }; + NativeBigInt.prototype.negate = function () { + return new NativeBigInt(-this.value); + }; + + BigInteger.prototype.abs = function () { + return new BigInteger(this.value, false); + }; + SmallInteger.prototype.abs = function () { + return new SmallInteger(Math.abs(this.value)); + }; + NativeBigInt.prototype.abs = function () { + return new NativeBigInt(this.value >= 0 ? this.value : -this.value); + }; + + + function multiplyLong(a, b) { + var a_l = a.length, + b_l = b.length, + l = a_l + b_l, + r = createArray(l), + base = BASE, + product, carry, i, a_i, b_j; + for (i = 0; i < a_l; ++i) { + a_i = a[i]; + for (var j = 0; j < b_l; ++j) { + b_j = b[j]; + product = a_i * b_j + r[i + j]; + carry = Math.floor(product / base); + r[i + j] = product - carry * base; + r[i + j + 1] += carry; + } + } + trim(r); + return r; + } + + function multiplySmall(a, b) { // assumes a is array, b is number with |b| < BASE + var l = a.length, + r = new Array(l), + base = BASE, + carry = 0, + product, i; + for (i = 0; i < l; i++) { + product = a[i] * b + carry; + carry = Math.floor(product / base); + r[i] = product - carry * base; + } + while (carry > 0) { + r[i++] = carry % base; + carry = Math.floor(carry / base); + } + return r; + } + + function shiftLeft(x, n) { + var r = []; + while (n-- > 0) r.push(0); + return r.concat(x); + } + + function multiplyKaratsuba(x, y) { + var n = Math.max(x.length, y.length); + + if (n <= 30) return multiplyLong(x, y); + n = Math.ceil(n / 2); + + var b = x.slice(n), + a = x.slice(0, n), + d = y.slice(n), + c = y.slice(0, n); + + var ac = multiplyKaratsuba(a, c), + bd = multiplyKaratsuba(b, d), + abcd = multiplyKaratsuba(addAny(a, b), addAny(c, d)); + + var product = addAny(addAny(ac, shiftLeft(subtract(subtract(abcd, ac), bd), n)), shiftLeft(bd, 2 * n)); + trim(product); + return product; + } + + // The following function is derived from a surface fit of a graph plotting the performance difference + // between long multiplication and karatsuba multiplication versus the lengths of the two arrays. + function useKaratsuba(l1, l2) { + return -0.012 * l1 - 0.012 * l2 + 0.000015 * l1 * l2 > 0; + } + + BigInteger.prototype.multiply = function (v) { + var n = parseValue(v), + a = this.value, b = n.value, + sign = this.sign !== n.sign, + abs; + if (n.isSmall) { + if (b === 0) return Integer[0]; + if (b === 1) return this; + if (b === -1) return this.negate(); + abs = Math.abs(b); + if (abs < BASE) { + return new BigInteger(multiplySmall(a, abs), sign); + } + b = smallToArray(abs); + } + if (useKaratsuba(a.length, b.length)) // Karatsuba is only faster for certain array sizes + return new BigInteger(multiplyKaratsuba(a, b), sign); + return new BigInteger(multiplyLong(a, b), sign); + }; + + BigInteger.prototype.times = BigInteger.prototype.multiply; + + function multiplySmallAndArray(a, b, sign) { // a >= 0 + if (a < BASE) { + return new BigInteger(multiplySmall(b, a), sign); + } + return new BigInteger(multiplyLong(b, smallToArray(a)), sign); + } + SmallInteger.prototype._multiplyBySmall = function (a) { + if (isPrecise(a.value * this.value)) { + return new SmallInteger(a.value * this.value); + } + return multiplySmallAndArray(Math.abs(a.value), smallToArray(Math.abs(this.value)), this.sign !== a.sign); + }; + BigInteger.prototype._multiplyBySmall = function (a) { + if (a.value === 0) return Integer[0]; + if (a.value === 1) return this; + if (a.value === -1) return this.negate(); + return multiplySmallAndArray(Math.abs(a.value), this.value, this.sign !== a.sign); + }; + SmallInteger.prototype.multiply = function (v) { + return parseValue(v)._multiplyBySmall(this); + }; + SmallInteger.prototype.times = SmallInteger.prototype.multiply; + + NativeBigInt.prototype.multiply = function (v) { + return new NativeBigInt(this.value * parseValue(v).value); + }; + NativeBigInt.prototype.times = NativeBigInt.prototype.multiply; + + function square(a) { + //console.assert(2 * BASE * BASE < MAX_INT); + var l = a.length, + r = createArray(l + l), + base = BASE, + product, carry, i, a_i, a_j; + for (i = 0; i < l; i++) { + a_i = a[i]; + carry = 0 - a_i * a_i; + for (var j = i; j < l; j++) { + a_j = a[j]; + product = 2 * (a_i * a_j) + r[i + j] + carry; + carry = Math.floor(product / base); + r[i + j] = product - carry * base; + } + r[i + l] = carry; + } + trim(r); + return r; + } + + BigInteger.prototype.square = function () { + return new BigInteger(square(this.value), false); + }; + + SmallInteger.prototype.square = function () { + var value = this.value * this.value; + if (isPrecise(value)) return new SmallInteger(value); + return new BigInteger(square(smallToArray(Math.abs(this.value))), false); + }; + + NativeBigInt.prototype.square = function (v) { + return new NativeBigInt(this.value * this.value); + }; + + function divMod1(a, b) { // Left over from previous version. Performs faster than divMod2 on smaller input sizes. + var a_l = a.length, + b_l = b.length, + base = BASE, + result = createArray(b.length), + divisorMostSignificantDigit = b[b_l - 1], + // normalization + lambda = Math.ceil(base / (2 * divisorMostSignificantDigit)), + remainder = multiplySmall(a, lambda), + divisor = multiplySmall(b, lambda), + quotientDigit, shift, carry, borrow, i, l, q; + if (remainder.length <= a_l) remainder.push(0); + divisor.push(0); + divisorMostSignificantDigit = divisor[b_l - 1]; + for (shift = a_l - b_l; shift >= 0; shift--) { + quotientDigit = base - 1; + if (remainder[shift + b_l] !== divisorMostSignificantDigit) { + quotientDigit = Math.floor((remainder[shift + b_l] * base + remainder[shift + b_l - 1]) / divisorMostSignificantDigit); + } + // quotientDigit <= base - 1 + carry = 0; + borrow = 0; + l = divisor.length; + for (i = 0; i < l; i++) { + carry += quotientDigit * divisor[i]; + q = Math.floor(carry / base); + borrow += remainder[shift + i] - (carry - q * base); + carry = q; + if (borrow < 0) { + remainder[shift + i] = borrow + base; + borrow = -1; + } else { + remainder[shift + i] = borrow; + borrow = 0; + } + } + while (borrow !== 0) { + quotientDigit -= 1; + carry = 0; + for (i = 0; i < l; i++) { + carry += remainder[shift + i] - base + divisor[i]; + if (carry < 0) { + remainder[shift + i] = carry + base; + carry = 0; + } else { + remainder[shift + i] = carry; + carry = 1; + } + } + borrow += carry; + } + result[shift] = quotientDigit; + } + // denormalization + remainder = divModSmall(remainder, lambda)[0]; + return [arrayToSmall(result), arrayToSmall(remainder)]; + } + + function divMod2(a, b) { // Implementation idea shamelessly stolen from Silent Matt's library http://silentmatt.com/biginteger/ + // Performs faster than divMod1 on larger input sizes. + var a_l = a.length, + b_l = b.length, + result = [], + part = [], + base = BASE, + guess, xlen, highx, highy, check; + while (a_l) { + part.unshift(a[--a_l]); + trim(part); + if (compareAbs(part, b) < 0) { + result.push(0); + continue; + } + xlen = part.length; + highx = part[xlen - 1] * base + part[xlen - 2]; + highy = b[b_l - 1] * base + b[b_l - 2]; + if (xlen > b_l) { + highx = (highx + 1) * base; + } + guess = Math.ceil(highx / highy); + do { + check = multiplySmall(b, guess); + if (compareAbs(check, part) <= 0) break; + guess--; + } while (guess); + result.push(guess); + part = subtract(part, check); + } + result.reverse(); + return [arrayToSmall(result), arrayToSmall(part)]; + } + + function divModSmall(value, lambda) { + var length = value.length, + quotient = createArray(length), + base = BASE, + i, q, remainder, divisor; + remainder = 0; + for (i = length - 1; i >= 0; --i) { + divisor = remainder * base + value[i]; + q = truncate(divisor / lambda); + remainder = divisor - q * lambda; + quotient[i] = q | 0; + } + return [quotient, remainder | 0]; + } + + function divModAny(self, v) { + var value, n = parseValue(v); + if (supportsNativeBigInt) { + return [new NativeBigInt(self.value / n.value), new NativeBigInt(self.value % n.value)]; + } + var a = self.value, b = n.value; + var quotient; + if (b === 0) throw new Error("Cannot divide by zero"); + if (self.isSmall) { + if (n.isSmall) { + return [new SmallInteger(truncate(a / b)), new SmallInteger(a % b)]; + } + return [Integer[0], self]; + } + if (n.isSmall) { + if (b === 1) return [self, Integer[0]]; + if (b == -1) return [self.negate(), Integer[0]]; + var abs = Math.abs(b); + if (abs < BASE) { + value = divModSmall(a, abs); + quotient = arrayToSmall(value[0]); + var remainder = value[1]; + if (self.sign) remainder = -remainder; + if (typeof quotient === "number") { + if (self.sign !== n.sign) quotient = -quotient; + return [new SmallInteger(quotient), new SmallInteger(remainder)]; + } + return [new BigInteger(quotient, self.sign !== n.sign), new SmallInteger(remainder)]; + } + b = smallToArray(abs); + } + var comparison = compareAbs(a, b); + if (comparison === -1) return [Integer[0], self]; + if (comparison === 0) return [Integer[self.sign === n.sign ? 1 : -1], Integer[0]]; + + // divMod1 is faster on smaller input sizes + if (a.length + b.length <= 200) + value = divMod1(a, b); + else value = divMod2(a, b); + + quotient = value[0]; + var qSign = self.sign !== n.sign, + mod = value[1], + mSign = self.sign; + if (typeof quotient === "number") { + if (qSign) quotient = -quotient; + quotient = new SmallInteger(quotient); + } else quotient = new BigInteger(quotient, qSign); + if (typeof mod === "number") { + if (mSign) mod = -mod; + mod = new SmallInteger(mod); + } else mod = new BigInteger(mod, mSign); + return [quotient, mod]; + } + + BigInteger.prototype.divmod = function (v) { + var result = divModAny(this, v); + return { + quotient: result[0], + remainder: result[1] + }; + }; + NativeBigInt.prototype.divmod = SmallInteger.prototype.divmod = BigInteger.prototype.divmod; + + + BigInteger.prototype.divide = function (v) { + return divModAny(this, v)[0]; + }; + NativeBigInt.prototype.over = NativeBigInt.prototype.divide = function (v) { + return new NativeBigInt(this.value / parseValue(v).value); + }; + SmallInteger.prototype.over = SmallInteger.prototype.divide = BigInteger.prototype.over = BigInteger.prototype.divide; + + BigInteger.prototype.mod = function (v) { + return divModAny(this, v)[1]; + }; + NativeBigInt.prototype.mod = NativeBigInt.prototype.remainder = function (v) { + return new NativeBigInt(this.value % parseValue(v).value); + }; + SmallInteger.prototype.remainder = SmallInteger.prototype.mod = BigInteger.prototype.remainder = BigInteger.prototype.mod; + + BigInteger.prototype.pow = function (v) { + var n = parseValue(v), + a = this.value, + b = n.value, + value, x, y; + if (b === 0) return Integer[1]; + if (a === 0) return Integer[0]; + if (a === 1) return Integer[1]; + if (a === -1) return n.isEven() ? Integer[1] : Integer[-1]; + if (n.sign) { + return Integer[0]; + } + if (!n.isSmall) throw new Error("The exponent " + n.toString() + " is too large."); + if (this.isSmall) { + if (isPrecise(value = Math.pow(a, b))) + return new SmallInteger(truncate(value)); + } + x = this; + y = Integer[1]; + while (true) { + if (b & 1 === 1) { + y = y.times(x); + --b; + } + if (b === 0) break; + b /= 2; + x = x.square(); + } + return y; + }; + SmallInteger.prototype.pow = BigInteger.prototype.pow; + + NativeBigInt.prototype.pow = function (v) { + var n = parseValue(v); + var a = this.value, b = n.value; + var _0 = BigInt(0), _1 = BigInt(1), _2 = BigInt(2); + if (b === _0) return Integer[1]; + if (a === _0) return Integer[0]; + if (a === _1) return Integer[1]; + if (a === BigInt(-1)) return n.isEven() ? Integer[1] : Integer[-1]; + if (n.isNegative()) return new NativeBigInt(_0); + var x = this; + var y = Integer[1]; + while (true) { + if ((b & _1) === _1) { + y = y.times(x); + --b; + } + if (b === _0) break; + b /= _2; + x = x.square(); + } + return y; + }; + + BigInteger.prototype.modPow = function (exp, mod) { + exp = parseValue(exp); + mod = parseValue(mod); + if (mod.isZero()) throw new Error("Cannot take modPow with modulus 0"); + var r = Integer[1], + base = this.mod(mod); + if (exp.isNegative()) { + exp = exp.multiply(Integer[-1]); + base = base.modInv(mod); + } + while (exp.isPositive()) { + if (base.isZero()) return Integer[0]; + if (exp.isOdd()) r = r.multiply(base).mod(mod); + exp = exp.divide(2); + base = base.square().mod(mod); + } + return r; + }; + NativeBigInt.prototype.modPow = SmallInteger.prototype.modPow = BigInteger.prototype.modPow; + + function compareAbs(a, b) { + if (a.length !== b.length) { + return a.length > b.length ? 1 : -1; + } + for (var i = a.length - 1; i >= 0; i--) { + if (a[i] !== b[i]) return a[i] > b[i] ? 1 : -1; + } + return 0; + } + + BigInteger.prototype.compareAbs = function (v) { + var n = parseValue(v), + a = this.value, + b = n.value; + if (n.isSmall) return 1; + return compareAbs(a, b); + }; + SmallInteger.prototype.compareAbs = function (v) { + var n = parseValue(v), + a = Math.abs(this.value), + b = n.value; + if (n.isSmall) { + b = Math.abs(b); + return a === b ? 0 : a > b ? 1 : -1; + } + return -1; + }; + NativeBigInt.prototype.compareAbs = function (v) { + var a = this.value; + var b = parseValue(v).value; + a = a >= 0 ? a : -a; + b = b >= 0 ? b : -b; + return a === b ? 0 : a > b ? 1 : -1; + }; + + BigInteger.prototype.compare = function (v) { + // See discussion about comparison with Infinity: + // https://github.com/peterolson/BigInteger.js/issues/61 + if (v === Infinity) { + return -1; + } + if (v === -Infinity) { + return 1; + } + + var n = parseValue(v), + a = this.value, + b = n.value; + if (this.sign !== n.sign) { + return n.sign ? 1 : -1; + } + if (n.isSmall) { + return this.sign ? -1 : 1; + } + return compareAbs(a, b) * (this.sign ? -1 : 1); + }; + BigInteger.prototype.compareTo = BigInteger.prototype.compare; + + SmallInteger.prototype.compare = function (v) { + if (v === Infinity) { + return -1; + } + if (v === -Infinity) { + return 1; + } + + var n = parseValue(v), + a = this.value, + b = n.value; + if (n.isSmall) { + return a == b ? 0 : a > b ? 1 : -1; + } + if (a < 0 !== n.sign) { + return a < 0 ? -1 : 1; + } + return a < 0 ? 1 : -1; + }; + SmallInteger.prototype.compareTo = SmallInteger.prototype.compare; + + NativeBigInt.prototype.compare = function (v) { + if (v === Infinity) { + return -1; + } + if (v === -Infinity) { + return 1; + } + var a = this.value; + var b = parseValue(v).value; + return a === b ? 0 : a > b ? 1 : -1; + }; + NativeBigInt.prototype.compareTo = NativeBigInt.prototype.compare; + + BigInteger.prototype.equals = function (v) { + return this.compare(v) === 0; + }; + NativeBigInt.prototype.eq = NativeBigInt.prototype.equals = SmallInteger.prototype.eq = SmallInteger.prototype.equals = BigInteger.prototype.eq = BigInteger.prototype.equals; + + BigInteger.prototype.notEquals = function (v) { + return this.compare(v) !== 0; + }; + NativeBigInt.prototype.neq = NativeBigInt.prototype.notEquals = SmallInteger.prototype.neq = SmallInteger.prototype.notEquals = BigInteger.prototype.neq = BigInteger.prototype.notEquals; + + BigInteger.prototype.greater = function (v) { + return this.compare(v) > 0; + }; + NativeBigInt.prototype.gt = NativeBigInt.prototype.greater = SmallInteger.prototype.gt = SmallInteger.prototype.greater = BigInteger.prototype.gt = BigInteger.prototype.greater; + + BigInteger.prototype.lesser = function (v) { + return this.compare(v) < 0; + }; + NativeBigInt.prototype.lt = NativeBigInt.prototype.lesser = SmallInteger.prototype.lt = SmallInteger.prototype.lesser = BigInteger.prototype.lt = BigInteger.prototype.lesser; + + BigInteger.prototype.greaterOrEquals = function (v) { + return this.compare(v) >= 0; + }; + NativeBigInt.prototype.geq = NativeBigInt.prototype.greaterOrEquals = SmallInteger.prototype.geq = SmallInteger.prototype.greaterOrEquals = BigInteger.prototype.geq = BigInteger.prototype.greaterOrEquals; + + BigInteger.prototype.lesserOrEquals = function (v) { + return this.compare(v) <= 0; + }; + NativeBigInt.prototype.leq = NativeBigInt.prototype.lesserOrEquals = SmallInteger.prototype.leq = SmallInteger.prototype.lesserOrEquals = BigInteger.prototype.leq = BigInteger.prototype.lesserOrEquals; + + BigInteger.prototype.isEven = function () { + return (this.value[0] & 1) === 0; + }; + SmallInteger.prototype.isEven = function () { + return (this.value & 1) === 0; + }; + NativeBigInt.prototype.isEven = function () { + return (this.value & BigInt(1)) === BigInt(0); + }; + + BigInteger.prototype.isOdd = function () { + return (this.value[0] & 1) === 1; + }; + SmallInteger.prototype.isOdd = function () { + return (this.value & 1) === 1; + }; + NativeBigInt.prototype.isOdd = function () { + return (this.value & BigInt(1)) === BigInt(1); + }; + + BigInteger.prototype.isPositive = function () { + return !this.sign; + }; + SmallInteger.prototype.isPositive = function () { + return this.value > 0; + }; + NativeBigInt.prototype.isPositive = SmallInteger.prototype.isPositive; + + BigInteger.prototype.isNegative = function () { + return this.sign; + }; + SmallInteger.prototype.isNegative = function () { + return this.value < 0; + }; + NativeBigInt.prototype.isNegative = SmallInteger.prototype.isNegative; + + BigInteger.prototype.isUnit = function () { + return false; + }; + SmallInteger.prototype.isUnit = function () { + return Math.abs(this.value) === 1; + }; + NativeBigInt.prototype.isUnit = function () { + return this.abs().value === BigInt(1); + }; + + BigInteger.prototype.isZero = function () { + return false; + }; + SmallInteger.prototype.isZero = function () { + return this.value === 0; + }; + NativeBigInt.prototype.isZero = function () { + return this.value === BigInt(0); + }; + + BigInteger.prototype.isDivisibleBy = function (v) { + var n = parseValue(v); + if (n.isZero()) return false; + if (n.isUnit()) return true; + if (n.compareAbs(2) === 0) return this.isEven(); + return this.mod(n).isZero(); + }; + NativeBigInt.prototype.isDivisibleBy = SmallInteger.prototype.isDivisibleBy = BigInteger.prototype.isDivisibleBy; + + function isBasicPrime(v) { + var n = v.abs(); + if (n.isUnit()) return false; + if (n.equals(2) || n.equals(3) || n.equals(5)) return true; + if (n.isEven() || n.isDivisibleBy(3) || n.isDivisibleBy(5)) return false; + if (n.lesser(49)) return true; + // we don't know if it's prime: let the other functions figure it out + } + + function millerRabinTest(n, a) { + var nPrev = n.prev(), + b = nPrev, + r = 0, + d, i, x; + while (b.isEven()) b = b.divide(2), r++; + next: for (i = 0; i < a.length; i++) { + if (n.lesser(a[i])) continue; + x = bigInt(a[i]).modPow(b, n); + if (x.isUnit() || x.equals(nPrev)) continue; + for (d = r - 1; d != 0; d--) { + x = x.square().mod(n); + if (x.isUnit()) return false; + if (x.equals(nPrev)) continue next; + } + return false; + } + return true; + } + + // Set "strict" to true to force GRH-supported lower bound of 2*log(N)^2 + BigInteger.prototype.isPrime = function (strict) { + var isPrime = isBasicPrime(this); + if (isPrime !== undefined$1) return isPrime; + var n = this.abs(); + var bits = n.bitLength(); + if (bits <= 64) + return millerRabinTest(n, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]); + var logN = Math.log(2) * bits.toJSNumber(); + var t = Math.ceil((strict === true) ? (2 * Math.pow(logN, 2)) : logN); + for (var a = [], i = 0; i < t; i++) { + a.push(bigInt(i + 2)); + } + return millerRabinTest(n, a); + }; + NativeBigInt.prototype.isPrime = SmallInteger.prototype.isPrime = BigInteger.prototype.isPrime; + + BigInteger.prototype.isProbablePrime = function (iterations, rng) { + var isPrime = isBasicPrime(this); + if (isPrime !== undefined$1) return isPrime; + var n = this.abs(); + var t = iterations === undefined$1 ? 5 : iterations; + for (var a = [], i = 0; i < t; i++) { + a.push(bigInt.randBetween(2, n.minus(2), rng)); + } + return millerRabinTest(n, a); + }; + NativeBigInt.prototype.isProbablePrime = SmallInteger.prototype.isProbablePrime = BigInteger.prototype.isProbablePrime; + + BigInteger.prototype.modInv = function (n) { + var t = bigInt.zero, newT = bigInt.one, r = parseValue(n), newR = this.abs(), q, lastT, lastR; + while (!newR.isZero()) { + q = r.divide(newR); + lastT = t; + lastR = r; + t = newT; + r = newR; + newT = lastT.subtract(q.multiply(newT)); + newR = lastR.subtract(q.multiply(newR)); + } + if (!r.isUnit()) throw new Error(this.toString() + " and " + n.toString() + " are not co-prime"); + if (t.compare(0) === -1) { + t = t.add(n); + } + if (this.isNegative()) { + return t.negate(); + } + return t; + }; + + NativeBigInt.prototype.modInv = SmallInteger.prototype.modInv = BigInteger.prototype.modInv; + + BigInteger.prototype.next = function () { + var value = this.value; + if (this.sign) { + return subtractSmall(value, 1, this.sign); + } + return new BigInteger(addSmall(value, 1), this.sign); + }; + SmallInteger.prototype.next = function () { + var value = this.value; + if (value + 1 < MAX_INT) return new SmallInteger(value + 1); + return new BigInteger(MAX_INT_ARR, false); + }; + NativeBigInt.prototype.next = function () { + return new NativeBigInt(this.value + BigInt(1)); + }; + + BigInteger.prototype.prev = function () { + var value = this.value; + if (this.sign) { + return new BigInteger(addSmall(value, 1), true); + } + return subtractSmall(value, 1, this.sign); + }; + SmallInteger.prototype.prev = function () { + var value = this.value; + if (value - 1 > -MAX_INT) return new SmallInteger(value - 1); + return new BigInteger(MAX_INT_ARR, true); + }; + NativeBigInt.prototype.prev = function () { + return new NativeBigInt(this.value - BigInt(1)); + }; + + var powersOfTwo = [1]; + while (2 * powersOfTwo[powersOfTwo.length - 1] <= BASE) powersOfTwo.push(2 * powersOfTwo[powersOfTwo.length - 1]); + var powers2Length = powersOfTwo.length, highestPower2 = powersOfTwo[powers2Length - 1]; + + function shift_isSmall(n) { + return Math.abs(n) <= BASE; + } + + BigInteger.prototype.shiftLeft = function (v) { + var n = parseValue(v).toJSNumber(); + if (!shift_isSmall(n)) { + throw new Error(String(n) + " is too large for shifting."); + } + if (n < 0) return this.shiftRight(-n); + var result = this; + if (result.isZero()) return result; + while (n >= powers2Length) { + result = result.multiply(highestPower2); + n -= powers2Length - 1; + } + return result.multiply(powersOfTwo[n]); + }; + NativeBigInt.prototype.shiftLeft = SmallInteger.prototype.shiftLeft = BigInteger.prototype.shiftLeft; + + BigInteger.prototype.shiftRight = function (v) { + var remQuo; + var n = parseValue(v).toJSNumber(); + if (!shift_isSmall(n)) { + throw new Error(String(n) + " is too large for shifting."); + } + if (n < 0) return this.shiftLeft(-n); + var result = this; + while (n >= powers2Length) { + if (result.isZero() || (result.isNegative() && result.isUnit())) return result; + remQuo = divModAny(result, highestPower2); + result = remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0]; + n -= powers2Length - 1; + } + remQuo = divModAny(result, powersOfTwo[n]); + return remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0]; + }; + NativeBigInt.prototype.shiftRight = SmallInteger.prototype.shiftRight = BigInteger.prototype.shiftRight; + + function bitwise(x, y, fn) { + y = parseValue(y); + var xSign = x.isNegative(), ySign = y.isNegative(); + var xRem = xSign ? x.not() : x, + yRem = ySign ? y.not() : y; + var xDigit = 0, yDigit = 0; + var xDivMod = null, yDivMod = null; + var result = []; + while (!xRem.isZero() || !yRem.isZero()) { + xDivMod = divModAny(xRem, highestPower2); + xDigit = xDivMod[1].toJSNumber(); + if (xSign) { + xDigit = highestPower2 - 1 - xDigit; // two's complement for negative numbers + } + + yDivMod = divModAny(yRem, highestPower2); + yDigit = yDivMod[1].toJSNumber(); + if (ySign) { + yDigit = highestPower2 - 1 - yDigit; // two's complement for negative numbers + } + + xRem = xDivMod[0]; + yRem = yDivMod[0]; + result.push(fn(xDigit, yDigit)); + } + var sum = fn(xSign ? 1 : 0, ySign ? 1 : 0) !== 0 ? bigInt(-1) : bigInt(0); + for (var i = result.length - 1; i >= 0; i -= 1) { + sum = sum.multiply(highestPower2).add(bigInt(result[i])); + } + return sum; + } + + BigInteger.prototype.not = function () { + return this.negate().prev(); + }; + NativeBigInt.prototype.not = SmallInteger.prototype.not = BigInteger.prototype.not; + + BigInteger.prototype.and = function (n) { + return bitwise(this, n, function (a, b) { return a & b; }); + }; + NativeBigInt.prototype.and = SmallInteger.prototype.and = BigInteger.prototype.and; + + BigInteger.prototype.or = function (n) { + return bitwise(this, n, function (a, b) { return a | b; }); + }; + NativeBigInt.prototype.or = SmallInteger.prototype.or = BigInteger.prototype.or; + + BigInteger.prototype.xor = function (n) { + return bitwise(this, n, function (a, b) { return a ^ b; }); + }; + NativeBigInt.prototype.xor = SmallInteger.prototype.xor = BigInteger.prototype.xor; + + var LOBMASK_I = 1 << 30, LOBMASK_BI = (BASE & -BASE) * (BASE & -BASE) | LOBMASK_I; + function roughLOB(n) { // get lowestOneBit (rough) + // SmallInteger: return Min(lowestOneBit(n), 1 << 30) + // BigInteger: return Min(lowestOneBit(n), 1 << 14) [BASE=1e7] + var v = n.value, + x = typeof v === "number" ? v | LOBMASK_I : + typeof v === "bigint" ? v | BigInt(LOBMASK_I) : + v[0] + v[1] * BASE | LOBMASK_BI; + return x & -x; + } + + function integerLogarithm(value, base) { + if (base.compareTo(value) <= 0) { + var tmp = integerLogarithm(value, base.square(base)); + var p = tmp.p; + var e = tmp.e; + var t = p.multiply(base); + return t.compareTo(value) <= 0 ? { p: t, e: e * 2 + 1 } : { p: p, e: e * 2 }; + } + return { p: bigInt(1), e: 0 }; + } + + BigInteger.prototype.bitLength = function () { + var n = this; + if (n.compareTo(bigInt(0)) < 0) { + n = n.negate().subtract(bigInt(1)); + } + if (n.compareTo(bigInt(0)) === 0) { + return bigInt(0); + } + return bigInt(integerLogarithm(n, bigInt(2)).e).add(bigInt(1)); + }; + NativeBigInt.prototype.bitLength = SmallInteger.prototype.bitLength = BigInteger.prototype.bitLength; + + function max(a, b) { + a = parseValue(a); + b = parseValue(b); + return a.greater(b) ? a : b; + } + function min(a, b) { + a = parseValue(a); + b = parseValue(b); + return a.lesser(b) ? a : b; + } + function gcd(a, b) { + a = parseValue(a).abs(); + b = parseValue(b).abs(); + if (a.equals(b)) return a; + if (a.isZero()) return b; + if (b.isZero()) return a; + var c = Integer[1], d, t; + while (a.isEven() && b.isEven()) { + d = min(roughLOB(a), roughLOB(b)); + a = a.divide(d); + b = b.divide(d); + c = c.multiply(d); + } + while (a.isEven()) { + a = a.divide(roughLOB(a)); + } + do { + while (b.isEven()) { + b = b.divide(roughLOB(b)); + } + if (a.greater(b)) { + t = b; b = a; a = t; + } + b = b.subtract(a); + } while (!b.isZero()); + return c.isUnit() ? a : a.multiply(c); + } + function lcm(a, b) { + a = parseValue(a).abs(); + b = parseValue(b).abs(); + return a.divide(gcd(a, b)).multiply(b); + } + function randBetween(a, b, rng) { + a = parseValue(a); + b = parseValue(b); + var usedRNG = rng || Math.random; + var low = min(a, b), high = max(a, b); + var range = high.subtract(low).add(1); + if (range.isSmall) return low.add(Math.floor(usedRNG() * range)); + var digits = toBase(range, BASE).value; + var result = [], restricted = true; + for (var i = 0; i < digits.length; i++) { + var top = restricted ? digits[i] + (i + 1 < digits.length ? digits[i + 1] / BASE : 0) : BASE; + var digit = truncate(usedRNG() * top); + result.push(digit); + if (digit < digits[i]) restricted = false; + } + return low.add(Integer.fromArray(result, BASE, false)); + } + + var parseBase = function (text, base, alphabet, caseSensitive) { + alphabet = alphabet || DEFAULT_ALPHABET; + text = String(text); + if (!caseSensitive) { + text = text.toLowerCase(); + alphabet = alphabet.toLowerCase(); + } + var length = text.length; + var i; + var absBase = Math.abs(base); + var alphabetValues = {}; + for (i = 0; i < alphabet.length; i++) { + alphabetValues[alphabet[i]] = i; + } + for (i = 0; i < length; i++) { + var c = text[i]; + if (c === "-") continue; + if (c in alphabetValues) { + if (alphabetValues[c] >= absBase) { + if (c === "1" && absBase === 1) continue; + throw new Error(c + " is not a valid digit in base " + base + "."); + } + } + } + base = parseValue(base); + var digits = []; + var isNegative = text[0] === "-"; + for (i = isNegative ? 1 : 0; i < text.length; i++) { + var c = text[i]; + if (c in alphabetValues) digits.push(parseValue(alphabetValues[c])); + else if (c === "<") { + var start = i; + do { i++; } while (text[i] !== ">" && i < text.length); + digits.push(parseValue(text.slice(start + 1, i))); + } + else throw new Error(c + " is not a valid character"); + } + return parseBaseFromArray(digits, base, isNegative); + }; + + function parseBaseFromArray(digits, base, isNegative) { + var val = Integer[0], pow = Integer[1], i; + for (i = digits.length - 1; i >= 0; i--) { + val = val.add(digits[i].times(pow)); + pow = pow.times(base); + } + return isNegative ? val.negate() : val; + } + + function stringify(digit, alphabet) { + alphabet = alphabet || DEFAULT_ALPHABET; + if (digit < alphabet.length) { + return alphabet[digit]; + } + return "<" + digit + ">"; + } + + function toBase(n, base) { + base = bigInt(base); + if (base.isZero()) { + if (n.isZero()) return { value: [0], isNegative: false }; + throw new Error("Cannot convert nonzero numbers to base 0."); + } + if (base.equals(-1)) { + if (n.isZero()) return { value: [0], isNegative: false }; + if (n.isNegative()) + return { + value: [].concat.apply([], Array.apply(null, Array(-n.toJSNumber())) + .map(Array.prototype.valueOf, [1, 0]) + ), + isNegative: false + }; + + var arr = Array.apply(null, Array(n.toJSNumber() - 1)) + .map(Array.prototype.valueOf, [0, 1]); + arr.unshift([1]); + return { + value: [].concat.apply([], arr), + isNegative: false + }; + } + + var neg = false; + if (n.isNegative() && base.isPositive()) { + neg = true; + n = n.abs(); + } + if (base.isUnit()) { + if (n.isZero()) return { value: [0], isNegative: false }; + + return { + value: Array.apply(null, Array(n.toJSNumber())) + .map(Number.prototype.valueOf, 1), + isNegative: neg + }; + } + var out = []; + var left = n, divmod; + while (left.isNegative() || left.compareAbs(base) >= 0) { + divmod = left.divmod(base); + left = divmod.quotient; + var digit = divmod.remainder; + if (digit.isNegative()) { + digit = base.minus(digit).abs(); + left = left.next(); + } + out.push(digit.toJSNumber()); + } + out.push(left.toJSNumber()); + return { value: out.reverse(), isNegative: neg }; + } + + function toBaseString(n, base, alphabet) { + var arr = toBase(n, base); + return (arr.isNegative ? "-" : "") + arr.value.map(function (x) { + return stringify(x, alphabet); + }).join(''); + } + + BigInteger.prototype.toArray = function (radix) { + return toBase(this, radix); + }; + + SmallInteger.prototype.toArray = function (radix) { + return toBase(this, radix); + }; + + NativeBigInt.prototype.toArray = function (radix) { + return toBase(this, radix); + }; + + BigInteger.prototype.toString = function (radix, alphabet) { + if (radix === undefined$1) radix = 10; + if (radix !== 10 || alphabet) return toBaseString(this, radix, alphabet); + var v = this.value, l = v.length, str = String(v[--l]), zeros = "0000000", digit; + while (--l >= 0) { + digit = String(v[l]); + str += zeros.slice(digit.length) + digit; + } + var sign = this.sign ? "-" : ""; + return sign + str; + }; + + SmallInteger.prototype.toString = function (radix, alphabet) { + if (radix === undefined$1) radix = 10; + if (radix != 10 || alphabet) return toBaseString(this, radix, alphabet); + return String(this.value); + }; + + NativeBigInt.prototype.toString = SmallInteger.prototype.toString; + + NativeBigInt.prototype.toJSON = BigInteger.prototype.toJSON = SmallInteger.prototype.toJSON = function () { return this.toString(); }; + + BigInteger.prototype.valueOf = function () { + return parseInt(this.toString(), 10); + }; + BigInteger.prototype.toJSNumber = BigInteger.prototype.valueOf; + + SmallInteger.prototype.valueOf = function () { + return this.value; + }; + SmallInteger.prototype.toJSNumber = SmallInteger.prototype.valueOf; + NativeBigInt.prototype.valueOf = NativeBigInt.prototype.toJSNumber = function () { + return parseInt(this.toString(), 10); + }; + + function parseStringValue(v) { + if (isPrecise(+v)) { + var x = +v; + if (x === truncate(x)) + return supportsNativeBigInt ? new NativeBigInt(BigInt(x)) : new SmallInteger(x); + throw new Error("Invalid integer: " + v); + } + var sign = v[0] === "-"; + if (sign) v = v.slice(1); + var split = v.split(/e/i); + if (split.length > 2) throw new Error("Invalid integer: " + split.join("e")); + if (split.length === 2) { + var exp = split[1]; + if (exp[0] === "+") exp = exp.slice(1); + exp = +exp; + if (exp !== truncate(exp) || !isPrecise(exp)) throw new Error("Invalid integer: " + exp + " is not a valid exponent."); + var text = split[0]; + var decimalPlace = text.indexOf("."); + if (decimalPlace >= 0) { + exp -= text.length - decimalPlace - 1; + text = text.slice(0, decimalPlace) + text.slice(decimalPlace + 1); + } + if (exp < 0) throw new Error("Cannot include negative exponent part for integers"); + text += (new Array(exp + 1)).join("0"); + v = text; + } + var isValid = /^([0-9][0-9]*)$/.test(v); + if (!isValid) throw new Error("Invalid integer: " + v); + if (supportsNativeBigInt) { + return new NativeBigInt(BigInt(sign ? "-" + v : v)); + } + var r = [], max = v.length, l = LOG_BASE, min = max - l; + while (max > 0) { + r.push(+v.slice(min, max)); + min -= l; + if (min < 0) min = 0; + max -= l; + } + trim(r); + return new BigInteger(r, sign); + } + + function parseNumberValue(v) { + if (supportsNativeBigInt) { + return new NativeBigInt(BigInt(v)); + } + if (isPrecise(v)) { + if (v !== truncate(v)) throw new Error(v + " is not an integer."); + return new SmallInteger(v); + } + return parseStringValue(v.toString()); + } + + function parseValue(v) { + if (typeof v === "number") { + return parseNumberValue(v); + } + if (typeof v === "string") { + return parseStringValue(v); + } + if (typeof v === "bigint") { + return new NativeBigInt(v); + } + return v; + } + // Pre-define numbers in range [-999,999] + for (var i = 0; i < 1000; i++) { + Integer[i] = parseValue(i); + if (i > 0) Integer[-i] = parseValue(-i); + } + // Backwards compatibility + Integer.one = Integer[1]; + Integer.zero = Integer[0]; + Integer.minusOne = Integer[-1]; + Integer.max = max; + Integer.min = min; + Integer.gcd = gcd; + Integer.lcm = lcm; + Integer.isInstance = function (x) { return x instanceof BigInteger || x instanceof SmallInteger || x instanceof NativeBigInt; }; + Integer.randBetween = randBetween; + + Integer.fromArray = function (digits, base, isNegative) { + return parseBaseFromArray(digits.map(parseValue), parseValue(base || 10), isNegative); + }; + + return Integer; + })(); + + // Node.js check + if (module.hasOwnProperty("exports")) { + module.exports = bigInt; + } +} (BigInteger$1)); + +var BigIntegerExports$1 = BigInteger$1.exports; +var bigInt$e = /*@__PURE__*/getDefaultExportFromCjs(BigIntegerExports$1); + +function fromString$1(s, radix) { + if (typeof s == "string") { + if (s.slice(0,2) == "0x") { + return bigInt$e(s.slice(2), 16); + } else { + return bigInt$e(s,radix); + } + } else { + return bigInt$e(s, radix); + } +} + +const e$1 = fromString$1; + +function fromArray$1(a, radix) { + return bigInt$e.fromArray(a, radix); +} + +function bitLength$1(a) { + return bigInt$e(a).bitLength(); +} + +function isNegative$1(a) { + return bigInt$e(a).isNegative(); +} + +function isZero$1(a) { + return bigInt$e(a).isZero(); +} + +function shiftLeft$1(a, n) { + return bigInt$e(a).shiftLeft(n); +} + +function shiftRight$1(a, n) { + return bigInt$e(a).shiftRight(n); +} + +const shl$1 = shiftLeft$1; +const shr$1 = shiftRight$1; + +function isOdd$1(a) { + return bigInt$e(a).isOdd(); +} + + +function naf$1(n) { + let E = bigInt$e(n); + const res = []; + while (E.gt(bigInt$e.zero)) { + if (E.isOdd()) { + const z = 2 - E.mod(4).toJSNumber(); + res.push( z ); + E = E.minus(z); + } else { + res.push( 0 ); + } + E = E.shiftRight(1); + } + return res; +} + +function bits$1(n) { + let E = bigInt$e(n); + const res = []; + while (E.gt(bigInt$e.zero)) { + if (E.isOdd()) { + res.push(1); + } else { + res.push( 0 ); + } + E = E.shiftRight(1); + } + return res; +} + +function toNumber$2(s) { + if (!s.lt(bigInt$e("9007199254740992", 10))) { + throw new Error("Number too big"); + } + return s.toJSNumber(); +} + +function toArray$1(s, radix) { + return bigInt$e(s).toArray(radix); +} + +function add$1(a, b) { + return bigInt$e(a).add(bigInt$e(b)); +} + +function sub$1(a, b) { + return bigInt$e(a).minus(bigInt$e(b)); +} + +function neg$1(a) { + return bigInt$e.zero.minus(bigInt$e(a)); +} + +function mul$1(a, b) { + return bigInt$e(a).times(bigInt$e(b)); +} + +function square$1(a) { + return bigInt$e(a).square(); +} + +function pow$1(a, b) { + return bigInt$e(a).pow(bigInt$e(b)); +} + +function exp$1(a, b) { + return bigInt$e(a).pow(bigInt$e(b)); +} + +function abs$1(a) { + return bigInt$e(a).abs(); +} + +function div$1(a, b) { + return bigInt$e(a).divide(bigInt$e(b)); +} + +function mod$1(a, b) { + return bigInt$e(a).mod(bigInt$e(b)); +} + +function eq$1(a, b) { + return bigInt$e(a).eq(bigInt$e(b)); +} + +function neq$1(a, b) { + return bigInt$e(a).neq(bigInt$e(b)); +} + +function lt$1(a, b) { + return bigInt$e(a).lt(bigInt$e(b)); +} + +function gt$1(a, b) { + return bigInt$e(a).gt(bigInt$e(b)); +} + +function leq$1(a, b) { + return bigInt$e(a).leq(bigInt$e(b)); +} + +function geq$1(a, b) { + return bigInt$e(a).geq(bigInt$e(b)); +} + +function band$1(a, b) { + return bigInt$e(a).and(bigInt$e(b)); +} + +function bor$1(a, b) { + return bigInt$e(a).or(bigInt$e(b)); +} + +function bxor$1(a, b) { + return bigInt$e(a).xor(bigInt$e(b)); +} + +function land$1(a, b) { + return (!bigInt$e(a).isZero()) && (!bigInt$e(b).isZero()); +} + +function lor$1(a, b) { + return (!bigInt$e(a).isZero()) || (!bigInt$e(b).isZero()); +} + +function lnot$1(a) { + return bigInt$e(a).isZero(); +} + +var Scalar_bigint = /*#__PURE__*/Object.freeze({ + __proto__: null, + abs: abs$1, + add: add$1, + band: band$1, + bitLength: bitLength$1, + bits: bits$1, + bor: bor$1, + bxor: bxor$1, + div: div$1, + e: e$1, + eq: eq$1, + exp: exp$1, + fromArray: fromArray$1, + fromString: fromString$1, + geq: geq$1, + gt: gt$1, + isNegative: isNegative$1, + isOdd: isOdd$1, + isZero: isZero$1, + land: land$1, + leq: leq$1, + lnot: lnot$1, + lor: lor$1, + lt: lt$1, + mod: mod$1, + mul: mul$1, + naf: naf$1, + neg: neg$1, + neq: neq$1, + pow: pow$1, + shiftLeft: shiftLeft$1, + shiftRight: shiftRight$1, + shl: shl$1, + shr: shr$1, + square: square$1, + sub: sub$1, + toArray: toArray$1, + toNumber: toNumber$2 +}); + +const supportsNativeBigInt$1 = typeof BigInt === "function"; + +let Scalar$1 = {}; +if (supportsNativeBigInt$1) { + Object.assign(Scalar$1, Scalar_native); +} else { + Object.assign(Scalar$1, Scalar_bigint); +} + + +// Returns a buffer with Little Endian Representation +Scalar$1.toRprLE = function rprBE(buff, o, e, n8) { + const s = "0000000" + e.toString(16); + const v = new Uint32Array(buff.buffer, o, n8/4); + const l = (((s.length-7)*4 - 1) >> 5)+1; // Number of 32bit words; + for (let i=0; i> 5)+1; // Number of 32bit words; + for (let i=0; i a[a.length-i-1] = ch.toString(16).padStart(8,"0") ); + return Scalar$1.fromString(a.join(""), 16); +}; + +// Pases a buffer with Big Endian Representation +Scalar$1.fromRprBE = function rprLEM(buff, o, n8) { + n8 = n8 || buff.byteLength; + o = o || 0; + const v = new DataView(buff.buffer, buff.byteOffset + o, n8); + const a = new Array(n8/4); + for (let i=0; i>> 0; + st[d] = (st[d] ^ st[a]) >>> 0; + st[d] = ((st[d] << 16) | ((st[d]>>>16) & 0xFFFF)) >>> 0; + + st[c] = (st[c] + st[d]) >>> 0; + st[b] = (st[b] ^ st[c]) >>> 0; + st[b] = ((st[b] << 12) | ((st[b]>>>20) & 0xFFF)) >>> 0; + + st[a] = (st[a] + st[b]) >>> 0; + st[d] = (st[d] ^ st[a]) >>> 0; + st[d] = ((st[d] << 8) | ((st[d]>>>24) & 0xFF)) >>> 0; + + st[c] = (st[c] + st[d]) >>> 0; + st[b] = (st[b] ^ st[c]) >>> 0; + st[b] = ((st[b] << 7) | ((st[b]>>>25) & 0x7F)) >>> 0; +} + +function doubleRound(st) { + quarterRound(st, 0, 4, 8,12); + quarterRound(st, 1, 5, 9,13); + quarterRound(st, 2, 6,10,14); + quarterRound(st, 3, 7,11,15); + + quarterRound(st, 0, 5,10,15); + quarterRound(st, 1, 6,11,12); + quarterRound(st, 2, 7, 8,13); + quarterRound(st, 3, 4, 9,14); +} + +class ChaCha { + + constructor(seed) { + seed = seed || [0,0,0,0,0,0,0,0]; + this.state = [ + 0x61707865, + 0x3320646E, + 0x79622D32, + 0x6B206574, + seed[0], + seed[1], + seed[2], + seed[3], + seed[4], + seed[5], + seed[6], + seed[7], + 0, + 0, + 0, + 0 + ]; + this.idx = 16; + this.buff = new Array(16); + } + + nextU32() { + if (this.idx == 16) this.update(); + return this.buff[this.idx++]; + } + + nextU64() { + return add(mul(this.nextU32(), 0x100000000), this.nextU32()); + } + + nextBool() { + return (this.nextU32() & 1) == 1; + } + + update() { + // Copy the state + for (let i=0; i<16; i++) this.buff[i] = this.state[i]; + + // Apply the rounds + for (let i=0; i<10; i++) doubleRound(this.buff); + + // Add to the initial + for (let i=0; i<16; i++) this.buff[i] = (this.buff[i] + this.state[i]) >>> 0; + + this.idx = 0; + + this.state[12] = (this.state[12] + 1) >>> 0; + if (this.state[12] != 0) return; + this.state[13] = (this.state[13] + 1) >>> 0; + if (this.state[13] != 0) return; + this.state[14] = (this.state[14] + 1) >>> 0; + if (this.state[14] != 0) return; + this.state[15] = (this.state[15] + 1) >>> 0; + } +} + +function getRandomBytes(n) { + let array = new Uint8Array(n); + if (process.browser) { // Browser + if (typeof globalThis.crypto !== "undefined") { // Supported + globalThis.crypto.getRandomValues(array); + } else { // fallback + for (let i=0; i>>0; + } + } + } + else { // NodeJS + require$$5.randomFillSync(array); + } + return array; +} + +function getRandomSeed() { + const arr = getRandomBytes(32); + const arrV = new Uint32Array(arr.buffer); + const seed = []; + for (let i=0; i<8; i++) { + seed.push(arrV[i]); + } + return seed; +} + +let threadRng = null; + +function getThreadRng() { + if (threadRng) return threadRng; + threadRng = new ChaCha(getRandomSeed()); + return threadRng; +} + +var utils$d = {}; + +/* + Copyright 2019 0KIMS association. + + This file is part of wasmsnark (Web Assembly zkSnark Prover). + + wasmsnark is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + wasmsnark is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with wasmsnark. If not, see . +*/ + +const bigInt$d = BigIntegerExports$1; + +utils$d.bigInt2BytesLE = function bigInt2BytesLE(_a, len) { + const b = Array(len); + let v = bigInt$d(_a); + for (let i=0; i. +*/ + +const utils$c = utils$d; + +var build_int = function buildInt(module, n64, _prefix) { + + const prefix = _prefix || "int"; + if (module.modules[prefix]) return prefix; // already builded + module.modules[prefix] = {}; + + const n32 = n64*2; + const n8 = n64*8; + + module.alloc(n8, utils$c.bigInt2BytesLE(1, n8)); + + function buildCopy() { + const f = module.addFunction(prefix+"_copy"); + f.addParam("px", "i32"); + f.addParam("pr", "i32"); + + const c = f.getCodeBuilder(); + + for (let i=0; i>1) )&&(i>1, k>>1) + ) + ) + ); + + f.addCode( + c.setLocal(c1, + c.i64_add( + c.getLocal(c1), + c.i64_shr_u( + c.getLocal(c0), + c.i64_const(32) + ) + ) + ) + ); + } + + // Add the old carry + + if (k>0) { + f.addCode( + c.setLocal(c0, + c.i64_add( + c.i64_and( + c.getLocal(c0), + c.i64_const(0xFFFFFFFF) + ), + c.i64_and( + c.getLocal(c0_old), + c.i64_const(0xFFFFFFFF) + ), + ) + ) + ); + + f.addCode( + c.setLocal(c1, + c.i64_add( + c.i64_add( + c.getLocal(c1), + c.i64_shr_u( + c.getLocal(c0), + c.i64_const(32) + ) + ), + c.getLocal(c1_old) + ) + ) + ); + } + + f.addCode( + c.i64_store32( + c.getLocal("r"), + k*4, + c.getLocal(c0) + ) + ); + + f.addCode( + c.setLocal( + c0_old, + c.getLocal(c1) + ), + c.setLocal( + c1_old, + c.i64_shr_u( + c.getLocal(c0_old), + c.i64_const(32) + ) + ) + ); + + } + f.addCode( + c.i64_store32( + c.getLocal("r"), + n32*4*2-4, + c.getLocal(c0_old) + ) + ); + + } + + + function buildSquareOld() { + const f = module.addFunction(prefix+"_squareOld"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode(c.call(prefix + "_mul", c.getLocal("x"), c.getLocal("x"), c.getLocal("r"))); + } + + function _buildMul1() { + const f = module.addFunction(prefix+"__mul1"); + f.addParam("px", "i32"); + f.addParam("y", "i64"); + f.addParam("pr", "i32"); + f.addLocal("c", "i64"); + + const c = f.getCodeBuilder(); + + f.addCode(c.setLocal( + "c", + c.i64_mul( + c.i64_load32_u(c.getLocal("px"), 0, 0), + c.getLocal("y") + ) + )); + + f.addCode(c.i64_store32( + c.getLocal("pr"), + 0, + 0, + c.getLocal("c"), + )); + + for (let i=1; i3)&&(Y[eY]==0) ey--; + f.addCode(c.block(c.loop( + c.br_if( + 1, + c.i32_or( + c.i32_load8_u( + c.i32_add(Y , c.getLocal("eY")), + 0, + 0 + ), + c.i32_eq( + c.getLocal("eY"), + c.i32_const(3) + ) + ) + ), + c.setLocal("eY", c.i32_sub(c.getLocal("eY"), c.i32_const(1))), + c.br(0) + ))); + + f.addCode( + c.setLocal( + "sy", + c.i64_add( + c.i64_load32_u( + c.i32_sub( + c.i32_add( Y, c.getLocal("eY")), + c.i32_const(3) + ), + 0, + 0 + ), + c.i64_const(1) + ) + ) + ); + + // Force a divide by 0 if quotien is 0 + f.addCode( + c.if( + c.i64_eq( + c.getLocal("sy"), + c.i64_const(1) + ), + c.drop(c.i64_div_u(c.i64_const(0), c.i64_const(0))) + ) + ); + + f.addCode(c.block(c.loop( + + // while (eX>7)&&(Y[eX]==0) ex--; + c.block(c.loop( + c.br_if( + 1, + c.i32_or( + c.i32_load8_u( + c.i32_add(R , c.getLocal("eX")), + 0, + 0 + ), + c.i32_eq( + c.getLocal("eX"), + c.i32_const(7) + ) + ) + ), + c.setLocal("eX", c.i32_sub(c.getLocal("eX"), c.i32_const(1))), + c.br(0) + )), + + c.setLocal( + "sx", + c.i64_load( + c.i32_sub( + c.i32_add( R, c.getLocal("eX")), + c.i32_const(7) + ), + 0, + 0 + ) + ), + + c.setLocal( + "sx", + c.i64_div_u( + c.getLocal("sx"), + c.getLocal("sy") + ) + ), + c.setLocal( + "ec", + c.i32_sub( + c.i32_sub( + c.getLocal("eX"), + c.getLocal("eY") + ), + c.i32_const(4) + ) + ), + + // While greater than 32 bits or ec is neg, shr and inc exp + c.block(c.loop( + c.br_if( + 1, + c.i32_and( + c.i64_eqz( + c.i64_and( + c.getLocal("sx"), + c.i64_const("0xFFFFFFFF00000000") + ) + ), + c.i32_ge_s( + c.getLocal("ec"), + c.i32_const(0) + ) + ) + ), + + c.setLocal( + "sx", + c.i64_shr_u( + c.getLocal("sx"), + c.i64_const(8) + ) + ), + + c.setLocal( + "ec", + c.i32_add( + c.getLocal("ec"), + c.i32_const(1) + ) + ), + c.br(0) + )), + + c.if( + c.i64_eqz(c.getLocal("sx")), + [ + ...c.br_if( + 2, + c.i32_eqz(c.call(prefix + "_gte", R, Y)) + ), + ...c.setLocal("sx", c.i64_const(1)), + ...c.setLocal("ec", c.i32_const(0)) + ] + ), + + c.call(prefix + "__mul1", Y, c.getLocal("sx"), R2), + c.drop(c.call( + prefix + "_sub", + R, + c.i32_sub(R2, c.getLocal("ec")), + R + )), + c.call( + prefix + "__add1", + c.i32_add(C, c.getLocal("ec")), + c.getLocal("sx") + ), + c.br(0) + ))); + } + + function buildInverseMod() { + + const f = module.addFunction(prefix+"_inverseMod"); + f.addParam("px", "i32"); + f.addParam("pm", "i32"); + f.addParam("pr", "i32"); + f.addLocal("t", "i32"); + f.addLocal("newt", "i32"); + f.addLocal("r", "i32"); + f.addLocal("qq", "i32"); + f.addLocal("qr", "i32"); + f.addLocal("newr", "i32"); + f.addLocal("swp", "i32"); + f.addLocal("x", "i32"); + f.addLocal("signt", "i32"); + f.addLocal("signnewt", "i32"); + f.addLocal("signx", "i32"); + + const c = f.getCodeBuilder(); + + const aux1 = c.i32_const(module.alloc(n8)); + const aux2 = c.i32_const(module.alloc(n8)); + const aux3 = c.i32_const(module.alloc(n8)); + const aux4 = c.i32_const(module.alloc(n8)); + const aux5 = c.i32_const(module.alloc(n8)); + const aux6 = c.i32_const(module.alloc(n8)); + const mulBuff = c.i32_const(module.alloc(n8*2)); + const aux7 = c.i32_const(module.alloc(n8)); + + f.addCode( + c.setLocal("t", aux1), + c.call(prefix + "_zero", aux1), + c.setLocal("signt", c.i32_const(0)), + ); + + f.addCode( + c.setLocal("r", aux2), + c.call(prefix + "_copy", c.getLocal("pm"), aux2) + ); + + f.addCode( + c.setLocal("newt", aux3), + c.call(prefix + "_one", aux3), + c.setLocal("signnewt", c.i32_const(0)), + ); + + f.addCode( + c.setLocal("newr", aux4), + c.call(prefix + "_copy", c.getLocal("px"), aux4) + ); + + + + + f.addCode(c.setLocal("qq", aux5)); + f.addCode(c.setLocal("qr", aux6)); + f.addCode(c.setLocal("x", aux7)); + + f.addCode(c.block(c.loop( + c.br_if( + 1, + c.call(prefix + "_isZero", c.getLocal("newr") ) + ), + c.call(prefix + "_div", c.getLocal("r"), c.getLocal("newr"), c.getLocal("qq"), c.getLocal("qr")), + + c.call(prefix + "_mul", c.getLocal("qq"), c.getLocal("newt"), mulBuff), + + c.if( + c.getLocal("signt"), + c.if( + c.getLocal("signnewt"), + c.if ( + c.call(prefix + "_gte", mulBuff, c.getLocal("t")), + [ + ...c.drop(c.call(prefix + "_sub", mulBuff, c.getLocal("t"), c.getLocal("x"))), + ...c.setLocal("signx", c.i32_const(0)) + ], + [ + ...c.drop(c.call(prefix + "_sub", c.getLocal("t"), mulBuff, c.getLocal("x"))), + ...c.setLocal("signx", c.i32_const(1)) + ], + ), + [ + ...c.drop(c.call(prefix + "_add", mulBuff, c.getLocal("t"), c.getLocal("x"))), + ...c.setLocal("signx", c.i32_const(1)) + ] + ), + c.if( + c.getLocal("signnewt"), + [ + ...c.drop(c.call(prefix + "_add", mulBuff, c.getLocal("t"), c.getLocal("x"))), + ...c.setLocal("signx", c.i32_const(0)) + ], + c.if ( + c.call(prefix + "_gte", c.getLocal("t"), mulBuff), + [ + ...c.drop(c.call(prefix + "_sub", c.getLocal("t"), mulBuff, c.getLocal("x"))), + ...c.setLocal("signx", c.i32_const(0)) + ], + [ + ...c.drop(c.call(prefix + "_sub", mulBuff, c.getLocal("t"), c.getLocal("x"))), + ...c.setLocal("signx", c.i32_const(1)) + ] + ) + ) + ), + + c.setLocal("swp", c.getLocal("t")), + c.setLocal("t", c.getLocal("newt")), + c.setLocal("newt", c.getLocal("x")), + c.setLocal("x", c.getLocal("swp")), + + c.setLocal("signt", c.getLocal("signnewt")), + c.setLocal("signnewt", c.getLocal("signx")), + + c.setLocal("swp", c.getLocal("r")), + c.setLocal("r", c.getLocal("newr")), + c.setLocal("newr", c.getLocal("qr")), + c.setLocal("qr", c.getLocal("swp")), + + c.br(0) + ))); + + f.addCode(c.if( + c.getLocal("signt"), + c.drop(c.call(prefix + "_sub", c.getLocal("pm"), c.getLocal("t"), c.getLocal("pr"))), + c.call(prefix + "_copy", c.getLocal("t"), c.getLocal("pr")) + )); + } + + + buildCopy(); + buildZero(); + buildIsZero(); + buildOne(); + buildEq(); + buildGte(); + buildAdd(); + buildSub(); + buildMul(); + buildSquare(); + buildSquareOld(); + buildDiv(); + buildInverseMod(); + module.exportFunction(prefix+"_copy"); + module.exportFunction(prefix+"_zero"); + module.exportFunction(prefix+"_one"); + module.exportFunction(prefix+"_isZero"); + module.exportFunction(prefix+"_eq"); + module.exportFunction(prefix+"_gte"); + module.exportFunction(prefix+"_add"); + module.exportFunction(prefix+"_sub"); + module.exportFunction(prefix+"_mul"); + module.exportFunction(prefix+"_square"); + module.exportFunction(prefix+"_squareOld"); + module.exportFunction(prefix+"_div"); + module.exportFunction(prefix+"_inverseMod"); + + return prefix; +}; + +/* + Copyright 2019 0KIMS association. + + This file is part of wasmsnark (Web Assembly zkSnark Prover). + + wasmsnark is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + wasmsnark is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with wasmsnark. If not, see . +*/ + +var build_timesscalar = function buildTimesScalar(module, fnName, elementLen, opAB, opAA, opCopy, opInit) { + + const f = module.addFunction(fnName); + f.addParam("base", "i32"); + f.addParam("scalar", "i32"); + f.addParam("scalarLength", "i32"); + f.addParam("r", "i32"); + f.addLocal("i", "i32"); + f.addLocal("b", "i32"); + + const c = f.getCodeBuilder(); + + const aux = c.i32_const(module.alloc(elementLen)); + + f.addCode( + c.if( + c.i32_eqz(c.getLocal("scalarLength")), + [ + ...c.call(opInit, c.getLocal("r")), + ...c.ret([]) + ] + ) + ); + f.addCode(c.call(opCopy, c.getLocal("base"), aux)); + f.addCode(c.call(opInit, c.getLocal("r"))); + f.addCode(c.setLocal("i", c.getLocal("scalarLength"))); + f.addCode(c.block(c.loop( + c.setLocal("i", c.i32_sub(c.getLocal("i"), c.i32_const(1))), + + c.setLocal( + "b", + c.i32_load8_u( + c.i32_add( + c.getLocal("scalar"), + c.getLocal("i") + ) + ) + ), + ...innerLoop(), + c.br_if(1, c.i32_eqz ( c.getLocal("i") )), + c.br(0) + ))); + + + function innerLoop() { + const code = []; + for (let i=0; i<8; i++) { + code.push( + ...c.call(opAA, c.getLocal("r"), c.getLocal("r")), + ...c.if( + c.i32_ge_u( c.getLocal("b"), c.i32_const(0x80 >> i)), + [ + ...c.setLocal( + "b", + c.i32_sub( + c.getLocal("b"), + c.i32_const(0x80 >> i) + ) + ), + ...c.call(opAB, c.getLocal("r"),aux, c.getLocal("r")) + ] + ) + ); + } + return code; + } + +}; + +var build_batchinverse = buildBatchInverse$3; + +function buildBatchInverse$3(module, prefix) { + + + const n8 = module.modules[prefix].n64*8; + + const f = module.addFunction(prefix+"_batchInverse"); + f.addParam("pIn", "i32"); + f.addParam("inStep", "i32"); + f.addParam("n", "i32"); + f.addParam("pOut", "i32"); + f.addParam("outStep", "i32"); + f.addLocal("itAux", "i32"); + f.addLocal("itIn", "i32"); + f.addLocal("itOut","i32"); + f.addLocal("i","i32"); + + const c = f.getCodeBuilder(); + + const AUX = c.i32_const(module.alloc(n8)); + + + // Alloc Working space for accumulated umltiplications + f.addCode( + c.setLocal("itAux", c.i32_load( c.i32_const(0) )), + c.i32_store( + c.i32_const(0), + c.i32_add( + c.getLocal("itAux"), + c.i32_mul( + c.i32_add( + c.getLocal("n"), + c.i32_const(1) + ), + c.i32_const(n8) + ) + ) + ) + ); + + f.addCode( + + // aux[0] = a; + c.call(prefix+"_one", c.getLocal("itAux")), + // for (i=0;i. +*/ + +const bigInt$c = BigIntegerExports$1; +const buildInt = build_int; +const utils$b = utils$d; +const buildExp$2 = build_timesscalar; +const buildBatchInverse$2 = build_batchinverse; +const buildBatchConvertion$1 = build_batchconvertion; +const buildBatchOp = build_batchop; + +var build_f1m = function buildF1m(module, _q, _prefix, _intPrefix) { + const q = bigInt$c(_q); + const n64 = Math.floor((q.minus(1).bitLength() - 1)/64) +1; + const n32 = n64*2; + const n8 = n64*8; + + const prefix = _prefix || "f1m"; + if (module.modules[prefix]) return prefix; // already builded + + const intPrefix = buildInt(module, n64, _intPrefix); + const pq = module.alloc(n8, utils$b.bigInt2BytesLE(q, n8)); + + module.alloc(utils$b.bigInt2BytesLE(bigInt$c.one.shiftLeft(n64*64).mod(q), n8)); + const pR2 = module.alloc(utils$b.bigInt2BytesLE(bigInt$c.one.shiftLeft(n64*64).square().mod(q), n8)); + const pOne = module.alloc(utils$b.bigInt2BytesLE(bigInt$c.one.shiftLeft(n64*64).mod(q), n8)); + const pZero = module.alloc(utils$b.bigInt2BytesLE(bigInt$c.zero, n8)); + const _minusOne = q.minus(bigInt$c.one); + const _e = _minusOne.shiftRight(1); // e = (p-1)/2 + const pe = module.alloc(n8, utils$b.bigInt2BytesLE(_e, n8)); + + const _ePlusOne = _e.add(bigInt$c.one); // e = (p-1)/2 + const pePlusOne = module.alloc(n8, utils$b.bigInt2BytesLE(_ePlusOne, n8)); + + module.modules[prefix] = { + pq: pq, + pR2: pR2, + n64: n64, + q: q, + pOne: pOne, + pZero: pZero, + pePlusOne: pePlusOne + }; + + function buildOne() { + const f = module.addFunction(prefix+"_one"); + f.addParam("pr", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode(c.call(intPrefix + "_copy", c.i32_const(pOne), c.getLocal("pr"))); + } + + function buildAdd() { + const f = module.addFunction(prefix+"_add"); + f.addParam("x", "i32"); + f.addParam("y", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.if( + c.call(intPrefix+"_add", c.getLocal("x"), c.getLocal("y"), c.getLocal("r")), + c.drop(c.call(intPrefix+"_sub", c.getLocal("r"), c.i32_const(pq), c.getLocal("r"))), + c.if( + c.call(intPrefix+"_gte", c.getLocal("r"), c.i32_const(pq) ), + c.drop(c.call(intPrefix+"_sub", c.getLocal("r"), c.i32_const(pq), c.getLocal("r"))), + ) + ) + ); + } + + function buildSub() { + const f = module.addFunction(prefix+"_sub"); + f.addParam("x", "i32"); + f.addParam("y", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.if( + c.call(intPrefix+"_sub", c.getLocal("x"), c.getLocal("y"), c.getLocal("r")), + c.drop(c.call(intPrefix+"_add", c.getLocal("r"), c.i32_const(pq), c.getLocal("r"))) + ) + ); + } + + function buildNeg() { + const f = module.addFunction(prefix+"_neg"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.call(prefix + "_sub", c.i32_const(pZero), c.getLocal("x"), c.getLocal("r")) + ); + } + + + function buildIsNegative() { + const f = module.addFunction(prefix+"_isNegative"); + f.addParam("x", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + const AUX = c.i32_const(module.alloc(n8)); + + f.addCode( + c.call(prefix + "_fromMontgomery", c.getLocal("x"), AUX), + c.call(intPrefix + "_gte", AUX, c.i32_const(pePlusOne) ) + ); + } + + +/* + function buildIsNegative() { + const f = module.addFunction(prefix+"_isNegative"); + f.addParam("x", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + const AUX = c.i32_const(module.alloc(n8)); + + f.addCode( + c.call(prefix + "_fromMontgomery", c.getLocal("x"), AUX), + c.i32_and( + c.i32_load(AUX), + c.i32_const(1) + ) + ); + } +*/ + + function buildSign() { + const f = module.addFunction(prefix+"_sign"); + f.addParam("x", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + const AUX = c.i32_const(module.alloc(n8)); + + f.addCode( + c.if ( + c.call(intPrefix + "_isZero", c.getLocal("x")), + c.ret(c.i32_const(0)) + ), + c.call(prefix + "_fromMontgomery", c.getLocal("x"), AUX), + c.if( + c.call(intPrefix + "_gte", AUX, c.i32_const(pePlusOne)), + c.ret(c.i32_const(-1)) + ), + c.ret(c.i32_const(1)) + ); + } + + + function buildMReduct() { + const carries = module.alloc(n32*n32*8); + + const f = module.addFunction(prefix+"_mReduct"); + f.addParam("t", "i32"); + f.addParam("r", "i32"); + f.addLocal("np32", "i64"); + f.addLocal("c", "i64"); + f.addLocal("m", "i64"); + + const c = f.getCodeBuilder(); + + const np32 = bigInt$c("100000000",16).minus( q.modInv(bigInt$c("100000000",16))).toJSNumber(); + + f.addCode(c.setLocal("np32", c.i64_const(np32))); + + for (let i=0; i=n32) { + f.addCode( + c.i64_store32( + c.getLocal("r"), + (k-n32)*4, + c.getLocal(c0) + ) + ); + } + [c0, c1] = [c1, c0]; + f.addCode( + c.setLocal(c1, + c.i64_shr_u( + c.getLocal(c0), + c.i64_const(32) + ) + ) + ); + } + f.addCode( + c.i64_store32( + c.getLocal("r"), + n32*4-4, + c.getLocal(c0) + ) + ); + + f.addCode( + c.if( + c.i32_wrap_i64(c.getLocal(c1)), + c.drop(c.call(intPrefix+"_sub", c.getLocal("r"), c.i32_const(pq), c.getLocal("r"))), + c.if( + c.call(intPrefix+"_gte", c.getLocal("r"), c.i32_const(pq) ), + c.drop(c.call(intPrefix+"_sub", c.getLocal("r"), c.i32_const(pq), c.getLocal("r"))), + ) + ) + ); + } + + + function buildSquare() { + + const f = module.addFunction(prefix+"_square"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + f.addLocal("c0", "i64"); + f.addLocal("c1", "i64"); + f.addLocal("c0_old", "i64"); + f.addLocal("c1_old", "i64"); + f.addLocal("np32", "i64"); + + + for (let i=0;i>1) )&&(i>1, k>>1) + ) + ) + ); + + f.addCode( + c.setLocal(c1, + c.i64_add( + c.getLocal(c1), + c.i64_shr_u( + c.getLocal(c0), + c.i64_const(32) + ) + ) + ) + ); + } + + // Add the old carry + + if (k>0) { + f.addCode( + c.setLocal(c0, + c.i64_add( + c.i64_and( + c.getLocal(c0), + c.i64_const(0xFFFFFFFF) + ), + c.i64_and( + c.getLocal(c0_old), + c.i64_const(0xFFFFFFFF) + ), + ) + ) + ); + + f.addCode( + c.setLocal(c1, + c.i64_add( + c.i64_add( + c.getLocal(c1), + c.i64_shr_u( + c.getLocal(c0), + c.i64_const(32) + ) + ), + c.getLocal(c1_old) + ) + ) + ); + } + + + for (let i=Math.max(1, k-n32+1); (i<=k)&&(i=n32) { + f.addCode( + c.i64_store32( + c.getLocal("r"), + (k-n32)*4, + c.getLocal(c0) + ) + ); + } + f.addCode( + c.setLocal( + c0_old, + c.getLocal(c1) + ), + c.setLocal( + c1_old, + c.i64_shr_u( + c.getLocal(c0_old), + c.i64_const(32) + ) + ) + ); + } + f.addCode( + c.i64_store32( + c.getLocal("r"), + n32*4-4, + c.getLocal(c0_old) + ) + ); + + f.addCode( + c.if( + c.i32_wrap_i64(c.getLocal(c1_old)), + c.drop(c.call(intPrefix+"_sub", c.getLocal("r"), c.i32_const(pq), c.getLocal("r"))), + c.if( + c.call(intPrefix+"_gte", c.getLocal("r"), c.i32_const(pq) ), + c.drop(c.call(intPrefix+"_sub", c.getLocal("r"), c.i32_const(pq), c.getLocal("r"))), + ) + ) + ); + } + + + function buildSquareOld() { + const f = module.addFunction(prefix+"_squareOld"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode(c.call(prefix + "_mul", c.getLocal("x"), c.getLocal("x"), c.getLocal("r"))); + } + + function buildToMontgomery() { + const f = module.addFunction(prefix+"_toMontgomery"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + f.addCode(c.call(prefix+"_mul", c.getLocal("x"), c.i32_const(pR2), c.getLocal("r"))); + } + + function buildFromMontgomery() { + + const pAux2 = module.alloc(n8*2); + + const f = module.addFunction(prefix+"_fromMontgomery"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + f.addCode(c.call(intPrefix + "_copy", c.getLocal("x"), c.i32_const(pAux2) )); + f.addCode(c.call(intPrefix + "_zero", c.i32_const(pAux2 + n8) )); + f.addCode(c.call(prefix+"_mReduct", c.i32_const(pAux2), c.getLocal("r"))); + } + + function buildInverse() { + + const f = module.addFunction(prefix+ "_inverse"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + f.addCode(c.call(prefix + "_fromMontgomery", c.getLocal("x"), c.getLocal("r"))); + f.addCode(c.call(intPrefix + "_inverseMod", c.getLocal("r"), c.i32_const(pq), c.getLocal("r"))); + f.addCode(c.call(prefix + "_toMontgomery", c.getLocal("r"), c.getLocal("r"))); + } + + // Calculate various valuse needed for sqrt + + + let _nqr = bigInt$c(2); + if (q.isPrime()) { + while (!_nqr.modPow(_e, q).equals(_minusOne)) _nqr = _nqr.add(bigInt$c.one); + } + + module.alloc(utils$b.bigInt2BytesLE(_nqr.shiftLeft(n64*64).mod(q), n8)); + + let s2 = 0; + let _t = _minusOne; + + while ((!_t.isOdd())&&(!_t.isZero())) { + s2++; + _t = _t.shiftRight(1); + } + const pt = module.alloc(n8, utils$b.bigInt2BytesLE(_t, n8)); + + const _nqrToT = _nqr.modPow(_t, q); + const pNqrToT = module.alloc(utils$b.bigInt2BytesLE(_nqrToT.shiftLeft(n64*64).mod(q), n8)); + + const _tPlusOneOver2 = _t.add(1).shiftRight(1); + const ptPlusOneOver2 = module.alloc(n8, utils$b.bigInt2BytesLE(_tPlusOneOver2, n8)); + + function buildSqrt() { + + const f = module.addFunction(prefix+ "_sqrt"); + f.addParam("n", "i32"); + f.addParam("r", "i32"); + f.addLocal("m", "i32"); + f.addLocal("i", "i32"); + f.addLocal("j", "i32"); + + const c = f.getCodeBuilder(); + + const ONE = c.i32_const(pOne); + const C = c.i32_const(module.alloc(n8)); + const T = c.i32_const(module.alloc(n8)); + const R = c.i32_const(module.alloc(n8)); + const SQ = c.i32_const(module.alloc(n8)); + const B = c.i32_const(module.alloc(n8)); + + f.addCode( + + // If (n==0) return 0 + c.if( + c.call(prefix + "_isZero", c.getLocal("n")), + c.ret( + c.call(prefix + "_zero", c.getLocal("r")) + ) + ), + + c.setLocal("m", c.i32_const(s2)), + c.call(prefix + "_copy", c.i32_const(pNqrToT), C), + c.call(prefix + "_exp", c.getLocal("n"), c.i32_const(pt), c.i32_const(n8), T), + c.call(prefix + "_exp", c.getLocal("n"), c.i32_const(ptPlusOneOver2), c.i32_const(n8), R), + + c.block(c.loop( + c.br_if(1, c.call(prefix + "_eq", T, ONE)), + + c.call(prefix + "_square", T, SQ), + c.setLocal("i", c.i32_const(1)), + c.block(c.loop( + c.br_if(1, c.call(prefix + "_eq", SQ, ONE)), + c.call(prefix + "_square", SQ, SQ), + c.setLocal("i", c.i32_add(c.getLocal("i"), c.i32_const(1))), + c.br(0) + )), + + c.call(prefix + "_copy", C, B), + c.setLocal("j", c.i32_sub(c.i32_sub( c.getLocal("m"), c.getLocal("i")), c.i32_const(1)) ), + c.block(c.loop( + c.br_if(1, c.i32_eqz(c.getLocal("j"))), + c.call(prefix + "_square", B, B), + c.setLocal("j", c.i32_sub(c.getLocal("j"), c.i32_const(1))), + c.br(0) + )), + + c.setLocal("m", c.getLocal("i")), + c.call(prefix + "_square", B, C), + c.call(prefix + "_mul", T, C, T), + c.call(prefix + "_mul", R, B, R), + + c.br(0) + )), + + c.if( + c.call(prefix + "_isNegative", R), + c.call(prefix + "_neg", R, c.getLocal("r")), + c.call(prefix + "_copy", R, c.getLocal("r")), + ) + ); + } + + function buildIsSquare() { + const f = module.addFunction(prefix+"_isSquare"); + f.addParam("n", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + const ONE = c.i32_const(pOne); + const AUX = c.i32_const(module.alloc(n8)); + + f.addCode( + c.if( + c.call(prefix + "_isZero", c.getLocal("n")), + c.ret(c.i32_const(1)) + ), + c.call(prefix + "_exp", c.getLocal("n"), c.i32_const(pe), c.i32_const(n8), AUX), + c.call(prefix + "_eq", AUX, ONE) + ); + } + + + function buildLoad() { + const f = module.addFunction(prefix+"_load"); + f.addParam("scalar", "i32"); + f.addParam("scalarLen", "i32"); + f.addParam("r", "i32"); + f.addLocal("p", "i32"); + f.addLocal("l", "i32"); + f.addLocal("i", "i32"); + f.addLocal("j", "i32"); + const c = f.getCodeBuilder(); + + const R = c.i32_const(module.alloc(n8)); + const pAux = module.alloc(n8); + const AUX = c.i32_const(pAux); + + f.addCode( + c.call(intPrefix + "_zero", c.getLocal("r")), + c.setLocal("i", c.i32_const(n8)), + c.setLocal("p", c.getLocal("scalar")), + c.block(c.loop( + c.br_if(1, c.i32_gt_u(c.getLocal("i"), c.getLocal("scalarLen"))), + + c.if( + c.i32_eq(c.getLocal("i"), c.i32_const(n8)), + c.call(prefix + "_one", R), + c.call(prefix + "_mul", R, c.i32_const(pR2), R) + ), + c.call(prefix + "_mul", c.getLocal("p"), R, AUX), + c.call(prefix + "_add", c.getLocal("r"), AUX, c.getLocal("r")), + + c.setLocal("p", c.i32_add(c.getLocal("p"), c.i32_const(n8))), + c.setLocal("i", c.i32_add(c.getLocal("i"), c.i32_const(n8))), + c.br(0) + )), + + c.setLocal("l", c.i32_rem_u( c.getLocal("scalarLen"), c.i32_const(n8))), + c.if(c.i32_eqz(c.getLocal("l")), c.ret([])), + c.call(intPrefix + "_zero", AUX), + c.setLocal("j", c.i32_const(0)), + c.block(c.loop( + c.br_if(1, c.i32_eq(c.getLocal("j"), c.getLocal("l"))), + + c.i32_store8( + c.getLocal("j"), + pAux, + c.i32_load8_u(c.getLocal("p")), + ), + c.setLocal("p", c.i32_add(c.getLocal("p"), c.i32_const(1))), + c.setLocal("j", c.i32_add(c.getLocal("j"), c.i32_const(1))), + c.br(0) + )), + + c.if( + c.i32_eq(c.getLocal("i"), c.i32_const(n8)), + c.call(prefix + "_one", R), + c.call(prefix + "_mul", R, c.i32_const(pR2), R) + ), + c.call(prefix + "_mul", AUX, R, AUX), + c.call(prefix + "_add", c.getLocal("r"), AUX, c.getLocal("r")), + ); + } + + function buildTimesScalar() { + const f = module.addFunction(prefix+"_timesScalar"); + f.addParam("x", "i32"); + f.addParam("scalar", "i32"); + f.addParam("scalarLen", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const AUX = c.i32_const(module.alloc(n8)); + + f.addCode( + c.call(prefix + "_load", c.getLocal("scalar"), c.getLocal("scalarLen"), AUX), + c.call(prefix + "_toMontgomery", AUX, AUX), + c.call(prefix + "_mul", c.getLocal("x"), AUX, c.getLocal("r")), + ); + } + + function buildIsOne() { + const f = module.addFunction(prefix+"_isOne"); + f.addParam("x", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + f.addCode( + c.ret(c.call(intPrefix + "_eq", c.getLocal("x"), c.i32_const(pOne))) + ); + } + + + module.exportFunction(intPrefix + "_copy", prefix+"_copy"); + module.exportFunction(intPrefix + "_zero", prefix+"_zero"); + module.exportFunction(intPrefix + "_isZero", prefix+"_isZero"); + module.exportFunction(intPrefix + "_eq", prefix+"_eq"); + + buildIsOne(); + buildAdd(); + buildSub(); + buildNeg(); + buildMReduct(); + buildMul(); + buildSquare(); + buildSquareOld(); + buildToMontgomery(); + buildFromMontgomery(); + buildIsNegative(); + buildSign(); + buildInverse(); + buildOne(); + buildLoad(); + buildTimesScalar(); + buildBatchInverse$2(module, prefix); + buildBatchConvertion$1(module, prefix + "_batchToMontgomery", prefix + "_toMontgomery", n8, n8); + buildBatchConvertion$1(module, prefix + "_batchFromMontgomery", prefix + "_fromMontgomery", n8, n8); + buildBatchConvertion$1(module, prefix + "_batchNeg", prefix + "_neg", n8, n8); + buildBatchOp(module, prefix + "_batchAdd", prefix + "_add", n8, n8); + buildBatchOp(module, prefix + "_batchSub", prefix + "_sub", n8, n8); + buildBatchOp(module, prefix + "_batchMul", prefix + "_mul", n8, n8); + + module.exportFunction(prefix + "_add"); + module.exportFunction(prefix + "_sub"); + module.exportFunction(prefix + "_neg"); + module.exportFunction(prefix + "_isNegative"); + module.exportFunction(prefix + "_isOne"); + module.exportFunction(prefix + "_sign"); + module.exportFunction(prefix + "_mReduct"); + module.exportFunction(prefix + "_mul"); + module.exportFunction(prefix + "_square"); + module.exportFunction(prefix + "_squareOld"); + module.exportFunction(prefix + "_fromMontgomery"); + module.exportFunction(prefix + "_toMontgomery"); + module.exportFunction(prefix + "_inverse"); + module.exportFunction(prefix + "_one"); + module.exportFunction(prefix + "_load"); + module.exportFunction(prefix + "_timesScalar"); + buildExp$2( + module, + prefix + "_exp", + n8, + prefix + "_mul", + prefix + "_square", + intPrefix + "_copy", + prefix + "_one", + ); + module.exportFunction(prefix + "_exp"); + module.exportFunction(prefix + "_batchInverse"); + if (q.isPrime()) { + buildSqrt(); + buildIsSquare(); + module.exportFunction(prefix + "_sqrt"); + module.exportFunction(prefix + "_isSquare"); + } + module.exportFunction(prefix + "_batchToMontgomery"); + module.exportFunction(prefix + "_batchFromMontgomery"); + // console.log(module.functionIdxByName); + + return prefix; +}; + +/* + Copyright 2019 0KIMS association. + + This file is part of wasmsnark (Web Assembly zkSnark Prover). + + wasmsnark is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + wasmsnark is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with wasmsnark. If not, see . +*/ + +const bigInt$b = BigIntegerExports$1; + +const buildF1m$2 =build_f1m; + +var build_f1 = function buildF1(module, _q, _prefix, _f1mPrefix, _intPrefix) { + + const q = bigInt$b(_q); + const n64 = Math.floor((q.minus(1).bitLength() - 1)/64) +1; + const n8 = n64*8; + + const prefix = _prefix || "f1"; + if (module.modules[prefix]) return prefix; // already builded + module.modules[prefix] = { + n64: n64 + }; + + const intPrefix = _intPrefix || "int"; + const f1mPrefix = buildF1m$2(module, q, _f1mPrefix, intPrefix); + + + const pR2 = module.modules[f1mPrefix].pR2; + const pq = module.modules[f1mPrefix].pq; + const pePlusOne = module.modules[f1mPrefix].pePlusOne; + + function buildMul() { + const pAux1 = module.alloc(n8); + + const f = module.addFunction(prefix+ "_mul"); + f.addParam("x", "i32"); + f.addParam("y", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + f.addCode(c.call(f1mPrefix + "_mul", c.getLocal("x"), c.getLocal("y"), c.i32_const(pAux1))); + f.addCode(c.call(f1mPrefix + "_mul", c.i32_const(pAux1), c.i32_const(pR2), c.getLocal("r"))); + } + + function buildSquare() { + const f = module.addFunction(prefix+"_square"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode(c.call(prefix + "_mul", c.getLocal("x"), c.getLocal("x"), c.getLocal("r"))); + } + + + function buildInverse() { + + const f = module.addFunction(prefix+ "_inverse"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + f.addCode(c.call(intPrefix + "_inverseMod", c.getLocal("x"), c.i32_const(pq), c.getLocal("r"))); + } + + function buildIsNegative() { + const f = module.addFunction(prefix+"_isNegative"); + f.addParam("x", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.call(intPrefix + "_gte", c.getLocal("x"), c.i32_const(pePlusOne) ) + ); + } + + + buildMul(); + buildSquare(); + buildInverse(); + buildIsNegative(); + module.exportFunction(f1mPrefix + "_add", prefix + "_add"); + module.exportFunction(f1mPrefix + "_sub", prefix + "_sub"); + module.exportFunction(f1mPrefix + "_neg", prefix + "_neg"); + module.exportFunction(prefix + "_mul"); + module.exportFunction(prefix + "_square"); + module.exportFunction(prefix + "_inverse"); + module.exportFunction(prefix + "_isNegative"); + module.exportFunction(f1mPrefix + "_copy", prefix+"_copy"); + module.exportFunction(f1mPrefix + "_zero", prefix+"_zero"); + module.exportFunction(f1mPrefix + "_one", prefix+"_one"); + module.exportFunction(f1mPrefix + "_isZero", prefix+"_isZero"); + module.exportFunction(f1mPrefix + "_eq", prefix+"_eq"); + + return prefix; +}; + +/* + Copyright 2019 0KIMS association. + + This file is part of wasmsnark (Web Assembly zkSnark Prover). + + wasmsnark is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + wasmsnark is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with wasmsnark. If not, see . +*/ + +const buildExp$1 = build_timesscalar; +const buildBatchInverse$1 = build_batchinverse; +const bigInt$a = BigIntegerExports$1; +const utils$a = utils$d; + +var build_f2m = function buildF2m(module, mulNonResidueFn, prefix, f1mPrefix) { + + if (module.modules[prefix]) return prefix; // already builded + + const f1n8 = module.modules[f1mPrefix].n64*8; + const q = module.modules[f1mPrefix].q; + + module.modules[prefix] = { + n64: module.modules[f1mPrefix].n64*2 + }; + + function buildAdd() { + const f = module.addFunction(prefix+"_add"); + f.addParam("x", "i32"); + f.addParam("y", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const y0 = c.getLocal("y"); + const y1 = c.i32_add(c.getLocal("y"), c.i32_const(f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + + f.addCode( + c.call(f1mPrefix+"_add", x0, y0, r0), + c.call(f1mPrefix+"_add", x1, y1, r1), + ); + } + + function buildTimesScalar() { + const f = module.addFunction(prefix+"_timesScalar"); + f.addParam("x", "i32"); + f.addParam("scalar", "i32"); + f.addParam("scalarLen", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + + f.addCode( + c.call(f1mPrefix+"_timesScalar", x0, c.getLocal("scalar"), c.getLocal("scalarLen"), r0), + c.call(f1mPrefix+"_timesScalar", x1, c.getLocal("scalar"), c.getLocal("scalarLen"), r1), + ); + } + + function buildSub() { + const f = module.addFunction(prefix+"_sub"); + f.addParam("x", "i32"); + f.addParam("y", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const y0 = c.getLocal("y"); + const y1 = c.i32_add(c.getLocal("y"), c.i32_const(f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + + f.addCode( + c.call(f1mPrefix+"_sub", x0, y0, r0), + c.call(f1mPrefix+"_sub", x1, y1, r1), + ); + } + + function buildNeg() { + const f = module.addFunction(prefix+"_neg"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + + f.addCode( + c.call(f1mPrefix+"_neg", x0, r0), + c.call(f1mPrefix+"_neg", x1, r1), + ); + } + + function buildConjugate() { + const f = module.addFunction(prefix+"_conjugate"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + + f.addCode( + c.call(f1mPrefix+"_copy", x0, r0), + c.call(f1mPrefix+"_neg", x1, r1), + ); + } + + + function buildIsNegative() { + const f = module.addFunction(prefix+"_isNegative"); + f.addParam("x", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + + f.addCode( + c.if( + c.call(f1mPrefix+"_isZero", x1), + c.ret(c.call(f1mPrefix+"_isNegative", x0)) + ), + c.ret(c.call(f1mPrefix+"_isNegative", x1)) + ); + } + + function buildMul() { + const f = module.addFunction(prefix+"_mul"); + f.addParam("x", "i32"); + f.addParam("y", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const y0 = c.getLocal("y"); + const y1 = c.i32_add(c.getLocal("y"), c.i32_const(f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + + const A = c.i32_const(module.alloc(f1n8)); + const B = c.i32_const(module.alloc(f1n8)); + const C = c.i32_const(module.alloc(f1n8)); + const D = c.i32_const(module.alloc(f1n8)); + + + f.addCode( + c.call(f1mPrefix + "_mul", x0, y0, A), // A = x0*y0 + c.call(f1mPrefix + "_mul", x1, y1, B), // B = x1*y1 + + c.call(f1mPrefix + "_add", x0, x1, C), // C = x0 + x1 + c.call(f1mPrefix + "_add", y0, y1, D), // D = y0 + y1 + c.call(f1mPrefix + "_mul", C, D, C), // C = (x0 + x1)*(y0 + y1) = x0*y0+x0*y1+x1*y0+x1*y1 + + // c.call(f1mPrefix + "_mul", B, c.i32_const(pNonResidue), r0), // r0 = nr*(x1*y1) + c.call(mulNonResidueFn, B, r0), // r0 = nr*(x1*y1) + c.call(f1mPrefix + "_add", A, r0, r0), // r0 = x0*y0 + nr*(x1*y1) + c.call(f1mPrefix + "_add", A, B, r1), // r1 = x0*y0+x1*y1 + c.call(f1mPrefix + "_sub", C, r1, r1) // r1 = x0*y0+x0*y1+x1*y0+x1*y1 - x0*y0+x1*y1 = x0*y1+x1*y0 + ); + + } + + function buildMul1() { + const f = module.addFunction(prefix+"_mul1"); + f.addParam("x", "i32"); + f.addParam("y", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const y = c.getLocal("y"); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + + + f.addCode( + c.call(f1mPrefix + "_mul", x0, y, r0), // A = x0*y + c.call(f1mPrefix + "_mul", x1, y, r1), // B = x1*y + ); + } + + function buildSquare() { + const f = module.addFunction(prefix+"_square"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + + const AB = c.i32_const(module.alloc(f1n8)); + const APB = c.i32_const(module.alloc(f1n8)); + const APNB = c.i32_const(module.alloc(f1n8)); + const ABPNAB = c.i32_const(module.alloc(f1n8)); + + + f.addCode( + // AB = x0*y1 + c.call(f1mPrefix + "_mul", x0, x1, AB), + + // APB = x0+y1 + c.call(f1mPrefix + "_add", x0, x1, APB), + + // APBN0 = x0 + nr*x1 + c.call(mulNonResidueFn, x1, APNB), + c.call(f1mPrefix + "_add", x0, APNB, APNB), + + // ABPNAB = ab + nr*ab + c.call(mulNonResidueFn, AB, ABPNAB), + c.call(f1mPrefix + "_add", ABPNAB, AB, ABPNAB), + + // r0 = APB * APNB - ABPNAB + c.call(f1mPrefix + "_mul", APB, APNB, r0), + c.call(f1mPrefix + "_sub", r0, ABPNAB, r0), + + // r1 = AB + AB + c.call(f1mPrefix + "_add", AB, AB, r1), + ); + + } + + + function buildToMontgomery() { + const f = module.addFunction(prefix+"_toMontgomery"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + + f.addCode( + c.call(f1mPrefix+"_toMontgomery", x0, r0), + c.call(f1mPrefix+"_toMontgomery", x1, r1) + ); + } + + function buildFromMontgomery() { + const f = module.addFunction(prefix+"_fromMontgomery"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + + f.addCode( + c.call(f1mPrefix+"_fromMontgomery", x0, r0), + c.call(f1mPrefix+"_fromMontgomery", x1, r1) + ); + } + + function buildCopy() { + const f = module.addFunction(prefix+"_copy"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + + f.addCode( + c.call(f1mPrefix+"_copy", x0, r0), + c.call(f1mPrefix+"_copy", x1, r1) + ); + } + + function buildZero() { + const f = module.addFunction(prefix+"_zero"); + f.addParam("x", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + + f.addCode( + c.call(f1mPrefix+"_zero", x0), + c.call(f1mPrefix+"_zero", x1) + ); + } + + function buildOne() { + const f = module.addFunction(prefix+"_one"); + f.addParam("x", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + + f.addCode( + c.call(f1mPrefix+"_one", x0), + c.call(f1mPrefix+"_zero", x1) + ); + } + + function buildEq() { + const f = module.addFunction(prefix+"_eq"); + f.addParam("x", "i32"); + f.addParam("y", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const y0 = c.getLocal("y"); + const y1 = c.i32_add(c.getLocal("y"), c.i32_const(f1n8)); + + f.addCode( + c.i32_and( + c.call(f1mPrefix+"_eq", x0, y0), + c.call(f1mPrefix+"_eq", x1, y1) + ) + ); + } + + function buildIsZero() { + const f = module.addFunction(prefix+"_isZero"); + f.addParam("x", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + + f.addCode( + c.i32_and( + c.call(f1mPrefix+"_isZero", x0), + c.call(f1mPrefix+"_isZero", x1) + ) + ); + } + + function buildInverse() { + const f = module.addFunction(prefix+"_inverse"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + + const t0 = c.i32_const(module.alloc(f1n8)); + const t1 = c.i32_const(module.alloc(f1n8)); + const t2 = c.i32_const(module.alloc(f1n8)); + const t3 = c.i32_const(module.alloc(f1n8)); + + f.addCode( + c.call(f1mPrefix+"_square", x0, t0), + c.call(f1mPrefix+"_square", x1, t1), + // c.call(f1mPrefix+"_mul", t1, c.i32_const(pNonResidue), t2), + c.call(mulNonResidueFn, t1, t2), + + c.call(f1mPrefix+"_sub", t0, t2, t2), + c.call(f1mPrefix+"_inverse", t2, t3), + + c.call(f1mPrefix+"_mul", x0, t3, r0), + c.call(f1mPrefix+"_mul", x1, t3, r1), + c.call(f1mPrefix+"_neg", r1, r1), + ); + } + + + function buildSign() { + const f = module.addFunction(prefix+"_sign"); + f.addParam("x", "i32"); + f.addLocal("s", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + + f.addCode( + c.setLocal("s" , c.call( f1mPrefix + "_sign", x1)), + c.if( + c.getLocal("s"), + c.ret(c.getLocal("s")) + ), + c.ret(c.call( f1mPrefix + "_sign", x0)) + ); + } + + function buildIsOne() { + const f = module.addFunction(prefix+"_isOne"); + f.addParam("x", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + + f.addCode( + c.ret(c.i32_and( + c.call(f1mPrefix + "_isOne", x0), + c.call(f1mPrefix + "_isZero", x1), + )) + ); + } + + + // Check here: https://eprint.iacr.org/2012/685.pdf + // Alg 9adj + function buildSqrt() { + + const f = module.addFunction(prefix+"_sqrt"); + f.addParam("a", "i32"); + f.addParam("pr", "i32"); + + const c = f.getCodeBuilder(); + + const e34 = c.i32_const(module.alloc(utils$a.bigInt2BytesLE(bigInt$a(q).minus(bigInt$a(3)).divide(4), f1n8 ))); + const e12 = c.i32_const(module.alloc(utils$a.bigInt2BytesLE(bigInt$a(q).minus(bigInt$a(1)).divide(2), f1n8 ))); + + const a = c.getLocal("a"); + const a1 = c.i32_const(module.alloc(f1n8*2)); + const alpha = c.i32_const(module.alloc(f1n8*2)); + const a0 = c.i32_const(module.alloc(f1n8*2)); + const pn1 = module.alloc(f1n8*2); + const n1 = c.i32_const(pn1); + const n1a = c.i32_const(pn1); + const n1b = c.i32_const(pn1+f1n8); + const x0 = c.i32_const(module.alloc(f1n8*2)); + const b = c.i32_const(module.alloc(f1n8*2)); + + f.addCode( + + c.call(prefix + "_one", n1), + c.call(prefix + "_neg", n1, n1), + + // const a1 = F.pow(a, F.sqrt_e34); + c.call(prefix + "_exp", a, e34, c.i32_const(f1n8), a1), + + // const a1 = F.pow(a, F.sqrt_e34); + c.call(prefix + "_square", a1, alpha), + c.call(prefix + "_mul", a, alpha, alpha), + + // const a0 = F.mul(F.frobenius(1, alfa), alfa); + c.call(prefix + "_conjugate", alpha, a0), + c.call(prefix + "_mul", a0, alpha, a0), + + // if (F.eq(a0, F.negone)) return null; + c.if(c.call(prefix + "_eq",a0,n1), c.unreachable() ), + + // const x0 = F.mul(a1, a); + c.call(prefix + "_mul", a1, a, x0), + + // if (F.eq(alfa, F.negone)) { + c.if( + c.call(prefix + "_eq", alpha, n1), + [ + // x = F.mul(x0, [F.F.zero, F.F.one]); + ...c.call(f1mPrefix + "_zero", n1a), + ...c.call(f1mPrefix + "_one", n1b), + ...c.call(prefix + "_mul", n1, x0, c.getLocal("pr")), + ], + [ + // const b = F.pow(F.add(F.one, alfa), F.sqrt_e12); + ...c.call(prefix + "_one", b), + ...c.call(prefix + "_add", b, alpha, b), + ...c.call(prefix + "_exp", b, e12, c.i32_const(f1n8), b), + + // x = F.mul(b, x0); + ...c.call(prefix + "_mul", b, x0, c.getLocal("pr")), + ] + ) + ); + + } + + + function buildIsSquare() { + + const f = module.addFunction(prefix+"_isSquare"); + f.addParam("a", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + const e34 = c.i32_const(module.alloc(utils$a.bigInt2BytesLE(bigInt$a(q).minus(bigInt$a(3)).divide(4), f1n8 ))); + + const a = c.getLocal("a"); + const a1 = c.i32_const(module.alloc(f1n8*2)); + const alpha = c.i32_const(module.alloc(f1n8*2)); + const a0 = c.i32_const(module.alloc(f1n8*2)); + const pn1 = module.alloc(f1n8*2); + const n1 = c.i32_const(pn1); + + f.addCode( + + c.call(prefix + "_one", n1), + c.call(prefix + "_neg", n1, n1), + + // const a1 = F.pow(a, F.sqrt_e34); + c.call(prefix + "_exp", a, e34, c.i32_const(f1n8), a1), + + // const a1 = F.pow(a, F.sqrt_e34); + c.call(prefix + "_square", a1, alpha), + c.call(prefix + "_mul", a, alpha, alpha), + + // const a0 = F.mul(F.frobenius(1, alfa), alfa); + c.call(prefix + "_conjugate", alpha, a0), + c.call(prefix + "_mul", a0, alpha, a0), + + // if (F.eq(a0, F.negone)) return null; + c.if( + c.call( + prefix + "_eq", + a0, + n1 + ), + c.ret(c.i32_const(0)) + ), + c.ret(c.i32_const(1)) + ); + + } + + + buildIsZero(); + buildIsOne(); + buildZero(); + buildOne(); + buildCopy(); + buildMul(); + buildMul1(); + buildSquare(); + buildAdd(); + buildSub(); + buildNeg(); + buildConjugate(); + buildToMontgomery(); + buildFromMontgomery(); + buildEq(); + buildInverse(); + buildTimesScalar(); + buildSign(); + buildIsNegative(); + + module.exportFunction(prefix + "_isZero"); + module.exportFunction(prefix + "_isOne"); + module.exportFunction(prefix + "_zero"); + module.exportFunction(prefix + "_one"); + module.exportFunction(prefix + "_copy"); + module.exportFunction(prefix + "_mul"); + module.exportFunction(prefix + "_mul1"); + module.exportFunction(prefix + "_square"); + module.exportFunction(prefix + "_add"); + module.exportFunction(prefix + "_sub"); + module.exportFunction(prefix + "_neg"); + module.exportFunction(prefix + "_sign"); + module.exportFunction(prefix + "_conjugate"); + module.exportFunction(prefix + "_fromMontgomery"); + module.exportFunction(prefix + "_toMontgomery"); + module.exportFunction(prefix + "_eq"); + module.exportFunction(prefix + "_inverse"); + buildBatchInverse$1(module, prefix); + buildExp$1( + module, + prefix + "_exp", + f1n8*2, + prefix + "_mul", + prefix + "_square", + prefix + "_copy", + prefix + "_one", + ); + buildSqrt(); + buildIsSquare(); + + module.exportFunction(prefix + "_exp"); + module.exportFunction(prefix + "_timesScalar"); + module.exportFunction(prefix + "_batchInverse"); + module.exportFunction(prefix + "_sqrt"); + module.exportFunction(prefix + "_isSquare"); + module.exportFunction(prefix + "_isNegative"); + + + return prefix; +}; + +/* + Copyright 2019 0KIMS association. + + This file is part of wasmsnark (Web Assembly zkSnark Prover). + + wasmsnark is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + wasmsnark is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with wasmsnark. If not, see . +*/ + +const buildExp = build_timesscalar; +const buildBatchInverse = build_batchinverse; + +var build_f3m = function buildF3m(module, mulNonResidueFn, prefix, f1mPrefix) { + + if (module.modules[prefix]) return prefix; // already builded + + const f1n8 = module.modules[f1mPrefix].n64*8; + module.modules[prefix] = { + n64: module.modules[f1mPrefix].n64*3 + }; + + function buildAdd() { + const f = module.addFunction(prefix+"_add"); + f.addParam("x", "i32"); + f.addParam("y", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(2*f1n8)); + const y0 = c.getLocal("y"); + const y1 = c.i32_add(c.getLocal("y"), c.i32_const(f1n8)); + const y2 = c.i32_add(c.getLocal("y"), c.i32_const(2*f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + const r2 = c.i32_add(c.getLocal("r"), c.i32_const(2*f1n8)); + + f.addCode( + c.call(f1mPrefix+"_add", x0, y0, r0), + c.call(f1mPrefix+"_add", x1, y1, r1), + c.call(f1mPrefix+"_add", x2, y2, r2), + ); + } + + function buildTimesScalar() { + const f = module.addFunction(prefix+"_timesScalar"); + f.addParam("x", "i32"); + f.addParam("scalar", "i32"); + f.addParam("scalarLen", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(2*f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + const r2 = c.i32_add(c.getLocal("r"), c.i32_const(2*f1n8)); + + f.addCode( + c.call(f1mPrefix+"_timesScalar", x0, c.getLocal("scalar"), c.getLocal("scalarLen"), r0), + c.call(f1mPrefix+"_timesScalar", x1, c.getLocal("scalar"), c.getLocal("scalarLen"), r1), + c.call(f1mPrefix+"_timesScalar", x2, c.getLocal("scalar"), c.getLocal("scalarLen"), r2), + ); + } + + + function buildSub() { + const f = module.addFunction(prefix+"_sub"); + f.addParam("x", "i32"); + f.addParam("y", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(2*f1n8)); + const y0 = c.getLocal("y"); + const y1 = c.i32_add(c.getLocal("y"), c.i32_const(f1n8)); + const y2 = c.i32_add(c.getLocal("y"), c.i32_const(2*f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + const r2 = c.i32_add(c.getLocal("r"), c.i32_const(2*f1n8)); + + f.addCode( + c.call(f1mPrefix+"_sub", x0, y0, r0), + c.call(f1mPrefix+"_sub", x1, y1, r1), + c.call(f1mPrefix+"_sub", x2, y2, r2), + ); + } + + function buildNeg() { + const f = module.addFunction(prefix+"_neg"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(2*f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + const r2 = c.i32_add(c.getLocal("r"), c.i32_const(2*f1n8)); + + f.addCode( + c.call(f1mPrefix+"_neg", x0, r0), + c.call(f1mPrefix+"_neg", x1, r1), + c.call(f1mPrefix+"_neg", x2, r2), + ); + } + + function buildIsNegative() { + const f = module.addFunction(prefix+"_isNegative"); + f.addParam("x", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(2*f1n8)); + + f.addCode( + c.if( + c.call(f1mPrefix+"_isZero", x2), + c.if( + c.call(f1mPrefix+"_isZero", x1), + c.ret(c.call(f1mPrefix+"_isNegative", x0)), + c.ret(c.call(f1mPrefix+"_isNegative", x1)) + ) + ), + c.ret(c.call(f1mPrefix+"_isNegative", x2)) + ); + } + + + function buildMul() { + const f = module.addFunction(prefix+"_mul"); + f.addParam("x", "i32"); + f.addParam("y", "i32"); + f.addParam("r", "i32"); + + const cd = f.getCodeBuilder(); + + const a = cd.getLocal("x"); + const b = cd.i32_add(cd.getLocal("x"), cd.i32_const(f1n8)); + const c = cd.i32_add(cd.getLocal("x"), cd.i32_const(2*f1n8)); + const A = cd.getLocal("y"); + const B = cd.i32_add(cd.getLocal("y"), cd.i32_const(f1n8)); + const C = cd.i32_add(cd.getLocal("y"), cd.i32_const(2*f1n8)); + const r0 = cd.getLocal("r"); + const r1 = cd.i32_add(cd.getLocal("r"), cd.i32_const(f1n8)); + const r2 = cd.i32_add(cd.getLocal("r"), cd.i32_const(2*f1n8)); + + const aA = cd.i32_const(module.alloc(f1n8)); + const bB = cd.i32_const(module.alloc(f1n8)); + const cC = cd.i32_const(module.alloc(f1n8)); + const a_b = cd.i32_const(module.alloc(f1n8)); + const A_B = cd.i32_const(module.alloc(f1n8)); + const a_c = cd.i32_const(module.alloc(f1n8)); + const A_C = cd.i32_const(module.alloc(f1n8)); + const b_c = cd.i32_const(module.alloc(f1n8)); + const B_C = cd.i32_const(module.alloc(f1n8)); + const aA_bB = cd.i32_const(module.alloc(f1n8)); + const aA_cC = cd.i32_const(module.alloc(f1n8)); + const bB_cC = cd.i32_const(module.alloc(f1n8)); + const AUX = cd.i32_const(module.alloc(f1n8)); + + + f.addCode( + cd.call(f1mPrefix + "_mul", a, A, aA), + cd.call(f1mPrefix + "_mul", b, B, bB), + cd.call(f1mPrefix + "_mul", c, C, cC), + + cd.call(f1mPrefix + "_add", a, b, a_b), + cd.call(f1mPrefix + "_add", A, B, A_B), + cd.call(f1mPrefix + "_add", a, c, a_c), + cd.call(f1mPrefix + "_add", A, C, A_C), + cd.call(f1mPrefix + "_add", b, c, b_c), + cd.call(f1mPrefix + "_add", B, C, B_C), + + cd.call(f1mPrefix + "_add", aA, bB, aA_bB), + cd.call(f1mPrefix + "_add", aA, cC, aA_cC), + cd.call(f1mPrefix + "_add", bB, cC, bB_cC), + + cd.call(f1mPrefix + "_mul", b_c, B_C, r0), + cd.call(f1mPrefix + "_sub", r0, bB_cC, r0), + cd.call(mulNonResidueFn, r0, r0), + cd.call(f1mPrefix + "_add", aA, r0, r0), + + cd.call(f1mPrefix + "_mul", a_b, A_B, r1), + cd.call(f1mPrefix + "_sub", r1, aA_bB, r1), + cd.call(mulNonResidueFn, cC, AUX), + cd.call(f1mPrefix + "_add", r1, AUX, r1), + + cd.call(f1mPrefix + "_mul", a_c, A_C, r2), + cd.call(f1mPrefix + "_sub", r2, aA_cC, r2), + cd.call(f1mPrefix + "_add", r2, bB, r2), + ); + + } + + function buildSquare() { + const f = module.addFunction(prefix+"_square"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const A = c.getLocal("x"); + const B = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const C = c.i32_add(c.getLocal("x"), c.i32_const(2*f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + const r2 = c.i32_add(c.getLocal("r"), c.i32_const(2*f1n8)); + + const s0 = c.i32_const(module.alloc(f1n8)); + const ab = c.i32_const(module.alloc(f1n8)); + const s1 = c.i32_const(module.alloc(f1n8)); + const s2 = c.i32_const(module.alloc(f1n8)); + const bc = c.i32_const(module.alloc(f1n8)); + const s3 = c.i32_const(module.alloc(f1n8)); + const s4 = c.i32_const(module.alloc(f1n8)); + + + f.addCode( + + c.call(f1mPrefix + "_square", A, s0), + c.call(f1mPrefix + "_mul", A, B, ab), + c.call(f1mPrefix + "_add", ab, ab, s1), + + c.call(f1mPrefix + "_sub", A, B, s2), + c.call(f1mPrefix + "_add", s2, C, s2), + c.call(f1mPrefix + "_square", s2, s2), + + c.call(f1mPrefix + "_mul", B, C, bc), + c.call(f1mPrefix + "_add", bc, bc, s3), + + c.call(f1mPrefix + "_square", C, s4), + + c.call(mulNonResidueFn, s3, r0), + c.call(f1mPrefix + "_add", s0, r0, r0), + + c.call(mulNonResidueFn, s4, r1), + c.call(f1mPrefix + "_add", s1, r1, r1), + + c.call(f1mPrefix + "_add", s0, s4, r2), + c.call(f1mPrefix + "_sub", s3, r2, r2), + c.call(f1mPrefix + "_add", s2, r2, r2), + c.call(f1mPrefix + "_add", s1, r2, r2), + ); + + } + + + function buildToMontgomery() { + const f = module.addFunction(prefix+"_toMontgomery"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(2*f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + const r2 = c.i32_add(c.getLocal("r"), c.i32_const(2*f1n8)); + + f.addCode( + c.call(f1mPrefix+"_toMontgomery", x0, r0), + c.call(f1mPrefix+"_toMontgomery", x1, r1), + c.call(f1mPrefix+"_toMontgomery", x2, r2) + ); + } + + function buildFromMontgomery() { + const f = module.addFunction(prefix+"_fromMontgomery"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(2*f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + const r2 = c.i32_add(c.getLocal("r"), c.i32_const(2*f1n8)); + + f.addCode( + c.call(f1mPrefix+"_fromMontgomery", x0, r0), + c.call(f1mPrefix+"_fromMontgomery", x1, r1), + c.call(f1mPrefix+"_fromMontgomery", x2, r2) + ); + } + + function buildCopy() { + const f = module.addFunction(prefix+"_copy"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(2*f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + const r2 = c.i32_add(c.getLocal("r"), c.i32_const(2*f1n8)); + + f.addCode( + c.call(f1mPrefix+"_copy", x0, r0), + c.call(f1mPrefix+"_copy", x1, r1), + c.call(f1mPrefix+"_copy", x2, r2), + ); + } + + function buildZero() { + const f = module.addFunction(prefix+"_zero"); + f.addParam("x", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(2*f1n8)); + + f.addCode( + c.call(f1mPrefix+"_zero", x0), + c.call(f1mPrefix+"_zero", x1), + c.call(f1mPrefix+"_zero", x2), + ); + } + + function buildOne() { + const f = module.addFunction(prefix+"_one"); + f.addParam("x", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(2*f1n8)); + + f.addCode( + c.call(f1mPrefix+"_one", x0), + c.call(f1mPrefix+"_zero", x1), + c.call(f1mPrefix+"_zero", x2), + ); + } + + function buildEq() { + const f = module.addFunction(prefix+"_eq"); + f.addParam("x", "i32"); + f.addParam("y", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(2*f1n8)); + const y0 = c.getLocal("y"); + const y1 = c.i32_add(c.getLocal("y"), c.i32_const(f1n8)); + const y2 = c.i32_add(c.getLocal("y"), c.i32_const(2*f1n8)); + + f.addCode( + c.i32_and( + c.i32_and( + c.call(f1mPrefix+"_eq", x0, y0), + c.call(f1mPrefix+"_eq", x1, y1), + ), + c.call(f1mPrefix+"_eq", x2, y2) + ) + ); + } + + function buildIsZero() { + const f = module.addFunction(prefix+"_isZero"); + f.addParam("x", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(2*f1n8)); + + f.addCode( + c.i32_and( + c.i32_and( + c.call(f1mPrefix+"_isZero", x0), + c.call(f1mPrefix+"_isZero", x1) + ), + c.call(f1mPrefix+"_isZero", x2) + ) + ); + } + + function buildInverse() { + const f = module.addFunction(prefix+"_inverse"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(2*f1n8)); + const r0 = c.getLocal("r"); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(f1n8)); + const r2 = c.i32_add(c.getLocal("r"), c.i32_const(2*f1n8)); + + const t0 = c.i32_const(module.alloc(f1n8)); + const t1 = c.i32_const(module.alloc(f1n8)); + const t2 = c.i32_const(module.alloc(f1n8)); + const t3 = c.i32_const(module.alloc(f1n8)); + const t4 = c.i32_const(module.alloc(f1n8)); + const t5 = c.i32_const(module.alloc(f1n8)); + const c0 = c.i32_const(module.alloc(f1n8)); + const c1 = c.i32_const(module.alloc(f1n8)); + const c2 = c.i32_const(module.alloc(f1n8)); + const t6 = c.i32_const(module.alloc(f1n8)); + const AUX = c.i32_const(module.alloc(f1n8)); + + f.addCode( + c.call(f1mPrefix+"_square", x0, t0), + c.call(f1mPrefix+"_square", x1, t1), + c.call(f1mPrefix+"_square", x2, t2), + c.call(f1mPrefix+"_mul", x0, x1, t3), + c.call(f1mPrefix+"_mul", x0, x2, t4), + c.call(f1mPrefix+"_mul", x1, x2, t5), + + c.call(mulNonResidueFn, t5, c0), + c.call(f1mPrefix+"_sub", t0, c0, c0), + + c.call(mulNonResidueFn, t2, c1), + c.call(f1mPrefix+"_sub", c1, t3, c1), + + c.call(f1mPrefix+"_sub", t1, t4, c2), + + c.call(f1mPrefix+"_mul", x2, c1, t6), + c.call(f1mPrefix+"_mul", x1, c2, AUX), + c.call(f1mPrefix+"_add", t6, AUX, t6), + c.call(mulNonResidueFn, t6, t6), + c.call(f1mPrefix+"_mul", x0, c0, AUX), + c.call(f1mPrefix+"_add", AUX, t6, t6), + + c.call(f1mPrefix+"_inverse", t6, t6), + + c.call(f1mPrefix+"_mul", t6, c0, r0), + c.call(f1mPrefix+"_mul", t6, c1, r1), + c.call(f1mPrefix+"_mul", t6, c2, r2) + ); + } + + + function buildSign() { + const f = module.addFunction(prefix+"_sign"); + f.addParam("x", "i32"); + f.addLocal("s", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(2*f1n8)); + + f.addCode( + c.setLocal("s" , c.call( f1mPrefix + "_sign", x2)), + c.if( + c.getLocal("s"), + c.ret(c.getLocal("s")) + ), + c.setLocal("s" , c.call( f1mPrefix + "_sign", x1)), + c.if( + c.getLocal("s"), + c.ret(c.getLocal("s")) + ), + c.ret(c.call( f1mPrefix + "_sign", x0)) + ); + } + + function buildIsOne() { + const f = module.addFunction(prefix+"_isOne"); + f.addParam("x", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(f1n8*2)); + + f.addCode( + c.ret( + c.i32_and( + c.i32_and( + c.call(f1mPrefix + "_isOne", x0), + c.call(f1mPrefix + "_isZero", x1) + ), + c.call(f1mPrefix + "_isZero", x2) + ) + ) + ); + } + + buildIsZero(); + buildIsOne(); + buildZero(); + buildOne(); + buildCopy(); + buildMul(); + buildSquare(); + buildAdd(); + buildSub(); + buildNeg(); + buildSign(); + buildToMontgomery(); + buildFromMontgomery(); + buildEq(); + buildInverse(); + buildTimesScalar(); + buildIsNegative(); + + module.exportFunction(prefix + "_isZero"); + module.exportFunction(prefix + "_isOne"); + module.exportFunction(prefix + "_zero"); + module.exportFunction(prefix + "_one"); + module.exportFunction(prefix + "_copy"); + module.exportFunction(prefix + "_mul"); + module.exportFunction(prefix + "_square"); + module.exportFunction(prefix + "_add"); + module.exportFunction(prefix + "_sub"); + module.exportFunction(prefix + "_neg"); + module.exportFunction(prefix + "_sign"); + module.exportFunction(prefix + "_fromMontgomery"); + module.exportFunction(prefix + "_toMontgomery"); + module.exportFunction(prefix + "_eq"); + module.exportFunction(prefix + "_inverse"); + buildBatchInverse(module, prefix); + buildExp( + module, + prefix + "_exp", + f1n8*3, + prefix + "_mul", + prefix + "_square", + prefix + "_copy", + prefix + "_one" + ); + module.exportFunction(prefix + "_exp"); + module.exportFunction(prefix + "_timesScalar"); + module.exportFunction(prefix + "_batchInverse"); + module.exportFunction(prefix + "_isNegative"); + + return prefix; +}; + +/* + Copyright 2019 0KIMS association. + + This file is part of wasmsnark (Web Assembly zkSnark Prover). + + wasmsnark is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + wasmsnark is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with wasmsnark. If not, see . +*/ + +var build_timesscalarnaf = function buildTimesScalarNAF(module, fnName, elementLen, opAB, opAA, opAmB, opCopy, opInit) { + + const f = module.addFunction(fnName); + f.addParam("base", "i32"); + f.addParam("scalar", "i32"); + f.addParam("scalarLength", "i32"); + f.addParam("r", "i32"); + f.addLocal("old0", "i32"); + f.addLocal("nbits", "i32"); + f.addLocal("i", "i32"); + f.addLocal("last", "i32"); + f.addLocal("cur", "i32"); + f.addLocal("carry", "i32"); + f.addLocal("p", "i32"); + + const c = f.getCodeBuilder(); + + const aux = c.i32_const(module.alloc(elementLen)); + + function getBit(IDX) { + return c.i32_and( + c.i32_shr_u( + c.i32_load( + c.i32_add( + c.getLocal("scalar"), + c.i32_and( + c.i32_shr_u( + IDX, + c.i32_const(3) + ), + c.i32_const(0xFFFFFFFC) + ) + ) + ), + c.i32_and( + IDX, + c.i32_const(0x1F) + ) + ), + c.i32_const(1) + ); + } + + function pushBit(b) { + return [ + ...c.i32_store8( + c.getLocal("p"), + c.i32_const(b) + ), + ...c.setLocal( + "p", + c.i32_add( + c.getLocal("p"), + c.i32_const(1) + ) + ) + ]; + } + + f.addCode( + c.if( + c.i32_eqz(c.getLocal("scalarLength")), + [ + ...c.call(opInit, c.getLocal("r")), + ...c.ret([]) + ] + ), + c.setLocal("nbits", c.i32_shl(c.getLocal("scalarLength"), c.i32_const(3))), + c.setLocal("old0", c.i32_load(c.i32_const(0))), + c.setLocal("p", c.getLocal("old0")), + c.i32_store( + c.i32_const(0), + c.i32_and( + c.i32_add( + c.i32_add( + c.getLocal("old0"), + c.i32_const(32) + ), + c.getLocal("nbits") + ), + c.i32_const(0xFFFFFFF8) + ) + ), + c.setLocal("i", c.i32_const(1)), + + c.setLocal("last",getBit(c.i32_const(0))), + c.setLocal("carry",c.i32_const(0)), + + c.block(c.loop( + c.br_if(1, c.i32_eq( c.getLocal("i"), c.getLocal("nbits"))), + + c.setLocal("cur", getBit(c.getLocal("i"))), + c.if( c.getLocal("last"), + c.if( c.getLocal("cur"), + c.if(c.getLocal("carry"), + [ + ...c.setLocal("last", c.i32_const(0)), + ...c.setLocal("carry", c.i32_const(1)), + ...pushBit(1) + ] + , + [ + ...c.setLocal("last", c.i32_const(0)), + ...c.setLocal("carry", c.i32_const(1)), + ...pushBit(255) + ], + ), + c.if(c.getLocal("carry"), + [ + ...c.setLocal("last", c.i32_const(0)), + ...c.setLocal("carry", c.i32_const(1)), + ...pushBit(255) + ] + , + [ + ...c.setLocal("last", c.i32_const(0)), + ...c.setLocal("carry", c.i32_const(0)), + ...pushBit(1) + ], + ), + ), + c.if( c.getLocal("cur"), + c.if(c.getLocal("carry"), + [ + ...c.setLocal("last", c.i32_const(0)), + ...c.setLocal("carry", c.i32_const(1)), + ...pushBit(0) + ] + , + [ + ...c.setLocal("last", c.i32_const(1)), + ...c.setLocal("carry", c.i32_const(0)), + ...pushBit(0) + ], + ), + c.if(c.getLocal("carry"), + [ + ...c.setLocal("last", c.i32_const(1)), + ...c.setLocal("carry", c.i32_const(0)), + ...pushBit(0) + ] + , + [ + ...c.setLocal("last", c.i32_const(0)), + ...c.setLocal("carry", c.i32_const(0)), + ...pushBit(0) + ], + ), + ) + ), + c.setLocal("i", c.i32_add(c.getLocal("i"), c.i32_const(1))), + c.br(0) + )), + + c.if( c.getLocal("last"), + c.if(c.getLocal("carry"), + [ + ...pushBit(255), + ...pushBit(0), + ...pushBit(1) + ] + , + [ + ...pushBit(1) + ], + ), + c.if(c.getLocal("carry"), + [ + ...pushBit(0), + ...pushBit(1) + ] + ), + ), + + c.setLocal("p", c.i32_sub(c.getLocal("p"), c.i32_const(1))), + + // p already points to the last bit + + c.call(opCopy, c.getLocal("base"), aux), + + c.call(opInit, c.getLocal("r")), + + c.block(c.loop( + + + c.call(opAA, c.getLocal("r"), c.getLocal("r")), + + + c.setLocal("cur", + c.i32_load8_u( + c.getLocal("p") + ) + ), + + c.if( + c.getLocal("cur"), + c.if( + c.i32_eq(c.getLocal("cur"), c.i32_const(1)), + c.call(opAB, c.getLocal("r"), aux, c.getLocal("r")), + c.call(opAmB, c.getLocal("r"), aux, c.getLocal("r")), + ) + ), + + c.br_if(1, c.i32_eq( c.getLocal("old0"), c.getLocal("p"))), + c.setLocal("p", c.i32_sub(c.getLocal("p"), c.i32_const(1))), + c.br(0) + + )), + + c.i32_store( c.i32_const(0), c.getLocal("old0")) + + ); + +}; + +/* + Copyright 2019 0KIMS association. + + This file is part of wasmsnark (Web Assembly zkSnark Prover). + + wasmsnark is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + wasmsnark is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with wasmsnark. If not, see . +*/ + +var build_multiexp = function buildMultiexp(module, prefix, fnName, opAdd, n8b) { + + const n64g = module.modules[prefix].n64; + const n8g = n64g*8; + + function buildGetChunk() { + const f = module.addFunction(fnName + "_getChunk"); + f.addParam("pScalar", "i32"); + f.addParam("scalarSize", "i32"); // Number of bytes of the scalar + f.addParam("startBit", "i32"); // Bit to start extract + f.addParam("chunkSize", "i32"); // Chunk size in bits + f.addLocal("bitsToEnd", "i32"); + f.addLocal("mask", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.setLocal("bitsToEnd", + c.i32_sub( + c.i32_mul( + c.getLocal("scalarSize"), + c.i32_const(8) + ), + c.getLocal("startBit") + ) + ), + c.if( + c.i32_gt_s( + c.getLocal("chunkSize"), + c.getLocal("bitsToEnd") + ), + c.setLocal( + "mask", + c.i32_sub( + c.i32_shl( + c.i32_const(1), + c.getLocal("bitsToEnd") + ), + c.i32_const(1) + ) + ), + c.setLocal( + "mask", + c.i32_sub( + c.i32_shl( + c.i32_const(1), + c.getLocal("chunkSize") + ), + c.i32_const(1) + ) + ) + ), + c.i32_and( + c.i32_shr_u( + c.i32_load( + c.i32_add( + c.getLocal("pScalar"), + c.i32_shr_u( + c.getLocal("startBit"), + c.i32_const(3) + ) + ), + 0, // offset + 0 // align to byte. + ), + c.i32_and( + c.getLocal("startBit"), + c.i32_const(0x7) + ) + ), + c.getLocal("mask") + ) + ); + } + + function buildMutiexpChunk() { + const f = module.addFunction(fnName + "_chunk"); + f.addParam("pBases", "i32"); + f.addParam("pScalars", "i32"); + f.addParam("scalarSize", "i32"); // Number of points + f.addParam("n", "i32"); // Number of points + f.addParam("startBit", "i32"); // bit where it starts the chunk + f.addParam("chunkSize", "i32"); // bit where it starts the chunk + f.addParam("pr", "i32"); + f.addLocal("nChunks", "i32"); + f.addLocal("itScalar", "i32"); + f.addLocal("endScalar", "i32"); + f.addLocal("itBase", "i32"); + f.addLocal("i", "i32"); + f.addLocal("j", "i32"); + f.addLocal("nTable", "i32"); + f.addLocal("pTable", "i32"); + f.addLocal("idx", "i32"); + f.addLocal("pIdxTable", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.if( + c.i32_eqz(c.getLocal("n")), + [ + ...c.call(prefix + "_zero", c.getLocal("pr")), + ...c.ret([]) + ] + ), + + // Allocate memory + + c.setLocal( + "nTable", + c.i32_shl( + c.i32_const(1), + c.getLocal("chunkSize") + ) + ), + c.setLocal("pTable", c.i32_load( c.i32_const(0) )), + c.i32_store( + c.i32_const(0), + c.i32_add( + c.getLocal("pTable"), + c.i32_mul( + c.getLocal("nTable"), + c.i32_const(n8g) + ) + ) + ), + + // Reset Table + c.setLocal("j", c.i32_const(0)), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("j"), + c.getLocal("nTable") + ) + ), + + c.call( + prefix + "_zero", + c.i32_add( + c.getLocal("pTable"), + c.i32_mul( + c.getLocal("j"), + c.i32_const(n8g) + ) + ) + ), + + c.setLocal("j", c.i32_add(c.getLocal("j"), c.i32_const(1))), + c.br(0) + )), + + // Distribute elements + c.setLocal("itBase", c.getLocal("pBases")), + c.setLocal("itScalar", c.getLocal("pScalars")), + c.setLocal("endScalar", + c.i32_add( + c.getLocal("pScalars"), + c.i32_mul( + c.getLocal("n"), + c.getLocal("scalarSize") + ) + ) + ), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("itScalar"), + c.getLocal("endScalar") + ) + ), + + c.setLocal( + "idx", + c.call(fnName + "_getChunk", + c.getLocal("itScalar"), + c.getLocal("scalarSize"), + c.getLocal("startBit"), + c.getLocal("chunkSize") + ) + ), + + c.if( + c.getLocal("idx"), + [ + ...c.setLocal( + "pIdxTable", + c.i32_add( + c.getLocal("pTable"), + c.i32_mul( + c.i32_sub( + c.getLocal("idx"), + c.i32_const(1) + ), + c.i32_const(n8g) + ) + ) + ), + ...c.call( + opAdd, + c.getLocal("pIdxTable"), + c.getLocal("itBase"), + c.getLocal("pIdxTable"), + ) + ] + ), + + c.setLocal("itScalar", c.i32_add(c.getLocal("itScalar"), c.getLocal("scalarSize"))), + c.setLocal("itBase", c.i32_add(c.getLocal("itBase"), c.i32_const(n8b))), + c.br(0) + )), + + c.call(fnName + "_reduceTable", c.getLocal("pTable"), c.getLocal("chunkSize")), + c.call( + prefix + "_copy", + c.getLocal("pTable"), + c.getLocal("pr") + ), + + + c.i32_store( + c.i32_const(0), + c.getLocal("pTable") + ) + + ); + } + + function buildMultiexp() { + const f = module.addFunction(fnName); + f.addParam("pBases", "i32"); + f.addParam("pScalars", "i32"); + f.addParam("scalarSize", "i32"); // Number of points + f.addParam("n", "i32"); // Number of points + f.addParam("pr", "i32"); + f.addLocal("chunkSize", "i32"); + f.addLocal("nChunks", "i32"); + f.addLocal("itScalar", "i32"); + f.addLocal("endScalar", "i32"); + f.addLocal("itBase", "i32"); + f.addLocal("itBit", "i32"); + f.addLocal("i", "i32"); + f.addLocal("j", "i32"); + f.addLocal("nTable", "i32"); + f.addLocal("pTable", "i32"); + f.addLocal("idx", "i32"); + f.addLocal("pIdxTable", "i32"); + + const c = f.getCodeBuilder(); + + const aux = c.i32_const(module.alloc(n8g)); + + const pTSizes = module.alloc([ + 17, 17, 17, 17, 17, 17, 17, 17, + 17, 17, 16, 16, 15, 14, 13, 13, + 12, 11, 10, 9, 8, 7, 7, 6, + 5 , 4, 3, 2, 1, 1, 1, 1 + ]); + + f.addCode( + c.call(prefix + "_zero", c.getLocal("pr")), + c.if( + c.i32_eqz(c.getLocal("n")), + c.ret([]) + ), + c.setLocal("chunkSize", c.i32_load8_u( c.i32_clz(c.getLocal("n")), pTSizes )), + c.setLocal( + "nChunks", + c.i32_add( + c.i32_div_u( + c.i32_sub( + c.i32_shl( + c.getLocal("scalarSize"), + c.i32_const(3) + ), + c.i32_const(1) + ), + c.getLocal("chunkSize") + ), + c.i32_const(1) + ) + ), + + + // Allocate memory + + c.setLocal( + "itBit", + c.i32_mul( + c.i32_sub( + c.getLocal("nChunks"), + c.i32_const(1) + ), + c.getLocal("chunkSize") + ) + ), + c.block(c.loop( + c.br_if( + 1, + c.i32_lt_s( + c.getLocal("itBit"), + c.i32_const(0) + ) + ), + + // Double nChunk times + c.if( + c.i32_eqz(c.call(prefix + "_isZero", c.getLocal("pr"))), + [ + ...c.setLocal("j", c.i32_const(0)), + ...c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("j"), + c.getLocal("chunkSize") + ) + ), + + c.call(prefix + "_double", c.getLocal("pr"), c.getLocal("pr")), + + c.setLocal("j", c.i32_add(c.getLocal("j"), c.i32_const(1))), + c.br(0) + )) + ] + ), + + c.call( + fnName + "_chunk", + c.getLocal("pBases"), + c.getLocal("pScalars"), + c.getLocal("scalarSize"), + c.getLocal("n"), + c.getLocal("itBit"), + c.getLocal("chunkSize"), + aux + ), + + c.call( + prefix + "_add", + c.getLocal("pr"), + aux, + c.getLocal("pr") + ), + c.setLocal("itBit", c.i32_sub(c.getLocal("itBit"), c.getLocal("chunkSize"))), + c.br(0) + )) + ); + } + + function buildReduceTable() { + const f = module.addFunction(fnName + "_reduceTable"); + f.addParam("pTable", "i32"); + f.addParam("p", "i32"); // Number of bits of the table + f.addLocal("half", "i32"); + f.addLocal("it1", "i32"); + f.addLocal("it2", "i32"); + f.addLocal("pAcc", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.if( + c.i32_eq(c.getLocal("p"), c.i32_const(1)), + c.ret([]) + ), + c.setLocal( + "half", + c.i32_shl( + c.i32_const(1), + c.i32_sub( + c.getLocal("p"), + c.i32_const(1) + ) + ) + ), + + c.setLocal("it1", c.getLocal("pTable")), + c.setLocal( + "it2", + c.i32_add( + c.getLocal("pTable"), + c.i32_mul( + c.getLocal("half"), + c.i32_const(n8g) + ) + ) + ), + c.setLocal("pAcc", + c.i32_sub( + c.getLocal("it2"), + c.i32_const(n8g) + ) + ), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("it1"), + c.getLocal("pAcc") + ) + ), + c.call( + prefix + "_add", + c.getLocal("it1"), + c.getLocal("it2"), + c.getLocal("it1") + ), + c.call( + prefix + "_add", + c.getLocal("pAcc"), + c.getLocal("it2"), + c.getLocal("pAcc") + ), + c.setLocal("it1", c.i32_add(c.getLocal("it1"), c.i32_const(n8g))), + c.setLocal("it2", c.i32_add(c.getLocal("it2"), c.i32_const(n8g))), + c.br(0) + )), + + c.call( + fnName + "_reduceTable", + c.getLocal("pTable"), + c.i32_sub( + c.getLocal("p"), + c.i32_const(1) + ) + ), + + c.setLocal("p", c.i32_sub(c.getLocal("p"), c.i32_const(1))), + c.block(c.loop( + c.br_if(1, c.i32_eqz(c.getLocal("p"))), + c.call(prefix + "_double", c.getLocal("pAcc"), c.getLocal("pAcc")), + c.setLocal("p", c.i32_sub(c.getLocal("p"), c.i32_const(1))), + c.br(0) + )), + + c.call(prefix + "_add", c.getLocal("pTable"), c.getLocal("pAcc"), c.getLocal("pTable")) + ); + } + + buildGetChunk(); + buildReduceTable(); + buildMutiexpChunk(); + buildMultiexp(); + + module.exportFunction(fnName); + module.exportFunction(fnName +"_chunk"); + + +}; + +/* + Copyright 2019 0KIMS association. + + This file is part of wasmsnark (Web Assembly zkSnark Prover). + + wasmsnark is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + wasmsnark is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with wasmsnark. If not, see . +*/ + +const buildTimesScalarNAF = build_timesscalarnaf; +//const buildTimesScalar = require("./build_timesscalar"); +const buildBatchConvertion = build_batchconvertion; +const buildMultiexp$1 = build_multiexp; + +var build_curve_jacobian_a0 = function buildCurve(module, prefix, prefixField, pB) { + + + const n64 = module.modules[prefixField].n64; + const n8 = n64*8; + + if (module.modules[prefix]) return prefix; // already builded + module.modules[prefix] = { + n64: n64*3 + }; + + function buildIsZero() { + const f = module.addFunction(prefix + "_isZero"); + f.addParam("p1", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + f.addCode(c.call( + prefixField + "_isZero", + c.i32_add( + c.getLocal("p1"), + c.i32_const(n8*2) + ) + )); + } + function buildIsZeroAffine() { + const f = module.addFunction(prefix + "_isZeroAffine"); + f.addParam("p1", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.i32_and( + c.call( + prefixField + "_isZero", + c.getLocal("p1") + ), + c.call( + prefixField + "_isZero", + c.i32_add( + c.getLocal("p1"), + c.i32_const(n8) + ) + ) + ) + ); + } + + function buildCopy() { + const f = module.addFunction(prefix + "_copy"); + f.addParam("ps", "i32"); + f.addParam("pd", "i32"); + + const c = f.getCodeBuilder(); + + for (let i=0; i. +*/ + +const bigInt$9 = BigIntegerExports$1; +const utils$9 = utils$d; + +var build_fft = function buildFFT(module, prefix, gPrefix, fPrefix, opGtimesF) { + + const n64f = module.modules[fPrefix].n64; + const n8f = n64f*8; + + const n64g = module.modules[gPrefix].n64; + const n8g = n64g*8; + + const q = module.modules[fPrefix].q; + + let rem = q.minus(bigInt$9(1)); + let maxBits = 0; + while (!rem.isOdd()) { + maxBits ++; + rem = rem.shiftRight(1); + } + + let nr = bigInt$9(2); + + while ( nr.modPow(q.shiftRight(1), q).equals(1) ) nr = nr.add(1); + + // console.log(nr); + + const w = new Array(maxBits+1); + w[maxBits] = nr.modPow(rem, q); + + let n=maxBits-1; + while (n>=0) { + w[n] = w[n+1].modPow(2, q); + n--; + } + + const bytes = []; + const R = bigInt$9(1).shiftLeft(n8f*8).mod(q); + + for (let i=0; i> i); + } + } + return r; + } + + const rtable = Array(256); + for (let i=0; i<256; i++) { + rtable[i] = rev(i); + } + + const REVTABLE = module.alloc(rtable); + + + function buildLog2() { + const f = module.addFunction(prefix+"__log2"); + f.addParam("n", "i32"); + f.setReturnType("i32"); + f.addLocal("bits", "i32"); + f.addLocal("aux", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.setLocal( + "aux", + c.i32_shr_u( + c.getLocal("n"), + c.i32_const(1) + ) + ) + ); + f.addCode(c.setLocal("bits", c.i32_const(0))); + + f.addCode(c.block(c.loop( + c.br_if( + 1, + c.i32_eqz(c.getLocal("aux")) + ), + + c.setLocal( + "aux", + c.i32_shr_u( + c.getLocal("aux"), + c.i32_const(1) + ) + ), + + c.setLocal( + "bits", + c.i32_add( + c.getLocal("bits"), + c.i32_const(1) + ) + ), + + c.br(0) + ))); + + f.addCode(c.if( + c.i32_ne( + c.getLocal("n"), + c.i32_shl( + c.i32_const(1), + c.getLocal("bits") + ) + ), + c.unreachable() + )); + + f.addCode(c.if( + c.i32_gt_u( + c.getLocal("bits"), + c.i32_const(maxBits) + ), + c.unreachable() + )); + + f.addCode(c.getLocal("bits")); + } + + function buildFFT() { + const f = module.addFunction(prefix+"_fft"); + f.addParam("px", "i32"); + f.addParam("n", "i32"); + + f.addLocal("bits", "i32"); + + const c = f.getCodeBuilder(); + + const One = c.i32_const(module.alloc(n8f)); + + f.addCode( + c.setLocal( + "bits", + c.call( + prefix + "__log2", + c.getLocal("n") + ) + ), + c.call(fPrefix + "_one", One), + c.call( + prefix+"_rawfft", + c.getLocal("px"), + c.getLocal("bits"), + c.i32_const(0), + One + ) + ); + + } + + function buildIFFT() { + const f = module.addFunction(prefix+"_ifft"); + f.addParam("px", "i32"); + f.addParam("n", "i32"); + f.addLocal("bits", "i32"); + f.addLocal("pInv2", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.setLocal( + "bits", + c.call( + prefix + "__log2", + c.getLocal("n") + ) + ), + c.setLocal( + "pInv2", + c.i32_add( + c.i32_const(INV2), + c.i32_mul( + c.getLocal("bits"), + c.i32_const(n8f) + ) + ) + ), + + c.call( + prefix+"_rawfft", + c.getLocal("px"), + c.getLocal("bits"), + c.i32_const(1), + c.getLocal("pInv2") + ), + ); + } + + function buildRawFFT() { + const f = module.addFunction(prefix+"_rawfft"); + f.addParam("px", "i32"); + f.addParam("bits", "i32"); // 2 power + f.addParam("reverse", "i32"); + f.addParam("mulFactor", "i32"); + + f.addLocal("s", "i32"); + f.addLocal("k", "i32"); + f.addLocal("j", "i32"); + f.addLocal("m", "i32"); + f.addLocal("mdiv2", "i32"); + f.addLocal("n", "i32"); + f.addLocal("pwm", "i32"); + f.addLocal("idx1", "i32"); + f.addLocal("idx2", "i32"); + + const c = f.getCodeBuilder(); + + const W = c.i32_const(module.alloc(n8f)); + const T = c.i32_const(module.alloc(n8g)); + const U = c.i32_const(module.alloc(n8g)); + + f.addCode( + c.call(prefix + "__reversePermutation", c.getLocal("px"), c.getLocal("bits")), + c.setLocal("n", c.i32_shl(c.i32_const(1), c.getLocal("bits"))), + c.setLocal("s", c.i32_const(1)), + c.block(c.loop( + c.br_if( + 1, + c.i32_gt_u( + c.getLocal("s"), + c.getLocal("bits") + ) + ), + c.setLocal("m", c.i32_shl(c.i32_const(1), c.getLocal("s"))), + c.setLocal("pwm", + c.i32_add( + c.i32_const(ROOTs), + c.i32_mul( + c.getLocal("s"), + c.i32_const(n8f) + ) + ) + ), + c.setLocal("k", c.i32_const(0)), + c.block(c.loop( + c.br_if( + 1, + c.i32_ge_u( + c.getLocal("k"), + c.getLocal("n") + ) + ), + + c.call(fPrefix + "_one", W), + + c.setLocal("mdiv2", c.i32_shr_u(c.getLocal("m"), c.i32_const(1)) ), + c.setLocal("j", c.i32_const(0)), + c.block(c.loop( + c.br_if( + 1, + c.i32_ge_u( + c.getLocal("j"), + c.getLocal("mdiv2") + ) + ), + + c.setLocal( + "idx1", + c.i32_add( + c.getLocal("px"), + c.i32_mul( + c.i32_add( + c.getLocal("k"), + c.getLocal("j") + ), + c.i32_const(n8g) + ) + ) + ), + + c.setLocal( + "idx2", + c.i32_add( + c.getLocal("idx1"), + c.i32_mul( + c.getLocal("mdiv2"), + c.i32_const(n8g) + ) + ) + ), + + c.call( + opGtimesF, + c.getLocal("idx2"), + W, + T + ), + + c.call( + gPrefix + "_copy", + c.getLocal("idx1"), + U + ), + + c.call( + gPrefix + "_add", + U, + T, + c.getLocal("idx1"), + ), + + c.call( + gPrefix + "_sub", + U, + T, + c.getLocal("idx2"), + ), + + c.call( + fPrefix + "_mul", + W, + c.getLocal("pwm"), + W, + ), + + c.setLocal("j", c.i32_add(c.getLocal("j"), c.i32_const(1))), + c.br(0) + )), + + c.setLocal("k", c.i32_add(c.getLocal("k"), c.getLocal("m"))), + c.br(0) + )), + + c.setLocal("s", c.i32_add(c.getLocal("s"), c.i32_const(1))), + c.br(0) + )), + c.call( + prefix + "__fftFinal", + c.getLocal("px"), + c.getLocal("bits"), + c.getLocal("reverse"), + c.getLocal("mulFactor") + ) + ); + } + + + function buildFinalInverse() { + const f = module.addFunction(prefix+"__fftFinal"); + f.addParam("px", "i32"); + f.addParam("bits", "i32"); + f.addParam("reverse", "i32"); + f.addParam("mulFactor", "i32"); + f.addLocal("n", "i32"); + f.addLocal("ndiv2", "i32"); + f.addLocal("pInv2", "i32"); + f.addLocal("i", "i32"); + f.addLocal("mask", "i32"); + f.addLocal("idx1", "i32"); + f.addLocal("idx2", "i32"); + + const c = f.getCodeBuilder(); + + const T = c.i32_const(module.alloc(n8g)); + + f.addCode( + c.if( + c.i32_and( + c.i32_eqz(c.getLocal("reverse")), + c.call(fPrefix + "_isOne", c.getLocal("mulFactor")) + ), + c.ret([]) + ), + c.setLocal("n", c.i32_shl( c.i32_const(1), c.getLocal("bits"))), + + c.setLocal("mask", c.i32_sub( c.getLocal("n") , c.i32_const(1))), + c.setLocal("i", c.i32_const(1)), + c.setLocal( + "ndiv2", + c.i32_shr_u( + c.getLocal("n"), + c.i32_const(1) + ) + ), + c.block(c.loop( + c.br_if( + 1, + c.i32_ge_u( + c.getLocal("i"), + c.getLocal("ndiv2") + ) + ), + + c.setLocal("idx1", + c.i32_add( + c.getLocal("px"), + c.i32_mul( + c.getLocal("i"), + c.i32_const(n8g) + ) + ) + ), + + c.setLocal("idx2", + c.i32_add( + c.getLocal("px"), + c.i32_mul( + c.i32_sub( + c.getLocal("n"), + c.getLocal("i") + ), + c.i32_const(n8g) + ) + ) + ), + + c.if( + c.getLocal("reverse"), + c.if( + c.call(fPrefix + "_isOne", c.getLocal("mulFactor")), + [ + ...c.call(gPrefix + "_copy", c.getLocal("idx1"), T), + ...c.call(gPrefix + "_copy", c.getLocal("idx2") , c.getLocal("idx1") ), + ...c.call(gPrefix + "_copy", T , c.getLocal("idx2")), + ], + [ + ...c.call(gPrefix + "_copy", c.getLocal("idx1"), T), + ...c.call(opGtimesF , c.getLocal("idx2") , c.getLocal("mulFactor"), c.getLocal("idx1") ), + ...c.call(opGtimesF , T , c.getLocal("mulFactor"), c.getLocal("idx2")), + ] + ), + c.if( + c.call(fPrefix + "_isOne", c.getLocal("mulFactor")), + [ + // Do nothing (It should not be here) + ], + [ + ...c.call(opGtimesF , c.getLocal("idx1") , c.getLocal("mulFactor"), c.getLocal("idx1") ), + ...c.call(opGtimesF , c.getLocal("idx2") , c.getLocal("mulFactor"), c.getLocal("idx2")), + ] + ) + ), + c.setLocal("i", c.i32_add(c.getLocal("i"), c.i32_const(1))), + + c.br(0) + )), + + c.if( + c.call(fPrefix + "_isOne", c.getLocal("mulFactor")), + [ + // Do nothing (It should not be here) + ], + [ + ...c.call(opGtimesF, c.getLocal("px") , c.getLocal("mulFactor"), c.getLocal("px")), + ...c.setLocal("idx2", + c.i32_add( + c.getLocal("px"), + c.i32_mul( + c.getLocal("ndiv2"), + c.i32_const(n8g) + ) + ) + ), + ...c.call(opGtimesF, c.getLocal("idx2"),c.getLocal("mulFactor"), c.getLocal("idx2")) + ] + ) + ); + } + + function buildReversePermutation() { + const f = module.addFunction(prefix+"__reversePermutation"); + f.addParam("px", "i32"); + f.addParam("bits", "i32"); + f.addLocal("n", "i32"); + f.addLocal("i", "i32"); + f.addLocal("ri", "i32"); + f.addLocal("idx1", "i32"); + f.addLocal("idx2", "i32"); + + const c = f.getCodeBuilder(); + + const T = c.i32_const(module.alloc(n8g)); + + f.addCode( + c.setLocal("n", c.i32_shl( c.i32_const(1), c.getLocal("bits"))), + c.setLocal("i", c.i32_const(0)), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("i"), + c.getLocal("n") + ) + ), + + c.setLocal("idx1", + c.i32_add( + c.getLocal("px"), + c.i32_mul( + c.getLocal("i"), + c.i32_const(n8g) + ) + ) + ), + + c.setLocal("ri", c.call(prefix + "__rev", c.getLocal("i"), c.getLocal("bits"))), + + c.setLocal("idx2", + c.i32_add( + c.getLocal("px"), + c.i32_mul( + c.getLocal("ri"), + c.i32_const(n8g) + ) + ) + ), + + c.if( + c.i32_lt_u( + c.getLocal("i"), + c.getLocal("ri") + ), + [ + ...c.call(gPrefix + "_copy", c.getLocal("idx1"), T), + ...c.call(gPrefix + "_copy", c.getLocal("idx2") , c.getLocal("idx1")), + ...c.call(gPrefix + "_copy", T , c.getLocal("idx2")) + ] + ), + + c.setLocal("i", c.i32_add(c.getLocal("i"), c.i32_const(1))), + + c.br(0) + )) + ); + } + + function buildRev() { + const f = module.addFunction(prefix+"__rev"); + f.addParam("x", "i32"); + f.addParam("bits", "i32"); + f.setReturnType("i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.i32_rotl( + c.i32_add( + c.i32_add( + c.i32_shl( + c.i32_load8_u( + c.i32_and( + c.getLocal("x"), + c.i32_const(0xFF) + ), + REVTABLE, + 0 + ), + c.i32_const(24) + ), + c.i32_shl( + c.i32_load8_u( + c.i32_and( + c.i32_shr_u( + c.getLocal("x"), + c.i32_const(8) + ), + c.i32_const(0xFF) + ), + REVTABLE, + 0 + ), + c.i32_const(16) + ), + ), + c.i32_add( + c.i32_shl( + c.i32_load8_u( + c.i32_and( + c.i32_shr_u( + c.getLocal("x"), + c.i32_const(16) + ), + c.i32_const(0xFF) + ), + REVTABLE, + 0 + ), + c.i32_const(8) + ), + c.i32_load8_u( + c.i32_and( + c.i32_shr_u( + c.getLocal("x"), + c.i32_const(24) + ), + c.i32_const(0xFF) + ), + REVTABLE, + 0 + ), + ) + ), + c.getLocal("bits") + ) + ); + } + + + function buildFFTJoin() { + const f = module.addFunction(prefix+"_fftJoin"); + f.addParam("pBuff1", "i32"); + f.addParam("pBuff2", "i32"); + f.addParam("n", "i32"); + f.addParam("first", "i32"); + f.addParam("inc", "i32"); + f.addLocal("idx1", "i32"); + f.addLocal("idx2", "i32"); + f.addLocal("i", "i32"); + + const c = f.getCodeBuilder(); + + const W = c.i32_const(module.alloc(n8f)); + const T = c.i32_const(module.alloc(n8g)); + const U = c.i32_const(module.alloc(n8g)); + + f.addCode( + c.call( fPrefix + "_copy", c.getLocal("first"), W), + c.setLocal("i", c.i32_const(0)), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("i"), + c.getLocal("n") + ) + ), + + c.setLocal( + "idx1", + c.i32_add( + c.getLocal("pBuff1"), + c.i32_mul( + c.getLocal("i"), + c.i32_const(n8g) + ) + ) + ), + + c.setLocal( + "idx2", + c.i32_add( + c.getLocal("pBuff2"), + c.i32_mul( + c.getLocal("i"), + c.i32_const(n8g) + ) + ) + ), + + c.call( + opGtimesF, + c.getLocal("idx2"), + W, + T + ), + + c.call( + gPrefix + "_copy", + c.getLocal("idx1"), + U + ), + + c.call( + gPrefix + "_add", + U, + T, + c.getLocal("idx1"), + ), + + c.call( + gPrefix + "_sub", + U, + T, + c.getLocal("idx2"), + ), + + c.call( + fPrefix + "_mul", + W, + c.getLocal("inc"), + W, + ), + + c.setLocal("i", c.i32_add(c.getLocal("i"), c.i32_const(1))), + c.br(0) + )) + ); + } + + + function buildFFTJoinExt() { + const f = module.addFunction(prefix+"_fftJoinExt"); + f.addParam("pBuff1", "i32"); + f.addParam("pBuff2", "i32"); + f.addParam("n", "i32"); + f.addParam("first", "i32"); + f.addParam("inc", "i32"); + f.addParam("totalBits", "i32"); + f.addLocal("idx1", "i32"); + f.addLocal("idx2", "i32"); + f.addLocal("i", "i32"); + f.addLocal("pShiftToM", "i32"); + + const c = f.getCodeBuilder(); + + const W = c.i32_const(module.alloc(n8f)); + const U = c.i32_const(module.alloc(n8g)); + + f.addCode( + + c.setLocal("pShiftToM", + c.i32_add( + c.i32_const(SHIFT_TO_M), + c.i32_mul( + c.getLocal("totalBits"), + c.i32_const(n8f) + ) + ) + ), + + + c.call( fPrefix + "_copy", c.getLocal("first"), W), + c.setLocal("i", c.i32_const(0)), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("i"), + c.getLocal("n") + ) + ), + + c.setLocal( + "idx1", + c.i32_add( + c.getLocal("pBuff1"), + c.i32_mul( + c.getLocal("i"), + c.i32_const(n8g) + ) + ) + ), + + c.setLocal( + "idx2", + c.i32_add( + c.getLocal("pBuff2"), + c.i32_mul( + c.getLocal("i"), + c.i32_const(n8g) + ) + ) + ), + + c.call( + gPrefix + "_add", + c.getLocal("idx1"), + c.getLocal("idx2"), + U + ), + + c.call( + opGtimesF, + c.getLocal("idx2"), + c.getLocal("pShiftToM"), + c.getLocal("idx2") + ), + + c.call( + gPrefix + "_add", + c.getLocal("idx1"), + c.getLocal("idx2"), + c.getLocal("idx2") + ), + + c.call( + opGtimesF, + c.getLocal("idx2"), + W, + c.getLocal("idx2"), + ), + + c.call( + gPrefix + "_copy", + U, + c.getLocal("idx1") + ), + + c.call( + fPrefix + "_mul", + W, + c.getLocal("inc"), + W + ), + + c.setLocal("i", c.i32_add(c.getLocal("i"), c.i32_const(1))), + c.br(0) + )) + ); + } + + function buildFFTJoinExtInv() { + const f = module.addFunction(prefix+"_fftJoinExtInv"); + f.addParam("pBuff1", "i32"); + f.addParam("pBuff2", "i32"); + f.addParam("n", "i32"); + f.addParam("first", "i32"); + f.addParam("inc", "i32"); + f.addParam("totalBits", "i32"); + f.addLocal("idx1", "i32"); + f.addLocal("idx2", "i32"); + f.addLocal("i", "i32"); + f.addLocal("pShiftToM", "i32"); + f.addLocal("pSConst", "i32"); + + const c = f.getCodeBuilder(); + + const W = c.i32_const(module.alloc(n8f)); + const U = c.i32_const(module.alloc(n8g)); + + f.addCode( + + c.setLocal("pShiftToM", + c.i32_add( + c.i32_const(SHIFT_TO_M), + c.i32_mul( + c.getLocal("totalBits"), + c.i32_const(n8f) + ) + ) + ), + c.setLocal("pSConst", + c.i32_add( + c.i32_const(SCONST), + c.i32_mul( + c.getLocal("totalBits"), + c.i32_const(n8f) + ) + ) + ), + + + c.call( fPrefix + "_copy", c.getLocal("first"), W), + c.setLocal("i", c.i32_const(0)), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("i"), + c.getLocal("n") + ) + ), + + c.setLocal( + "idx1", + c.i32_add( + c.getLocal("pBuff1"), + c.i32_mul( + c.getLocal("i"), + c.i32_const(n8g) + ) + ) + ), + + c.setLocal( + "idx2", + c.i32_add( + c.getLocal("pBuff2"), + c.i32_mul( + c.getLocal("i"), + c.i32_const(n8g) + ) + ) + ), + + c.call( + opGtimesF, + c.getLocal("idx2"), + W, + U + ), + + c.call( + gPrefix + "_sub", + c.getLocal("idx1"), + U, + c.getLocal("idx2"), + ), + + c.call( + opGtimesF, + c.getLocal("idx2"), + c.getLocal("pSConst"), + c.getLocal("idx2") + ), + + c.call( + opGtimesF, + c.getLocal("idx1"), + c.getLocal("pShiftToM"), + c.getLocal("idx1") + ), + + c.call( + gPrefix + "_sub", + U, + c.getLocal("idx1"), + c.getLocal("idx1") + ), + + c.call( + opGtimesF, + c.getLocal("idx1"), + c.getLocal("pSConst"), + c.getLocal("idx1") + ), + + c.call( + fPrefix + "_mul", + W, + c.getLocal("inc"), + W + ), + + c.setLocal("i", c.i32_add(c.getLocal("i"), c.i32_const(1))), + c.br(0) + )) + ); + } + + + + function buildPrepareLagrangeEvaluation() { + const f = module.addFunction(prefix+"_prepareLagrangeEvaluation"); + f.addParam("pBuff1", "i32"); + f.addParam("pBuff2", "i32"); + f.addParam("n", "i32"); + f.addParam("first", "i32"); + f.addParam("inc", "i32"); + f.addParam("totalBits", "i32"); + f.addLocal("idx1", "i32"); + f.addLocal("idx2", "i32"); + f.addLocal("i", "i32"); + f.addLocal("pShiftToM", "i32"); + f.addLocal("pSConst", "i32"); + + const c = f.getCodeBuilder(); + + const W = c.i32_const(module.alloc(n8f)); + const U = c.i32_const(module.alloc(n8g)); + + f.addCode( + + c.setLocal("pShiftToM", + c.i32_add( + c.i32_const(SHIFT_TO_M), + c.i32_mul( + c.getLocal("totalBits"), + c.i32_const(n8f) + ) + ) + ), + c.setLocal("pSConst", + c.i32_add( + c.i32_const(SCONST), + c.i32_mul( + c.getLocal("totalBits"), + c.i32_const(n8f) + ) + ) + ), + + + c.call( fPrefix + "_copy", c.getLocal("first"), W), + c.setLocal("i", c.i32_const(0)), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("i"), + c.getLocal("n") + ) + ), + + c.setLocal( + "idx1", + c.i32_add( + c.getLocal("pBuff1"), + c.i32_mul( + c.getLocal("i"), + c.i32_const(n8g) + ) + ) + ), + + c.setLocal( + "idx2", + c.i32_add( + c.getLocal("pBuff2"), + c.i32_mul( + c.getLocal("i"), + c.i32_const(n8g) + ) + ) + ), + + + c.call( + opGtimesF, + c.getLocal("idx1"), + c.getLocal("pShiftToM"), + U + ), + + c.call( + gPrefix + "_sub", + c.getLocal("idx2"), + U, + U + ), + + c.call( + gPrefix + "_sub", + c.getLocal("idx1"), + c.getLocal("idx2"), + c.getLocal("idx2"), + ), + + c.call( + opGtimesF, + U, + c.getLocal("pSConst"), + c.getLocal("idx1"), + ), + + c.call( + opGtimesF, + c.getLocal("idx2"), + W, + c.getLocal("idx2"), + ), + + c.call( + fPrefix + "_mul", + W, + c.getLocal("inc"), + W + ), + + c.setLocal("i", c.i32_add(c.getLocal("i"), c.i32_const(1))), + c.br(0) + )) + ); + } + + function buildFFTMix() { + const f = module.addFunction(prefix+"_fftMix"); + f.addParam("pBuff", "i32"); + f.addParam("n", "i32"); + f.addParam("exp", "i32"); + f.addLocal("nGroups", "i32"); + f.addLocal("nPerGroup", "i32"); + f.addLocal("nPerGroupDiv2", "i32"); + f.addLocal("pairOffset", "i32"); + f.addLocal("idx1", "i32"); + f.addLocal("idx2", "i32"); + f.addLocal("i", "i32"); + f.addLocal("j", "i32"); + f.addLocal("pwm", "i32"); + + const c = f.getCodeBuilder(); + + const W = c.i32_const(module.alloc(n8f)); + const T = c.i32_const(module.alloc(n8g)); + const U = c.i32_const(module.alloc(n8g)); + + f.addCode( + c.setLocal("nPerGroup", c.i32_shl(c.i32_const(1), c.getLocal("exp"))), + c.setLocal("nPerGroupDiv2", c.i32_shr_u(c.getLocal("nPerGroup"), c.i32_const(1))), + c.setLocal("nGroups", c.i32_shr_u(c.getLocal("n"), c.getLocal("exp"))), + c.setLocal("pairOffset", c.i32_mul(c.getLocal("nPerGroupDiv2"), c.i32_const(n8g))), + c.setLocal("pwm", + c.i32_add( + c.i32_const(ROOTs), + c.i32_mul( + c.getLocal("exp"), + c.i32_const(n8f) + ) + ) + ), + c.setLocal("i", c.i32_const(0)), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("i"), + c.getLocal("nGroups") + ) + ), + c.call( fPrefix + "_one", W), + c.setLocal("j", c.i32_const(0)), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("j"), + c.getLocal("nPerGroupDiv2") + ) + ), + + c.setLocal( + "idx1", + c.i32_add( + c.getLocal("pBuff"), + c.i32_mul( + c.i32_add( + c.i32_mul( + c.getLocal("i"), + c.getLocal("nPerGroup") + ), + c.getLocal("j") + ), + c.i32_const(n8g) + ) + ) + ), + + c.setLocal( + "idx2", + c.i32_add( + c.getLocal("idx1"), + c.getLocal("pairOffset") + ) + ), + + c.call( + opGtimesF, + c.getLocal("idx2"), + W, + T + ), + + c.call( + gPrefix + "_copy", + c.getLocal("idx1"), + U + ), + + c.call( + gPrefix + "_add", + U, + T, + c.getLocal("idx1"), + ), + + c.call( + gPrefix + "_sub", + U, + T, + c.getLocal("idx2"), + ), + + c.call( + fPrefix + "_mul", + W, + c.getLocal("pwm"), + W, + ), + c.setLocal("j", c.i32_add(c.getLocal("j"), c.i32_const(1))), + c.br(0) + )), + c.setLocal("i", c.i32_add(c.getLocal("i"), c.i32_const(1))), + c.br(0) + )) + ); + } + + + // Reverse all and multiply by factor + function buildFFTFinal() { + const f = module.addFunction(prefix+"_fftFinal"); + f.addParam("pBuff", "i32"); + f.addParam("n", "i32"); + f.addParam("factor", "i32"); + f.addLocal("idx1", "i32"); + f.addLocal("idx2", "i32"); + f.addLocal("i", "i32"); + f.addLocal("ndiv2", "i32"); + + const c = f.getCodeBuilder(); + + const T = c.i32_const(module.alloc(n8g)); + + f.addCode( + c.setLocal("ndiv2", c.i32_shr_u(c.getLocal("n"), c.i32_const(1))), + c.if( + c.i32_and( + c.getLocal("n"), + c.i32_const(1) + ), + c.call( + opGtimesF, + c.i32_add( + c.getLocal("pBuff"), + c.i32_mul( + c.getLocal("ndiv2"), + c.i32_const(n8g) + ) + ), + c.getLocal("factor"), + c.i32_add( + c.getLocal("pBuff"), + c.i32_mul( + c.getLocal("ndiv2"), + c.i32_const(n8g) + ) + ), + ), + ), + c.setLocal("i", c.i32_const(0)), + c.block(c.loop( + c.br_if( + 1, + c.i32_ge_u( + c.getLocal("i"), + c.getLocal("ndiv2") + ) + ), + + c.setLocal( + "idx1", + c.i32_add( + c.getLocal("pBuff"), + c.i32_mul( + c.getLocal("i"), + c.i32_const(n8g) + ) + ) + ), + + c.setLocal( + "idx2", + c.i32_add( + c.getLocal("pBuff"), + c.i32_mul( + c.i32_sub( + c.i32_sub( + c.getLocal("n"), + c.i32_const(1) + ), + c.getLocal("i") + ), + c.i32_const(n8g) + ) + ) + ), + + c.call( + opGtimesF, + c.getLocal("idx2"), + c.getLocal("factor"), + T + ), + + c.call( + opGtimesF, + c.getLocal("idx1"), + c.getLocal("factor"), + c.getLocal("idx2"), + ), + + c.call( + gPrefix + "_copy", + T, + c.getLocal("idx1"), + ), + + c.setLocal("i", c.i32_add(c.getLocal("i"), c.i32_const(1))), + c.br(0) + )) + ); + } + + buildRev(); + buildReversePermutation(); + buildFinalInverse(); + buildRawFFT(); + buildLog2(); + buildFFT(); + buildIFFT(); + buildFFTJoin(); + buildFFTJoinExt(); + buildFFTJoinExtInv(); + buildFFTMix(); + buildFFTFinal(); + buildPrepareLagrangeEvaluation(); + + module.exportFunction(prefix+"_fft"); + module.exportFunction(prefix+"_ifft"); + module.exportFunction(prefix+"_rawfft"); + module.exportFunction(prefix+"_fftJoin"); + module.exportFunction(prefix+"_fftJoinExt"); + module.exportFunction(prefix+"_fftJoinExtInv"); + module.exportFunction(prefix+"_fftMix"); + module.exportFunction(prefix+"_fftFinal"); + module.exportFunction(prefix+"_prepareLagrangeEvaluation"); + +}; + +/* + Copyright 2019 0KIMS association. + + This file is part of wasmsnark (Web Assembly zkSnark Prover). + + wasmsnark is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + wasmsnark is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with wasmsnark. If not, see . +*/ + +var build_pol = function buildPol(module, prefix, prefixField) { + + const n64 = module.modules[prefixField].n64; + const n8 = n64*8; + + + function buildZero() { + const f = module.addFunction(prefix+"_zero"); + f.addParam("px", "i32"); + f.addParam("n", "i32"); + f.addLocal("lastp", "i32"); + f.addLocal("p", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.setLocal("p", c.getLocal("px")), + c.setLocal( + "lastp", + c.i32_add( + c.getLocal("px"), + c.i32_mul( + c.getLocal("n"), + c.i32_const(n8) + ) + ) + ), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("p"), + c.getLocal("lastp") + ) + ), + c.call(prefixField + "_zero", c.getLocal("p")), + c.setLocal("p", c.i32_add(c.getLocal("p"), c.i32_const(n8))), + c.br(0) + )) + ); + } + + function buildConstructLC() { + const f = module.addFunction(prefix+"_constructLC"); + f.addParam("ppolynomials", "i32"); + f.addParam("psignals", "i32"); + f.addParam("nSignals", "i32"); + f.addParam("pres", "i32"); + f.addLocal("i", "i32"); + f.addLocal("j", "i32"); + f.addLocal("pp", "i32"); + f.addLocal("ps", "i32"); + f.addLocal("pd", "i32"); + f.addLocal("ncoefs", "i32"); + + const c = f.getCodeBuilder(); + + const aux = c.i32_const(module.alloc(n8)); + + f.addCode( + c.setLocal("i", c.i32_const(0)), + c.setLocal("pp", c.getLocal("ppolynomials")), + c.setLocal("ps", c.getLocal("psignals")), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("i"), + c.getLocal("nSignals") + ) + ), + + c.setLocal("ncoefs", c.i32_load(c.getLocal("pp"))), + c.setLocal("pp", c.i32_add(c.getLocal("pp"), c.i32_const(4))), + + c.setLocal("j", c.i32_const(0)), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("j"), + c.getLocal("ncoefs") + ) + ), + + c.setLocal( + "pd", + c.i32_add( + c.getLocal("pres"), + c.i32_mul( + c.i32_load(c.getLocal("pp")), + c.i32_const(n8) + ) + ) + ), + + c.setLocal("pp", c.i32_add(c.getLocal("pp"), c.i32_const(4))), + + + c.call( + prefixField + "_mul", + c.getLocal("ps"), + c.getLocal("pp"), + aux + ), + + c.call( + prefixField + "_add", + aux, + c.getLocal("pd"), + c.getLocal("pd") + ), + + c.setLocal("pp", c.i32_add(c.getLocal("pp"), c.i32_const(n8))), + c.setLocal("j", c.i32_add(c.getLocal("j"), c.i32_const(1))), + c.br(0) + )), + + c.setLocal("ps", c.i32_add(c.getLocal("ps"), c.i32_const(n8))), + c.setLocal("i", c.i32_add(c.getLocal("i"), c.i32_const(1))), + c.br(0) + )) + ); + + } + + buildZero(); + buildConstructLC(); + + + module.exportFunction(prefix + "_zero"); + module.exportFunction(prefix + "_constructLC"); + + return prefix; + + + + +}; + +var build_qap = function buildQAP(module, prefix, prefixField) { + + const n64 = module.modules[prefixField].n64; + const n8 = n64*8; + + + function buildBuildABC() { + const f = module.addFunction(prefix+"_buildABC"); + f.addParam("pCoefs", "i32"); + f.addParam("nCoefs", "i32"); + f.addParam("pWitness", "i32"); + f.addParam("pA", "i32"); + f.addParam("pB", "i32"); + f.addParam("pC", "i32"); + f.addParam("offsetOut", "i32"); + f.addParam("nOut", "i32"); + f.addParam("offsetWitness", "i32"); + f.addParam("nWitness", "i32"); + f.addLocal("it", "i32"); + f.addLocal("ita", "i32"); + f.addLocal("itb", "i32"); + f.addLocal("last", "i32"); + f.addLocal("m", "i32"); + f.addLocal("c", "i32"); + f.addLocal("s", "i32"); + f.addLocal("pOut", "i32"); + + const c = f.getCodeBuilder(); + + const aux = c.i32_const(module.alloc(n8)); + + f.addCode( + + // Set output a and b to 0 + c.setLocal("ita", c.getLocal("pA")), + c.setLocal("itb", c.getLocal("pB")), + c.setLocal( + "last", + c.i32_add( + c.getLocal("pA"), + c.i32_mul( + c.getLocal("nOut"), + c.i32_const(n8) + ) + ) + ), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("ita"), + c.getLocal("last") + ) + ), + c.call(prefixField + "_zero", c.getLocal("ita")), + c.call(prefixField + "_zero", c.getLocal("itb")), + c.setLocal("ita", c.i32_add(c.getLocal("ita"), c.i32_const(n8))), + c.setLocal("itb", c.i32_add(c.getLocal("itb"), c.i32_const(n8))), + c.br(0) + )), + + + c.setLocal("it", c.getLocal("pCoefs")), + c.setLocal( + "last", + c.i32_add( + c.getLocal("pCoefs"), + c.i32_mul( + c.getLocal("nCoefs"), + c.i32_const(n8+12) + ) + ) + ), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("it"), + c.getLocal("last") + ) + ), + c.setLocal( + "s", + c.i32_load(c.getLocal("it"), 8) + ), + c.if( + c.i32_or( + c.i32_lt_u( + c.getLocal("s"), + c.getLocal("offsetWitness"), + ), + c.i32_ge_u( + c.getLocal("s"), + c.i32_add( + c.getLocal("offsetWitness"), + c.getLocal("nWitness"), + ) + ) + ), + [ + ...c.setLocal("it", c.i32_add(c.getLocal("it"), c.i32_const(n8+12))), + ...c.br(1) + ] + ), + + c.setLocal( + "m", + c.i32_load(c.getLocal("it")) + ), + c.if( + c.i32_eq(c.getLocal("m"), c.i32_const(0)), + c.setLocal("pOut", c.getLocal("pA")), + c.if( + c.i32_eq(c.getLocal("m"), c.i32_const(1)), + c.setLocal("pOut", c.getLocal("pB")), + [ + ...c.setLocal("it", c.i32_add(c.getLocal("it"), c.i32_const(n8+12))), + ...c.br(1) + ] + ) + ), + c.setLocal( + "c", + c.i32_load(c.getLocal("it"), 4) + ), + c.if( + c.i32_or( + c.i32_lt_u( + c.getLocal("c"), + c.getLocal("offsetOut"), + ), + c.i32_ge_u( + c.getLocal("c"), + c.i32_add( + c.getLocal("offsetOut"), + c.getLocal("nOut"), + ) + ) + ), + [ + ...c.setLocal("it", c.i32_add(c.getLocal("it"), c.i32_const(n8+12))), + ...c.br(1) + ] + ), + c.setLocal( + "pOut", + c.i32_add( + c.getLocal("pOut"), + c.i32_mul( + c.i32_sub( + c.getLocal("c"), + c.getLocal("offsetOut") + ), + c.i32_const(n8) + ) + ) + ), + c.call( + prefixField + "_mul", + c.i32_add( + c.getLocal("pWitness"), + c.i32_mul( + c.i32_sub(c.getLocal("s"), c.getLocal("offsetWitness")), + c.i32_const(n8) + ) + ), + c.i32_add( c.getLocal("it"), c.i32_const(12)), + aux + ), + c.call( + prefixField + "_add", + c.getLocal("pOut"), + aux, + c.getLocal("pOut"), + ), + c.setLocal("it", c.i32_add(c.getLocal("it"), c.i32_const(n8+12))), + c.br(0) + )), + + c.setLocal("ita", c.getLocal("pA")), + c.setLocal("itb", c.getLocal("pB")), + c.setLocal("it", c.getLocal("pC")), + c.setLocal( + "last", + c.i32_add( + c.getLocal("pA"), + c.i32_mul( + c.getLocal("nOut"), + c.i32_const(n8) + ) + ) + ), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("ita"), + c.getLocal("last") + ) + ), + c.call( + prefixField + "_mul", + c.getLocal("ita"), + c.getLocal("itb"), + c.getLocal("it") + ), + c.setLocal("ita", c.i32_add(c.getLocal("ita"), c.i32_const(n8))), + c.setLocal("itb", c.i32_add(c.getLocal("itb"), c.i32_const(n8))), + c.setLocal("it", c.i32_add(c.getLocal("it"), c.i32_const(n8))), + c.br(0) + )), + + ); + } + + function buildJoinABC() { + const f = module.addFunction(prefix+"_joinABC"); + f.addParam("pA", "i32"); + f.addParam("pB", "i32"); + f.addParam("pC", "i32"); + f.addParam("n", "i32"); + f.addParam("pP", "i32"); + f.addLocal("ita", "i32"); + f.addLocal("itb", "i32"); + f.addLocal("itc", "i32"); + f.addLocal("itp", "i32"); + f.addLocal("last", "i32"); + + const c = f.getCodeBuilder(); + + const aux = c.i32_const(module.alloc(n8)); + + f.addCode( + c.setLocal("ita", c.getLocal("pA")), + c.setLocal("itb", c.getLocal("pB")), + c.setLocal("itc", c.getLocal("pC")), + c.setLocal("itp", c.getLocal("pP")), + c.setLocal( + "last", + c.i32_add( + c.getLocal("pA"), + c.i32_mul( + c.getLocal("n"), + c.i32_const(n8) + ) + ) + ), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("ita"), + c.getLocal("last") + ) + ), + c.call( + prefixField + "_mul", + c.getLocal("ita"), + c.getLocal("itb"), + aux + ), + c.call( + prefixField + "_sub", + aux, + c.getLocal("itc"), + c.getLocal("itp"), + ), + c.setLocal("ita", c.i32_add(c.getLocal("ita"), c.i32_const(n8))), + c.setLocal("itb", c.i32_add(c.getLocal("itb"), c.i32_const(n8))), + c.setLocal("itc", c.i32_add(c.getLocal("itc"), c.i32_const(n8))), + c.setLocal("itp", c.i32_add(c.getLocal("itp"), c.i32_const(n8))), + c.br(0) + )) + ); + } + + function buildBatchAdd() { + const f = module.addFunction(prefix+"_batchAdd"); + f.addParam("pa", "i32"); + f.addParam("pb", "i32"); + f.addParam("n", "i32"); + f.addParam("pr", "i32"); + f.addLocal("ita", "i32"); + f.addLocal("itb", "i32"); + f.addLocal("itr", "i32"); + f.addLocal("last", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.setLocal("ita", c.getLocal("pa")), + c.setLocal("itb", c.getLocal("pb")), + c.setLocal("itr", c.getLocal("pr")), + c.setLocal( + "last", + c.i32_add( + c.getLocal("pa"), + c.i32_mul( + c.getLocal("n"), + c.i32_const(n8) + ) + ) + ), + c.block(c.loop( + c.br_if( + 1, + c.i32_eq( + c.getLocal("ita"), + c.getLocal("last") + ) + ), + c.call( + prefixField + "_add", + c.getLocal("ita"), + c.getLocal("itb"), + c.getLocal("itr"), + ), + c.setLocal("ita", c.i32_add(c.getLocal("ita"), c.i32_const(n8))), + c.setLocal("itb", c.i32_add(c.getLocal("itb"), c.i32_const(n8))), + c.setLocal("itr", c.i32_add(c.getLocal("itr"), c.i32_const(n8))), + c.br(0) + )) + ); + } + + buildBuildABC(); + buildJoinABC(); + buildBatchAdd(); + + module.exportFunction(prefix + "_buildABC"); + module.exportFunction(prefix + "_joinABC"); + module.exportFunction(prefix + "_batchAdd"); + + return prefix; + +}; + +/* + Copyright 2019 0KIMS association. + + This file is part of wasmsnark (Web Assembly zkSnark Prover). + + wasmsnark is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + wasmsnark is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with wasmsnark. If not, see . +*/ + +var build_applykey = function buildApplyKey(module, fnName, gPrefix, frPrefix, sizeGIn, sizeGOut, sizeF, opGtimesF) { + + const f = module.addFunction(fnName); + f.addParam("pIn", "i32"); + f.addParam("n", "i32"); + f.addParam("pFirst", "i32"); + f.addParam("pInc", "i32"); + f.addParam("pOut", "i32"); + f.addLocal("pOldFree", "i32"); + f.addLocal("i", "i32"); + f.addLocal("pFrom", "i32"); + f.addLocal("pTo", "i32"); + + const c = f.getCodeBuilder(); + + const t = c.i32_const(module.alloc(sizeF)); + + f.addCode( + c.setLocal("pFrom", c.getLocal("pIn")), + c.setLocal("pTo", c.getLocal("pOut")), + ); + + // t = first + f.addCode( + c.call( + frPrefix + "_copy", + c.getLocal("pFirst"), + t + ) + ); + f.addCode( + c.setLocal("i", c.i32_const(0)), + c.block(c.loop( + c.br_if(1, c.i32_eq ( c.getLocal("i"), c.getLocal("n") )), + + c.call( + opGtimesF, + c.getLocal("pFrom"), + t, + c.getLocal("pTo") + ), + c.setLocal("pFrom", c.i32_add(c.getLocal("pFrom"), c.i32_const(sizeGIn))), + c.setLocal("pTo", c.i32_add(c.getLocal("pTo"), c.i32_const(sizeGOut))), + + // t = t* inc + c.call( + frPrefix + "_mul", + t, + c.getLocal("pInc"), + t + ), + c.setLocal("i", c.i32_add(c.getLocal("i"), c.i32_const(1))), + c.br(0) + )) + ); + + module.exportFunction(fnName); + +}; + +const bigInt$8 = BigIntegerExports$1; +const utils$8 = utils$d; + +const buildF1m$1 =build_f1m; +const buildF1$1 =build_f1; +const buildF2m$1 =build_f2m; +const buildF3m$1 =build_f3m; +const buildCurve$1 =build_curve_jacobian_a0; +const buildFFT$2 = build_fft; +const buildPol$1 = build_pol; +const buildQAP$1 = build_qap; +const buildApplyKey$1 = build_applykey; + +var build_bn128 = function buildBN128(module, _prefix) { + + const prefix = _prefix || "bn128"; + + if (module.modules[prefix]) return prefix; // already builded + + const q = bigInt$8("21888242871839275222246405745257275088696311157297823662689037894645226208583"); + const r = bigInt$8("21888242871839275222246405745257275088548364400416034343698204186575808495617"); + + + const n64 = Math.floor((q.minus(1).bitLength() - 1)/64) +1; + const n8 = n64*8; + const frsize = n8; + const f1size = n8; + const f2size = f1size * 2; + const ftsize = f1size * 12; + + const pr = module.alloc(utils$8.bigInt2BytesLE( r, frsize )); + + const f1mPrefix = buildF1m$1(module, q, "f1m"); + buildF1$1(module, r, "fr", "frm"); + + const pG1b = module.alloc(utils$8.bigInt2BytesLE( toMontgomery(bigInt$8(3)), f1size )); + const g1mPrefix = buildCurve$1(module, "g1m", "f1m", pG1b); + + buildFFT$2(module, "frm", "frm", "frm", "frm_mul"); + + buildPol$1(module, "pol", "frm"); + buildQAP$1(module, "qap", "frm"); + + const f2mPrefix = buildF2m$1(module, "f1m_neg", "f2m", "f1m"); + const pG2b = module.alloc([ + ...utils$8.bigInt2BytesLE( toMontgomery(bigInt$8("19485874751759354771024239261021720505790618469301721065564631296452457478373")), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(bigInt$8("266929791119991161246907387137283842545076965332900288569378510910307636690")), f1size ) + ]); + const g2mPrefix = buildCurve$1(module, "g2m", "f2m", pG2b); + + + function buildGTimesFr(fnName, opMul) { + const f = module.addFunction(fnName); + f.addParam("pG", "i32"); + f.addParam("pFr", "i32"); + f.addParam("pr", "i32"); + + const c = f.getCodeBuilder(); + + const AUX = c.i32_const(module.alloc(n8)); + + f.addCode( + c.call("frm_fromMontgomery", c.getLocal("pFr"), AUX), + c.call( + opMul, + c.getLocal("pG"), + AUX, + c.i32_const(n8), + c.getLocal("pr") + ) + ); + + module.exportFunction(fnName); + } + buildGTimesFr("g1m_timesFr", "g1m_timesScalar"); + buildFFT$2(module, "g1m", "g1m", "frm", "g1m_timesFr"); + + buildGTimesFr("g2m_timesFr", "g2m_timesScalar"); + buildFFT$2(module, "g2m", "g2m", "frm", "g2m_timesFr"); + + buildGTimesFr("g1m_timesFrAffine", "g1m_timesScalarAffine"); + buildGTimesFr("g2m_timesFrAffine", "g2m_timesScalarAffine"); + + buildApplyKey$1(module, "frm_batchApplyKey", "fmr", "frm", n8, n8, n8, "frm_mul"); + buildApplyKey$1(module, "g1m_batchApplyKey", "g1m", "frm", n8*3, n8*3, n8, "g1m_timesFr"); + buildApplyKey$1(module, "g1m_batchApplyKeyMixed", "g1m", "frm", n8*2, n8*3, n8, "g1m_timesFrAffine"); + buildApplyKey$1(module, "g2m_batchApplyKey", "g2m", "frm", n8*2*3, n8*3*2, n8, "g2m_timesFr"); + buildApplyKey$1(module, "g2m_batchApplyKeyMixed", "g2m", "frm", n8*2*2, n8*3*2, n8, "g2m_timesFrAffine"); + + function toMontgomery(a) { + return bigInt$8(a).times( bigInt$8.one.shiftLeft(f1size*8)).mod(q); + } + + const G1gen = [ + bigInt$8("1"), + bigInt$8("2"), + bigInt$8.one + ]; + + const pG1gen = module.alloc( + [ + ...utils$8.bigInt2BytesLE( toMontgomery(G1gen[0]), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(G1gen[1]), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(G1gen[2]), f1size ), + ] + ); + + const G1zero = [ + bigInt$8.zero, + bigInt$8.one, + bigInt$8.zero + ]; + + const pG1zero = module.alloc( + [ + ...utils$8.bigInt2BytesLE( toMontgomery(G1zero[0]), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(G1zero[1]), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(G1zero[2]), f1size ) + ] + ); + + const G2gen = [ + [ + bigInt$8("10857046999023057135944570762232829481370756359578518086990519993285655852781"), + bigInt$8("11559732032986387107991004021392285783925812861821192530917403151452391805634"), + ],[ + bigInt$8("8495653923123431417604973247489272438418190587263600148770280649306958101930"), + bigInt$8("4082367875863433681332203403145435568316851327593401208105741076214120093531"), + ],[ + bigInt$8.one, + bigInt$8.zero, + ] + ]; + + const pG2gen = module.alloc( + [ + ...utils$8.bigInt2BytesLE( toMontgomery(G2gen[0][0]), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(G2gen[0][1]), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(G2gen[1][0]), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(G2gen[1][1]), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(G2gen[2][0]), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(G2gen[2][1]), f1size ), + ] + ); + + const G2zero = [ + [ + bigInt$8.zero, + bigInt$8.zero, + ],[ + bigInt$8.one, + bigInt$8.zero, + ],[ + bigInt$8.zero, + bigInt$8.zero, + ] + ]; + + const pG2zero = module.alloc( + [ + ...utils$8.bigInt2BytesLE( toMontgomery(G2zero[0][0]), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(G2zero[0][1]), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(G2zero[1][0]), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(G2zero[1][1]), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(G2zero[2][0]), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(G2zero[2][1]), f1size ), + ] + ); + + const pOneT = module.alloc([ + ...utils$8.bigInt2BytesLE( toMontgomery(1), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(0), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(0), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(0), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(0), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(0), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(0), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(0), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(0), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(0), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(0), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(0), f1size ), + ]); + + const pNonResidueF6 = module.alloc([ + ...utils$8.bigInt2BytesLE( toMontgomery(9), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery(1), f1size ), + ]); + + const pTwoInv = module.alloc([ + ...utils$8.bigInt2BytesLE( toMontgomery( bigInt$8(2).modInv(q)), f1size ), + ...utils$8.bigInt2BytesLE( bigInt$8(0), f1size ) + ]); + + const pAltBn128Twist = pNonResidueF6; + + const pTwistCoefB = module.alloc([ + ...utils$8.bigInt2BytesLE( toMontgomery("19485874751759354771024239261021720505790618469301721065564631296452457478373"), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery("266929791119991161246907387137283842545076965332900288569378510910307636690"), f1size ), + ]); + + function build_mulNR6() { + const f = module.addFunction(prefix + "_mulNR6"); + f.addParam("x", "i32"); + f.addParam("pr", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.call( + f2mPrefix + "_mul", + c.i32_const(pNonResidueF6), + c.getLocal("x"), + c.getLocal("pr") + ) + ); + } + build_mulNR6(); + + const f6mPrefix = buildF3m$1(module, prefix+"_mulNR6", "f6m", "f2m"); + + function build_mulNR12() { + const f = module.addFunction(prefix + "_mulNR12"); + f.addParam("x", "i32"); + f.addParam("pr", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.call( + f2mPrefix + "_mul", + c.i32_const(pNonResidueF6), + c.i32_add(c.getLocal("x"), c.i32_const(n8*4)), + c.getLocal("pr") + ), + c.call( + f2mPrefix + "_copy", + c.getLocal("x"), + c.i32_add(c.getLocal("pr"), c.i32_const(n8*2)), + ), + c.call( + f2mPrefix + "_copy", + c.i32_add(c.getLocal("x"), c.i32_const(n8*2)), + c.i32_add(c.getLocal("pr"), c.i32_const(n8*4)), + ) + ); + } + build_mulNR12(); + + const ftmPrefix = buildF2m$1(module, prefix+"_mulNR12", "ftm", f6mPrefix); + + + const ateLoopCount = bigInt$8("29793968203157093288"); + const ateLoopBitBytes = bits(ateLoopCount); + const pAteLoopBitBytes = module.alloc(ateLoopBitBytes); + + const ateCoefSize = 3 * f2size; + const ateNDblCoefs = ateLoopBitBytes.length-1; + const ateNAddCoefs = ateLoopBitBytes.reduce((acc, b) => acc + ( b!=0 ? 1 : 0) ,0); + const ateNCoefs = ateNAddCoefs + ateNDblCoefs + 1; + const prePSize = 3*2*n8; + const preQSize = 3*n8*2 + ateNCoefs*ateCoefSize; + + + module.modules[prefix] = { + n64: n64, + pG1gen: pG1gen, + pG1zero: pG1zero, + pG1b: pG1b, + pG2gen: pG2gen, + pG2zero: pG2zero, + pG2b: pG2b, + pq: module.modules["f1m"].pq, + pr: pr, + pOneT: pOneT, + prePSize: prePSize, + preQSize: preQSize, + r: r.toString(), + q: q.toString() + }; + + // console.log("PrePSize: " +prePSize); + // console.log("PreQSize: " +preQSize); + + const finalExpZ = bigInt$8("4965661367192848881"); + + function naf(n) { + let E = n; + const res = []; + while (E.gt(bigInt$8.zero)) { + if (E.isOdd()) { + const z = 2 - E.mod(4).toJSNumber(); + res.push( z ); + E = E.minus(z); + } else { + res.push( 0 ); + } + E = E.shiftRight(1); + } + return res; + } + + function bits(n) { + let E = n; + const res = []; + while (E.gt(bigInt$8.zero)) { + if (E.isOdd()) { + res.push( 1 ); + } else { + res.push( 0 ); + } + E = E.shiftRight(1); + } + return res; + } + + function buildPrepareG1() { + const f = module.addFunction(prefix+ "_prepareG1"); + f.addParam("pP", "i32"); + f.addParam("ppreP", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.call(g1mPrefix + "_normalize", c.getLocal("pP"), c.getLocal("ppreP")), // TODO Remove if already in affine + ); + } + + function buildPrepAddStep() { + const f = module.addFunction(prefix+ "_prepAddStep"); + f.addParam("pQ", "i32"); + f.addParam("pR", "i32"); + f.addParam("pCoef", "i32"); + + const c = f.getCodeBuilder(); + + const X2 = c.getLocal("pQ"); + const Y2 = c.i32_add(c.getLocal("pQ"), c.i32_const(f2size)); + + const X1 = c.getLocal("pR"); + const Y1 = c.i32_add(c.getLocal("pR"), c.i32_const(f2size)); + const Z1 = c.i32_add(c.getLocal("pR"), c.i32_const(2*f2size)); + + const ELL_0 = c.getLocal("pCoef"); + const ELL_VW = c.i32_add(c.getLocal("pCoef"), c.i32_const(f2size)); + const ELL_VV = c.i32_add(c.getLocal("pCoef"), c.i32_const(2*f2size)); + + const D = ELL_VW; + const E = c.i32_const(module.alloc(f2size)); + const F = c.i32_const(module.alloc(f2size)); + const G = c.i32_const(module.alloc(f2size)); + const H = c.i32_const(module.alloc(f2size)); + const I = c.i32_const(module.alloc(f2size)); + const J = c.i32_const(module.alloc(f2size)); + const AUX = c.i32_const(module.alloc(f2size)); + + f.addCode( + // D = X1 - X2*Z1 + c.call(f2mPrefix + "_mul", X2, Z1, D), + c.call(f2mPrefix + "_sub", X1, D, D), + + // E = Y1 - Y2*Z1 + c.call(f2mPrefix + "_mul", Y2, Z1, E), + c.call(f2mPrefix + "_sub", Y1, E, E), + + // F = D^2 + c.call(f2mPrefix + "_square", D, F), + + // G = E^2 + c.call(f2mPrefix + "_square", E, G), + + // H = D*F + c.call(f2mPrefix + "_mul", D, F, H), + + // I = X1 * F + c.call(f2mPrefix + "_mul", X1, F, I), + + // J = H + Z1*G - (I+I) + c.call(f2mPrefix + "_add", I, I, AUX), + c.call(f2mPrefix + "_mul", Z1, G, J), + c.call(f2mPrefix + "_add", H, J, J), + c.call(f2mPrefix + "_sub", J, AUX, J), + + + // X3 (X1) = D*J + c.call(f2mPrefix + "_mul", D, J, X1), + + // Y3 (Y1) = E*(I-J)-(H*Y1) + c.call(f2mPrefix + "_mul", H, Y1, Y1), + c.call(f2mPrefix + "_sub", I, J, AUX), + c.call(f2mPrefix + "_mul", E, AUX, AUX), + c.call(f2mPrefix + "_sub", AUX, Y1, Y1), + + // Z3 (Z1) = Z1*H + c.call(f2mPrefix + "_mul", Z1, H, Z1), + + // ell_0 = xi * (E * X2 - D * Y2) + c.call(f2mPrefix + "_mul", D, Y2, AUX), + c.call(f2mPrefix + "_mul", E, X2, ELL_0), + c.call(f2mPrefix + "_sub", ELL_0, AUX, ELL_0), + c.call(f2mPrefix + "_mul", ELL_0, c.i32_const(pAltBn128Twist), ELL_0), + + + // ell_VV = - E (later: * xP) + c.call(f2mPrefix + "_neg", E, ELL_VV), + + // ell_VW = D (later: * yP ) + // Already assigned + + ); + } + + + + function buildPrepDoubleStep() { + const f = module.addFunction(prefix+ "_prepDblStep"); + f.addParam("pR", "i32"); + f.addParam("pCoef", "i32"); + + const c = f.getCodeBuilder(); + + const X1 = c.getLocal("pR"); + const Y1 = c.i32_add(c.getLocal("pR"), c.i32_const(f2size)); + const Z1 = c.i32_add(c.getLocal("pR"), c.i32_const(2*f2size)); + + const ELL_0 = c.getLocal("pCoef"); + const ELL_VW = c.i32_add(c.getLocal("pCoef"), c.i32_const(f2size)); + const ELL_VV = c.i32_add(c.getLocal("pCoef"), c.i32_const(2*f2size)); + + const A = c.i32_const(module.alloc(f2size)); + const B = c.i32_const(module.alloc(f2size)); + const C = c.i32_const(module.alloc(f2size)); + const D = c.i32_const(module.alloc(f2size)); + const E = c.i32_const(module.alloc(f2size)); + const F = c.i32_const(module.alloc(f2size)); + const G = c.i32_const(module.alloc(f2size)); + const H = c.i32_const(module.alloc(f2size)); + const I = c.i32_const(module.alloc(f2size)); + const J = c.i32_const(module.alloc(f2size)); + const E2 = c.i32_const(module.alloc(f2size)); + const AUX = c.i32_const(module.alloc(f2size)); + + f.addCode( + + // A = X1 * Y1 / 2 + c.call(f2mPrefix + "_mul", Y1, c.i32_const(pTwoInv), A), + c.call(f2mPrefix + "_mul", X1, A, A), + + // B = Y1^2 + c.call(f2mPrefix + "_square", Y1, B), + + // C = Z1^2 + c.call(f2mPrefix + "_square", Z1, C), + + // D = 3 * C + c.call(f2mPrefix + "_add", C, C, D), + c.call(f2mPrefix + "_add", D, C, D), + + // E = twist_b * D + c.call(f2mPrefix + "_mul", c.i32_const(pTwistCoefB), D, E), + + // F = 3 * E + c.call(f2mPrefix + "_add", E, E, F), + c.call(f2mPrefix + "_add", E, F, F), + + // G = (B+F)/2 + c.call(f2mPrefix + "_add", B, F, G), + c.call(f2mPrefix + "_mul", G, c.i32_const(pTwoInv), G), + + // H = (Y1+Z1)^2-(B+C) + c.call(f2mPrefix + "_add", B, C, AUX), + c.call(f2mPrefix + "_add", Y1, Z1, H), + c.call(f2mPrefix + "_square", H, H), + c.call(f2mPrefix + "_sub", H, AUX, H), + + // I = E-B + c.call(f2mPrefix + "_sub", E, B, I), + + // J = X1^2 + c.call(f2mPrefix + "_square", X1, J), + + // E_squared = E^2 + c.call(f2mPrefix + "_square", E, E2), + + // X3 (X1) = A * (B-F) + c.call(f2mPrefix + "_sub", B, F, AUX), + c.call(f2mPrefix + "_mul", A, AUX, X1), + + // Y3 (Y1) = G^2 - 3*E^2 + c.call(f2mPrefix + "_add", E2, E2, AUX), + c.call(f2mPrefix + "_add", E2, AUX, AUX), + c.call(f2mPrefix + "_square", G, Y1), + c.call(f2mPrefix + "_sub", Y1, AUX, Y1), + + // Z3 (Z1) = B * H + c.call(f2mPrefix + "_mul", B, H, Z1), + + // ell_0 = xi * I + c.call(f2mPrefix + "_mul", c.i32_const(pAltBn128Twist), I, ELL_0), + + // ell_VW = - H (later: * yP) + c.call(f2mPrefix + "_neg", H, ELL_VW), + + // ell_VV = 3*J (later: * xP) + c.call(f2mPrefix + "_add", J, J, ELL_VV), + c.call(f2mPrefix + "_add", J, ELL_VV, ELL_VV), + + ); + } + + function buildMulByQ() { + const f = module.addFunction(prefix + "_mulByQ"); + f.addParam("p1", "i32"); + f.addParam("pr", "i32"); + + const c = f.getCodeBuilder(); + + const x = c.getLocal("p1"); + const y = c.i32_add(c.getLocal("p1"), c.i32_const(f2size)); + const z = c.i32_add(c.getLocal("p1"), c.i32_const(f2size*2)); + const x3 = c.getLocal("pr"); + const y3 = c.i32_add(c.getLocal("pr"), c.i32_const(f2size)); + const z3 = c.i32_add(c.getLocal("pr"), c.i32_const(f2size*2)); + + const MulByQX = c.i32_const(module.alloc([ + ...utils$8.bigInt2BytesLE( toMontgomery("21575463638280843010398324269430826099269044274347216827212613867836435027261"), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery("10307601595873709700152284273816112264069230130616436755625194854815875713954"), f1size ), + ])); + + const MulByQY = c.i32_const(module.alloc([ + ...utils$8.bigInt2BytesLE( toMontgomery("2821565182194536844548159561693502659359617185244120367078079554186484126554"), f1size ), + ...utils$8.bigInt2BytesLE( toMontgomery("3505843767911556378687030309984248845540243509899259641013678093033130930403"), f1size ), + ])); + + f.addCode( + // The frobeniusMap(1) in this field, is the conjugate + c.call(f2mPrefix + "_conjugate", x, x3), + c.call(f2mPrefix + "_mul", MulByQX, x3, x3), + c.call(f2mPrefix + "_conjugate", y, y3), + c.call(f2mPrefix + "_mul", MulByQY, y3, y3), + c.call(f2mPrefix + "_conjugate", z, z3), + ); + } + + + function buildPrepareG2() { + buildMulByQ(); + const f = module.addFunction(prefix+ "_prepareG2"); + f.addParam("pQ", "i32"); + f.addParam("ppreQ", "i32"); + f.addLocal("pCoef", "i32"); + f.addLocal("i", "i32"); + + const c = f.getCodeBuilder(); + + const QX = c.getLocal("pQ"); + c.i32_add( c.getLocal("pQ"), c.i32_const(f2size)); + c.i32_add( c.getLocal("pQ"), c.i32_const(f2size*2)); + + const pR = module.alloc(f2size*3); + const R = c.i32_const(pR); + const RX = c.i32_const(pR); + const RY = c.i32_const(pR+f2size); + const RZ = c.i32_const(pR+2*f2size); + + const cQX = c.i32_add( c.getLocal("ppreQ"), c.i32_const(0)); + const cQY = c.i32_add( c.getLocal("ppreQ"), c.i32_const(f2size)); + c.i32_add( c.getLocal("ppreQ"), c.i32_const(f2size*2)); + + const pQ1 = module.alloc(f2size*3); + const Q1 = c.i32_const(pQ1); + + const pQ2 = module.alloc(f2size*3); + const Q2 = c.i32_const(pQ2); + c.i32_const(pQ2); + const Q2Y = c.i32_const(pQ2 + f2size); + c.i32_const(pQ2 + f2size*2); + + f.addCode( + c.call(g2mPrefix + "_normalize", QX, cQX), // TODO Remove if already in affine + c.call(f2mPrefix + "_copy", cQX, RX), + c.call(f2mPrefix + "_copy", cQY, RY), + c.call(f2mPrefix + "_one", RZ), + ); + + f.addCode( + c.setLocal("pCoef", c.i32_add( c.getLocal("ppreQ"), c.i32_const(f2size*3))), + c.setLocal("i", c.i32_const(ateLoopBitBytes.length-2)), + c.block(c.loop( + + c.call(prefix + "_prepDblStep", R, c.getLocal("pCoef")), + c.setLocal("pCoef", c.i32_add(c.getLocal("pCoef"), c.i32_const(ateCoefSize))), + + c.if( + c.i32_load8_s(c.getLocal("i"), pAteLoopBitBytes), + [ + ...c.call(prefix + "_prepAddStep", cQX, R, c.getLocal("pCoef")), + ...c.setLocal("pCoef", c.i32_add(c.getLocal("pCoef"), c.i32_const(ateCoefSize))), + ] + ), + c.br_if(1, c.i32_eqz ( c.getLocal("i") )), + c.setLocal("i", c.i32_sub(c.getLocal("i"), c.i32_const(1))), + c.br(0) + )) + ); + + f.addCode( + c.call(prefix + "_mulByQ", cQX, Q1), + c.call(prefix + "_mulByQ", Q1, Q2) + ); + + f.addCode( + c.call(f2mPrefix + "_neg", Q2Y, Q2Y), + + c.call(prefix + "_prepAddStep", Q1, R, c.getLocal("pCoef")), + c.setLocal("pCoef", c.i32_add(c.getLocal("pCoef"), c.i32_const(ateCoefSize))), + + c.call(prefix + "_prepAddStep", Q2, R, c.getLocal("pCoef")), + c.setLocal("pCoef", c.i32_add(c.getLocal("pCoef"), c.i32_const(ateCoefSize))), + ); + } + + function buildMulBy024Old() { + const f = module.addFunction(prefix+ "__mulBy024Old"); + f.addParam("pEll0", "i32"); + f.addParam("pEllVW", "i32"); + f.addParam("pEllVV", "i32"); + f.addParam("pR", "i32"); // Result in F12 + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("pEll0"); + const x2 = c.getLocal("pEllVV"); + const x4 = c.getLocal("pEllVW"); + + const z0 = c.getLocal("pR"); + + const pAUX12 = module.alloc(ftsize); + const AUX12 = c.i32_const(pAUX12); + const AUX12_0 = c.i32_const(pAUX12); + const AUX12_2 = c.i32_const(pAUX12+f2size); + const AUX12_4 = c.i32_const(pAUX12+f2size*2); + const AUX12_6 = c.i32_const(pAUX12+f2size*3); + const AUX12_8 = c.i32_const(pAUX12+f2size*4); + const AUX12_10 = c.i32_const(pAUX12+f2size*5); + + f.addCode( + + c.call(f2mPrefix + "_copy", x0, AUX12_0), + c.call(f2mPrefix + "_zero", AUX12_2), + c.call(f2mPrefix + "_copy", x2, AUX12_4), + c.call(f2mPrefix + "_zero", AUX12_6), + c.call(f2mPrefix + "_copy", x4, AUX12_8), + c.call(f2mPrefix + "_zero", AUX12_10), + c.call(ftmPrefix + "_mul", AUX12, z0, z0), + ); + } + + function buildMulBy024() { + const f = module.addFunction(prefix+ "__mulBy024"); + f.addParam("pEll0", "i32"); + f.addParam("pEllVW", "i32"); + f.addParam("pEllVV", "i32"); + f.addParam("pR", "i32"); // Result in F12 + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("pEll0"); + const x2 = c.getLocal("pEllVV"); + const x4 = c.getLocal("pEllVW"); + + const z0 = c.getLocal("pR"); + const z1 = c.i32_add(c.getLocal("pR"), c.i32_const(2*n8)); + const z2 = c.i32_add(c.getLocal("pR"), c.i32_const(4*n8)); + const z3 = c.i32_add(c.getLocal("pR"), c.i32_const(6*n8)); + const z4 = c.i32_add(c.getLocal("pR"), c.i32_const(8*n8)); + const z5 = c.i32_add(c.getLocal("pR"), c.i32_const(10*n8)); + + const t0 = c.i32_const(module.alloc(f2size)); + const t1 = c.i32_const(module.alloc(f2size)); + const t2 = c.i32_const(module.alloc(f2size)); + const s0 = c.i32_const(module.alloc(f2size)); + const T3 = c.i32_const(module.alloc(f2size)); + const T4 = c.i32_const(module.alloc(f2size)); + const D0 = c.i32_const(module.alloc(f2size)); + const D2 = c.i32_const(module.alloc(f2size)); + const D4 = c.i32_const(module.alloc(f2size)); + const S1 = c.i32_const(module.alloc(f2size)); + const AUX = c.i32_const(module.alloc(f2size)); + + f.addCode( + + // D0 = z0 * x0; + c.call(f2mPrefix + "_mul", z0, x0, D0), + // D2 = z2 * x2; + c.call(f2mPrefix + "_mul", z2, x2, D2), + // D4 = z4 * x4; + c.call(f2mPrefix + "_mul", z4, x4, D4), + // t2 = z0 + z4; + c.call(f2mPrefix + "_add", z0, z4, t2), + // t1 = z0 + z2; + c.call(f2mPrefix + "_add", z0, z2, t1), + // s0 = z1 + z3 + z5; + c.call(f2mPrefix + "_add", z1, z3, s0), + c.call(f2mPrefix + "_add", s0, z5, s0), + + + // For z.a_.a_ = z0. + // S1 = z1 * x2; + c.call(f2mPrefix + "_mul", z1, x2, S1), + // T3 = S1 + D4; + c.call(f2mPrefix + "_add", S1, D4, T3), + // T4 = my_Fp6::non_residue * T3 + D0; + c.call(f2mPrefix + "_mul", c.i32_const(pNonResidueF6), T3, T4), + c.call(f2mPrefix + "_add", T4, D0, z0), + // z0 = T4; + + // For z.a_.b_ = z1 + // T3 = z5 * x4; + c.call(f2mPrefix + "_mul", z5, x4, T3), + // S1 = S1 + T3; + c.call(f2mPrefix + "_add", S1, T3, S1), + // T3 = T3 + D2; + c.call(f2mPrefix + "_add", T3, D2, T3), + // T4 = my_Fp6::non_residue * T3; + c.call(f2mPrefix + "_mul", c.i32_const(pNonResidueF6), T3, T4), + // T3 = z1 * x0; + c.call(f2mPrefix + "_mul", z1, x0, T3), + // S1 = S1 + T3; + c.call(f2mPrefix + "_add", S1, T3, S1), + // T4 = T4 + T3; + c.call(f2mPrefix + "_add", T4, T3, z1), + // z1 = T4; + + + + // For z.a_.c_ = z2 + // t0 = x0 + x2; + c.call(f2mPrefix + "_add", x0, x2, t0), + // T3 = t1 * t0 - D0 - D2; + c.call(f2mPrefix + "_mul", t1, t0, T3), + c.call(f2mPrefix + "_add", D0, D2, AUX), + c.call(f2mPrefix + "_sub", T3, AUX, T3), + // T4 = z3 * x4; + c.call(f2mPrefix + "_mul", z3, x4, T4), + // S1 = S1 + T4; + c.call(f2mPrefix + "_add", S1, T4, S1), + + + // For z.b_.a_ = z3 (z3 needs z2) + // t0 = z2 + z4; + c.call(f2mPrefix + "_add", z2, z4, t0), + // T3 = T3 + T4; + // z2 = T3; + c.call(f2mPrefix + "_add", T3, T4, z2), + // t1 = x2 + x4; + c.call(f2mPrefix + "_add", x2, x4, t1), + // T3 = t0 * t1 - D2 - D4; + c.call(f2mPrefix + "_mul", t1, t0, T3), + c.call(f2mPrefix + "_add", D2, D4, AUX), + c.call(f2mPrefix + "_sub", T3, AUX, T3), + // T4 = my_Fp6::non_residue * T3; + c.call(f2mPrefix + "_mul", c.i32_const(pNonResidueF6), T3, T4), + // T3 = z3 * x0; + c.call(f2mPrefix + "_mul", z3, x0, T3), + // S1 = S1 + T3; + c.call(f2mPrefix + "_add", S1, T3, S1), + // T4 = T4 + T3; + c.call(f2mPrefix + "_add", T4, T3, z3), + // z3 = T4; + + // For z.b_.b_ = z4 + // T3 = z5 * x2; + c.call(f2mPrefix + "_mul", z5, x2, T3), + // S1 = S1 + T3; + c.call(f2mPrefix + "_add", S1, T3, S1), + // T4 = my_Fp6::non_residue * T3; + c.call(f2mPrefix + "_mul", c.i32_const(pNonResidueF6), T3, T4), + // t0 = x0 + x4; + c.call(f2mPrefix + "_add", x0, x4, t0), + // T3 = t2 * t0 - D0 - D4; + c.call(f2mPrefix + "_mul", t2, t0, T3), + c.call(f2mPrefix + "_add", D0, D4, AUX), + c.call(f2mPrefix + "_sub", T3, AUX, T3), + // T4 = T4 + T3; + c.call(f2mPrefix + "_add", T4, T3, z4), + // z4 = T4; + + // For z.b_.c_ = z5. + // t0 = x0 + x2 + x4; + c.call(f2mPrefix + "_add", x0, x2, t0), + c.call(f2mPrefix + "_add", t0, x4, t0), + // T3 = s0 * t0 - S1; + c.call(f2mPrefix + "_mul", s0, t0, T3), + c.call(f2mPrefix + "_sub", T3, S1, z5), + // z5 = T3; + + ); + } + + + function buildMillerLoop() { + const f = module.addFunction(prefix+ "_millerLoop"); + f.addParam("ppreP", "i32"); + f.addParam("ppreQ", "i32"); + f.addParam("r", "i32"); + f.addLocal("pCoef", "i32"); + f.addLocal("i", "i32"); + + const c = f.getCodeBuilder(); + + const preP_PX = c.getLocal("ppreP"); + const preP_PY = c.i32_add(c.getLocal("ppreP"), c.i32_const(f1size)); + + const ELL_0 = c.getLocal("pCoef"); + const ELL_VW = c.i32_add(c.getLocal("pCoef"), c.i32_const(f2size)); + const ELL_VV = c.i32_add(c.getLocal("pCoef"), c.i32_const(2*f2size)); + + + const pVW = module.alloc(f2size); + const VW = c.i32_const(pVW); + const pVV = module.alloc(f2size); + const VV = c.i32_const(pVV); + + const F = c.getLocal("r"); + + + f.addCode( + c.call(ftmPrefix + "_one", F), + + c.setLocal("pCoef", c.i32_add( c.getLocal("ppreQ"), c.i32_const(f2size*3))), + + c.setLocal("i", c.i32_const(ateLoopBitBytes.length-2)), + c.block(c.loop( + + + c.call(ftmPrefix + "_square", F, F), + + c.call(f2mPrefix + "_mul1", ELL_VW,preP_PY, VW), + c.call(f2mPrefix + "_mul1", ELL_VV, preP_PX, VV), + c.call(prefix + "__mulBy024", ELL_0, VW, VV, F), + c.setLocal("pCoef", c.i32_add(c.getLocal("pCoef"), c.i32_const(ateCoefSize))), + + c.if( + c.i32_load8_s(c.getLocal("i"), pAteLoopBitBytes), + [ + ...c.call(f2mPrefix + "_mul1", ELL_VW, preP_PY, VW), + ...c.call(f2mPrefix + "_mul1", ELL_VV, preP_PX, VV), + + ...c.call(prefix + "__mulBy024", ELL_0, VW, VV, F), + ...c.setLocal("pCoef", c.i32_add(c.getLocal("pCoef"), c.i32_const(ateCoefSize))), + + ] + ), + c.br_if(1, c.i32_eqz ( c.getLocal("i") )), + c.setLocal("i", c.i32_sub(c.getLocal("i"), c.i32_const(1))), + c.br(0) + )) + + ); + + f.addCode( + c.call(f2mPrefix + "_mul1", ELL_VW, preP_PY, VW), + c.call(f2mPrefix + "_mul1", ELL_VV, preP_PX, VV), + c.call(prefix + "__mulBy024", ELL_0, VW, VV, F), + c.setLocal("pCoef", c.i32_add(c.getLocal("pCoef"), c.i32_const(ateCoefSize))), + + c.call(f2mPrefix + "_mul1", ELL_VW, preP_PY, VW), + c.call(f2mPrefix + "_mul1", ELL_VV, preP_PX, VV), + c.call(prefix + "__mulBy024", ELL_0, VW, VV, F), + c.setLocal("pCoef", c.i32_add(c.getLocal("pCoef"), c.i32_const(ateCoefSize))), + + ); + + } + + + function buildFrobeniusMap(n) { + const F12 = [ + [ + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("1"), bigInt$8("0")], + ], + [ + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("8376118865763821496583973867626364092589906065868298776909617916018768340080"), bigInt$8("16469823323077808223889137241176536799009286646108169935659301613961712198316")], + [bigInt$8("21888242871839275220042445260109153167277707414472061641714758635765020556617"), bigInt$8("0")], + [bigInt$8("11697423496358154304825782922584725312912383441159505038794027105778954184319"), bigInt$8("303847389135065887422783454877609941456349188919719272345083954437860409601")], + [bigInt$8("21888242871839275220042445260109153167277707414472061641714758635765020556616"), bigInt$8("0")], + [bigInt$8("3321304630594332808241809054958361220322477375291206261884409189760185844239"), bigInt$8("5722266937896532885780051958958348231143373700109372999374820235121374419868")], + [bigInt$8("21888242871839275222246405745257275088696311157297823662689037894645226208582"), bigInt$8("0")], + [bigInt$8("13512124006075453725662431877630910996106405091429524885779419978626457868503"), bigInt$8("5418419548761466998357268504080738289687024511189653727029736280683514010267")], + [bigInt$8("2203960485148121921418603742825762020974279258880205651966"), bigInt$8("0")], + [bigInt$8("10190819375481120917420622822672549775783927716138318623895010788866272024264"), bigInt$8("21584395482704209334823622290379665147239961968378104390343953940207365798982")], + [bigInt$8("2203960485148121921418603742825762020974279258880205651967"), bigInt$8("0")], + [bigInt$8("18566938241244942414004596690298913868373833782006617400804628704885040364344"), bigInt$8("16165975933942742336466353786298926857552937457188450663314217659523851788715")], + ] + ]; + + const F6 = [ + [ + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("1"), bigInt$8("0")], + ], + [ + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("21575463638280843010398324269430826099269044274347216827212613867836435027261"), bigInt$8("10307601595873709700152284273816112264069230130616436755625194854815875713954")], + [bigInt$8("21888242871839275220042445260109153167277707414472061641714758635765020556616"), bigInt$8("0")], + [bigInt$8("3772000881919853776433695186713858239009073593817195771773381919316419345261"), bigInt$8("2236595495967245188281701248203181795121068902605861227855261137820944008926")], + [bigInt$8("2203960485148121921418603742825762020974279258880205651966"), bigInt$8("0")], + [bigInt$8("18429021223477853657660792034369865839114504446431234726392080002137598044644"), bigInt$8("9344045779998320333812420223237981029506012124075525679208581902008406485703")], + ], + [ + [bigInt$8("1"), bigInt$8("0")], + [bigInt$8("2581911344467009335267311115468803099551665605076196740867805258568234346338"), bigInt$8("19937756971775647987995932169929341994314640652964949448313374472400716661030")], + [bigInt$8("2203960485148121921418603742825762020974279258880205651966"), bigInt$8("0")], + [bigInt$8("5324479202449903542726783395506214481928257762400643279780343368557297135718"), bigInt$8("16208900380737693084919495127334387981393726419856888799917914180988844123039")], + [bigInt$8("21888242871839275220042445260109153167277707414472061641714758635765020556616"), bigInt$8("0")], + [bigInt$8("13981852324922362344252311234282257507216387789820983642040889267519694726527"), bigInt$8("7629828391165209371577384193250820201684255241773809077146787135900891633097")], + ] + ]; + + const f = module.addFunction(prefix+ "__frobeniusMap"+n); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + for (let i=0; i<6; i++) { + const X = (i==0) ? c.getLocal("x") : c.i32_add(c.getLocal("x"), c.i32_const(i*f2size)); + const Xc0 = X; + const Xc1 = c.i32_add(c.getLocal("x"), c.i32_const(i*f2size + f1size)); + const R = (i==0) ? c.getLocal("r") : c.i32_add(c.getLocal("r"), c.i32_const(i*f2size)); + const Rc0 = R; + const Rc1 = c.i32_add(c.getLocal("r"), c.i32_const(i*f2size + f1size)); + const coef = mul2(F12[Math.floor(i/3)][n%12] , F6[i%3][n%6]); + const pCoef = module.alloc([ + ...utils$8.bigInt2BytesLE(toMontgomery(coef[0]), 32), + ...utils$8.bigInt2BytesLE(toMontgomery(coef[1]), 32), + ]); + if (n%2 == 1) { + f.addCode( + c.call(f1mPrefix + "_copy", Xc0, Rc0), + c.call(f1mPrefix + "_neg", Xc1, Rc1), + c.call(f2mPrefix + "_mul", R, c.i32_const(pCoef), R), + ); + } else { + f.addCode(c.call(f2mPrefix + "_mul", X, c.i32_const(pCoef), R)); + } + } + + function mul2(a, b) { + const ac0 = bigInt$8(a[0]); + const ac1 = bigInt$8(a[1]); + const bc0 = bigInt$8(b[0]); + const bc1 = bigInt$8(b[1]); + const res = [ + ac0.times(bc0).minus( ac1.times(bc1) ).mod(q), + ac0.times(bc1).add( ac1.times(bc0) ).mod(q), + ]; + if (res[0].isNegative()) res[0] = res[0].add(q); + return res; + } + + } + + + + function buildFinalExponentiationFirstChunk() { + + const f = module.addFunction(prefix+ "__finalExponentiationFirstChunk"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const elt = c.getLocal("x"); + const eltC0 = elt; + const eltC1 = c.i32_add(elt, c.i32_const(n8*6)); + const r = c.getLocal("r"); + const pA = module.alloc(ftsize); + const A = c.i32_const(pA); + const Ac0 = A; + const Ac1 = c.i32_const(pA + n8*6); + const B = c.i32_const(module.alloc(ftsize)); + const C = c.i32_const(module.alloc(ftsize)); + const D = c.i32_const(module.alloc(ftsize)); + + f.addCode( + // const alt_bn128_Fq12 A = alt_bn128_Fq12(elt.c0,-elt.c1); + c.call(f6mPrefix + "_copy", eltC0, Ac0), + c.call(f6mPrefix + "_neg", eltC1, Ac1), + + // const alt_bn128_Fq12 B = elt.inverse(); + c.call(ftmPrefix + "_inverse", elt, B), + + // const alt_bn128_Fq12 C = A * B; + c.call(ftmPrefix + "_mul", A, B, C), + // const alt_bn128_Fq12 D = C.Frobenius_map(2); + c.call(prefix + "__frobeniusMap2", C, D), + // const alt_bn128_Fq12 result = D * C; + c.call(ftmPrefix + "_mul", C, D, r), + ); + } + + function buildCyclotomicSquare() { + const f = module.addFunction(prefix+ "__cyclotomicSquare"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x4 = c.i32_add(c.getLocal("x"), c.i32_const(f2size)); + const x3 = c.i32_add(c.getLocal("x"), c.i32_const(2*f2size)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(3*f2size)); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(4*f2size)); + const x5 = c.i32_add(c.getLocal("x"), c.i32_const(5*f2size)); + + const r0 = c.getLocal("r"); + const r4 = c.i32_add(c.getLocal("r"), c.i32_const(f2size)); + const r3 = c.i32_add(c.getLocal("r"), c.i32_const(2*f2size)); + const r2 = c.i32_add(c.getLocal("r"), c.i32_const(3*f2size)); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(4*f2size)); + const r5 = c.i32_add(c.getLocal("r"), c.i32_const(5*f2size)); + + const t0 = c.i32_const(module.alloc(f2size)); + const t1 = c.i32_const(module.alloc(f2size)); + const t2 = c.i32_const(module.alloc(f2size)); + const t3 = c.i32_const(module.alloc(f2size)); + const t4 = c.i32_const(module.alloc(f2size)); + const t5 = c.i32_const(module.alloc(f2size)); + const tmp = c.i32_const(module.alloc(f2size)); + const AUX = c.i32_const(module.alloc(f2size)); + + + f.addCode( + +// c.call(ftmPrefix + "_square", x0, r0), + + // // t0 + t1*y = (z0 + z1*y)^2 = a^2 + // tmp = z0 * z1; + // t0 = (z0 + z1) * (z0 + my_Fp6::non_residue * z1) - tmp - my_Fp6::non_residue * tmp; + // t1 = tmp + tmp; + c.call(f2mPrefix + "_mul", x0, x1, tmp), + c.call(f2mPrefix + "_mul", x1, c.i32_const(pNonResidueF6), t0), + c.call(f2mPrefix + "_add", x0, t0, t0), + c.call(f2mPrefix + "_add", x0, x1, AUX), + c.call(f2mPrefix + "_mul", AUX, t0, t0), + c.call(f2mPrefix + "_mul", c.i32_const(pNonResidueF6), tmp, AUX), + c.call(f2mPrefix + "_add", tmp, AUX, AUX), + c.call(f2mPrefix + "_sub", t0, AUX, t0), + c.call(f2mPrefix + "_add", tmp, tmp, t1), + + // // t2 + t3*y = (z2 + z3*y)^2 = b^2 + // tmp = z2 * z3; + // t2 = (z2 + z3) * (z2 + my_Fp6::non_residue * z3) - tmp - my_Fp6::non_residue * tmp; + // t3 = tmp + tmp; + c.call(f2mPrefix + "_mul", x2, x3, tmp), + c.call(f2mPrefix + "_mul", x3, c.i32_const(pNonResidueF6), t2), + c.call(f2mPrefix + "_add", x2, t2, t2), + c.call(f2mPrefix + "_add", x2, x3, AUX), + c.call(f2mPrefix + "_mul", AUX, t2, t2), + c.call(f2mPrefix + "_mul", c.i32_const(pNonResidueF6), tmp, AUX), + c.call(f2mPrefix + "_add", tmp, AUX, AUX), + c.call(f2mPrefix + "_sub", t2, AUX, t2), + c.call(f2mPrefix + "_add", tmp, tmp, t3), + + // // t4 + t5*y = (z4 + z5*y)^2 = c^2 + // tmp = z4 * z5; + // t4 = (z4 + z5) * (z4 + my_Fp6::non_residue * z5) - tmp - my_Fp6::non_residue * tmp; + // t5 = tmp + tmp; + c.call(f2mPrefix + "_mul", x4, x5, tmp), + c.call(f2mPrefix + "_mul", x5, c.i32_const(pNonResidueF6), t4), + c.call(f2mPrefix + "_add", x4, t4, t4), + c.call(f2mPrefix + "_add", x4, x5, AUX), + c.call(f2mPrefix + "_mul", AUX, t4, t4), + c.call(f2mPrefix + "_mul", c.i32_const(pNonResidueF6), tmp, AUX), + c.call(f2mPrefix + "_add", tmp, AUX, AUX), + c.call(f2mPrefix + "_sub", t4, AUX, t4), + c.call(f2mPrefix + "_add", tmp, tmp, t5), + + // For A + // z0 = 3 * t0 - 2 * z0 + c.call(f2mPrefix + "_sub", t0, x0, r0), + c.call(f2mPrefix + "_add", r0, r0, r0), + c.call(f2mPrefix + "_add", t0, r0, r0), + // z1 = 3 * t1 + 2 * z1 + c.call(f2mPrefix + "_add", t1, x1, r1), + c.call(f2mPrefix + "_add", r1, r1, r1), + c.call(f2mPrefix + "_add", t1, r1, r1), + + // For B + // z2 = 3 * (xi * t5) + 2 * z2 + c.call(f2mPrefix + "_mul", t5, c.i32_const(pAltBn128Twist), AUX), + c.call(f2mPrefix + "_add", AUX, x2, r2), + c.call(f2mPrefix + "_add", r2, r2, r2), + c.call(f2mPrefix + "_add", AUX, r2, r2), + // z3 = 3 * t4 - 2 * z3 + c.call(f2mPrefix + "_sub", t4, x3, r3), + c.call(f2mPrefix + "_add", r3, r3, r3), + c.call(f2mPrefix + "_add", t4, r3, r3), + + // For C + // z4 = 3 * t2 - 2 * z4 + c.call(f2mPrefix + "_sub", t2, x4, r4), + c.call(f2mPrefix + "_add", r4, r4, r4), + c.call(f2mPrefix + "_add", t2, r4, r4), + // z5 = 3 * t3 + 2 * z5 + c.call(f2mPrefix + "_add", t3, x5, r5), + c.call(f2mPrefix + "_add", r5, r5, r5), + c.call(f2mPrefix + "_add", t3, r5, r5), + + ); + } + + + function buildCyclotomicExp(exponent, fnName) { + const exponentNafBytes = naf(exponent).map( (b) => (b==-1 ? 0xFF: b) ); + const pExponentNafBytes = module.alloc(exponentNafBytes); + module.alloc(utils$8.bigInt2BytesLE(exponent, 32)); + + const f = module.addFunction(prefix+ "__cyclotomicExp_"+fnName); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + f.addLocal("bit", "i32"); + f.addLocal("i", "i32"); + + const c = f.getCodeBuilder(); + + const x = c.getLocal("x"); + + const res = c.getLocal("r"); + + const inverse = c.i32_const(module.alloc(ftsize)); + + + f.addCode( +// c.call(ftmPrefix + "_exp", x, c.i32_const(pExponent), c.i32_const(32), res), + + c.call(ftmPrefix + "_conjugate", x, inverse), + c.call(ftmPrefix + "_one", res), + + c.if( + c.teeLocal("bit", c.i32_load8_s(c.i32_const(exponentNafBytes.length-1), pExponentNafBytes)), + c.if( + c.i32_eq( + c.getLocal("bit"), + c.i32_const(1) + ), + c.call(ftmPrefix + "_mul", res, x, res), + c.call(ftmPrefix + "_mul", res, inverse, res), + ) + ), + + c.setLocal("i", c.i32_const(exponentNafBytes.length-2)), + c.block(c.loop( +// c.call(ftmPrefix + "_square", res, res), + c.call(prefix + "__cyclotomicSquare", res, res), + c.if( + c.teeLocal("bit", c.i32_load8_s(c.getLocal("i"), pExponentNafBytes)), + c.if( + c.i32_eq( + c.getLocal("bit"), + c.i32_const(1) + ), + c.call(ftmPrefix + "_mul", res, x, res), + c.call(ftmPrefix + "_mul", res, inverse, res), + ) + ), + c.br_if(1, c.i32_eqz ( c.getLocal("i") )), + c.setLocal("i", c.i32_sub(c.getLocal("i"), c.i32_const(1))), + c.br(0) + )) + ); + } + + + + function buildFinalExponentiationLastChunk() { + buildCyclotomicSquare(); + buildCyclotomicExp(finalExpZ, "w0"); + + const f = module.addFunction(prefix+ "__finalExponentiationLastChunk"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const elt = c.getLocal("x"); + const result = c.getLocal("r"); + const A = c.i32_const(module.alloc(ftsize)); + const B = c.i32_const(module.alloc(ftsize)); + const C = c.i32_const(module.alloc(ftsize)); + const D = c.i32_const(module.alloc(ftsize)); + const E = c.i32_const(module.alloc(ftsize)); + const F = c.i32_const(module.alloc(ftsize)); + const G = c.i32_const(module.alloc(ftsize)); + const H = c.i32_const(module.alloc(ftsize)); + const I = c.i32_const(module.alloc(ftsize)); + const J = c.i32_const(module.alloc(ftsize)); + const K = c.i32_const(module.alloc(ftsize)); + const L = c.i32_const(module.alloc(ftsize)); + const M = c.i32_const(module.alloc(ftsize)); + const N = c.i32_const(module.alloc(ftsize)); + const O = c.i32_const(module.alloc(ftsize)); + const P = c.i32_const(module.alloc(ftsize)); + const Q = c.i32_const(module.alloc(ftsize)); + const R = c.i32_const(module.alloc(ftsize)); + const S = c.i32_const(module.alloc(ftsize)); + const T = c.i32_const(module.alloc(ftsize)); + const U = c.i32_const(module.alloc(ftsize)); + + f.addCode( + + + // A = exp_by_neg_z(elt) // = elt^(-z) + c.call(prefix + "__cyclotomicExp_w0", elt, A), + c.call(ftmPrefix + "_conjugate", A, A), + // B = A^2 // = elt^(-2*z) + c.call(prefix + "__cyclotomicSquare", A, B), + // C = B^2 // = elt^(-4*z) + c.call(prefix + "__cyclotomicSquare", B, C), + // D = C * B // = elt^(-6*z) + c.call(ftmPrefix + "_mul", C, B, D), + // E = exp_by_neg_z(D) // = elt^(6*z^2) + c.call(prefix + "__cyclotomicExp_w0", D, E), + c.call(ftmPrefix + "_conjugate", E, E), + // F = E^2 // = elt^(12*z^2) + c.call(prefix + "__cyclotomicSquare", E, F), + // G = epx_by_neg_z(F) // = elt^(-12*z^3) + c.call(prefix + "__cyclotomicExp_w0", F, G), + c.call(ftmPrefix + "_conjugate", G, G), + // H = conj(D) // = elt^(6*z) + c.call(ftmPrefix + "_conjugate", D, H), + // I = conj(G) // = elt^(12*z^3) + c.call(ftmPrefix + "_conjugate", G, I), + // J = I * E // = elt^(12*z^3 + 6*z^2) + c.call(ftmPrefix + "_mul", I, E, J), + // K = J * H // = elt^(12*z^3 + 6*z^2 + 6*z) + c.call(ftmPrefix + "_mul", J, H, K), + // L = K * B // = elt^(12*z^3 + 6*z^2 + 4*z) + c.call(ftmPrefix + "_mul", K, B, L), + // M = K * E // = elt^(12*z^3 + 12*z^2 + 6*z) + c.call(ftmPrefix + "_mul", K, E, M), + + // N = M * elt // = elt^(12*z^3 + 12*z^2 + 6*z + 1) + c.call(ftmPrefix + "_mul", M, elt, N), + + // O = L.Frobenius_map(1) // = elt^(q*(12*z^3 + 6*z^2 + 4*z)) + c.call(prefix + "__frobeniusMap1", L, O), + // P = O * N // = elt^(q*(12*z^3 + 6*z^2 + 4*z) * (12*z^3 + 12*z^2 + 6*z + 1)) + c.call(ftmPrefix + "_mul", O, N, P), + // Q = K.Frobenius_map(2) // = elt^(q^2 * (12*z^3 + 6*z^2 + 6*z)) + c.call(prefix + "__frobeniusMap2", K, Q), + // R = Q * P // = elt^(q^2 * (12*z^3 + 6*z^2 + 6*z) + q*(12*z^3 + 6*z^2 + 4*z) * (12*z^3 + 12*z^2 + 6*z + 1)) + c.call(ftmPrefix + "_mul", Q, P, R), + // S = conj(elt) // = elt^(-1) + c.call(ftmPrefix + "_conjugate", elt, S), + // T = S * L // = elt^(12*z^3 + 6*z^2 + 4*z - 1) + c.call(ftmPrefix + "_mul", S, L, T), + // U = T.Frobenius_map(3) // = elt^(q^3(12*z^3 + 6*z^2 + 4*z - 1)) + c.call(prefix + "__frobeniusMap3", T, U), + // V = U * R // = elt^(q^3(12*z^3 + 6*z^2 + 4*z - 1) + q^2 * (12*z^3 + 6*z^2 + 6*z) + q*(12*z^3 + 6*z^2 + 4*z) * (12*z^3 + 12*z^2 + 6*z + 1)) + c.call(ftmPrefix + "_mul", U, R, result), + // result = V + ); + } + + + function buildFinalExponentiation() { + buildFinalExponentiationFirstChunk(); + buildFinalExponentiationLastChunk(); + const f = module.addFunction(prefix+ "_finalExponentiation"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const elt = c.getLocal("x"); + const result = c.getLocal("r"); + const eltToFirstChunk = c.i32_const(module.alloc(ftsize)); + + f.addCode( + c.call(prefix + "__finalExponentiationFirstChunk", elt, eltToFirstChunk ), + c.call(prefix + "__finalExponentiationLastChunk", eltToFirstChunk, result ) + ); + } + + + function buildFinalExponentiationOld() { + const f = module.addFunction(prefix+ "_finalExponentiationOld"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const exponent = bigInt$8("552484233613224096312617126783173147097382103762957654188882734314196910839907541213974502761540629817009608548654680343627701153829446747810907373256841551006201639677726139946029199968412598804882391702273019083653272047566316584365559776493027495458238373902875937659943504873220554161550525926302303331747463515644711876653177129578303191095900909191624817826566688241804408081892785725967931714097716709526092261278071952560171111444072049229123565057483750161460024353346284167282452756217662335528813519139808291170539072125381230815729071544861602750936964829313608137325426383735122175229541155376346436093930287402089517426973178917569713384748081827255472576937471496195752727188261435633271238710131736096299798168852925540549342330775279877006784354801422249722573783561685179618816480037695005515426162362431072245638324744480"); + + const pExponent = module.alloc(utils$8.bigInt2BytesLE( exponent, 352 )); + + const c = f.getCodeBuilder(); + + f.addCode( + c.call(ftmPrefix + "_exp", c.getLocal("x"), c.i32_const(pExponent), c.i32_const(352), c.getLocal("r")), + ); + } + + + + + const pPreP = module.alloc(prePSize); + const pPreQ = module.alloc(preQSize); + + function buildPairingEquation(nPairings) { + + const f = module.addFunction(prefix+ "_pairingEq"+nPairings); + for (let i=0; i acc + ( b!=0 ? 1 : 0) ,0); + const ateNCoefs = ateNAddCoefs + ateNDblCoefs + 1; + const prePSize = 3*2*n8q; + const preQSize = 3*n8q*2 + ateNCoefs*ateCoefSize; + const finalExpIsNegative = true; + + const finalExpZ = bigInt$7("15132376222941642752"); + + + module.modules[prefix] = { + n64q: n64q, + n64r: n64r, + n8q: n8q, + n8r: n8r, + pG1gen: pG1gen, + pG1zero: pG1zero, + pG1b: pG1b, + pG2gen: pG2gen, + pG2zero: pG2zero, + pG2b: pG2b, + pq: module.modules["f1m"].pq, + pr: pr, + pOneT: pOneT, + r: r, + q: q, + prePSize: prePSize, + preQSize: preQSize + }; + + + function naf(n) { + let E = n; + const res = []; + while (E.gt(bigInt$7.zero)) { + if (E.isOdd()) { + const z = 2 - E.mod(4).toJSNumber(); + res.push( z ); + E = E.minus(z); + } else { + res.push( 0 ); + } + E = E.shiftRight(1); + } + return res; + } + + function bits(n) { + let E = n; + const res = []; + while (E.gt(bigInt$7.zero)) { + if (E.isOdd()) { + res.push( 1 ); + } else { + res.push( 0 ); + } + E = E.shiftRight(1); + } + return res; + } + + function buildPrepareG1() { + const f = module.addFunction(prefix+ "_prepareG1"); + f.addParam("pP", "i32"); + f.addParam("ppreP", "i32"); + + const c = f.getCodeBuilder(); + + f.addCode( + c.call(g1mPrefix + "_normalize", c.getLocal("pP"), c.getLocal("ppreP")), // TODO Remove if already in affine + ); + } + + + + function buildPrepDoubleStep() { + const f = module.addFunction(prefix+ "_prepDblStep"); + f.addParam("R", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const Rx = c.getLocal("R"); + const Ry = c.i32_add(c.getLocal("R"), c.i32_const(2*n8q)); + const Rz = c.i32_add(c.getLocal("R"), c.i32_const(4*n8q)); + + const t0 = c.getLocal("r"); + const t3 = c.i32_add(c.getLocal("r"), c.i32_const(2*n8q)); + const t6 = c.i32_add(c.getLocal("r"), c.i32_const(4*n8q)); + + + const zsquared = c.i32_const(module.alloc(f2size)); + const t1 = c.i32_const(module.alloc(f2size)); + const t2 = c.i32_const(module.alloc(f2size)); + const t4 = c.i32_const(module.alloc(f2size)); + const t5 = c.i32_const(module.alloc(f2size)); + + f.addCode( + + // tmp0 = r.x.square(); + c.call(f2mPrefix + "_square", Rx, t0), + + // tmp1 = r.y.square(); + c.call(f2mPrefix + "_square", Ry, t1), + + // tmp2 = tmp1.square(); + c.call(f2mPrefix + "_square", t1, t2), + + // tmp3 = (tmp1 + r.x).square() - tmp0 - tmp2; + c.call(f2mPrefix + "_add", t1, Rx, t3), + c.call(f2mPrefix + "_square", t3, t3), + c.call(f2mPrefix + "_sub", t3, t0, t3), + c.call(f2mPrefix + "_sub", t3, t2, t3), + + // tmp3 = tmp3 + tmp3; + c.call(f2mPrefix + "_add", t3, t3, t3), + + // tmp4 = tmp0 + tmp0 + tmp0; + c.call(f2mPrefix + "_add", t0, t0, t4), + c.call(f2mPrefix + "_add", t4, t0, t4), + + // tmp6 = r.x + tmp4; + c.call(f2mPrefix + "_add", Rx, t4, t6), + + // tmp5 = tmp4.square(); + c.call(f2mPrefix + "_square", t4, t5), + + // zsquared = r.z.square(); + c.call(f2mPrefix + "_square", Rz, zsquared), + + // r.x = tmp5 - tmp3 - tmp3; + c.call(f2mPrefix + "_sub", t5, t3, Rx), + c.call(f2mPrefix + "_sub", Rx, t3, Rx), + + // r.z = (r.z + r.y).square() - tmp1 - zsquared; + c.call(f2mPrefix + "_add", Rz, Ry, Rz), + c.call(f2mPrefix + "_square", Rz, Rz), + c.call(f2mPrefix + "_sub", Rz, t1, Rz), + c.call(f2mPrefix + "_sub", Rz, zsquared, Rz), + + // r.y = (tmp3 - r.x) * tmp4; + c.call(f2mPrefix + "_sub", t3, Rx, Ry), + c.call(f2mPrefix + "_mul", Ry, t4, Ry), + + // tmp2 = tmp2 + tmp2; + c.call(f2mPrefix + "_add", t2, t2, t2), + + // tmp2 = tmp2 + tmp2; + c.call(f2mPrefix + "_add", t2, t2, t2), + + // tmp2 = tmp2 + tmp2; + c.call(f2mPrefix + "_add", t2, t2, t2), + + // r.y -= tmp2; + c.call(f2mPrefix + "_sub", Ry, t2, Ry), + + // tmp3 = tmp4 * zsquared; + c.call(f2mPrefix + "_mul", t4, zsquared, t3), + + // tmp3 = tmp3 + tmp3; + c.call(f2mPrefix + "_add", t3, t3, t3), + + // tmp3 = -tmp3; + c.call(f2mPrefix + "_neg", t3, t3), + + // tmp6 = tmp6.square() - tmp0 - tmp5; + c.call(f2mPrefix + "_square", t6, t6), + c.call(f2mPrefix + "_sub", t6, t0, t6), + c.call(f2mPrefix + "_sub", t6, t5, t6), + + // tmp1 = tmp1 + tmp1; + c.call(f2mPrefix + "_add", t1, t1, t1), + + // tmp1 = tmp1 + tmp1; + c.call(f2mPrefix + "_add", t1, t1, t1), + + // tmp6 = tmp6 - tmp1; + c.call(f2mPrefix + "_sub", t6, t1, t6), + + // tmp0 = r.z * zsquared; + c.call(f2mPrefix + "_mul", Rz, zsquared, t0), + + // tmp0 = tmp0 + tmp0; + c.call(f2mPrefix + "_add", t0, t0, t0), + + ); + } + + function buildPrepAddStep() { + const f = module.addFunction(prefix+ "_prepAddStep"); + f.addParam("R", "i32"); + f.addParam("Q", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const Rx = c.getLocal("R"); + const Ry = c.i32_add(c.getLocal("R"), c.i32_const(2*n8q)); + const Rz = c.i32_add(c.getLocal("R"), c.i32_const(4*n8q)); + + const Qx = c.getLocal("Q"); + const Qy = c.i32_add(c.getLocal("Q"), c.i32_const(2*n8q)); + + const t10 = c.getLocal("r"); + const t1 = c.i32_add(c.getLocal("r"), c.i32_const(2*n8q)); + const t9 = c.i32_add(c.getLocal("r"), c.i32_const(4*n8q)); + + const zsquared = c.i32_const(module.alloc(f2size)); + const ysquared = c.i32_const(module.alloc(f2size)); + const ztsquared = c.i32_const(module.alloc(f2size)); + const t0 = c.i32_const(module.alloc(f2size)); + const t2 = c.i32_const(module.alloc(f2size)); + const t3 = c.i32_const(module.alloc(f2size)); + const t4 = c.i32_const(module.alloc(f2size)); + const t5 = c.i32_const(module.alloc(f2size)); + const t6 = c.i32_const(module.alloc(f2size)); + const t7 = c.i32_const(module.alloc(f2size)); + const t8 = c.i32_const(module.alloc(f2size)); + + f.addCode( + + // zsquared = r.z.square(); + c.call(f2mPrefix + "_square", Rz, zsquared), + + // ysquared = q.y.square(); + c.call(f2mPrefix + "_square", Qy, ysquared), + + // t0 = zsquared * q.x; + c.call(f2mPrefix + "_mul", zsquared, Qx, t0), + + // t1 = ((q.y + r.z).square() - ysquared - zsquared) * zsquared; + c.call(f2mPrefix + "_add", Qy, Rz, t1), + c.call(f2mPrefix + "_square", t1, t1), + c.call(f2mPrefix + "_sub", t1, ysquared, t1), + c.call(f2mPrefix + "_sub", t1, zsquared, t1), + c.call(f2mPrefix + "_mul", t1, zsquared, t1), + + // t2 = t0 - r.x; + c.call(f2mPrefix + "_sub", t0, Rx, t2), + + // t3 = t2.square(); + c.call(f2mPrefix + "_square", t2, t3), + + // t4 = t3 + t3; + c.call(f2mPrefix + "_add", t3, t3, t4), + + // t4 = t4 + t4; + c.call(f2mPrefix + "_add", t4, t4, t4), + + // t5 = t4 * t2; + c.call(f2mPrefix + "_mul", t4, t2, t5), + + // t6 = t1 - r.y - r.y; + c.call(f2mPrefix + "_sub", t1, Ry, t6), + c.call(f2mPrefix + "_sub", t6, Ry, t6), + + // t9 = t6 * q.x; + c.call(f2mPrefix + "_mul", t6, Qx, t9), + + // t7 = t4 * r.x; + c.call(f2mPrefix + "_mul", t4, Rx, t7), + + // r.x = t6.square() - t5 - t7 - t7; + c.call(f2mPrefix + "_square", t6, Rx), + c.call(f2mPrefix + "_sub", Rx, t5, Rx), + c.call(f2mPrefix + "_sub", Rx, t7, Rx), + c.call(f2mPrefix + "_sub", Rx, t7, Rx), + + // r.z = (r.z + t2).square() - zsquared - t3; + c.call(f2mPrefix + "_add", Rz, t2, Rz), + c.call(f2mPrefix + "_square", Rz, Rz), + c.call(f2mPrefix + "_sub", Rz, zsquared, Rz), + c.call(f2mPrefix + "_sub", Rz, t3, Rz), + + // t10 = q.y + r.z; + c.call(f2mPrefix + "_add", Qy, Rz, t10), + + // t8 = (t7 - r.x) * t6; + c.call(f2mPrefix + "_sub", t7, Rx, t8), + c.call(f2mPrefix + "_mul", t8, t6, t8), + + // t0 = r.y * t5; + c.call(f2mPrefix + "_mul", Ry, t5, t0), + + // t0 = t0 + t0; + c.call(f2mPrefix + "_add", t0, t0, t0), + + // r.y = t8 - t0; + c.call(f2mPrefix + "_sub", t8, t0, Ry), + + // t10 = t10.square() - ysquared; + c.call(f2mPrefix + "_square", t10, t10), + c.call(f2mPrefix + "_sub", t10, ysquared, t10), + + // ztsquared = r.z.square(); + c.call(f2mPrefix + "_square", Rz, ztsquared), + + // t10 = t10 - ztsquared; + c.call(f2mPrefix + "_sub", t10, ztsquared, t10), + + // t9 = t9 + t9 - t10; + c.call(f2mPrefix + "_add", t9, t9, t9), + c.call(f2mPrefix + "_sub", t9, t10, t9), + + // t10 = r.z + r.z; + c.call(f2mPrefix + "_add", Rz, Rz, t10), + + // t6 = -t6; + c.call(f2mPrefix + "_neg", t6, t6), + + // t1 = t6 + t6; + c.call(f2mPrefix + "_add", t6, t6, t1), + ); + } + + + function buildPrepareG2() { + const f = module.addFunction(prefix+ "_prepareG2"); + f.addParam("pQ", "i32"); + f.addParam("ppreQ", "i32"); + f.addLocal("pCoef", "i32"); + f.addLocal("i", "i32"); + + const c = f.getCodeBuilder(); + + + const Q = c.getLocal("pQ"); + + const pR = module.alloc(f2size*3); + const R = c.i32_const(pR); + + const base = c.getLocal("ppreQ"); + + f.addCode( + c.call(g2mPrefix + "_normalize", Q, base), + c.if( + c.call(g2mPrefix + "_isZero", base), + c.ret([]) + ), + c.call(g2mPrefix + "_copy", base, R), + c.setLocal("pCoef", c.i32_add(c.getLocal("ppreQ"), c.i32_const(f2size*3))), + ); + + f.addCode( + c.setLocal("i", c.i32_const(ateLoopBitBytes.length-2)), + c.block(c.loop( + + c.call(prefix + "_prepDblStep", R, c.getLocal("pCoef")), + c.setLocal("pCoef", c.i32_add(c.getLocal("pCoef"), c.i32_const(ateCoefSize))), + + c.if( + c.i32_load8_s(c.getLocal("i"), pAteLoopBitBytes), + [ + ...c.call(prefix + "_prepAddStep", R, base, c.getLocal("pCoef")), + ...c.setLocal("pCoef", c.i32_add(c.getLocal("pCoef"), c.i32_const(ateCoefSize))), + ] + ), + c.br_if(1, c.i32_eqz ( c.getLocal("i") )), + c.setLocal("i", c.i32_sub(c.getLocal("i"), c.i32_const(1))), + c.br(0) + )) + ); + } + + + function buildF6Mul1() { + const f = module.addFunction(f6mPrefix+ "_mul1"); + f.addParam("pA", "i32"); // F6 + f.addParam("pC1", "i32"); // F2 + f.addParam("pR", "i32"); // F6 + + const c = f.getCodeBuilder(); + + const A_c0 = c.getLocal("pA"); + const A_c1 = c.i32_add(c.getLocal("pA"), c.i32_const(f1size*2)); + const A_c2 = c.i32_add(c.getLocal("pA"), c.i32_const(f1size*4)); + + const c1 = c.getLocal("pC1"); + + const t1 = c.getLocal("pR"); + const t2 = c.i32_add(c.getLocal("pR"), c.i32_const(f1size*2)); + const b_b = c.i32_add(c.getLocal("pR"), c.i32_const(f1size*4)); + + const Ac0_Ac1 = c.i32_const(module.alloc(f1size*2)); + const Ac1_Ac2 = c.i32_const(module.alloc(f1size*2)); + + f.addCode( + + c.call(f2mPrefix + "_add", A_c0, A_c1, Ac0_Ac1), + c.call(f2mPrefix + "_add", A_c1, A_c2, Ac1_Ac2), + + // let b_b = self.c1 * c1; + c.call(f2mPrefix + "_mul", A_c1, c1, b_b), + + // let t1 = (self.c1 + self.c2) * c1 - b_b; + c.call(f2mPrefix + "_mul", Ac1_Ac2, c1, t1), + c.call(f2mPrefix + "_sub", t1, b_b, t1), + + // let t1 = t1.mul_by_nonresidue(); + c.call(f2mPrefix + "_mulNR", t1, t1), + + // let t2 = (self.c0 + self.c1) * c1 - b_b; + c.call(f2mPrefix + "_mul", Ac0_Ac1, c1, t2), + c.call(f2mPrefix + "_sub", t2, b_b, t2), + ); + } + buildF6Mul1(); + + function buildF6Mul01() { + const f = module.addFunction(f6mPrefix+ "_mul01"); + f.addParam("pA", "i32"); // F6 + f.addParam("pC0", "i32"); // F2 + f.addParam("pC1", "i32"); // F2 + f.addParam("pR", "i32"); // F6 + + const c = f.getCodeBuilder(); + + const A_c0 = c.getLocal("pA"); + const A_c1 = c.i32_add(c.getLocal("pA"), c.i32_const(f1size*2)); + const A_c2 = c.i32_add(c.getLocal("pA"), c.i32_const(f1size*4)); + + const c0 = c.getLocal("pC0"); + const c1 = c.getLocal("pC1"); + + const t1 = c.getLocal("pR"); + const t2 = c.i32_add(c.getLocal("pR"), c.i32_const(f1size*2)); + const t3 = c.i32_add(c.getLocal("pR"), c.i32_const(f1size*4)); + + const a_a = c.i32_const(module.alloc(f1size*2)); + const b_b = c.i32_const(module.alloc(f1size*2)); + const Ac0_Ac1 = c.i32_const(module.alloc(f1size*2)); + const Ac0_Ac2 = c.i32_const(module.alloc(f1size*2)); + + f.addCode( + // let a_a = self.c0 * c0; + c.call(f2mPrefix + "_mul", A_c0, c0, a_a), + + // let b_b = self.c1 * c1; + c.call(f2mPrefix + "_mul", A_c1, c1, b_b), + + + c.call(f2mPrefix + "_add", A_c0, A_c1, Ac0_Ac1), + c.call(f2mPrefix + "_add", A_c0, A_c2, Ac0_Ac2), + + // let t1 = (self.c1 + self.c2) * c1 - b_b; + c.call(f2mPrefix + "_add", A_c1, A_c2, t1), + c.call(f2mPrefix + "_mul", t1, c1, t1), + c.call(f2mPrefix + "_sub", t1, b_b, t1), + + // let t1 = t1.mul_by_nonresidue() + a_a; + c.call(f2mPrefix + "_mulNR", t1, t1), + c.call(f2mPrefix + "_add", t1, a_a, t1), + + // let t2 = (c0 + c1) * (self.c0 + self.c1) - a_a - b_b; + c.call(f2mPrefix + "_add", c0, c1, t2), + c.call(f2mPrefix + "_mul", t2, Ac0_Ac1, t2), + c.call(f2mPrefix + "_sub", t2, a_a, t2), + c.call(f2mPrefix + "_sub", t2, b_b, t2), + + // let t3 = (self.c0 + self.c2) * c0 - a_a + b_b; + c.call(f2mPrefix + "_mul", Ac0_Ac2, c0, t3), + c.call(f2mPrefix + "_sub", t3, a_a, t3), + c.call(f2mPrefix + "_add", t3, b_b, t3), + + + ); + } + buildF6Mul01(); + + + function buildF12Mul014() { + + const f = module.addFunction(ftmPrefix+ "_mul014"); + f.addParam("pA", "i32"); // F12 + f.addParam("pC0", "i32"); // F2 + f.addParam("pC1", "i32"); // F2 + f.addParam("pC4", "i32"); // F2 + f.addParam("pR", "i32"); // F12 + + const c = f.getCodeBuilder(); + + + const A_c0 = c.getLocal("pA"); + const A_c1 = c.i32_add(c.getLocal("pA"), c.i32_const(f1size*6)); + + const c0 = c.getLocal("pC0"); + const c1 = c.getLocal("pC1"); + const c4 = c.getLocal("pC4"); + + const aa = c.i32_const(module.alloc(f1size*6)); + const bb = c.i32_const(module.alloc(f1size*6)); + const o = c.i32_const(module.alloc(f1size*2)); + + const R_c0 = c.getLocal("pR"); + const R_c1 = c.i32_add(c.getLocal("pR"), c.i32_const(f1size*6)); + + f.addCode( + // let aa = self.c0.mul_by_01(c0, c1); + c.call(f6mPrefix + "_mul01", A_c0, c0, c1, aa), + + // let bb = self.c1.mul_by_1(c4); + c.call(f6mPrefix + "_mul1", A_c1, c4, bb), + + // let o = c1 + c4; + c.call(f2mPrefix + "_add", c1, c4, o), + + // let c1 = self.c1 + self.c0; + c.call(f6mPrefix + "_add", A_c1, A_c0, R_c1), + + // let c1 = c1.mul_by_01(c0, &o); + c.call(f6mPrefix + "_mul01", R_c1, c0, o, R_c1), + + // let c1 = c1 - aa - bb; + c.call(f6mPrefix + "_sub", R_c1, aa, R_c1), + c.call(f6mPrefix + "_sub", R_c1, bb, R_c1), + + // let c0 = bb; + c.call(f6mPrefix + "_copy", bb, R_c0), + + // let c0 = c0.mul_by_nonresidue(); + c.call(f6mPrefix + "_mulNR", R_c0, R_c0), + + // let c0 = c0 + aa; + c.call(f6mPrefix + "_add", R_c0, aa, R_c0), + ); + } + buildF12Mul014(); + + + function buildELL() { + const f = module.addFunction(prefix+ "_ell"); + f.addParam("pP", "i32"); + f.addParam("pCoefs", "i32"); + f.addParam("pF", "i32"); + + const c = f.getCodeBuilder(); + + const Px = c.getLocal("pP"); + const Py = c.i32_add(c.getLocal("pP"), c.i32_const(n8q)); + + const F = c.getLocal("pF"); + + const coef0_0 = c.getLocal("pCoefs"); + const coef0_1 = c.i32_add(c.getLocal("pCoefs"), c.i32_const(f1size)); + const coef1_0 = c.i32_add(c.getLocal("pCoefs"), c.i32_const(f1size*2)); + const coef1_1 = c.i32_add(c.getLocal("pCoefs"), c.i32_const(f1size*3)); + const coef2 = c.i32_add(c.getLocal("pCoefs"), c.i32_const(f1size*4)); + + const pc0 = module.alloc(f1size*2); + const c0 = c.i32_const(pc0); + const c0_c0 = c.i32_const(pc0); + const c0_c1 = c.i32_const(pc0+f1size); + + const pc1 = module.alloc(f1size*2); + const c1 = c.i32_const(pc1); + const c1_c0 = c.i32_const(pc1); + const c1_c1 = c.i32_const(pc1+f1size); + f.addCode( + // let mut c0 = coeffs.0; + // let mut c1 = coeffs.1; + // + // c0.c0 *= p.y; + // c0.c1 *= p.y; + // + // c1.c0 *= p.x; + // c1.c1 *= p.x; + // + // f.mul_by_014(&coeffs.2, &c1, &c0) + + c.call(f1mPrefix + "_mul", coef0_0, Py, c0_c0), + c.call(f1mPrefix + "_mul", coef0_1, Py, c0_c1), + c.call(f1mPrefix + "_mul", coef1_0, Px, c1_c0), + c.call(f1mPrefix + "_mul", coef1_1, Px, c1_c1), + + c.call(ftmPrefix + "_mul014", F, coef2, c1, c0, F), + + ); + + } + buildELL(); + + function buildMillerLoop() { + const f = module.addFunction(prefix+ "_millerLoop"); + f.addParam("ppreP", "i32"); + f.addParam("ppreQ", "i32"); + f.addParam("r", "i32"); + f.addLocal("pCoef", "i32"); + f.addLocal("i", "i32"); + + const c = f.getCodeBuilder(); + + const preP = c.getLocal("ppreP"); + c.getLocal("ppreQ"); + + const coefs = c.getLocal("pCoef"); + + const F = c.getLocal("r"); + + + f.addCode( + c.call(ftmPrefix + "_one", F), + + c.if( + c.call(g1mPrefix + "_isZero", preP), + c.ret([]) + ), + c.if( + c.call(g1mPrefix + "_isZero", c.getLocal("ppreQ")), + c.ret([]) + ), + c.setLocal("pCoef", c.i32_add( c.getLocal("ppreQ"), c.i32_const(f2size*3))), + + c.setLocal("i", c.i32_const(ateLoopBitBytes.length-2)), + c.block(c.loop( + + + c.call(prefix + "_ell", preP, coefs, F), + c.setLocal("pCoef", c.i32_add(c.getLocal("pCoef"), c.i32_const(ateCoefSize))), + + c.if( + c.i32_load8_s(c.getLocal("i"), pAteLoopBitBytes), + [ + ...c.call(prefix + "_ell", preP, coefs, F), + ...c.setLocal("pCoef", c.i32_add(c.getLocal("pCoef"), c.i32_const(ateCoefSize))), + ] + ), + c.call(ftmPrefix + "_square", F, F), + + c.br_if(1, c.i32_eq ( c.getLocal("i"), c.i32_const(1) )), + c.setLocal("i", c.i32_sub(c.getLocal("i"), c.i32_const(1))), + c.br(0) + )), + c.call(prefix + "_ell", preP, coefs, F), + + ); + + + { + f.addCode( + c.call(ftmPrefix + "_conjugate", F, F), + ); + } + } + + + function buildFrobeniusMap(n) { + const F12 = [ + [ + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("1"), bigInt$7("0")], + ], + [ + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("3850754370037169011952147076051364057158807420970682438676050522613628423219637725072182697113062777891589506424760"), bigInt$7("151655185184498381465642749684540099398075398968325446656007613510403227271200139370504932015952886146304766135027")], + [bigInt$7("793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620351"), bigInt$7("0")], + [bigInt$7("2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530"), bigInt$7("1028732146235106349975324479215795277384839936929757896155643118032610843298655225875571310552543014690878354869257")], + [bigInt$7("793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350"), bigInt$7("0")], + [bigInt$7("3125332594171059424908108096204648978570118281977575435832422631601824034463382777937621250592425535493320683825557"), bigInt$7("877076961050607968509681729531255177986764537961432449499635504522207616027455086505066378536590128544573588734230")], + [bigInt$7("4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559786"), bigInt$7("0")], + [bigInt$7("151655185184498381465642749684540099398075398968325446656007613510403227271200139370504932015952886146304766135027"), bigInt$7("3850754370037169011952147076051364057158807420970682438676050522613628423219637725072182697113062777891589506424760")], + [bigInt$7("4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436"), bigInt$7("0")], + [bigInt$7("1028732146235106349975324479215795277384839936929757896155643118032610843298655225875571310552543014690878354869257"), bigInt$7("2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530")], + [bigInt$7("4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939437"), bigInt$7("0")], + [bigInt$7("877076961050607968509681729531255177986764537961432449499635504522207616027455086505066378536590128544573588734230"), bigInt$7("3125332594171059424908108096204648978570118281977575435832422631601824034463382777937621250592425535493320683825557")], + ] + ]; + + const F6 = [ + [ + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("1"), bigInt$7("0")], + ], + [ + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("0"), bigInt$7("4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436")], + [bigInt$7("793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350"), bigInt$7("0")], + [bigInt$7("0"), bigInt$7("1")], + [bigInt$7("4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436"), bigInt$7("0")], + [bigInt$7("0"), bigInt$7("793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350")], + ], + [ + [bigInt$7("1"), bigInt$7("0")], + [bigInt$7("4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939437"), bigInt$7("0")], + [bigInt$7("4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436"), bigInt$7("0")], + [bigInt$7("4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559786"), bigInt$7("0")], + [bigInt$7("793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350"), bigInt$7("0")], + [bigInt$7("793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620351"), bigInt$7("0")], + ] + ]; + + const f = module.addFunction(ftmPrefix + "_frobeniusMap"+n); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + for (let i=0; i<6; i++) { + const X = (i==0) ? c.getLocal("x") : c.i32_add(c.getLocal("x"), c.i32_const(i*f2size)); + const Xc0 = X; + const Xc1 = c.i32_add(c.getLocal("x"), c.i32_const(i*f2size + f1size)); + const R = (i==0) ? c.getLocal("r") : c.i32_add(c.getLocal("r"), c.i32_const(i*f2size)); + const Rc0 = R; + const Rc1 = c.i32_add(c.getLocal("r"), c.i32_const(i*f2size + f1size)); + const coef = mul2(F12[Math.floor(i/3)][n%12] , F6[i%3][n%6]); + const pCoef = module.alloc([ + ...utils$7.bigInt2BytesLE(toMontgomery(coef[0]), n8q), + ...utils$7.bigInt2BytesLE(toMontgomery(coef[1]), n8q), + ]); + if (n%2 == 1) { + f.addCode( + c.call(f1mPrefix + "_copy", Xc0, Rc0), + c.call(f1mPrefix + "_neg", Xc1, Rc1), + c.call(f2mPrefix + "_mul", R, c.i32_const(pCoef), R), + ); + } else { + f.addCode(c.call(f2mPrefix + "_mul", X, c.i32_const(pCoef), R)); + } + } + + function mul2(a, b) { + const ac0 = bigInt$7(a[0]); + const ac1 = bigInt$7(a[1]); + const bc0 = bigInt$7(b[0]); + const bc1 = bigInt$7(b[1]); + const res = [ + ac0.times(bc0).minus( ac1.times(bc1) ).mod(q), + ac0.times(bc1).add( ac1.times(bc0) ).mod(q), + ]; + if (res[0].isNegative()) res[0] = res[0].add(q); + return res; + } + + } + + + function buildCyclotomicSquare() { + const f = module.addFunction(prefix+ "__cyclotomicSquare"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const x0 = c.getLocal("x"); + const x4 = c.i32_add(c.getLocal("x"), c.i32_const(f2size)); + const x3 = c.i32_add(c.getLocal("x"), c.i32_const(2*f2size)); + const x2 = c.i32_add(c.getLocal("x"), c.i32_const(3*f2size)); + const x1 = c.i32_add(c.getLocal("x"), c.i32_const(4*f2size)); + const x5 = c.i32_add(c.getLocal("x"), c.i32_const(5*f2size)); + + const r0 = c.getLocal("r"); + const r4 = c.i32_add(c.getLocal("r"), c.i32_const(f2size)); + const r3 = c.i32_add(c.getLocal("r"), c.i32_const(2*f2size)); + const r2 = c.i32_add(c.getLocal("r"), c.i32_const(3*f2size)); + const r1 = c.i32_add(c.getLocal("r"), c.i32_const(4*f2size)); + const r5 = c.i32_add(c.getLocal("r"), c.i32_const(5*f2size)); + + const t0 = c.i32_const(module.alloc(f2size)); + const t1 = c.i32_const(module.alloc(f2size)); + const t2 = c.i32_const(module.alloc(f2size)); + const t3 = c.i32_const(module.alloc(f2size)); + const t4 = c.i32_const(module.alloc(f2size)); + const t5 = c.i32_const(module.alloc(f2size)); + const tmp = c.i32_const(module.alloc(f2size)); + const AUX = c.i32_const(module.alloc(f2size)); + + + f.addCode( + +// c.call(ftmPrefix + "_square", x0, r0), + + // // t0 + t1*y = (z0 + z1*y)^2 = a^2 + // tmp = z0 * z1; + // t0 = (z0 + z1) * (z0 + my_Fp6::non_residue * z1) - tmp - my_Fp6::non_residue * tmp; + // t1 = tmp + tmp; + c.call(f2mPrefix + "_mul", x0, x1, tmp), + c.call(f2mPrefix + "_mulNR", x1, t0), + c.call(f2mPrefix + "_add", x0, t0, t0), + c.call(f2mPrefix + "_add", x0, x1, AUX), + c.call(f2mPrefix + "_mul", AUX, t0, t0), + c.call(f2mPrefix + "_mulNR", tmp, AUX), + c.call(f2mPrefix + "_add", tmp, AUX, AUX), + c.call(f2mPrefix + "_sub", t0, AUX, t0), + c.call(f2mPrefix + "_add", tmp, tmp, t1), + + // // t2 + t3*y = (z2 + z3*y)^2 = b^2 + // tmp = z2 * z3; + // t2 = (z2 + z3) * (z2 + my_Fp6::non_residue * z3) - tmp - my_Fp6::non_residue * tmp; + // t3 = tmp + tmp; + c.call(f2mPrefix + "_mul", x2, x3, tmp), + c.call(f2mPrefix + "_mulNR", x3, t2), + c.call(f2mPrefix + "_add", x2, t2, t2), + c.call(f2mPrefix + "_add", x2, x3, AUX), + c.call(f2mPrefix + "_mul", AUX, t2, t2), + c.call(f2mPrefix + "_mulNR", tmp, AUX), + c.call(f2mPrefix + "_add", tmp, AUX, AUX), + c.call(f2mPrefix + "_sub", t2, AUX, t2), + c.call(f2mPrefix + "_add", tmp, tmp, t3), + + // // t4 + t5*y = (z4 + z5*y)^2 = c^2 + // tmp = z4 * z5; + // t4 = (z4 + z5) * (z4 + my_Fp6::non_residue * z5) - tmp - my_Fp6::non_residue * tmp; + // t5 = tmp + tmp; + c.call(f2mPrefix + "_mul", x4, x5, tmp), + c.call(f2mPrefix + "_mulNR", x5, t4), + c.call(f2mPrefix + "_add", x4, t4, t4), + c.call(f2mPrefix + "_add", x4, x5, AUX), + c.call(f2mPrefix + "_mul", AUX, t4, t4), + c.call(f2mPrefix + "_mulNR", tmp, AUX), + c.call(f2mPrefix + "_add", tmp, AUX, AUX), + c.call(f2mPrefix + "_sub", t4, AUX, t4), + c.call(f2mPrefix + "_add", tmp, tmp, t5), + + // For A + // z0 = 3 * t0 - 2 * z0 + c.call(f2mPrefix + "_sub", t0, x0, r0), + c.call(f2mPrefix + "_add", r0, r0, r0), + c.call(f2mPrefix + "_add", t0, r0, r0), + // z1 = 3 * t1 + 2 * z1 + c.call(f2mPrefix + "_add", t1, x1, r1), + c.call(f2mPrefix + "_add", r1, r1, r1), + c.call(f2mPrefix + "_add", t1, r1, r1), + + // For B + // z2 = 3 * (xi * t5) + 2 * z2 + c.call(f2mPrefix + "_mul", t5, c.i32_const(pBls12381Twist), AUX), + c.call(f2mPrefix + "_add", AUX, x2, r2), + c.call(f2mPrefix + "_add", r2, r2, r2), + c.call(f2mPrefix + "_add", AUX, r2, r2), + // z3 = 3 * t4 - 2 * z3 + c.call(f2mPrefix + "_sub", t4, x3, r3), + c.call(f2mPrefix + "_add", r3, r3, r3), + c.call(f2mPrefix + "_add", t4, r3, r3), + + // For C + // z4 = 3 * t2 - 2 * z4 + c.call(f2mPrefix + "_sub", t2, x4, r4), + c.call(f2mPrefix + "_add", r4, r4, r4), + c.call(f2mPrefix + "_add", t2, r4, r4), + // z5 = 3 * t3 + 2 * z5 + c.call(f2mPrefix + "_add", t3, x5, r5), + c.call(f2mPrefix + "_add", r5, r5, r5), + c.call(f2mPrefix + "_add", t3, r5, r5), + + ); + } + + + function buildCyclotomicExp(exponent, isExpNegative, fnName) { + const exponentNafBytes = naf(exponent).map( (b) => (b==-1 ? 0xFF: b) ); + const pExponentNafBytes = module.alloc(exponentNafBytes); + // const pExponent = module.alloc(utils.bigInt2BytesLE(exponent, n8)); + + const f = module.addFunction(prefix+ "__cyclotomicExp_"+fnName); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + f.addLocal("bit", "i32"); + f.addLocal("i", "i32"); + + const c = f.getCodeBuilder(); + + const x = c.getLocal("x"); + + const res = c.getLocal("r"); + + const inverse = c.i32_const(module.alloc(ftsize)); + + + f.addCode( +// c.call(ftmPrefix + "_exp", x, c.i32_const(pExponent), c.i32_const(32), res), + + c.call(ftmPrefix + "_conjugate", x, inverse), + c.call(ftmPrefix + "_one", res), + + c.if( + c.teeLocal("bit", c.i32_load8_s(c.i32_const(exponentNafBytes.length-1), pExponentNafBytes)), + c.if( + c.i32_eq( + c.getLocal("bit"), + c.i32_const(1) + ), + c.call(ftmPrefix + "_mul", res, x, res), + c.call(ftmPrefix + "_mul", res, inverse, res), + ) + ), + + c.setLocal("i", c.i32_const(exponentNafBytes.length-2)), + c.block(c.loop( +// c.call(ftmPrefix + "_square", res, res), + c.call(prefix + "__cyclotomicSquare", res, res), + c.if( + c.teeLocal("bit", c.i32_load8_s(c.getLocal("i"), pExponentNafBytes)), + c.if( + c.i32_eq( + c.getLocal("bit"), + c.i32_const(1) + ), + c.call(ftmPrefix + "_mul", res, x, res), + c.call(ftmPrefix + "_mul", res, inverse, res), + ) + ), + c.br_if(1, c.i32_eqz ( c.getLocal("i") )), + c.setLocal("i", c.i32_sub(c.getLocal("i"), c.i32_const(1))), + c.br(0) + )) + ); + + if (isExpNegative) { + f.addCode( + c.call(ftmPrefix + "_conjugate", res, res), + ); + } + + } + + function buildFinalExponentiation() { + buildCyclotomicSquare(); + buildCyclotomicExp(finalExpZ, finalExpIsNegative, "w0"); + + const f = module.addFunction(prefix+ "_finalExponentiation"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const c = f.getCodeBuilder(); + + const elt = c.getLocal("x"); + const res = c.getLocal("r"); + const t0 = c.i32_const(module.alloc(ftsize)); + const t1 = c.i32_const(module.alloc(ftsize)); + const t2 = c.i32_const(module.alloc(ftsize)); + const t3 = c.i32_const(module.alloc(ftsize)); + const t4 = c.i32_const(module.alloc(ftsize)); + const t5 = c.i32_const(module.alloc(ftsize)); + const t6 = c.i32_const(module.alloc(ftsize)); + + f.addCode( + + // let mut t0 = f.frobenius_map(6) + c.call(ftmPrefix + "_frobeniusMap6", elt, t0), + + // let t1 = f.invert() + c.call(ftmPrefix + "_inverse", elt, t1), + + // let mut t2 = t0 * t1; + c.call(ftmPrefix + "_mul", t0, t1, t2), + + // t1 = t2.clone(); + c.call(ftmPrefix + "_copy", t2, t1), + + // t2 = t2.frobenius_map().frobenius_map(); + c.call(ftmPrefix + "_frobeniusMap2", t2, t2), + + // t2 *= t1; + c.call(ftmPrefix + "_mul", t2, t1, t2), + + + // t1 = cyclotomic_square(t2).conjugate(); + c.call(prefix + "__cyclotomicSquare", t2, t1), + c.call(ftmPrefix + "_conjugate", t1, t1), + + // let mut t3 = cycolotomic_exp(t2); + c.call(prefix + "__cyclotomicExp_w0", t2, t3), + + // let mut t4 = cyclotomic_square(t3); + c.call(prefix + "__cyclotomicSquare", t3, t4), + + // let mut t5 = t1 * t3; + c.call(ftmPrefix + "_mul", t1, t3, t5), + + // t1 = cycolotomic_exp(t5); + c.call(prefix + "__cyclotomicExp_w0", t5, t1), + + // t0 = cycolotomic_exp(t1); + c.call(prefix + "__cyclotomicExp_w0", t1, t0), + + // let mut t6 = cycolotomic_exp(t0); + c.call(prefix + "__cyclotomicExp_w0", t0, t6), + + // t6 *= t4; + c.call(ftmPrefix + "_mul", t6, t4, t6), + + // t4 = cycolotomic_exp(t6); + c.call(prefix + "__cyclotomicExp_w0", t6, t4), + + // t5 = t5.conjugate(); + c.call(ftmPrefix + "_conjugate", t5, t5), + + // t4 *= t5 * t2; + c.call(ftmPrefix + "_mul", t4, t5, t4), + c.call(ftmPrefix + "_mul", t4, t2, t4), + + // t5 = t2.conjugate(); + c.call(ftmPrefix + "_conjugate", t2, t5), + + // t1 *= t2; + c.call(ftmPrefix + "_mul", t1, t2, t1), + + // t1 = t1.frobenius_map().frobenius_map().frobenius_map(); + c.call(ftmPrefix + "_frobeniusMap3", t1, t1), + + // t6 *= t5; + c.call(ftmPrefix + "_mul", t6, t5, t6), + + // t6 = t6.frobenius_map(); + c.call(ftmPrefix + "_frobeniusMap1", t6, t6), + + // t3 *= t0; + c.call(ftmPrefix + "_mul", t3, t0, t3), + + // t3 = t3.frobenius_map().frobenius_map(); + c.call(ftmPrefix + "_frobeniusMap2", t3, t3), + + // t3 *= t1; + c.call(ftmPrefix + "_mul", t3, t1, t3), + + // t3 *= t6; + c.call(ftmPrefix + "_mul", t3, t6, t3), + + // f = t3 * t4; + c.call(ftmPrefix + "_mul", t3, t4, res), + + ); + } + + + function buildFinalExponentiationOld() { + const f = module.addFunction(prefix+ "_finalExponentiationOld"); + f.addParam("x", "i32"); + f.addParam("r", "i32"); + + const exponent = bigInt$7("322277361516934140462891564586510139908379969514828494218366688025288661041104682794998680497580008899973249814104447692778988208376779573819485263026159588510513834876303014016798809919343532899164848730280942609956670917565618115867287399623286813270357901731510188149934363360381614501334086825442271920079363289954510565375378443704372994881406797882676971082200626541916413184642520269678897559532260949334760604962086348898118982248842634379637598665468817769075878555493752214492790122785850202957575200176084204422751485957336465472324810982833638490904279282696134323072515220044451592646885410572234451732790590013479358343841220074174848221722017083597872017638514103174122784843925578370430843522959600095676285723737049438346544753168912974976791528535276317256904336520179281145394686565050419250614107803233314658825463117900250701199181529205942363159325765991819433914303908860460720581408201373164047773794825411011922305820065611121544561808414055302212057471395719432072209245600258134364584636810093520285711072578721435517884103526483832733289802426157301542744476740008494780363354305116978805620671467071400711358839553375340724899735460480144599782014906586543813292157922220645089192130209334926661588737007768565838519456601560804957985667880395221049249803753582637708560"); + + const pExponent = module.alloc(utils$7.bigInt2BytesLE( exponent, 544 )); + + const c = f.getCodeBuilder(); + + f.addCode( + c.call(ftmPrefix + "_exp", c.getLocal("x"), c.i32_const(pExponent), c.i32_const(544), c.getLocal("r")), + ); + } + + + const pPreP = module.alloc(prePSize); + const pPreQ = module.alloc(preQSize); + + function buildPairingEquation(nPairings) { + + const f = module.addFunction(prefix+ "_pairingEq"+nPairings); + for (let i=0; i. +*/ + +// module.exports.bn128_wasm = require("./build/bn128_wasm.js"); +// module.exports.bls12381_wasm = require("./build/bls12381_wasm.js"); +// module.exports.mnt6753_wasm = require("./build/mnt6753_wasm.js"); + +var buildBn128$1 = build_bn128; +var buildBls12381$1 = build_bls12381; + +/* global BigInt */ + +function stringifyBigInts$4(o) { + if ((typeof(o) == "bigint") || o.eq !== undefined) { + return o.toString(10); + } else if (o instanceof Uint8Array) { + return fromRprLE(o, 0); + } else if (Array.isArray(o)) { + return o.map(stringifyBigInts$4); + } else if (typeof o == "object") { + const res = {}; + const keys = Object.keys(o); + keys.forEach( (k) => { + res[k] = stringifyBigInts$4(o[k]); + }); + return res; + } else { + return o; + } +} + +function unstringifyBigInts$6(o) { + if ((typeof(o) == "string") && (/^[0-9]+$/.test(o) )) { + return BigInt(o); + } else if ((typeof(o) == "string") && (/^0x[0-9a-fA-F]+$/.test(o) )) { + return BigInt(o); + } else if (Array.isArray(o)) { + return o.map(unstringifyBigInts$6); + } else if (typeof o == "object") { + if (o===null) return null; + const res = {}; + const keys = Object.keys(o); + keys.forEach( (k) => { + res[k] = unstringifyBigInts$6(o[k]); + }); + return res; + } else { + return o; + } +} + +function beBuff2int$2(buff) { + let res = BigInt(0); + let i = buff.length; + let offset = 0; + const buffV = new DataView(buff.buffer, buff.byteOffset, buff.byteLength); + while (i>0) { + if (i >= 4) { + i -= 4; + res += BigInt(buffV.getUint32(i)) << BigInt(offset*8); + offset += 4; + } else if (i >= 2) { + i -= 2; + res += BigInt(buffV.getUint16(i)) << BigInt(offset*8); + offset += 2; + } else { + i -= 1; + res += BigInt(buffV.getUint8(i)) << BigInt(offset*8); + offset += 1; + } + } + return res; +} + +function beInt2Buff$2(n, len) { + let r = n; + const buff = new Uint8Array(len); + const buffV = new DataView(buff.buffer); + let o = len; + while (o > 0) { + if (o-4 >= 0) { + o -= 4; + buffV.setUint32(o, Number(r & BigInt(0xFFFFFFFF))); + r = r >> BigInt(32); + } else if (o-2 >= 0) { + o -= 2; + buffV.setUint16(o, Number(r & BigInt(0xFFFF))); + r = r >> BigInt(16); + } else { + o -= 1; + buffV.setUint8(o, Number(r & BigInt(0xFF))); + r = r >> BigInt(8); + } + } + if (r) { + throw new Error("Number does not fit in this length"); + } + return buff; +} + + +function leBuff2int$2(buff) { + let res = BigInt(0); + let i = 0; + const buffV = new DataView(buff.buffer, buff.byteOffset, buff.byteLength); + while (i> BigInt(32); + } else if (o+2 <= len) { + buffV.setUint16(Number(o, r & BigInt(0xFFFF)), true ); + o += 2; + r = r >> BigInt(16); + } else { + buffV.setUint8(Number(o, r & BigInt(0xFF)), true ); + o += 1; + r = r >> BigInt(8); + } + } + if (r) { + throw new Error("Number does not fit in this length"); + } + return buff; +} + + +function stringifyFElements$1(F, o) { + if ((typeof(o) == "bigint") || o.eq !== undefined) { + return o.toString(10); + } else if (o instanceof Uint8Array) { + return F.toString(F.e(o)); + } else if (Array.isArray(o)) { + return o.map(stringifyFElements$1.bind(this,F)); + } else if (typeof o == "object") { + const res = {}; + const keys = Object.keys(o); + keys.forEach( (k) => { + res[k] = stringifyFElements$1(F, o[k]); + }); + return res; + } else { + return o; + } +} + + +function unstringifyFElements$1(F, o) { + if ((typeof(o) == "string") && (/^[0-9]+$/.test(o) )) { + return F.e(o); + } else if ((typeof(o) == "string") && (/^0x[0-9a-fA-F]+$/.test(o) )) { + return F.e(o); + } else if (Array.isArray(o)) { + return o.map(unstringifyFElements$1.bind(this,F)); + } else if (typeof o == "object") { + if (o===null) return null; + const res = {}; + const keys = Object.keys(o); + keys.forEach( (k) => { + res[k] = unstringifyFElements$1(F, o[k]); + }); + return res; + } else { + return o; + } +} + +var utils_native = /*#__PURE__*/Object.freeze({ + __proto__: null, + beBuff2int: beBuff2int$2, + beInt2Buff: beInt2Buff$2, + leBuff2int: leBuff2int$2, + leInt2Buff: leInt2Buff$2, + stringifyBigInts: stringifyBigInts$4, + stringifyFElements: stringifyFElements$1, + unstringifyBigInts: unstringifyBigInts$6, + unstringifyFElements: unstringifyFElements$1 +}); + +function stringifyBigInts$3(o) { + if ((typeof(o) == "bigint") || o.eq !== undefined) { + return o.toString(10); + } else if (Array.isArray(o)) { + return o.map(stringifyBigInts$3); + } else if (typeof o == "object") { + const res = {}; + const keys = Object.keys(o); + keys.forEach( (k) => { + res[k] = stringifyBigInts$3(o[k]); + }); + return res; + } else { + return o; + } +} + +function unstringifyBigInts$5(o) { + if ((typeof(o) == "string") && (/^[0-9]+$/.test(o) )) { + return bigInt$e(o); + } else if ((typeof(o) == "string") && (/^0x[0-9a-fA-F]+$/.test(o) )) { + return bigInt$e(o); + } else if (Array.isArray(o)) { + return o.map(unstringifyBigInts$5); + } else if (typeof o == "object") { + const res = {}; + const keys = Object.keys(o); + keys.forEach( (k) => { + res[k] = unstringifyBigInts$5(o[k]); + }); + return res; + } else { + return o; + } +} + +function beBuff2int$1(buff) { + let res = bigInt$e.zero; + for (let i=0; i=0)) { + let c = Number(r.and(bigInt$e("255"))); + buff[o] = c; + o--; + r = r.shiftRight(8); + } + if (!r.eq(bigInt$e.zero)) { + throw new Error("Number does not fit in this length"); + } + return buff; +} + + +function leBuff2int$1 (buff) { + let res = bigInt$e.zero; + for (let i=0; i>=1; + } + return res; +} + +utils$6.bitReverse = function bitReverse(idx, bits) { + return ( + _revTable[idx >>> 24] | + (_revTable[(idx >>> 16) & 0xFF] << 8) | + (_revTable[(idx >>> 8) & 0xFF] << 16) | + (_revTable[idx & 0xFF] << 24) + ) >>> (32-bits); +}; + + +utils$6.log2 = function log2( V ) +{ + return( ( ( V & 0xFFFF0000 ) !== 0 ? ( V &= 0xFFFF0000, 16 ) : 0 ) | ( ( V & 0xFF00FF00 ) !== 0 ? ( V &= 0xFF00FF00, 8 ) : 0 ) | ( ( V & 0xF0F0F0F0 ) !== 0 ? ( V &= 0xF0F0F0F0, 4 ) : 0 ) | ( ( V & 0xCCCCCCCC ) !== 0 ? ( V &= 0xCCCCCCCC, 2 ) : 0 ) | ( ( V & 0xAAAAAAAA ) !== 0 ) ); +}; + +utils$6.buffReverseBits = function buffReverseBits(buff, eSize) { + const n = buff.byteLength /eSize; + const bits = utils$6.log2(n); + if (n != (1 << bits)) { + throw new Error("Invalid number of pointers"); + } + for (let i=0; ir) { + const tmp = buff.slice(i*eSize, (i+1)*eSize); + buff.set( buff.slice(r*eSize, (r+1)*eSize), i*eSize); + buff.set(tmp, r*eSize); + } + } +}; + + +utils$6.array2buffer = function(arr, sG) { + const buff = new Uint8Array(sG*arr.length); + + for (let i=0; i0) { + // bytes to copy from this page + const l = (o+r > PAGE_SIZE) ? (PAGE_SIZE -o) : r; + const srcView = new Uint8Array(this.buffers[p].buffer, this.buffers[p].byteOffset+o, l); + if (l == len) return srcView.slice(); + if (!buff) { + if (len <= PAGE_SIZE) { + buff = new Uint8Array(len); + } else { + buff = new BigBuffer(len); + } + } + buff.set(srcView, len-r); + r = r-l; + p ++; + o = 0; + } + + return buff; + } + + set(buff, offset) { + if (offset === undefined) offset = 0; + + const len = buff.byteLength; + + if (len==0) return; + + const firstPage = Math.floor(offset / PAGE_SIZE); + const lastPage = Math.floor((offset+len-1) / PAGE_SIZE); + + if (firstPage == lastPage) { + if ((buff instanceof BigBuffer)&&(buff.buffers.length==1)) { + return this.buffers[firstPage].set(buff.buffers[0], offset % PAGE_SIZE); + } else { + return this.buffers[firstPage].set(buff, offset % PAGE_SIZE); + } + + } + + + let p = firstPage; + let o = offset % PAGE_SIZE; + let r = len; + while (r>0) { + const l = (o+r > PAGE_SIZE) ? (PAGE_SIZE -o) : r; + const srcView = buff.slice( len -r, len -r+l); + const dstView = new Uint8Array(this.buffers[p].buffer, this.buffers[p].byteOffset + o, l); + dstView.set(srcView); + r = r-l; + p ++; + o = 0; + } + + } +} + +function buildBatchConvert(tm, fnName, sIn, sOut) { + return async function batchConvert(buffIn) { + const nPoints = Math.floor(buffIn.byteLength / sIn); + if ( nPoints * sIn !== buffIn.byteLength) { + throw new Error("Invalid buffer size"); + } + const pointsPerChunk = Math.floor(nPoints/tm.concurrency); + const opPromises = []; + for (let i=0; i=0; i--) { + this.w[i] = this.square(this.w[i+1]); + } + + if (!this.eq(this.w[0], this.one)) { + throw new Error("Error calculating roots of unity"); + } + + this.batchToMontgomery = buildBatchConvert(tm, prefix + "_batchToMontgomery", this.n8, this.n8); + this.batchFromMontgomery = buildBatchConvert(tm, prefix + "_batchFromMontgomery", this.n8, this.n8); + } + + + op2(opName, a, b) { + this.tm.setBuff(this.pOp1, a); + this.tm.setBuff(this.pOp2, b); + this.tm.instance.exports[this.prefix + opName](this.pOp1, this.pOp2, this.pOp3); + return this.tm.getBuff(this.pOp3, this.n8); + } + + op2Bool(opName, a, b) { + this.tm.setBuff(this.pOp1, a); + this.tm.setBuff(this.pOp2, b); + return !!this.tm.instance.exports[this.prefix + opName](this.pOp1, this.pOp2); + } + + op1(opName, a) { + this.tm.setBuff(this.pOp1, a); + this.tm.instance.exports[this.prefix + opName](this.pOp1, this.pOp3); + return this.tm.getBuff(this.pOp3, this.n8); + } + + op1Bool(opName, a) { + this.tm.setBuff(this.pOp1, a); + return !!this.tm.instance.exports[this.prefix + opName](this.pOp1, this.pOp3); + } + + add(a,b) { + return this.op2("_add", a, b); + } + + + eq(a,b) { + return this.op2Bool("_eq", a, b); + } + + isZero(a) { + return this.op1Bool("_isZero", a); + } + + sub(a,b) { + return this.op2("_sub", a, b); + } + + neg(a) { + return this.op1("_neg", a); + } + + inv(a) { + return this.op1("_inverse", a); + } + + toMontgomery(a) { + return this.op1("_toMontgomery", a); + } + + fromMontgomery(a) { + return this.op1("_fromMontgomery", a); + } + + mul(a,b) { + return this.op2("_mul", a, b); + } + + div(a, b) { + this.tm.setBuff(this.pOp1, a); + this.tm.setBuff(this.pOp2, b); + this.tm.instance.exports[this.prefix + "_inverse"](this.pOp2, this.pOp2); + this.tm.instance.exports[this.prefix + "_mul"](this.pOp1, this.pOp2, this.pOp3); + return this.tm.getBuff(this.pOp3, this.n8); + } + + square(a) { + return this.op1("_square", a); + } + + isSquare(a) { + return this.op1Bool("_isSquare", a); + } + + sqrt(a) { + return this.op1("_sqrt", a); + } + + exp(a, b) { + if (!(b instanceof Uint8Array)) { + b = toLEBuff(e(b)); + } + this.tm.setBuff(this.pOp1, a); + this.tm.setBuff(this.pOp2, b); + this.tm.instance.exports[this.prefix + "_exp"](this.pOp1, this.pOp2, b.byteLength, this.pOp3); + return this.tm.getBuff(this.pOp3, this.n8); + } + + isNegative(a) { + return this.op1Bool("_isNegative", a); + } + + e(a, b) { + if (a instanceof Uint8Array) return a; + let ra = e(a, b); + if (isNegative(ra)) { + ra = neg(ra); + if (gt(ra, this.p)) { + ra = mod(ra, this.p); + } + ra = sub(this.p, ra); + } else { + if (gt(ra, this.p)) { + ra = mod(ra, this.p); + } + } + const buff = leInt2Buff(ra, this.n8); + return this.toMontgomery(buff); + } + + toString(a, radix) { + const an = this.fromMontgomery(a); + const s = fromRprLE(an, 0); + return toString$1(s, radix); + } + + fromRng(rng) { + let v; + const buff = new Uint8Array(this.n8); + do { + v = zero; + for (let i=0; i memory.buffer.byteLength) { + const currentPages = memory.buffer.byteLength / 0x10000; + let requiredPages = Math.floor((u32[0] + length) / 0x10000)+1; + if (requiredPages>MAXMEM) requiredPages=MAXMEM; + memory.grow(requiredPages-currentPages); + } + return res; + } + + function allocBuffer(buffer) { + const p = alloc(buffer.byteLength); + setBuffer(p, buffer); + return p; + } + + function getBuffer(pointer, length) { + const u8 = new Uint8Array(memory.buffer); + return new Uint8Array(u8.buffer, u8.byteOffset + pointer, length); + } + + function setBuffer(pointer, buffer) { + const u8 = new Uint8Array(memory.buffer); + u8.set(new Uint8Array(buffer), pointer); + } + + function runTask(task) { + if (task[0].cmd == "INIT") { + return init(task[0]); + } + const ctx = { + vars: [], + out: [] + }; + const u32a = new Uint32Array(memory.buffer, 0, 1); + const oldAlloc = u32a[0]; + for (let i=0; i { + try { + handler.call(this, event); + } + catch (err) { + console.error(err); + } + }); + } + addEventListener(type, fn) { + let events = this[EVENTS].get(type); + if (!events) this[EVENTS].set(type, events = []); + events.push(fn); + } + removeEventListener(type, fn) { + let events = this[EVENTS].get(type); + if (events) { + const index = events.indexOf(fn); + if (index !== -1) events.splice(index, 1); + } + } +} + +function Event(type, target) { + this.type = type; + this.timeStamp = Date.now(); + this.target = this.currentTarget = this.data = null; +} + +// this module is used self-referentially on both sides of the +// thread boundary, but behaves differently in each context. +var Worker$1 = threads.isMainThread ? mainThread() : workerThread(); + +const baseUrl = Url.pathToFileURL(process.cwd() + '/'); + +function mainThread() { + + /** + * A web-compatible Worker implementation atop Node's worker_threads. + * - uses DOM-style events (Event.data, Event.type, etc) + * - supports event handler properties (worker.onmessage) + * - Worker() constructor accepts a module URL + * - accepts the {type:'module'} option + * - emulates WorkerGlobalScope within the worker + * @param {string} url The URL or module specifier to load + * @param {object} [options] Worker construction options + * @param {string} [options.name] Available as `self.name` within the Worker + * @param {string} [options.type="classic"] Pass "module" to create a Module Worker. + */ + class Worker extends EventTarget { + constructor(url, options) { + super(); + const { name, type } = options || {}; + url += ''; + let mod; + if (/^data:/.test(url)) { + mod = url; + } + else { + mod = Url.fileURLToPath(new Url.URL(url, baseUrl)); + } + const worker = new threads.Worker( + __filename, + { workerData: { mod, name, type } } + ); + Object.defineProperty(this, WORKER, { + value: worker + }); + worker.on('message', data => { + const event = new Event('message'); + event.data = data; + this.dispatchEvent(event); + }); + worker.on('error', error => { + error.type = 'error'; + this.dispatchEvent(error); + }); + worker.on('exit', () => { + this.dispatchEvent(new Event('close')); + }); + } + postMessage(data, transferList) { + this[WORKER].postMessage(data, transferList); + } + terminate() { + this[WORKER].terminate(); + } + } + Worker.prototype.onmessage = Worker.prototype.onerror = Worker.prototype.onclose = null; + return Worker; +} + +function workerThread() { + let { mod, name, type } = threads.workerData; + if (!mod) return mainThread(); + + // turn global into a mock WorkerGlobalScope + const self = global.self = global; + + // enqueue messages to dispatch after modules are loaded + let q = []; + function flush() { + const buffered = q; + q = null; + buffered.forEach(event => { self.dispatchEvent(event); }); + } + threads.parentPort.on('message', data => { + const event = new Event('message'); + event.data = data; + if (q == null) self.dispatchEvent(event); + else q.push(event); + }); + threads.parentPort.on('error', err => { + err.type = 'Error'; + self.dispatchEvent(err); + }); + + class WorkerGlobalScope extends EventTarget { + postMessage(data, transferList) { + threads.parentPort.postMessage(data, transferList); + } + // Emulates https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope/close + close() { + process.exit(); + } + } + let proto = Object.getPrototypeOf(global); + delete proto.constructor; + Object.defineProperties(WorkerGlobalScope.prototype, proto); + proto = Object.setPrototypeOf(global, new WorkerGlobalScope()); + ['postMessage', 'addEventListener', 'removeEventListener', 'dispatchEvent'].forEach(fn => { + proto[fn] = proto[fn].bind(global); + }); + global.name = name; + + const isDataUrl = /^data:/.test(mod); + if (type === 'module') { + import(mod) + .catch(err => { + if (isDataUrl && err.message === 'Not supported') { + console.warn('Worker(): Importing data: URLs requires Node 12.10+. Falling back to classic worker.'); + return evaluateDataUrl(mod, name); + } + console.error(err); + }) + .then(flush); + } + else { + try { + if (/^data:/.test(mod)) { + evaluateDataUrl(mod, name); + } + else { + require(mod); + } + } + catch (err) { + console.error(err); + } + Promise.resolve().then(flush); + } +} + +function evaluateDataUrl(url, name) { + const { data } = parseDataUrl(url); + return VM.runInThisContext(data, { + filename: 'worker.<'+(name || 'data:')+'>' + }); +} + +function parseDataUrl(url) { + let [m, type, encoding, data] = url.match(/^data: *([^;,]*)(?: *; *([^,]*))? *,(.*)$/) || []; + if (!m) throw Error('Invalid Data URL.'); + if (encoding) switch (encoding.toLowerCase()) { + case 'base64': + data = Buffer.from(data, 'base64').toString(); + break; + default: + throw Error('Unknown Data URL encoding "' + encoding + '"'); + } + return { type, data }; +} + +/* global navigator, WebAssembly */ +/* + Copyright 2019 0KIMS association. + + This file is part of wasmsnark (Web Assembly zkSnark Prover). + + wasmsnark is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + wasmsnark is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with wasmsnark. If not, see . +*/ + +// const MEM_SIZE = 1000; // Memory size in 64K Pakes (512Mb) +const MEM_SIZE = 25; // Memory size in 64K Pakes (1600Kb) + +let Deferred$1 = class Deferred { + constructor() { + this.promise = new Promise((resolve, reject)=> { + this.reject = reject; + this.resolve = resolve; + }); + } +}; + +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +function stringToBase64(str) { + if (process.browser) { + return globalThis.btoa(str); + } else { + return Buffer.from(str).toString("base64"); + } +} + +const threadSource = stringToBase64("(" + thread$1.toString() + ")(self)"); +const workerSource = "data:application/javascript;base64," + threadSource; + + + +async function buildThreadManager(wasm, singleThread) { + const tm = new ThreadManager(); + + tm.memory = new WebAssembly.Memory({initial:MEM_SIZE}); + tm.u8 = new Uint8Array(tm.memory.buffer); + tm.u32 = new Uint32Array(tm.memory.buffer); + + const wasmModule = await WebAssembly.compile(wasm.code); + + tm.instance = await WebAssembly.instantiate(wasmModule, { + env: { + "memory": tm.memory + } + }); + + tm.singleThread = singleThread; + tm.initalPFree = tm.u32[0]; // Save the Pointer to free space. + tm.pq = wasm.pq; + tm.pr = wasm.pr; + tm.pG1gen = wasm.pG1gen; + tm.pG1zero = wasm.pG1zero; + tm.pG2gen = wasm.pG2gen; + tm.pG2zero = wasm.pG2zero; + tm.pOneT = wasm.pOneT; + + // tm.pTmp0 = tm.alloc(curve.G2.F.n8*3); + // tm.pTmp1 = tm.alloc(curve.G2.F.n8*3); + + + if (singleThread) { + tm.code = wasm.code; + tm.taskManager = thread$1(); + await tm.taskManager([{ + cmd: "INIT", + init: MEM_SIZE, + code: tm.code.slice() + }]); + tm.concurrency = 1; + } else { + tm.workers = []; + tm.pendingDeferreds = []; + tm.working = []; + + let concurrency; + + if ((typeof(navigator) === "object") && navigator.hardwareConcurrency) { + concurrency = navigator.hardwareConcurrency; + } else { + concurrency = require$$0$2.cpus().length; + } + + if(concurrency == 0){ + concurrency = 2; + } + + // Limit to 64 threads for memory reasons. + if (concurrency>64) concurrency=64; + tm.concurrency = concurrency; + + for (let i = 0; i 0); i++) { + if (this.working[i] == false) { + const work = this.actionQueue.shift(); + this.postAction(i, work.data, work.transfers, work.deferred); + } + } + } + + queueAction(actionData, transfers) { + const d = new Deferred$1(); + + if (this.singleThread) { + const res = this.taskManager(actionData); + d.resolve(res); + } else { + this.actionQueue.push({ + data: actionData, + transfers: transfers, + deferred: d + }); + this.processWorks(); + } + return d.promise; + } + + resetMemory() { + this.u32[0] = this.initalPFree; + } + + allocBuff(buff) { + const pointer = this.alloc(buff.byteLength); + this.setBuff(pointer, buff); + return pointer; + } + + getBuff(pointer, length) { + return this.u8.slice(pointer, pointer+ length); + } + + setBuff(pointer, buffer) { + this.u8.set(new Uint8Array(buffer), pointer); + } + + alloc(length) { + while (this.u32[0] & 3) this.u32[0]++; // Return always aligned pointers + const res = this.u32[0]; + this.u32[0] += length; + return res; + } + + async terminate() { + for (let i=0; i=0; i--) { + if (!G.isZero(res)) { + for (let j=0; jMAX_CHUNK_SIZE) chunkSize = MAX_CHUNK_SIZE; + if (chunkSize { + if (logger) logger.debug(`Multiexp end: ${logText}: ${i}/${nPoints}`); + return r; + })); + } + + const result = await Promise.all(opPromises); + + let res = G.zero; + for (let i=result.length-1; i>=0; i--) { + res = G.add(res, result[i]); + } + + return res; + } + + G.multiExp = async function multiExpAffine(buffBases, buffScalars, logger, logText) { + return await _multiExp(buffBases, buffScalars, "jacobian", logger, logText); + }; + G.multiExpAffine = async function multiExpAffine(buffBases, buffScalars, logger, logText) { + return await _multiExp(buffBases, buffScalars, "affine", logger, logText); + }; +} + +function buildFFT(curve, groupName) { + const G = curve[groupName]; + const Fr = curve.Fr; + const tm = G.tm; + async function _fft(buff, inverse, inType, outType, logger, loggerTxt) { + + inType = inType || "affine"; + outType = outType || "affine"; + const MAX_BITS_THREAD = 14; + + let sIn, sMid, sOut, fnIn2Mid, fnMid2Out, fnFFTMix, fnFFTJoin, fnFFTFinal; + if (groupName == "G1") { + if (inType == "affine") { + sIn = G.F.n8*2; + fnIn2Mid = "g1m_batchToJacobian"; + } else { + sIn = G.F.n8*3; + } + sMid = G.F.n8*3; + if (inverse) { + fnFFTFinal = "g1m_fftFinal"; + } + fnFFTJoin = "g1m_fftJoin"; + fnFFTMix = "g1m_fftMix"; + + if (outType == "affine") { + sOut = G.F.n8*2; + fnMid2Out = "g1m_batchToAffine"; + } else { + sOut = G.F.n8*3; + } + + } else if (groupName == "G2") { + if (inType == "affine") { + sIn = G.F.n8*2; + fnIn2Mid = "g2m_batchToJacobian"; + } else { + sIn = G.F.n8*3; + } + sMid = G.F.n8*3; + if (inverse) { + fnFFTFinal = "g2m_fftFinal"; + } + fnFFTJoin = "g2m_fftJoin"; + fnFFTMix = "g2m_fftMix"; + if (outType == "affine") { + sOut = G.F.n8*2; + fnMid2Out = "g2m_batchToAffine"; + } else { + sOut = G.F.n8*3; + } + } else if (groupName == "Fr") { + sIn = G.n8; + sMid = G.n8; + sOut = G.n8; + if (inverse) { + fnFFTFinal = "frm_fftFinal"; + } + fnFFTMix = "frm_fftMix"; + fnFFTJoin = "frm_fftJoin"; + } + + + let returnArray = false; + if (Array.isArray(buff)) { + buff = array2buffer(buff, sIn); + returnArray = true; + } else { + buff = buff.slice(0, buff.byteLength); + } + + const nPoints = buff.byteLength / sIn; + const bits = log2(nPoints); + + if ((1 << bits) != nPoints) { + throw new Error("fft must be multiple of 2" ); + } + + if (bits == Fr.s +1) { + let buffOut; + + if (inverse) { + buffOut = await _fftExtInv(buff, inType, outType, logger, loggerTxt); + } else { + buffOut = await _fftExt(buff, inType, outType, logger, loggerTxt); + } + + if (returnArray) { + return buffer2array(buffOut, sOut); + } else { + return buffOut; + } + } + + let inv; + if (inverse) { + inv = Fr.inv(Fr.e(nPoints)); + } + + let buffOut; + + buffReverseBits(buff, sIn); + + let chunks; + let pointsInChunk = Math.min(1 << MAX_BITS_THREAD, nPoints); + let nChunks = nPoints / pointsInChunk; + + while ((nChunks < tm.concurrency)&&(pointsInChunk>=16)) { + nChunks *= 2; + pointsInChunk /= 2; + } + + const l2Chunk = log2(pointsInChunk); + + const promises = []; + for (let i = 0; i< nChunks; i++) { + if (logger) logger.debug(`${loggerTxt}: fft ${bits} mix start: ${i}/${nChunks}`); + const task = []; + task.push({cmd: "ALLOC", var: 0, len: sMid*pointsInChunk}); + const buffChunk = buff.slice( (pointsInChunk * i)*sIn, (pointsInChunk * (i+1))*sIn); + task.push({cmd: "SET", var: 0, buff: buffChunk}); + if (fnIn2Mid) { + task.push({cmd: "CALL", fnName:fnIn2Mid, params: [{var:0}, {val: pointsInChunk}, {var: 0}]}); + } + for (let j=1; j<=l2Chunk;j++) { + task.push({cmd: "CALL", fnName:fnFFTMix, params: [{var:0}, {val: pointsInChunk}, {val: j}]}); + } + + if (l2Chunk==bits) { + if (fnFFTFinal) { + task.push({cmd: "ALLOCSET", var: 1, buff: inv}); + task.push({cmd: "CALL", fnName: fnFFTFinal, params:[ + {var: 0}, + {val: pointsInChunk}, + {var: 1}, + ]}); + } + if (fnMid2Out) { + task.push({cmd: "CALL", fnName:fnMid2Out, params: [{var:0}, {val: pointsInChunk}, {var: 0}]}); + } + task.push({cmd: "GET", out: 0, var: 0, len: pointsInChunk*sOut}); + } else { + task.push({cmd: "GET", out:0, var: 0, len: sMid*pointsInChunk}); + } + promises.push(tm.queueAction(task).then( (r) => { + if (logger) logger.debug(`${loggerTxt}: fft ${bits} mix end: ${i}/${nChunks}`); + return r; + })); + } + + chunks = await Promise.all(promises); + for (let i = 0; i< nChunks; i++) chunks[i] = chunks[i][0]; + + for (let i = l2Chunk+1; i<=bits; i++) { + if (logger) logger.debug(`${loggerTxt}: fft ${bits} join: ${i}/${bits}`); + const nGroups = 1 << (bits - i); + const nChunksPerGroup = nChunks / nGroups; + const opPromises = []; + for (let j=0; j { + if (logger) logger.debug(`${loggerTxt}: fft ${bits} join ${i}/${bits} ${j+1}/${nGroups} ${k}/${nChunksPerGroup/2}`); + return r; + })); + } + } + + const res = await Promise.all(opPromises); + for (let j=0; j0; i--) { + buffOut.set(chunks[i], p); + p += pointsInChunk*sOut; + delete chunks[i]; // Liberate mem + } + buffOut.set(chunks[0].slice(0, (pointsInChunk-1)*sOut), p); + delete chunks[0]; + } else { + for (let i=0; i (1<<28)) { + buffOut = new BigBuffer(res1[0].byteLength*2); + } else { + buffOut = new Uint8Array(res1[0].byteLength*2); + } + + buffOut.set(res1[0]); + buffOut.set(res1[1], res1[0].byteLength); + + return buffOut; + } + + async function _fftExtInv(buff, inType, outType, logger, loggerTxt) { + let b1, b2; + b1 = buff.slice( 0 , buff.byteLength/2); + b2 = buff.slice( buff.byteLength/2, buff.byteLength); + + const promises = []; + + promises.push( _fft(b1, true, inType, "jacobian", logger, loggerTxt)); + promises.push( _fft(b2, true, inType, "jacobian", logger, loggerTxt)); + + [b1, b2] = await Promise.all(promises); + + const res1 = await _fftJoinExt(b1, b2, "fftJoinExtInv", Fr.one, Fr.shiftInv, "jacobian", outType, logger, loggerTxt); + + let buffOut; + if (res1[0].byteLength > (1<<28)) { + buffOut = new BigBuffer(res1[0].byteLength*2); + } else { + buffOut = new Uint8Array(res1[0].byteLength*2); + } + + buffOut.set(res1[0]); + buffOut.set(res1[1], res1[0].byteLength); + + return buffOut; + } + + + async function _fftJoinExt(buff1, buff2, fn, first, inc, inType, outType, logger, loggerTxt) { + const MAX_CHUNK_SIZE = 1<<16; + const MIN_CHUNK_SIZE = 1<<4; + + let fnName; + let fnIn2Mid, fnMid2Out; + let sOut, sIn, sMid; + + if (groupName == "G1") { + if (inType == "affine") { + sIn = G.F.n8*2; + fnIn2Mid = "g1m_batchToJacobian"; + } else { + sIn = G.F.n8*3; + } + sMid = G.F.n8*3; + fnName = "g1m_"+fn; + if (outType == "affine") { + fnMid2Out = "g1m_batchToAffine"; + sOut = G.F.n8*2; + } else { + sOut = G.F.n8*3; + } + } else if (groupName == "G2") { + if (inType == "affine") { + sIn = G.F.n8*2; + fnIn2Mid = "g2m_batchToJacobian"; + } else { + sIn = G.F.n8*3; + } + fnName = "g2m_"+fn; + sMid = G.F.n8*3; + if (outType == "affine") { + fnMid2Out = "g2m_batchToAffine"; + sOut = G.F.n8*2; + } else { + sOut = G.F.n8*3; + } + } else if (groupName == "Fr") { + sIn = Fr.n8; + sOut = Fr.n8; + sMid = Fr.n8; + fnName = "frm_" + fn; + } else { + throw new Error("Invalid group"); + } + + if (buff1.byteLength != buff2.byteLength) { + throw new Error("Invalid buffer size"); + } + const nPoints = Math.floor(buff1.byteLength / sIn); + if (nPoints != 1 << log2(nPoints)) { + throw new Error("Invalid number of points"); + } + + let chunkSize = Math.floor(nPoints /tm.concurrency); + if (chunkSize < MIN_CHUNK_SIZE) chunkSize = MIN_CHUNK_SIZE; + if (chunkSize > MAX_CHUNK_SIZE) chunkSize = MAX_CHUNK_SIZE; + + const opPromises = []; + + for (let i=0; i { + if (logger) logger.debug(`${loggerTxt}: fftJoinExt End: ${i}/${nPoints}`); + return r; + }) + ); + } + + const result = await Promise.all(opPromises); + + let fullBuffOut1; + let fullBuffOut2; + if (nPoints * sOut > 1<<28) { + fullBuffOut1 = new BigBuffer(nPoints*sOut); + fullBuffOut2 = new BigBuffer(nPoints*sOut); + } else { + fullBuffOut1 = new Uint8Array(nPoints*sOut); + fullBuffOut2 = new Uint8Array(nPoints*sOut); + } + + let p =0; + for (let i=0; i Fr.s+1) { + if (logger) logger.error("lagrangeEvaluations input too big"); + throw new Error("lagrangeEvaluations input too big"); + } + + let t0 = buff.slice(0, buff.byteLength/2); + let t1 = buff.slice(buff.byteLength/2, buff.byteLength); + + + const shiftToSmallM = Fr.exp(Fr.shift, nPoints/2); + const sConst = Fr.inv( Fr.sub(Fr.one, shiftToSmallM)); + + [t0, t1] = await _fftJoinExt(t0, t1, "prepareLagrangeEvaluation", sConst, Fr.shiftInv, inType, "jacobian", logger, loggerTxt + " prep"); + + const promises = []; + + promises.push( _fft(t0, true, "jacobian", outType, logger, loggerTxt + " t0")); + promises.push( _fft(t1, true, "jacobian", outType, logger, loggerTxt + " t1")); + + [t0, t1] = await Promise.all(promises); + + let buffOut; + if (t0.byteLength > (1<<28)) { + buffOut = new BigBuffer(t0.byteLength*2); + } else { + buffOut = new Uint8Array(t0.byteLength*2); + } + + buffOut.set(t0); + buffOut.set(t1, t0.byteLength); + + return buffOut; + }; + + G.fftMix = async function fftMix(buff) { + const sG = G.F.n8*3; + let fnName, fnFFTJoin; + if (groupName == "G1") { + fnName = "g1m_fftMix"; + fnFFTJoin = "g1m_fftJoin"; + } else if (groupName == "G2") { + fnName = "g2m_fftMix"; + fnFFTJoin = "g2m_fftJoin"; + } else if (groupName == "Fr") { + fnName = "frm_fftMix"; + fnFFTJoin = "frm_fftJoin"; + } else { + throw new Error("Invalid group"); + } + + const nPoints = Math.floor(buff.byteLength / sG); + const power = log2(nPoints); + + let nChunks = 1 << log2(tm.concurrency); + + if (nPoints <= nChunks*2) nChunks = 1; + + const pointsPerChunk = nPoints / nChunks; + + const powerChunk = log2(pointsPerChunk); + + const opPromises = []; + for (let i=0; i=0; i--) { + fullBuffOut.set(result[i][0], p); + p+=result[i][0].byteLength; + } + + return fullBuffOut; + }; +} + +async function buildEngine(params) { + + const tm = await buildThreadManager(params.wasm, params.singleThread); + + + const curve = {}; + + curve.q = e(params.wasm.q); + curve.r = e(params.wasm.r); + curve.name = params.name; + curve.tm = tm; + curve.prePSize = params.wasm.prePSize; + curve.preQSize = params.wasm.preQSize; + curve.Fr = new WasmField1(tm, "frm", params.n8r, params.r); + curve.F1 = new WasmField1(tm, "f1m", params.n8q, params.q); + curve.F2 = new WasmField2(tm, "f2m", curve.F1); + curve.G1 = new WasmCurve(tm, "g1m", curve.F1, params.wasm.pG1gen, params.wasm.pG1b, params.cofactorG1); + curve.G2 = new WasmCurve(tm, "g2m", curve.F2, params.wasm.pG2gen, params.wasm.pG2b, params.cofactorG2); + curve.F6 = new WasmField3(tm, "f6m", curve.F2); + curve.F12 = new WasmField2(tm, "ftm", curve.F6); + + curve.Gt = curve.F12; + + buildBatchApplyKey(curve, "G1"); + buildBatchApplyKey(curve, "G2"); + buildBatchApplyKey(curve, "Fr"); + + buildMultiexp(curve, "G1"); + buildMultiexp(curve, "G2"); + + buildFFT(curve, "G1"); + buildFFT(curve, "G2"); + buildFFT(curve, "Fr"); + + buildPairing(curve); + + curve.array2buffer = function(arr, sG) { + const buff = new Uint8Array(sG*arr.length); + + for (let i=0; i. +*/ + +const bigInt$6 = BigIntegerExports$1; + +function toNumber(n) { + let v; + if (typeof n=="string") { + if (n.slice(0,2).toLowerCase() == "0x") { + v = bigInt$6(n.slice(2),16); + } else { + v = bigInt$6(n); + } + } else { + v = bigInt$6(n); + } + return v; +} + +function u32(n) { + const b = []; + const v = toNumber(n); + b.push(v.and(0xFF).toJSNumber()); + b.push(v.shiftRight(8).and(0xFF).toJSNumber()); + b.push(v.shiftRight(16).and(0xFF).toJSNumber()); + b.push(v.shiftRight(24).and(0xFF).toJSNumber()); + return b; +} + +function u64(n) { + const b = []; + const v = toNumber(n); + b.push(v.and(0xFF).toJSNumber()); + b.push(v.shiftRight(8).and(0xFF).toJSNumber()); + b.push(v.shiftRight(16).and(0xFF).toJSNumber()); + b.push(v.shiftRight(24).and(0xFF).toJSNumber()); + b.push(v.shiftRight(32).and(0xFF).toJSNumber()); + b.push(v.shiftRight(40).and(0xFF).toJSNumber()); + b.push(v.shiftRight(48).and(0xFF).toJSNumber()); + b.push(v.shiftRight(56).and(0xFF).toJSNumber()); + return b; +} + +function toUTF8Array(str) { + var utf8 = []; + for (var i=0; i < str.length; i++) { + var charcode = str.charCodeAt(i); + if (charcode < 0x80) utf8.push(charcode); + else if (charcode < 0x800) { + utf8.push(0xc0 | (charcode >> 6), + 0x80 | (charcode & 0x3f)); + } + else if (charcode < 0xd800 || charcode >= 0xe000) { + utf8.push(0xe0 | (charcode >> 12), + 0x80 | ((charcode>>6) & 0x3f), + 0x80 | (charcode & 0x3f)); + } + // surrogate pair + else { + i++; + // UTF-16 encodes 0x10000-0x10FFFF by + // subtracting 0x10000 and splitting the + // 20 bits of 0x0-0xFFFFF into two halves + charcode = 0x10000 + (((charcode & 0x3ff)<<10) + | (str.charCodeAt(i) & 0x3ff)); + utf8.push(0xf0 | (charcode >>18), + 0x80 | ((charcode>>12) & 0x3f), + 0x80 | ((charcode>>6) & 0x3f), + 0x80 | (charcode & 0x3f)); + } + } + return utf8; +} + +function string(str) { + const bytes = toUTF8Array(str); + return [ ...varuint32(bytes.length), ...bytes ]; +} + +function varuint(n) { + const code = []; + let v = toNumber(n); + if (v.isNegative()) throw new Error("Number cannot be negative"); + while (!v.isZero()) { + code.push(v.and(0x7F).toJSNumber()); + v = v.shiftRight(7); + } + if (code.length==0) code.push(0); + for (let i=0; i. +*/ + +const utils$4 = utils$5; + +let CodeBuilder$1 = class CodeBuilder { + constructor(func) { + this.func = func; + this.functionName = func.functionName; + this.module = func.module; + } + + setLocal(localName, valCode) { + const idx = this.func.localIdxByName[localName]; + if (idx === undefined) + throw new Error(`Local Variable not defined: Function: ${this.functionName} local: ${localName} `); + return [...valCode, 0x21, ...utils$4.varuint32( idx )]; + } + + teeLocal(localName, valCode) { + const idx = this.func.localIdxByName[localName]; + if (idx === undefined) + throw new Error(`Local Variable not defined: Function: ${this.functionName} local: ${localName} `); + return [...valCode, 0x22, ...utils$4.varuint32( idx )]; + } + + getLocal(localName) { + const idx = this.func.localIdxByName[localName]; + if (idx === undefined) + throw new Error(`Local Variable not defined: Function: ${this.functionName} local: ${localName} `); + return [0x20, ...utils$4.varuint32( idx )]; + } + + i64_load8_s(idxCode, _offset, _align) { + const offset = _offset || 0; + const align = (_align === undefined) ? 0 : _align; // 8 bits alignment by default + return [...idxCode, 0x30, align, ...utils$4.varuint32(offset)]; + } + + i64_load8_u(idxCode, _offset, _align) { + const offset = _offset || 0; + const align = (_align === undefined) ? 0 : _align; // 8 bits alignment by default + return [...idxCode, 0x31, align, ...utils$4.varuint32(offset)]; + } + + i64_load16_s(idxCode, _offset, _align) { + const offset = _offset || 0; + const align = (_align === undefined) ? 1 : _align; // 16 bits alignment by default + return [...idxCode, 0x32, align, ...utils$4.varuint32(offset)]; + } + + i64_load16_u(idxCode, _offset, _align) { + const offset = _offset || 0; + const align = (_align === undefined) ? 1 : _align; // 16 bits alignment by default + return [...idxCode, 0x33, align, ...utils$4.varuint32(offset)]; + } + + i64_load32_s(idxCode, _offset, _align) { + const offset = _offset || 0; + const align = (_align === undefined) ? 2 : _align; // 32 bits alignment by default + return [...idxCode, 0x34, align, ...utils$4.varuint32(offset)]; + } + + i64_load32_u(idxCode, _offset, _align) { + const offset = _offset || 0; + const align = (_align === undefined) ? 2 : _align; // 32 bits alignment by default + return [...idxCode, 0x35, align, ...utils$4.varuint32(offset)]; + } + + i64_load(idxCode, _offset, _align) { + const offset = _offset || 0; + const align = (_align === undefined) ? 3 : _align; // 64 bits alignment by default + return [...idxCode, 0x29, align, ...utils$4.varuint32(offset)]; + } + + + i64_store(idxCode, _offset, _align, _codeVal) { + let offset, align, codeVal; + if (Array.isArray(_offset)) { + offset = 0; + align = 3; + codeVal = _offset; + } else if (Array.isArray(_align)) { + offset = _offset; + align = 3; + codeVal = _align; + } else if (Array.isArray(_codeVal)) { + offset = _offset; + align = _align; + codeVal = _codeVal; + } + return [...idxCode, ...codeVal, 0x37, align, ...utils$4.varuint32(offset)]; + } + + i64_store32(idxCode, _offset, _align, _codeVal) { + let offset, align, codeVal; + if (Array.isArray(_offset)) { + offset = 0; + align = 2; + codeVal = _offset; + } else if (Array.isArray(_align)) { + offset = _offset; + align = 2; + codeVal = _align; + } else if (Array.isArray(_codeVal)) { + offset = _offset; + align = _align; + codeVal = _codeVal; + } + return [...idxCode, ...codeVal, 0x3e, align, ...utils$4.varuint32(offset)]; + } + + + i64_store16(idxCode, _offset, _align, _codeVal) { + let offset, align, codeVal; + if (Array.isArray(_offset)) { + offset = 0; + align = 1; + codeVal = _offset; + } else if (Array.isArray(_align)) { + offset = _offset; + align = 1; + codeVal = _align; + } else if (Array.isArray(_codeVal)) { + offset = _offset; + align = _align; + codeVal = _codeVal; + } + return [...idxCode, ...codeVal, 0x3d, align, ...utils$4.varuint32(offset)]; + } + + + i64_store8(idxCode, _offset, _align, _codeVal) { + let offset, align, codeVal; + if (Array.isArray(_offset)) { + offset = 0; + align = 0; + codeVal = _offset; + } else if (Array.isArray(_align)) { + offset = _offset; + align = 0; + codeVal = _align; + } else if (Array.isArray(_codeVal)) { + offset = _offset; + align = _align; + codeVal = _codeVal; + } + return [...idxCode, ...codeVal, 0x3c, align, ...utils$4.varuint32(offset)]; + } + + i32_load8_s(idxCode, _offset, _align) { + const offset = _offset || 0; + const align = (_align === undefined) ? 0 : _align; // 32 bits alignment by default + return [...idxCode, 0x2c, align, ...utils$4.varuint32(offset)]; + } + + i32_load8_u(idxCode, _offset, _align) { + const offset = _offset || 0; + const align = (_align === undefined) ? 0 : _align; // 32 bits alignment by default + return [...idxCode, 0x2d, align, ...utils$4.varuint32(offset)]; + } + + i32_load16_s(idxCode, _offset, _align) { + const offset = _offset || 0; + const align = (_align === undefined) ? 1 : _align; // 32 bits alignment by default + return [...idxCode, 0x2e, align, ...utils$4.varuint32(offset)]; + } + + i32_load16_u(idxCode, _offset, _align) { + const offset = _offset || 0; + const align = (_align === undefined) ? 1 : _align; // 32 bits alignment by default + return [...idxCode, 0x2f, align, ...utils$4.varuint32(offset)]; + } + + i32_load(idxCode, _offset, _align) { + const offset = _offset || 0; + const align = (_align === undefined) ? 2 : _align; // 32 bits alignment by default + return [...idxCode, 0x28, align, ...utils$4.varuint32(offset)]; + } + + i32_store(idxCode, _offset, _align, _codeVal) { + let offset, align, codeVal; + if (Array.isArray(_offset)) { + offset = 0; + align = 2; + codeVal = _offset; + } else if (Array.isArray(_align)) { + offset = _offset; + align = 2; + codeVal = _align; + } else if (Array.isArray(_codeVal)) { + offset = _offset; + align = _align; + codeVal = _codeVal; + } + return [...idxCode, ...codeVal, 0x36, align, ...utils$4.varuint32(offset)]; + } + + + i32_store16(idxCode, _offset, _align, _codeVal) { + let offset, align, codeVal; + if (Array.isArray(_offset)) { + offset = 0; + align = 1; + codeVal = _offset; + } else if (Array.isArray(_align)) { + offset = _offset; + align = 1; + codeVal = _align; + } else if (Array.isArray(_codeVal)) { + offset = _offset; + align = _align; + codeVal = _codeVal; + } + return [...idxCode, ...codeVal, 0x3b, align, ...utils$4.varuint32(offset)]; + } + + i32_store8(idxCode, _offset, _align, _codeVal) { + let offset, align, codeVal; + if (Array.isArray(_offset)) { + offset = 0; + align = 0; + codeVal = _offset; + } else if (Array.isArray(_align)) { + offset = _offset; + align = 0; + codeVal = _align; + } else if (Array.isArray(_codeVal)) { + offset = _offset; + align = _align; + codeVal = _codeVal; + } + return [...idxCode, ...codeVal, 0x3a, align, ...utils$4.varuint32(offset)]; + } + + call(fnName, ...args) { + const idx = this.module.functionIdxByName[fnName]; + if (idx === undefined) + throw new Error(`Function not defined: Function: ${fnName}`); + return [...[].concat(...args), 0x10, ...utils$4.varuint32(idx)]; + } + + call_indirect(fnIdx, ...args) { + return [...[].concat(...args), ...fnIdx, 0x11, 0, 0]; + } + + if(condCode, thenCode, elseCode) { + if (elseCode) { + return [...condCode, 0x04, 0x40, ...thenCode, 0x05, ...elseCode, 0x0b]; + } else { + return [...condCode, 0x04, 0x40, ...thenCode, 0x0b]; + } + } + + block(bCode) { return [0x02, 0x40, ...bCode, 0x0b]; } + loop(...args) { + return [0x03, 0x40, ...[].concat(...[...args]), 0x0b]; + } + br_if(relPath, condCode) { return [...condCode, 0x0d, ...utils$4.varuint32(relPath)]; } + br(relPath) { return [0x0c, ...utils$4.varuint32(relPath)]; } + ret(rCode) { return [...rCode, 0x0f]; } + drop(dCode) { return [...dCode, 0x1a]; } + + i64_const(num) { return [0x42, ...utils$4.varint64(num)]; } + i32_const(num) { return [0x41, ...utils$4.varint32(num)]; } + + + i64_eqz(opcode) { return [...opcode, 0x50]; } + i64_eq(op1code, op2code) { return [...op1code, ...op2code, 0x51]; } + i64_ne(op1code, op2code) { return [...op1code, ...op2code, 0x52]; } + i64_lt_s(op1code, op2code) { return [...op1code, ...op2code, 0x53]; } + i64_lt_u(op1code, op2code) { return [...op1code, ...op2code, 0x54]; } + i64_gt_s(op1code, op2code) { return [...op1code, ...op2code, 0x55]; } + i64_gt_u(op1code, op2code) { return [...op1code, ...op2code, 0x56]; } + i64_le_s(op1code, op2code) { return [...op1code, ...op2code, 0x57]; } + i64_le_u(op1code, op2code) { return [...op1code, ...op2code, 0x58]; } + i64_ge_s(op1code, op2code) { return [...op1code, ...op2code, 0x59]; } + i64_ge_u(op1code, op2code) { return [...op1code, ...op2code, 0x5a]; } + i64_add(op1code, op2code) { return [...op1code, ...op2code, 0x7c]; } + i64_sub(op1code, op2code) { return [...op1code, ...op2code, 0x7d]; } + i64_mul(op1code, op2code) { return [...op1code, ...op2code, 0x7e]; } + i64_div_s(op1code, op2code) { return [...op1code, ...op2code, 0x7f]; } + i64_div_u(op1code, op2code) { return [...op1code, ...op2code, 0x80]; } + i64_rem_s(op1code, op2code) { return [...op1code, ...op2code, 0x81]; } + i64_rem_u(op1code, op2code) { return [...op1code, ...op2code, 0x82]; } + i64_and(op1code, op2code) { return [...op1code, ...op2code, 0x83]; } + i64_or(op1code, op2code) { return [...op1code, ...op2code, 0x84]; } + i64_xor(op1code, op2code) { return [...op1code, ...op2code, 0x85]; } + i64_shl(op1code, op2code) { return [...op1code, ...op2code, 0x86]; } + i64_shr_s(op1code, op2code) { return [...op1code, ...op2code, 0x87]; } + i64_shr_u(op1code, op2code) { return [...op1code, ...op2code, 0x88]; } + i64_extend_i32_s(op1code) { return [...op1code, 0xac]; } + i64_extend_i32_u(op1code) { return [...op1code, 0xad]; } + i64_clz(op1code) { return [...op1code, 0x79]; } + i64_ctz(op1code) { return [...op1code, 0x7a]; } + + i32_eqz(op1code) { return [...op1code, 0x45]; } + i32_eq(op1code, op2code) { return [...op1code, ...op2code, 0x46]; } + i32_ne(op1code, op2code) { return [...op1code, ...op2code, 0x47]; } + i32_lt_s(op1code, op2code) { return [...op1code, ...op2code, 0x48]; } + i32_lt_u(op1code, op2code) { return [...op1code, ...op2code, 0x49]; } + i32_gt_s(op1code, op2code) { return [...op1code, ...op2code, 0x4a]; } + i32_gt_u(op1code, op2code) { return [...op1code, ...op2code, 0x4b]; } + i32_le_s(op1code, op2code) { return [...op1code, ...op2code, 0x4c]; } + i32_le_u(op1code, op2code) { return [...op1code, ...op2code, 0x4d]; } + i32_ge_s(op1code, op2code) { return [...op1code, ...op2code, 0x4e]; } + i32_ge_u(op1code, op2code) { return [...op1code, ...op2code, 0x4f]; } + i32_add(op1code, op2code) { return [...op1code, ...op2code, 0x6a]; } + i32_sub(op1code, op2code) { return [...op1code, ...op2code, 0x6b]; } + i32_mul(op1code, op2code) { return [...op1code, ...op2code, 0x6c]; } + i32_div_s(op1code, op2code) { return [...op1code, ...op2code, 0x6d]; } + i32_div_u(op1code, op2code) { return [...op1code, ...op2code, 0x6e]; } + i32_rem_s(op1code, op2code) { return [...op1code, ...op2code, 0x6f]; } + i32_rem_u(op1code, op2code) { return [...op1code, ...op2code, 0x70]; } + i32_and(op1code, op2code) { return [...op1code, ...op2code, 0x71]; } + i32_or(op1code, op2code) { return [...op1code, ...op2code, 0x72]; } + i32_xor(op1code, op2code) { return [...op1code, ...op2code, 0x73]; } + i32_shl(op1code, op2code) { return [...op1code, ...op2code, 0x74]; } + i32_shr_s(op1code, op2code) { return [...op1code, ...op2code, 0x75]; } + i32_shr_u(op1code, op2code) { return [...op1code, ...op2code, 0x76]; } + i32_rotl(op1code, op2code) { return [...op1code, ...op2code, 0x77]; } + i32_rotr(op1code, op2code) { return [...op1code, ...op2code, 0x78]; } + i32_wrap_i64(op1code) { return [...op1code, 0xa7]; } + i32_clz(op1code) { return [...op1code, 0x67]; } + i32_ctz(op1code) { return [...op1code, 0x68]; } + + unreachable() { return [ 0x0 ]; } + + current_memory() { return [ 0x3f, 0]; } + + comment() { return []; } +}; + +var codebuilder = CodeBuilder$1; + +/* + Copyright 2019 0KIMS association. + + This file is part of wasmbuilder + + wasmbuilder is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + wasmbuilder is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with wasmbuilder. If not, see . +*/ + +const CodeBuilder = codebuilder; +const utils$3 = utils$5; + +const typeCodes = { + "i32": 0x7f, + "i64": 0x7e, + "f32": 0x7d, + "f64": 0x7c, + "anyfunc": 0x70, + "func": 0x60, + "emptyblock": 0x40 +}; + + +let FunctionBuilder$1 = class FunctionBuilder { + + constructor (module, fnName, fnType, moduleName, fieldName) { + if (fnType == "import") { + this.fnType = "import"; + this.moduleName = moduleName; + this.fieldName = fieldName; + } else if (fnType == "internal") { + this.fnType = "internal"; + } else { + throw new Error("Invalid function fnType: " + fnType); + } + this.module = module; + this.fnName = fnName; + this.params = []; + this.locals = []; + this.localIdxByName = {}; + this.code = []; + this.returnType = null; + this.nextLocal =0; + } + + addParam(paramName, paramType) { + if (this.localIdxByName[paramName]) + throw new Error(`param already exists. Function: ${this.fnName}, Param: ${paramName} `); + const idx = this.nextLocal++; + this.localIdxByName[paramName] = idx; + this.params.push({ + type: paramType + }); + } + + addLocal(localName, localType, _length) { + const length = _length || 1; + if (this.localIdxByName[localName]) + throw new Error(`local already exists. Function: ${this.fnName}, Param: ${localName} `); + const idx = this.nextLocal++; + this.localIdxByName[localName] = idx; + this.locals.push({ + type: localType, + length: length + }); + } + + setReturnType(returnType) { + if (this.returnType) + throw new Error(`returnType already defined. Function: ${this.fnName}`); + this.returnType = returnType; + } + + getSignature() { + const params = [...utils$3.varuint32(this.params.length), ...this.params.map((p) => typeCodes[p.type])]; + const returns = this.returnType ? [0x01, typeCodes[this.returnType]] : [0]; + return [0x60, ...params, ...returns]; + } + + getBody() { + const locals = this.locals.map((l) => [ + ...utils$3.varuint32(l.length), + typeCodes[l.type] + ]); + + const body = [ + ...utils$3.varuint32(this.locals.length), + ...[].concat(...locals), + ...this.code, + 0x0b + ]; + return [ + ...utils$3.varuint32(body.length), + ...body + ]; + } + + addCode(...code) { + this.code.push(...[].concat(...[...code])); + } + + getCodeBuilder() { + return new CodeBuilder(this); + } +}; + +var functionbuilder = FunctionBuilder$1; + +/* + Copyright 2019 0KIMS association. + + This file is part of wasmbuilder + + wasmbuilder is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + wasmbuilder is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with wasmbuilder. If not, see . +*/ + +const FunctionBuilder = functionbuilder; +const utils$2 = utils$5; + +let ModuleBuilder$1 = class ModuleBuilder { + + constructor() { + this.functions = []; + this.functionIdxByName = {}; + this.nImportFunctions = 0; + this.nInternalFunctions =0; + this.memory = { + pagesSize: 1, + moduleName: "env", + fieldName: "memory" + }; + this.free = 8; + this.datas = []; + this.modules = {}; + this.exports = []; + this.functionsTable = []; + } + + build() { + this._setSignatures(); + return new Uint8Array([ + ...utils$2.u32(0x6d736100), + ...utils$2.u32(1), + ...this._buildType(), + ...this._buildImport(), + ...this._buildFunctionDeclarations(), + ...this._buildFunctionsTable(), + ...this._buildExports(), + ...this._buildElements(), + ...this._buildCode(), + ...this._buildData() + ]); + } + + addFunction(fnName) { + if (typeof(this.functionIdxByName[fnName]) !== "undefined") + throw new Error(`Function already defined: ${fnName}`); + + const idx = this.functions.length; + this.functionIdxByName[fnName] = idx; + + this.functions.push(new FunctionBuilder(this, fnName, "internal")); + + this.nInternalFunctions++; + return this.functions[idx]; + } + + addIimportFunction(fnName, moduleName, _fieldName) { + if (typeof(this.functionIdxByName[fnName]) !== "undefined") + throw new Error(`Function already defined: ${fnName}`); + + if ( (this.functions.length>0) + &&(this.functions[this.functions.length-1].type == "internal")) + throw new Error(`Import functions must be declared before internal: ${fnName}`); + + let fieldName = _fieldName || fnName; + + const idx = this.functions.length; + this.functionIdxByName[fnName] = idx; + + this.functions.push(new FunctionBuilder(this, fnName, "import", moduleName, fieldName)); + + this.nImportFunctions ++; + return this.functions[idx]; + } + + setMemory(pagesSize, moduleName, fieldName) { + this.memory = { + pagesSize: pagesSize, + moduleName: moduleName || "env", + fieldName: fieldName || "memory" + }; + } + + exportFunction(fnName, _exportName) { + const exportName = _exportName || fnName; + if (typeof(this.functionIdxByName[fnName]) === "undefined") + throw new Error(`Function not defined: ${fnName}`); + const idx = this.functionIdxByName[fnName]; + if (exportName != fnName) { + this.functionIdxByName[exportName] = idx; + } + this.exports.push({ + exportName: exportName, + idx: idx + }); + } + + addFunctionToTable(fnName) { + const idx = this.functionIdxByName[fnName]; + this.functionsTable.push(idx); + } + + addData(offset, bytes) { + this.datas.push({ + offset: offset, + bytes: bytes + }); + } + + alloc(a, b) { + let size; + let bytes; + if ((Array.isArray(a) || ArrayBuffer.isView(a)) && (typeof(b) === "undefined")) { + size = a.length; + bytes = a; + } else { + size = a; + bytes = b; + } + size = (((size-1)>>3) +1)<<3; // Align to 64 bits. + const p = this.free; + this.free += size; + if (bytes) { + this.addData(p, bytes); + } + return p; + } + + allocString(s) { + const encoder = new globalThis.TextEncoder(); + const uint8array = encoder.encode(s); + return this.alloc([...uint8array, 0]); + } + + _setSignatures() { + this.signatures = []; + const signatureIdxByName = {}; + if (this.functionsTable.length>0) { + const signature = this.functions[this.functionsTable[0]].getSignature(); + const signatureName = "s_"+utils$2.toHexString(signature); + signatureIdxByName[signatureName] = 0; + this.signatures.push(signature); + } + for (let i=0; i. +*/ + +var ModuleBuilder = modulebuilder; + +globalThis.curve_bn128 = null; + +async function buildBn128(singleThread, plugins) { + + const moduleBuilder = new ModuleBuilder(); + moduleBuilder.setMemory(25); + buildBn128$1(moduleBuilder); + + if (plugins) plugins(moduleBuilder); + + const bn128wasm = {}; + + bn128wasm.code = moduleBuilder.build(); + bn128wasm.pq = moduleBuilder.modules.f1m.pq; + bn128wasm.pr = moduleBuilder.modules.frm.pq; + bn128wasm.pG1gen = moduleBuilder.modules.bn128.pG1gen; + bn128wasm.pG1zero = moduleBuilder.modules.bn128.pG1zero; + bn128wasm.pG1b = moduleBuilder.modules.bn128.pG1b; + bn128wasm.pG2gen = moduleBuilder.modules.bn128.pG2gen; + bn128wasm.pG2zero = moduleBuilder.modules.bn128.pG2zero; + bn128wasm.pG2b = moduleBuilder.modules.bn128.pG2b; + bn128wasm.pOneT = moduleBuilder.modules.bn128.pOneT; + bn128wasm.prePSize = moduleBuilder.modules.bn128.prePSize; + bn128wasm.preQSize = moduleBuilder.modules.bn128.preQSize; + bn128wasm.n8q = 32; + bn128wasm.n8r = 32; + bn128wasm.q = moduleBuilder.modules.bn128.q; + bn128wasm.r = moduleBuilder.modules.bn128.r; + + if ((!singleThread) && (globalThis.curve_bn128)) return globalThis.curve_bn128; + const params = { + name: "bn128", + wasm: bn128wasm, + q: e("21888242871839275222246405745257275088696311157297823662689037894645226208583"), + r: e("21888242871839275222246405745257275088548364400416034343698204186575808495617"), + n8q: 32, + n8r: 32, + cofactorG2: e("30644e72e131a029b85045b68181585e06ceecda572a2489345f2299c0f9fa8d", 16), + singleThread: singleThread ? true : false + }; + + const curve = await buildEngine(params); + curve.terminate = async function () { + if (!params.singleThread) { + globalThis.curve_bn128 = null; + await this.tm.terminate(); + } + }; + + if (!singleThread) { + globalThis.curve_bn128 = curve; + } + + return curve; +} + +globalThis.curve_bls12381 = null; + +async function buildBls12381(singleThread, plugins) { + + const moduleBuilder = new ModuleBuilder(); + moduleBuilder.setMemory(25); + buildBls12381$1(moduleBuilder); + + if (plugins) plugins(moduleBuilder); + + const bls12381wasm = {}; + + bls12381wasm.code = moduleBuilder.build(); + bls12381wasm.pq = moduleBuilder.modules.f1m.pq; + bls12381wasm.pr = moduleBuilder.modules.frm.pq; + bls12381wasm.pG1gen = moduleBuilder.modules.bls12381.pG1gen; + bls12381wasm.pG1zero = moduleBuilder.modules.bls12381.pG1zero; + bls12381wasm.pG1b = moduleBuilder.modules.bls12381.pG1b; + bls12381wasm.pG2gen = moduleBuilder.modules.bls12381.pG2gen; + bls12381wasm.pG2zero = moduleBuilder.modules.bls12381.pG2zero; + bls12381wasm.pG2b = moduleBuilder.modules.bls12381.pG2b; + bls12381wasm.pOneT = moduleBuilder.modules.bls12381.pOneT; + bls12381wasm.prePSize = moduleBuilder.modules.bls12381.prePSize; + bls12381wasm.preQSize = moduleBuilder.modules.bls12381.preQSize; + bls12381wasm.n8q = 48; + bls12381wasm.n8r = 32; + bls12381wasm.q = moduleBuilder.modules.bn128.q; + bls12381wasm.r = moduleBuilder.modules.bn128.r; + + + if ((!singleThread) && (globalThis.curve_bls12381)) return globalThis.curve_bls12381; + const params = { + name: "bls12381", + wasm: bls12381wasm, + q: e("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab", 16), + r: e("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001", 16), + n8q: 48, + n8r: 32, + cofactorG1: e("0x396c8c005555e1568c00aaab0000aaab", 16), + cofactorG2: e("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5", 16), + singleThread: singleThread ? true : false + }; + + const curve = await buildEngine(params); + curve.terminate = async function () { + if (!params.singleThread) { + globalThis.curve_bls12381 = null; + await this.tm.terminate(); + } + }; + + if (!singleThread) { + globalThis.curve_bls12381 = curve; + } + + return curve; +} + +e("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001", 16); +e("21888242871839275222246405745257275088548364400416034343698204186575808495617"); + +e("1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab", 16); +e("21888242871839275222246405745257275088696311157297823662689037894645226208583"); + +async function getCurveFromName(name, singleThread, plugins) { + let curve; + const normName = normalizeName(name); + if (["BN128", "BN254", "ALTBN128"].indexOf(normName) >= 0) { + curve = await buildBn128(singleThread, plugins); + } else if (["BLS12381"].indexOf(normName) >= 0) { + curve = await buildBls12381(singleThread, plugins); + } else { + throw new Error(`Curve not supported: ${name}`); + } + return curve; + + function normalizeName(n) { + return n.toUpperCase().match(/[A-Za-z0-9]+/g).join(""); + } + +} + +const Scalar=_Scalar; +const utils$1 = _utils; + +async function buildBabyJub() { + const bn128 = await getCurveFromName("bn128", true); + return new BabyJub(bn128.Fr); +} + +class BabyJub { + constructor(F) { + this.F = F; + this.p = Scalar.fromString("21888242871839275222246405745257275088548364400416034343698204186575808495617"); + this.pm1d2 = Scalar.div(Scalar.sub(this.p, Scalar.e(1)), Scalar.e(2)); + + this.Generator = [ + F.e("995203441582195749578291179787384436505546430278305826713579947235728471134"), + F.e("5472060717959818805561601436314318772137091100104008585924551046643952123905") + ]; + this.Base8 = [ + F.e("5299619240641551281634865583518297030282874472190772894086521144482721001553"), + F.e("16950150798460657717958625567821834550301663161624707787222815936182638968203") + ]; + this.order = Scalar.fromString("21888242871839275222246405745257275088614511777268538073601725287587578984328"); + this.subOrder = Scalar.shiftRight(this.order, 3); + this.A = F.e("168700"); + this.D = F.e("168696"); + } + + + addPoint(a,b) { + const F = this.F; + + const res = []; + + /* does the equivalent of: + res[0] = bigInt((a[0]*b[1] + b[0]*a[1]) * bigInt(bigInt("1") + d*a[0]*b[0]*a[1]*b[1]).inverse(q)).affine(q); + res[1] = bigInt((a[1]*b[1] - cta*a[0]*b[0]) * bigInt(bigInt("1") - d*a[0]*b[0]*a[1]*b[1]).inverse(q)).affine(q); + */ + + const beta = F.mul(a[0],b[1]); + const gamma = F.mul(a[1],b[0]); + const delta = F.mul( + F.sub(a[1], F.mul(this.A, a[0])), + F.add(b[0], b[1]) + ); + const tau = F.mul(beta, gamma); + const dtau = F.mul(this.D, tau); + + res[0] = F.div( + F.add(beta, gamma), + F.add(F.one, dtau) + ); + + res[1] = F.div( + F.add(delta, F.sub(F.mul(this.A,beta), gamma)), + F.sub(F.one, dtau) + ); + + return res; + } + + mulPointEscalar(base, e) { + const F = this.F; + let res = [F.e("0"),F.e("1")]; + let rem = e; + let exp = base; + + while (! Scalar.isZero(rem)) { + if (Scalar.isOdd(rem)) { + res = this.addPoint(res, exp); + } + exp = this.addPoint(exp, exp); + rem = Scalar.shiftRight(rem, 1); + } + + return res; + } + + inSubgroup(P) { + const F = this.F; + if (!this.inCurve(P)) return false; + const res= this.mulPointEscalar(P, this.subOrder); + return (F.isZero(res[0]) && F.eq(res[1], F.one)); + } + + inCurve(P) { + const F = this.F; + const x2 = F.square(P[0]); + const y2 = F.square(P[1]); + + if (!F.eq( + F.add(F.mul(this.A, x2), y2), + F.add(F.one, F.mul(F.mul(x2, y2), this.D)))) return false; + + return true; + } + + packPoint(P) { + const F = this.F; + const buff = new Uint8Array(32); + F.toRprLE(buff, 0, P[1]); + const n = F.toObject(P[0]); + if (Scalar.gt(n, this.pm1d2)) { + buff[31] = buff[31] | 0x80; + } + return buff; + } + + unpackPoint(buff) { + const F = this.F; + let sign = false; + const P = new Array(2); + if (buff[31] & 0x80) { + sign = true; + buff[31] = buff[31] & 0x7F; + } + P[1] = F.fromRprLE(buff, 0); + if (Scalar.gt(F.toObject(P[1]), this.p)) return null; + + const y2 = F.square(P[1]); + + const x2 = F.div( + F.sub(F.one, y2), + F.sub(this.A, F.mul(this.D, y2)) + ); + + const x2h = F.exp(x2, F.half); + if (! F.eq(F.one, x2h)) return null; + + let x = F.sqrt(x2); + + if (x == null) return null; + + if (sign) x = F.neg(x); + + P[0] = x; + + return P; + } +} + +var blake2b$2 = {exports: {}}; + +var nanoassert = assert$3; + +class AssertionError extends Error {} +AssertionError.prototype.name = 'AssertionError'; + +/** + * Minimal assert function + * @param {any} t Value to check if falsy + * @param {string=} m Optional assertion error message + * @throws {AssertionError} + */ +function assert$3 (t, m) { + if (!t) { + var err = new AssertionError(m); + if (Error.captureStackTrace) Error.captureStackTrace(err, assert$3); + throw err + } +} + +var blake2bWasm = {exports: {}}; + +function isBuffer (value) { + return Buffer.isBuffer(value) || value instanceof Uint8Array +} + +function isEncoding (encoding) { + return Buffer.isEncoding(encoding) +} + +function alloc (size, fill, encoding) { + return Buffer.alloc(size, fill, encoding) +} + +function allocUnsafe (size) { + return Buffer.allocUnsafe(size) +} + +function allocUnsafeSlow (size) { + return Buffer.allocUnsafeSlow(size) +} + +function byteLength (string, encoding) { + return Buffer.byteLength(string, encoding) +} + +function compare (a, b) { + return Buffer.compare(a, b) +} + +function concat (buffers, totalLength) { + return Buffer.concat(buffers, totalLength) +} + +function copy (source, target, targetStart, start, end) { + return toBuffer(source).copy(target, targetStart, start, end) +} + +function equals (a, b) { + return toBuffer(a).equals(b) +} + +function fill (buffer, value, offset, end, encoding) { + return toBuffer(buffer).fill(value, offset, end, encoding) +} + +function from (value, encodingOrOffset, length) { + return Buffer.from(value, encodingOrOffset, length) +} + +function includes (buffer, value, byteOffset, encoding) { + return toBuffer(buffer).includes(value, byteOffset, encoding) +} + +function indexOf (buffer, value, byfeOffset, encoding) { + return toBuffer(buffer).indexOf(value, byfeOffset, encoding) +} + +function lastIndexOf (buffer, value, byteOffset, encoding) { + return toBuffer(buffer).lastIndexOf(value, byteOffset, encoding) +} + +function swap16 (buffer) { + return toBuffer(buffer).swap16() +} + +function swap32 (buffer) { + return toBuffer(buffer).swap32() +} + +function swap64 (buffer) { + return toBuffer(buffer).swap64() +} + +function toBuffer (buffer) { + if (Buffer.isBuffer(buffer)) return buffer + return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength) +} + +function toString (buffer, encoding, start, end) { + return toBuffer(buffer).toString(encoding, start, end) +} + +function write (buffer, string, offset, length, encoding) { + return toBuffer(buffer).write(string, offset, length, encoding) +} + +function writeDoubleLE (buffer, value, offset) { + return toBuffer(buffer).writeDoubleLE(value, offset) +} + +function writeFloatLE (buffer, value, offset) { + return toBuffer(buffer).writeFloatLE(value, offset) +} + +function writeUInt32LE (buffer, value, offset) { + return toBuffer(buffer).writeUInt32LE(value, offset) +} + +function writeInt32LE (buffer, value, offset) { + return toBuffer(buffer).writeInt32LE(value, offset) +} + +function readDoubleLE (buffer, offset) { + return toBuffer(buffer).readDoubleLE(offset) +} + +function readFloatLE (buffer, offset) { + return toBuffer(buffer).readFloatLE(offset) +} + +function readUInt32LE (buffer, offset) { + return toBuffer(buffer).readUInt32LE(offset) +} + +function readInt32LE (buffer, offset) { + return toBuffer(buffer).readInt32LE(offset) +} + +var b4a$1 = { + isBuffer, + isEncoding, + alloc, + allocUnsafe, + allocUnsafeSlow, + byteLength, + compare, + concat, + copy, + equals, + fill, + from, + includes, + indexOf, + lastIndexOf, + swap16, + swap32, + swap64, + toBuffer, + toString, + write, + writeDoubleLE, + writeFloatLE, + writeUInt32LE, + writeInt32LE, + readDoubleLE, + readFloatLE, + readUInt32LE, + readInt32LE +}; + +var blake2b$1; +var hasRequiredBlake2b; + +function requireBlake2b () { + if (hasRequiredBlake2b) return blake2b$1; + hasRequiredBlake2b = 1; + var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; + }; + var __toBinary = /* @__PURE__ */ (() => { + var table = new Uint8Array(128); + for (var i = 0; i < 64; i++) + table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i; + return (base64) => { + var n = base64.length, bytes2 = new Uint8Array((n - (base64[n - 1] == "=") - (base64[n - 2] == "=")) * 3 / 4 | 0); + for (var i2 = 0, j = 0; i2 < n; ) { + var c0 = table[base64.charCodeAt(i2++)], c1 = table[base64.charCodeAt(i2++)]; + var c2 = table[base64.charCodeAt(i2++)], c3 = table[base64.charCodeAt(i2++)]; + bytes2[j++] = c0 << 2 | c1 >> 4; + bytes2[j++] = c1 << 4 | c2 >> 2; + bytes2[j++] = c2 << 6 | c3; + } + return bytes2; + }; + })(); + + // wasm-binary:./blake2b.wat + var require_blake2b = __commonJS({ + "wasm-binary:./blake2b.wat"(exports2, module2) { + module2.exports = __toBinary("AGFzbQEAAAABEANgAn9/AGADf39/AGABfwADBQQAAQICBQUBAQroBwdNBQZtZW1vcnkCAAxibGFrZTJiX2luaXQAAA5ibGFrZTJiX3VwZGF0ZQABDWJsYWtlMmJfZmluYWwAAhBibGFrZTJiX2NvbXByZXNzAAMKvz8EwAIAIABCADcDACAAQgA3AwggAEIANwMQIABCADcDGCAAQgA3AyAgAEIANwMoIABCADcDMCAAQgA3AzggAEIANwNAIABCADcDSCAAQgA3A1AgAEIANwNYIABCADcDYCAAQgA3A2ggAEIANwNwIABCADcDeCAAQoiS853/zPmE6gBBACkDAIU3A4ABIABCu86qptjQ67O7f0EIKQMAhTcDiAEgAEKr8NP0r+68tzxBECkDAIU3A5ABIABC8e30+KWn/aelf0EYKQMAhTcDmAEgAELRhZrv+s+Uh9EAQSApAwCFNwOgASAAQp/Y+dnCkdqCm39BKCkDAIU3A6gBIABC6/qG2r+19sEfQTApAwCFNwOwASAAQvnC+JuRo7Pw2wBBOCkDAIU3A7gBIABCADcDwAEgAEIANwPIASAAQgA3A9ABC20BA38gAEHAAWohAyAAQcgBaiEEIAQpAwCnIQUCQANAIAEgAkYNASAFQYABRgRAIAMgAykDACAFrXw3AwBBACEFIAAQAwsgACAFaiABLQAAOgAAIAVBAWohBSABQQFqIQEMAAsLIAQgBa03AwALYQEDfyAAQcABaiEBIABByAFqIQIgASABKQMAIAIpAwB8NwMAIABCfzcD0AEgAikDAKchAwJAA0AgA0GAAUYNASAAIANqQQA6AAAgA0EBaiEDDAALCyACIAOtNwMAIAAQAwuqOwIgfgl/IABBgAFqISEgAEGIAWohIiAAQZABaiEjIABBmAFqISQgAEGgAWohJSAAQagBaiEmIABBsAFqIScgAEG4AWohKCAhKQMAIQEgIikDACECICMpAwAhAyAkKQMAIQQgJSkDACEFICYpAwAhBiAnKQMAIQcgKCkDACEIQoiS853/zPmE6gAhCUK7zqqm2NDrs7t/IQpCq/DT9K/uvLc8IQtC8e30+KWn/aelfyEMQtGFmu/6z5SH0QAhDUKf2PnZwpHagpt/IQ5C6/qG2r+19sEfIQ9C+cL4m5Gjs/DbACEQIAApAwAhESAAKQMIIRIgACkDECETIAApAxghFCAAKQMgIRUgACkDKCEWIAApAzAhFyAAKQM4IRggACkDQCEZIAApA0ghGiAAKQNQIRsgACkDWCEcIAApA2AhHSAAKQNoIR4gACkDcCEfIAApA3ghICANIAApA8ABhSENIA8gACkD0AGFIQ8gASAFIBF8fCEBIA0gAYVCIIohDSAJIA18IQkgBSAJhUIYiiEFIAEgBSASfHwhASANIAGFQhCKIQ0gCSANfCEJIAUgCYVCP4ohBSACIAYgE3x8IQIgDiAChUIgiiEOIAogDnwhCiAGIAqFQhiKIQYgAiAGIBR8fCECIA4gAoVCEIohDiAKIA58IQogBiAKhUI/iiEGIAMgByAVfHwhAyAPIAOFQiCKIQ8gCyAPfCELIAcgC4VCGIohByADIAcgFnx8IQMgDyADhUIQiiEPIAsgD3whCyAHIAuFQj+KIQcgBCAIIBd8fCEEIBAgBIVCIIohECAMIBB8IQwgCCAMhUIYiiEIIAQgCCAYfHwhBCAQIASFQhCKIRAgDCAQfCEMIAggDIVCP4ohCCABIAYgGXx8IQEgECABhUIgiiEQIAsgEHwhCyAGIAuFQhiKIQYgASAGIBp8fCEBIBAgAYVCEIohECALIBB8IQsgBiALhUI/iiEGIAIgByAbfHwhAiANIAKFQiCKIQ0gDCANfCEMIAcgDIVCGIohByACIAcgHHx8IQIgDSAChUIQiiENIAwgDXwhDCAHIAyFQj+KIQcgAyAIIB18fCEDIA4gA4VCIIohDiAJIA58IQkgCCAJhUIYiiEIIAMgCCAefHwhAyAOIAOFQhCKIQ4gCSAOfCEJIAggCYVCP4ohCCAEIAUgH3x8IQQgDyAEhUIgiiEPIAogD3whCiAFIAqFQhiKIQUgBCAFICB8fCEEIA8gBIVCEIohDyAKIA98IQogBSAKhUI/iiEFIAEgBSAffHwhASANIAGFQiCKIQ0gCSANfCEJIAUgCYVCGIohBSABIAUgG3x8IQEgDSABhUIQiiENIAkgDXwhCSAFIAmFQj+KIQUgAiAGIBV8fCECIA4gAoVCIIohDiAKIA58IQogBiAKhUIYiiEGIAIgBiAZfHwhAiAOIAKFQhCKIQ4gCiAOfCEKIAYgCoVCP4ohBiADIAcgGnx8IQMgDyADhUIgiiEPIAsgD3whCyAHIAuFQhiKIQcgAyAHICB8fCEDIA8gA4VCEIohDyALIA98IQsgByALhUI/iiEHIAQgCCAefHwhBCAQIASFQiCKIRAgDCAQfCEMIAggDIVCGIohCCAEIAggF3x8IQQgECAEhUIQiiEQIAwgEHwhDCAIIAyFQj+KIQggASAGIBJ8fCEBIBAgAYVCIIohECALIBB8IQsgBiALhUIYiiEGIAEgBiAdfHwhASAQIAGFQhCKIRAgCyAQfCELIAYgC4VCP4ohBiACIAcgEXx8IQIgDSAChUIgiiENIAwgDXwhDCAHIAyFQhiKIQcgAiAHIBN8fCECIA0gAoVCEIohDSAMIA18IQwgByAMhUI/iiEHIAMgCCAcfHwhAyAOIAOFQiCKIQ4gCSAOfCEJIAggCYVCGIohCCADIAggGHx8IQMgDiADhUIQiiEOIAkgDnwhCSAIIAmFQj+KIQggBCAFIBZ8fCEEIA8gBIVCIIohDyAKIA98IQogBSAKhUIYiiEFIAQgBSAUfHwhBCAPIASFQhCKIQ8gCiAPfCEKIAUgCoVCP4ohBSABIAUgHHx8IQEgDSABhUIgiiENIAkgDXwhCSAFIAmFQhiKIQUgASAFIBl8fCEBIA0gAYVCEIohDSAJIA18IQkgBSAJhUI/iiEFIAIgBiAdfHwhAiAOIAKFQiCKIQ4gCiAOfCEKIAYgCoVCGIohBiACIAYgEXx8IQIgDiAChUIQiiEOIAogDnwhCiAGIAqFQj+KIQYgAyAHIBZ8fCEDIA8gA4VCIIohDyALIA98IQsgByALhUIYiiEHIAMgByATfHwhAyAPIAOFQhCKIQ8gCyAPfCELIAcgC4VCP4ohByAEIAggIHx8IQQgECAEhUIgiiEQIAwgEHwhDCAIIAyFQhiKIQggBCAIIB58fCEEIBAgBIVCEIohECAMIBB8IQwgCCAMhUI/iiEIIAEgBiAbfHwhASAQIAGFQiCKIRAgCyAQfCELIAYgC4VCGIohBiABIAYgH3x8IQEgECABhUIQiiEQIAsgEHwhCyAGIAuFQj+KIQYgAiAHIBR8fCECIA0gAoVCIIohDSAMIA18IQwgByAMhUIYiiEHIAIgByAXfHwhAiANIAKFQhCKIQ0gDCANfCEMIAcgDIVCP4ohByADIAggGHx8IQMgDiADhUIgiiEOIAkgDnwhCSAIIAmFQhiKIQggAyAIIBJ8fCEDIA4gA4VCEIohDiAJIA58IQkgCCAJhUI/iiEIIAQgBSAafHwhBCAPIASFQiCKIQ8gCiAPfCEKIAUgCoVCGIohBSAEIAUgFXx8IQQgDyAEhUIQiiEPIAogD3whCiAFIAqFQj+KIQUgASAFIBh8fCEBIA0gAYVCIIohDSAJIA18IQkgBSAJhUIYiiEFIAEgBSAafHwhASANIAGFQhCKIQ0gCSANfCEJIAUgCYVCP4ohBSACIAYgFHx8IQIgDiAChUIgiiEOIAogDnwhCiAGIAqFQhiKIQYgAiAGIBJ8fCECIA4gAoVCEIohDiAKIA58IQogBiAKhUI/iiEGIAMgByAefHwhAyAPIAOFQiCKIQ8gCyAPfCELIAcgC4VCGIohByADIAcgHXx8IQMgDyADhUIQiiEPIAsgD3whCyAHIAuFQj+KIQcgBCAIIBx8fCEEIBAgBIVCIIohECAMIBB8IQwgCCAMhUIYiiEIIAQgCCAffHwhBCAQIASFQhCKIRAgDCAQfCEMIAggDIVCP4ohCCABIAYgE3x8IQEgECABhUIgiiEQIAsgEHwhCyAGIAuFQhiKIQYgASAGIBd8fCEBIBAgAYVCEIohECALIBB8IQsgBiALhUI/iiEGIAIgByAWfHwhAiANIAKFQiCKIQ0gDCANfCEMIAcgDIVCGIohByACIAcgG3x8IQIgDSAChUIQiiENIAwgDXwhDCAHIAyFQj+KIQcgAyAIIBV8fCEDIA4gA4VCIIohDiAJIA58IQkgCCAJhUIYiiEIIAMgCCARfHwhAyAOIAOFQhCKIQ4gCSAOfCEJIAggCYVCP4ohCCAEIAUgIHx8IQQgDyAEhUIgiiEPIAogD3whCiAFIAqFQhiKIQUgBCAFIBl8fCEEIA8gBIVCEIohDyAKIA98IQogBSAKhUI/iiEFIAEgBSAafHwhASANIAGFQiCKIQ0gCSANfCEJIAUgCYVCGIohBSABIAUgEXx8IQEgDSABhUIQiiENIAkgDXwhCSAFIAmFQj+KIQUgAiAGIBZ8fCECIA4gAoVCIIohDiAKIA58IQogBiAKhUIYiiEGIAIgBiAYfHwhAiAOIAKFQhCKIQ4gCiAOfCEKIAYgCoVCP4ohBiADIAcgE3x8IQMgDyADhUIgiiEPIAsgD3whCyAHIAuFQhiKIQcgAyAHIBV8fCEDIA8gA4VCEIohDyALIA98IQsgByALhUI/iiEHIAQgCCAbfHwhBCAQIASFQiCKIRAgDCAQfCEMIAggDIVCGIohCCAEIAggIHx8IQQgECAEhUIQiiEQIAwgEHwhDCAIIAyFQj+KIQggASAGIB98fCEBIBAgAYVCIIohECALIBB8IQsgBiALhUIYiiEGIAEgBiASfHwhASAQIAGFQhCKIRAgCyAQfCELIAYgC4VCP4ohBiACIAcgHHx8IQIgDSAChUIgiiENIAwgDXwhDCAHIAyFQhiKIQcgAiAHIB18fCECIA0gAoVCEIohDSAMIA18IQwgByAMhUI/iiEHIAMgCCAXfHwhAyAOIAOFQiCKIQ4gCSAOfCEJIAggCYVCGIohCCADIAggGXx8IQMgDiADhUIQiiEOIAkgDnwhCSAIIAmFQj+KIQggBCAFIBR8fCEEIA8gBIVCIIohDyAKIA98IQogBSAKhUIYiiEFIAQgBSAefHwhBCAPIASFQhCKIQ8gCiAPfCEKIAUgCoVCP4ohBSABIAUgE3x8IQEgDSABhUIgiiENIAkgDXwhCSAFIAmFQhiKIQUgASAFIB18fCEBIA0gAYVCEIohDSAJIA18IQkgBSAJhUI/iiEFIAIgBiAXfHwhAiAOIAKFQiCKIQ4gCiAOfCEKIAYgCoVCGIohBiACIAYgG3x8IQIgDiAChUIQiiEOIAogDnwhCiAGIAqFQj+KIQYgAyAHIBF8fCEDIA8gA4VCIIohDyALIA98IQsgByALhUIYiiEHIAMgByAcfHwhAyAPIAOFQhCKIQ8gCyAPfCELIAcgC4VCP4ohByAEIAggGXx8IQQgECAEhUIgiiEQIAwgEHwhDCAIIAyFQhiKIQggBCAIIBR8fCEEIBAgBIVCEIohECAMIBB8IQwgCCAMhUI/iiEIIAEgBiAVfHwhASAQIAGFQiCKIRAgCyAQfCELIAYgC4VCGIohBiABIAYgHnx8IQEgECABhUIQiiEQIAsgEHwhCyAGIAuFQj+KIQYgAiAHIBh8fCECIA0gAoVCIIohDSAMIA18IQwgByAMhUIYiiEHIAIgByAWfHwhAiANIAKFQhCKIQ0gDCANfCEMIAcgDIVCP4ohByADIAggIHx8IQMgDiADhUIgiiEOIAkgDnwhCSAIIAmFQhiKIQggAyAIIB98fCEDIA4gA4VCEIohDiAJIA58IQkgCCAJhUI/iiEIIAQgBSASfHwhBCAPIASFQiCKIQ8gCiAPfCEKIAUgCoVCGIohBSAEIAUgGnx8IQQgDyAEhUIQiiEPIAogD3whCiAFIAqFQj+KIQUgASAFIB18fCEBIA0gAYVCIIohDSAJIA18IQkgBSAJhUIYiiEFIAEgBSAWfHwhASANIAGFQhCKIQ0gCSANfCEJIAUgCYVCP4ohBSACIAYgEnx8IQIgDiAChUIgiiEOIAogDnwhCiAGIAqFQhiKIQYgAiAGICB8fCECIA4gAoVCEIohDiAKIA58IQogBiAKhUI/iiEGIAMgByAffHwhAyAPIAOFQiCKIQ8gCyAPfCELIAcgC4VCGIohByADIAcgHnx8IQMgDyADhUIQiiEPIAsgD3whCyAHIAuFQj+KIQcgBCAIIBV8fCEEIBAgBIVCIIohECAMIBB8IQwgCCAMhUIYiiEIIAQgCCAbfHwhBCAQIASFQhCKIRAgDCAQfCEMIAggDIVCP4ohCCABIAYgEXx8IQEgECABhUIgiiEQIAsgEHwhCyAGIAuFQhiKIQYgASAGIBh8fCEBIBAgAYVCEIohECALIBB8IQsgBiALhUI/iiEGIAIgByAXfHwhAiANIAKFQiCKIQ0gDCANfCEMIAcgDIVCGIohByACIAcgFHx8IQIgDSAChUIQiiENIAwgDXwhDCAHIAyFQj+KIQcgAyAIIBp8fCEDIA4gA4VCIIohDiAJIA58IQkgCCAJhUIYiiEIIAMgCCATfHwhAyAOIAOFQhCKIQ4gCSAOfCEJIAggCYVCP4ohCCAEIAUgGXx8IQQgDyAEhUIgiiEPIAogD3whCiAFIAqFQhiKIQUgBCAFIBx8fCEEIA8gBIVCEIohDyAKIA98IQogBSAKhUI/iiEFIAEgBSAefHwhASANIAGFQiCKIQ0gCSANfCEJIAUgCYVCGIohBSABIAUgHHx8IQEgDSABhUIQiiENIAkgDXwhCSAFIAmFQj+KIQUgAiAGIBh8fCECIA4gAoVCIIohDiAKIA58IQogBiAKhUIYiiEGIAIgBiAffHwhAiAOIAKFQhCKIQ4gCiAOfCEKIAYgCoVCP4ohBiADIAcgHXx8IQMgDyADhUIgiiEPIAsgD3whCyAHIAuFQhiKIQcgAyAHIBJ8fCEDIA8gA4VCEIohDyALIA98IQsgByALhUI/iiEHIAQgCCAUfHwhBCAQIASFQiCKIRAgDCAQfCEMIAggDIVCGIohCCAEIAggGnx8IQQgECAEhUIQiiEQIAwgEHwhDCAIIAyFQj+KIQggASAGIBZ8fCEBIBAgAYVCIIohECALIBB8IQsgBiALhUIYiiEGIAEgBiARfHwhASAQIAGFQhCKIRAgCyAQfCELIAYgC4VCP4ohBiACIAcgIHx8IQIgDSAChUIgiiENIAwgDXwhDCAHIAyFQhiKIQcgAiAHIBV8fCECIA0gAoVCEIohDSAMIA18IQwgByAMhUI/iiEHIAMgCCAZfHwhAyAOIAOFQiCKIQ4gCSAOfCEJIAggCYVCGIohCCADIAggF3x8IQMgDiADhUIQiiEOIAkgDnwhCSAIIAmFQj+KIQggBCAFIBN8fCEEIA8gBIVCIIohDyAKIA98IQogBSAKhUIYiiEFIAQgBSAbfHwhBCAPIASFQhCKIQ8gCiAPfCEKIAUgCoVCP4ohBSABIAUgF3x8IQEgDSABhUIgiiENIAkgDXwhCSAFIAmFQhiKIQUgASAFICB8fCEBIA0gAYVCEIohDSAJIA18IQkgBSAJhUI/iiEFIAIgBiAffHwhAiAOIAKFQiCKIQ4gCiAOfCEKIAYgCoVCGIohBiACIAYgGnx8IQIgDiAChUIQiiEOIAogDnwhCiAGIAqFQj+KIQYgAyAHIBx8fCEDIA8gA4VCIIohDyALIA98IQsgByALhUIYiiEHIAMgByAUfHwhAyAPIAOFQhCKIQ8gCyAPfCELIAcgC4VCP4ohByAEIAggEXx8IQQgECAEhUIgiiEQIAwgEHwhDCAIIAyFQhiKIQggBCAIIBl8fCEEIBAgBIVCEIohECAMIBB8IQwgCCAMhUI/iiEIIAEgBiAdfHwhASAQIAGFQiCKIRAgCyAQfCELIAYgC4VCGIohBiABIAYgE3x8IQEgECABhUIQiiEQIAsgEHwhCyAGIAuFQj+KIQYgAiAHIB58fCECIA0gAoVCIIohDSAMIA18IQwgByAMhUIYiiEHIAIgByAYfHwhAiANIAKFQhCKIQ0gDCANfCEMIAcgDIVCP4ohByADIAggEnx8IQMgDiADhUIgiiEOIAkgDnwhCSAIIAmFQhiKIQggAyAIIBV8fCEDIA4gA4VCEIohDiAJIA58IQkgCCAJhUI/iiEIIAQgBSAbfHwhBCAPIASFQiCKIQ8gCiAPfCEKIAUgCoVCGIohBSAEIAUgFnx8IQQgDyAEhUIQiiEPIAogD3whCiAFIAqFQj+KIQUgASAFIBt8fCEBIA0gAYVCIIohDSAJIA18IQkgBSAJhUIYiiEFIAEgBSATfHwhASANIAGFQhCKIQ0gCSANfCEJIAUgCYVCP4ohBSACIAYgGXx8IQIgDiAChUIgiiEOIAogDnwhCiAGIAqFQhiKIQYgAiAGIBV8fCECIA4gAoVCEIohDiAKIA58IQogBiAKhUI/iiEGIAMgByAYfHwhAyAPIAOFQiCKIQ8gCyAPfCELIAcgC4VCGIohByADIAcgF3x8IQMgDyADhUIQiiEPIAsgD3whCyAHIAuFQj+KIQcgBCAIIBJ8fCEEIBAgBIVCIIohECAMIBB8IQwgCCAMhUIYiiEIIAQgCCAWfHwhBCAQIASFQhCKIRAgDCAQfCEMIAggDIVCP4ohCCABIAYgIHx8IQEgECABhUIgiiEQIAsgEHwhCyAGIAuFQhiKIQYgASAGIBx8fCEBIBAgAYVCEIohECALIBB8IQsgBiALhUI/iiEGIAIgByAafHwhAiANIAKFQiCKIQ0gDCANfCEMIAcgDIVCGIohByACIAcgH3x8IQIgDSAChUIQiiENIAwgDXwhDCAHIAyFQj+KIQcgAyAIIBR8fCEDIA4gA4VCIIohDiAJIA58IQkgCCAJhUIYiiEIIAMgCCAdfHwhAyAOIAOFQhCKIQ4gCSAOfCEJIAggCYVCP4ohCCAEIAUgHnx8IQQgDyAEhUIgiiEPIAogD3whCiAFIAqFQhiKIQUgBCAFIBF8fCEEIA8gBIVCEIohDyAKIA98IQogBSAKhUI/iiEFIAEgBSARfHwhASANIAGFQiCKIQ0gCSANfCEJIAUgCYVCGIohBSABIAUgEnx8IQEgDSABhUIQiiENIAkgDXwhCSAFIAmFQj+KIQUgAiAGIBN8fCECIA4gAoVCIIohDiAKIA58IQogBiAKhUIYiiEGIAIgBiAUfHwhAiAOIAKFQhCKIQ4gCiAOfCEKIAYgCoVCP4ohBiADIAcgFXx8IQMgDyADhUIgiiEPIAsgD3whCyAHIAuFQhiKIQcgAyAHIBZ8fCEDIA8gA4VCEIohDyALIA98IQsgByALhUI/iiEHIAQgCCAXfHwhBCAQIASFQiCKIRAgDCAQfCEMIAggDIVCGIohCCAEIAggGHx8IQQgECAEhUIQiiEQIAwgEHwhDCAIIAyFQj+KIQggASAGIBl8fCEBIBAgAYVCIIohECALIBB8IQsgBiALhUIYiiEGIAEgBiAafHwhASAQIAGFQhCKIRAgCyAQfCELIAYgC4VCP4ohBiACIAcgG3x8IQIgDSAChUIgiiENIAwgDXwhDCAHIAyFQhiKIQcgAiAHIBx8fCECIA0gAoVCEIohDSAMIA18IQwgByAMhUI/iiEHIAMgCCAdfHwhAyAOIAOFQiCKIQ4gCSAOfCEJIAggCYVCGIohCCADIAggHnx8IQMgDiADhUIQiiEOIAkgDnwhCSAIIAmFQj+KIQggBCAFIB98fCEEIA8gBIVCIIohDyAKIA98IQogBSAKhUIYiiEFIAQgBSAgfHwhBCAPIASFQhCKIQ8gCiAPfCEKIAUgCoVCP4ohBSABIAUgH3x8IQEgDSABhUIgiiENIAkgDXwhCSAFIAmFQhiKIQUgASAFIBt8fCEBIA0gAYVCEIohDSAJIA18IQkgBSAJhUI/iiEFIAIgBiAVfHwhAiAOIAKFQiCKIQ4gCiAOfCEKIAYgCoVCGIohBiACIAYgGXx8IQIgDiAChUIQiiEOIAogDnwhCiAGIAqFQj+KIQYgAyAHIBp8fCEDIA8gA4VCIIohDyALIA98IQsgByALhUIYiiEHIAMgByAgfHwhAyAPIAOFQhCKIQ8gCyAPfCELIAcgC4VCP4ohByAEIAggHnx8IQQgECAEhUIgiiEQIAwgEHwhDCAIIAyFQhiKIQggBCAIIBd8fCEEIBAgBIVCEIohECAMIBB8IQwgCCAMhUI/iiEIIAEgBiASfHwhASAQIAGFQiCKIRAgCyAQfCELIAYgC4VCGIohBiABIAYgHXx8IQEgECABhUIQiiEQIAsgEHwhCyAGIAuFQj+KIQYgAiAHIBF8fCECIA0gAoVCIIohDSAMIA18IQwgByAMhUIYiiEHIAIgByATfHwhAiANIAKFQhCKIQ0gDCANfCEMIAcgDIVCP4ohByADIAggHHx8IQMgDiADhUIgiiEOIAkgDnwhCSAIIAmFQhiKIQggAyAIIBh8fCEDIA4gA4VCEIohDiAJIA58IQkgCCAJhUI/iiEIIAQgBSAWfHwhBCAPIASFQiCKIQ8gCiAPfCEKIAUgCoVCGIohBSAEIAUgFHx8IQQgDyAEhUIQiiEPIAogD3whCiAFIAqFQj+KIQUgISAhKQMAIAEgCYWFNwMAICIgIikDACACIAqFhTcDACAjICMpAwAgAyALhYU3AwAgJCAkKQMAIAQgDIWFNwMAICUgJSkDACAFIA2FhTcDACAmICYpAwAgBiAOhYU3AwAgJyAnKQMAIAcgD4WFNwMAICggKCkDACAIIBCFhTcDAAs="); + } + }); + + // wasm-module:./blake2b.wat + var bytes = require_blake2b(); + var compiled = WebAssembly.compile(bytes); + blake2b$1 = async (imports) => { + const instance = await WebAssembly.instantiate(await compiled, imports); + return instance.exports; + }; + return blake2b$1; +} + +var assert$2 = nanoassert; +var b4a = b4a$1; + +var wasm = null; +var wasmPromise = typeof WebAssembly !== "undefined" && requireBlake2b()().then(mod => { + wasm = mod; +}); + +var head = 64; +var freeList = []; + +blake2bWasm.exports = Blake2b$1; +var BYTES_MIN$1 = blake2bWasm.exports.BYTES_MIN = 16; +var BYTES_MAX$1 = blake2bWasm.exports.BYTES_MAX = 64; +blake2bWasm.exports.BYTES = 32; +var KEYBYTES_MIN$1 = blake2bWasm.exports.KEYBYTES_MIN = 16; +var KEYBYTES_MAX$1 = blake2bWasm.exports.KEYBYTES_MAX = 64; +blake2bWasm.exports.KEYBYTES = 32; +var SALTBYTES$1 = blake2bWasm.exports.SALTBYTES = 16; +var PERSONALBYTES$1 = blake2bWasm.exports.PERSONALBYTES = 16; + +function Blake2b$1 (digestLength, key, salt, personal, noAssert) { + if (!(this instanceof Blake2b$1)) return new Blake2b$1(digestLength, key, salt, personal, noAssert) + if (!wasm) throw new Error('WASM not loaded. Wait for Blake2b.ready(cb)') + if (!digestLength) digestLength = 32; + + if (noAssert !== true) { + assert$2(digestLength >= BYTES_MIN$1, 'digestLength must be at least ' + BYTES_MIN$1 + ', was given ' + digestLength); + assert$2(digestLength <= BYTES_MAX$1, 'digestLength must be at most ' + BYTES_MAX$1 + ', was given ' + digestLength); + if (key != null) { + assert$2(key instanceof Uint8Array, 'key must be Uint8Array or Buffer'); + assert$2(key.length >= KEYBYTES_MIN$1, 'key must be at least ' + KEYBYTES_MIN$1 + ', was given ' + key.length); + assert$2(key.length <= KEYBYTES_MAX$1, 'key must be at least ' + KEYBYTES_MAX$1 + ', was given ' + key.length); + } + if (salt != null) { + assert$2(salt instanceof Uint8Array, 'salt must be Uint8Array or Buffer'); + assert$2(salt.length === SALTBYTES$1, 'salt must be exactly ' + SALTBYTES$1 + ', was given ' + salt.length); + } + if (personal != null) { + assert$2(personal instanceof Uint8Array, 'personal must be Uint8Array or Buffer'); + assert$2(personal.length === PERSONALBYTES$1, 'personal must be exactly ' + PERSONALBYTES$1 + ', was given ' + personal.length); + } + } + + if (!freeList.length) { + freeList.push(head); + head += 216; + } + + this.digestLength = digestLength; + this.finalized = false; + this.pointer = freeList.pop(); + this._memory = new Uint8Array(wasm.memory.buffer); + + this._memory.fill(0, 0, 64); + this._memory[0] = this.digestLength; + this._memory[1] = key ? key.length : 0; + this._memory[2] = 1; // fanout + this._memory[3] = 1; // depth + + if (salt) this._memory.set(salt, 32); + if (personal) this._memory.set(personal, 48); + + if (this.pointer + 216 > this._memory.length) this._realloc(this.pointer + 216); // we need 216 bytes for the state + wasm.blake2b_init(this.pointer, this.digestLength); + + if (key) { + this.update(key); + this._memory.fill(0, head, head + key.length); // whiteout key + this._memory[this.pointer + 200] = 128; + } +} + +Blake2b$1.prototype._realloc = function (size) { + wasm.memory.grow(Math.max(0, Math.ceil(Math.abs(size - this._memory.length) / 65536))); + this._memory = new Uint8Array(wasm.memory.buffer); +}; + +Blake2b$1.prototype.update = function (input) { + assert$2(this.finalized === false, 'Hash instance finalized'); + assert$2(input instanceof Uint8Array, 'input must be Uint8Array or Buffer'); + + if (head + input.length > this._memory.length) this._realloc(head + input.length); + this._memory.set(input, head); + wasm.blake2b_update(this.pointer, head, head + input.length); + return this +}; + +Blake2b$1.prototype.digest = function (enc) { + assert$2(this.finalized === false, 'Hash instance finalized'); + this.finalized = true; + + freeList.push(this.pointer); + wasm.blake2b_final(this.pointer); + + if (!enc || enc === 'binary') { + return this._memory.slice(this.pointer + 128, this.pointer + 128 + this.digestLength) + } + + if (typeof enc === 'string') { + return b4a.toString(this._memory, enc, this.pointer + 128, this.pointer + 128 + this.digestLength) + } + + assert$2(enc instanceof Uint8Array && enc.length >= this.digestLength, 'input must be Uint8Array or Buffer'); + for (var i = 0; i < this.digestLength; i++) { + enc[i] = this._memory[this.pointer + 128 + i]; + } + + return enc +}; + +// libsodium compat +Blake2b$1.prototype.final = Blake2b$1.prototype.digest; + +Blake2b$1.WASM = wasm; +Blake2b$1.SUPPORTED = typeof WebAssembly !== 'undefined'; + +Blake2b$1.ready = function (cb) { + if (!cb) cb = noop; + if (!wasmPromise) return cb(new Error('WebAssembly not supported')) + return wasmPromise.then(() => cb(), cb) +}; + +Blake2b$1.prototype.ready = Blake2b$1.ready; + +Blake2b$1.prototype.getPartialHash = function () { + return this._memory.slice(this.pointer, this.pointer + 216); +}; + +Blake2b$1.prototype.setPartialHash = function (ph) { + this._memory.set(ph, this.pointer); +}; + +function noop () {} + +var blake2bWasmExports = blake2bWasm.exports; + +var assert$1 = nanoassert; +var b2wasm = blake2bWasmExports; + +// 64-bit unsigned addition +// Sets v[a,a+1] += v[b,b+1] +// v should be a Uint32Array +function ADD64AA (v, a, b) { + var o0 = v[a] + v[b]; + var o1 = v[a + 1] + v[b + 1]; + if (o0 >= 0x100000000) { + o1++; + } + v[a] = o0; + v[a + 1] = o1; +} + +// 64-bit unsigned addition +// Sets v[a,a+1] += b +// b0 is the low 32 bits of b, b1 represents the high 32 bits +function ADD64AC (v, a, b0, b1) { + var o0 = v[a] + b0; + if (b0 < 0) { + o0 += 0x100000000; + } + var o1 = v[a + 1] + b1; + if (o0 >= 0x100000000) { + o1++; + } + v[a] = o0; + v[a + 1] = o1; +} + +// Little-endian byte access +function B2B_GET32 (arr, i) { + return (arr[i] ^ + (arr[i + 1] << 8) ^ + (arr[i + 2] << 16) ^ + (arr[i + 3] << 24)) +} + +// G Mixing function +// The ROTRs are inlined for speed +function B2B_G (a, b, c, d, ix, iy) { + var x0 = m[ix]; + var x1 = m[ix + 1]; + var y0 = m[iy]; + var y1 = m[iy + 1]; + + ADD64AA(v, a, b); // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s + ADD64AC(v, a, x0, x1); // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits + + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits + var xor0 = v[d] ^ v[a]; + var xor1 = v[d + 1] ^ v[a + 1]; + v[d] = xor1; + v[d + 1] = xor0; + + ADD64AA(v, c, d); + + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits + xor0 = v[b] ^ v[c]; + xor1 = v[b + 1] ^ v[c + 1]; + v[b] = (xor0 >>> 24) ^ (xor1 << 8); + v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8); + + ADD64AA(v, a, b); + ADD64AC(v, a, y0, y1); + + // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits + xor0 = v[d] ^ v[a]; + xor1 = v[d + 1] ^ v[a + 1]; + v[d] = (xor0 >>> 16) ^ (xor1 << 16); + v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16); + + ADD64AA(v, c, d); + + // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits + xor0 = v[b] ^ v[c]; + xor1 = v[b + 1] ^ v[c + 1]; + v[b] = (xor1 >>> 31) ^ (xor0 << 1); + v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1); +} + +// Initialization Vector +var BLAKE2B_IV32 = new Uint32Array([ + 0xF3BCC908, 0x6A09E667, 0x84CAA73B, 0xBB67AE85, + 0xFE94F82B, 0x3C6EF372, 0x5F1D36F1, 0xA54FF53A, + 0xADE682D1, 0x510E527F, 0x2B3E6C1F, 0x9B05688C, + 0xFB41BD6B, 0x1F83D9AB, 0x137E2179, 0x5BE0CD19 +]); + +var SIGMA8 = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3, + 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4, + 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8, + 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13, + 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9, + 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11, + 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10, + 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5, + 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 +]; + +// These are offsets into a uint64 buffer. +// Multiply them all by 2 to make them offsets into a uint32 buffer, +// because this is Javascript and we don't have uint64s +var SIGMA82 = new Uint8Array(SIGMA8.map(function (x) { return x * 2 })); + +// Compression function. 'last' flag indicates last block. +// Note we're representing 16 uint64s as 32 uint32s +var v = new Uint32Array(32); +var m = new Uint32Array(32); +function blake2bCompress (ctx, last) { + var i = 0; + + // init work variables + for (i = 0; i < 16; i++) { + v[i] = ctx.h[i]; + v[i + 16] = BLAKE2B_IV32[i]; + } + + // low 64 bits of offset + v[24] = v[24] ^ ctx.t; + v[25] = v[25] ^ (ctx.t / 0x100000000); + // high 64 bits not supported, offset may not be higher than 2**53-1 + + // last block flag set ? + if (last) { + v[28] = ~v[28]; + v[29] = ~v[29]; + } + + // get little-endian words + for (i = 0; i < 32; i++) { + m[i] = B2B_GET32(ctx.b, 4 * i); + } + + // twelve rounds of mixing + for (i = 0; i < 12; i++) { + B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1]); + B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3]); + B2B_G(4, 12, 20, 28, SIGMA82[i * 16 + 4], SIGMA82[i * 16 + 5]); + B2B_G(6, 14, 22, 30, SIGMA82[i * 16 + 6], SIGMA82[i * 16 + 7]); + B2B_G(0, 10, 20, 30, SIGMA82[i * 16 + 8], SIGMA82[i * 16 + 9]); + B2B_G(2, 12, 22, 24, SIGMA82[i * 16 + 10], SIGMA82[i * 16 + 11]); + B2B_G(4, 14, 16, 26, SIGMA82[i * 16 + 12], SIGMA82[i * 16 + 13]); + B2B_G(6, 8, 18, 28, SIGMA82[i * 16 + 14], SIGMA82[i * 16 + 15]); + } + + for (i = 0; i < 16; i++) { + ctx.h[i] = ctx.h[i] ^ v[i] ^ v[i + 16]; + } +} + +// reusable parameter_block +var parameter_block = new Uint8Array([ + 0, 0, 0, 0, // 0: outlen, keylen, fanout, depth + 0, 0, 0, 0, // 4: leaf length, sequential mode + 0, 0, 0, 0, // 8: node offset + 0, 0, 0, 0, // 12: node offset + 0, 0, 0, 0, // 16: node depth, inner length, rfu + 0, 0, 0, 0, // 20: rfu + 0, 0, 0, 0, // 24: rfu + 0, 0, 0, 0, // 28: rfu + 0, 0, 0, 0, // 32: salt + 0, 0, 0, 0, // 36: salt + 0, 0, 0, 0, // 40: salt + 0, 0, 0, 0, // 44: salt + 0, 0, 0, 0, // 48: personal + 0, 0, 0, 0, // 52: personal + 0, 0, 0, 0, // 56: personal + 0, 0, 0, 0 // 60: personal +]); + +// Creates a BLAKE2b hashing context +// Requires an output length between 1 and 64 bytes +// Takes an optional Uint8Array key +function Blake2b (outlen, key, salt, personal) { + // zero out parameter_block before usage + parameter_block.fill(0); + // state, 'param block' + + this.b = new Uint8Array(128); + this.h = new Uint32Array(16); + this.t = 0; // input count + this.c = 0; // pointer within buffer + this.outlen = outlen; // output length in bytes + + parameter_block[0] = outlen; + if (key) parameter_block[1] = key.length; + parameter_block[2] = 1; // fanout + parameter_block[3] = 1; // depth + + if (salt) parameter_block.set(salt, 32); + if (personal) parameter_block.set(personal, 48); + + // initialize hash state + for (var i = 0; i < 16; i++) { + this.h[i] = BLAKE2B_IV32[i] ^ B2B_GET32(parameter_block, i * 4); + } + + // key the hash, if applicable + if (key) { + blake2bUpdate(this, key); + // at the end + this.c = 128; + } +} + +Blake2b.prototype.update = function (input) { + assert$1(input instanceof Uint8Array, 'input must be Uint8Array or Buffer'); + blake2bUpdate(this, input); + return this +}; + +Blake2b.prototype.digest = function (out) { + var buf = (!out || out === 'binary' || out === 'hex') ? new Uint8Array(this.outlen) : out; + assert$1(buf instanceof Uint8Array, 'out must be "binary", "hex", Uint8Array, or Buffer'); + assert$1(buf.length >= this.outlen, 'out must have at least outlen bytes of space'); + blake2bFinal(this, buf); + if (out === 'hex') return hexSlice(buf) + return buf +}; + +Blake2b.prototype.final = Blake2b.prototype.digest; + +Blake2b.ready = function (cb) { + b2wasm.ready(function () { + cb(); // ignore the error + }); +}; + +// Updates a BLAKE2b streaming hash +// Requires hash context and Uint8Array (byte array) +function blake2bUpdate (ctx, input) { + for (var i = 0; i < input.length; i++) { + if (ctx.c === 128) { // buffer full ? + ctx.t += ctx.c; // add counters + blake2bCompress(ctx, false); // compress (not last) + ctx.c = 0; // counter to zero + } + ctx.b[ctx.c++] = input[i]; + } +} + +// Completes a BLAKE2b streaming hash +// Returns a Uint8Array containing the message digest +function blake2bFinal (ctx, out) { + ctx.t += ctx.c; // mark last block offset + + while (ctx.c < 128) { // fill up with zeros + ctx.b[ctx.c++] = 0; + } + blake2bCompress(ctx, true); // final block flag = 1 + + for (var i = 0; i < ctx.outlen; i++) { + out[i] = ctx.h[i >> 2] >> (8 * (i & 3)); + } + return out +} + +function hexSlice (buf) { + var str = ''; + for (var i = 0; i < buf.length; i++) str += toHex(buf[i]); + return str +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +var Proto = Blake2b; + +blake2b$2.exports = function createHash (outlen, key, salt, personal, noAssert) { + if (noAssert !== true) { + assert$1(outlen >= BYTES_MIN, 'outlen must be at least ' + BYTES_MIN + ', was given ' + outlen); + assert$1(outlen <= BYTES_MAX, 'outlen must be at most ' + BYTES_MAX + ', was given ' + outlen); + if (key != null) { + assert$1(key instanceof Uint8Array, 'key must be Uint8Array or Buffer'); + assert$1(key.length >= KEYBYTES_MIN, 'key must be at least ' + KEYBYTES_MIN + ', was given ' + key.length); + assert$1(key.length <= KEYBYTES_MAX, 'key must be at most ' + KEYBYTES_MAX + ', was given ' + key.length); + } + if (salt != null) { + assert$1(salt instanceof Uint8Array, 'salt must be Uint8Array or Buffer'); + assert$1(salt.length === SALTBYTES, 'salt must be exactly ' + SALTBYTES + ', was given ' + salt.length); + } + if (personal != null) { + assert$1(personal instanceof Uint8Array, 'personal must be Uint8Array or Buffer'); + assert$1(personal.length === PERSONALBYTES, 'personal must be exactly ' + PERSONALBYTES + ', was given ' + personal.length); + } + } + + return new Proto(outlen, key, salt, personal) +}; + +blake2b$2.exports.ready = function (cb) { + b2wasm.ready(function () { // ignore errors + cb(); + }); +}; + +blake2b$2.exports.WASM_SUPPORTED = b2wasm.SUPPORTED; +blake2b$2.exports.WASM_LOADED = false; + +var BYTES_MIN = blake2b$2.exports.BYTES_MIN = 16; +var BYTES_MAX = blake2b$2.exports.BYTES_MAX = 64; +blake2b$2.exports.BYTES = 32; +var KEYBYTES_MIN = blake2b$2.exports.KEYBYTES_MIN = 16; +var KEYBYTES_MAX = blake2b$2.exports.KEYBYTES_MAX = 64; +blake2b$2.exports.KEYBYTES = 32; +var SALTBYTES = blake2b$2.exports.SALTBYTES = 16; +var PERSONALBYTES = blake2b$2.exports.PERSONALBYTES = 16; + +b2wasm.ready(function (err) { + if (!err) { + blake2b$2.exports.WASM_LOADED = true; + blake2b$2.exports = b2wasm; + } +}); + +var blake2bExports = blake2b$2.exports; +var blake2b = /*@__PURE__*/getDefaultExportFromCjs(blake2bExports); + +var blakeHash = {exports: {}}; + +var readable = {exports: {}}; + +var stream; +var hasRequiredStream; + +function requireStream () { + if (hasRequiredStream) return stream; + hasRequiredStream = 1; + stream = Stream; + return stream; +} + +var buffer_list; +var hasRequiredBuffer_list; + +function requireBuffer_list () { + if (hasRequiredBuffer_list) return buffer_list; + hasRequiredBuffer_list = 1; + + function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } + function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } + function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } + function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } + function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } + function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } + var _require = require$$0$7, + Buffer = _require.Buffer; + var _require2 = require$$1$2, + inspect = _require2.inspect; + var custom = inspect && inspect.custom || 'inspect'; + function copyBuffer(src, target, offset) { + Buffer.prototype.copy.call(src, target, offset); + } + buffer_list = /*#__PURE__*/function () { + function BufferList() { + _classCallCheck(this, BufferList); + this.head = null; + this.tail = null; + this.length = 0; + } + _createClass(BufferList, [{ + key: "push", + value: function push(v) { + var entry = { + data: v, + next: null + }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + } + }, { + key: "unshift", + value: function unshift(v) { + var entry = { + data: v, + next: this.head + }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + } + }, { + key: "shift", + value: function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + } + }, { + key: "clear", + value: function clear() { + this.head = this.tail = null; + this.length = 0; + } + }, { + key: "join", + value: function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + while (p = p.next) ret += s + p.data; + return ret; + } + }, { + key: "concat", + value: function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; + } + return ret; + } + + // Consumes a specified amount of bytes or characters from the buffered data. + }, { + key: "consume", + value: function consume(n, hasStrings) { + var ret; + if (n < this.head.data.length) { + // `slice` is the same for buffers and strings. + ret = this.head.data.slice(0, n); + this.head.data = this.head.data.slice(n); + } else if (n === this.head.data.length) { + // First chunk is a perfect match. + ret = this.shift(); + } else { + // Result spans more than one buffer. + ret = hasStrings ? this._getString(n) : this._getBuffer(n); + } + return ret; + } + }, { + key: "first", + value: function first() { + return this.head.data; + } + + // Consumes a specified amount of characters from the buffered data. + }, { + key: "_getString", + value: function _getString(n) { + var p = this.head; + var c = 1; + var ret = p.data; + n -= ret.length; + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) this.head = p.next;else this.head = this.tail = null; + } else { + this.head = p; + p.data = str.slice(nb); + } + break; + } + ++c; + } + this.length -= c; + return ret; + } + + // Consumes a specified amount of bytes from the buffered data. + }, { + key: "_getBuffer", + value: function _getBuffer(n) { + var ret = Buffer.allocUnsafe(n); + var p = this.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) this.head = p.next;else this.head = this.tail = null; + } else { + this.head = p; + p.data = buf.slice(nb); + } + break; + } + ++c; + } + this.length -= c; + return ret; + } + + // Make sure the linked list only shows the minimal necessary information. + }, { + key: custom, + value: function value(_, options) { + return inspect(this, _objectSpread(_objectSpread({}, options), {}, { + // Only inspect one level. + depth: 0, + // It should not recurse. + customInspect: false + })); + } + }]); + return BufferList; + }(); + return buffer_list; +} + +var destroy_1; +var hasRequiredDestroy; + +function requireDestroy () { + if (hasRequiredDestroy) return destroy_1; + hasRequiredDestroy = 1; + + // undocumented cb() API, needed for core, not for public API + function destroy(err, cb) { + var _this = this; + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err) { + if (!this._writableState) { + process.nextTick(emitErrorNT, this, err); + } else if (!this._writableState.errorEmitted) { + this._writableState.errorEmitted = true; + process.nextTick(emitErrorNT, this, err); + } + } + return this; + } + + // we set destroyed to true before firing error callbacks in order + // to make it re-entrance safe in case destroy() is called within callbacks + + if (this._readableState) { + this._readableState.destroyed = true; + } + + // if this is a duplex stream mark the writable part as destroyed as well + if (this._writableState) { + this._writableState.destroyed = true; + } + this._destroy(err || null, function (err) { + if (!cb && err) { + if (!_this._writableState) { + process.nextTick(emitErrorAndCloseNT, _this, err); + } else if (!_this._writableState.errorEmitted) { + _this._writableState.errorEmitted = true; + process.nextTick(emitErrorAndCloseNT, _this, err); + } else { + process.nextTick(emitCloseNT, _this); + } + } else if (cb) { + process.nextTick(emitCloseNT, _this); + cb(err); + } else { + process.nextTick(emitCloseNT, _this); + } + }); + return this; + } + function emitErrorAndCloseNT(self, err) { + emitErrorNT(self, err); + emitCloseNT(self); + } + function emitCloseNT(self) { + if (self._writableState && !self._writableState.emitClose) return; + if (self._readableState && !self._readableState.emitClose) return; + self.emit('close'); + } + function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; + } + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finalCalled = false; + this._writableState.prefinished = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } + } + function emitErrorNT(self, err) { + self.emit('error', err); + } + function errorOrDestroy(stream, err) { + // We have tests that rely on errors being emitted + // in the same tick, so changing this is semver major. + // For now when you opt-in to autoDestroy we allow + // the error to be emitted nextTick. In a future + // semver major update we should change the default to this. + + var rState = stream._readableState; + var wState = stream._writableState; + if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err); + } + destroy_1 = { + destroy: destroy, + undestroy: undestroy, + errorOrDestroy: errorOrDestroy + }; + return destroy_1; +} + +var errors = {}; + +var hasRequiredErrors; + +function requireErrors () { + if (hasRequiredErrors) return errors; + hasRequiredErrors = 1; + + const codes = {}; + + function createErrorType(code, message, Base) { + if (!Base) { + Base = Error; + } + + function getMessage (arg1, arg2, arg3) { + if (typeof message === 'string') { + return message + } else { + return message(arg1, arg2, arg3) + } + } + + class NodeError extends Base { + constructor (arg1, arg2, arg3) { + super(getMessage(arg1, arg2, arg3)); + } + } + + NodeError.prototype.name = Base.name; + NodeError.prototype.code = code; + + codes[code] = NodeError; + } + + // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js + function oneOf(expected, thing) { + if (Array.isArray(expected)) { + const len = expected.length; + expected = expected.map((i) => String(i)); + if (len > 2) { + return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or ` + + expected[len - 1]; + } else if (len === 2) { + return `one of ${thing} ${expected[0]} or ${expected[1]}`; + } else { + return `of ${thing} ${expected[0]}`; + } + } else { + return `of ${thing} ${String(expected)}`; + } + } + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith + function startsWith(str, search, pos) { + return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search; + } + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith + function endsWith(str, search, this_len) { + if (this_len === undefined || this_len > str.length) { + this_len = str.length; + } + return str.substring(this_len - search.length, this_len) === search; + } + + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes + function includes(str, search, start) { + if (typeof start !== 'number') { + start = 0; + } + + if (start + search.length > str.length) { + return false; + } else { + return str.indexOf(search, start) !== -1; + } + } + + createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) { + return 'The value "' + value + '" is invalid for option "' + name + '"' + }, TypeError); + createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) { + // determiner: 'must be' or 'must not be' + let determiner; + if (typeof expected === 'string' && startsWith(expected, 'not ')) { + determiner = 'must not be'; + expected = expected.replace(/^not /, ''); + } else { + determiner = 'must be'; + } + + let msg; + if (endsWith(name, ' argument')) { + // For cases like 'first argument' + msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`; + } else { + const type = includes(name, '.') ? 'property' : 'argument'; + msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, 'type')}`; + } + + msg += `. Received type ${typeof actual}`; + return msg; + }, TypeError); + createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF'); + createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) { + return 'The ' + name + ' method is not implemented' + }); + createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close'); + createErrorType('ERR_STREAM_DESTROYED', function (name) { + return 'Cannot call ' + name + ' after a stream was destroyed'; + }); + createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times'); + createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable'); + createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end'); + createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError); + createErrorType('ERR_UNKNOWN_ENCODING', function (arg) { + return 'Unknown encoding: ' + arg + }, TypeError); + createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event'); + + errors.codes = codes; + return errors; +} + +var state; +var hasRequiredState; + +function requireState () { + if (hasRequiredState) return state; + hasRequiredState = 1; + + var ERR_INVALID_OPT_VALUE = requireErrors().codes.ERR_INVALID_OPT_VALUE; + function highWaterMarkFrom(options, isDuplex, duplexKey) { + return options.highWaterMark != null ? options.highWaterMark : isDuplex ? options[duplexKey] : null; + } + function getHighWaterMark(state, options, duplexKey, isDuplex) { + var hwm = highWaterMarkFrom(options, isDuplex, duplexKey); + if (hwm != null) { + if (!(isFinite(hwm) && Math.floor(hwm) === hwm) || hwm < 0) { + var name = isDuplex ? duplexKey : 'highWaterMark'; + throw new ERR_INVALID_OPT_VALUE(name, hwm); + } + return Math.floor(hwm); + } + + // Default value + return state.objectMode ? 16 : 16 * 1024; + } + state = { + getHighWaterMark: getHighWaterMark + }; + return state; +} + +var inherits = {exports: {}}; + +var inherits_browser = {exports: {}}; + +var hasRequiredInherits_browser; + +function requireInherits_browser () { + if (hasRequiredInherits_browser) return inherits_browser.exports; + hasRequiredInherits_browser = 1; + if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + inherits_browser.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + } + }; + } else { + // old school shim for old browsers + inherits_browser.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + }; + } + return inherits_browser.exports; +} + +var hasRequiredInherits; + +function requireInherits () { + if (hasRequiredInherits) return inherits.exports; + hasRequiredInherits = 1; + try { + var util = require('util'); + /* istanbul ignore next */ + if (typeof util.inherits !== 'function') throw ''; + inherits.exports = util.inherits; + } catch (e) { + /* istanbul ignore next */ + inherits.exports = requireInherits_browser(); + } + return inherits.exports; +} + +var node; +var hasRequiredNode; + +function requireNode () { + if (hasRequiredNode) return node; + hasRequiredNode = 1; + /** + * For Node.js, simply re-export the core `util.deprecate` function. + */ + + node = require$$1$2.deprecate; + return node; +} + +var _stream_writable; +var hasRequired_stream_writable; + +function require_stream_writable () { + if (hasRequired_stream_writable) return _stream_writable; + hasRequired_stream_writable = 1; + + _stream_writable = Writable; + + // It seems a linked list but it is not + // there will be only 2 of these for each stream + function CorkedRequest(state) { + var _this = this; + this.next = null; + this.entry = null; + this.finish = function () { + onCorkedFinish(_this, state); + }; + } + /* */ + + /**/ + var Duplex; + /**/ + + Writable.WritableState = WritableState; + + /**/ + var internalUtil = { + deprecate: requireNode() + }; + /**/ + + /**/ + var Stream = requireStream(); + /**/ + + var Buffer = require$$0$7.Buffer; + var OurUint8Array = (typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {}; + function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); + } + function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; + } + var destroyImpl = requireDestroy(); + var _require = requireState(), + getHighWaterMark = _require.getHighWaterMark; + var _require$codes = requireErrors().codes, + ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, + ERR_STREAM_CANNOT_PIPE = _require$codes.ERR_STREAM_CANNOT_PIPE, + ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED, + ERR_STREAM_NULL_VALUES = _require$codes.ERR_STREAM_NULL_VALUES, + ERR_STREAM_WRITE_AFTER_END = _require$codes.ERR_STREAM_WRITE_AFTER_END, + ERR_UNKNOWN_ENCODING = _require$codes.ERR_UNKNOWN_ENCODING; + var errorOrDestroy = destroyImpl.errorOrDestroy; + requireInherits()(Writable, Stream); + function nop() {} + function WritableState(options, stream, isDuplex) { + Duplex = Duplex || require_stream_duplex(); + options = options || {}; + + // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream, + // e.g. options.readableObjectMode vs. options.writableObjectMode, etc. + if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + this.highWaterMark = getHighWaterMark(this, options, 'writableHighWaterMark', isDuplex); + + // if _final has been called + this.finalCalled = false; + + // drain event flag. + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // has it been destroyed + this.destroyed = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // when true all writes will be buffered until .uncork() call + this.corked = 0; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + this.bufferedRequest = null; + this.lastBufferedRequest = null; + + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; + + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; + + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; + + // Should close be emitted on destroy. Defaults to true. + this.emitClose = options.emitClose !== false; + + // Should .destroy() be called after 'finish' (and potentially 'end') + this.autoDestroy = !!options.autoDestroy; + + // count buffered requests + this.bufferedRequestCount = 0; + + // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two + this.corkedRequestsFree = new CorkedRequest(this); + } + WritableState.prototype.getBuffer = function getBuffer() { + var current = this.bufferedRequest; + var out = []; + while (current) { + out.push(current); + current = current.next; + } + return out; + }; + (function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function writableStateBufferGetter() { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') + }); + } catch (_) {} + })(); + + // Test _writableState for inheritance to account for Duplex streams, + // whose prototype chain only points to Readable. + var realHasInstance; + if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable, Symbol.hasInstance, { + value: function value(object) { + if (realHasInstance.call(this, object)) return true; + if (this !== Writable) return false; + return object && object._writableState instanceof WritableState; + } + }); + } else { + realHasInstance = function realHasInstance(object) { + return object instanceof this; + }; + } + function Writable(options) { + Duplex = Duplex || require_stream_duplex(); + + // Writable ctor is applied to Duplexes, too. + // `realHasInstance` is necessary because using plain `instanceof` + // would return false, as no `_writableState` property is attached. + + // Trying to use the custom `instanceof` for Writable here will also break the + // Node.js LazyTransform implementation, which has a non-trivial getter for + // `_writableState` that would lead to infinite recursion. + + // Checking for a Stream.Duplex instance is faster here instead of inside + // the WritableState constructor, at least with V8 6.5 + var isDuplex = this instanceof Duplex; + if (!isDuplex && !realHasInstance.call(Writable, this)) return new Writable(options); + this._writableState = new WritableState(options, this, isDuplex); + + // legacy. + this.writable = true; + if (options) { + if (typeof options.write === 'function') this._write = options.write; + if (typeof options.writev === 'function') this._writev = options.writev; + if (typeof options.destroy === 'function') this._destroy = options.destroy; + if (typeof options.final === 'function') this._final = options.final; + } + Stream.call(this); + } + + // Otherwise people can pipe Writable streams, which is just wrong. + Writable.prototype.pipe = function () { + errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE()); + }; + function writeAfterEnd(stream, cb) { + var er = new ERR_STREAM_WRITE_AFTER_END(); + // TODO: defer error events consistently everywhere, not just the cb + errorOrDestroy(stream, er); + process.nextTick(cb, er); + } + + // Checks that a user-supplied chunk is valid, especially for the particular + // mode the stream is in. Currently this means that `null` is never accepted + // and undefined/non-string values are only allowed in object mode. + function validChunk(stream, state, chunk, cb) { + var er; + if (chunk === null) { + er = new ERR_STREAM_NULL_VALUES(); + } else if (typeof chunk !== 'string' && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk); + } + if (er) { + errorOrDestroy(stream, er); + process.nextTick(cb, er); + return false; + } + return true; + } + Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + var isBuf = !state.objectMode && _isUint8Array(chunk); + if (isBuf && !Buffer.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + if (typeof cb !== 'function') cb = nop; + if (state.ending) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); + } + return ret; + }; + Writable.prototype.cork = function () { + this._writableState.corked++; + }; + Writable.prototype.uncork = function () { + var state = this._writableState; + if (state.corked) { + state.corked--; + if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + } + }; + Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new ERR_UNKNOWN_ENCODING(encoding); + this._writableState.defaultEncoding = encoding; + return this; + }; + Object.defineProperty(Writable.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } + }); + function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); + } + return chunk; + } + Object.defineProperty(Writable.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.highWaterMark; + } + }); + + // if we're already writing something, then just put this + // in the queue, and wait our turn. Otherwise, call _write + // If we return false, then we need a drain event, so set that flag. + function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { + isBuf = true; + encoding = 'buffer'; + chunk = newChunk; + } + } + var len = state.objectMode ? 1 : chunk.length; + state.length += len; + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) state.needDrain = true; + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = { + chunk: chunk, + encoding: encoding, + isBuf: isBuf, + callback: cb, + next: null + }; + if (last) { + last.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); + } + return ret; + } + function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (state.destroyed) state.onwrite(new ERR_STREAM_DESTROYED('write'));else if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; + } + function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; + if (sync) { + // defer the callback if we are being called synchronously + // to avoid piling up things on the stack + process.nextTick(cb, er); + // this can emit finish, and it will always happen + // after error + process.nextTick(finishMaybe, stream, state); + stream._writableState.errorEmitted = true; + errorOrDestroy(stream, er); + } else { + // the caller expect this to happen before if + // it is async + cb(er); + stream._writableState.errorEmitted = true; + errorOrDestroy(stream, er); + // this can emit finish, but finish must + // always follow error + finishMaybe(stream, state); + } + } + function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; + } + function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + if (typeof cb !== 'function') throw new ERR_MULTIPLE_CALLBACK(); + onwriteStateUpdate(state); + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state) || stream.destroyed; + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); + } + if (sync) { + process.nextTick(afterWrite, stream, state, finished, cb); + } else { + afterWrite(stream, state, finished, cb); + } + } + } + function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); + } + + // Must force callback to be called on nextTick, so that we don't + // emit 'drain' before the write() consumer gets the 'false' return + // value, and has a chance to attach a 'drain' listener. + function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } + } + + // if there's something in the buffer waiting, then process it + function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; + var count = 0; + var allBuffers = true; + while (entry) { + buffer[count] = entry; + if (!entry.isBuf) allBuffers = false; + entry = entry.next; + count += 1; + } + buffer.allBuffers = allBuffers; + doWrite(stream, state, true, state.length, buffer, '', holder.finish); + + // doWrite is almost always async, defer these to save a bit of time + // as the hot path ends with doWrite + state.pendingcb++; + state.lastBufferedRequest = null; + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); + } + state.bufferedRequestCount = 0; + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + state.bufferedRequestCount--; + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + break; + } + } + if (entry === null) state.lastBufferedRequest = null; + } + state.bufferedRequest = entry; + state.bufferProcessing = false; + } + Writable.prototype._write = function (chunk, encoding, cb) { + cb(new ERR_METHOD_NOT_IMPLEMENTED('_write()')); + }; + Writable.prototype._writev = null; + Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); + + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } + + // ignore unnecessary end() calls. + if (!state.ending) endWritable(this, state, cb); + return this; + }; + Object.defineProperty(Writable.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } + }); + function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; + } + function callFinal(stream, state) { + stream._final(function (err) { + state.pendingcb--; + if (err) { + errorOrDestroy(stream, err); + } + state.prefinished = true; + stream.emit('prefinish'); + finishMaybe(stream, state); + }); + } + function prefinish(stream, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream._final === 'function' && !state.destroyed) { + state.pendingcb++; + state.finalCalled = true; + process.nextTick(callFinal, stream, state); + } else { + state.prefinished = true; + stream.emit('prefinish'); + } + } + } + function finishMaybe(stream, state) { + var need = needFinish(state); + if (need) { + prefinish(stream, state); + if (state.pendingcb === 0) { + state.finished = true; + stream.emit('finish'); + if (state.autoDestroy) { + // In case of duplex streams we need a way to detect + // if the readable side is ready for autoDestroy as well + var rState = stream._readableState; + if (!rState || rState.autoDestroy && rState.endEmitted) { + stream.destroy(); + } + } + } + } + return need; + } + function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) process.nextTick(cb);else stream.once('finish', cb); + } + state.ended = true; + stream.writable = false; + } + function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + + // reuse the free corkReq. + state.corkedRequestsFree.next = corkReq; + } + Object.defineProperty(Writable.prototype, 'destroyed', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + if (this._writableState === undefined) { + return false; + } + return this._writableState.destroyed; + }, + set: function set(value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._writableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._writableState.destroyed = value; + } + }); + Writable.prototype.destroy = destroyImpl.destroy; + Writable.prototype._undestroy = destroyImpl.undestroy; + Writable.prototype._destroy = function (err, cb) { + cb(err); + }; + return _stream_writable; +} + +var _stream_duplex; +var hasRequired_stream_duplex; + +function require_stream_duplex () { + if (hasRequired_stream_duplex) return _stream_duplex; + hasRequired_stream_duplex = 1; + + /**/ + var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) keys.push(key); + return keys; + }; + /**/ + + _stream_duplex = Duplex; + var Readable = require_stream_readable(); + var Writable = require_stream_writable(); + requireInherits()(Duplex, Readable); + { + // Allow the keys array to be GC'ed. + var keys = objectKeys(Writable.prototype); + for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; + } + } + function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + Readable.call(this, options); + Writable.call(this, options); + this.allowHalfOpen = true; + if (options) { + if (options.readable === false) this.readable = false; + if (options.writable === false) this.writable = false; + if (options.allowHalfOpen === false) { + this.allowHalfOpen = false; + this.once('end', onend); + } + } + } + Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.highWaterMark; + } + }); + Object.defineProperty(Duplex.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } + }); + Object.defineProperty(Duplex.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } + }); + + // the no-half-open enforcer + function onend() { + // If the writable side ended, then we're ok. + if (this._writableState.ended) return; + + // no more data can be written. + // But allow more writes to happen in this tick. + process.nextTick(onEndNT, this); + } + function onEndNT(self) { + self.end(); + } + Object.defineProperty(Duplex.prototype, 'destroyed', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + if (this._readableState === undefined || this._writableState === undefined) { + return false; + } + return this._readableState.destroyed && this._writableState.destroyed; + }, + set: function set(value) { + // we ignore the value if the stream + // has not been initialized yet + if (this._readableState === undefined || this._writableState === undefined) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } + }); + return _stream_duplex; +} + +var string_decoder = {}; + +var safeBuffer = {exports: {}}; + +/*! safe-buffer. MIT License. Feross Aboukhadijeh */ + +var hasRequiredSafeBuffer; + +function requireSafeBuffer () { + if (hasRequiredSafeBuffer) return safeBuffer.exports; + hasRequiredSafeBuffer = 1; + (function (module, exports) { + /* eslint-disable node/no-deprecated-api */ + var buffer = require$$0$7; + var Buffer = buffer.Buffer; + + // alternative to using Object.keys for old browsers + function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key]; + } + } + if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer; + } else { + // Copy properties from require('buffer') + copyProps(buffer, exports); + exports.Buffer = SafeBuffer; + } + + function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) + } + + SafeBuffer.prototype = Object.create(Buffer.prototype); + + // Copy static methods from Buffer + copyProps(Buffer, SafeBuffer); + + SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) + }; + + SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size); + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding); + } else { + buf.fill(fill); + } + } else { + buf.fill(0); + } + return buf + }; + + SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) + }; + + SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) + }; + } (safeBuffer, safeBuffer.exports)); + return safeBuffer.exports; +} + +var hasRequiredString_decoder; + +function requireString_decoder () { + if (hasRequiredString_decoder) return string_decoder; + hasRequiredString_decoder = 1; + + /**/ + + var Buffer = requireSafeBuffer().Buffer; + /**/ + + var isEncoding = Buffer.isEncoding || function (encoding) { + encoding = '' + encoding; + switch (encoding && encoding.toLowerCase()) { + case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': + return true; + default: + return false; + } + }; + + function _normalizeEncoding(enc) { + if (!enc) return 'utf8'; + var retried; + while (true) { + switch (enc) { + case 'utf8': + case 'utf-8': + return 'utf8'; + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return 'utf16le'; + case 'latin1': + case 'binary': + return 'latin1'; + case 'base64': + case 'ascii': + case 'hex': + return enc; + default: + if (retried) return; // undefined + enc = ('' + enc).toLowerCase(); + retried = true; + } + } + } + // Do not cache `Buffer.isEncoding` when checking encoding names as some + // modules monkey-patch it to support additional encodings + function normalizeEncoding(enc) { + var nenc = _normalizeEncoding(enc); + if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); + return nenc || enc; + } + + // StringDecoder provides an interface for efficiently splitting a series of + // buffers into a series of JS strings without breaking apart multi-byte + // characters. + string_decoder.StringDecoder = StringDecoder; + function StringDecoder(encoding) { + this.encoding = normalizeEncoding(encoding); + var nb; + switch (this.encoding) { + case 'utf16le': + this.text = utf16Text; + this.end = utf16End; + nb = 4; + break; + case 'utf8': + this.fillLast = utf8FillLast; + nb = 4; + break; + case 'base64': + this.text = base64Text; + this.end = base64End; + nb = 3; + break; + default: + this.write = simpleWrite; + this.end = simpleEnd; + return; + } + this.lastNeed = 0; + this.lastTotal = 0; + this.lastChar = Buffer.allocUnsafe(nb); + } + + StringDecoder.prototype.write = function (buf) { + if (buf.length === 0) return ''; + var r; + var i; + if (this.lastNeed) { + r = this.fillLast(buf); + if (r === undefined) return ''; + i = this.lastNeed; + this.lastNeed = 0; + } else { + i = 0; + } + if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); + return r || ''; + }; + + StringDecoder.prototype.end = utf8End; + + // Returns only complete characters in a Buffer + StringDecoder.prototype.text = utf8Text; + + // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer + StringDecoder.prototype.fillLast = function (buf) { + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); + this.lastNeed -= buf.length; + }; + + // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a + // continuation byte. If an invalid byte is detected, -2 is returned. + function utf8CheckByte(byte) { + if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; + return byte >> 6 === 0x02 ? -1 : -2; + } + + // Checks at most 3 bytes at the end of a Buffer in order to detect an + // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) + // needed to complete the UTF-8 character (if applicable) are returned. + function utf8CheckIncomplete(self, buf, i) { + var j = buf.length - 1; + if (j < i) return 0; + var nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 1; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 2; + return nb; + } + if (--j < i || nb === -2) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) { + if (nb === 2) nb = 0;else self.lastNeed = nb - 3; + } + return nb; + } + return 0; + } + + // Validates as many continuation bytes for a multi-byte UTF-8 character as + // needed or are available. If we see a non-continuation byte where we expect + // one, we "replace" the validated continuation bytes we've seen so far with + // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding + // behavior. The continuation byte check is included three times in the case + // where all of the continuation bytes for a character exist in the same buffer. + // It is also done this way as a slight performance increase instead of using a + // loop. + function utf8CheckExtraBytes(self, buf, p) { + if ((buf[0] & 0xC0) !== 0x80) { + self.lastNeed = 0; + return '\ufffd'; + } + if (self.lastNeed > 1 && buf.length > 1) { + if ((buf[1] & 0xC0) !== 0x80) { + self.lastNeed = 1; + return '\ufffd'; + } + if (self.lastNeed > 2 && buf.length > 2) { + if ((buf[2] & 0xC0) !== 0x80) { + self.lastNeed = 2; + return '\ufffd'; + } + } + } + } + + // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. + function utf8FillLast(buf) { + var p = this.lastTotal - this.lastNeed; + var r = utf8CheckExtraBytes(this, buf); + if (r !== undefined) return r; + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, p, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, p, 0, buf.length); + this.lastNeed -= buf.length; + } + + // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a + // partial character, the character's bytes are buffered until the required + // number of bytes are available. + function utf8Text(buf, i) { + var total = utf8CheckIncomplete(this, buf, i); + if (!this.lastNeed) return buf.toString('utf8', i); + this.lastTotal = total; + var end = buf.length - (total - this.lastNeed); + buf.copy(this.lastChar, 0, end); + return buf.toString('utf8', i, end); + } + + // For UTF-8, a replacement character is added when ending on a partial + // character. + function utf8End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + '\ufffd'; + return r; + } + + // UTF-16LE typically needs two bytes per character, but even if we have an even + // number of bytes available, we need to check if we end on a leading/high + // surrogate. In that case, we need to wait for the next two bytes in order to + // decode the last character properly. + function utf16Text(buf, i) { + if ((buf.length - i) % 2 === 0) { + var r = buf.toString('utf16le', i); + if (r) { + var c = r.charCodeAt(r.length - 1); + if (c >= 0xD800 && c <= 0xDBFF) { + this.lastNeed = 2; + this.lastTotal = 4; + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + return r.slice(0, -1); + } + } + return r; + } + this.lastNeed = 1; + this.lastTotal = 2; + this.lastChar[0] = buf[buf.length - 1]; + return buf.toString('utf16le', i, buf.length - 1); + } + + // For UTF-16LE we do not explicitly append special replacement characters if we + // end on a partial character, we simply let v8 handle that. + function utf16End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) { + var end = this.lastTotal - this.lastNeed; + return r + this.lastChar.toString('utf16le', 0, end); + } + return r; + } + + function base64Text(buf, i) { + var n = (buf.length - i) % 3; + if (n === 0) return buf.toString('base64', i); + this.lastNeed = 3 - n; + this.lastTotal = 3; + if (n === 1) { + this.lastChar[0] = buf[buf.length - 1]; + } else { + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + } + return buf.toString('base64', i, buf.length - n); + } + + function base64End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); + return r; + } + + // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) + function simpleWrite(buf) { + return buf.toString(this.encoding); + } + + function simpleEnd(buf) { + return buf && buf.length ? this.write(buf) : ''; + } + return string_decoder; +} + +var endOfStream; +var hasRequiredEndOfStream; + +function requireEndOfStream () { + if (hasRequiredEndOfStream) return endOfStream; + hasRequiredEndOfStream = 1; + + var ERR_STREAM_PREMATURE_CLOSE = requireErrors().codes.ERR_STREAM_PREMATURE_CLOSE; + function once(callback) { + var called = false; + return function () { + if (called) return; + called = true; + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + callback.apply(this, args); + }; + } + function noop() {} + function isRequest(stream) { + return stream.setHeader && typeof stream.abort === 'function'; + } + function eos(stream, opts, callback) { + if (typeof opts === 'function') return eos(stream, null, opts); + if (!opts) opts = {}; + callback = once(callback || noop); + var readable = opts.readable || opts.readable !== false && stream.readable; + var writable = opts.writable || opts.writable !== false && stream.writable; + var onlegacyfinish = function onlegacyfinish() { + if (!stream.writable) onfinish(); + }; + var writableEnded = stream._writableState && stream._writableState.finished; + var onfinish = function onfinish() { + writable = false; + writableEnded = true; + if (!readable) callback.call(stream); + }; + var readableEnded = stream._readableState && stream._readableState.endEmitted; + var onend = function onend() { + readable = false; + readableEnded = true; + if (!writable) callback.call(stream); + }; + var onerror = function onerror(err) { + callback.call(stream, err); + }; + var onclose = function onclose() { + var err; + if (readable && !readableEnded) { + if (!stream._readableState || !stream._readableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream, err); + } + if (writable && !writableEnded) { + if (!stream._writableState || !stream._writableState.ended) err = new ERR_STREAM_PREMATURE_CLOSE(); + return callback.call(stream, err); + } + }; + var onrequest = function onrequest() { + stream.req.on('finish', onfinish); + }; + if (isRequest(stream)) { + stream.on('complete', onfinish); + stream.on('abort', onclose); + if (stream.req) onrequest();else stream.on('request', onrequest); + } else if (writable && !stream._writableState) { + // legacy streams + stream.on('end', onlegacyfinish); + stream.on('close', onlegacyfinish); + } + stream.on('end', onend); + stream.on('finish', onfinish); + if (opts.error !== false) stream.on('error', onerror); + stream.on('close', onclose); + return function () { + stream.removeListener('complete', onfinish); + stream.removeListener('abort', onclose); + stream.removeListener('request', onrequest); + if (stream.req) stream.req.removeListener('finish', onfinish); + stream.removeListener('end', onlegacyfinish); + stream.removeListener('close', onlegacyfinish); + stream.removeListener('finish', onfinish); + stream.removeListener('end', onend); + stream.removeListener('error', onerror); + stream.removeListener('close', onclose); + }; + } + endOfStream = eos; + return endOfStream; +} + +var async_iterator; +var hasRequiredAsync_iterator; + +function requireAsync_iterator () { + if (hasRequiredAsync_iterator) return async_iterator; + hasRequiredAsync_iterator = 1; + + var _Object$setPrototypeO; + function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } + function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } + var finished = requireEndOfStream(); + var kLastResolve = Symbol('lastResolve'); + var kLastReject = Symbol('lastReject'); + var kError = Symbol('error'); + var kEnded = Symbol('ended'); + var kLastPromise = Symbol('lastPromise'); + var kHandlePromise = Symbol('handlePromise'); + var kStream = Symbol('stream'); + function createIterResult(value, done) { + return { + value: value, + done: done + }; + } + function readAndResolve(iter) { + var resolve = iter[kLastResolve]; + if (resolve !== null) { + var data = iter[kStream].read(); + // we defer if data is null + // we can be expecting either 'end' or + // 'error' + if (data !== null) { + iter[kLastPromise] = null; + iter[kLastResolve] = null; + iter[kLastReject] = null; + resolve(createIterResult(data, false)); + } + } + } + function onReadable(iter) { + // we wait for the next tick, because it might + // emit an error with process.nextTick + process.nextTick(readAndResolve, iter); + } + function wrapForNext(lastPromise, iter) { + return function (resolve, reject) { + lastPromise.then(function () { + if (iter[kEnded]) { + resolve(createIterResult(undefined, true)); + return; + } + iter[kHandlePromise](resolve, reject); + }, reject); + }; + } + var AsyncIteratorPrototype = Object.getPrototypeOf(function () {}); + var ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf((_Object$setPrototypeO = { + get stream() { + return this[kStream]; + }, + next: function next() { + var _this = this; + // if we have detected an error in the meanwhile + // reject straight away + var error = this[kError]; + if (error !== null) { + return Promise.reject(error); + } + if (this[kEnded]) { + return Promise.resolve(createIterResult(undefined, true)); + } + if (this[kStream].destroyed) { + // We need to defer via nextTick because if .destroy(err) is + // called, the error will be emitted via nextTick, and + // we cannot guarantee that there is no error lingering around + // waiting to be emitted. + return new Promise(function (resolve, reject) { + process.nextTick(function () { + if (_this[kError]) { + reject(_this[kError]); + } else { + resolve(createIterResult(undefined, true)); + } + }); + }); + } + + // if we have multiple next() calls + // we will wait for the previous Promise to finish + // this logic is optimized to support for await loops, + // where next() is only called once at a time + var lastPromise = this[kLastPromise]; + var promise; + if (lastPromise) { + promise = new Promise(wrapForNext(lastPromise, this)); + } else { + // fast path needed to support multiple this.push() + // without triggering the next() queue + var data = this[kStream].read(); + if (data !== null) { + return Promise.resolve(createIterResult(data, false)); + } + promise = new Promise(this[kHandlePromise]); + } + this[kLastPromise] = promise; + return promise; + } + }, _defineProperty(_Object$setPrototypeO, Symbol.asyncIterator, function () { + return this; + }), _defineProperty(_Object$setPrototypeO, "return", function _return() { + var _this2 = this; + // destroy(err, cb) is a private API + // we can guarantee we have that here, because we control the + // Readable class this is attached to + return new Promise(function (resolve, reject) { + _this2[kStream].destroy(null, function (err) { + if (err) { + reject(err); + return; + } + resolve(createIterResult(undefined, true)); + }); + }); + }), _Object$setPrototypeO), AsyncIteratorPrototype); + var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator(stream) { + var _Object$create; + var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, { + value: stream, + writable: true + }), _defineProperty(_Object$create, kLastResolve, { + value: null, + writable: true + }), _defineProperty(_Object$create, kLastReject, { + value: null, + writable: true + }), _defineProperty(_Object$create, kError, { + value: null, + writable: true + }), _defineProperty(_Object$create, kEnded, { + value: stream._readableState.endEmitted, + writable: true + }), _defineProperty(_Object$create, kHandlePromise, { + value: function value(resolve, reject) { + var data = iterator[kStream].read(); + if (data) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve(createIterResult(data, false)); + } else { + iterator[kLastResolve] = resolve; + iterator[kLastReject] = reject; + } + }, + writable: true + }), _Object$create)); + iterator[kLastPromise] = null; + finished(stream, function (err) { + if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') { + var reject = iterator[kLastReject]; + // reject if we are waiting for data in the Promise + // returned by next() and store the error + if (reject !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + reject(err); + } + iterator[kError] = err; + return; + } + var resolve = iterator[kLastResolve]; + if (resolve !== null) { + iterator[kLastPromise] = null; + iterator[kLastResolve] = null; + iterator[kLastReject] = null; + resolve(createIterResult(undefined, true)); + } + iterator[kEnded] = true; + }); + stream.on('readable', onReadable.bind(null, iterator)); + return iterator; + }; + async_iterator = createReadableStreamAsyncIterator; + return async_iterator; +} + +var from_1; +var hasRequiredFrom; + +function requireFrom () { + if (hasRequiredFrom) return from_1; + hasRequiredFrom = 1; + + function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } + function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } + function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } + function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } + var ERR_INVALID_ARG_TYPE = requireErrors().codes.ERR_INVALID_ARG_TYPE; + function from(Readable, iterable, opts) { + var iterator; + if (iterable && typeof iterable.next === 'function') { + iterator = iterable; + } else if (iterable && iterable[Symbol.asyncIterator]) iterator = iterable[Symbol.asyncIterator]();else if (iterable && iterable[Symbol.iterator]) iterator = iterable[Symbol.iterator]();else throw new ERR_INVALID_ARG_TYPE('iterable', ['Iterable'], iterable); + var readable = new Readable(_objectSpread({ + objectMode: true + }, opts)); + // Reading boolean to protect against _read + // being called before last iteration completion. + var reading = false; + readable._read = function () { + if (!reading) { + reading = true; + next(); + } + }; + function next() { + return _next2.apply(this, arguments); + } + function _next2() { + _next2 = _asyncToGenerator(function* () { + try { + var _yield$iterator$next = yield iterator.next(), + value = _yield$iterator$next.value, + done = _yield$iterator$next.done; + if (done) { + readable.push(null); + } else if (readable.push(yield value)) { + next(); + } else { + reading = false; + } + } catch (err) { + readable.destroy(err); + } + }); + return _next2.apply(this, arguments); + } + return readable; + } + from_1 = from; + return from_1; +} + +var _stream_readable; +var hasRequired_stream_readable; + +function require_stream_readable () { + if (hasRequired_stream_readable) return _stream_readable; + hasRequired_stream_readable = 1; + + _stream_readable = Readable; + + /**/ + var Duplex; + /**/ + + Readable.ReadableState = ReadableState; + + /**/ + require$$0$3.EventEmitter; + var EElistenerCount = function EElistenerCount(emitter, type) { + return emitter.listeners(type).length; + }; + /**/ + + /**/ + var Stream = requireStream(); + /**/ + + var Buffer = require$$0$7.Buffer; + var OurUint8Array = (typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {}; + function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); + } + function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; + } + + /**/ + var debugUtil = require$$1$2; + var debug; + if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); + } else { + debug = function debug() {}; + } + /**/ + + var BufferList = requireBuffer_list(); + var destroyImpl = requireDestroy(); + var _require = requireState(), + getHighWaterMark = _require.getHighWaterMark; + var _require$codes = requireErrors().codes, + ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, + ERR_STREAM_PUSH_AFTER_EOF = _require$codes.ERR_STREAM_PUSH_AFTER_EOF, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; + + // Lazy loaded to improve the startup performance. + var StringDecoder; + var createReadableStreamAsyncIterator; + var from; + requireInherits()(Readable, Stream); + var errorOrDestroy = destroyImpl.errorOrDestroy; + var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; + function prependListener(emitter, event, fn) { + // Sadly this is not cacheable as some libraries bundle their own + // event emitter implementation with them. + if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); + + // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; + } + function ReadableState(options, stream, isDuplex) { + Duplex = Duplex || require_stream_duplex(); + options = options || {}; + + // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + if (typeof isDuplex !== 'boolean') isDuplex = stream instanceof Duplex; + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + this.highWaterMark = getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex); + + // A linked list is used to store data chunks instead of an array because the + // linked list can remove elements from the beginning faster than + // array.shift() + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // a flag to be able to tell if the event 'readable'/'data' is emitted + // immediately, or on a later tick. We set this to true at first, because + // any actions that shouldn't happen until "later" should generally also + // not happen before the first read call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + this.paused = true; + + // Should close be emitted on destroy. Defaults to true. + this.emitClose = options.emitClose !== false; + + // Should .destroy() be called after 'end' (and potentially 'finish') + this.autoDestroy = !!options.autoDestroy; + + // has it been destroyed + this.destroyed = false; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) StringDecoder = requireString_decoder().StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } + } + function Readable(options) { + Duplex = Duplex || require_stream_duplex(); + if (!(this instanceof Readable)) return new Readable(options); + + // Checking for a Stream.Duplex instance is faster here instead of inside + // the ReadableState constructor, at least with V8 6.5 + var isDuplex = this instanceof Duplex; + this._readableState = new ReadableState(options, this, isDuplex); + + // legacy + this.readable = true; + if (options) { + if (typeof options.read === 'function') this._read = options.read; + if (typeof options.destroy === 'function') this._destroy = options.destroy; + } + Stream.call(this); + } + Object.defineProperty(Readable.prototype, 'destroyed', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + if (this._readableState === undefined) { + return false; + } + return this._readableState.destroyed; + }, + set: function set(value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._readableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + } + }); + Readable.prototype.destroy = destroyImpl.destroy; + Readable.prototype._undestroy = destroyImpl.undestroy; + Readable.prototype._destroy = function (err, cb) { + cb(err); + }; + + // Manually shove something into the read() buffer. + // This returns true if the highWaterMark has not been hit yet, + // similar to how Writable.write() returns true if you should + // write() some more. + Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + var skipChunkCheck; + if (!state.objectMode) { + if (typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = Buffer.from(chunk, encoding); + encoding = ''; + } + skipChunkCheck = true; + } + } else { + skipChunkCheck = true; + } + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); + }; + + // Unshift should *always* be something directly out of read() + Readable.prototype.unshift = function (chunk) { + return readableAddChunk(this, chunk, null, true, false); + }; + function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + debug('readableAddChunk', chunk); + var state = stream._readableState; + if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else { + var er; + if (!skipChunkCheck) er = chunkInvalid(state, chunk); + if (er) { + errorOrDestroy(stream, er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { + chunk = _uint8ArrayToBuffer(chunk); + } + if (addToFront) { + if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true); + } else if (state.ended) { + errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF()); + } else if (state.destroyed) { + return false; + } else { + state.reading = false; + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); + } else { + addChunk(stream, state, chunk, false); + } + } + } else if (!addToFront) { + state.reading = false; + maybeReadMore(stream, state); + } + } + + // We can push more data if we are below the highWaterMark. + // Also, if we have no data yet, we can stand some more bytes. + // This is to work around cases where hwm=0, such as the repl. + return !state.ended && (state.length < state.highWaterMark || state.length === 0); + } + function addChunk(stream, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + state.awaitDrain = 0; + stream.emit('data', chunk); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + if (state.needReadable) emitReadable(stream); + } + maybeReadMore(stream, state); + } + function chunkInvalid(state, chunk) { + var er; + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer', 'Uint8Array'], chunk); + } + return er; + } + Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; + }; + + // backwards compatibility. + Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = requireString_decoder().StringDecoder; + var decoder = new StringDecoder(enc); + this._readableState.decoder = decoder; + // If setEncoding(null), decoder.encoding equals utf8 + this._readableState.encoding = this._readableState.decoder.encoding; + + // Iterate over current buffer to convert already stored Buffers: + var p = this._readableState.buffer.head; + var content = ''; + while (p !== null) { + content += decoder.write(p.data); + p = p.next; + } + this._readableState.buffer.clear(); + if (content !== '') this._readableState.buffer.push(content); + this._readableState.length = content.length; + return this; + }; + + // Don't raise the hwm > 1GB + var MAX_HWM = 0x40000000; + function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + // TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE. + n = MAX_HWM; + } else { + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + return n; + } + + // This function is designed to be inlinable, so please take care when making + // changes to the function body. + function howMuchToRead(n, state) { + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + } + // If we're asking for more than the current hwm, then raise the hwm. + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + if (n <= state.length) return n; + // Don't have enough + if (!state.ended) { + state.needReadable = true; + return 0; + } + return state.length; + } + + // you can override either this method, or the async _read(n) below. + Readable.prototype.read = function (n) { + debug('read', n); + n = parseInt(n, 10); + var state = this._readableState; + var nOrig = n; + if (n !== 0) state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && state.needReadable && ((state.highWaterMark !== 0 ? state.length >= state.highWaterMark : state.length > 0) || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } + + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + debug('need readable', doRead); + + // if we currently have less than the highWaterMark, then also read some + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } else if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (!state.reading) n = howMuchToRead(nOrig, state); + } + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; + if (ret === null) { + state.needReadable = state.length <= state.highWaterMark; + n = 0; + } else { + state.length -= n; + state.awaitDrain = 0; + } + if (state.length === 0) { + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (!state.ended) state.needReadable = true; + + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended) endReadable(this); + } + if (ret !== null) this.emit('data', ret); + return ret; + }; + function onEofChunk(stream, state) { + debug('onEofChunk'); + if (state.ended) return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + if (state.sync) { + // if we are sync, wait until next tick to emit the data. + // Otherwise we risk emitting data in the flow() + // the readable code triggers during a read() call + emitReadable(stream); + } else { + // emit 'readable' now to make sure it gets picked up. + state.needReadable = false; + if (!state.emittedReadable) { + state.emittedReadable = true; + emitReadable_(stream); + } + } + } + + // Don't emit readable right away in sync mode, because this can trigger + // another read() call => stack overflow. This way, it might trigger + // a nextTick recursion warning, but that's not so bad. + function emitReadable(stream) { + var state = stream._readableState; + debug('emitReadable', state.needReadable, state.emittedReadable); + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + process.nextTick(emitReadable_, stream); + } + } + function emitReadable_(stream) { + var state = stream._readableState; + debug('emitReadable_', state.destroyed, state.length, state.ended); + if (!state.destroyed && (state.length || state.ended)) { + stream.emit('readable'); + state.emittedReadable = false; + } + + // The stream needs another readable event if + // 1. It is not flowing, as the flow mechanism will take + // care of it. + // 2. It is not ended. + // 3. It is below the highWaterMark, so we can schedule + // another readable later. + state.needReadable = !state.flowing && !state.ended && state.length <= state.highWaterMark; + flow(stream); + } + + // at this point, the user has presumably seen the 'readable' event, + // and called read() to consume some data. that may have triggered + // in turn another _read(n) call, in which case reading = true if + // it's in progress. + // However, if we're not ended, or reading, and the length < hwm, + // then go ahead and try to read some more preemptively. + function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + process.nextTick(maybeReadMore_, stream, state); + } + } + function maybeReadMore_(stream, state) { + // Attempt to read more data if we should. + // + // The conditions for reading more data are (one of): + // - Not enough data buffered (state.length < state.highWaterMark). The loop + // is responsible for filling the buffer with enough data if such data + // is available. If highWaterMark is 0 and we are not in the flowing mode + // we should _not_ attempt to buffer any extra data. We'll get more data + // when the stream consumer calls read() instead. + // - No data in the buffer, and the stream is in flowing mode. In this mode + // the loop below is responsible for ensuring read() is called. Failing to + // call read here would abort the flow and there's no other mechanism for + // continuing the flow if the stream consumer has just subscribed to the + // 'data' event. + // + // In addition to the above conditions to keep reading data, the following + // conditions prevent the data from being read: + // - The stream has ended (state.ended). + // - There is already a pending 'read' operation (state.reading). This is a + // case where the the stream has called the implementation defined _read() + // method, but they are processing the call asynchronously and have _not_ + // called push() with new data. In this case we skip performing more + // read()s. The execution ends in this method again after the _read() ends + // up calling push() with more data. + while (!state.reading && !state.ended && (state.length < state.highWaterMark || state.flowing && state.length === 0)) { + var len = state.length; + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break; + } + state.readingMore = false; + } + + // abstract method. to be overridden in specific implementation classes. + // call cb(er, data) where data is <= n in length. + // for virtual (non-string, non-buffer) streams, "length" is somewhat + // arbitrary, and perhaps not very meaningful. + Readable.prototype._read = function (n) { + errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()')); + }; + Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + var endFn = doEnd ? onend : unpipe; + if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn); + dest.on('unpipe', onunpipe); + function onunpipe(readable, unpipeInfo) { + debug('onunpipe'); + if (readable === src) { + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } + } + } + function onend() { + debug('onend'); + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + var cleanedUp = false; + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', unpipe); + src.removeListener('data', ondata); + cleanedUp = true; + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + var ret = dest.write(chunk); + debug('dest.write', ret); + if (ret === false) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { + debug('false write response, pause', state.awaitDrain); + state.awaitDrain++; + } + src.pause(); + } + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er); + } + + // Make sure our error handler is attached before userland ones. + prependListener(dest, 'error', onerror); + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + return dest; + }; + function pipeOnDrain(src) { + return function pipeOnDrainFunctionResult() { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; + } + Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + var unpipeInfo = { + hasUnpiped: false + }; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; + if (!dest) dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this, unpipeInfo); + return this; + } + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + for (var i = 0; i < len; i++) dests[i].emit('unpipe', this, { + hasUnpiped: false + }); + return this; + } + + // try to find the right one. + var index = indexOf(state.pipes, dest); + if (index === -1) return this; + state.pipes.splice(index, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; + dest.emit('unpipe', this, unpipeInfo); + return this; + }; + + // set up data events if they are asked for + // Ensure readable listeners eventually get something + Readable.prototype.on = function (ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + var state = this._readableState; + if (ev === 'data') { + // update readableListening so that resume() may be a no-op + // a few lines down. This is needed to support once('readable'). + state.readableListening = this.listenerCount('readable') > 0; + + // Try start flowing on next tick if stream isn't explicitly paused + if (state.flowing !== false) this.resume(); + } else if (ev === 'readable') { + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.flowing = false; + state.emittedReadable = false; + debug('on readable', state.length, state.reading); + if (state.length) { + emitReadable(this); + } else if (!state.reading) { + process.nextTick(nReadingNextTick, this); + } + } + } + return res; + }; + Readable.prototype.addListener = Readable.prototype.on; + Readable.prototype.removeListener = function (ev, fn) { + var res = Stream.prototype.removeListener.call(this, ev, fn); + if (ev === 'readable') { + // We need to check if there is someone still listening to + // readable and reset the state. However this needs to happen + // after readable has been emitted but before I/O (nextTick) to + // support once('readable', fn) cycles. This means that calling + // resume within the same tick will have no + // effect. + process.nextTick(updateReadableListening, this); + } + return res; + }; + Readable.prototype.removeAllListeners = function (ev) { + var res = Stream.prototype.removeAllListeners.apply(this, arguments); + if (ev === 'readable' || ev === undefined) { + // We need to check if there is someone still listening to + // readable and reset the state. However this needs to happen + // after readable has been emitted but before I/O (nextTick) to + // support once('readable', fn) cycles. This means that calling + // resume within the same tick will have no + // effect. + process.nextTick(updateReadableListening, this); + } + return res; + }; + function updateReadableListening(self) { + var state = self._readableState; + state.readableListening = self.listenerCount('readable') > 0; + if (state.resumeScheduled && !state.paused) { + // flowing needs to be set to true now, otherwise + // the upcoming resume will not flow. + state.flowing = true; + + // crude way to check if we should resume + } else if (self.listenerCount('data') > 0) { + self.resume(); + } + } + function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); + } + + // pause() and resume() are remnants of the legacy readable stream API + // If the user uses them, then switch into old mode. + Readable.prototype.resume = function () { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + // we flow only if there is no one listening + // for readable, but we still have to call + // resume() + state.flowing = !state.readableListening; + resume(this, state); + } + state.paused = false; + return this; + }; + function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + process.nextTick(resume_, stream, state); + } + } + function resume_(stream, state) { + debug('resume', state.reading); + if (!state.reading) { + stream.read(0); + } + state.resumeScheduled = false; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); + } + Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + if (this._readableState.flowing !== false) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + this._readableState.paused = true; + return this; + }; + function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + while (state.flowing && stream.read() !== null); + } + + // wrap an old-style stream as the async data source. + // This is *not* part of the readable stream interface. + // It is an ugly unfortunate mess of history. + Readable.prototype.wrap = function (stream) { + var _this = this; + var state = this._readableState; + var paused = false; + stream.on('end', function () { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) _this.push(chunk); + } + _this.push(null); + }); + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); + + // don't skip over falsy values in objectMode + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + var ret = _this.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function methodWrap(method) { + return function methodWrapReturnFunction() { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } + + // proxy certain important events. + for (var n = 0; n < kProxyEvents.length; n++) { + stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); + } + + // when we try to consume some more bytes, simply unpause the + // underlying stream. + this._read = function (n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + return this; + }; + if (typeof Symbol === 'function') { + Readable.prototype[Symbol.asyncIterator] = function () { + if (createReadableStreamAsyncIterator === undefined) { + createReadableStreamAsyncIterator = requireAsync_iterator(); + } + return createReadableStreamAsyncIterator(this); + }; + } + Object.defineProperty(Readable.prototype, 'readableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.highWaterMark; + } + }); + Object.defineProperty(Readable.prototype, 'readableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState && this._readableState.buffer; + } + }); + Object.defineProperty(Readable.prototype, 'readableFlowing', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.flowing; + }, + set: function set(state) { + if (this._readableState) { + this._readableState.flowing = state; + } + } + }); + + // exposed for testing purposes only. + Readable._fromList = fromList; + Object.defineProperty(Readable.prototype, 'readableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._readableState.length; + } + }); + + // Pluck off n bytes from an array of buffers. + // Length is the combined lengths of all the buffers in the list. + // This function is designed to be inlinable, so please take care when making + // changes to the function body. + function fromList(n, state) { + // nothing buffered + if (state.length === 0) return null; + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.first();else ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + // read part of list + ret = state.buffer.consume(n, state.decoder); + } + return ret; + } + function endReadable(stream) { + var state = stream._readableState; + debug('endReadable', state.endEmitted); + if (!state.endEmitted) { + state.ended = true; + process.nextTick(endReadableNT, state, stream); + } + } + function endReadableNT(state, stream) { + debug('endReadableNT', state.endEmitted, state.length); + + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + if (state.autoDestroy) { + // In case of duplex streams we need a way to detect + // if the writable side is ready for autoDestroy as well + var wState = stream._writableState; + if (!wState || wState.autoDestroy && wState.finished) { + stream.destroy(); + } + } + } + } + if (typeof Symbol === 'function') { + Readable.from = function (iterable, opts) { + if (from === undefined) { + from = requireFrom(); + } + return from(Readable, iterable, opts); + }; + } + function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; + } + return _stream_readable; +} + +var _stream_transform; +var hasRequired_stream_transform; + +function require_stream_transform () { + if (hasRequired_stream_transform) return _stream_transform; + hasRequired_stream_transform = 1; + + _stream_transform = Transform; + var _require$codes = requireErrors().codes, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, + ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING, + ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0; + var Duplex = require_stream_duplex(); + requireInherits()(Transform, Duplex); + function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = false; + var cb = ts.writecb; + if (cb === null) { + return this.emit('error', new ERR_MULTIPLE_CALLBACK()); + } + ts.writechunk = null; + ts.writecb = null; + if (data != null) + // single equals check for both `null` and `undefined` + this.push(data); + cb(er); + var rs = this._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); + } + } + function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); + Duplex.call(this, options); + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null + }; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + if (typeof options.flush === 'function') this._flush = options.flush; + } + + // When the writable side finishes, then flush out anything remaining. + this.on('prefinish', prefinish); + } + function prefinish() { + var _this = this; + if (typeof this._flush === 'function' && !this._readableState.destroyed) { + this._flush(function (er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } + } + Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); + }; + + // This is the part where you do stuff! + // override this function in implementation classes. + // 'chunk' is an input chunk. + // + // Call `push(newChunk)` to pass along transformed output + // to the readable side. You may call 'push' zero or more times. + // + // Call `cb(err)` when you are done with this chunk. If you pass + // an error, then that'll put the hurt on the whole operation. If you + // never call cb(), then you'll never get another chunk. + Transform.prototype._transform = function (chunk, encoding, cb) { + cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()')); + }; + Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + } + }; + + // Doesn't matter what the args are here. + // _transform does all the work. + // That we got here means that the readable side wants more data. + Transform.prototype._read = function (n) { + var ts = this._transformState; + if (ts.writechunk !== null && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } + }; + Transform.prototype._destroy = function (err, cb) { + Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + }); + }; + function done(stream, er, data) { + if (er) return stream.emit('error', er); + if (data != null) + // single equals check for both `null` and `undefined` + stream.push(data); + + // TODO(BridgeAR): Write a test for these two error cases + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0(); + if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING(); + return stream.push(null); + } + return _stream_transform; +} + +var _stream_passthrough; +var hasRequired_stream_passthrough; + +function require_stream_passthrough () { + if (hasRequired_stream_passthrough) return _stream_passthrough; + hasRequired_stream_passthrough = 1; + + _stream_passthrough = PassThrough; + var Transform = require_stream_transform(); + requireInherits()(PassThrough, Transform); + function PassThrough(options) { + if (!(this instanceof PassThrough)) return new PassThrough(options); + Transform.call(this, options); + } + PassThrough.prototype._transform = function (chunk, encoding, cb) { + cb(null, chunk); + }; + return _stream_passthrough; +} + +var pipeline_1; +var hasRequiredPipeline; + +function requirePipeline () { + if (hasRequiredPipeline) return pipeline_1; + hasRequiredPipeline = 1; + + var eos; + function once(callback) { + var called = false; + return function () { + if (called) return; + called = true; + callback.apply(void 0, arguments); + }; + } + var _require$codes = requireErrors().codes, + ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS, + ERR_STREAM_DESTROYED = _require$codes.ERR_STREAM_DESTROYED; + function noop(err) { + // Rethrow the error if it exists to avoid swallowing it + if (err) throw err; + } + function isRequest(stream) { + return stream.setHeader && typeof stream.abort === 'function'; + } + function destroyer(stream, reading, writing, callback) { + callback = once(callback); + var closed = false; + stream.on('close', function () { + closed = true; + }); + if (eos === undefined) eos = requireEndOfStream(); + eos(stream, { + readable: reading, + writable: writing + }, function (err) { + if (err) return callback(err); + closed = true; + callback(); + }); + var destroyed = false; + return function (err) { + if (closed) return; + if (destroyed) return; + destroyed = true; + + // request.destroy just do .end - .abort is what we want + if (isRequest(stream)) return stream.abort(); + if (typeof stream.destroy === 'function') return stream.destroy(); + callback(err || new ERR_STREAM_DESTROYED('pipe')); + }; + } + function call(fn) { + fn(); + } + function pipe(from, to) { + return from.pipe(to); + } + function popCallback(streams) { + if (!streams.length) return noop; + if (typeof streams[streams.length - 1] !== 'function') return noop; + return streams.pop(); + } + function pipeline() { + for (var _len = arguments.length, streams = new Array(_len), _key = 0; _key < _len; _key++) { + streams[_key] = arguments[_key]; + } + var callback = popCallback(streams); + if (Array.isArray(streams[0])) streams = streams[0]; + if (streams.length < 2) { + throw new ERR_MISSING_ARGS('streams'); + } + var error; + var destroys = streams.map(function (stream, i) { + var reading = i < streams.length - 1; + var writing = i > 0; + return destroyer(stream, reading, writing, function (err) { + if (!error) error = err; + if (err) destroys.forEach(call); + if (reading) return; + destroys.forEach(call); + callback(error); + }); + }); + return streams.reduce(pipe); + } + pipeline_1 = pipeline; + return pipeline_1; +} + +var hasRequiredReadable; + +function requireReadable () { + if (hasRequiredReadable) return readable.exports; + hasRequiredReadable = 1; + (function (module, exports) { + var Stream$1 = Stream; + if (process.env.READABLE_STREAM === 'disable' && Stream$1) { + module.exports = Stream$1.Readable; + Object.assign(module.exports, Stream$1); + module.exports.Stream = Stream$1; + } else { + exports = module.exports = require_stream_readable(); + exports.Stream = Stream$1 || exports; + exports.Readable = exports; + exports.Writable = require_stream_writable(); + exports.Duplex = require_stream_duplex(); + exports.Transform = require_stream_transform(); + exports.PassThrough = require_stream_passthrough(); + exports.finished = requireEndOfStream(); + exports.pipeline = requirePipeline(); + } + } (readable, readable.exports)); + return readable.exports; +} + +var blake$1; +var hasRequiredBlake$1; + +function requireBlake$1 () { + if (hasRequiredBlake$1) return blake$1; + hasRequiredBlake$1 = 1; + const Transform = requireReadable().Transform; + + blake$1 = class Blake extends Transform { + constructor (engine, options) { + super(options); + + this._engine = engine; + this._finalized = false; + } + + _transform (chunk, encoding, callback) { + let error = null; + try { + this.update(chunk, encoding); + } catch (err) { + error = err; + } + + callback(error); + } + + _flush (callback) { + let error = null; + try { + this.push(this.digest()); + } catch (err) { + error = err; + } + + callback(error); + } + + update (data, encoding) { + if (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer') + if (this._finalized) throw new Error('Digest already called') + if (!Buffer.isBuffer(data)) data = Buffer.from(data, encoding); + + this._engine.update(data); + + return this + } + + digest (encoding) { + if (this._finalized) throw new Error('Digest already called') + this._finalized = true; + + let digest = this._engine.digest(); + if (encoding !== undefined) digest = digest.toString(encoding); + + return digest + } + }; + return blake$1; +} + +var api; +var hasRequiredApi; + +function requireApi () { + if (hasRequiredApi) return api; + hasRequiredApi = 1; + const Blake = requireBlake$1(); + + api = (engines) => { + const getEngine = (algorithm) => { + const hash = typeof algorithm === 'string' ? algorithm.toLowerCase() : algorithm; + switch (hash) { + case 'blake224': return engines.Blake224 + case 'blake256': return engines.Blake256 + case 'blake384': return engines.Blake384 + case 'blake512': return engines.Blake512 + + default: throw new Error('Invald algorithm: ' + algorithm) + } + }; + + return (algorithm, options) => { + const Engine = getEngine(algorithm); + return new Blake(new Engine(), options) + } + }; + return api; +} + +var nodeGypBuild$1 = {exports: {}}; + +var nodeGypBuild; +var hasRequiredNodeGypBuild$1; + +function requireNodeGypBuild$1 () { + if (hasRequiredNodeGypBuild$1) return nodeGypBuild; + hasRequiredNodeGypBuild$1 = 1; + var fs = require$$0$1; + var path = path$3; + var os = require$$0$2; + + // Workaround to fix webpack's build warnings: 'the request of a dependency is an expression' + var runtimeRequire = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : commonjsRequire; // eslint-disable-line + + var vars = (process.config && process.config.variables) || {}; + var prebuildsOnly = !!process.env.PREBUILDS_ONLY; + var abi = process.versions.modules; // TODO: support old node where this is undef + var runtime = isElectron() ? 'electron' : (isNwjs() ? 'node-webkit' : 'node'); + + var arch = process.env.npm_config_arch || os.arch(); + var platform = process.env.npm_config_platform || os.platform(); + var libc = process.env.LIBC || (isAlpine(platform) ? 'musl' : 'glibc'); + var armv = process.env.ARM_VERSION || (arch === 'arm64' ? '8' : vars.arm_version) || ''; + var uv = (process.versions.uv || '').split('.')[0]; + + nodeGypBuild = load; + + function load (dir) { + return runtimeRequire(load.resolve(dir)) + } + + load.resolve = load.path = function (dir) { + dir = path.resolve(dir || '.'); + + try { + var name = runtimeRequire(path.join(dir, 'package.json')).name.toUpperCase().replace(/-/g, '_'); + if (process.env[name + '_PREBUILD']) dir = process.env[name + '_PREBUILD']; + } catch (err) {} + + if (!prebuildsOnly) { + var release = getFirst(path.join(dir, 'build/Release'), matchBuild); + if (release) return release + + var debug = getFirst(path.join(dir, 'build/Debug'), matchBuild); + if (debug) return debug + } + + var prebuild = resolve(dir); + if (prebuild) return prebuild + + var nearby = resolve(path.dirname(process.execPath)); + if (nearby) return nearby + + var target = [ + 'platform=' + platform, + 'arch=' + arch, + 'runtime=' + runtime, + 'abi=' + abi, + 'uv=' + uv, + armv ? 'armv=' + armv : '', + 'libc=' + libc, + 'node=' + process.versions.node, + process.versions.electron ? 'electron=' + process.versions.electron : '', + typeof __webpack_require__ === 'function' ? 'webpack=true' : '' // eslint-disable-line + ].filter(Boolean).join(' '); + + throw new Error('No native build was found for ' + target + '\n loaded from: ' + dir + '\n') + + function resolve (dir) { + // Find matching "prebuilds/-" directory + var tuples = readdirSync(path.join(dir, 'prebuilds')).map(parseTuple); + var tuple = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0]; + if (!tuple) return + + // Find most specific flavor first + var prebuilds = path.join(dir, 'prebuilds', tuple.name); + var parsed = readdirSync(prebuilds).map(parseTags); + var candidates = parsed.filter(matchTags(runtime, abi)); + var winner = candidates.sort(compareTags(runtime))[0]; + if (winner) return path.join(prebuilds, winner.file) + } + }; + + function readdirSync (dir) { + try { + return fs.readdirSync(dir) + } catch (err) { + return [] + } + } + + function getFirst (dir, filter) { + var files = readdirSync(dir).filter(filter); + return files[0] && path.join(dir, files[0]) + } + + function matchBuild (name) { + return /\.node$/.test(name) + } + + function parseTuple (name) { + // Example: darwin-x64+arm64 + var arr = name.split('-'); + if (arr.length !== 2) return + + var platform = arr[0]; + var architectures = arr[1].split('+'); + + if (!platform) return + if (!architectures.length) return + if (!architectures.every(Boolean)) return + + return { name, platform, architectures } + } + + function matchTuple (platform, arch) { + return function (tuple) { + if (tuple == null) return false + if (tuple.platform !== platform) return false + return tuple.architectures.includes(arch) + } + } + + function compareTuples (a, b) { + // Prefer single-arch prebuilds over multi-arch + return a.architectures.length - b.architectures.length + } + + function parseTags (file) { + var arr = file.split('.'); + var extension = arr.pop(); + var tags = { file: file, specificity: 0 }; + + if (extension !== 'node') return + + for (var i = 0; i < arr.length; i++) { + var tag = arr[i]; + + if (tag === 'node' || tag === 'electron' || tag === 'node-webkit') { + tags.runtime = tag; + } else if (tag === 'napi') { + tags.napi = true; + } else if (tag.slice(0, 3) === 'abi') { + tags.abi = tag.slice(3); + } else if (tag.slice(0, 2) === 'uv') { + tags.uv = tag.slice(2); + } else if (tag.slice(0, 4) === 'armv') { + tags.armv = tag.slice(4); + } else if (tag === 'glibc' || tag === 'musl') { + tags.libc = tag; + } else { + continue + } + + tags.specificity++; + } + + return tags + } + + function matchTags (runtime, abi) { + return function (tags) { + if (tags == null) return false + if (tags.runtime && tags.runtime !== runtime && !runtimeAgnostic(tags)) return false + if (tags.abi && tags.abi !== abi && !tags.napi) return false + if (tags.uv && tags.uv !== uv) return false + if (tags.armv && tags.armv !== armv) return false + if (tags.libc && tags.libc !== libc) return false + + return true + } + } + + function runtimeAgnostic (tags) { + return tags.runtime === 'node' && tags.napi + } + + function compareTags (runtime) { + // Precedence: non-agnostic runtime, abi over napi, then by specificity. + return function (a, b) { + if (a.runtime !== b.runtime) { + return a.runtime === runtime ? -1 : 1 + } else if (a.abi !== b.abi) { + return a.abi ? -1 : 1 + } else if (a.specificity !== b.specificity) { + return a.specificity > b.specificity ? -1 : 1 + } else { + return 0 + } + } + } + + function isNwjs () { + return !!(process.versions && process.versions.nw) + } + + function isElectron () { + if (process.versions && process.versions.electron) return true + if (process.env.ELECTRON_RUN_AS_NODE) return true + return typeof window !== 'undefined' && window.process && window.process.type === 'renderer' + } + + function isAlpine (platform) { + return platform === 'linux' && fs.existsSync('/etc/alpine-release') + } + + // Exposed for unit tests + // TODO: move to lib + load.parseTags = parseTags; + load.matchTags = matchTags; + load.compareTags = compareTags; + load.parseTuple = parseTuple; + load.matchTuple = matchTuple; + load.compareTuples = compareTuples; + return nodeGypBuild; +} + +var hasRequiredNodeGypBuild; + +function requireNodeGypBuild () { + if (hasRequiredNodeGypBuild) return nodeGypBuild$1.exports; + hasRequiredNodeGypBuild = 1; + const runtimeRequire = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : commonjsRequire; // eslint-disable-line + if (typeof runtimeRequire.addon === 'function') { // if the platform supports native resolving prefer that + nodeGypBuild$1.exports = runtimeRequire.addon.bind(runtimeRequire); + } else { // else use the runtime version here + nodeGypBuild$1.exports = requireNodeGypBuild$1(); + } + return nodeGypBuild$1.exports; +} + +var bindings; +var hasRequiredBindings; + +function requireBindings () { + if (hasRequiredBindings) return bindings; + hasRequiredBindings = 1; + bindings = requireApi()(requireNodeGypBuild()(__dirname)); + return bindings; +} + +var blake; +var hasRequiredBlake; + +function requireBlake () { + if (hasRequiredBlake) return blake; + hasRequiredBlake = 1; + class Blake { + _lengthCarry (arr) { + for (let j = 0; j < arr.length; ++j) { + if (arr[j] < 0x0100000000) break + arr[j] -= 0x0100000000; + arr[j + 1] += 1; + } + } + + update (data) { + const block = this._block; + let offset = 0; + + while (this._blockOffset + data.length - offset >= block.length) { + for (let i = this._blockOffset; i < block.length;) block[i++] = data[offset++]; + + this._length[0] += block.length * 8; + this._lengthCarry(this._length); + + this._compress(); + this._blockOffset = 0; + } + + while (offset < data.length) block[this._blockOffset++] = data[offset++]; + } + } + + Blake.sigma = [ + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9], + [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11], + [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10], + [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5], + [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9] + ]; + + Blake.u256 = [ + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, + 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, + 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, + 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917 + ]; + + Blake.u512 = [ + 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, + 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, + 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, + 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, + 0x9216d5d9, 0x8979fb1b, 0xd1310ba6, 0x98dfb5ac, + 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, + 0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, + 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69 + ]; + + Blake.padding = Buffer.from([ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ]); + + blake = Blake; + return blake; +} + +var blake256; +var hasRequiredBlake256; + +function requireBlake256 () { + if (hasRequiredBlake256) return blake256; + hasRequiredBlake256 = 1; + const Blake = requireBlake(); + + const zo = Buffer.from([0x01]); + const oo = Buffer.from([0x81]); + + const rot = (x, n) => ((x << (32 - n)) | (x >>> n)) >>> 0; + + function g (v, m, i, a, b, c, d, e) { + const sigma = Blake.sigma; + const u256 = Blake.u256; + + v[a] = (v[a] + ((m[sigma[i][e]] ^ u256[sigma[i][e + 1]]) >>> 0) + v[b]) >>> 0; + v[d] = rot(v[d] ^ v[a], 16); + v[c] = (v[c] + v[d]) >>> 0; + v[b] = rot(v[b] ^ v[c], 12); + v[a] = (v[a] + ((m[sigma[i][e + 1]] ^ u256[sigma[i][e]]) >>> 0) + v[b]) >>> 0; + v[d] = rot(v[d] ^ v[a], 8); + v[c] = (v[c] + v[d]) >>> 0; + v[b] = rot(v[b] ^ v[c], 7); + } + + blake256 = class Blake256 extends Blake { + constructor () { + super(); + + this._h = [ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 + ]; + + this._s = [0, 0, 0, 0]; + + this._block = Buffer.alloc(64); + this._blockOffset = 0; + this._length = [0, 0]; + + this._nullt = false; + + this._zo = zo; + this._oo = oo; + } + + _compress () { + const u256 = Blake.u256; + const v = new Array(16); + const m = new Array(16); + let i; + + for (i = 0; i < 16; ++i) m[i] = this._block.readUInt32BE(i * 4); + for (i = 0; i < 8; ++i) v[i] = this._h[i] >>> 0; + for (i = 8; i < 12; ++i) v[i] = (this._s[i - 8] ^ u256[i - 8]) >>> 0; + for (i = 12; i < 16; ++i) v[i] = u256[i - 8]; + + if (!this._nullt) { + v[12] = (v[12] ^ this._length[0]) >>> 0; + v[13] = (v[13] ^ this._length[0]) >>> 0; + v[14] = (v[14] ^ this._length[1]) >>> 0; + v[15] = (v[15] ^ this._length[1]) >>> 0; + } + + for (i = 0; i < 14; ++i) { + /* column step */ + g(v, m, i, 0, 4, 8, 12, 0); + g(v, m, i, 1, 5, 9, 13, 2); + g(v, m, i, 2, 6, 10, 14, 4); + g(v, m, i, 3, 7, 11, 15, 6); + /* diagonal step */ + g(v, m, i, 0, 5, 10, 15, 8); + g(v, m, i, 1, 6, 11, 12, 10); + g(v, m, i, 2, 7, 8, 13, 12); + g(v, m, i, 3, 4, 9, 14, 14); + } + + for (i = 0; i < 16; ++i) this._h[i % 8] = (this._h[i % 8] ^ v[i]) >>> 0; + for (i = 0; i < 8; ++i) this._h[i] = (this._h[i] ^ this._s[i % 4]) >>> 0; + } + + _padding () { + let lo = this._length[0] + this._blockOffset * 8; + let hi = this._length[1]; + if (lo >= 0x0100000000) { + lo -= 0x0100000000; + hi += 1; + } + + const msglen = Buffer.alloc(8); + msglen.writeUInt32BE(hi, 0); + msglen.writeUInt32BE(lo, 4); + + if (this._blockOffset === 55) { + this._length[0] -= 8; + this.update(this._oo); + } else { + if (this._blockOffset < 55) { + if (this._blockOffset === 0) this._nullt = true; + this._length[0] -= (55 - this._blockOffset) * 8; + this.update(Blake.padding.slice(0, 55 - this._blockOffset)); + } else { + this._length[0] -= (64 - this._blockOffset) * 8; + this.update(Blake.padding.slice(0, 64 - this._blockOffset)); + this._length[0] -= 55 * 8; + this.update(Blake.padding.slice(1, 1 + 55)); + this._nullt = true; + } + + this.update(this._zo); + this._length[0] -= 8; + } + + this._length[0] -= 64; + this.update(msglen); + } + + digest () { + this._padding(); + + const buffer = Buffer.alloc(32); + for (let i = 0; i < 8; ++i) buffer.writeUInt32BE(this._h[i], i * 4); + return buffer + } + }; + return blake256; +} + +var blake224; +var hasRequiredBlake224; + +function requireBlake224 () { + if (hasRequiredBlake224) return blake224; + hasRequiredBlake224 = 1; + const Blake256 = requireBlake256(); + + const zo = Buffer.from([0x00]); + const oo = Buffer.from([0x80]); + + blake224 = class Blake224 extends Blake256 { + constructor () { + super(); + + this._h = [ + 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, + 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 + ]; + + this._zo = zo; + this._oo = oo; + } + + digest () { + this._padding(); + + const buffer = Buffer.alloc(28); + for (let i = 0; i < 7; ++i) buffer.writeUInt32BE(this._h[i], i * 4); + return buffer + } + }; + return blake224; +} + +var blake512; +var hasRequiredBlake512; + +function requireBlake512 () { + if (hasRequiredBlake512) return blake512; + hasRequiredBlake512 = 1; + const Blake = requireBlake(); + + const zo = Buffer.from([0x01]); + const oo = Buffer.from([0x81]); + + function rot (v, i, j, n) { + let hi = v[i * 2] ^ v[j * 2]; + let lo = v[i * 2 + 1] ^ v[j * 2 + 1]; + + if (n >= 32) { + lo = lo ^ hi; + hi = lo ^ hi; + lo = lo ^ hi; + n -= 32; + } + + if (n === 0) { + v[i * 2] = hi >>> 0; + v[i * 2 + 1] = lo >>> 0; + } else { + v[i * 2] = ((hi >>> n) | (lo << (32 - n))) >>> 0; + v[i * 2 + 1] = ((lo >>> n) | (hi << (32 - n))) >>> 0; + } + } + + function g (v, m, i, a, b, c, d, e) { + const sigma = Blake.sigma; + const u512 = Blake.u512; + let lo; + + // v[a] += (m[sigma[i][e]] ^ u512[sigma[i][e+1]]) + v[b]; + lo = v[a * 2 + 1] + ((m[sigma[i][e] * 2 + 1] ^ u512[sigma[i][e + 1] * 2 + 1]) >>> 0) + v[b * 2 + 1]; + v[a * 2] = (v[a * 2] + ((m[sigma[i][e] * 2] ^ u512[sigma[i][e + 1] * 2]) >>> 0) + v[b * 2] + ~~(lo / 0x0100000000)) >>> 0; + v[a * 2 + 1] = lo >>> 0; + + // v[d] = ROT( v[d] ^ v[a],32); + rot(v, d, a, 32); + + // v[c] += v[d]; + lo = v[c * 2 + 1] + v[d * 2 + 1]; + v[c * 2] = (v[c * 2] + v[d * 2] + ~~(lo / 0x0100000000)) >>> 0; + v[c * 2 + 1] = lo >>> 0; + + // v[b] = ROT( v[b] ^ v[c],25); + rot(v, b, c, 25); + + // v[a] += (m[sigma[i][e+1]] ^ u512[sigma[i][e]])+v[b]; + lo = v[a * 2 + 1] + ((m[sigma[i][e + 1] * 2 + 1] ^ u512[sigma[i][e] * 2 + 1]) >>> 0) + v[b * 2 + 1]; + v[a * 2] = (v[a * 2] + ((m[sigma[i][e + 1] * 2] ^ u512[sigma[i][e] * 2]) >>> 0) + v[b * 2] + ~~(lo / 0x0100000000)) >>> 0; + v[a * 2 + 1] = lo >>> 0; + + // v[d] = ROT( v[d] ^ v[a],16); + rot(v, d, a, 16); + + // v[c] += v[d]; + lo = v[c * 2 + 1] + v[d * 2 + 1]; + v[c * 2] = (v[c * 2] + v[d * 2] + ~~(lo / 0x0100000000)) >>> 0; + v[c * 2 + 1] = lo >>> 0; + + // v[b] = ROT( v[b] ^ v[c],11) + rot(v, b, c, 11); + } + + blake512 = class Blake512 extends Blake { + constructor () { + super(); + + this._h = [ + 0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, + 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1, + 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, + 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179 + ]; + + this._s = [0, 0, 0, 0, 0, 0, 0, 0]; + + this._block = Buffer.alloc(128); + this._blockOffset = 0; + this._length = [0, 0, 0, 0]; + + this._nullt = false; + + this._zo = zo; + this._oo = oo; + } + + _compress () { + const u512 = Blake.u512; + const v = new Array(32); + const m = new Array(32); + let i; + + for (i = 0; i < 32; ++i) m[i] = this._block.readUInt32BE(i * 4); + for (i = 0; i < 16; ++i) v[i] = this._h[i] >>> 0; + for (i = 16; i < 24; ++i) v[i] = (this._s[i - 16] ^ u512[i - 16]) >>> 0; + for (i = 24; i < 32; ++i) v[i] = u512[i - 16]; + + if (!this._nullt) { + v[24] = (v[24] ^ this._length[1]) >>> 0; + v[25] = (v[25] ^ this._length[0]) >>> 0; + v[26] = (v[26] ^ this._length[1]) >>> 0; + v[27] = (v[27] ^ this._length[0]) >>> 0; + v[28] = (v[28] ^ this._length[3]) >>> 0; + v[29] = (v[29] ^ this._length[2]) >>> 0; + v[30] = (v[30] ^ this._length[3]) >>> 0; + v[31] = (v[31] ^ this._length[2]) >>> 0; + } + + for (i = 0; i < 16; ++i) { + /* column step */ + g(v, m, i, 0, 4, 8, 12, 0); + g(v, m, i, 1, 5, 9, 13, 2); + g(v, m, i, 2, 6, 10, 14, 4); + g(v, m, i, 3, 7, 11, 15, 6); + /* diagonal step */ + g(v, m, i, 0, 5, 10, 15, 8); + g(v, m, i, 1, 6, 11, 12, 10); + g(v, m, i, 2, 7, 8, 13, 12); + g(v, m, i, 3, 4, 9, 14, 14); + } + + for (i = 0; i < 16; ++i) { + this._h[(i % 8) * 2] = (this._h[(i % 8) * 2] ^ v[i * 2]) >>> 0; + this._h[(i % 8) * 2 + 1] = (this._h[(i % 8) * 2 + 1] ^ v[i * 2 + 1]) >>> 0; + } + + for (i = 0; i < 8; ++i) { + this._h[i * 2] = (this._h[i * 2] ^ this._s[(i % 4) * 2]) >>> 0; + this._h[i * 2 + 1] = (this._h[i * 2 + 1] ^ this._s[(i % 4) * 2 + 1]) >>> 0; + } + } + + _padding () { + const len = this._length.slice(); + len[0] += this._blockOffset * 8; + this._lengthCarry(len); + + const msglen = Buffer.alloc(16); + for (let i = 0; i < 4; ++i) msglen.writeUInt32BE(len[3 - i], i * 4); + + if (this._blockOffset === 111) { + this._length[0] -= 8; + this.update(this._oo); + } else { + if (this._blockOffset < 111) { + if (this._blockOffset === 0) this._nullt = true; + this._length[0] -= (111 - this._blockOffset) * 8; + this.update(Blake.padding.slice(0, 111 - this._blockOffset)); + } else { + this._length[0] -= (128 - this._blockOffset) * 8; + this.update(Blake.padding.slice(0, 128 - this._blockOffset)); + this._length[0] -= 111 * 8; + this.update(Blake.padding.slice(1, 1 + 111)); + this._nullt = true; + } + + this.update(this._zo); + this._length[0] -= 8; + } + + this._length[0] -= 128; + this.update(msglen); + } + + digest () { + this._padding(); + + const buffer = Buffer.alloc(64); + for (let i = 0; i < 16; ++i) buffer.writeUInt32BE(this._h[i], i * 4); + return buffer + } + }; + return blake512; +} + +var blake384; +var hasRequiredBlake384; + +function requireBlake384 () { + if (hasRequiredBlake384) return blake384; + hasRequiredBlake384 = 1; + const Blake512 = requireBlake512(); + + const zo = Buffer.from([0x00]); + const oo = Buffer.from([0x80]); + + blake384 = class Blake384 extends Blake512 { + constructor () { + super(); + + this._h = [ + 0xcbbb9d5d, 0xc1059ed8, 0x629a292a, 0x367cd507, + 0x9159015a, 0x3070dd17, 0x152fecd8, 0xf70e5939, + 0x67332667, 0xffc00b31, 0x8eb44a87, 0x68581511, + 0xdb0c2e0d, 0x64f98fa7, 0x47b5481d, 0xbefa4fa4 + ]; + + this._zo = zo; + this._oo = oo; + } + + digest () { + this._padding(); + + const buffer = Buffer.alloc(48); + for (let i = 0; i < 12; ++i) buffer.writeUInt32BE(this._h[i], i * 4); + return buffer + } + }; + return blake384; +} + +var lib$1; +var hasRequiredLib; + +function requireLib () { + if (hasRequiredLib) return lib$1; + hasRequiredLib = 1; + lib$1 = { + Blake224: requireBlake224(), + Blake256: requireBlake256(), + Blake384: requireBlake384(), + Blake512: requireBlake512() + }; + return lib$1; +} + +var js; +var hasRequiredJs; + +function requireJs () { + if (hasRequiredJs) return js; + hasRequiredJs = 1; + js = requireApi()(requireLib()); + return js; +} + +try { + blakeHash.exports = requireBindings(); +} catch (err) { + blakeHash.exports = requireJs(); +} + +var blakeHashExports = blakeHash.exports; +var createBlakeHash = /*@__PURE__*/getDefaultExportFromCjs(blakeHashExports); + +const GENPOINT_PREFIX = "PedersenGenerator"; +const windowSize = 4; +const nWindowsPerSegment = 50; + +async function buildPedersenHash() { + const babyJub = await buildBabyJub(); + return new PedersenHash(babyJub); +} + +class PedersenHash { + + constructor(babyJub) { + this.babyJub = babyJub; + this.bases = []; + } + + baseHash(type, S) { + if (type == "blake") { + return createBlakeHash("blake256").update(S).digest(); + } else if (type == "blake2b") { + return Buffer.from(blake2b(32).update(Buffer.from(S)).digest()); + } + } + + hash(msg, options) { + options = options || {}; + options.baseHash = options.baseHash || "blake"; + const babyJub = this.babyJub; + const bitsPerSegment = windowSize*nWindowsPerSegment; + const bits = this.buffer2bits(msg); + + const nSegments = Math.floor((bits.length - 1)/(windowSize*nWindowsPerSegment)) +1; + + let accP = [babyJub.F.zero,babyJub.F.one]; + + for (let s=0; s> 1; + res[i*8+2] = (b & 0x04) >> 2; + res[i*8+3] = (b & 0x08) >> 3; + res[i*8+4] = (b & 0x10) >> 4; + res[i*8+5] = (b & 0x20) >> 5; + res[i*8+6] = (b & 0x40) >> 6; + res[i*8+7] = (b & 0x80) >> 7; + } + return res; + } +} + +const version$2 = "logger/5.7.0"; + +let _permanentCensorErrors = false; +let _censorErrors = false; +const LogLevels = { debug: 1, "default": 2, info: 2, warning: 3, error: 4, off: 5 }; +let _logLevel = LogLevels["default"]; +let _globalLogger = null; +function _checkNormalize() { + try { + const missing = []; + // Make sure all forms of normalization are supported + ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => { + try { + if ("test".normalize(form) !== "test") { + throw new Error("bad normalize"); + } + ; + } + catch (error) { + missing.push(form); + } + }); + if (missing.length) { + throw new Error("missing " + missing.join(", ")); + } + if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) { + throw new Error("broken implementation"); + } + } + catch (error) { + return error.message; + } + return null; +} +const _normalizeError = _checkNormalize(); +var LogLevel; +(function (LogLevel) { + LogLevel["DEBUG"] = "DEBUG"; + LogLevel["INFO"] = "INFO"; + LogLevel["WARNING"] = "WARNING"; + LogLevel["ERROR"] = "ERROR"; + LogLevel["OFF"] = "OFF"; +})(LogLevel || (LogLevel = {})); +var ErrorCode; +(function (ErrorCode) { + /////////////////// + // Generic Errors + // Unknown Error + ErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR"; + // Not Implemented + ErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED"; + // Unsupported Operation + // - operation + ErrorCode["UNSUPPORTED_OPERATION"] = "UNSUPPORTED_OPERATION"; + // Network Error (i.e. Ethereum Network, such as an invalid chain ID) + // - event ("noNetwork" is not re-thrown in provider.ready; otherwise thrown) + ErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR"; + // Some sort of bad response from the server + ErrorCode["SERVER_ERROR"] = "SERVER_ERROR"; + // Timeout + ErrorCode["TIMEOUT"] = "TIMEOUT"; + /////////////////// + // Operational Errors + // Buffer Overrun + ErrorCode["BUFFER_OVERRUN"] = "BUFFER_OVERRUN"; + // Numeric Fault + // - operation: the operation being executed + // - fault: the reason this faulted + ErrorCode["NUMERIC_FAULT"] = "NUMERIC_FAULT"; + /////////////////// + // Argument Errors + // Missing new operator to an object + // - name: The name of the class + ErrorCode["MISSING_NEW"] = "MISSING_NEW"; + // Invalid argument (e.g. value is incompatible with type) to a function: + // - argument: The argument name that was invalid + // - value: The value of the argument + ErrorCode["INVALID_ARGUMENT"] = "INVALID_ARGUMENT"; + // Missing argument to a function: + // - count: The number of arguments received + // - expectedCount: The number of arguments expected + ErrorCode["MISSING_ARGUMENT"] = "MISSING_ARGUMENT"; + // Too many arguments + // - count: The number of arguments received + // - expectedCount: The number of arguments expected + ErrorCode["UNEXPECTED_ARGUMENT"] = "UNEXPECTED_ARGUMENT"; + /////////////////// + // Blockchain Errors + // Call exception + // - transaction: the transaction + // - address?: the contract address + // - args?: The arguments passed into the function + // - method?: The Solidity method signature + // - errorSignature?: The EIP848 error signature + // - errorArgs?: The EIP848 error parameters + // - reason: The reason (only for EIP848 "Error(string)") + ErrorCode["CALL_EXCEPTION"] = "CALL_EXCEPTION"; + // Insufficient funds (< value + gasLimit * gasPrice) + // - transaction: the transaction attempted + ErrorCode["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS"; + // Nonce has already been used + // - transaction: the transaction attempted + ErrorCode["NONCE_EXPIRED"] = "NONCE_EXPIRED"; + // The replacement fee for the transaction is too low + // - transaction: the transaction attempted + ErrorCode["REPLACEMENT_UNDERPRICED"] = "REPLACEMENT_UNDERPRICED"; + // The gas limit could not be estimated + // - transaction: the transaction passed to estimateGas + ErrorCode["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT"; + // The transaction was replaced by one with a higher gas price + // - reason: "cancelled", "replaced" or "repriced" + // - cancelled: true if reason == "cancelled" or reason == "replaced") + // - hash: original transaction hash + // - replacement: the full TransactionsResponse for the replacement + // - receipt: the receipt of the replacement + ErrorCode["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED"; + /////////////////// + // Interaction Errors + // The user rejected the action, such as signing a message or sending + // a transaction + ErrorCode["ACTION_REJECTED"] = "ACTION_REJECTED"; +})(ErrorCode || (ErrorCode = {})); +const HEX = "0123456789abcdef"; +class Logger { + constructor(version) { + Object.defineProperty(this, "version", { + enumerable: true, + value: version, + writable: false + }); + } + _log(logLevel, args) { + const level = logLevel.toLowerCase(); + if (LogLevels[level] == null) { + this.throwArgumentError("invalid log level name", "logLevel", logLevel); + } + if (_logLevel > LogLevels[level]) { + return; + } + console.log.apply(console, args); + } + debug(...args) { + this._log(Logger.levels.DEBUG, args); + } + info(...args) { + this._log(Logger.levels.INFO, args); + } + warn(...args) { + this._log(Logger.levels.WARNING, args); + } + makeError(message, code, params) { + // Errors are being censored + if (_censorErrors) { + return this.makeError("censored error", code, {}); + } + if (!code) { + code = Logger.errors.UNKNOWN_ERROR; + } + if (!params) { + params = {}; + } + const messageDetails = []; + Object.keys(params).forEach((key) => { + const value = params[key]; + try { + if (value instanceof Uint8Array) { + let hex = ""; + for (let i = 0; i < value.length; i++) { + hex += HEX[value[i] >> 4]; + hex += HEX[value[i] & 0x0f]; + } + messageDetails.push(key + "=Uint8Array(0x" + hex + ")"); + } + else { + messageDetails.push(key + "=" + JSON.stringify(value)); + } + } + catch (error) { + messageDetails.push(key + "=" + JSON.stringify(params[key].toString())); + } + }); + messageDetails.push(`code=${code}`); + messageDetails.push(`version=${this.version}`); + const reason = message; + let url = ""; + switch (code) { + case ErrorCode.NUMERIC_FAULT: { + url = "NUMERIC_FAULT"; + const fault = message; + switch (fault) { + case "overflow": + case "underflow": + case "division-by-zero": + url += "-" + fault; + break; + case "negative-power": + case "negative-width": + url += "-unsupported"; + break; + case "unbound-bitwise-result": + url += "-unbound-result"; + break; + } + break; + } + case ErrorCode.CALL_EXCEPTION: + case ErrorCode.INSUFFICIENT_FUNDS: + case ErrorCode.MISSING_NEW: + case ErrorCode.NONCE_EXPIRED: + case ErrorCode.REPLACEMENT_UNDERPRICED: + case ErrorCode.TRANSACTION_REPLACED: + case ErrorCode.UNPREDICTABLE_GAS_LIMIT: + url = code; + break; + } + if (url) { + message += " [ See: https:/\/links.ethers.org/v5-errors-" + url + " ]"; + } + if (messageDetails.length) { + message += " (" + messageDetails.join(", ") + ")"; + } + // @TODO: Any?? + const error = new Error(message); + error.reason = reason; + error.code = code; + Object.keys(params).forEach(function (key) { + error[key] = params[key]; + }); + return error; + } + throwError(message, code, params) { + throw this.makeError(message, code, params); + } + throwArgumentError(message, name, value) { + return this.throwError(message, Logger.errors.INVALID_ARGUMENT, { + argument: name, + value: value + }); + } + assert(condition, message, code, params) { + if (!!condition) { + return; + } + this.throwError(message, code, params); + } + assertArgument(condition, message, name, value) { + if (!!condition) { + return; + } + this.throwArgumentError(message, name, value); + } + checkNormalize(message) { + if (_normalizeError) { + this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "String.prototype.normalize", form: _normalizeError + }); + } + } + checkSafeUint53(value, message) { + if (typeof (value) !== "number") { + return; + } + if (message == null) { + message = "value not safe"; + } + if (value < 0 || value >= 0x1fffffffffffff) { + this.throwError(message, Logger.errors.NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "out-of-safe-range", + value: value + }); + } + if (value % 1) { + this.throwError(message, Logger.errors.NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "non-integer", + value: value + }); + } + } + checkArgumentCount(count, expectedCount, message) { + if (message) { + message = ": " + message; + } + else { + message = ""; + } + if (count < expectedCount) { + this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, { + count: count, + expectedCount: expectedCount + }); + } + if (count > expectedCount) { + this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, { + count: count, + expectedCount: expectedCount + }); + } + } + checkNew(target, kind) { + if (target === Object || target == null) { + this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name }); + } + } + checkAbstract(target, kind) { + if (target === kind) { + this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" }); + } + else if (target === Object || target == null) { + this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name }); + } + } + static globalLogger() { + if (!_globalLogger) { + _globalLogger = new Logger(version$2); + } + return _globalLogger; + } + static setCensorship(censorship, permanent) { + if (!censorship && permanent) { + this.globalLogger().throwError("cannot permanently disable censorship", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "setCensorship" + }); + } + if (_permanentCensorErrors) { + if (!censorship) { + return; + } + this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "setCensorship" + }); + } + _censorErrors = !!censorship; + _permanentCensorErrors = !!permanent; + } + static setLogLevel(logLevel) { + const level = LogLevels[logLevel.toLowerCase()]; + if (level == null) { + Logger.globalLogger().warn("invalid log level - " + logLevel); + return; + } + _logLevel = level; + } + static from(version) { + return new Logger(version); + } +} +Logger.errors = ErrorCode; +Logger.levels = LogLevel; + +const version$1 = "bytes/5.7.0"; + +const logger$1 = new Logger(version$1); +/////////////////////////////// +function isHexable(value) { + return !!(value.toHexString); +} +function addSlice(array) { + if (array.slice) { + return array; + } + array.slice = function () { + const args = Array.prototype.slice.call(arguments); + return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args))); + }; + return array; +} +function isInteger(value) { + return (typeof (value) === "number" && value == value && (value % 1) === 0); +} +function isBytes(value) { + if (value == null) { + return false; + } + if (value.constructor === Uint8Array) { + return true; + } + if (typeof (value) === "string") { + return false; + } + if (!isInteger(value.length) || value.length < 0) { + return false; + } + for (let i = 0; i < value.length; i++) { + const v = value[i]; + if (!isInteger(v) || v < 0 || v >= 256) { + return false; + } + } + return true; +} +function arrayify(value, options) { + if (!options) { + options = {}; + } + if (typeof (value) === "number") { + logger$1.checkSafeUint53(value, "invalid arrayify value"); + const result = []; + while (value) { + result.unshift(value & 0xff); + value = parseInt(String(value / 256)); + } + if (result.length === 0) { + result.push(0); + } + return addSlice(new Uint8Array(result)); + } + if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + if (isHexable(value)) { + value = value.toHexString(); + } + if (isHexString(value)) { + let hex = value.substring(2); + if (hex.length % 2) { + if (options.hexPad === "left") { + hex = "0" + hex; + } + else if (options.hexPad === "right") { + hex += "0"; + } + else { + logger$1.throwArgumentError("hex data is odd-length", "value", value); + } + } + const result = []; + for (let i = 0; i < hex.length; i += 2) { + result.push(parseInt(hex.substring(i, i + 2), 16)); + } + return addSlice(new Uint8Array(result)); + } + if (isBytes(value)) { + return addSlice(new Uint8Array(value)); + } + return logger$1.throwArgumentError("invalid arrayify value", "value", value); +} +function isHexString(value, length) { + if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) { + return false; + } + if (length && value.length !== 2 + 2 * length) { + return false; + } + return true; +} + +var sha3$1 = {exports: {}}; + +/** + * [js-sha3]{@link https://github.com/emn178/js-sha3} + * + * @version 0.8.0 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2015-2018 + * @license MIT + */ + +(function (module) { + /*jslint bitwise: true */ + (function () { + + var INPUT_ERROR = 'input is invalid type'; + var FINALIZE_ERROR = 'finalize already called'; + var WINDOW = typeof window === 'object'; + var root = WINDOW ? window : {}; + if (root.JS_SHA3_NO_WINDOW) { + WINDOW = false; + } + var WEB_WORKER = !WINDOW && typeof self === 'object'; + var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; + if (NODE_JS) { + root = commonjsGlobal; + } else if (WEB_WORKER) { + root = self; + } + var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && 'object' === 'object' && module.exports; + var ARRAY_BUFFER = !root.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; + var HEX_CHARS = '0123456789abcdef'.split(''); + var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; + var CSHAKE_PADDING = [4, 1024, 262144, 67108864]; + var KECCAK_PADDING = [1, 256, 65536, 16777216]; + var PADDING = [6, 1536, 393216, 100663296]; + var SHIFT = [0, 8, 16, 24]; + var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, + 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, + 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, + 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, + 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; + var BITS = [224, 256, 384, 512]; + var SHAKE_BITS = [128, 256]; + var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array', 'digest']; + var CSHAKE_BYTEPAD = { + '128': 168, + '256': 136 + }; + + if (root.JS_SHA3_NO_NODE_JS || !Array.isArray) { + Array.isArray = function (obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; + }; + } + + if (ARRAY_BUFFER && (root.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { + ArrayBuffer.isView = function (obj) { + return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; + }; + } + + var createOutputMethod = function (bits, padding, outputType) { + return function (message) { + return new Keccak(bits, padding, bits).update(message)[outputType](); + }; + }; + + var createShakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits) { + return new Keccak(bits, padding, outputBits).update(message)[outputType](); + }; + }; + + var createCshakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits, n, s) { + return methods['cshake' + bits].update(message, outputBits, n, s)[outputType](); + }; + }; + + var createKmacOutputMethod = function (bits, padding, outputType) { + return function (key, message, outputBits, s) { + return methods['kmac' + bits].update(key, message, outputBits, s)[outputType](); + }; + }; + + var createOutputMethods = function (method, createMethod, bits, padding) { + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createMethod(bits, padding, type); + } + return method; + }; + + var createMethod = function (bits, padding) { + var method = createOutputMethod(bits, padding, 'hex'); + method.create = function () { + return new Keccak(bits, padding, bits); + }; + method.update = function (message) { + return method.create().update(message); + }; + return createOutputMethods(method, createOutputMethod, bits, padding); + }; + + var createShakeMethod = function (bits, padding) { + var method = createShakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits) { + return new Keccak(bits, padding, outputBits); + }; + method.update = function (message, outputBits) { + return method.create(outputBits).update(message); + }; + return createOutputMethods(method, createShakeOutputMethod, bits, padding); + }; + + var createCshakeMethod = function (bits, padding) { + var w = CSHAKE_BYTEPAD[bits]; + var method = createCshakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits, n, s) { + if (!n && !s) { + return methods['shake' + bits].create(outputBits); + } else { + return new Keccak(bits, padding, outputBits).bytepad([n, s], w); + } + }; + method.update = function (message, outputBits, n, s) { + return method.create(outputBits, n, s).update(message); + }; + return createOutputMethods(method, createCshakeOutputMethod, bits, padding); + }; + + var createKmacMethod = function (bits, padding) { + var w = CSHAKE_BYTEPAD[bits]; + var method = createKmacOutputMethod(bits, padding, 'hex'); + method.create = function (key, outputBits, s) { + return new Kmac(bits, padding, outputBits).bytepad(['KMAC', s], w).bytepad([key], w); + }; + method.update = function (key, message, outputBits, s) { + return method.create(key, outputBits, s).update(message); + }; + return createOutputMethods(method, createKmacOutputMethod, bits, padding); + }; + + var algorithms = [ + { name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod }, + { name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod }, + { name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod }, + { name: 'cshake', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createCshakeMethod }, + { name: 'kmac', padding: CSHAKE_PADDING, bits: SHAKE_BITS, createMethod: createKmacMethod } + ]; + + var methods = {}, methodNames = []; + + for (var i = 0; i < algorithms.length; ++i) { + var algorithm = algorithms[i]; + var bits = algorithm.bits; + for (var j = 0; j < bits.length; ++j) { + var methodName = algorithm.name + '_' + bits[j]; + methodNames.push(methodName); + methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); + if (algorithm.name !== 'sha3') { + var newMethodName = algorithm.name + bits[j]; + methodNames.push(newMethodName); + methods[newMethodName] = methods[methodName]; + } + } + } + + function Keccak(bits, padding, outputBits) { + this.blocks = []; + this.s = []; + this.padding = padding; + this.outputBits = outputBits; + this.reset = true; + this.finalized = false; + this.block = 0; + this.start = 0; + this.blockCount = (1600 - (bits << 1)) >> 5; + this.byteCount = this.blockCount << 2; + this.outputBlocks = outputBits >> 5; + this.extraBytes = (outputBits & 31) >> 3; + + for (var i = 0; i < 50; ++i) { + this.s[i] = 0; + } + } + + Keccak.prototype.update = function (message) { + if (this.finalized) { + throw new Error(FINALIZE_ERROR); + } + var notString, type = typeof message; + if (type !== 'string') { + if (type === 'object') { + if (message === null) { + throw new Error(INPUT_ERROR); + } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { + message = new Uint8Array(message); + } else if (!Array.isArray(message)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { + throw new Error(INPUT_ERROR); + } + } + } else { + throw new Error(INPUT_ERROR); + } + notString = true; + } + var blocks = this.blocks, byteCount = this.byteCount, length = message.length, + blockCount = this.blockCount, index = 0, s = this.s, i, code; + + while (index < length) { + if (this.reset) { + this.reset = false; + blocks[0] = this.block; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + if (notString) { + for (i = this.start; index < length && i < byteCount; ++index) { + blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; + } + } else { + for (i = this.start; index < length && i < byteCount; ++index) { + code = message.charCodeAt(index); + if (code < 0x80) { + blocks[i >> 2] |= code << SHIFT[i++ & 3]; + } else if (code < 0x800) { + blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else if (code < 0xd800 || code >= 0xe000) { + blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } + } + } + this.lastByteIndex = i; + if (i >= byteCount) { + this.start = i - byteCount; + this.block = blocks[blockCount]; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); + this.reset = true; + } else { + this.start = i; + } + } + return this; + }; + + Keccak.prototype.encode = function (x, right) { + var o = x & 255, n = 1; + var bytes = [o]; + x = x >> 8; + o = x & 255; + while (o > 0) { + bytes.unshift(o); + x = x >> 8; + o = x & 255; + ++n; + } + if (right) { + bytes.push(n); + } else { + bytes.unshift(n); + } + this.update(bytes); + return bytes.length; + }; + + Keccak.prototype.encodeString = function (str) { + var notString, type = typeof str; + if (type !== 'string') { + if (type === 'object') { + if (str === null) { + throw new Error(INPUT_ERROR); + } else if (ARRAY_BUFFER && str.constructor === ArrayBuffer) { + str = new Uint8Array(str); + } else if (!Array.isArray(str)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(str)) { + throw new Error(INPUT_ERROR); + } + } + } else { + throw new Error(INPUT_ERROR); + } + notString = true; + } + var bytes = 0, length = str.length; + if (notString) { + bytes = length; + } else { + for (var i = 0; i < str.length; ++i) { + var code = str.charCodeAt(i); + if (code < 0x80) { + bytes += 1; + } else if (code < 0x800) { + bytes += 2; + } else if (code < 0xd800 || code >= 0xe000) { + bytes += 3; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (str.charCodeAt(++i) & 0x3ff)); + bytes += 4; + } + } + } + bytes += this.encode(bytes * 8); + this.update(str); + return bytes; + }; + + Keccak.prototype.bytepad = function (strs, w) { + var bytes = this.encode(w); + for (var i = 0; i < strs.length; ++i) { + bytes += this.encodeString(strs[i]); + } + var paddingBytes = w - bytes % w; + var zeros = []; + zeros.length = paddingBytes; + this.update(zeros); + return this; + }; + + Keccak.prototype.finalize = function () { + if (this.finalized) { + return; + } + this.finalized = true; + var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; + blocks[i >> 2] |= this.padding[i & 3]; + if (this.lastByteIndex === this.byteCount) { + blocks[0] = blocks[blockCount]; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + blocks[blockCount - 1] |= 0x80000000; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); + }; + + Keccak.prototype.toString = Keccak.prototype.hex = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var hex = '', block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + + HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + + HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + + HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; + } + if (j % blockCount === 0) { + f(s); + i = 0; + } + } + if (extraBytes) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; + if (extraBytes > 1) { + hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; + } + if (extraBytes > 2) { + hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; + } + } + return hex; + }; + + Keccak.prototype.arrayBuffer = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var bytes = this.outputBits >> 3; + var buffer; + if (extraBytes) { + buffer = new ArrayBuffer((outputBlocks + 1) << 2); + } else { + buffer = new ArrayBuffer(bytes); + } + var array = new Uint32Array(buffer); + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + array[j] = s[i]; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + array[i] = s[i]; + buffer = buffer.slice(0, bytes); + } + return buffer; + }; + + Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; + + Keccak.prototype.digest = Keccak.prototype.array = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var array = [], offset, block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + array[offset + 1] = (block >> 8) & 0xFF; + array[offset + 2] = (block >> 16) & 0xFF; + array[offset + 3] = (block >> 24) & 0xFF; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + if (extraBytes > 1) { + array[offset + 1] = (block >> 8) & 0xFF; + } + if (extraBytes > 2) { + array[offset + 2] = (block >> 16) & 0xFF; + } + } + return array; + }; + + function Kmac(bits, padding, outputBits) { + Keccak.call(this, bits, padding, outputBits); + } + + Kmac.prototype = new Keccak(); + + Kmac.prototype.finalize = function () { + this.encode(this.outputBits, true); + return Keccak.prototype.finalize.call(this); + }; + + var f = function (s) { + var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, + b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, + b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, + b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; + for (n = 0; n < 48; n += 2) { + c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; + c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; + c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; + c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; + c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; + c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; + c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; + c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; + c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; + c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; + + h = c8 ^ ((c2 << 1) | (c3 >>> 31)); + l = c9 ^ ((c3 << 1) | (c2 >>> 31)); + s[0] ^= h; + s[1] ^= l; + s[10] ^= h; + s[11] ^= l; + s[20] ^= h; + s[21] ^= l; + s[30] ^= h; + s[31] ^= l; + s[40] ^= h; + s[41] ^= l; + h = c0 ^ ((c4 << 1) | (c5 >>> 31)); + l = c1 ^ ((c5 << 1) | (c4 >>> 31)); + s[2] ^= h; + s[3] ^= l; + s[12] ^= h; + s[13] ^= l; + s[22] ^= h; + s[23] ^= l; + s[32] ^= h; + s[33] ^= l; + s[42] ^= h; + s[43] ^= l; + h = c2 ^ ((c6 << 1) | (c7 >>> 31)); + l = c3 ^ ((c7 << 1) | (c6 >>> 31)); + s[4] ^= h; + s[5] ^= l; + s[14] ^= h; + s[15] ^= l; + s[24] ^= h; + s[25] ^= l; + s[34] ^= h; + s[35] ^= l; + s[44] ^= h; + s[45] ^= l; + h = c4 ^ ((c8 << 1) | (c9 >>> 31)); + l = c5 ^ ((c9 << 1) | (c8 >>> 31)); + s[6] ^= h; + s[7] ^= l; + s[16] ^= h; + s[17] ^= l; + s[26] ^= h; + s[27] ^= l; + s[36] ^= h; + s[37] ^= l; + s[46] ^= h; + s[47] ^= l; + h = c6 ^ ((c0 << 1) | (c1 >>> 31)); + l = c7 ^ ((c1 << 1) | (c0 >>> 31)); + s[8] ^= h; + s[9] ^= l; + s[18] ^= h; + s[19] ^= l; + s[28] ^= h; + s[29] ^= l; + s[38] ^= h; + s[39] ^= l; + s[48] ^= h; + s[49] ^= l; + + b0 = s[0]; + b1 = s[1]; + b32 = (s[11] << 4) | (s[10] >>> 28); + b33 = (s[10] << 4) | (s[11] >>> 28); + b14 = (s[20] << 3) | (s[21] >>> 29); + b15 = (s[21] << 3) | (s[20] >>> 29); + b46 = (s[31] << 9) | (s[30] >>> 23); + b47 = (s[30] << 9) | (s[31] >>> 23); + b28 = (s[40] << 18) | (s[41] >>> 14); + b29 = (s[41] << 18) | (s[40] >>> 14); + b20 = (s[2] << 1) | (s[3] >>> 31); + b21 = (s[3] << 1) | (s[2] >>> 31); + b2 = (s[13] << 12) | (s[12] >>> 20); + b3 = (s[12] << 12) | (s[13] >>> 20); + b34 = (s[22] << 10) | (s[23] >>> 22); + b35 = (s[23] << 10) | (s[22] >>> 22); + b16 = (s[33] << 13) | (s[32] >>> 19); + b17 = (s[32] << 13) | (s[33] >>> 19); + b48 = (s[42] << 2) | (s[43] >>> 30); + b49 = (s[43] << 2) | (s[42] >>> 30); + b40 = (s[5] << 30) | (s[4] >>> 2); + b41 = (s[4] << 30) | (s[5] >>> 2); + b22 = (s[14] << 6) | (s[15] >>> 26); + b23 = (s[15] << 6) | (s[14] >>> 26); + b4 = (s[25] << 11) | (s[24] >>> 21); + b5 = (s[24] << 11) | (s[25] >>> 21); + b36 = (s[34] << 15) | (s[35] >>> 17); + b37 = (s[35] << 15) | (s[34] >>> 17); + b18 = (s[45] << 29) | (s[44] >>> 3); + b19 = (s[44] << 29) | (s[45] >>> 3); + b10 = (s[6] << 28) | (s[7] >>> 4); + b11 = (s[7] << 28) | (s[6] >>> 4); + b42 = (s[17] << 23) | (s[16] >>> 9); + b43 = (s[16] << 23) | (s[17] >>> 9); + b24 = (s[26] << 25) | (s[27] >>> 7); + b25 = (s[27] << 25) | (s[26] >>> 7); + b6 = (s[36] << 21) | (s[37] >>> 11); + b7 = (s[37] << 21) | (s[36] >>> 11); + b38 = (s[47] << 24) | (s[46] >>> 8); + b39 = (s[46] << 24) | (s[47] >>> 8); + b30 = (s[8] << 27) | (s[9] >>> 5); + b31 = (s[9] << 27) | (s[8] >>> 5); + b12 = (s[18] << 20) | (s[19] >>> 12); + b13 = (s[19] << 20) | (s[18] >>> 12); + b44 = (s[29] << 7) | (s[28] >>> 25); + b45 = (s[28] << 7) | (s[29] >>> 25); + b26 = (s[38] << 8) | (s[39] >>> 24); + b27 = (s[39] << 8) | (s[38] >>> 24); + b8 = (s[48] << 14) | (s[49] >>> 18); + b9 = (s[49] << 14) | (s[48] >>> 18); + + s[0] = b0 ^ (~b2 & b4); + s[1] = b1 ^ (~b3 & b5); + s[10] = b10 ^ (~b12 & b14); + s[11] = b11 ^ (~b13 & b15); + s[20] = b20 ^ (~b22 & b24); + s[21] = b21 ^ (~b23 & b25); + s[30] = b30 ^ (~b32 & b34); + s[31] = b31 ^ (~b33 & b35); + s[40] = b40 ^ (~b42 & b44); + s[41] = b41 ^ (~b43 & b45); + s[2] = b2 ^ (~b4 & b6); + s[3] = b3 ^ (~b5 & b7); + s[12] = b12 ^ (~b14 & b16); + s[13] = b13 ^ (~b15 & b17); + s[22] = b22 ^ (~b24 & b26); + s[23] = b23 ^ (~b25 & b27); + s[32] = b32 ^ (~b34 & b36); + s[33] = b33 ^ (~b35 & b37); + s[42] = b42 ^ (~b44 & b46); + s[43] = b43 ^ (~b45 & b47); + s[4] = b4 ^ (~b6 & b8); + s[5] = b5 ^ (~b7 & b9); + s[14] = b14 ^ (~b16 & b18); + s[15] = b15 ^ (~b17 & b19); + s[24] = b24 ^ (~b26 & b28); + s[25] = b25 ^ (~b27 & b29); + s[34] = b34 ^ (~b36 & b38); + s[35] = b35 ^ (~b37 & b39); + s[44] = b44 ^ (~b46 & b48); + s[45] = b45 ^ (~b47 & b49); + s[6] = b6 ^ (~b8 & b0); + s[7] = b7 ^ (~b9 & b1); + s[16] = b16 ^ (~b18 & b10); + s[17] = b17 ^ (~b19 & b11); + s[26] = b26 ^ (~b28 & b20); + s[27] = b27 ^ (~b29 & b21); + s[36] = b36 ^ (~b38 & b30); + s[37] = b37 ^ (~b39 & b31); + s[46] = b46 ^ (~b48 & b40); + s[47] = b47 ^ (~b49 & b41); + s[8] = b8 ^ (~b0 & b2); + s[9] = b9 ^ (~b1 & b3); + s[18] = b18 ^ (~b10 & b12); + s[19] = b19 ^ (~b11 & b13); + s[28] = b28 ^ (~b20 & b22); + s[29] = b29 ^ (~b21 & b23); + s[38] = b38 ^ (~b30 & b32); + s[39] = b39 ^ (~b31 & b33); + s[48] = b48 ^ (~b40 & b42); + s[49] = b49 ^ (~b41 & b43); + + s[0] ^= RC[n]; + s[1] ^= RC[n + 1]; + } + }; + + if (COMMON_JS) { + module.exports = methods; + } else { + for (i = 0; i < methodNames.length; ++i) { + root[methodNames[i]] = methods[methodNames[i]]; + } + } + })(); +} (sha3$1)); + +var sha3Exports = sha3$1.exports; +var sha3 = /*@__PURE__*/getDefaultExportFromCjs(sha3Exports); + +function keccak256(data) { + return '0x' + sha3.keccak_256(arrayify(data)); +} + +const version = "strings/5.7.0"; + +const logger = new Logger(version); +/////////////////////////////// +var UnicodeNormalizationForm; +(function (UnicodeNormalizationForm) { + UnicodeNormalizationForm["current"] = ""; + UnicodeNormalizationForm["NFC"] = "NFC"; + UnicodeNormalizationForm["NFD"] = "NFD"; + UnicodeNormalizationForm["NFKC"] = "NFKC"; + UnicodeNormalizationForm["NFKD"] = "NFKD"; +})(UnicodeNormalizationForm || (UnicodeNormalizationForm = {})); +var Utf8ErrorReason; +(function (Utf8ErrorReason) { + // A continuation byte was present where there was nothing to continue + // - offset = the index the codepoint began in + Utf8ErrorReason["UNEXPECTED_CONTINUE"] = "unexpected continuation byte"; + // An invalid (non-continuation) byte to start a UTF-8 codepoint was found + // - offset = the index the codepoint began in + Utf8ErrorReason["BAD_PREFIX"] = "bad codepoint prefix"; + // The string is too short to process the expected codepoint + // - offset = the index the codepoint began in + Utf8ErrorReason["OVERRUN"] = "string overrun"; + // A missing continuation byte was expected but not found + // - offset = the index the continuation byte was expected at + Utf8ErrorReason["MISSING_CONTINUE"] = "missing continuation byte"; + // The computed code point is outside the range for UTF-8 + // - offset = start of this codepoint + // - badCodepoint = the computed codepoint; outside the UTF-8 range + Utf8ErrorReason["OUT_OF_RANGE"] = "out of UTF-8 range"; + // UTF-8 strings may not contain UTF-16 surrogate pairs + // - offset = start of this codepoint + // - badCodepoint = the computed codepoint; inside the UTF-16 surrogate range + Utf8ErrorReason["UTF16_SURROGATE"] = "UTF-16 surrogate"; + // The string is an overlong representation + // - offset = start of this codepoint + // - badCodepoint = the computed codepoint; already bounds checked + Utf8ErrorReason["OVERLONG"] = "overlong representation"; +})(Utf8ErrorReason || (Utf8ErrorReason = {})); +// http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array +function toUtf8Bytes(str, form = UnicodeNormalizationForm.current) { + if (form != UnicodeNormalizationForm.current) { + logger.checkNormalize(); + str = str.normalize(form); + } + let result = []; + for (let i = 0; i < str.length; i++) { + const c = str.charCodeAt(i); + if (c < 0x80) { + result.push(c); + } + else if (c < 0x800) { + result.push((c >> 6) | 0xc0); + result.push((c & 0x3f) | 0x80); + } + else if ((c & 0xfc00) == 0xd800) { + i++; + const c2 = str.charCodeAt(i); + if (i >= str.length || (c2 & 0xfc00) !== 0xdc00) { + throw new Error("invalid utf-8 string"); + } + // Surrogate Pair + const pair = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff); + result.push((pair >> 18) | 0xf0); + result.push(((pair >> 12) & 0x3f) | 0x80); + result.push(((pair >> 6) & 0x3f) | 0x80); + result.push((pair & 0x3f) | 0x80); + } + else { + result.push((c >> 12) | 0xe0); + result.push(((c >> 6) & 0x3f) | 0x80); + result.push((c & 0x3f) | 0x80); + } + } + return arrayify(result); +} + +const SEED = "mimcsponge"; +const NROUNDS = 220; + +async function buildMimcSponge() { + const bn128 = await getCurveFromName("bn128", true); + return new MimcSponge(bn128.Fr); +} + +class MimcSponge { + constructor (F) { + this.F = F; + this.cts = this.getConstants(SEED, NROUNDS); + } + + getIV (seed) { + const F = this.F; + if (typeof seed === "undefined") seed = SEED; + const c = keccak256(toUtf8Bytes(seed+"_iv")); + const cn = Scalar.e(c); + const iv = cn.mod(F.p); + return iv; + }; + + getConstants (seed, nRounds) { + const F = this.F; + if (typeof nRounds === "undefined") nRounds = NROUNDS; + const cts = new Array(nRounds); + let c = keccak256(toUtf8Bytes(SEED)); for (let i=1; i { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +class Pedersen { + constructor() { + this.pedersenPromise = this.initPedersen(); + } + initPedersen() { + return __async$7(this, null, function* () { + this.pedersenHash = yield buildPedersenHash(); + this.babyJub = this.pedersenHash.babyJub; + }); + } + unpackPoint(buffer) { + return __async$7(this, null, function* () { + var _a, _b; + yield this.pedersenPromise; + return (_b = this.babyJub) == null ? void 0 : _b.unpackPoint((_a = this.pedersenHash) == null ? void 0 : _a.hash(buffer)); + }); + } + toStringBuffer(buffer) { + var _a; + return (_a = this.babyJub) == null ? void 0 : _a.F.toString(buffer); + } +} +const pedersen = new Pedersen(); +function buffPedersenHash(buffer) { + return __async$7(this, null, function* () { + const [hash] = yield pedersen.unpackPoint(buffer); + return pedersen.toStringBuffer(hash); + }); +} + +var __async$6 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +function createDeposit(_0) { + return __async$6(this, arguments, function* ({ nullifier, secret }) { + const preimage = new Uint8Array([...leInt2Buff$3(nullifier), ...leInt2Buff$3(secret)]); + const noteHex = toFixedHex(bytesToBN(preimage), 62); + const commitment = BigInt(yield buffPedersenHash(preimage)); + const commitmentHex = toFixedHex(commitment); + const nullifierHash = BigInt(yield buffPedersenHash(leInt2Buff$3(nullifier))); + const nullifierHex = toFixedHex(nullifierHash); + return { + preimage, + noteHex, + commitment, + commitmentHex, + nullifierHash, + nullifierHex + }; + }); +} +class Deposit { + constructor({ + currency, + amount, + netId, + nullifier, + secret, + note, + noteHex, + invoice, + commitmentHex, + nullifierHex + }) { + this.currency = currency; + this.amount = amount; + this.netId = netId; + this.nullifier = nullifier; + this.secret = secret; + this.note = note; + this.noteHex = noteHex; + this.invoice = invoice; + this.commitmentHex = commitmentHex; + this.nullifierHex = nullifierHex; + } + toString() { + return JSON.stringify( + { + currency: this.currency, + amount: this.amount, + netId: this.netId, + nullifier: this.nullifier, + secret: this.secret, + note: this.note, + noteHex: this.noteHex, + invoice: this.invoice, + commitmentHex: this.commitmentHex, + nullifierHex: this.nullifierHex + }, + null, + 2 + ); + } + static createNote(_0) { + return __async$6(this, arguments, function* ({ currency, amount, netId, nullifier, secret }) { + if (!nullifier) { + nullifier = rBigInt(31); + } + if (!secret) { + secret = rBigInt(31); + } + const depositObject = yield createDeposit({ + nullifier, + secret + }); + const newDeposit = new Deposit({ + currency: currency.toLowerCase(), + amount, + netId: Number(netId), + note: `tornado-${currency.toLowerCase()}-${amount}-${netId}-${depositObject.noteHex}`, + noteHex: depositObject.noteHex, + invoice: `tornadoInvoice-${currency.toLowerCase()}-${amount}-${netId}-${depositObject.commitmentHex}`, + nullifier, + secret, + commitmentHex: depositObject.commitmentHex, + nullifierHex: depositObject.nullifierHex + }); + return newDeposit; + }); + } + static parseNote(noteString) { + return __async$6(this, null, function* () { + const noteRegex = new RegExp("tornado-(?\\w+)-(?[\\d.]+)-(?\\d+)-0x(?[0-9a-fA-F]{124})", "g"); + const match = noteRegex.exec(noteString); + if (!match) { + throw new Error("The note has invalid format"); + } + const matchGroup = match == null ? void 0 : match.groups; + const currency = matchGroup.currency.toLowerCase(); + const amount = matchGroup.amount; + const netId = Number(matchGroup.netId); + const bytes = bnToBytes("0x" + matchGroup.note); + const nullifier = BigInt(leBuff2Int(bytes.slice(0, 31)).toString()); + const secret = BigInt(leBuff2Int(bytes.slice(31, 62)).toString()); + const depositObject = yield createDeposit({ nullifier, secret }); + const invoice = `tornadoInvoice-${currency}-${amount}-${netId}-${depositObject.commitmentHex}`; + const newDeposit = new Deposit({ + currency, + amount, + netId, + note: noteString, + noteHex: depositObject.noteHex, + invoice, + nullifier, + secret, + commitmentHex: depositObject.commitmentHex, + nullifierHex: depositObject.nullifierHex + }); + return newDeposit; + }); + } +} +class Invoice { + constructor(invoiceString) { + const invoiceRegex = new RegExp("tornadoInvoice-(?\\w+)-(?[\\d.]+)-(?\\d+)-0x(?[0-9a-fA-F]{64})", "g"); + const match = invoiceRegex.exec(invoiceString); + if (!match) { + throw new Error("The note has invalid format"); + } + const matchGroup = match == null ? void 0 : match.groups; + const currency = matchGroup.currency.toLowerCase(); + const amount = matchGroup.amount; + const netId = Number(matchGroup.netId); + this.currency = currency; + this.amount = amount; + this.netId = netId; + this.commitment = "0x" + matchGroup.commitment; + this.invoice = invoiceString; + } + toString() { + return JSON.stringify( + { + currency: this.currency, + amount: this.amount, + netId: this.netId, + commitment: this.commitment, + invoice: this.invoice + }, + null, + 2 + ); + } +} + +const DUMMY_ADDRESS = "0x1111111111111111111111111111111111111111"; +const DUMMY_NONCE = "0x1111111111111111111111111111111111111111111111111111111111111111"; +const DUMMY_WITHDRAW_DATA = "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"; +function convertETHToTokenAmount(amountInWei, tokenPriceInWei, tokenDecimals = 18) { + const tokenDecimalsMultiplier = BigInt(10 ** Number(tokenDecimals)); + return BigInt(amountInWei) * tokenDecimalsMultiplier / BigInt(tokenPriceInWei); +} +class TornadoFeeOracle { + constructor(ovmGasPriceOracle) { + if (ovmGasPriceOracle) { + this.ovmGasPriceOracle = ovmGasPriceOracle; + } + } + /** + * Calculate L1 fee for op-stack chains + * + * This is required since relayers would pay the full transaction fees for users + */ + fetchL1OptimismFee(tx) { + if (!this.ovmGasPriceOracle) { + return new Promise((resolve) => resolve(BigInt(0))); + } + if (!tx) { + tx = { + type: 0, + gasLimit: 1e6, + nonce: Number(DUMMY_NONCE), + data: DUMMY_WITHDRAW_DATA, + gasPrice: parseUnits$1("1", "gwei"), + from: DUMMY_ADDRESS, + to: DUMMY_ADDRESS + }; + } + return this.ovmGasPriceOracle.getL1Fee.staticCall(Transaction.from(tx).unsignedSerialized); + } + /** + * We don't need to distinguish default refunds by tokens since most users interact with other defi protocols after withdrawal + * So we default with 1M gas which is enough for two or three swaps + * Using 30 gwei for default but it is recommended to supply cached gasPrice value from the UI + */ + defaultEthRefund(gasPrice, gasLimit) { + return (gasPrice ? BigInt(gasPrice) : parseUnits$1("30", "gwei")) * BigInt(gasLimit || 1e6); + } + /** + * Calculates token amount for required ethRefund purchases required to calculate fees + */ + calculateTokenAmount(ethRefund, tokenPriceInEth, tokenDecimals) { + return convertETHToTokenAmount(ethRefund, tokenPriceInEth, tokenDecimals); + } + /** + * Warning: For tokens you need to check if the fees are above denomination + * (Usually happens for small denomination pool or if the gas price is high) + */ + calculateRelayerFee({ + gasPrice, + gasLimit = 6e5, + l1Fee = 0, + denomination, + ethRefund = BigInt(0), + tokenPriceInWei, + tokenDecimals = 18, + relayerFeePercent = 0.33, + isEth = true, + premiumPercent = 20 + }) { + const gasCosts = BigInt(gasPrice) * BigInt(gasLimit) + BigInt(l1Fee); + const relayerFee = BigInt(denomination) * BigInt(Math.floor(1e4 * relayerFeePercent)) / BigInt(1e4 * 100); + if (isEth) { + return (gasCosts + relayerFee) * BigInt(premiumPercent ? 100 + premiumPercent : 100) / BigInt(100); + } + const feeInEth = gasCosts + BigInt(ethRefund); + return (convertETHToTokenAmount(feeInEth, tokenPriceInWei, tokenDecimals) + relayerFee) * BigInt(premiumPercent ? 100 + premiumPercent : 100) / BigInt(100); + } +} + +var lib = {}; + +var FixedMerkleTree = {}; + +var simpleHash$1 = {}; + +Object.defineProperty(simpleHash$1, "__esModule", { value: true }); +simpleHash$1.simpleHash = void 0; +/*** + * This is insecure hash function, just for example only + * @param data + * @param seed + * @param hashLength + */ +function simpleHash(data, seed, hashLength = 40) { + const str = data.join(''); + let i, l, hval = seed !== null && seed !== void 0 ? seed : 0x811c9dcc5; + for (i = 0, l = str.length; i < l; i++) { + hval ^= str.charCodeAt(i); + hval += (hval << 1) + (hval << 4) + (hval << 6) + (hval << 8) + (hval << 24); + } + const hash = (hval >>> 0).toString(16); + return BigInt('0x' + hash.padEnd(hashLength - (hash.length - 1), '0')).toString(10); +} +simpleHash$1.simpleHash = simpleHash; +simpleHash$1.default = (left, right) => simpleHash([left, right]); + +var BaseTree$1 = {}; + +Object.defineProperty(BaseTree$1, "__esModule", { value: true }); +BaseTree$1.BaseTree = void 0; +class BaseTree { + get capacity() { + return 2 ** this.levels; + } + get layers() { + return this._layers.slice(); + } + get zeros() { + return this._zeros.slice(); + } + get elements() { + return this._layers[0].slice(); + } + get root() { + var _a; + return (_a = this._layers[this.levels][0]) !== null && _a !== void 0 ? _a : this._zeros[this.levels]; + } + /** + * Find an element in the tree + * @param elements elements of tree + * @param element An element to find + * @param comparator A function that checks leaf value equality + * @param fromIndex The index to start the search at. If the index is greater than or equal to the array's length, -1 is returned + * @returns {number} Index if element is found, otherwise -1 + */ + static indexOf(elements, element, fromIndex, comparator) { + if (comparator) { + return elements.findIndex((el) => comparator(element, el)); + } + else { + return elements.indexOf(element, fromIndex); + } + } + /** + * Insert new element into the tree + * @param element Element to insert + */ + insert(element) { + if (this._layers[0].length >= this.capacity) { + throw new Error('Tree is full'); + } + this.update(this._layers[0].length, element); + } + /* + * Insert multiple elements into the tree. + * @param {Array} elements Elements to insert + */ + bulkInsert(elements) { + if (!elements.length) { + return; + } + if (this._layers[0].length + elements.length > this.capacity) { + throw new Error('Tree is full'); + } + // First we insert all elements except the last one + // updating only full subtree hashes (all layers where inserted element has odd index) + // the last element will update the full path to the root making the tree consistent again + for (let i = 0; i < elements.length - 1; i++) { + this._layers[0].push(elements[i]); + let level = 0; + let index = this._layers[0].length - 1; + while (index % 2 === 1) { + level++; + index >>= 1; + const left = this._layers[level - 1][index * 2]; + const right = this._layers[level - 1][index * 2 + 1]; + this._layers[level][index] = this._hashFn(left, right); + } + } + this.insert(elements[elements.length - 1]); + } + /** + * Change an element in the tree + * @param {number} index Index of element to change + * @param element Updated element value + */ + update(index, element) { + if (isNaN(Number(index)) || index < 0 || index > this._layers[0].length || index >= this.capacity) { + throw new Error('Insert index out of bounds: ' + index); + } + this._layers[0][index] = element; + this._processUpdate(index); + } + /** + * Get merkle path to a leaf + * @param {number} index Leaf index to generate path for + * @returns {{pathElements: Object[], pathIndex: number[]}} An object containing adjacent elements and left-right index + */ + path(index) { + if (isNaN(Number(index)) || index < 0 || index >= this._layers[0].length) { + throw new Error('Index out of bounds: ' + index); + } + let elIndex = +index; + const pathElements = []; + const pathIndices = []; + const pathPositions = []; + for (let level = 0; level < this.levels; level++) { + pathIndices[level] = elIndex % 2; + const leafIndex = elIndex ^ 1; + if (leafIndex < this._layers[level].length) { + pathElements[level] = this._layers[level][leafIndex]; + pathPositions[level] = leafIndex; + } + else { + pathElements[level] = this._zeros[level]; + pathPositions[level] = 0; + } + elIndex >>= 1; + } + return { + pathElements, + pathIndices, + pathPositions, + pathRoot: this.root, + }; + } + _buildZeros() { + this._zeros = [this.zeroElement]; + for (let i = 1; i <= this.levels; i++) { + this._zeros[i] = this._hashFn(this._zeros[i - 1], this._zeros[i - 1]); + } + } + _processNodes(nodes, layerIndex) { + const length = nodes.length; + let currentLength = Math.ceil(length / 2); + const currentLayer = new Array(currentLength); + currentLength--; + const starFrom = length - ((length % 2) ^ 1); + let j = 0; + for (let i = starFrom; i >= 0; i -= 2) { + if (nodes[i - 1] === undefined) + break; + const left = nodes[i - 1]; + const right = (i === starFrom && length % 2 === 1) ? this._zeros[layerIndex - 1] : nodes[i]; + currentLayer[currentLength - j] = this._hashFn(left, right); + j++; + } + return currentLayer; + } + _processUpdate(index) { + for (let level = 1; level <= this.levels; level++) { + index >>= 1; + const left = this._layers[level - 1][index * 2]; + const right = index * 2 + 1 < this._layers[level - 1].length + ? this._layers[level - 1][index * 2 + 1] + : this._zeros[level - 1]; + this._layers[level][index] = this._hashFn(left, right); + } + } +} +BaseTree$1.BaseTree = BaseTree; + +var __importDefault$1 = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(FixedMerkleTree, "__esModule", { value: true }); +const simpleHash_1$1 = __importDefault$1(simpleHash$1); +const BaseTree_1$1 = BaseTree$1; +class MerkleTree extends BaseTree_1$1.BaseTree { + constructor(levels, elements = [], { hashFunction = simpleHash_1$1.default, zeroElement = 0, } = {}) { + super(); + this.levels = levels; + if (elements.length > this.capacity) { + throw new Error('Tree is full'); + } + this._hashFn = hashFunction; + this.zeroElement = zeroElement; + this._layers = []; + const leaves = elements.slice(); + this._layers = [leaves]; + this._buildZeros(); + this._buildHashes(); + } + _buildHashes() { + for (let layerIndex = 1; layerIndex <= this.levels; layerIndex++) { + const nodes = this._layers[layerIndex - 1]; + this._layers[layerIndex] = this._processNodes(nodes, layerIndex); + } + } + /** + * Insert multiple elements into the tree. + * @param {Array} elements Elements to insert + */ + bulkInsert(elements) { + if (!elements.length) { + return; + } + if (this._layers[0].length + elements.length > this.capacity) { + throw new Error('Tree is full'); + } + // First we insert all elements except the last one + // updating only full subtree hashes (all layers where inserted element has odd index) + // the last element will update the full path to the root making the tree consistent again + for (let i = 0; i < elements.length - 1; i++) { + this._layers[0].push(elements[i]); + let level = 0; + let index = this._layers[0].length - 1; + while (index % 2 === 1) { + level++; + index >>= 1; + this._layers[level][index] = this._hashFn(this._layers[level - 1][index * 2], this._layers[level - 1][index * 2 + 1]); + } + } + this.insert(elements[elements.length - 1]); + } + indexOf(element, comparator) { + return BaseTree_1$1.BaseTree.indexOf(this._layers[0], element, 0, comparator); + } + proof(element) { + const index = this.indexOf(element); + return this.path(index); + } + getTreeEdge(edgeIndex) { + const edgeElement = this._layers[0][edgeIndex]; + if (edgeElement === undefined) { + throw new Error('Element not found'); + } + const edgePath = this.path(edgeIndex); + return { edgePath, edgeElement, edgeIndex, edgeElementsCount: this._layers[0].length }; + } + /** + * 🪓 + * @param count + */ + getTreeSlices(count = 4) { + const length = this._layers[0].length; + let size = Math.ceil(length / count); + if (size % 2) + size++; + const slices = []; + for (let i = 0; i < length; i += size) { + const edgeLeft = i; + const edgeRight = i + size; + slices.push({ edge: this.getTreeEdge(edgeLeft), elements: this.elements.slice(edgeLeft, edgeRight) }); + } + return slices; + } + /** + * Serialize entire tree state including intermediate layers into a plain object + * Deserializing it back will not require to recompute any hashes + * Elements are not converted to a plain type, this is responsibility of the caller + */ + serialize() { + return { + levels: this.levels, + _zeros: this._zeros, + _layers: this._layers, + }; + } + /** + * Deserialize data into a MerkleTree instance + * Make sure to provide the same hashFunction as was used in the source tree, + * otherwise the tree state will be invalid + */ + static deserialize(data, hashFunction) { + const instance = Object.assign(Object.create(this.prototype), data); + instance._hashFn = hashFunction || simpleHash_1$1.default; + instance.zeroElement = instance._zeros[0]; + return instance; + } + toString() { + return JSON.stringify(this.serialize()); + } +} +FixedMerkleTree.default = MerkleTree; + +var PartialMerkleTree$1 = {}; + +var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(PartialMerkleTree$1, "__esModule", { value: true }); +PartialMerkleTree$1.PartialMerkleTree = void 0; +const simpleHash_1 = __importDefault(simpleHash$1); +const BaseTree_1 = BaseTree$1; +class PartialMerkleTree extends BaseTree_1.BaseTree { + constructor(levels, { edgePath, edgeElement, edgeIndex, edgeElementsCount, }, leaves, { hashFunction, zeroElement } = {}) { + super(); + if (edgeIndex + leaves.length !== edgeElementsCount) + throw new Error('Invalid number of elements'); + this._edgeLeafProof = edgePath; + this._initialRoot = edgePath.pathRoot; + this.zeroElement = zeroElement !== null && zeroElement !== void 0 ? zeroElement : 0; + this._edgeLeaf = { data: edgeElement, index: edgeIndex }; + this._leavesAfterEdge = leaves; + this.levels = levels; + this._hashFn = hashFunction || simpleHash_1.default; + this._createProofMap(); + this._buildTree(); + } + get edgeIndex() { + return this._edgeLeaf.index; + } + get edgeElement() { + return this._edgeLeaf.data; + } + get edgeLeafProof() { + return this._edgeLeafProof; + } + _createProofMap() { + this._proofMap = this.edgeLeafProof.pathPositions.reduce((p, c, i) => { + p.set(i, [c, this.edgeLeafProof.pathElements[i]]); + return p; + }, new Map()); + this._proofMap.set(this.levels, [0, this.edgeLeafProof.pathRoot]); + } + _buildTree() { + const edgeLeafIndex = this._edgeLeaf.index; + this._leaves = Array(edgeLeafIndex).concat(this._leavesAfterEdge); + if (this._proofMap.has(0)) { + const [proofPos, proofEl] = this._proofMap.get(0); + this._leaves[proofPos] = proofEl; + } + this._layers = [this._leaves]; + this._buildZeros(); + this._buildHashes(); + } + _buildHashes() { + for (let layerIndex = 1; layerIndex <= this.levels; layerIndex++) { + const nodes = this._layers[layerIndex - 1]; + const currentLayer = this._processNodes(nodes, layerIndex); + if (this._proofMap.has(layerIndex)) { + const [proofPos, proofEl] = this._proofMap.get(layerIndex); + if (!currentLayer[proofPos]) + currentLayer[proofPos] = proofEl; + } + this._layers[layerIndex] = currentLayer; + } + } + /** + * Change an element in the tree + * @param {number} index Index of element to change + * @param element Updated element value + */ + update(index, element) { + if (isNaN(Number(index)) || index < 0 || index > this._layers[0].length || index >= this.capacity) { + throw new Error('Insert index out of bounds: ' + index); + } + if (index < this._edgeLeaf.index) { + throw new Error(`Index ${index} is below the edge: ${this._edgeLeaf.index}`); + } + this._layers[0][index] = element; + this._processUpdate(index); + } + path(index) { + var _a; + if (isNaN(Number(index)) || index < 0 || index >= this._layers[0].length) { + throw new Error('Index out of bounds: ' + index); + } + if (index < this._edgeLeaf.index) { + throw new Error(`Index ${index} is below the edge: ${this._edgeLeaf.index}`); + } + let elIndex = Number(index); + const pathElements = []; + const pathIndices = []; + const pathPositions = []; + for (let level = 0; level < this.levels; level++) { + pathIndices[level] = elIndex % 2; + const leafIndex = elIndex ^ 1; + if (leafIndex < this._layers[level].length) { + pathElements[level] = this._layers[level][leafIndex]; + pathPositions[level] = leafIndex; + } + else { + pathElements[level] = this._zeros[level]; + pathPositions[level] = 0; + } + const [proofPos, proofEl] = this._proofMap.get(level); + pathElements[level] = (_a = pathElements[level]) !== null && _a !== void 0 ? _a : (proofPos === leafIndex ? proofEl : this._zeros[level]); + elIndex >>= 1; + } + return { + pathElements, + pathIndices, + pathPositions, + pathRoot: this.root, + }; + } + indexOf(element, comparator) { + return BaseTree_1.BaseTree.indexOf(this._layers[0], element, this.edgeIndex, comparator); + } + proof(element) { + const index = this.indexOf(element); + return this.path(index); + } + /** + * Shifts edge of tree to left + * @param edge new TreeEdge below current edge + * @param elements leaves between old and new edge + */ + shiftEdge(edge, elements) { + if (this._edgeLeaf.index <= edge.edgeIndex) { + throw new Error(`New edgeIndex should be smaller then ${this._edgeLeaf.index}`); + } + if (elements.length !== (this._edgeLeaf.index - edge.edgeIndex)) { + throw new Error(`Elements length should be ${this._edgeLeaf.index - edge.edgeIndex}`); + } + this._edgeLeafProof = edge.edgePath; + this._edgeLeaf = { index: edge.edgeIndex, data: edge.edgeElement }; + this._leavesAfterEdge = [...elements, ...this._leavesAfterEdge]; + this._createProofMap(); + this._buildTree(); + } + serialize() { + return { + _edgeLeafProof: this._edgeLeafProof, + _edgeLeaf: this._edgeLeaf, + _layers: this._layers, + _zeros: this._zeros, + levels: this.levels, + }; + } + static deserialize(data, hashFunction) { + const instance = Object.assign(Object.create(this.prototype), data); + instance._hashFn = hashFunction || simpleHash_1.default; + instance._initialRoot = data._edgeLeafProof.pathRoot; + instance.zeroElement = instance._zeros[0]; + instance._leavesAfterEdge = instance._layers[0].slice(data._edgeLeaf.index); + instance._createProofMap(); + return instance; + } + toString() { + return JSON.stringify(this.serialize()); + } +} +PartialMerkleTree$1.PartialMerkleTree = PartialMerkleTree; + +(function (exports) { + var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.MerkleTree = exports.simpleHash = exports.PartialMerkleTree = void 0; + const FixedMerkleTree_1 = __importDefault(FixedMerkleTree); + Object.defineProperty(exports, "MerkleTree", { enumerable: true, get: function () { return FixedMerkleTree_1.default; } }); + var PartialMerkleTree_1 = PartialMerkleTree$1; + Object.defineProperty(exports, "PartialMerkleTree", { enumerable: true, get: function () { return PartialMerkleTree_1.PartialMerkleTree; } }); + var simpleHash_1 = simpleHash$1; + Object.defineProperty(exports, "simpleHash", { enumerable: true, get: function () { return simpleHash_1.simpleHash; } }); + exports.default = FixedMerkleTree_1.default; +} (lib)); + +var __async$5 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +class Mimc { + constructor() { + this.mimcPromise = this.initMimc(); + } + initMimc() { + return __async$5(this, null, function* () { + this.sponge = yield buildMimcSponge(); + this.hash = (left, right) => { + var _a, _b; + return (_b = this.sponge) == null ? void 0 : _b.F.toString((_a = this.sponge) == null ? void 0 : _a.multiHash([BigInt(left), BigInt(right)])); + }; + }); + } + getHash() { + return __async$5(this, null, function* () { + yield this.mimcPromise; + return { + sponge: this.sponge, + hash: this.hash + }; + }); + } +} +const mimc = new Mimc(); + +var __async$4 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +class MerkleTreeService { + constructor({ + netId, + amount, + currency, + Tornado, + commitment, + merkleTreeHeight = 20, + emptyElement = "21663839004416932945382355908790599225266501822907911457504978515578255421292", + merkleWorkerPath + }) { + const instanceName = `${netId}_${currency}_${amount}`; + this.currency = currency; + this.amount = amount; + this.netId = Number(netId); + this.Tornado = Tornado; + this.instanceName = instanceName; + this.commitment = commitment; + this.merkleTreeHeight = merkleTreeHeight; + this.emptyElement = emptyElement; + this.merkleWorkerPath = merkleWorkerPath; + } + createTree(_0) { + return __async$4(this, arguments, function* ({ events }) { + const { hash: hashFunction } = yield mimc.getHash(); + if (this.merkleWorkerPath) { + console.log("Using merkleWorker\n"); + try { + if (isNode) { + const merkleWorkerPromise = new Promise((resolve, reject) => { + const worker = new threads.Worker(this.merkleWorkerPath, { + workerData: { + merkleTreeHeight: this.merkleTreeHeight, + elements: events, + zeroElement: this.emptyElement + } + }); + worker.on("message", resolve); + worker.on("error", reject); + worker.on("exit", (code) => { + if (code !== 0) { + reject(new Error(`Worker stopped with exit code ${code}`)); + } + }); + }); + return lib.MerkleTree.deserialize(JSON.parse(yield merkleWorkerPromise), hashFunction); + } else { + const merkleWorkerPromise = new Promise((resolve, reject) => { + const worker = new Worker(this.merkleWorkerPath); + worker.onmessage = (e) => { + resolve(e.data); + }; + worker.onerror = (e) => { + reject(e); + }; + worker.postMessage({ + merkleTreeHeight: this.merkleTreeHeight, + elements: events, + zeroElement: this.emptyElement + }); + }); + return lib.MerkleTree.deserialize(JSON.parse(yield merkleWorkerPromise), hashFunction); + } + } catch (err) { + console.log("merkleWorker failed, falling back to synchronous merkle tree"); + console.log(err); + } + } + return new lib.MerkleTree(this.merkleTreeHeight, events, { + zeroElement: this.emptyElement, + hashFunction + }); + }); + } + verifyTree(_0) { + return __async$4(this, arguments, function* ({ events }) { + console.log( + ` +Creating deposit tree for ${this.netId} ${this.amount} ${this.currency.toUpperCase()} would take a while +` + ); + console.time("Created tree in"); + const tree = yield this.createTree({ events: events.map(({ commitment }) => BigInt(commitment).toString()) }); + console.timeEnd("Created tree in"); + console.log(""); + const isKnownRoot = yield this.Tornado.isKnownRoot(toFixedHex(BigInt(tree.root))); + if (!isKnownRoot) { + const errMsg = `Deposit Event ${this.netId} ${this.amount} ${this.currency} is invalid`; + throw new Error(errMsg); + } + return tree; + }); + } +} + +const enabledChains = ["1", "10", "56", "100", "137", "42161", "43114", "11155111"]; +const theGraph = { + name: "Hosted Graph", + url: "https://api.thegraph.com" +}; +const tornado = { + name: "Tornado Subgraphs", + url: "https://tornadocash-rpc.com" +}; +const networkConfig = { + netId1: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 80, + fast: 50, + standard: 25, + low: 8 + }, + nativeCurrency: "eth", + currencyName: "ETH", + explorerUrl: { + tx: "https://etherscan.io/tx/", + address: "https://etherscan.io/address/", + block: "https://etherscan.io/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Ethereum Mainnet", + deployedBlock: 9116966, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com" + }, + chainnodes: { + name: "Tornado RPC", + url: "https://mainnet.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + mevblockerRPC: { + name: "MevblockerRPC", + url: "https://rpc.mevblocker.io" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/ethereum-mainnet" + }, + noderealRPC: { + name: "NodeReal RPC", + url: "https://eth-mainnet.nodereal.io/v1/1659dfb40aa24bbb8153a677b98064d7" + }, + notadegenRPC: { + name: "NotADegen RPC", + url: "https://rpc.notadegen.com/eth" + }, + keydonixRPC: { + name: "Keydonix RPC", + url: "https://ethereum.keydonix.com/v1/mainnet" + }, + oneRPC: { + name: "1RPC", + url: "https://1rpc.io/eth" + } + }, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + routerContract: "0xd90e2f925DA726b50C4Ed8D0Fb90Ad053324F31b", + registryContract: "0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2", + echoContract: "0x9B27DD5Bb15d42DC224FCD0B7caEbBe16161Df42", + aggregatorContract: "0xE8F47A78A6D52D317D0D2FFFac56739fE14D1b49", + reverseRecordsContract: "0x3671aE578E63FdF66ad4F3E12CC0c0d71Ac7510C", + tornadoSubgraph: "tornadocash/mainnet-tornado-subgraph", + registrySubgraph: "tornadocash/tornado-relayer-registry", + subgraphs: { + tornado, + theGraph + }, + tokens: { + eth: { + instanceAddress: { + "0.1": "0x12D66f87A04A9E220743712cE6d9bB1B5616B8Fc", + "1": "0x47CE0C6eD5B0Ce3d3A51fdb1C52DC66a7c3c2936", + "10": "0x910Cbd523D972eb0a6f4cAe4618aD62622b39DbF", + "100": "0xA160cdAB225685dA1d56aa342Ad8841c3b53f291" + }, + symbol: "ETH", + decimals: 18 + }, + dai: { + instanceAddress: { + "100": "0xD4B88Df4D29F5CedD6857912842cff3b20C8Cfa3", + "1000": "0xFD8610d20aA15b7B2E3Be39B396a1bC3516c7144", + "10000": "0x07687e702b410Fa43f4cB4Af7FA097918ffD2730", + "100000": "0x23773E65ed146A459791799d01336DB287f25334" + }, + tokenAddress: "0x6B175474E89094C44Da98b954EedeAC495271d0F", + tokenGasLimit: 7e4, + symbol: "DAI", + decimals: 18, + gasLimit: 7e5 + }, + cdai: { + instanceAddress: { + "5000": "0x22aaA7720ddd5388A3c0A3333430953C68f1849b", + "50000": "0x03893a7c7463AE47D46bc7f091665f1893656003", + "500000": "0x2717c5e28cf931547B621a5dddb772Ab6A35B701", + "5000000": "0xD21be7248e0197Ee08E0c20D4a96DEBdaC3D20Af" + }, + tokenAddress: "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643", + tokenGasLimit: 2e5, + symbol: "cDAI", + decimals: 8, + gasLimit: 7e5 + }, + usdc: { + instanceAddress: { + "100": "0xd96f2B1c14Db8458374d9Aca76E26c3D18364307", + "1000": "0x4736dCf1b7A3d580672CcE6E7c65cd5cc9cFBa9D" + }, + tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", + tokenGasLimit: 7e4, + symbol: "USDC", + decimals: 6, + gasLimit: 7e5 + }, + usdt: { + instanceAddress: { + "100": "0x169AD27A470D064DEDE56a2D3ff727986b15D52B", + "1000": "0x0836222F2B2B24A3F36f98668Ed8F0B38D1a872f" + }, + tokenAddress: "0xdAC17F958D2ee523a2206206994597C13D831ec7", + tokenGasLimit: 7e4, + symbol: "USDT", + decimals: 6, + gasLimit: 7e5 + }, + wbtc: { + instanceAddress: { + "0.1": "0x178169B423a011fff22B9e3F3abeA13414dDD0F1", + "1": "0x610B717796ad172B316836AC95a2ffad065CeaB4", + "10": "0xbB93e510BbCD0B7beb5A853875f9eC60275CF498" + }, + tokenAddress: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", + tokenGasLimit: 7e4, + symbol: "WBTC", + decimals: 8, + gasLimit: 7e5 + } + }, + ensSubdomainKey: "mainnet-tornado", + pollInterval: 15, + constants: { + GOVERNANCE_BLOCK: 11474695, + NOTE_ACCOUNT_BLOCK: 11842486, + ENCRYPTED_NOTES_BLOCK: 14248730, + REGISTRY_BLOCK: 14173129, + MINING_BLOCK_TIME: 15 + }, + "torn.contract.tornadocash.eth": "0x77777FeDdddFfC19Ff86DB637967013e6C6A116C", + "governance.contract.tornadocash.eth": "0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce", + "tornado-router.contract.tornadocash.eth": "0xd90e2f925DA726b50C4Ed8D0Fb90Ad053324F31b", + "staking-rewards.contract.tornadocash.eth": "0x5B3f656C80E8ddb9ec01Dd9018815576E9238c29" + }, + netId56: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 5, + fast: 5, + standard: 5, + low: 5 + }, + nativeCurrency: "bnb", + currencyName: "BNB", + explorerUrl: { + tx: "https://bscscan.com/tx/", + address: "https://bscscan.com/address/", + block: "https://bscscan.com/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Binance Smart Chain", + deployedBlock: 8158799, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + tornadoSubgraph: "tornadocash/bsc-tornado-subgraph", + subgraphs: { + tornado, + theGraph + }, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com/bsc" + }, + chainnodes: { + name: "Tornado RPC", + url: "https://bsc-mainnet.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/bsc-mainnet" + }, + noderealRPC: { + name: "NodeReal RPC", + url: "https://bsc-mainnet.nodereal.io/v1/64a9df0874fb4a93b9d0a3849de012d3" + }, + oneRPC: { + name: "1RPC", + url: "https://1rpc.io/bnb" + } + }, + tokens: { + bnb: { + instanceAddress: { + "0.1": "0x84443CFd09A48AF6eF360C6976C5392aC5023a1F", + "1": "0xd47438C816c9E7f2E2888E060936a499Af9582b3", + "10": "0x330bdFADE01eE9bF63C209Ee33102DD334618e0a", + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD" + }, + symbol: "BNB", + decimals: 18 + } + }, + ensSubdomainKey: "bsc-tornado", + pollInterval: 10, + constants: { + NOTE_ACCOUNT_BLOCK: 8159269, + ENCRYPTED_NOTES_BLOCK: 8159269 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId137: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 100, + fast: 75, + standard: 50, + low: 30 + }, + nativeCurrency: "matic", + currencyName: "MATIC", + explorerUrl: { + tx: "https://polygonscan.com/tx/", + address: "https://polygonscan.com/address/", + block: "https://polygonscan.com/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Polygon (Matic) Network", + deployedBlock: 16257962, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + gasPriceOracleContract: "0xF81A8D8D3581985D3969fe53bFA67074aDFa8F3C", + tornadoSubgraph: "tornadocash/matic-tornado-subgraph", + subgraphs: { + tornado, + theGraph + }, + rpcUrls: { + chainnodes: { + name: "Tornado RPC", + url: "https://polygon-mainnet.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/polygon-mainnet" + }, + oneRpc: { + name: "1RPC", + url: "https://1rpc.io/matic" + } + }, + tokens: { + matic: { + instanceAddress: { + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD", + "1000": "0xdf231d99Ff8b6c6CBF4E9B9a945CBAcEF9339178", + "10000": "0xaf4c0B70B2Ea9FB7487C7CbB37aDa259579fe040", + "100000": "0xa5C2254e4253490C54cef0a4347fddb8f75A4998" + }, + symbol: "MATIC", + decimals: 18 + } + }, + ensSubdomainKey: "polygon-tornado", + pollInterval: 10, + constants: { + NOTE_ACCOUNT_BLOCK: 16257996, + ENCRYPTED_NOTES_BLOCK: 16257996 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId10: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 1e-3, + fast: 1e-3, + standard: 1e-3, + low: 1e-3 + }, + nativeCurrency: "eth", + currencyName: "ETH", + explorerUrl: { + tx: "https://optimistic.etherscan.io/tx/", + address: "https://optimistic.etherscan.io/address/", + block: "https://optimistic.etherscan.io/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Optimism", + deployedBlock: 2243689, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + ovmGasPriceOracleContract: "0x420000000000000000000000000000000000000F", + tornadoSubgraph: "tornadocash/optimism-tornado-subgraph", + subgraphs: { + tornado, + theGraph + }, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com/op" + }, + chainnodes: { + name: "Tornado RPC", + url: "https://optimism-mainnet.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + optimism: { + name: "Optimism RPC", + url: "https://mainnet.optimism.io" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/optimism-mainnet" + }, + oneRpc: { + name: "1RPC", + url: "https://1rpc.io/op" + } + }, + tokens: { + eth: { + instanceAddress: { + "0.1": "0x84443CFd09A48AF6eF360C6976C5392aC5023a1F", + "1": "0xd47438C816c9E7f2E2888E060936a499Af9582b3", + "10": "0x330bdFADE01eE9bF63C209Ee33102DD334618e0a", + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD" + }, + symbol: "ETH", + decimals: 18 + } + }, + ensSubdomainKey: "optimism-tornado", + pollInterval: 15, + constants: { + NOTE_ACCOUNT_BLOCK: 2243694, + ENCRYPTED_NOTES_BLOCK: 2243694 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId42161: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 4, + fast: 3, + standard: 2.52, + low: 2.29 + }, + nativeCurrency: "eth", + currencyName: "ETH", + explorerUrl: { + tx: "https://arbiscan.io/tx/", + address: "https://arbiscan.io/address/", + block: "https://arbiscan.io/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Arbitrum One", + deployedBlock: 3430648, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + tornadoSubgraph: "tornadocash/arbitrum-tornado-subgraph", + subgraphs: { + tornado, + theGraph + }, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com/arbitrum" + }, + chainnodes: { + name: "Tornado RPC", + url: "https://arbitrum-one.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + arbitrum: { + name: "Arbitrum RPC", + url: "https://arb1.arbitrum.io/rpc" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/arbitrum-one" + }, + oneRpc: { + name: "1rpc", + url: "https://1rpc.io/arb" + } + }, + tokens: { + eth: { + instanceAddress: { + "0.1": "0x84443CFd09A48AF6eF360C6976C5392aC5023a1F", + "1": "0xd47438C816c9E7f2E2888E060936a499Af9582b3", + "10": "0x330bdFADE01eE9bF63C209Ee33102DD334618e0a", + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD" + }, + symbol: "ETH", + decimals: 18 + } + }, + ensSubdomainKey: "arbitrum-tornado", + pollInterval: 15, + constants: { + NOTE_ACCOUNT_BLOCK: 3430605, + ENCRYPTED_NOTES_BLOCK: 3430605 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId100: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 6, + fast: 5, + standard: 4, + low: 1 + }, + nativeCurrency: "xdai", + currencyName: "xDAI", + explorerUrl: { + tx: "https://blockscout.com/xdai/mainnet/tx/", + address: "https://blockscout.com/xdai/mainnet/address/", + block: "https://blockscout.com/xdai/mainnet/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Gnosis Chain", + deployedBlock: 17754561, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + tornadoSubgraph: "tornadocash/xdai-tornado-subgraph", + subgraphs: { + tornado, + theGraph + }, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com/gnosis" + }, + chainnodes: { + name: "Tornado RPC", + url: "https://gnosis-mainnet.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + gnosis: { + name: "Gnosis RPC", + url: "https://rpc.gnosischain.com" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/arbitrum-one" + }, + blockPi: { + name: "BlockPi", + url: "https://gnosis.blockpi.network/v1/rpc/public" + } + }, + tokens: { + xdai: { + instanceAddress: { + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD", + "1000": "0xdf231d99Ff8b6c6CBF4E9B9a945CBAcEF9339178", + "10000": "0xaf4c0B70B2Ea9FB7487C7CbB37aDa259579fe040", + "100000": "0xa5C2254e4253490C54cef0a4347fddb8f75A4998" + }, + symbol: "xDAI", + decimals: 18 + } + }, + ensSubdomainKey: "gnosis-tornado", + pollInterval: 15, + constants: { + NOTE_ACCOUNT_BLOCK: 17754564, + ENCRYPTED_NOTES_BLOCK: 17754564 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId43114: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 225, + fast: 35, + standard: 25, + low: 25 + }, + nativeCurrency: "avax", + currencyName: "AVAX", + explorerUrl: { + tx: "https://snowtrace.io/tx/", + address: "https://snowtrace.io/address/", + block: "https://snowtrace.io/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Avalanche Mainnet", + deployedBlock: 4429818, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + tornadoSubgraph: "tornadocash/avalanche-tornado-subgraph", + subgraphs: { + theGraph + }, + rpcUrls: { + oneRPC: { + name: "OneRPC", + url: "https://1rpc.io/avax/c" + }, + avalancheRPC: { + name: "Avalanche RPC", + url: "https://api.avax.network/ext/bc/C/rpc" + }, + meowRPC: { + name: "Meow RPC", + url: "https://avax.meowrpc.com" + } + }, + tokens: { + avax: { + instanceAddress: { + "10": "0x330bdFADE01eE9bF63C209Ee33102DD334618e0a", + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD", + "500": "0xaf8d1839c3c67cf571aa74B5c12398d4901147B3" + }, + symbol: "AVAX", + decimals: 18 + } + }, + ensSubdomainKey: "avalanche-tornado", + pollInterval: 10, + constants: { + NOTE_ACCOUNT_BLOCK: 4429813, + ENCRYPTED_NOTES_BLOCK: 4429813 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId11155111: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 2, + fast: 2, + standard: 2, + low: 2 + }, + nativeCurrency: "eth", + currencyName: "SepoliaETH", + explorerUrl: { + tx: "https://sepolia.etherscan.io/tx/", + address: "https://sepolia.etherscan.io/address/", + block: "https://sepolia.etherscan.io/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Ethereum Sepolia", + deployedBlock: 5594395, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + routerContract: "0x1572AFE6949fdF51Cb3E0856216670ae9Ee160Ee", + registryContract: "0x1428e5d2356b13778A13108b10c440C83011dfB8", + echoContract: "0xcDD1fc3F5ac2782D83449d3AbE80D6b7B273B0e5", + aggregatorContract: "0x4088712AC9fad39ea133cdb9130E465d235e9642", + reverseRecordsContract: "0xEc29700C0283e5Be64AcdFe8077d6cC95dE23C23", + tornadoSubgraph: "tornadocash/sepolia-tornado-subgraph", + subgraphs: { + tornado + }, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com/sepolia" + }, + sepolia: { + name: "Sepolia RPC", + url: "https://rpc.sepolia.org" + }, + chainnodes: { + name: "Chainnodes RPC", + url: "https://sepolia.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + } + }, + tokens: { + eth: { + instanceAddress: { + "0.1": "0x8C4A04d872a6C1BE37964A21ba3a138525dFF50b", + "1": "0x8cc930096B4Df705A007c4A039BDFA1320Ed2508", + "10": "0x8D10d506D29Fc62ABb8A290B99F66dB27Fc43585", + "100": "0x44c5C92ed73dB43888210264f0C8b36Fd68D8379" + }, + symbol: "ETH", + decimals: 18 + }, + dai: { + instanceAddress: { + "100": "0x6921fd1a97441dd603a997ED6DDF388658daf754", + "1000": "0x50a637770F5d161999420F7d70d888DE47207145", + "10000": "0xecD649870407cD43923A816Cc6334a5bdf113621", + "100000": "0x73B4BD04bF83206B6e979BE2507098F92EDf4F90" + }, + tokenAddress: "0xFF34B3d4Aee8ddCd6F9AFFFB6Fe49bD371b8a357", + tokenGasLimit: 7e4, + symbol: "DAI", + decimals: 18, + gasLimit: 7e5 + } + }, + ensSubdomainKey: "sepolia-tornado", + pollInterval: 15, + constants: { + GOVERNANCE_BLOCK: 5594395, + NOTE_ACCOUNT_BLOCK: 5594395, + ENCRYPTED_NOTES_BLOCK: 5594395, + MINING_BLOCK_TIME: 15 + }, + "torn.contract.tornadocash.eth": "0x3AE6667167C0f44394106E197904519D808323cA", + "governance.contract.tornadocash.eth": "0xe5324cD7602eeb387418e594B87aCADee08aeCAD", + "tornado-router.contract.tornadocash.eth": "0x1572AFE6949fdF51Cb3E0856216670ae9Ee160Ee" + } +}; +const subdomains = enabledChains.map((chain) => networkConfig[`netId${chain}`].ensSubdomainKey); + +function parseNumber(value) { + if (!value || isNaN(Number(value))) { + throw new InvalidArgumentError("Invalid Number"); + } + return Number(value); +} +function parseUrl(value) { + if (!value || !validateUrl(value, ["http:", "https:"])) { + throw new InvalidArgumentError("Invalid URL"); + } + return value; +} +function parseRelayer(value) { + if (!value || !(value.endsWith(".eth") || validateUrl(value, ["http:", "https:"]))) { + throw new InvalidArgumentError("Invalid Relayer ETH address or URL"); + } + return value; +} +function parseAddress(value) { + if (!value) { + throw new InvalidArgumentError("Invalid Address"); + } + try { + return getAddress(value); + } catch (e) { + throw new InvalidArgumentError("Invalid Address"); + } +} +function parseMnemonic(value) { + if (!value) { + throw new InvalidArgumentError("Invalid Mnemonic"); + } + try { + Mnemonic.fromPhrase(value); + } catch (e) { + throw new InvalidArgumentError("Invalid Mnemonic"); + } + return value; +} +function parseKey(value) { + if (!value) { + throw new InvalidArgumentError("Invalid Private Key"); + } + if (value.length === 64) { + value = "0x" + value; + } + try { + computeAddress(value); + } catch (e) { + throw new InvalidArgumentError("Invalid Private Key"); + } + return value; +} + +class TokenPriceOracle { + constructor(provider, multicall2, oracle) { + this.provider = provider; + this.multicall = multicall2; + this.oracle = oracle; + } + fetchPrices(tokens) { + if (!this.oracle) { + return new Promise((resolve) => resolve(tokens.map(() => parseEther("0.0001")))); + } + return multicall( + this.multicall, + tokens.map((token) => ({ + contract: this.oracle, + name: "getRateToEth", + params: [token, true] + })) + ); + } +} + +var __defProp$1 = Object.defineProperty; +var __defProps$1 = Object.defineProperties; +var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols; +var __hasOwnProp$1 = Object.prototype.hasOwnProperty; +var __propIsEnum$1 = Object.prototype.propertyIsEnumerable; +var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues$1 = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp$1.call(b, prop)) + __defNormalProp$1(a, prop, b[prop]); + if (__getOwnPropSymbols$1) + for (var prop of __getOwnPropSymbols$1(b)) { + if (__propIsEnum$1.call(b, prop)) + __defNormalProp$1(a, prop, b[prop]); + } + return a; +}; +var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b)); +var __async$3 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +const MIN_STAKE_BALANCE = parseEther("500"); +const semVerRegex = new RegExp("^(?0|[1-9]\\d*)\\.(?0|[1-9]\\d*)\\.(?0|[1-9]\\d*)(?:-(?(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+(?[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"); +function parseSemanticVersion(version) { + const { groups } = semVerRegex.exec(version); + return groups; +} +function isRelayerUpdated(relayerVersion, netId) { + const { major, patch, prerelease } = parseSemanticVersion(relayerVersion); + const requiredMajor = netId === 1 ? "4" : "5"; + const isUpdatedMajor = major === requiredMajor; + if (prerelease) + return false; + return isUpdatedMajor && (Number(patch) >= 5 || Number(netId) !== 1); +} +function calculateScore({ stakeBalance, tornadoServiceFee }, minFee = 0.33, maxFee = 0.53) { + if (tornadoServiceFee < minFee) { + tornadoServiceFee = minFee; + } else if (tornadoServiceFee >= maxFee) { + return BigInt(0); + } + const serviceFeeCoefficient = (tornadoServiceFee - minFee) ** 2; + const feeDiffCoefficient = 1 / (maxFee - minFee) ** 2; + const coefficientsMultiplier = 1 - feeDiffCoefficient * serviceFeeCoefficient; + return BigInt(Math.floor(Number(stakeBalance) * coefficientsMultiplier)); +} +function getWeightRandom(weightsScores, random) { + for (let i = 0; i < weightsScores.length; i++) { + if (random < weightsScores[i]) { + return i; + } + random = random - weightsScores[i]; + } + return Math.floor(Math.random() * weightsScores.length); +} +function pickWeightedRandomRelayer(relayers, netId) { + let minFee, maxFee; + if (Number(netId) !== 1) { + minFee = 0.01; + maxFee = 0.3; + } + const weightsScores = relayers.map((el) => calculateScore(el, minFee, maxFee)); + const totalWeight = weightsScores.reduce((acc, curr) => { + return acc = acc + curr; + }, BigInt("0")); + const random = BigInt(Number(totalWeight) * Math.random()); + const weightRandomIndex = getWeightRandom(weightsScores, random); + return relayers[weightRandomIndex]; +} +class RelayerClient { + constructor({ netId, config, Aggregator, fetchDataOptions: fetchDataOptions2 }) { + this.netId = Number(netId); + this.config = config; + this.Aggregator = Aggregator; + this.fetchDataOptions = fetchDataOptions2; + } + askRelayerStatus(_0) { + return __async$3(this, arguments, function* ({ + hostname, + relayerAddress + }) { + var _a, _b; + const url = `https://${!hostname.endsWith("/") ? hostname + "/" : hostname}`; + const rawStatus = yield fetchData(`${url}status`, __spreadProps$1(__spreadValues$1({}, this.fetchDataOptions), { + headers: { + "Content-Type": "application/json, application/x-www-form-urlencoded" + }, + timeout: ((_a = this.fetchDataOptions) == null ? void 0 : _a.torPort) ? 1e4 : 3e3, + maxRetry: ((_b = this.fetchDataOptions) == null ? void 0 : _b.torPort) ? 2 : 0 + })); + const statusValidator = ajv.compile(getStatusSchema(this.netId, this.config)); + if (!statusValidator(rawStatus)) { + throw new Error("Invalid status schema"); + } + const status = __spreadProps$1(__spreadValues$1({}, rawStatus), { + url + }); + if (status.currentQueue > 5) { + throw new Error("Withdrawal queue is overloaded"); + } + if (status.netId !== this.netId) { + throw new Error("This relayer serves a different network"); + } + if (relayerAddress && this.netId === 1 && status.rewardAccount !== relayerAddress) { + throw new Error("The Relayer reward address must match registered address"); + } + if (!isRelayerUpdated(status.version, this.netId)) { + throw new Error("Outdated version."); + } + return status; + }); + } + filterRelayer(curr, relayer, subdomains, debugRelayer = false) { + return __async$3(this, null, function* () { + const { ensSubdomainKey } = this.config; + const subdomainIndex = subdomains.indexOf(ensSubdomainKey); + const mainnetSubdomain = curr.records[0]; + const hostname = curr.records[subdomainIndex]; + const isHostWithProtocol = hostname.includes("http"); + const { owner, balance: stakeBalance, isRegistered } = curr; + const { ensName, relayerAddress } = relayer; + const isOwner = !relayerAddress || relayerAddress === owner; + const hasMinBalance = stakeBalance >= MIN_STAKE_BALANCE; + const preCondition = hostname && isOwner && mainnetSubdomain && isRegistered && hasMinBalance && !isHostWithProtocol; + if (preCondition || debugRelayer) { + try { + const status = yield this.askRelayerStatus({ hostname, relayerAddress }); + return { + netId: status.netId, + url: status.url, + hostname, + ensName, + stakeBalance, + relayerAddress, + rewardAccount: status.rewardAccount, + ethPrices: status.ethPrices, + currentQueue: status.currentQueue, + tornadoServiceFee: status.tornadoServiceFee + }; + } catch (err) { + if (debugRelayer) { + throw err; + } + return { + hostname, + relayerAddress, + errorMessage: err.message + }; + } + } else { + if (debugRelayer) { + const errMsg = `Relayer ${hostname} condition not met`; + throw new Error(errMsg); + } + return { + hostname, + relayerAddress, + errorMessage: `Relayer ${hostname} condition not met` + }; + } + }); + } + getValidRelayers(relayers, subdomains, debugRelayer = false) { + return __async$3(this, null, function* () { + const relayersSet = /* @__PURE__ */ new Set(); + const uniqueRelayers = relayers.reverse().filter(({ ensName }) => { + if (!relayersSet.has(ensName)) { + relayersSet.add(ensName); + return true; + } + return false; + }); + const relayerNameHashes = uniqueRelayers.map((r) => namehash(r.ensName)); + const relayersData = yield this.Aggregator.relayersData.staticCall(relayerNameHashes, subdomains); + const invalidRelayers = []; + const validRelayers = (yield Promise.all( + relayersData.map((curr, index) => this.filterRelayer(curr, uniqueRelayers[index], subdomains, debugRelayer)) + )).filter((r) => { + if (r.errorMessage) { + invalidRelayers.push(r); + return false; + } + return true; + }); + return { + validRelayers, + invalidRelayers + }; + }); + } + pickWeightedRandomRelayer(relayers) { + return pickWeightedRandomRelayer(relayers, this.netId); + } + tornadoWithdraw(_0) { + return __async$3(this, arguments, function* ({ contract, proof, args }) { + const { url } = this.selectedRelayer; + const withdrawResponse = yield fetchData(`${url}v1/tornadoWithdraw`, __spreadProps$1(__spreadValues$1({}, this.fetchDataOptions), { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + contract, + proof, + args + }) + })); + const { id, error } = withdrawResponse; + if (error) { + throw new Error(error); + } + let relayerStatus; + const jobUrl = `${url}v1/jobs/${id}`; + console.log(`Job submitted: ${jobUrl} +`); + while (!relayerStatus || !["FAILED", "CONFIRMED"].includes(relayerStatus)) { + const jobResponse = yield fetchData(jobUrl, __spreadProps$1(__spreadValues$1({}, this.fetchDataOptions), { + method: "GET", + headers: { + "Content-Type": "application/json" + } + })); + if (jobResponse.error) { + throw new Error(error); + } + const jobValidator = ajv.compile(jobsSchema); + if (!jobValidator(jobResponse)) { + const errMsg = `${jobUrl} has an invalid job response`; + throw new Error(errMsg); + } + const { status, txHash, confirmations, failedReason } = jobResponse; + if (relayerStatus !== status) { + if (status === "FAILED") { + const errMsg = `Job ${status}: ${jobUrl} failed reason: ${failedReason}`; + throw new Error(errMsg); + } else if (status === "SENT") { + console.log(`Job ${status}: ${jobUrl}, txhash: ${txHash} +`); + } else if (status === "MINED") { + console.log(`Job ${status}: ${jobUrl}, txhash: ${txHash}, confirmations: ${confirmations} +`); + } else if (status === "CONFIRMED") { + console.log(`Job ${status}: ${jobUrl}, txhash: ${txHash}, confirmations: ${confirmations} +`); + } else { + console.log(`Job ${status}: ${jobUrl} +`); + } + relayerStatus = status; + } + yield sleep$1(3e3); + } + }); + } +} + +var __async$2 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +function getTokenBalances(_0) { + return __async$2(this, arguments, function* ({ + provider, + Multicall: Multicall2, + currencyName, + userAddress, + tokenAddresses = [] + }) { + const tokenCalls = tokenAddresses.map((tokenAddress) => { + const Token = ERC20__factory.connect(tokenAddress, provider); + return [ + { + contract: Token, + name: "balanceOf", + params: [userAddress] + }, + { + contract: Token, + name: "name" + }, + { + contract: Token, + name: "symbol" + }, + { + contract: Token, + name: "decimals" + } + ]; + }).flat(); + const multicallResults = yield multicall(Multicall2, [ + { + contract: Multicall2, + name: "getEthBalance", + params: [userAddress] + }, + ...tokenCalls.length ? tokenCalls : [] + ]); + const ethResults = multicallResults[0]; + const tokenResults = multicallResults.slice(1).length ? chunk(multicallResults.slice(1), tokenCalls.length / tokenAddresses.length) : []; + const tokenBalances = tokenResults.map((tokenResult, index) => { + const [tokenBalance, tokenName, tokenSymbol, tokenDecimals] = tokenResult; + const tokenAddress = tokenAddresses[index]; + return { + address: tokenAddress, + name: tokenName, + symbol: tokenSymbol, + decimals: Number(tokenDecimals), + balance: tokenBalance + }; + }); + return [ + { + address: ZeroAddress, + name: currencyName, + symbol: currencyName, + decimals: 18, + balance: ethResults + }, + ...tokenBalances + ]; + }); +} + +var BigInteger = {exports: {}}; + +(function (module) { + var bigInt = (function (undefined$1) { + + var BASE = 1e7, + LOG_BASE = 7, + MAX_INT = 9007199254740992, + MAX_INT_ARR = smallToArray(MAX_INT), + DEFAULT_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz"; + + var supportsNativeBigInt = typeof BigInt === "function"; + + function Integer(v, radix, alphabet, caseSensitive) { + if (typeof v === "undefined") return Integer[0]; + if (typeof radix !== "undefined") return +radix === 10 && !alphabet ? parseValue(v) : parseBase(v, radix, alphabet, caseSensitive); + return parseValue(v); + } + + function BigInteger(value, sign) { + this.value = value; + this.sign = sign; + this.isSmall = false; + } + BigInteger.prototype = Object.create(Integer.prototype); + + function SmallInteger(value) { + this.value = value; + this.sign = value < 0; + this.isSmall = true; + } + SmallInteger.prototype = Object.create(Integer.prototype); + + function NativeBigInt(value) { + this.value = value; + } + NativeBigInt.prototype = Object.create(Integer.prototype); + + function isPrecise(n) { + return -MAX_INT < n && n < MAX_INT; + } + + function smallToArray(n) { // For performance reasons doesn't reference BASE, need to change this function if BASE changes + if (n < 1e7) + return [n]; + if (n < 1e14) + return [n % 1e7, Math.floor(n / 1e7)]; + return [n % 1e7, Math.floor(n / 1e7) % 1e7, Math.floor(n / 1e14)]; + } + + function arrayToSmall(arr) { // If BASE changes this function may need to change + trim(arr); + var length = arr.length; + if (length < 4 && compareAbs(arr, MAX_INT_ARR) < 0) { + switch (length) { + case 0: return 0; + case 1: return arr[0]; + case 2: return arr[0] + arr[1] * BASE; + default: return arr[0] + (arr[1] + arr[2] * BASE) * BASE; + } + } + return arr; + } + + function trim(v) { + var i = v.length; + while (v[--i] === 0); + v.length = i + 1; + } + + function createArray(length) { // function shamelessly stolen from Yaffle's library https://github.com/Yaffle/BigInteger + var x = new Array(length); + var i = -1; + while (++i < length) { + x[i] = 0; + } + return x; + } + + function truncate(n) { + if (n > 0) return Math.floor(n); + return Math.ceil(n); + } + + function add(a, b) { // assumes a and b are arrays with a.length >= b.length + var l_a = a.length, + l_b = b.length, + r = new Array(l_a), + carry = 0, + base = BASE, + sum, i; + for (i = 0; i < l_b; i++) { + sum = a[i] + b[i] + carry; + carry = sum >= base ? 1 : 0; + r[i] = sum - carry * base; + } + while (i < l_a) { + sum = a[i] + carry; + carry = sum === base ? 1 : 0; + r[i++] = sum - carry * base; + } + if (carry > 0) r.push(carry); + return r; + } + + function addAny(a, b) { + if (a.length >= b.length) return add(a, b); + return add(b, a); + } + + function addSmall(a, carry) { // assumes a is array, carry is number with 0 <= carry < MAX_INT + var l = a.length, + r = new Array(l), + base = BASE, + sum, i; + for (i = 0; i < l; i++) { + sum = a[i] - base + carry; + carry = Math.floor(sum / base); + r[i] = sum - carry * base; + carry += 1; + } + while (carry > 0) { + r[i++] = carry % base; + carry = Math.floor(carry / base); + } + return r; + } + + BigInteger.prototype.add = function (v) { + var n = parseValue(v); + if (this.sign !== n.sign) { + return this.subtract(n.negate()); + } + var a = this.value, b = n.value; + if (n.isSmall) { + return new BigInteger(addSmall(a, Math.abs(b)), this.sign); + } + return new BigInteger(addAny(a, b), this.sign); + }; + BigInteger.prototype.plus = BigInteger.prototype.add; + + SmallInteger.prototype.add = function (v) { + var n = parseValue(v); + var a = this.value; + if (a < 0 !== n.sign) { + return this.subtract(n.negate()); + } + var b = n.value; + if (n.isSmall) { + if (isPrecise(a + b)) return new SmallInteger(a + b); + b = smallToArray(Math.abs(b)); + } + return new BigInteger(addSmall(b, Math.abs(a)), a < 0); + }; + SmallInteger.prototype.plus = SmallInteger.prototype.add; + + NativeBigInt.prototype.add = function (v) { + return new NativeBigInt(this.value + parseValue(v).value); + }; + NativeBigInt.prototype.plus = NativeBigInt.prototype.add; + + function subtract(a, b) { // assumes a and b are arrays with a >= b + var a_l = a.length, + b_l = b.length, + r = new Array(a_l), + borrow = 0, + base = BASE, + i, difference; + for (i = 0; i < b_l; i++) { + difference = a[i] - borrow - b[i]; + if (difference < 0) { + difference += base; + borrow = 1; + } else borrow = 0; + r[i] = difference; + } + for (i = b_l; i < a_l; i++) { + difference = a[i] - borrow; + if (difference < 0) difference += base; + else { + r[i++] = difference; + break; + } + r[i] = difference; + } + for (; i < a_l; i++) { + r[i] = a[i]; + } + trim(r); + return r; + } + + function subtractAny(a, b, sign) { + var value; + if (compareAbs(a, b) >= 0) { + value = subtract(a, b); + } else { + value = subtract(b, a); + sign = !sign; + } + value = arrayToSmall(value); + if (typeof value === "number") { + if (sign) value = -value; + return new SmallInteger(value); + } + return new BigInteger(value, sign); + } + + function subtractSmall(a, b, sign) { // assumes a is array, b is number with 0 <= b < MAX_INT + var l = a.length, + r = new Array(l), + carry = -b, + base = BASE, + i, difference; + for (i = 0; i < l; i++) { + difference = a[i] + carry; + carry = Math.floor(difference / base); + difference %= base; + r[i] = difference < 0 ? difference + base : difference; + } + r = arrayToSmall(r); + if (typeof r === "number") { + if (sign) r = -r; + return new SmallInteger(r); + } return new BigInteger(r, sign); + } + + BigInteger.prototype.subtract = function (v) { + var n = parseValue(v); + if (this.sign !== n.sign) { + return this.add(n.negate()); + } + var a = this.value, b = n.value; + if (n.isSmall) + return subtractSmall(a, Math.abs(b), this.sign); + return subtractAny(a, b, this.sign); + }; + BigInteger.prototype.minus = BigInteger.prototype.subtract; + + SmallInteger.prototype.subtract = function (v) { + var n = parseValue(v); + var a = this.value; + if (a < 0 !== n.sign) { + return this.add(n.negate()); + } + var b = n.value; + if (n.isSmall) { + return new SmallInteger(a - b); + } + return subtractSmall(b, Math.abs(a), a >= 0); + }; + SmallInteger.prototype.minus = SmallInteger.prototype.subtract; + + NativeBigInt.prototype.subtract = function (v) { + return new NativeBigInt(this.value - parseValue(v).value); + }; + NativeBigInt.prototype.minus = NativeBigInt.prototype.subtract; + + BigInteger.prototype.negate = function () { + return new BigInteger(this.value, !this.sign); + }; + SmallInteger.prototype.negate = function () { + var sign = this.sign; + var small = new SmallInteger(-this.value); + small.sign = !sign; + return small; + }; + NativeBigInt.prototype.negate = function () { + return new NativeBigInt(-this.value); + }; + + BigInteger.prototype.abs = function () { + return new BigInteger(this.value, false); + }; + SmallInteger.prototype.abs = function () { + return new SmallInteger(Math.abs(this.value)); + }; + NativeBigInt.prototype.abs = function () { + return new NativeBigInt(this.value >= 0 ? this.value : -this.value); + }; + + + function multiplyLong(a, b) { + var a_l = a.length, + b_l = b.length, + l = a_l + b_l, + r = createArray(l), + base = BASE, + product, carry, i, a_i, b_j; + for (i = 0; i < a_l; ++i) { + a_i = a[i]; + for (var j = 0; j < b_l; ++j) { + b_j = b[j]; + product = a_i * b_j + r[i + j]; + carry = Math.floor(product / base); + r[i + j] = product - carry * base; + r[i + j + 1] += carry; + } + } + trim(r); + return r; + } + + function multiplySmall(a, b) { // assumes a is array, b is number with |b| < BASE + var l = a.length, + r = new Array(l), + base = BASE, + carry = 0, + product, i; + for (i = 0; i < l; i++) { + product = a[i] * b + carry; + carry = Math.floor(product / base); + r[i] = product - carry * base; + } + while (carry > 0) { + r[i++] = carry % base; + carry = Math.floor(carry / base); + } + return r; + } + + function shiftLeft(x, n) { + var r = []; + while (n-- > 0) r.push(0); + return r.concat(x); + } + + function multiplyKaratsuba(x, y) { + var n = Math.max(x.length, y.length); + + if (n <= 30) return multiplyLong(x, y); + n = Math.ceil(n / 2); + + var b = x.slice(n), + a = x.slice(0, n), + d = y.slice(n), + c = y.slice(0, n); + + var ac = multiplyKaratsuba(a, c), + bd = multiplyKaratsuba(b, d), + abcd = multiplyKaratsuba(addAny(a, b), addAny(c, d)); + + var product = addAny(addAny(ac, shiftLeft(subtract(subtract(abcd, ac), bd), n)), shiftLeft(bd, 2 * n)); + trim(product); + return product; + } + + // The following function is derived from a surface fit of a graph plotting the performance difference + // between long multiplication and karatsuba multiplication versus the lengths of the two arrays. + function useKaratsuba(l1, l2) { + return -0.012 * l1 - 0.012 * l2 + 0.000015 * l1 * l2 > 0; + } + + BigInteger.prototype.multiply = function (v) { + var n = parseValue(v), + a = this.value, b = n.value, + sign = this.sign !== n.sign, + abs; + if (n.isSmall) { + if (b === 0) return Integer[0]; + if (b === 1) return this; + if (b === -1) return this.negate(); + abs = Math.abs(b); + if (abs < BASE) { + return new BigInteger(multiplySmall(a, abs), sign); + } + b = smallToArray(abs); + } + if (useKaratsuba(a.length, b.length)) // Karatsuba is only faster for certain array sizes + return new BigInteger(multiplyKaratsuba(a, b), sign); + return new BigInteger(multiplyLong(a, b), sign); + }; + + BigInteger.prototype.times = BigInteger.prototype.multiply; + + function multiplySmallAndArray(a, b, sign) { // a >= 0 + if (a < BASE) { + return new BigInteger(multiplySmall(b, a), sign); + } + return new BigInteger(multiplyLong(b, smallToArray(a)), sign); + } + SmallInteger.prototype._multiplyBySmall = function (a) { + if (isPrecise(a.value * this.value)) { + return new SmallInteger(a.value * this.value); + } + return multiplySmallAndArray(Math.abs(a.value), smallToArray(Math.abs(this.value)), this.sign !== a.sign); + }; + BigInteger.prototype._multiplyBySmall = function (a) { + if (a.value === 0) return Integer[0]; + if (a.value === 1) return this; + if (a.value === -1) return this.negate(); + return multiplySmallAndArray(Math.abs(a.value), this.value, this.sign !== a.sign); + }; + SmallInteger.prototype.multiply = function (v) { + return parseValue(v)._multiplyBySmall(this); + }; + SmallInteger.prototype.times = SmallInteger.prototype.multiply; + + NativeBigInt.prototype.multiply = function (v) { + return new NativeBigInt(this.value * parseValue(v).value); + }; + NativeBigInt.prototype.times = NativeBigInt.prototype.multiply; + + function square(a) { + //console.assert(2 * BASE * BASE < MAX_INT); + var l = a.length, + r = createArray(l + l), + base = BASE, + product, carry, i, a_i, a_j; + for (i = 0; i < l; i++) { + a_i = a[i]; + carry = 0 - a_i * a_i; + for (var j = i; j < l; j++) { + a_j = a[j]; + product = 2 * (a_i * a_j) + r[i + j] + carry; + carry = Math.floor(product / base); + r[i + j] = product - carry * base; + } + r[i + l] = carry; + } + trim(r); + return r; + } + + BigInteger.prototype.square = function () { + return new BigInteger(square(this.value), false); + }; + + SmallInteger.prototype.square = function () { + var value = this.value * this.value; + if (isPrecise(value)) return new SmallInteger(value); + return new BigInteger(square(smallToArray(Math.abs(this.value))), false); + }; + + NativeBigInt.prototype.square = function (v) { + return new NativeBigInt(this.value * this.value); + }; + + function divMod1(a, b) { // Left over from previous version. Performs faster than divMod2 on smaller input sizes. + var a_l = a.length, + b_l = b.length, + base = BASE, + result = createArray(b.length), + divisorMostSignificantDigit = b[b_l - 1], + // normalization + lambda = Math.ceil(base / (2 * divisorMostSignificantDigit)), + remainder = multiplySmall(a, lambda), + divisor = multiplySmall(b, lambda), + quotientDigit, shift, carry, borrow, i, l, q; + if (remainder.length <= a_l) remainder.push(0); + divisor.push(0); + divisorMostSignificantDigit = divisor[b_l - 1]; + for (shift = a_l - b_l; shift >= 0; shift--) { + quotientDigit = base - 1; + if (remainder[shift + b_l] !== divisorMostSignificantDigit) { + quotientDigit = Math.floor((remainder[shift + b_l] * base + remainder[shift + b_l - 1]) / divisorMostSignificantDigit); + } + // quotientDigit <= base - 1 + carry = 0; + borrow = 0; + l = divisor.length; + for (i = 0; i < l; i++) { + carry += quotientDigit * divisor[i]; + q = Math.floor(carry / base); + borrow += remainder[shift + i] - (carry - q * base); + carry = q; + if (borrow < 0) { + remainder[shift + i] = borrow + base; + borrow = -1; + } else { + remainder[shift + i] = borrow; + borrow = 0; + } + } + while (borrow !== 0) { + quotientDigit -= 1; + carry = 0; + for (i = 0; i < l; i++) { + carry += remainder[shift + i] - base + divisor[i]; + if (carry < 0) { + remainder[shift + i] = carry + base; + carry = 0; + } else { + remainder[shift + i] = carry; + carry = 1; + } + } + borrow += carry; + } + result[shift] = quotientDigit; + } + // denormalization + remainder = divModSmall(remainder, lambda)[0]; + return [arrayToSmall(result), arrayToSmall(remainder)]; + } + + function divMod2(a, b) { // Implementation idea shamelessly stolen from Silent Matt's library http://silentmatt.com/biginteger/ + // Performs faster than divMod1 on larger input sizes. + var a_l = a.length, + b_l = b.length, + result = [], + part = [], + base = BASE, + guess, xlen, highx, highy, check; + while (a_l) { + part.unshift(a[--a_l]); + trim(part); + if (compareAbs(part, b) < 0) { + result.push(0); + continue; + } + xlen = part.length; + highx = part[xlen - 1] * base + part[xlen - 2]; + highy = b[b_l - 1] * base + b[b_l - 2]; + if (xlen > b_l) { + highx = (highx + 1) * base; + } + guess = Math.ceil(highx / highy); + do { + check = multiplySmall(b, guess); + if (compareAbs(check, part) <= 0) break; + guess--; + } while (guess); + result.push(guess); + part = subtract(part, check); + } + result.reverse(); + return [arrayToSmall(result), arrayToSmall(part)]; + } + + function divModSmall(value, lambda) { + var length = value.length, + quotient = createArray(length), + base = BASE, + i, q, remainder, divisor; + remainder = 0; + for (i = length - 1; i >= 0; --i) { + divisor = remainder * base + value[i]; + q = truncate(divisor / lambda); + remainder = divisor - q * lambda; + quotient[i] = q | 0; + } + return [quotient, remainder | 0]; + } + + function divModAny(self, v) { + var value, n = parseValue(v); + if (supportsNativeBigInt) { + return [new NativeBigInt(self.value / n.value), new NativeBigInt(self.value % n.value)]; + } + var a = self.value, b = n.value; + var quotient; + if (b === 0) throw new Error("Cannot divide by zero"); + if (self.isSmall) { + if (n.isSmall) { + return [new SmallInteger(truncate(a / b)), new SmallInteger(a % b)]; + } + return [Integer[0], self]; + } + if (n.isSmall) { + if (b === 1) return [self, Integer[0]]; + if (b == -1) return [self.negate(), Integer[0]]; + var abs = Math.abs(b); + if (abs < BASE) { + value = divModSmall(a, abs); + quotient = arrayToSmall(value[0]); + var remainder = value[1]; + if (self.sign) remainder = -remainder; + if (typeof quotient === "number") { + if (self.sign !== n.sign) quotient = -quotient; + return [new SmallInteger(quotient), new SmallInteger(remainder)]; + } + return [new BigInteger(quotient, self.sign !== n.sign), new SmallInteger(remainder)]; + } + b = smallToArray(abs); + } + var comparison = compareAbs(a, b); + if (comparison === -1) return [Integer[0], self]; + if (comparison === 0) return [Integer[self.sign === n.sign ? 1 : -1], Integer[0]]; + + // divMod1 is faster on smaller input sizes + if (a.length + b.length <= 200) + value = divMod1(a, b); + else value = divMod2(a, b); + + quotient = value[0]; + var qSign = self.sign !== n.sign, + mod = value[1], + mSign = self.sign; + if (typeof quotient === "number") { + if (qSign) quotient = -quotient; + quotient = new SmallInteger(quotient); + } else quotient = new BigInteger(quotient, qSign); + if (typeof mod === "number") { + if (mSign) mod = -mod; + mod = new SmallInteger(mod); + } else mod = new BigInteger(mod, mSign); + return [quotient, mod]; + } + + BigInteger.prototype.divmod = function (v) { + var result = divModAny(this, v); + return { + quotient: result[0], + remainder: result[1] + }; + }; + NativeBigInt.prototype.divmod = SmallInteger.prototype.divmod = BigInteger.prototype.divmod; + + + BigInteger.prototype.divide = function (v) { + return divModAny(this, v)[0]; + }; + NativeBigInt.prototype.over = NativeBigInt.prototype.divide = function (v) { + return new NativeBigInt(this.value / parseValue(v).value); + }; + SmallInteger.prototype.over = SmallInteger.prototype.divide = BigInteger.prototype.over = BigInteger.prototype.divide; + + BigInteger.prototype.mod = function (v) { + return divModAny(this, v)[1]; + }; + NativeBigInt.prototype.mod = NativeBigInt.prototype.remainder = function (v) { + return new NativeBigInt(this.value % parseValue(v).value); + }; + SmallInteger.prototype.remainder = SmallInteger.prototype.mod = BigInteger.prototype.remainder = BigInteger.prototype.mod; + + BigInteger.prototype.pow = function (v) { + var n = parseValue(v), + a = this.value, + b = n.value, + value, x, y; + if (b === 0) return Integer[1]; + if (a === 0) return Integer[0]; + if (a === 1) return Integer[1]; + if (a === -1) return n.isEven() ? Integer[1] : Integer[-1]; + if (n.sign) { + return Integer[0]; + } + if (!n.isSmall) throw new Error("The exponent " + n.toString() + " is too large."); + if (this.isSmall) { + if (isPrecise(value = Math.pow(a, b))) + return new SmallInteger(truncate(value)); + } + x = this; + y = Integer[1]; + while (true) { + if (b & 1 === 1) { + y = y.times(x); + --b; + } + if (b === 0) break; + b /= 2; + x = x.square(); + } + return y; + }; + SmallInteger.prototype.pow = BigInteger.prototype.pow; + + NativeBigInt.prototype.pow = function (v) { + var n = parseValue(v); + var a = this.value, b = n.value; + var _0 = BigInt(0), _1 = BigInt(1), _2 = BigInt(2); + if (b === _0) return Integer[1]; + if (a === _0) return Integer[0]; + if (a === _1) return Integer[1]; + if (a === BigInt(-1)) return n.isEven() ? Integer[1] : Integer[-1]; + if (n.isNegative()) return new NativeBigInt(_0); + var x = this; + var y = Integer[1]; + while (true) { + if ((b & _1) === _1) { + y = y.times(x); + --b; + } + if (b === _0) break; + b /= _2; + x = x.square(); + } + return y; + }; + + BigInteger.prototype.modPow = function (exp, mod) { + exp = parseValue(exp); + mod = parseValue(mod); + if (mod.isZero()) throw new Error("Cannot take modPow with modulus 0"); + var r = Integer[1], + base = this.mod(mod); + while (exp.isPositive()) { + if (base.isZero()) return Integer[0]; + if (exp.isOdd()) r = r.multiply(base).mod(mod); + exp = exp.divide(2); + base = base.square().mod(mod); + } + return r; + }; + NativeBigInt.prototype.modPow = SmallInteger.prototype.modPow = BigInteger.prototype.modPow; + + function compareAbs(a, b) { + if (a.length !== b.length) { + return a.length > b.length ? 1 : -1; + } + for (var i = a.length - 1; i >= 0; i--) { + if (a[i] !== b[i]) return a[i] > b[i] ? 1 : -1; + } + return 0; + } + + BigInteger.prototype.compareAbs = function (v) { + var n = parseValue(v), + a = this.value, + b = n.value; + if (n.isSmall) return 1; + return compareAbs(a, b); + }; + SmallInteger.prototype.compareAbs = function (v) { + var n = parseValue(v), + a = Math.abs(this.value), + b = n.value; + if (n.isSmall) { + b = Math.abs(b); + return a === b ? 0 : a > b ? 1 : -1; + } + return -1; + }; + NativeBigInt.prototype.compareAbs = function (v) { + var a = this.value; + var b = parseValue(v).value; + a = a >= 0 ? a : -a; + b = b >= 0 ? b : -b; + return a === b ? 0 : a > b ? 1 : -1; + }; + + BigInteger.prototype.compare = function (v) { + // See discussion about comparison with Infinity: + // https://github.com/peterolson/BigInteger.js/issues/61 + if (v === Infinity) { + return -1; + } + if (v === -Infinity) { + return 1; + } + + var n = parseValue(v), + a = this.value, + b = n.value; + if (this.sign !== n.sign) { + return n.sign ? 1 : -1; + } + if (n.isSmall) { + return this.sign ? -1 : 1; + } + return compareAbs(a, b) * (this.sign ? -1 : 1); + }; + BigInteger.prototype.compareTo = BigInteger.prototype.compare; + + SmallInteger.prototype.compare = function (v) { + if (v === Infinity) { + return -1; + } + if (v === -Infinity) { + return 1; + } + + var n = parseValue(v), + a = this.value, + b = n.value; + if (n.isSmall) { + return a == b ? 0 : a > b ? 1 : -1; + } + if (a < 0 !== n.sign) { + return a < 0 ? -1 : 1; + } + return a < 0 ? 1 : -1; + }; + SmallInteger.prototype.compareTo = SmallInteger.prototype.compare; + + NativeBigInt.prototype.compare = function (v) { + if (v === Infinity) { + return -1; + } + if (v === -Infinity) { + return 1; + } + var a = this.value; + var b = parseValue(v).value; + return a === b ? 0 : a > b ? 1 : -1; + }; + NativeBigInt.prototype.compareTo = NativeBigInt.prototype.compare; + + BigInteger.prototype.equals = function (v) { + return this.compare(v) === 0; + }; + NativeBigInt.prototype.eq = NativeBigInt.prototype.equals = SmallInteger.prototype.eq = SmallInteger.prototype.equals = BigInteger.prototype.eq = BigInteger.prototype.equals; + + BigInteger.prototype.notEquals = function (v) { + return this.compare(v) !== 0; + }; + NativeBigInt.prototype.neq = NativeBigInt.prototype.notEquals = SmallInteger.prototype.neq = SmallInteger.prototype.notEquals = BigInteger.prototype.neq = BigInteger.prototype.notEquals; + + BigInteger.prototype.greater = function (v) { + return this.compare(v) > 0; + }; + NativeBigInt.prototype.gt = NativeBigInt.prototype.greater = SmallInteger.prototype.gt = SmallInteger.prototype.greater = BigInteger.prototype.gt = BigInteger.prototype.greater; + + BigInteger.prototype.lesser = function (v) { + return this.compare(v) < 0; + }; + NativeBigInt.prototype.lt = NativeBigInt.prototype.lesser = SmallInteger.prototype.lt = SmallInteger.prototype.lesser = BigInteger.prototype.lt = BigInteger.prototype.lesser; + + BigInteger.prototype.greaterOrEquals = function (v) { + return this.compare(v) >= 0; + }; + NativeBigInt.prototype.geq = NativeBigInt.prototype.greaterOrEquals = SmallInteger.prototype.geq = SmallInteger.prototype.greaterOrEquals = BigInteger.prototype.geq = BigInteger.prototype.greaterOrEquals; + + BigInteger.prototype.lesserOrEquals = function (v) { + return this.compare(v) <= 0; + }; + NativeBigInt.prototype.leq = NativeBigInt.prototype.lesserOrEquals = SmallInteger.prototype.leq = SmallInteger.prototype.lesserOrEquals = BigInteger.prototype.leq = BigInteger.prototype.lesserOrEquals; + + BigInteger.prototype.isEven = function () { + return (this.value[0] & 1) === 0; + }; + SmallInteger.prototype.isEven = function () { + return (this.value & 1) === 0; + }; + NativeBigInt.prototype.isEven = function () { + return (this.value & BigInt(1)) === BigInt(0); + }; + + BigInteger.prototype.isOdd = function () { + return (this.value[0] & 1) === 1; + }; + SmallInteger.prototype.isOdd = function () { + return (this.value & 1) === 1; + }; + NativeBigInt.prototype.isOdd = function () { + return (this.value & BigInt(1)) === BigInt(1); + }; + + BigInteger.prototype.isPositive = function () { + return !this.sign; + }; + SmallInteger.prototype.isPositive = function () { + return this.value > 0; + }; + NativeBigInt.prototype.isPositive = SmallInteger.prototype.isPositive; + + BigInteger.prototype.isNegative = function () { + return this.sign; + }; + SmallInteger.prototype.isNegative = function () { + return this.value < 0; + }; + NativeBigInt.prototype.isNegative = SmallInteger.prototype.isNegative; + + BigInteger.prototype.isUnit = function () { + return false; + }; + SmallInteger.prototype.isUnit = function () { + return Math.abs(this.value) === 1; + }; + NativeBigInt.prototype.isUnit = function () { + return this.abs().value === BigInt(1); + }; + + BigInteger.prototype.isZero = function () { + return false; + }; + SmallInteger.prototype.isZero = function () { + return this.value === 0; + }; + NativeBigInt.prototype.isZero = function () { + return this.value === BigInt(0); + }; + + BigInteger.prototype.isDivisibleBy = function (v) { + var n = parseValue(v); + if (n.isZero()) return false; + if (n.isUnit()) return true; + if (n.compareAbs(2) === 0) return this.isEven(); + return this.mod(n).isZero(); + }; + NativeBigInt.prototype.isDivisibleBy = SmallInteger.prototype.isDivisibleBy = BigInteger.prototype.isDivisibleBy; + + function isBasicPrime(v) { + var n = v.abs(); + if (n.isUnit()) return false; + if (n.equals(2) || n.equals(3) || n.equals(5)) return true; + if (n.isEven() || n.isDivisibleBy(3) || n.isDivisibleBy(5)) return false; + if (n.lesser(49)) return true; + // we don't know if it's prime: let the other functions figure it out + } + + function millerRabinTest(n, a) { + var nPrev = n.prev(), + b = nPrev, + r = 0, + d, i, x; + while (b.isEven()) b = b.divide(2), r++; + next: for (i = 0; i < a.length; i++) { + if (n.lesser(a[i])) continue; + x = bigInt(a[i]).modPow(b, n); + if (x.isUnit() || x.equals(nPrev)) continue; + for (d = r - 1; d != 0; d--) { + x = x.square().mod(n); + if (x.isUnit()) return false; + if (x.equals(nPrev)) continue next; + } + return false; + } + return true; + } + + // Set "strict" to true to force GRH-supported lower bound of 2*log(N)^2 + BigInteger.prototype.isPrime = function (strict) { + var isPrime = isBasicPrime(this); + if (isPrime !== undefined$1) return isPrime; + var n = this.abs(); + var bits = n.bitLength(); + if (bits <= 64) + return millerRabinTest(n, [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]); + var logN = Math.log(2) * bits.toJSNumber(); + var t = Math.ceil((strict === true) ? (2 * Math.pow(logN, 2)) : logN); + for (var a = [], i = 0; i < t; i++) { + a.push(bigInt(i + 2)); + } + return millerRabinTest(n, a); + }; + NativeBigInt.prototype.isPrime = SmallInteger.prototype.isPrime = BigInteger.prototype.isPrime; + + BigInteger.prototype.isProbablePrime = function (iterations) { + var isPrime = isBasicPrime(this); + if (isPrime !== undefined$1) return isPrime; + var n = this.abs(); + var t = iterations === undefined$1 ? 5 : iterations; + for (var a = [], i = 0; i < t; i++) { + a.push(bigInt.randBetween(2, n.minus(2))); + } + return millerRabinTest(n, a); + }; + NativeBigInt.prototype.isProbablePrime = SmallInteger.prototype.isProbablePrime = BigInteger.prototype.isProbablePrime; + + BigInteger.prototype.modInv = function (n) { + var t = bigInt.zero, newT = bigInt.one, r = parseValue(n), newR = this.abs(), q, lastT, lastR; + while (!newR.isZero()) { + q = r.divide(newR); + lastT = t; + lastR = r; + t = newT; + r = newR; + newT = lastT.subtract(q.multiply(newT)); + newR = lastR.subtract(q.multiply(newR)); + } + if (!r.isUnit()) throw new Error(this.toString() + " and " + n.toString() + " are not co-prime"); + if (t.compare(0) === -1) { + t = t.add(n); + } + if (this.isNegative()) { + return t.negate(); + } + return t; + }; + + NativeBigInt.prototype.modInv = SmallInteger.prototype.modInv = BigInteger.prototype.modInv; + + BigInteger.prototype.next = function () { + var value = this.value; + if (this.sign) { + return subtractSmall(value, 1, this.sign); + } + return new BigInteger(addSmall(value, 1), this.sign); + }; + SmallInteger.prototype.next = function () { + var value = this.value; + if (value + 1 < MAX_INT) return new SmallInteger(value + 1); + return new BigInteger(MAX_INT_ARR, false); + }; + NativeBigInt.prototype.next = function () { + return new NativeBigInt(this.value + BigInt(1)); + }; + + BigInteger.prototype.prev = function () { + var value = this.value; + if (this.sign) { + return new BigInteger(addSmall(value, 1), true); + } + return subtractSmall(value, 1, this.sign); + }; + SmallInteger.prototype.prev = function () { + var value = this.value; + if (value - 1 > -MAX_INT) return new SmallInteger(value - 1); + return new BigInteger(MAX_INT_ARR, true); + }; + NativeBigInt.prototype.prev = function () { + return new NativeBigInt(this.value - BigInt(1)); + }; + + var powersOfTwo = [1]; + while (2 * powersOfTwo[powersOfTwo.length - 1] <= BASE) powersOfTwo.push(2 * powersOfTwo[powersOfTwo.length - 1]); + var powers2Length = powersOfTwo.length, highestPower2 = powersOfTwo[powers2Length - 1]; + + function shift_isSmall(n) { + return Math.abs(n) <= BASE; + } + + BigInteger.prototype.shiftLeft = function (v) { + var n = parseValue(v).toJSNumber(); + if (!shift_isSmall(n)) { + throw new Error(String(n) + " is too large for shifting."); + } + if (n < 0) return this.shiftRight(-n); + var result = this; + if (result.isZero()) return result; + while (n >= powers2Length) { + result = result.multiply(highestPower2); + n -= powers2Length - 1; + } + return result.multiply(powersOfTwo[n]); + }; + NativeBigInt.prototype.shiftLeft = SmallInteger.prototype.shiftLeft = BigInteger.prototype.shiftLeft; + + BigInteger.prototype.shiftRight = function (v) { + var remQuo; + var n = parseValue(v).toJSNumber(); + if (!shift_isSmall(n)) { + throw new Error(String(n) + " is too large for shifting."); + } + if (n < 0) return this.shiftLeft(-n); + var result = this; + while (n >= powers2Length) { + if (result.isZero() || (result.isNegative() && result.isUnit())) return result; + remQuo = divModAny(result, highestPower2); + result = remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0]; + n -= powers2Length - 1; + } + remQuo = divModAny(result, powersOfTwo[n]); + return remQuo[1].isNegative() ? remQuo[0].prev() : remQuo[0]; + }; + NativeBigInt.prototype.shiftRight = SmallInteger.prototype.shiftRight = BigInteger.prototype.shiftRight; + + function bitwise(x, y, fn) { + y = parseValue(y); + var xSign = x.isNegative(), ySign = y.isNegative(); + var xRem = xSign ? x.not() : x, + yRem = ySign ? y.not() : y; + var xDigit = 0, yDigit = 0; + var xDivMod = null, yDivMod = null; + var result = []; + while (!xRem.isZero() || !yRem.isZero()) { + xDivMod = divModAny(xRem, highestPower2); + xDigit = xDivMod[1].toJSNumber(); + if (xSign) { + xDigit = highestPower2 - 1 - xDigit; // two's complement for negative numbers + } + + yDivMod = divModAny(yRem, highestPower2); + yDigit = yDivMod[1].toJSNumber(); + if (ySign) { + yDigit = highestPower2 - 1 - yDigit; // two's complement for negative numbers + } + + xRem = xDivMod[0]; + yRem = yDivMod[0]; + result.push(fn(xDigit, yDigit)); + } + var sum = fn(xSign ? 1 : 0, ySign ? 1 : 0) !== 0 ? bigInt(-1) : bigInt(0); + for (var i = result.length - 1; i >= 0; i -= 1) { + sum = sum.multiply(highestPower2).add(bigInt(result[i])); + } + return sum; + } + + BigInteger.prototype.not = function () { + return this.negate().prev(); + }; + NativeBigInt.prototype.not = SmallInteger.prototype.not = BigInteger.prototype.not; + + BigInteger.prototype.and = function (n) { + return bitwise(this, n, function (a, b) { return a & b; }); + }; + NativeBigInt.prototype.and = SmallInteger.prototype.and = BigInteger.prototype.and; + + BigInteger.prototype.or = function (n) { + return bitwise(this, n, function (a, b) { return a | b; }); + }; + NativeBigInt.prototype.or = SmallInteger.prototype.or = BigInteger.prototype.or; + + BigInteger.prototype.xor = function (n) { + return bitwise(this, n, function (a, b) { return a ^ b; }); + }; + NativeBigInt.prototype.xor = SmallInteger.prototype.xor = BigInteger.prototype.xor; + + var LOBMASK_I = 1 << 30, LOBMASK_BI = (BASE & -BASE) * (BASE & -BASE) | LOBMASK_I; + function roughLOB(n) { // get lowestOneBit (rough) + // SmallInteger: return Min(lowestOneBit(n), 1 << 30) + // BigInteger: return Min(lowestOneBit(n), 1 << 14) [BASE=1e7] + var v = n.value, + x = typeof v === "number" ? v | LOBMASK_I : + typeof v === "bigint" ? v | BigInt(LOBMASK_I) : + v[0] + v[1] * BASE | LOBMASK_BI; + return x & -x; + } + + function integerLogarithm(value, base) { + if (base.compareTo(value) <= 0) { + var tmp = integerLogarithm(value, base.square(base)); + var p = tmp.p; + var e = tmp.e; + var t = p.multiply(base); + return t.compareTo(value) <= 0 ? { p: t, e: e * 2 + 1 } : { p: p, e: e * 2 }; + } + return { p: bigInt(1), e: 0 }; + } + + BigInteger.prototype.bitLength = function () { + var n = this; + if (n.compareTo(bigInt(0)) < 0) { + n = n.negate().subtract(bigInt(1)); + } + if (n.compareTo(bigInt(0)) === 0) { + return bigInt(0); + } + return bigInt(integerLogarithm(n, bigInt(2)).e).add(bigInt(1)); + }; + NativeBigInt.prototype.bitLength = SmallInteger.prototype.bitLength = BigInteger.prototype.bitLength; + + function max(a, b) { + a = parseValue(a); + b = parseValue(b); + return a.greater(b) ? a : b; + } + function min(a, b) { + a = parseValue(a); + b = parseValue(b); + return a.lesser(b) ? a : b; + } + function gcd(a, b) { + a = parseValue(a).abs(); + b = parseValue(b).abs(); + if (a.equals(b)) return a; + if (a.isZero()) return b; + if (b.isZero()) return a; + var c = Integer[1], d, t; + while (a.isEven() && b.isEven()) { + d = min(roughLOB(a), roughLOB(b)); + a = a.divide(d); + b = b.divide(d); + c = c.multiply(d); + } + while (a.isEven()) { + a = a.divide(roughLOB(a)); + } + do { + while (b.isEven()) { + b = b.divide(roughLOB(b)); + } + if (a.greater(b)) { + t = b; b = a; a = t; + } + b = b.subtract(a); + } while (!b.isZero()); + return c.isUnit() ? a : a.multiply(c); + } + function lcm(a, b) { + a = parseValue(a).abs(); + b = parseValue(b).abs(); + return a.divide(gcd(a, b)).multiply(b); + } + function randBetween(a, b) { + a = parseValue(a); + b = parseValue(b); + var low = min(a, b), high = max(a, b); + var range = high.subtract(low).add(1); + if (range.isSmall) return low.add(Math.floor(Math.random() * range)); + var digits = toBase(range, BASE).value; + var result = [], restricted = true; + for (var i = 0; i < digits.length; i++) { + var top = restricted ? digits[i] : BASE; + var digit = truncate(Math.random() * top); + result.push(digit); + if (digit < top) restricted = false; + } + return low.add(Integer.fromArray(result, BASE, false)); + } + + var parseBase = function (text, base, alphabet, caseSensitive) { + alphabet = alphabet || DEFAULT_ALPHABET; + text = String(text); + if (!caseSensitive) { + text = text.toLowerCase(); + alphabet = alphabet.toLowerCase(); + } + var length = text.length; + var i; + var absBase = Math.abs(base); + var alphabetValues = {}; + for (i = 0; i < alphabet.length; i++) { + alphabetValues[alphabet[i]] = i; + } + for (i = 0; i < length; i++) { + var c = text[i]; + if (c === "-") continue; + if (c in alphabetValues) { + if (alphabetValues[c] >= absBase) { + if (c === "1" && absBase === 1) continue; + throw new Error(c + " is not a valid digit in base " + base + "."); + } + } + } + base = parseValue(base); + var digits = []; + var isNegative = text[0] === "-"; + for (i = isNegative ? 1 : 0; i < text.length; i++) { + var c = text[i]; + if (c in alphabetValues) digits.push(parseValue(alphabetValues[c])); + else if (c === "<") { + var start = i; + do { i++; } while (text[i] !== ">" && i < text.length); + digits.push(parseValue(text.slice(start + 1, i))); + } + else throw new Error(c + " is not a valid character"); + } + return parseBaseFromArray(digits, base, isNegative); + }; + + function parseBaseFromArray(digits, base, isNegative) { + var val = Integer[0], pow = Integer[1], i; + for (i = digits.length - 1; i >= 0; i--) { + val = val.add(digits[i].times(pow)); + pow = pow.times(base); + } + return isNegative ? val.negate() : val; + } + + function stringify(digit, alphabet) { + alphabet = alphabet || DEFAULT_ALPHABET; + if (digit < alphabet.length) { + return alphabet[digit]; + } + return "<" + digit + ">"; + } + + function toBase(n, base) { + base = bigInt(base); + if (base.isZero()) { + if (n.isZero()) return { value: [0], isNegative: false }; + throw new Error("Cannot convert nonzero numbers to base 0."); + } + if (base.equals(-1)) { + if (n.isZero()) return { value: [0], isNegative: false }; + if (n.isNegative()) + return { + value: [].concat.apply([], Array.apply(null, Array(-n.toJSNumber())) + .map(Array.prototype.valueOf, [1, 0]) + ), + isNegative: false + }; + + var arr = Array.apply(null, Array(n.toJSNumber() - 1)) + .map(Array.prototype.valueOf, [0, 1]); + arr.unshift([1]); + return { + value: [].concat.apply([], arr), + isNegative: false + }; + } + + var neg = false; + if (n.isNegative() && base.isPositive()) { + neg = true; + n = n.abs(); + } + if (base.isUnit()) { + if (n.isZero()) return { value: [0], isNegative: false }; + + return { + value: Array.apply(null, Array(n.toJSNumber())) + .map(Number.prototype.valueOf, 1), + isNegative: neg + }; + } + var out = []; + var left = n, divmod; + while (left.isNegative() || left.compareAbs(base) >= 0) { + divmod = left.divmod(base); + left = divmod.quotient; + var digit = divmod.remainder; + if (digit.isNegative()) { + digit = base.minus(digit).abs(); + left = left.next(); + } + out.push(digit.toJSNumber()); + } + out.push(left.toJSNumber()); + return { value: out.reverse(), isNegative: neg }; + } + + function toBaseString(n, base, alphabet) { + var arr = toBase(n, base); + return (arr.isNegative ? "-" : "") + arr.value.map(function (x) { + return stringify(x, alphabet); + }).join(''); + } + + BigInteger.prototype.toArray = function (radix) { + return toBase(this, radix); + }; + + SmallInteger.prototype.toArray = function (radix) { + return toBase(this, radix); + }; + + NativeBigInt.prototype.toArray = function (radix) { + return toBase(this, radix); + }; + + BigInteger.prototype.toString = function (radix, alphabet) { + if (radix === undefined$1) radix = 10; + if (radix !== 10) return toBaseString(this, radix, alphabet); + var v = this.value, l = v.length, str = String(v[--l]), zeros = "0000000", digit; + while (--l >= 0) { + digit = String(v[l]); + str += zeros.slice(digit.length) + digit; + } + var sign = this.sign ? "-" : ""; + return sign + str; + }; + + SmallInteger.prototype.toString = function (radix, alphabet) { + if (radix === undefined$1) radix = 10; + if (radix != 10) return toBaseString(this, radix, alphabet); + return String(this.value); + }; + + NativeBigInt.prototype.toString = SmallInteger.prototype.toString; + + NativeBigInt.prototype.toJSON = BigInteger.prototype.toJSON = SmallInteger.prototype.toJSON = function () { return this.toString(); }; + + BigInteger.prototype.valueOf = function () { + return parseInt(this.toString(), 10); + }; + BigInteger.prototype.toJSNumber = BigInteger.prototype.valueOf; + + SmallInteger.prototype.valueOf = function () { + return this.value; + }; + SmallInteger.prototype.toJSNumber = SmallInteger.prototype.valueOf; + NativeBigInt.prototype.valueOf = NativeBigInt.prototype.toJSNumber = function () { + return parseInt(this.toString(), 10); + }; + + function parseStringValue(v) { + if (isPrecise(+v)) { + var x = +v; + if (x === truncate(x)) + return supportsNativeBigInt ? new NativeBigInt(BigInt(x)) : new SmallInteger(x); + throw new Error("Invalid integer: " + v); + } + var sign = v[0] === "-"; + if (sign) v = v.slice(1); + var split = v.split(/e/i); + if (split.length > 2) throw new Error("Invalid integer: " + split.join("e")); + if (split.length === 2) { + var exp = split[1]; + if (exp[0] === "+") exp = exp.slice(1); + exp = +exp; + if (exp !== truncate(exp) || !isPrecise(exp)) throw new Error("Invalid integer: " + exp + " is not a valid exponent."); + var text = split[0]; + var decimalPlace = text.indexOf("."); + if (decimalPlace >= 0) { + exp -= text.length - decimalPlace - 1; + text = text.slice(0, decimalPlace) + text.slice(decimalPlace + 1); + } + if (exp < 0) throw new Error("Cannot include negative exponent part for integers"); + text += (new Array(exp + 1)).join("0"); + v = text; + } + var isValid = /^([0-9][0-9]*)$/.test(v); + if (!isValid) throw new Error("Invalid integer: " + v); + if (supportsNativeBigInt) { + return new NativeBigInt(BigInt(sign ? "-" + v : v)); + } + var r = [], max = v.length, l = LOG_BASE, min = max - l; + while (max > 0) { + r.push(+v.slice(min, max)); + min -= l; + if (min < 0) min = 0; + max -= l; + } + trim(r); + return new BigInteger(r, sign); + } + + function parseNumberValue(v) { + if (supportsNativeBigInt) { + return new NativeBigInt(BigInt(v)); + } + if (isPrecise(v)) { + if (v !== truncate(v)) throw new Error(v + " is not an integer."); + return new SmallInteger(v); + } + return parseStringValue(v.toString()); + } + + function parseValue(v) { + if (typeof v === "number") { + return parseNumberValue(v); + } + if (typeof v === "string") { + return parseStringValue(v); + } + if (typeof v === "bigint") { + return new NativeBigInt(v); + } + return v; + } + // Pre-define numbers in range [-999,999] + for (var i = 0; i < 1000; i++) { + Integer[i] = parseValue(i); + if (i > 0) Integer[-i] = parseValue(-i); + } + // Backwards compatibility + Integer.one = Integer[1]; + Integer.zero = Integer[0]; + Integer.minusOne = Integer[-1]; + Integer.max = max; + Integer.min = min; + Integer.gcd = gcd; + Integer.lcm = lcm; + Integer.isInstance = function (x) { return x instanceof BigInteger || x instanceof SmallInteger || x instanceof NativeBigInt; }; + Integer.randBetween = randBetween; + + Integer.fromArray = function (digits, base, isNegative) { + return parseBaseFromArray(digits.map(parseValue), parseValue(base || 10), isNegative); + }; + + return Integer; + })(); + + // Node.js check + if (module.hasOwnProperty("exports")) { + module.exports = bigInt; + } +} (BigInteger)); + +var BigIntegerExports = BigInteger.exports; + +/* + Copyright 2018 0kims association. + + This file is part of snarkjs. + + snarkjs is a free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your option) + any later version. + + snarkjs is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + snarkjs. If not, see . +*/ + +/* global BigInt */ +const bigInt$5 = BigIntegerExports$1; + +let wBigInt; + +if (typeof(BigInt) != "undefined") { + wBigInt = BigInt; + wBigInt.one = wBigInt(1); + wBigInt.zero = wBigInt(0); + + // Affine + wBigInt.genAffine = (q) => { + const nq = -q; + return (a) => { + let aux = a; + if (aux < 0) { + if (aux <= nq) { + aux = aux % q; + } + if (aux < wBigInt.zero) { + aux = aux + q; + } + } else { + if (aux >= q) { + aux = aux % q; + } + } + return aux.valueOf(); + }; + }; + + + // Inverse + wBigInt.genInverse = (q) => { + return (a) => { + let t = wBigInt.zero; + let r = q; + let newt = wBigInt.one; + let newr = wBigInt.affine(a, q); + while (newr!=wBigInt.zero) { + let q = r/newr; + [t, newt] = [newt, t-q*newt]; + [r, newr] = [newr, r-q*newr]; + } + if (t { + if (q) { + return (a,b) => (a+b) % q; + } else { + return (a,b) => a+b; + } + }; + + // Sub + wBigInt.genSub = (q) => { + if (q) { + return (a,b) => (a-b) % q; + } else { + return (a,b) => a-b; + } + }; + + + // Neg + wBigInt.genNeg = (q) => { + if (q) { + return (a) => (-a) % q; + } else { + return (a) => -a; + } + }; + + // Mul + wBigInt.genMul = (q) => { + if (q) { + return (a,b) => (a*b) % q; + } else { + return (a,b) => a*b; + } + }; + + // Shr + wBigInt.genShr = () => { + return (a,b) => a >> wBigInt(b); + }; + + // Shl + wBigInt.genShl = (q) => { + if (q) { + return (a,b) => (a << wBigInt(b)) % q; + } else { + return (a,b) => a << wBigInt(b); + } + }; + + // Equals + wBigInt.genEquals = (q) => { + if (q) { + return (a,b) => (a.affine(q) == b.affine(q)); + } else { + return (a,b) => a == b; + } + }; + + // Square + wBigInt.genSquare = (q) => { + if (q) { + return (a) => (a*a) %q; + } else { + return (a) => a*a; + } + }; + + + // Double + wBigInt.genDouble = (q) => { + if (q) { + return (a) => (a+a) %q; + } else { + return (a) => a+a; + } + }; + + // IsZero + wBigInt.genIsZero = (q) => { + if (q) { + return (a) => (a.affine(q) == wBigInt.zero); + } else { + return (a) => a == wBigInt.zero; + } + }; + + + // Other minor functions + wBigInt.prototype.isOdd = function() { + return (this & wBigInt.one) == wBigInt(1); + }; + + wBigInt.prototype.isNegative = function() { + return this < wBigInt.zero; + }; + + wBigInt.prototype.and = function(m) { + return this & m; + }; + + wBigInt.prototype.div = function(c) { + return this / c; + }; + + wBigInt.prototype.mod = function(c) { + return this % c; + }; + + wBigInt.prototype.pow = function(c) { + return this ** c; + }; + + wBigInt.prototype.abs = function() { + return (this > wBigInt.zero) ? this : -this; + }; + + wBigInt.prototype.modPow = function(e, m) { + let acc = wBigInt.one; + let exp = this; + let rem = e; + while (rem) { + if (rem & wBigInt.one) { + acc = (acc * exp) %m; + } + exp = (exp * exp) % m; + rem = rem >> wBigInt.one; + } + return acc; + }; + + wBigInt.prototype.greaterOrEquals = function(b) { + return this >= b; + }; + + wBigInt.prototype.greater = function(b) { + return this > b; + }; + wBigInt.prototype.gt = wBigInt.prototype.greater; + + wBigInt.prototype.lesserOrEquals = function(b) { + return this <= b; + }; + + wBigInt.prototype.lesser = function(b) { + return this < b; + }; + wBigInt.prototype.lt = wBigInt.prototype.lesser; + + wBigInt.prototype.equals = function(b) { + return this == b; + }; + wBigInt.prototype.eq = wBigInt.prototype.equals; + + wBigInt.prototype.neq = function(b) { + return this != b; + }; + + wBigInt.prototype.toJSNumber = function() { + return Number(this); + }; + + +} else { + + var oldProto = bigInt$5.prototype; + wBigInt = function(a) { + if ((typeof a == "string") && (a.slice(0,2) == "0x")) { + return bigInt$5(a.slice(2), 16); + } else { + return bigInt$5(a); + } + }; + wBigInt.one = bigInt$5.one; + wBigInt.zero = bigInt$5.zero; + wBigInt.prototype = oldProto; + + wBigInt.prototype.div = function(c) { + return this.divide(c); + }; + + // Affine + wBigInt.genAffine = (q) => { + const nq = wBigInt.zero.minus(q); + return (a) => { + let aux = a; + if (aux.isNegative()) { + if (aux.lesserOrEquals(nq)) { + aux = aux.mod(q); + } + if (aux.isNegative()) { + aux = aux.add(q); + } + } else { + if (aux.greaterOrEquals(q)) { + aux = aux.mod(q); + } + } + return aux; + }; + }; + + + // Inverse + wBigInt.genInverse = (q) => { + return (a) => a.affine(q).modInv(q); + }; + + // Add + wBigInt.genAdd = (q) => { + if (q) { + return (a,b) => { + const r = a.add(b); + return r.greaterOrEquals(q) ? r.minus(q) : r; + }; + } else { + return (a,b) => a.add(b); + } + }; + + // Sub + wBigInt.genSub = (q) => { + if (q) { + return (a,b) => a.greaterOrEquals(b) ? a.minus(b) : a.minus(b).add(q); + } else { + return (a,b) => a.minus(b); + } + }; + + wBigInt.genNeg = (q) => { + if (q) { + return (a) => a.isZero() ? a : q.minus(a); + } else { + return (a) => wBigInt.zero.minus(a); + } + }; + + // Mul + wBigInt.genMul = (q) => { + if (q) { + return (a,b) => a.times(b).mod(q); + } else { + return (a,b) => a.times(b); + } + }; + + // Shr + wBigInt.genShr = () => { + return (a,b) => a.shiftRight(wBigInt(b).value); + }; + + // Shr + wBigInt.genShl = (q) => { + if (q) { + return (a,b) => a.shiftLeft(wBigInt(b).value).mod(q); + } else { + return (a,b) => a.shiftLeft(wBigInt(b).value); + } + }; + + // Square + wBigInt.genSquare = (q) => { + if (q) { + return (a) => a.square().mod(q); + } else { + return (a) => a.square(); + } + }; + + // Double + wBigInt.genDouble = (q) => { + if (q) { + return (a) => a.add(a).mod(q); + } else { + return (a) => a.add(a); + } + }; + + // Equals + wBigInt.genEquals = (q) => { + if (q) { + return (a,b) => a.affine(q).equals(b.affine(q)); + } else { + return (a,b) => a.equals(b); + } + }; + + // IsZero + wBigInt.genIsZero = (q) => { + if (q) { + return (a) => (a.affine(q).isZero()); + } else { + return (a) => a.isZero(); + } + }; +} + + + +wBigInt.affine = function(a, q) { + return wBigInt.genAffine(q)(a); +}; + +wBigInt.prototype.affine = function (q) { + return wBigInt.affine(this, q); +}; + +wBigInt.inverse = function(a, q) { + return wBigInt.genInverse(q)(a); +}; + +wBigInt.prototype.inverse = function (q) { + return wBigInt.genInverse(q)(this); +}; + +wBigInt.add = function(a, b, q) { + return wBigInt.genAdd(q)(a,b); +}; + +wBigInt.prototype.add = function (a, q) { + return wBigInt.genAdd(q)(this, a); +}; + +wBigInt.sub = function(a, b, q) { + return wBigInt.genSub(q)(a,b); +}; + +wBigInt.prototype.sub = function (a, q) { + return wBigInt.genSub(q)(this, a); +}; + +wBigInt.neg = function(a, q) { + return wBigInt.genNeg(q)(a); +}; + +wBigInt.prototype.neg = function (q) { + return wBigInt.genNeg(q)(this); +}; + +wBigInt.mul = function(a, b, q) { + return wBigInt.genMul(q)(a,b); +}; + +wBigInt.prototype.mul = function (a, q) { + return wBigInt.genMul(q)(this, a); +}; + +wBigInt.shr = function(a, b, q) { + return wBigInt.genShr(q)(a,b); +}; + +wBigInt.prototype.shr = function (a, q) { + return wBigInt.genShr(q)(this, a); +}; + +wBigInt.shl = function(a, b, q) { + return wBigInt.genShl(q)(a,b); +}; + +wBigInt.prototype.shl = function (a, q) { + return wBigInt.genShl(q)(this, a); +}; + +wBigInt.equals = function(a, b, q) { + return wBigInt.genEquals(q)(a,b); +}; + +wBigInt.prototype.equals = function (a, q) { + return wBigInt.genEquals(q)(this, a); +}; + +wBigInt.square = function(a, q) { + return wBigInt.genSquare(q)(a); +}; + +wBigInt.prototype.square = function (q) { + return wBigInt.genSquare(q)(this); +}; + +wBigInt.double = function(a, q) { + return wBigInt.genDouble(q)(a); +}; + +wBigInt.prototype.double = function (q) { + return wBigInt.genDouble(q)(this); +}; + +wBigInt.isZero = function(a, q) { + return wBigInt.genIsZero(q)(a); +}; + +wBigInt.prototype.isZero = function (q) { + return wBigInt.genIsZero(q)(this); +}; + +wBigInt.leBuff2int = function(buff) { + let res = wBigInt.zero; + for (let i=0; i=0)) { + let c = Number(r.and(wBigInt("255"))); + buff[o] = c; + o--; + r = r.shr(8); + } + if (r.greater(wBigInt.zero)) throw new Error("Number does not feed in buffer"); + return buff; +}; + +wBigInt.prototype.beInt2Buff = function (len) { + return wBigInt.beInt2Buff(this,len); +}; + +var bigint = wBigInt; + +/* + Copyright 2018 0kims association. + + This file is part of snarkjs. + + snarkjs is a free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your option) + any later version. + + snarkjs is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + snarkjs. If not, see . +*/ + +var calculateWitness_1; +var hasRequiredCalculateWitness; + +function requireCalculateWitness () { + if (hasRequiredCalculateWitness) return calculateWitness_1; + hasRequiredCalculateWitness = 1; + const bigInt = bigint; + + calculateWitness_1 = calculateWitness; + + function calculateWitness(circuit, inputSignals, options) { + options = options || {}; + if (!options.logFunction) options.logFunction = console.log; + const ctx = new RTCtx(circuit, options); + + function iterateSelector(values, sels, cb) { + if (!Array.isArray(values)) { + return cb(sels, values); + } + for (let i=0; i " + ctx.witness[i].toString()); + } + return ctx.witness.slice(0, circuit.nVars); + // return ctx.witness; + } + + class RTCtx { + constructor(circuit, options) { + this.options = options; + this.scopes = []; + this.circuit = circuit; + this.witness = new Array(circuit.nSignals); + this.notInitSignals = {}; + for (let c in this.circuit.components) { + this.notInitSignals[c] = this.circuit.components[c].inputSignals; + } + } + + _sels2str(sels) { + let res = ""; + for (let i=0; i { + if (this.notInitSignals[c] == 0) this.triggerComponent(c); + }); + return this.witness[sId]; + } + + setVar(name, sels, value) { + function setVarArray(a, sels2, value) { + if (sels2.length == 1) { + a[sels2[0]] = value; + } else { + if (typeof(a[sels2[0]]) == "undefined") a[sels2[0]] = []; + setVarArray(a[sels2[0]], sels2.slice(1), value); + } + } + const scope = this.scopes[this.scopes.length-1]; + if (sels.length == 0) { + scope[name] = value; + } else { + if (typeof(scope[name]) == "undefined") scope[name] = []; + setVarArray(scope[name], sels, value); + } + return value; + } + + getVar(name, sels) { + function select(a, sels2) { + return (sels2.length == 0) ? a : select(a[sels2[0]], sels2.slice(1)); + } + for (let i=this.scopes.length-1; i>=0; i--) { + if (typeof(this.scopes[i][name]) != "undefined") return select(this.scopes[i][name], sels); + } + throw new Error("Variable not defined: " + name); + } + + getSignal(name, sels) { + let fullName = name=="one" ? "one" : this.currentComponent + "." + name; + fullName += this._sels2str(sels); + return this.getSignalFullName(fullName); + } + + + getPin(componentName, componentSels, signalName, signalSels) { + let fullName = componentName=="one" ? "one" : this.currentComponent + "." + componentName; + fullName += this._sels2str(componentSels) + + "."+ + signalName+ + this._sels2str(signalSels); + return this.getSignalFullName(fullName); + } + + getSignalFullName(fullName) { + const sId = this.circuit.getSignalIdx(fullName); + if (typeof(this.witness[sId]) == "undefined") { + throw new Error("Signal not initialized: "+fullName); + } + if (this.options.logGet) this.options.logFunction("get --->" + fullName + " = " + this.witness[sId].toString() ); + return this.witness[sId]; + } + + assert(a,b,errStr) { + const ba = bigInt(a); + const bb = bigInt(b); + if (!ba.equals(bb)) { + throw new Error("Constraint doesn't match "+ this.currentComponent+": "+ errStr + " -> "+ ba.toString() + " != " + bb.toString()); + } + } + } + return calculateWitness_1; +} + +/* + Copyright 2018 0kims association. + + This file is part of snarkjs. + + snarkjs is a free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your option) + any later version. + + snarkjs is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + snarkjs. If not, see . +*/ + +const bigInt$4 = bigint; + +const __P__ = bigInt$4("21888242871839275222246405745257275088548364400416034343698204186575808495617"); +bigInt$4("28948022309329048855892746252171976963317496166410141009864396001978282409983"); // 0x3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF +const calculateWitness = requireCalculateWitness(); + +var circuit = class Circuit { + constructor(circuitDef) { + this.nPubInputs = circuitDef.nPubInputs; + this.nPrvInputs = circuitDef.nPrvInputs; + this.nInputs = circuitDef.nInputs; + this.nOutputs = circuitDef.nOutputs; + this.nVars = circuitDef.nVars; + this.nSignals = circuitDef.nSignals; + this.nConstants = circuitDef.nConstants; + + this.nConstraints = circuitDef.constraints.length; + + this.signalName2Idx = circuitDef.signalName2Idx; + this.components = circuitDef.components; + this.componentName2Idx = circuitDef.componentName2Idx; + this.signals = circuitDef.signals; + this.constraints = circuitDef.constraints; + + this.templates = {}; + for (let t in circuitDef.templates) { + this.templates[t] = eval(" const __f= " +circuitDef.templates[t] + "\n__f"); + } + + this.functions = {}; + for (let f in circuitDef.functions) { + this.functions[f] = { + params: circuitDef.functions[f].params, + func: eval(" const __f= " +circuitDef.functions[f].func + "\n__f;") + }; + } + } + + calculateWitness(input, log) { + return calculateWitness(this, input, log); + } + + checkWitness(w) { + const evalLC = (lc, w) => { + let acc = bigInt$4(0); + for (let k in lc) { + acc= acc.add(bigInt$4(w[k]).mul(bigInt$4(lc[k]))).mod(__P__); + } + return acc; + }; + + const checkConstraint = (ct, w) => { + const a=evalLC(ct[0],w); + const b=evalLC(ct[1],w); + const c=evalLC(ct[2],w); + const res = (a.mul(b).sub(c)).affine(__P__); + if (!res.isZero()) return false; + return true; + }; + + + for (let i=0; i { + let S = ""; + for (let k in lc) { + let name = this.signals[k].names[0]; + if (name == "one") name = ""; + let v = bigInt$4(lc[k]); + let vs; + if (!v.lesserOrEquals(__P__.shr(bigInt$4(1)))) { + v = __P__.sub(v); + vs = "-"+v.toString(); + } else { + if (S!="") { + vs = "+"+v.toString(); + } else { + vs = ""; + } + if (vs!="1") { + vs = vs + v.toString(); } + } + + S= S + " " + vs + name; + } + return S; + }; + const S = `[ ${lc2str(c[0])} ] * [ ${lc2str(c[1])} ] - [ ${lc2str(c[2])} ] = 0`; + console.log(S); + } + + printConstraints() { + for (let i=0; i=this.nOutputs) throw new Error("Accessing an invalid output: "+i); + return i+1; + } + + // returns the index of the i'th input + inputIdx(i) { + if (i>=this.nInputs) throw new Error("Accessing an invalid input: "+i); + return this.nOutputs + 1 + i; + } + + // returns the index of the i'th public input + pubInputIdx(i) { + if (i>=this.nPubInputs) throw new Error("Accessing an invalid pubInput: "+i); + return this.inputIdx(i); + } + + // returns the index of the i'th private input + prvInputIdx(i) { + if (i>=this.nPrvInputs) throw new Error("Accessing an invalid prvInput: "+i); + return this.inputIdx(this.nPubInputs + i); + } + + // returns the index of the i'th variable + varIdx(i) { + if (i>=this.nVars) throw new Error("Accessing an invalid variable: "+i); + return i; + } + + // returns the index of the i'th constant + constantIdx(i) { + if (i>=this.nConstants) throw new Error("Accessing an invalid constant: "+i); + return this.nVars + i; + } + + // returns the index of the i'th signal + signalIdx(i) { + if (i>=this.nSignls) throw new Error("Accessing an invalid signal: "+i); + return i; + } + + signalNames(i) { + return this.signals[ this.getSignalIdx(i) ].names.join(", "); + } + + a(constraint, signalIdx) { + return bigInt$4(this.constraints[constraint][0][signalIdx] || 0 ); + } + + b(constraint, signalIdx) { + return bigInt$4(this.constraints[constraint][1][signalIdx] || 0); + } + + c(constraint, signalIdx) { + return bigInt$4(this.constraints[constraint][2][signalIdx] || 0); + } +}; + +var stringifybigint$1 = {}; + +/* + Copyright 2018 0kims association. + + This file is part of snarkjs. + + snarkjs is a free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your option) + any later version. + + snarkjs is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + snarkjs. If not, see . +*/ + +const bigInt$3 = BigIntegerExports; + +stringifybigint$1.stringifyBigInts = stringifyBigInts$1; +stringifybigint$1.unstringifyBigInts = unstringifyBigInts$2; +stringifybigint$1.hexifyBigInts = hexifyBigInts$1; +stringifybigint$1.unhexifyBigInts = unhexifyBigInts; + +function stringifyBigInts$1(o) { + if ((typeof(o) == "bigint") || (o instanceof bigInt$3)) { + return o.toString(10); + } else if (Array.isArray(o)) { + return o.map(stringifyBigInts$1); + } else if (typeof o == "object") { + const res = {}; + for (let k in o) { + res[k] = stringifyBigInts$1(o[k]); + } + return res; + } else { + return o; + } +} + +function unstringifyBigInts$2(o) { + if ((typeof(o) == "string") && (/^[0-9]+$/.test(o) )) { + return bigInt$3(o); + } else if (Array.isArray(o)) { + return o.map(unstringifyBigInts$2); + } else if (typeof o == "object" && !(o instanceof bigInt$3)) { + const res = {}; + for (let k in o) { + res[k] = unstringifyBigInts$2(o[k]); + } + return res; + } else { + return o; + } +} + +function hexifyBigInts$1(o) { + if (typeof (o) === "bigInt" || (o instanceof bigInt$3)) { + let str = o.toString(16); + while (str.length < 64) str = "0" + str; + str = "0x" + str; + return str; + } else if (Array.isArray(o)) { + return o.map(hexifyBigInts$1); + } else if (typeof o == "object") { + const res = {}; + for (let k in o) { + res[k] = hexifyBigInts$1(o[k]); + } + return res; + } else { + return o; + } +} + +function unhexifyBigInts(o) { + if ((typeof(o) == "string") && (/^0x[0-9a-fA-F]+$/.test(o))) { + return bigInt$3(o); + } else if (Array.isArray(o)) { + return o.map(unhexifyBigInts); + } else if (typeof o == "object") { + const res = {}; + for (let k in o) { + res[k] = unhexifyBigInts(o[k]); + } + return res; + } else { + return o; + } +} + +var stringifybigint = {}; + +/* + Copyright 2018 0kims association. + + This file is part of snarkjs. + + snarkjs is a free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as published by the + Free Software Foundation, either version 3 of the License, or (at your option) + any later version. + + snarkjs is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along with + snarkjs. If not, see . +*/ + +const bigInt$2 = bigint; + +stringifybigint.stringifyBigInts = stringifyBigInts; +stringifybigint.unstringifyBigInts = unstringifyBigInts$1; + +function stringifyBigInts(o) { + if ((typeof(o) == "bigint") || o.isZero !== undefined) { + return o.toString(10); + } else if (Array.isArray(o)) { + return o.map(stringifyBigInts); + } else if (typeof o == "object") { + const res = {}; + for (let k in o) { + res[k] = stringifyBigInts(o[k]); + } + return res; + } else { + return o; + } +} + +function unstringifyBigInts$1(o) { + if ((typeof(o) == "string") && (/^[0-9]+$/.test(o) )) { + return bigInt$2(o); + } else if (Array.isArray(o)) { + return o.map(unstringifyBigInts$1); + } else if (typeof o == "object") { + const res = {}; + for (let k in o) { + res[k] = unstringifyBigInts$1(o[k]); + } + return res; + } else { + return o; + } +} + +/* + Copyright 2019 0KIMS association. + + This file is part of websnark (Web Assembly zkSnark Prover). + + websnark is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + websnark is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with websnark. If not, see . +*/ + +const bigInt$1 = BigIntegerExports; +const Circuit = circuit; +const bigInt2 = bigint; +const hexifyBigInts = stringifybigint$1.hexifyBigInts; +const unstringifyBigInts = stringifybigint$1.unstringifyBigInts; +const stringifyBigInts2 = stringifybigint.stringifyBigInts; +const unstringifyBigInts2 = stringifybigint.unstringifyBigInts; + +function bigInt2BytesLE(_a, len) { + const b = Array(len); + let v = bigInt$1(_a); + for (let i = 0; i < len; i++) { + b[i] = v.and(0xff).toJSNumber(); + v = v.shiftRight(8); + } + return b; +} + +function bigInt2U32LE(_a, len) { + const b = Array(len); + let v = bigInt$1(_a); + for (let i = 0; i < len; i++) { + b[i] = v.and(0xffffffff).toJSNumber(); + v = v.shiftRight(32); + } + return b; +} + +function convertWitness(witness) { + const buffLen = witness.length * 32; + const buff = new ArrayBuffer(buffLen); + const h = { + dataView: new DataView(buff), + offset: 0, + }; + const mask = bigInt2(0xffffffff); + for (let i = 0; i < witness.length; i++) { + for (let j = 0; j < 8; j++) { + const v = Number(witness[i].shr(j * 32).and(mask)); + h.dataView.setUint32(h.offset, v, true); + h.offset += 4; + } + } + return buff; +} + +function toHex32(number) { + let str = number.toString(16); + while (str.length < 64) str = "0" + str; + return str; +} + +function toSolidityInput(proof) { + const flatProof = unstringifyBigInts([ + proof.pi_a[0], + proof.pi_a[1], + proof.pi_b[0][1], + proof.pi_b[0][0], + proof.pi_b[1][1], + proof.pi_b[1][0], + proof.pi_c[0], + proof.pi_c[1], + ]); + const result = { + proof: "0x" + flatProof.map((x) => toHex32(x)).join(""), + }; + if (proof.publicSignals) { + result.publicSignals = hexifyBigInts(unstringifyBigInts(proof.publicSignals)); + } + return result; +} + +function genWitness(input, circuitJson) { + const circuit = new Circuit(unstringifyBigInts2(circuitJson)); + const witness = circuit.calculateWitness(unstringifyBigInts2(input)); + const publicSignals = witness.slice(1, circuit.nPubInputs + circuit.nOutputs + 1); + return { witness, publicSignals }; +} + +async function genWitnessAndProve(groth16, input, circuitJson, provingKey) { + const witnessData = genWitness(input, circuitJson); + const witnessBin = convertWitness(witnessData.witness); + const result = await groth16.proof(witnessBin, provingKey); + result.publicSignals = stringifyBigInts2(witnessData.publicSignals); + return result; +} + +var utils = { bigInt2BytesLE, bigInt2U32LE, toSolidityInput, genWitnessAndProve }; + +var groth16_wasm$1 = {}; + +groth16_wasm$1.code = new Buffer("AGFzbQEAAAABPApgAn9/AGABfwBgAX8Bf2ACf38Bf2ADf39/AX9gA39/fwBgA39+fwBgAn9+AGAEf39/fwBgBX9/f39/AAIQAQNlbnYGbWVtb3J5AgDoBwNsawABAgEDAwQEBQUGBwgFBQUAAAUFAAAAAQUFAAAFBQAAAAEFAAIBAAAFAAUAAAAIAQIAAgUICQgABQkDAAUFBQUAAgUFCAAIAgEBAAUFBQAAAAMAAgEAAAUABQAAAAgBAgACBQgJCAAFCQgIB8gJYghpbnRfY29weQAACGludF96ZXJvAAEHaW50X29uZQADCmludF9pc1plcm8AAgZpbnRfZXEABAdpbnRfZ3RlAAUHaW50X2FkZAAGB2ludF9zdWIABwppbnRfbXVsT2xkAAkHaW50X211bAAIB2ludF9kaXYADA5pbnRfaW52ZXJzZU1vZAANB2YxbV9hZGQADgdmMW1fc3ViAA8HZjFtX25lZwAQC2YxbV9tUmVkdWN0ABEHZjFtX211bAASCmYxbV9tdWxPbGQAExJmMW1fZnJvbU1vbnRnb21lcnkAFRBmMW1fdG9Nb250Z29tZXJ5ABQLZjFtX2ludmVyc2UAFghmMW1fY29weQAACGYxbV96ZXJvAAEKZjFtX2lzWmVybwACBmYxbV9lcQAEB2YxbV9vbmUAFwdmcm1fYWRkABgHZnJtX3N1YgAZB2ZybV9uZWcAGgtmcm1fbVJlZHVjdAAbB2ZybV9tdWwAHApmcm1fbXVsT2xkAB0SZnJtX2Zyb21Nb250Z29tZXJ5AB8QZnJtX3RvTW9udGdvbWVyeQAeC2ZybV9pbnZlcnNlACAIZnJtX2NvcHkAAAhmcm1femVybwABCmZybV9pc1plcm8AAgZmcm1fZXEABAdmcm1fb25lACEGZnJfYWRkABgGZnJfc3ViABkGZnJfbmVnABoGZnJfbXVsACIKZnJfaW52ZXJzZQAjB2ZyX2NvcHkAAAdmcl96ZXJvAAEGZnJfb25lACEJZnJfaXNaZXJvAAIFZnJfZXEABAlnMV9pc1plcm8AJAdnMV9jb3B5ACYHZzFfemVybwAlCWcxX2RvdWJsZQAnBmcxX2FkZAAoBmcxX25lZwApBmcxX3N1YgAqEWcxX2Zyb21Nb250Z29tZXJ5ACsPZzFfdG9Nb250Z29tZXJ5ACwJZzFfYWZmaW5lAC0OZzFfdGltZXNTY2FsYXIALgtnMV9tdWx0aWV4cAA1DGcxX211bHRpZXhwMgA5B2ZmdF9mZnQAQghmZnRfaWZmdABDEWZmdF90b01vbnRnb21lcnlOAD8TZmZ0X2Zyb21Nb250Z29tZXJ5TgA+FGZmdF9jb3B5TkludGVybGVhdmVkAD0IZmZ0X211bE4ARAhwb2xfemVybwBFD3BvbF9jb25zdHJ1Y3RMQwBGCmYybV9pc1plcm8ARwhmMm1femVybwBIB2YybV9vbmUASQhmMm1fY29weQBKB2YybV9tdWwASwdmMm1fYWRkAEwHZjJtX3N1YgBNB2YybV9uZWcAThJmMm1fZnJvbU1vbnRnb21lcnkAUBBmMm1fdG9Nb250Z29tZXJ5AE8GZjJtX2VxAFELZjJtX2ludmVyc2UAUglnMl9pc1plcm8AUwdnMl9jb3B5AFUHZzJfemVybwBUCWcyX2RvdWJsZQBWBmcyX2FkZABXBmcyX25lZwBYBmcyX3N1YgBZEWcyX2Zyb21Nb250Z29tZXJ5AFoPZzJfdG9Nb250Z29tZXJ5AFsJZzJfYWZmaW5lAFwOZzJfdGltZXNTY2FsYXIAXQtnMl9tdWx0aWV4cABkDGcyX211bHRpZXhwMgBoDHRlc3RfZjFtX211bABpD3Rlc3RfZjFtX211bE9sZABqCsfEAWsqACABIAApAwA3AwAgASAAKQMINwMIIAEgACkDEDcDECABIAApAxg3AxgLHgAgAEIANwMAIABCADcDCCAAQgA3AxAgAEIANwMYCzMAIAApAxhQBEAgACkDEFAEQCAAKQMIUARAIAApAwBQDwVBAA8LBUEADwsFQQAPC0EADwseACAAQgE3AwAgAEIANwMIIABCADcDECAAQgA3AxgLRwAgACkDGCABKQMYUQRAIAApAxAgASkDEFEEQCAAKQMIIAEpAwhRBEAgACkDACABKQMAUQ8FQQAPCwVBAA8LBUEADwtBAA8LfQAgACkDGCABKQMYVARAQQAPBSAAKQMYIAEpAxhWBEBBAQ8FIAApAxAgASkDEFQEQEEADwUgACkDECABKQMQVgRAQQEPBSAAKQMIIAEpAwhUBEBBAA8FIAApAwggASkDCFYEQEEBDwUgACkDACABKQMAWg8LCwsLCwtBAA8L1AEBAX4gADUCACABNQIAfCEDIAIgAz4CACAANQIEIAE1AgR8IANCIIh8IQMgAiADPgIEIAA1AgggATUCCHwgA0IgiHwhAyACIAM+AgggADUCDCABNQIMfCADQiCIfCEDIAIgAz4CDCAANQIQIAE1AhB8IANCIIh8IQMgAiADPgIQIAA1AhQgATUCFHwgA0IgiHwhAyACIAM+AhQgADUCGCABNQIYfCADQiCIfCEDIAIgAz4CGCAANQIcIAE1Ahx8IANCIIh8IQMgAiADPgIcIANCIIinC4wCAQF+IAA1AgAgATUCAH0hAyACIANC/////w+DPgIAIAA1AgQgATUCBH0gA0Igh3whAyACIANC/////w+DPgIEIAA1AgggATUCCH0gA0Igh3whAyACIANC/////w+DPgIIIAA1AgwgATUCDH0gA0Igh3whAyACIANC/////w+DPgIMIAA1AhAgATUCEH0gA0Igh3whAyACIANC/////w+DPgIQIAA1AhQgATUCFH0gA0Igh3whAyACIANC/////w+DPgIUIAA1AhggATUCGH0gA0Igh3whAyACIANC/////w+DPgIYIAA1AhwgATUCHH0gA0Igh3whAyACIANC/////w+DPgIcIANCIIenC48QEgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfiADQv////8PgyAANQIAIgUgATUCACIGfnwhAyAEIANCIIh8IQQgAiADPgIAIARCIIghAyAEQv////8PgyAFIAE1AgQiCH58IQQgAyAEQiCIfCEDIARC/////w+DIAA1AgQiByAGfnwhBCADIARCIIh8IQMgAiAEPgIEIANCIIghBCADQv////8PgyAFIAE1AggiCn58IQMgBCADQiCIfCEEIANC/////w+DIAcgCH58IQMgBCADQiCIfCEEIANC/////w+DIAA1AggiCSAGfnwhAyAEIANCIIh8IQQgAiADPgIIIARCIIghAyAEQv////8PgyAFIAE1AgwiDH58IQQgAyAEQiCIfCEDIARC/////w+DIAcgCn58IQQgAyAEQiCIfCEDIARC/////w+DIAkgCH58IQQgAyAEQiCIfCEDIARC/////w+DIAA1AgwiCyAGfnwhBCADIARCIIh8IQMgAiAEPgIMIANCIIghBCADQv////8PgyAFIAE1AhAiDn58IQMgBCADQiCIfCEEIANC/////w+DIAcgDH58IQMgBCADQiCIfCEEIANC/////w+DIAkgCn58IQMgBCADQiCIfCEEIANC/////w+DIAsgCH58IQMgBCADQiCIfCEEIANC/////w+DIAA1AhAiDSAGfnwhAyAEIANCIIh8IQQgAiADPgIQIARCIIghAyAEQv////8PgyAFIAE1AhQiEH58IQQgAyAEQiCIfCEDIARC/////w+DIAcgDn58IQQgAyAEQiCIfCEDIARC/////w+DIAkgDH58IQQgAyAEQiCIfCEDIARC/////w+DIAsgCn58IQQgAyAEQiCIfCEDIARC/////w+DIA0gCH58IQQgAyAEQiCIfCEDIARC/////w+DIAA1AhQiDyAGfnwhBCADIARCIIh8IQMgAiAEPgIUIANCIIghBCADQv////8PgyAFIAE1AhgiEn58IQMgBCADQiCIfCEEIANC/////w+DIAcgEH58IQMgBCADQiCIfCEEIANC/////w+DIAkgDn58IQMgBCADQiCIfCEEIANC/////w+DIAsgDH58IQMgBCADQiCIfCEEIANC/////w+DIA0gCn58IQMgBCADQiCIfCEEIANC/////w+DIA8gCH58IQMgBCADQiCIfCEEIANC/////w+DIAA1AhgiESAGfnwhAyAEIANCIIh8IQQgAiADPgIYIARCIIghAyAEQv////8PgyAFIAE1AhwiFH58IQQgAyAEQiCIfCEDIARC/////w+DIAcgEn58IQQgAyAEQiCIfCEDIARC/////w+DIAkgEH58IQQgAyAEQiCIfCEDIARC/////w+DIAsgDn58IQQgAyAEQiCIfCEDIARC/////w+DIA0gDH58IQQgAyAEQiCIfCEDIARC/////w+DIA8gCn58IQQgAyAEQiCIfCEDIARC/////w+DIBEgCH58IQQgAyAEQiCIfCEDIARC/////w+DIAA1AhwiEyAGfnwhBCADIARCIIh8IQMgAiAEPgIcIANCIIghBCADQv////8PgyAHIBR+fCEDIAQgA0IgiHwhBCADQv////8PgyAJIBJ+fCEDIAQgA0IgiHwhBCADQv////8PgyALIBB+fCEDIAQgA0IgiHwhBCADQv////8PgyANIA5+fCEDIAQgA0IgiHwhBCADQv////8PgyAPIAx+fCEDIAQgA0IgiHwhBCADQv////8PgyARIAp+fCEDIAQgA0IgiHwhBCADQv////8PgyATIAh+fCEDIAQgA0IgiHwhBCACIAM+AiAgBEIgiCEDIARC/////w+DIAkgFH58IQQgAyAEQiCIfCEDIARC/////w+DIAsgEn58IQQgAyAEQiCIfCEDIARC/////w+DIA0gEH58IQQgAyAEQiCIfCEDIARC/////w+DIA8gDn58IQQgAyAEQiCIfCEDIARC/////w+DIBEgDH58IQQgAyAEQiCIfCEDIARC/////w+DIBMgCn58IQQgAyAEQiCIfCEDIAIgBD4CJCADQiCIIQQgA0L/////D4MgCyAUfnwhAyAEIANCIIh8IQQgA0L/////D4MgDSASfnwhAyAEIANCIIh8IQQgA0L/////D4MgDyAQfnwhAyAEIANCIIh8IQQgA0L/////D4MgESAOfnwhAyAEIANCIIh8IQQgA0L/////D4MgEyAMfnwhAyAEIANCIIh8IQQgAiADPgIoIARCIIghAyAEQv////8PgyANIBR+fCEEIAMgBEIgiHwhAyAEQv////8PgyAPIBJ+fCEEIAMgBEIgiHwhAyAEQv////8PgyARIBB+fCEEIAMgBEIgiHwhAyAEQv////8PgyATIA5+fCEEIAMgBEIgiHwhAyACIAQ+AiwgA0IgiCEEIANC/////w+DIA8gFH58IQMgBCADQiCIfCEEIANC/////w+DIBEgEn58IQMgBCADQiCIfCEEIANC/////w+DIBMgEH58IQMgBCADQiCIfCEEIAIgAz4CMCAEQiCIIQMgBEL/////D4MgESAUfnwhBCADIARCIIh8IQMgBEL/////D4MgEyASfnwhBCADIARCIIh8IQMgAiAEPgI0IANCIIghBCADQv////8PgyATIBR+fCEDIAQgA0IgiHwhBCACIAM+AjggBEIgiCEDIAIgBD4CPAv0EAEBfkEoIAA1AgAgATUCAH43AwBBKCAANQIAIAE1AgR+NwMIQSggADUCACABNQIIfjcDEEEoIAA1AgAgATUCDH43AxhBKCAANQIAIAE1AhB+NwMgQSggADUCACABNQIUfjcDKEEoIAA1AgAgATUCGH43AzBBKCAANQIAIAE1Ahx+NwM4QSggADUCBCABNQIAfjcDQEEoIAA1AgQgATUCBH43A0hBKCAANQIEIAE1Agh+NwNQQSggADUCBCABNQIMfjcDWEEoIAA1AgQgATUCEH43A2BBKCAANQIEIAE1AhR+NwNoQSggADUCBCABNQIYfjcDcEEoIAA1AgQgATUCHH43A3hBKCAANQIIIAE1AgB+NwOAAUEoIAA1AgggATUCBH43A4gBQSggADUCCCABNQIIfjcDkAFBKCAANQIIIAE1Agx+NwOYAUEoIAA1AgggATUCEH43A6ABQSggADUCCCABNQIUfjcDqAFBKCAANQIIIAE1Ahh+NwOwAUEoIAA1AgggATUCHH43A7gBQSggADUCDCABNQIAfjcDwAFBKCAANQIMIAE1AgR+NwPIAUEoIAA1AgwgATUCCH43A9ABQSggADUCDCABNQIMfjcD2AFBKCAANQIMIAE1AhB+NwPgAUEoIAA1AgwgATUCFH43A+gBQSggADUCDCABNQIYfjcD8AFBKCAANQIMIAE1Ahx+NwP4AUEoIAA1AhAgATUCAH43A4ACQSggADUCECABNQIEfjcDiAJBKCAANQIQIAE1Agh+NwOQAkEoIAA1AhAgATUCDH43A5gCQSggADUCECABNQIQfjcDoAJBKCAANQIQIAE1AhR+NwOoAkEoIAA1AhAgATUCGH43A7ACQSggADUCECABNQIcfjcDuAJBKCAANQIUIAE1AgB+NwPAAkEoIAA1AhQgATUCBH43A8gCQSggADUCFCABNQIIfjcD0AJBKCAANQIUIAE1Agx+NwPYAkEoIAA1AhQgATUCEH43A+ACQSggADUCFCABNQIUfjcD6AJBKCAANQIUIAE1Ahh+NwPwAkEoIAA1AhQgATUCHH43A/gCQSggADUCGCABNQIAfjcDgANBKCAANQIYIAE1AgR+NwOIA0EoIAA1AhggATUCCH43A5ADQSggADUCGCABNQIMfjcDmANBKCAANQIYIAE1AhB+NwOgA0EoIAA1AhggATUCFH43A6gDQSggADUCGCABNQIYfjcDsANBKCAANQIYIAE1Ahx+NwO4A0EoIAA1AhwgATUCAH43A8ADQSggADUCHCABNQIEfjcDyANBKCAANQIcIAE1Agh+NwPQA0EoIAA1AhwgATUCDH43A9gDQSggADUCHCABNQIQfjcD4ANBKCAANQIcIAE1AhR+NwPoA0EoIAA1AhwgATUCGH43A/ADQSggADUCHCABNQIcfjcD+AMgA0IgiEEoNQIAfCEDIAIgAz4CACADQiCIQSg1AgR8QSg1Agh8QSg1AkB8IQMgAiADPgIEIANCIIhBKDUCDHxBKDUCRHxBKDUCEHxBKDUCSHxBKDUCgAF8IQMgAiADPgIIIANCIIhBKDUCFHxBKDUCTHxBKDUChAF8QSg1Ahh8QSg1AlB8QSg1AogBfEEoNQLAAXwhAyACIAM+AgwgA0IgiEEoNQIcfEEoNQJUfEEoNQKMAXxBKDUCxAF8QSg1AiB8QSg1Alh8QSg1ApABfEEoNQLIAXxBKDUCgAJ8IQMgAiADPgIQIANCIIhBKDUCJHxBKDUCXHxBKDUClAF8QSg1AswBfEEoNQKEAnxBKDUCKHxBKDUCYHxBKDUCmAF8QSg1AtABfEEoNQKIAnxBKDUCwAJ8IQMgAiADPgIUIANCIIhBKDUCLHxBKDUCZHxBKDUCnAF8QSg1AtQBfEEoNQKMAnxBKDUCxAJ8QSg1AjB8QSg1Amh8QSg1AqABfEEoNQLYAXxBKDUCkAJ8QSg1AsgCfEEoNQKAA3whAyACIAM+AhggA0IgiEEoNQI0fEEoNQJsfEEoNQKkAXxBKDUC3AF8QSg1ApQCfEEoNQLMAnxBKDUChAN8QSg1Ajh8QSg1AnB8QSg1AqgBfEEoNQLgAXxBKDUCmAJ8QSg1AtACfEEoNQKIA3xBKDUCwAN8IQMgAiADPgIcIANCIIhBKDUCPHxBKDUCdHxBKDUCrAF8QSg1AuQBfEEoNQKcAnxBKDUC1AJ8QSg1AowDfEEoNQLEA3xBKDUCeHxBKDUCsAF8QSg1AugBfEEoNQKgAnxBKDUC2AJ8QSg1ApADfEEoNQLIA3whAyACIAM+AiAgA0IgiEEoNQJ8fEEoNQK0AXxBKDUC7AF8QSg1AqQCfEEoNQLcAnxBKDUClAN8QSg1AswDfEEoNQK4AXxBKDUC8AF8QSg1AqgCfEEoNQLgAnxBKDUCmAN8QSg1AtADfCEDIAIgAz4CJCADQiCIQSg1ArwBfEEoNQL0AXxBKDUCrAJ8QSg1AuQCfEEoNQKcA3xBKDUC1AN8QSg1AvgBfEEoNQKwAnxBKDUC6AJ8QSg1AqADfEEoNQLYA3whAyACIAM+AiggA0IgiEEoNQL8AXxBKDUCtAJ8QSg1AuwCfEEoNQKkA3xBKDUC3AN8QSg1ArgCfEEoNQLwAnxBKDUCqAN8QSg1AuADfCEDIAIgAz4CLCADQiCIQSg1ArwCfEEoNQL0AnxBKDUCrAN8QSg1AuQDfEEoNQL4AnxBKDUCsAN8QSg1AugDfCEDIAIgAz4CMCADQiCIQSg1AvwCfEEoNQK0A3xBKDUC7AN8QSg1ArgDfEEoNQLwA3whAyACIAM+AjQgA0IgiEEoNQK8A3xBKDUC9AN8QSg1AvgDfCEDIAIgAz4COCADQiCIQSg1AvwDfCEDIAIgAz4CPAu2AQEBfiAANQAAIAF+IQMgAiADPgAAIAA1AAQgAX4gA0IgiHwhAyACIAM+AAQgADUACCABfiADQiCIfCEDIAIgAz4ACCAANQAMIAF+IANCIIh8IQMgAiADPgAMIAA1ABAgAX4gA0IgiHwhAyACIAM+ABAgADUAFCABfiADQiCIfCEDIAIgAz4AFCAANQAYIAF+IANCIIh8IQMgAiADPgAYIAA1ABwgAX4gA0IgiHwhAyACIAM+ABwLTgIBfgF/IAAhAyADNQAAIAF8IQIgAyACPgAAIAJCIIghAgJAA0AgAlANASADQQRqIQMgAzUAACACfCECIAMgAj4AACACQiCIIQIMAAsLC7ACBwF/AX8BfwF/AX4BfgF/IAIEQCACIQUFQcgEIQULIAMEQCADIQQFQegEIQQLIAAgBBAAIAFBqAQQACAFEAFBiAUQAUEfIQZBHyEHAkADQEGoBCAHai0AACAHQQNGcg0BIAdBAWshBwwACwtBqAQgB2pBA2s1AABCAXwhCCAIQgFRBEBCAEIAgBoLAkADQAJAA0AgBCAGai0AACAGQQdGcg0BIAZBAWshBgwACwsgBCAGakEHaykAACEJIAkgCIAhCSAGIAdrQQRrIQoCQANAIAlCgICAgHCDUCAKQQBOcQ0BIAlCCIghCSAKQQFqIQoMAAsLIAlQBEAgBEGoBBAFRQ0CQgEhCUEAIQoLQagEIAlBqAUQCiAEQagFIAprIAQQBxogBSAKaiAJEAsMAAsLC7UCCwF/AX8BfwF/AX8BfwF/AX8BfwF/AX9ByAUhA0HIBRABQQAhC0HoBSEFIAFB6AUQAEGIBiEEQYgGEANBACEMQagGIQggAEGoBhAAQcgGIQZB6AYhB0HIByEKAkADQCAIEAINASAFIAggBiAHEAwgBiAEQYgHEAggCwRAIAwEQEGIByADEAUEQEGIByADIAoQBxpBACENBSADQYgHIAoQBxpBASENCwVBiAcgAyAKEAYaQQEhDQsFIAwEQEGIByADIAoQBhpBACENBSADQYgHEAUEQCADQYgHIAoQBxpBACENBUGIByADIAoQBxpBASENCwsLIAMhCSAEIQMgCiEEIAkhCiAMIQsgDSEMIAUhCSAIIQUgByEIIAkhBwwACwsgCwRAIAEgAyACEAcaBSADIAIQAAsLLAAgACABIAIQBgRAIAJB6AcgAhAHGgUgAkHoBxAFBEAgAkHoByACEAcaCwsLFwAgACABIAIQBwRAIAJB6AcgAhAGGgsLFAAgABACRQRAQegHIAAgARAHGgsLnBEDAX4BfgF+QonHmaQOIQJCACEDIAA1AgAgAn5C/////w+DIQQgADUCACADQiCIfEHoBzUCACAEfnwhAyAAIAM+AgAgADUCBCADQiCIfEHoBzUCBCAEfnwhAyAAIAM+AgQgADUCCCADQiCIfEHoBzUCCCAEfnwhAyAAIAM+AgggADUCDCADQiCIfEHoBzUCDCAEfnwhAyAAIAM+AgwgADUCECADQiCIfEHoBzUCECAEfnwhAyAAIAM+AhAgADUCFCADQiCIfEHoBzUCFCAEfnwhAyAAIAM+AhQgADUCGCADQiCIfEHoBzUCGCAEfnwhAyAAIAM+AhggADUCHCADQiCIfEHoBzUCHCAEfnwhAyAAIAM+AhxB6AggA0IgiD4CAEIAIQMgADUCBCACfkL/////D4MhBCAANQIEIANCIIh8QegHNQIAIAR+fCEDIAAgAz4CBCAANQIIIANCIIh8QegHNQIEIAR+fCEDIAAgAz4CCCAANQIMIANCIIh8QegHNQIIIAR+fCEDIAAgAz4CDCAANQIQIANCIIh8QegHNQIMIAR+fCEDIAAgAz4CECAANQIUIANCIIh8QegHNQIQIAR+fCEDIAAgAz4CFCAANQIYIANCIIh8QegHNQIUIAR+fCEDIAAgAz4CGCAANQIcIANCIIh8QegHNQIYIAR+fCEDIAAgAz4CHCAANQIgIANCIIh8QegHNQIcIAR+fCEDIAAgAz4CIEHoCCADQiCIPgIEQgAhAyAANQIIIAJ+Qv////8PgyEEIAA1AgggA0IgiHxB6Ac1AgAgBH58IQMgACADPgIIIAA1AgwgA0IgiHxB6Ac1AgQgBH58IQMgACADPgIMIAA1AhAgA0IgiHxB6Ac1AgggBH58IQMgACADPgIQIAA1AhQgA0IgiHxB6Ac1AgwgBH58IQMgACADPgIUIAA1AhggA0IgiHxB6Ac1AhAgBH58IQMgACADPgIYIAA1AhwgA0IgiHxB6Ac1AhQgBH58IQMgACADPgIcIAA1AiAgA0IgiHxB6Ac1AhggBH58IQMgACADPgIgIAA1AiQgA0IgiHxB6Ac1AhwgBH58IQMgACADPgIkQegIIANCIIg+AghCACEDIAA1AgwgAn5C/////w+DIQQgADUCDCADQiCIfEHoBzUCACAEfnwhAyAAIAM+AgwgADUCECADQiCIfEHoBzUCBCAEfnwhAyAAIAM+AhAgADUCFCADQiCIfEHoBzUCCCAEfnwhAyAAIAM+AhQgADUCGCADQiCIfEHoBzUCDCAEfnwhAyAAIAM+AhggADUCHCADQiCIfEHoBzUCECAEfnwhAyAAIAM+AhwgADUCICADQiCIfEHoBzUCFCAEfnwhAyAAIAM+AiAgADUCJCADQiCIfEHoBzUCGCAEfnwhAyAAIAM+AiQgADUCKCADQiCIfEHoBzUCHCAEfnwhAyAAIAM+AihB6AggA0IgiD4CDEIAIQMgADUCECACfkL/////D4MhBCAANQIQIANCIIh8QegHNQIAIAR+fCEDIAAgAz4CECAANQIUIANCIIh8QegHNQIEIAR+fCEDIAAgAz4CFCAANQIYIANCIIh8QegHNQIIIAR+fCEDIAAgAz4CGCAANQIcIANCIIh8QegHNQIMIAR+fCEDIAAgAz4CHCAANQIgIANCIIh8QegHNQIQIAR+fCEDIAAgAz4CICAANQIkIANCIIh8QegHNQIUIAR+fCEDIAAgAz4CJCAANQIoIANCIIh8QegHNQIYIAR+fCEDIAAgAz4CKCAANQIsIANCIIh8QegHNQIcIAR+fCEDIAAgAz4CLEHoCCADQiCIPgIQQgAhAyAANQIUIAJ+Qv////8PgyEEIAA1AhQgA0IgiHxB6Ac1AgAgBH58IQMgACADPgIUIAA1AhggA0IgiHxB6Ac1AgQgBH58IQMgACADPgIYIAA1AhwgA0IgiHxB6Ac1AgggBH58IQMgACADPgIcIAA1AiAgA0IgiHxB6Ac1AgwgBH58IQMgACADPgIgIAA1AiQgA0IgiHxB6Ac1AhAgBH58IQMgACADPgIkIAA1AiggA0IgiHxB6Ac1AhQgBH58IQMgACADPgIoIAA1AiwgA0IgiHxB6Ac1AhggBH58IQMgACADPgIsIAA1AjAgA0IgiHxB6Ac1AhwgBH58IQMgACADPgIwQegIIANCIIg+AhRCACEDIAA1AhggAn5C/////w+DIQQgADUCGCADQiCIfEHoBzUCACAEfnwhAyAAIAM+AhggADUCHCADQiCIfEHoBzUCBCAEfnwhAyAAIAM+AhwgADUCICADQiCIfEHoBzUCCCAEfnwhAyAAIAM+AiAgADUCJCADQiCIfEHoBzUCDCAEfnwhAyAAIAM+AiQgADUCKCADQiCIfEHoBzUCECAEfnwhAyAAIAM+AiggADUCLCADQiCIfEHoBzUCFCAEfnwhAyAAIAM+AiwgADUCMCADQiCIfEHoBzUCGCAEfnwhAyAAIAM+AjAgADUCNCADQiCIfEHoBzUCHCAEfnwhAyAAIAM+AjRB6AggA0IgiD4CGEIAIQMgADUCHCACfkL/////D4MhBCAANQIcIANCIIh8QegHNQIAIAR+fCEDIAAgAz4CHCAANQIgIANCIIh8QegHNQIEIAR+fCEDIAAgAz4CICAANQIkIANCIIh8QegHNQIIIAR+fCEDIAAgAz4CJCAANQIoIANCIIh8QegHNQIMIAR+fCEDIAAgAz4CKCAANQIsIANCIIh8QegHNQIQIAR+fCEDIAAgAz4CLCAANQIwIANCIIh8QegHNQIUIAR+fCEDIAAgAz4CMCAANQI0IANCIIh8QegHNQIYIAR+fCEDIAAgAz4CNCAANQI4IANCIIh8QegHNQIcIAR+fCEDIAAgAz4COEHoCCADQiCIPgIcQegIIABBIGogARAOC74fIwF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX5CiceZpA4hBSADQv////8PgyAANQIAIgYgATUCACIHfnwhAyAEIANCIIh8IQQgA0L/////D4MgBX5C/////w+DIQggA0L/////D4NBADUC6AciCSAIfnwhAyAEIANCIIh8IQQgBEIgiCEDIARC/////w+DIAYgATUCBCILfnwhBCADIARCIIh8IQMgBEL/////D4MgADUCBCIKIAd+fCEEIAMgBEIgiHwhAyAEQv////8Pg0EANQLsByINIAh+fCEEIAMgBEIgiHwhAyAEQv////8PgyAFfkL/////D4MhDCAEQv////8PgyAJIAx+fCEEIAMgBEIgiHwhAyADQiCIIQQgA0L/////D4MgBiABNQIIIg9+fCEDIAQgA0IgiHwhBCADQv////8PgyAKIAt+fCEDIAQgA0IgiHwhBCADQv////8PgyAANQIIIg4gB358IQMgBCADQiCIfCEEIANC/////w+DIA0gDH58IQMgBCADQiCIfCEEIANC/////w+DQQA1AvAHIhEgCH58IQMgBCADQiCIfCEEIANC/////w+DIAV+Qv////8PgyEQIANC/////w+DIAkgEH58IQMgBCADQiCIfCEEIARCIIghAyAEQv////8PgyAGIAE1AgwiE358IQQgAyAEQiCIfCEDIARC/////w+DIAogD358IQQgAyAEQiCIfCEDIARC/////w+DIA4gC358IQQgAyAEQiCIfCEDIARC/////w+DIAA1AgwiEiAHfnwhBCADIARCIIh8IQMgBEL/////D4MgDSAQfnwhBCADIARCIIh8IQMgBEL/////D4MgESAMfnwhBCADIARCIIh8IQMgBEL/////D4NBADUC9AciFSAIfnwhBCADIARCIIh8IQMgBEL/////D4MgBX5C/////w+DIRQgBEL/////D4MgCSAUfnwhBCADIARCIIh8IQMgA0IgiCEEIANC/////w+DIAYgATUCECIXfnwhAyAEIANCIIh8IQQgA0L/////D4MgCiATfnwhAyAEIANCIIh8IQQgA0L/////D4MgDiAPfnwhAyAEIANCIIh8IQQgA0L/////D4MgEiALfnwhAyAEIANCIIh8IQQgA0L/////D4MgADUCECIWIAd+fCEDIAQgA0IgiHwhBCADQv////8PgyANIBR+fCEDIAQgA0IgiHwhBCADQv////8PgyARIBB+fCEDIAQgA0IgiHwhBCADQv////8PgyAVIAx+fCEDIAQgA0IgiHwhBCADQv////8Pg0EANQL4ByIZIAh+fCEDIAQgA0IgiHwhBCADQv////8PgyAFfkL/////D4MhGCADQv////8PgyAJIBh+fCEDIAQgA0IgiHwhBCAEQiCIIQMgBEL/////D4MgBiABNQIUIht+fCEEIAMgBEIgiHwhAyAEQv////8PgyAKIBd+fCEEIAMgBEIgiHwhAyAEQv////8PgyAOIBN+fCEEIAMgBEIgiHwhAyAEQv////8PgyASIA9+fCEEIAMgBEIgiHwhAyAEQv////8PgyAWIAt+fCEEIAMgBEIgiHwhAyAEQv////8PgyAANQIUIhogB358IQQgAyAEQiCIfCEDIARC/////w+DIA0gGH58IQQgAyAEQiCIfCEDIARC/////w+DIBEgFH58IQQgAyAEQiCIfCEDIARC/////w+DIBUgEH58IQQgAyAEQiCIfCEDIARC/////w+DIBkgDH58IQQgAyAEQiCIfCEDIARC/////w+DQQA1AvwHIh0gCH58IQQgAyAEQiCIfCEDIARC/////w+DIAV+Qv////8PgyEcIARC/////w+DIAkgHH58IQQgAyAEQiCIfCEDIANCIIghBCADQv////8PgyAGIAE1AhgiH358IQMgBCADQiCIfCEEIANC/////w+DIAogG358IQMgBCADQiCIfCEEIANC/////w+DIA4gF358IQMgBCADQiCIfCEEIANC/////w+DIBIgE358IQMgBCADQiCIfCEEIANC/////w+DIBYgD358IQMgBCADQiCIfCEEIANC/////w+DIBogC358IQMgBCADQiCIfCEEIANC/////w+DIAA1AhgiHiAHfnwhAyAEIANCIIh8IQQgA0L/////D4MgDSAcfnwhAyAEIANCIIh8IQQgA0L/////D4MgESAYfnwhAyAEIANCIIh8IQQgA0L/////D4MgFSAUfnwhAyAEIANCIIh8IQQgA0L/////D4MgGSAQfnwhAyAEIANCIIh8IQQgA0L/////D4MgHSAMfnwhAyAEIANCIIh8IQQgA0L/////D4NBADUCgAgiISAIfnwhAyAEIANCIIh8IQQgA0L/////D4MgBX5C/////w+DISAgA0L/////D4MgCSAgfnwhAyAEIANCIIh8IQQgBEIgiCEDIARC/////w+DIAYgATUCHCIjfnwhBCADIARCIIh8IQMgBEL/////D4MgCiAffnwhBCADIARCIIh8IQMgBEL/////D4MgDiAbfnwhBCADIARCIIh8IQMgBEL/////D4MgEiAXfnwhBCADIARCIIh8IQMgBEL/////D4MgFiATfnwhBCADIARCIIh8IQMgBEL/////D4MgGiAPfnwhBCADIARCIIh8IQMgBEL/////D4MgHiALfnwhBCADIARCIIh8IQMgBEL/////D4MgADUCHCIiIAd+fCEEIAMgBEIgiHwhAyAEQv////8PgyANICB+fCEEIAMgBEIgiHwhAyAEQv////8PgyARIBx+fCEEIAMgBEIgiHwhAyAEQv////8PgyAVIBh+fCEEIAMgBEIgiHwhAyAEQv////8PgyAZIBR+fCEEIAMgBEIgiHwhAyAEQv////8PgyAdIBB+fCEEIAMgBEIgiHwhAyAEQv////8PgyAhIAx+fCEEIAMgBEIgiHwhAyAEQv////8Pg0EANQKECCIlIAh+fCEEIAMgBEIgiHwhAyAEQv////8PgyAFfkL/////D4MhJCAEQv////8PgyAJICR+fCEEIAMgBEIgiHwhAyADQiCIIQQgA0L/////D4MgCiAjfnwhAyAEIANCIIh8IQQgA0L/////D4MgDiAffnwhAyAEIANCIIh8IQQgA0L/////D4MgEiAbfnwhAyAEIANCIIh8IQQgA0L/////D4MgFiAXfnwhAyAEIANCIIh8IQQgA0L/////D4MgGiATfnwhAyAEIANCIIh8IQQgA0L/////D4MgHiAPfnwhAyAEIANCIIh8IQQgA0L/////D4MgIiALfnwhAyAEIANCIIh8IQQgA0L/////D4MgDSAkfnwhAyAEIANCIIh8IQQgA0L/////D4MgESAgfnwhAyAEIANCIIh8IQQgA0L/////D4MgFSAcfnwhAyAEIANCIIh8IQQgA0L/////D4MgGSAYfnwhAyAEIANCIIh8IQQgA0L/////D4MgHSAUfnwhAyAEIANCIIh8IQQgA0L/////D4MgISAQfnwhAyAEIANCIIh8IQQgA0L/////D4MgJSAMfnwhAyAEIANCIIh8IQQgAiADPgIAIARCIIghAyAEQv////8PgyAOICN+fCEEIAMgBEIgiHwhAyAEQv////8PgyASIB9+fCEEIAMgBEIgiHwhAyAEQv////8PgyAWIBt+fCEEIAMgBEIgiHwhAyAEQv////8PgyAaIBd+fCEEIAMgBEIgiHwhAyAEQv////8PgyAeIBN+fCEEIAMgBEIgiHwhAyAEQv////8PgyAiIA9+fCEEIAMgBEIgiHwhAyAEQv////8PgyARICR+fCEEIAMgBEIgiHwhAyAEQv////8PgyAVICB+fCEEIAMgBEIgiHwhAyAEQv////8PgyAZIBx+fCEEIAMgBEIgiHwhAyAEQv////8PgyAdIBh+fCEEIAMgBEIgiHwhAyAEQv////8PgyAhIBR+fCEEIAMgBEIgiHwhAyAEQv////8PgyAlIBB+fCEEIAMgBEIgiHwhAyACIAQ+AgQgA0IgiCEEIANC/////w+DIBIgI358IQMgBCADQiCIfCEEIANC/////w+DIBYgH358IQMgBCADQiCIfCEEIANC/////w+DIBogG358IQMgBCADQiCIfCEEIANC/////w+DIB4gF358IQMgBCADQiCIfCEEIANC/////w+DICIgE358IQMgBCADQiCIfCEEIANC/////w+DIBUgJH58IQMgBCADQiCIfCEEIANC/////w+DIBkgIH58IQMgBCADQiCIfCEEIANC/////w+DIB0gHH58IQMgBCADQiCIfCEEIANC/////w+DICEgGH58IQMgBCADQiCIfCEEIANC/////w+DICUgFH58IQMgBCADQiCIfCEEIAIgAz4CCCAEQiCIIQMgBEL/////D4MgFiAjfnwhBCADIARCIIh8IQMgBEL/////D4MgGiAffnwhBCADIARCIIh8IQMgBEL/////D4MgHiAbfnwhBCADIARCIIh8IQMgBEL/////D4MgIiAXfnwhBCADIARCIIh8IQMgBEL/////D4MgGSAkfnwhBCADIARCIIh8IQMgBEL/////D4MgHSAgfnwhBCADIARCIIh8IQMgBEL/////D4MgISAcfnwhBCADIARCIIh8IQMgBEL/////D4MgJSAYfnwhBCADIARCIIh8IQMgAiAEPgIMIANCIIghBCADQv////8PgyAaICN+fCEDIAQgA0IgiHwhBCADQv////8PgyAeIB9+fCEDIAQgA0IgiHwhBCADQv////8PgyAiIBt+fCEDIAQgA0IgiHwhBCADQv////8PgyAdICR+fCEDIAQgA0IgiHwhBCADQv////8PgyAhICB+fCEDIAQgA0IgiHwhBCADQv////8PgyAlIBx+fCEDIAQgA0IgiHwhBCACIAM+AhAgBEIgiCEDIARC/////w+DIB4gI358IQQgAyAEQiCIfCEDIARC/////w+DICIgH358IQQgAyAEQiCIfCEDIARC/////w+DICEgJH58IQQgAyAEQiCIfCEDIARC/////w+DICUgIH58IQQgAyAEQiCIfCEDIAIgBD4CFCADQiCIIQQgA0L/////D4MgIiAjfnwhAyAEIANCIIh8IQQgA0L/////D4MgJSAkfnwhAyAEIANCIIh8IQQgAiADPgIYIARCIIghAyACIAQ+AhwgA6cEQCACQegHIAIQBxoFIAJB6AcQBQRAIAJB6AcgAhAHGgsLCxIAIAAgAUHoDBAJQegMIAIQEQsLACAAQYgIIAEQEgsVACAAQagNEABByA0QAUGoDSABEBELFwAgACABEBUgAUHoByABEA0gASABEBQLCQBBqAggABAACywAIAAgASACEAYEQCACQegNIAIQBxoFIAJB6A0QBQRAIAJB6A0gAhAHGgsLCxcAIAAgASACEAcEQCACQegNIAIQBhoLCxQAIAAQAkUEQEHoDSAAIAEQBxoLC5wRAwF+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+DIQQgADUCHCADQiCIfEHoDTUCACAEfnwhAyAAIAM+AhwgADUCICADQiCIfEHoDTUCBCAEfnwhAyAAIAM+AiAgADUCJCADQiCIfEHoDTUCCCAEfnwhAyAAIAM+AiQgADUCKCADQiCIfEHoDTUCDCAEfnwhAyAAIAM+AiggADUCLCADQiCIfEHoDTUCECAEfnwhAyAAIAM+AiwgADUCMCADQiCIfEHoDTUCFCAEfnwhAyAAIAM+AjAgADUCNCADQiCIfEHoDTUCGCAEfnwhAyAAIAM+AjQgADUCOCADQiCIfEHoDTUCHCAEfnwhAyAAIAM+AjhB6A4gA0IgiD4CHEHoDiAAQSBqIAEQGAu+HyMBfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+AX4BfgF+Qv////8OIQUgA0L/////D4MgADUCACIGIAE1AgAiB358IQMgBCADQiCIfCEEIANC/////w+DIAV+Qv////8PgyEIIANC/////w+DQQA1AugNIgkgCH58IQMgBCADQiCIfCEEIARCIIghAyAEQv////8PgyAGIAE1AgQiC358IQQgAyAEQiCIfCEDIARC/////w+DIAA1AgQiCiAHfnwhBCADIARCIIh8IQMgBEL/////D4NBADUC7A0iDSAIfnwhBCADIARCIIh8IQMgBEL/////D4MgBX5C/////w+DIQwgBEL/////D4MgCSAMfnwhBCADIARCIIh8IQMgA0IgiCEEIANC/////w+DIAYgATUCCCIPfnwhAyAEIANCIIh8IQQgA0L/////D4MgCiALfnwhAyAEIANCIIh8IQQgA0L/////D4MgADUCCCIOIAd+fCEDIAQgA0IgiHwhBCADQv////8PgyANIAx+fCEDIAQgA0IgiHwhBCADQv////8Pg0EANQLwDSIRIAh+fCEDIAQgA0IgiHwhBCADQv////8PgyAFfkL/////D4MhECADQv////8PgyAJIBB+fCEDIAQgA0IgiHwhBCAEQiCIIQMgBEL/////D4MgBiABNQIMIhN+fCEEIAMgBEIgiHwhAyAEQv////8PgyAKIA9+fCEEIAMgBEIgiHwhAyAEQv////8PgyAOIAt+fCEEIAMgBEIgiHwhAyAEQv////8PgyAANQIMIhIgB358IQQgAyAEQiCIfCEDIARC/////w+DIA0gEH58IQQgAyAEQiCIfCEDIARC/////w+DIBEgDH58IQQgAyAEQiCIfCEDIARC/////w+DQQA1AvQNIhUgCH58IQQgAyAEQiCIfCEDIARC/////w+DIAV+Qv////8PgyEUIARC/////w+DIAkgFH58IQQgAyAEQiCIfCEDIANCIIghBCADQv////8PgyAGIAE1AhAiF358IQMgBCADQiCIfCEEIANC/////w+DIAogE358IQMgBCADQiCIfCEEIANC/////w+DIA4gD358IQMgBCADQiCIfCEEIANC/////w+DIBIgC358IQMgBCADQiCIfCEEIANC/////w+DIAA1AhAiFiAHfnwhAyAEIANCIIh8IQQgA0L/////D4MgDSAUfnwhAyAEIANCIIh8IQQgA0L/////D4MgESAQfnwhAyAEIANCIIh8IQQgA0L/////D4MgFSAMfnwhAyAEIANCIIh8IQQgA0L/////D4NBADUC+A0iGSAIfnwhAyAEIANCIIh8IQQgA0L/////D4MgBX5C/////w+DIRggA0L/////D4MgCSAYfnwhAyAEIANCIIh8IQQgBEIgiCEDIARC/////w+DIAYgATUCFCIbfnwhBCADIARCIIh8IQMgBEL/////D4MgCiAXfnwhBCADIARCIIh8IQMgBEL/////D4MgDiATfnwhBCADIARCIIh8IQMgBEL/////D4MgEiAPfnwhBCADIARCIIh8IQMgBEL/////D4MgFiALfnwhBCADIARCIIh8IQMgBEL/////D4MgADUCFCIaIAd+fCEEIAMgBEIgiHwhAyAEQv////8PgyANIBh+fCEEIAMgBEIgiHwhAyAEQv////8PgyARIBR+fCEEIAMgBEIgiHwhAyAEQv////8PgyAVIBB+fCEEIAMgBEIgiHwhAyAEQv////8PgyAZIAx+fCEEIAMgBEIgiHwhAyAEQv////8Pg0EANQL8DSIdIAh+fCEEIAMgBEIgiHwhAyAEQv////8PgyAFfkL/////D4MhHCAEQv////8PgyAJIBx+fCEEIAMgBEIgiHwhAyADQiCIIQQgA0L/////D4MgBiABNQIYIh9+fCEDIAQgA0IgiHwhBCADQv////8PgyAKIBt+fCEDIAQgA0IgiHwhBCADQv////8PgyAOIBd+fCEDIAQgA0IgiHwhBCADQv////8PgyASIBN+fCEDIAQgA0IgiHwhBCADQv////8PgyAWIA9+fCEDIAQgA0IgiHwhBCADQv////8PgyAaIAt+fCEDIAQgA0IgiHwhBCADQv////8PgyAANQIYIh4gB358IQMgBCADQiCIfCEEIANC/////w+DIA0gHH58IQMgBCADQiCIfCEEIANC/////w+DIBEgGH58IQMgBCADQiCIfCEEIANC/////w+DIBUgFH58IQMgBCADQiCIfCEEIANC/////w+DIBkgEH58IQMgBCADQiCIfCEEIANC/////w+DIB0gDH58IQMgBCADQiCIfCEEIANC/////w+DQQA1AoAOIiEgCH58IQMgBCADQiCIfCEEIANC/////w+DIAV+Qv////8PgyEgIANC/////w+DIAkgIH58IQMgBCADQiCIfCEEIARCIIghAyAEQv////8PgyAGIAE1AhwiI358IQQgAyAEQiCIfCEDIARC/////w+DIAogH358IQQgAyAEQiCIfCEDIARC/////w+DIA4gG358IQQgAyAEQiCIfCEDIARC/////w+DIBIgF358IQQgAyAEQiCIfCEDIARC/////w+DIBYgE358IQQgAyAEQiCIfCEDIARC/////w+DIBogD358IQQgAyAEQiCIfCEDIARC/////w+DIB4gC358IQQgAyAEQiCIfCEDIARC/////w+DIAA1AhwiIiAHfnwhBCADIARCIIh8IQMgBEL/////D4MgDSAgfnwhBCADIARCIIh8IQMgBEL/////D4MgESAcfnwhBCADIARCIIh8IQMgBEL/////D4MgFSAYfnwhBCADIARCIIh8IQMgBEL/////D4MgGSAUfnwhBCADIARCIIh8IQMgBEL/////D4MgHSAQfnwhBCADIARCIIh8IQMgBEL/////D4MgISAMfnwhBCADIARCIIh8IQMgBEL/////D4NBADUChA4iJSAIfnwhBCADIARCIIh8IQMgBEL/////D4MgBX5C/////w+DISQgBEL/////D4MgCSAkfnwhBCADIARCIIh8IQMgA0IgiCEEIANC/////w+DIAogI358IQMgBCADQiCIfCEEIANC/////w+DIA4gH358IQMgBCADQiCIfCEEIANC/////w+DIBIgG358IQMgBCADQiCIfCEEIANC/////w+DIBYgF358IQMgBCADQiCIfCEEIANC/////w+DIBogE358IQMgBCADQiCIfCEEIANC/////w+DIB4gD358IQMgBCADQiCIfCEEIANC/////w+DICIgC358IQMgBCADQiCIfCEEIANC/////w+DIA0gJH58IQMgBCADQiCIfCEEIANC/////w+DIBEgIH58IQMgBCADQiCIfCEEIANC/////w+DIBUgHH58IQMgBCADQiCIfCEEIANC/////w+DIBkgGH58IQMgBCADQiCIfCEEIANC/////w+DIB0gFH58IQMgBCADQiCIfCEEIANC/////w+DICEgEH58IQMgBCADQiCIfCEEIANC/////w+DICUgDH58IQMgBCADQiCIfCEEIAIgAz4CACAEQiCIIQMgBEL/////D4MgDiAjfnwhBCADIARCIIh8IQMgBEL/////D4MgEiAffnwhBCADIARCIIh8IQMgBEL/////D4MgFiAbfnwhBCADIARCIIh8IQMgBEL/////D4MgGiAXfnwhBCADIARCIIh8IQMgBEL/////D4MgHiATfnwhBCADIARCIIh8IQMgBEL/////D4MgIiAPfnwhBCADIARCIIh8IQMgBEL/////D4MgESAkfnwhBCADIARCIIh8IQMgBEL/////D4MgFSAgfnwhBCADIARCIIh8IQMgBEL/////D4MgGSAcfnwhBCADIARCIIh8IQMgBEL/////D4MgHSAYfnwhBCADIARCIIh8IQMgBEL/////D4MgISAUfnwhBCADIARCIIh8IQMgBEL/////D4MgJSAQfnwhBCADIARCIIh8IQMgAiAEPgIEIANCIIghBCADQv////8PgyASICN+fCEDIAQgA0IgiHwhBCADQv////8PgyAWIB9+fCEDIAQgA0IgiHwhBCADQv////8PgyAaIBt+fCEDIAQgA0IgiHwhBCADQv////8PgyAeIBd+fCEDIAQgA0IgiHwhBCADQv////8PgyAiIBN+fCEDIAQgA0IgiHwhBCADQv////8PgyAVICR+fCEDIAQgA0IgiHwhBCADQv////8PgyAZICB+fCEDIAQgA0IgiHwhBCADQv////8PgyAdIBx+fCEDIAQgA0IgiHwhBCADQv////8PgyAhIBh+fCEDIAQgA0IgiHwhBCADQv////8PgyAlIBR+fCEDIAQgA0IgiHwhBCACIAM+AgggBEIgiCEDIARC/////w+DIBYgI358IQQgAyAEQiCIfCEDIARC/////w+DIBogH358IQQgAyAEQiCIfCEDIARC/////w+DIB4gG358IQQgAyAEQiCIfCEDIARC/////w+DICIgF358IQQgAyAEQiCIfCEDIARC/////w+DIBkgJH58IQQgAyAEQiCIfCEDIARC/////w+DIB0gIH58IQQgAyAEQiCIfCEDIARC/////w+DICEgHH58IQQgAyAEQiCIfCEDIARC/////w+DICUgGH58IQQgAyAEQiCIfCEDIAIgBD4CDCADQiCIIQQgA0L/////D4MgGiAjfnwhAyAEIANCIIh8IQQgA0L/////D4MgHiAffnwhAyAEIANCIIh8IQQgA0L/////D4MgIiAbfnwhAyAEIANCIIh8IQQgA0L/////D4MgHSAkfnwhAyAEIANCIIh8IQQgA0L/////D4MgISAgfnwhAyAEIANCIIh8IQQgA0L/////D4MgJSAcfnwhAyAEIANCIIh8IQQgAiADPgIQIARCIIghAyAEQv////8PgyAeICN+fCEEIAMgBEIgiHwhAyAEQv////8PgyAiIB9+fCEEIAMgBEIgiHwhAyAEQv////8PgyAhICR+fCEEIAMgBEIgiHwhAyAEQv////8PgyAlICB+fCEEIAMgBEIgiHwhAyACIAQ+AhQgA0IgiCEEIANC/////w+DICIgI358IQMgBCADQiCIfCEEIANC/////w+DICUgJH58IQMgBCADQiCIfCEEIAIgAz4CGCAEQiCIIQMgAiAEPgIcIAOnBEAgAkHoDSACEAcaBSACQegNEAUEQCACQegNIAIQBxoLCwsSACAAIAFB6BIQCUHoEiACEBsLCwAgAEGIDiABEBwLFQAgAEGoExAAQcgTEAFBqBMgARAbCxcAIAAgARAfIAFB6A0gARANIAEgARAeCwkAQagOIAAQAAsVACAAIAFB6BMQHEHoE0GIDiACEBwLCwAgAEHoDSABEA0LCgAgAEHAAGoQAgsVACAAEAEgAEEgahAXIABBwABqEAELIgAgACABEAAgAEEgaiABQSBqEAAgAEHAAGogAUHAAGoQAAuGAgAgABAkBEAgACABECYPCyAAIABBiBQQEiAAQSBqIABBIGpBqBQQEkGoFEGoFEHIFBASIABBqBRB6BQQDkHoFEHoFEHoFBASQegUQYgUQegUEA9B6BRByBRB6BQQD0HoFEHoFEHoFBAOQYgUQYgUQYgVEA5BiBVBiBRBiBUQDkGIFUGIFUGoFRASIABBIGogAEHAAGpByBUQEkHoFEHoFCABEA5BqBUgASABEA9ByBRByBRB6BUQDkHoFUHoFUHoFRAOQegVQegVQegVEA5B6BQgASABQSBqEA8gAUEgakGIFSABQSBqEBIgAUEgakHoFSABQSBqEA9ByBVByBUgAUHAAGoQDgusAwIBfwF/IABBwABqIQMgAUHAAGohBCAAECQEQCABIAIQJg8LIAEQJARAIAAgAhAmDwsgAyADQYgWEBIgBCAEQagWEBIgAEGoFkHIFhASIAFBiBZB6BYQEiADQYgWQYgXEBIgBEGoFkGoFxASIABBIGpBqBdByBcQEiABQSBqQYgXQegXEBJByBZB6BYQBARAQcgXQegXEAQEQCAAIAIQJw8LC0HoFkHIFkGIGBAPQegXQcgXQagYEA9BiBhBiBhByBgQDkHIGEHIGEHIGBASQYgYQcgYQegYEBJBqBhBqBhBiBkQDkHIFkHIGEHIGRASQYgZQYgZQagZEBJByBlByBlB6BkQDkGoGUHoGCACEA8gAkHoGSACEA9ByBdB6BhBiBoQEkGIGkGIGkGIGhAOQcgZIAIgAkEgahAPIAJBIGpBiBkgAkEgahASIAJBIGpBiBogAkEgahAPIAMgBCACQcAAahAOIAJBwABqIAJBwABqIAJBwABqEBIgAkHAAGpBiBYgAkHAAGoQDyACQcAAakGoFiACQcAAahAPIAJBwABqQYgYIAJBwABqEBILIgAgACABEAAgAEEgaiABQSBqEBAgAEHAAGogAUHAAGoQAAsQACABIAIQKSAAIAIgAhAoCyIAIAAgARAVIABBIGogAUEgahAVIABBwABqIAFBwABqEBULIgAgACABEBQgAEEgaiABQSBqEBQgAEHAAGogAUHAAGoQFAtPACAAECQEQCABECUFIABBwABqQagaEBZBqBpBqBpByBoQEkGoGkHIGkHoGhASIABByBogARASIABBIGpB6BogAUEgahASIAFBwABqEBcLC6cCAgF/AX8gAEGIGxAmIAMQJSACIQQCQANAIARBAWshBCABIARqLQAAIQUgAyADECcgBUGAAU8EQCAFQYABayEFQYgbIAMgAxAoCyADIAMQJyAFQcAATwRAIAVBwABrIQVBiBsgAyADECgLIAMgAxAnIAVBIE8EQCAFQSBrIQVBiBsgAyADECgLIAMgAxAnIAVBEE8EQCAFQRBrIQVBiBsgAyADECgLIAMgAxAnIAVBCE8EQCAFQQhrIQVBiBsgAyADECgLIAMgAxAnIAVBBE8EQCAFQQRrIQVBiBsgAyADECgLIAMgAxAnIAVBAk8EQCAFQQJrIQVBiBsgAyADECgLIAMgAxAnIAVBAU8EQCAFQQFrIQVBiBsgAyADECgLIARFDQEMAAsLCysCAX8BfyAAQQV2QQJ0IQFBASAAQR9xdCECIAEgASgC6NsBIAJyNgLo2wELJAIBfwF/IABBBXZBAnQhAUEBIABBH3F0IQIgASgC6NsBIAJxC6ABBAF/AX8BfwF/IAAhAkHoGxAlQQAhBAJAA0AgBCABRg0BQegbQQEgBHRB4ABsaiEDIAIQAiEFIAIgAxAAIAJBIGohAiADQSBqIQMgAiADEAAgAkEgaiECIANBIGohAyAFBEAgAxABBSADEBcLIARBAWohBAwACwtB6NsBQpeChIAQNwMAQfDbAUIBNwMAQfjbAUIBNwMAQYDcAUIANwMAC0ADAX8BfwF/QegbIABB4ABsaiEBIAAQMEUEQCAALQCI3AEQMiECIAAtAIjeARAyIQMgAiADIAEQKCAAEC8LIAELpQEEAX8BfwF+AX5BACEDAkADQCADQSBGDQFCACEGQQAhBAJAA0AgBCABRg0BIAAgBEEgbCADamoxAAAhBSAFIAVCHIaEQo+AgIDwAYMhBSAFIAVCDoaEQoOAjICwgMABgyEFIAUgBUIHhoRCgYKEiJCgwIABgyEFIAYgBSAErYaEIQYgBEEBaiEEDAALCyACIANBCGxqIAY3AwAgA0EBaiEDDAALCwtLAQF/IAAgAkGI4AEQMyADECUgASACEDFBACEEAkADQCAEQYACRg0BIAMgAxAnIANBh+IBIARrLQAAEDIgAxAoIARBAWohBAwACwsLfgQBfwF/AX8BfyAAIQUgASEGIAUgAiADbiADbEEgbGohCAJAA0AgBSAIRg0BIAUgBiADQYjiARA0QYjiASAEIAQQKCAFQSAgA2xqIQUgBkHAACADbGohBgwACwsgAiADcCEHIAcEQCAFIAYgB0GI4gEQNEGI4gEgBCAEECgLC04CAX8BfyAAIAJB6OIBEDMgASACEDFBACEEAkADQCAEQYACRg0BIAMgBEHgAGxqIQUgBUHn5AEgBGstAAAQMiAFECggBEEBaiEEDAALCwspAQF/QQAhAgJAA0AgAiABRg0BIAAgAkHgAGxqECUgAkEBaiECDAALCwtIAgF/AX8gACEEIAQgAhAmIARB4ABqIQRBASEDAkADQCADIAFGDQEgAiACECcgBCACIAIQKCAEQeAAaiEEIANBAWohAwwACwsLigEEAX8BfwF/AX9B6OQBQYACEDcgACEFIAEhBiAFIAIgA24gA2xBIGxqIQgCQANAIAUgCEYNASAFIAYgA0Ho5AEQNiAFQSAgA2xqIQUgBkHAACADbGohBgwACwsgAiADcCEHIAcEQCAFIAYgB0Ho5AEQNgtB6OQBQYACQeikAxA4QeikAyAEIAQQKAtGACAAQf8BcS0AiLQDQRh0IABBCHZB/wFxLQCItANBEHRqIABBEHZB/wFxLQCItANBCHQgAEEYdkH/AXEtAIi0A2pqIAF3C2cFAX8BfwF/AX8Bf0EBIAF0IQJBACEDAkADQCADIAJGDQEgACADQSBsaiEFIAMgARA6IQQgACAEQSBsaiEGIAMgBEkEQCAFQYi2AxAAIAYgBRAAQYi2AyAGEAALIANBAWohAwwACwsL7wEJAX8BfwF/AX8BfwF/AX8BfwF/IAAgARA7QQEgAXQhCEEBIQMCQANAIAMgAUsNAUEBIAN0IQZByKUDIANBIGxqIQlBACEEAkADQCAEIAhPDQEgAgRAIAlBIGpBqLYDEAAFQai2AxAhCyAGQQF2IQdBACEFAkADQCAFIAdPDQEgACAEIAVqQSBsaiEKIAogB0EgbGohC0GotgMgC0HItgMQHCAKQei2AxAAQei2A0HItgMgChAYQei2A0HItgMgCxAZQai2AyAJQai2AxAcIAVBAWohBQwACwsgBCAGaiEEDAALCyADQQFqIQMMAAsLCz4DAX8BfwF/IAAhAyABIQQgACACQSBsaiEFAkADQCADIAVGDQEgAyAEEAAgA0EgaiEDIARBwABqIQQMAAsLCz0DAX8BfwF/IAAhAyABIQQgACACQSBsaiEFAkADQCADIAVGDQEgAyAEEB8gA0EgaiEDIARBIGohBAwACwsLPQMBfwF/AX8gACEDIAEhBCAAIAJBIGxqIQUCQANAIAMgBUYNASADIAQQHiADQSBqIQMgBEEgaiEEDAALCwuWAQcBfwF/AX8BfwF/AX8Bf0EBIAF0IQJB6KwDIAFBIGxqIQQgAkEBayEGQQEhBSACQQF2IQMCQANAIAUgA0YNASAAIAVBIGxqIQcgACACIAVrQSBsaiEIIAdBiLcDEAAgCCAEIAcQHEGItwMgBCAIEBwgBUEBaiEFDAALCyAAIAQgABAcIAAgA0EgbGohCCAIIAQgCBAcC0MCAX8BfyAAQQF2IQJBACEBAkADQCACRQ0BIAJBAXYhAiABQQFqIQEMAAsLIABBASABdEcEQAALIAFBHEsEQAALIAELEgEBfyABEEEhAyAAIAMgAhA8CxgBAX8gARBBIQMgACADIAIQPCAAIAMQQAtMBAF/AX8BfwF/IAAhBCABIQUgAyEGIAAgAkEgbGohBwJAA0AgBCAHRg0BIAQgBSAGEBwgBEEgaiEEIAVBIGohBSAGQSBqIQYMAAsLCy4CAX8BfyAAIQMgACABQSBsaiECAkADQCADIAJGDQEgAxABIANBIGohAwwACwsLjgEGAX8BfwF/AX8BfwF/QQAhBCAAIQYgASEHAkADQCAEIAJGDQEgBigCACEJIAZBBGohBkEAIQUCQANAIAUgCUYNASADIAYoAgBBIGxqIQggBkEEaiEGIAcgBkGotwMQHEGotwMgCCAIEBggBkEgaiEGIAVBAWohBQwACwsgB0EgaiEHIARBAWohBAwACwsLDgAgABACIABBIGoQAnELDQAgABABIABBIGoQAQsNACAAEBcgAEEgahABCxQAIAAgARAAIABBIGogAUEgahAAC3kAIAAgAUHotwMQEiAAQSBqIAFBIGpBiLgDEBIgACAAQSBqQai4AxAOIAEgAUEgakHIuAMQDkGouANByLgDQai4AxASQYi4A0HItwMgAhASQei3AyACIAIQDkHotwNBiLgDIAJBIGoQDkGouAMgAkEgaiACQSBqEA8LGwAgACABIAIQDiAAQSBqIAFBIGogAkEgahAOCxsAIAAgASACEA8gAEEgaiABQSBqIAJBIGoQDwsUACAAIAEQECAAQSBqIAFBIGoQEAsUACAAIAEQFCAAQSBqIAFBIGoQFAsUACAAIAEQFSAAQSBqIAFBIGoQFQsVACAAIAEQBCAAQSBqIAFBIGoQBHELaAAgACAAQei4AxASIABBIGogAEEgakGIuQMQEkGIuQNByLcDQai5AxASQei4A0GouQNBqLkDEA9BqLkDQci5AxAWIABByLkDIAEQEiAAQSBqQci5AyABQSBqEBIgAUEgaiABQSBqEBALCgAgAEGAAWoQRwsWACAAEEggAEHAAGoQSSAAQYABahBICyQAIAAgARBKIABBwABqIAFBwABqEEogAEGAAWogAUGAAWoQSgu8AgAgABBTBEAgACABEFUPCyAAIABB6LkDEEsgAEHAAGogAEHAAGpBqLoDEEtBqLoDQai6A0HougMQSyAAQai6A0GouwMQTEGouwNBqLsDQai7AxBLQai7A0HouQNBqLsDEE1BqLsDQei6A0GouwMQTUGouwNBqLsDQai7AxBMQei5A0HouQNB6LsDEExB6LsDQei5A0HouwMQTEHouwNB6LsDQai8AxBLIABBwABqIABBgAFqQei8AxBLQai7A0GouwMgARBMQai8AyABIAEQTUHougNB6LoDQai9AxBMQai9A0GovQNBqL0DEExBqL0DQai9A0GovQMQTEGouwMgASABQcAAahBNIAFBwABqQei7AyABQcAAahBLIAFBwABqQai9AyABQcAAahBNQei8A0HovAMgAUGAAWoQTAvvAwIBfwF/IABBgAFqIQMgAUGAAWohBCAAEFMEQCABIAIQVQ8LIAEQUwRAIAAgAhBVDwsgAyADQei9AxBLIAQgBEGovgMQSyAAQai+A0HovgMQSyABQei9A0GovwMQSyADQei9A0HovwMQSyAEQai+A0GowAMQSyAAQcAAakGowANB6MADEEsgAUHAAGpB6L8DQajBAxBLQei+A0GovwMQUQRAQejAA0GowQMQUQRAIAAgAhBWDwsLQai/A0HovgNB6MEDEE1BqMEDQejAA0GowgMQTUHowQNB6MEDQejCAxBMQejCA0HowgNB6MIDEEtB6MEDQejCA0GowwMQS0GowgNBqMIDQejDAxBMQei+A0HowgNB6MQDEEtB6MMDQejDA0GoxAMQS0HoxANB6MQDQajFAxBMQajEA0GowwMgAhBNIAJBqMUDIAIQTUHowANBqMMDQejFAxBLQejFA0HoxQNB6MUDEExB6MQDIAIgAkHAAGoQTSACQcAAakHowwMgAkHAAGoQSyACQcAAakHoxQMgAkHAAGoQTSADIAQgAkGAAWoQTCACQYABaiACQYABaiACQYABahBLIAJBgAFqQei9AyACQYABahBNIAJBgAFqQai+AyACQYABahBNIAJBgAFqQejBAyACQYABahBLCyQAIAAgARBKIABBwABqIAFBwABqEE4gAEGAAWogAUGAAWoQSgsQACABIAIQWCAAIAIgAhBXCyQAIAAgARBQIABBwABqIAFBwABqEFAgAEGAAWogAUGAAWoQUAskACAAIAEQTyAAQcAAaiABQcAAahBPIABBgAFqIAFBgAFqEE8LWgAgABBTBEAgARBUBSAAQYABakGoxgMQUkGoxgNBqMYDQejGAxBLQajGA0HoxgNBqMcDEEsgAEHoxgMgARBLIABBwABqQajHAyABQcAAahBLIAFBgAFqEEkLC7ACAgF/AX8gAEHoxwMQVSADEFQgAiEEAkADQCAEQQFrIQQgASAEai0AACEFIAMgAxBWIAVBgAFPBEAgBUGAAWshBUHoxwMgAyADEFcLIAMgAxBWIAVBwABPBEAgBUHAAGshBUHoxwMgAyADEFcLIAMgAxBWIAVBIE8EQCAFQSBrIQVB6McDIAMgAxBXCyADIAMQViAFQRBPBEAgBUEQayEFQejHAyADIAMQVwsgAyADEFYgBUEITwRAIAVBCGshBUHoxwMgAyADEFcLIAMgAxBWIAVBBE8EQCAFQQRrIQVB6McDIAMgAxBXCyADIAMQViAFQQJPBEAgBUECayEFQejHAyADIAMQVwsgAyADEFYgBUEBTwRAIAVBAWshBUHoxwMgAyADEFcLIARFDQEMAAsLCysCAX8BfyAAQQV2QQJ0IQFBASAAQR9xdCECIAEgASgCqMkGIAJyNgKoyQYLJAIBfwF/IABBBXZBAnQhAUEBIABBH3F0IQIgASgCqMkGIAJxC6YBBAF/AX8BfwF/IAAhAkGoyQMQVEEAIQQCQANAIAQgAUYNAUGoyQNBASAEdEHAAWxqIQMgAhBHIQUgAiADEEogAkHAAGohAiADQcAAaiEDIAIgAxBKIAJBwABqIQIgA0HAAGohAyAFBEAgAxBIBSADEEkLIARBAWohBAwACwtBqMkGQpeChIAQNwMAQbDJBkIBNwMAQbjJBkIBNwMAQcDJBkIANwMAC0EDAX8BfwF/QajJAyAAQcABbGohASAAEF9FBEAgAC0AyMkGEGEhAiAALQDIywYQYSEDIAIgAyABEFcgABBeCyABC6UBBAF/AX8BfgF+QQAhAwJAA0AgA0EgRg0BQgAhBkEAIQQCQANAIAQgAUYNASAAIARBIGwgA2pqMQAAIQUgBSAFQhyGhEKPgICA8AGDIQUgBSAFQg6GhEKDgIyAsIDAAYMhBSAFIAVCB4aEQoGChIiQoMCAAYMhBSAGIAUgBK2GhCEGIARBAWohBAwACwsgAiADQQhsaiAGNwMAIANBAWohAwwACwsLSwEBfyAAIAJByM0GEGIgAxBUIAEgAhBgQQAhBAJAA0AgBEGAAkYNASADIAMQViADQcfPBiAEay0AABBhIAMQVyAEQQFqIQQMAAsLC34EAX8BfwF/AX8gACEFIAEhBiAFIAIgA24gA2xBIGxqIQgCQANAIAUgCEYNASAFIAYgA0HIzwYQY0HIzwYgBCAEEFcgBUEgIANsaiEFIAZBgAEgA2xqIQYMAAsLIAIgA3AhByAHBEAgBSAGIAdByM8GEGNByM8GIAQgBBBXCwtOAgF/AX8gACACQYjRBhBiIAEgAhBgQQAhBAJAA0AgBEGAAkYNASADIARBwAFsaiEFIAVBh9MGIARrLQAAEGEgBRBXIARBAWohBAwACwsLKQEBf0EAIQICQANAIAIgAUYNASAAIAJBwAFsahBUIAJBAWohAgwACwsLSAIBfwF/IAAhBCAEIAIQVSAEQcABaiEEQQEhAwJAA0AgAyABRg0BIAIgAhBWIAQgAiACEFcgBEHAAWohBCADQQFqIQMMAAsLC4oBBAF/AX8BfwF/QYjTBkGAAhBmIAAhBSABIQYgBSACIANuIANsQSBsaiEIAkADQCAFIAhGDQEgBSAGIANBiNMGEGUgBUEgIANsaiEFIAZBgAEgA2xqIQYMAAsLIAIgA3AhByAHBEAgBSAGIAdBiNMGEGULQYjTBkGAAkGI0wkQZ0GI0wkgBCAEEFcLJAEBfyADIQQCQANAIAAgASACEBIgBEEBayEEIARFDQEMAAsLCyQBAX8gAyEEAkADQCAAIAEgAhATIARBAWshBCAERQ0BDAALCwsL/hsSAEEACwRIagIAAEEICyABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABB6AcLIEf9fNgWjCA8jcpxaJFqgZddWIGBtkVQuCmgMeFyTmQwAEGICAsgifqKU1v8LPP7AUXUERnntfZ/QQr/HqtHHzW4ynGf2AYAQagICyCdDY/FjUNd0z0Lx/Uo63gKLEZ5eG+jbmYv3weawXcKDgBByAgLIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEHoDQsgAQAA8JP14UORcLl5SOgzKF1YgYG2RVC4KaAx4XJOZDAAQYgOCyCnbSGuRea4G+NZXOOxOv5ThYC7Uz2DSYylRE5/sdAWAgBBqA4LIPv//08cNJasKc1gn5V2/DYuRnl4b6NuZi/fB5rBdwoOAEHIDgsgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQYjcAQuAAgAAAAIABAQGAAgICggMDAwAEBASEBQUFBAYGBgYGBgcACAgIiAkJCQgKCgoKCgoLCAwMDAwMDA0MDAwODA4ODgAQEBCQEREREBISEhISEhMQFBQUFBQUFRQUFBYUFhYWEBgYGBgYGBkYGBgaGBoaGhgYGBwYHBwcGBwcHBwcHB4AICAgoCEhISAiIiIiIiIjICQkJCQkJCUkJCQmJCYmJiAoKCgoKCgpKCgoKigqKiooKCgsKCwsLCgsLCwsLCwuIDAwMDAwMDEwMDAyMDIyMjAwMDQwNDQ0MDQ0NDQ0NDYwMDA4MDg4ODA4ODg4ODg6MDg4ODg4ODw4ODg8ODw8PAAQYjeAQuAAgAAAAEAAQIBAAECAQQBAgMAAQIBBAECAwgBAgMEBQYDAAECAQQBAgMIAQIDBAUGAxABAgMEBQYDCAkKAwwFBgcAAQIBBAECAwgBAgMEBQYDEAECAwQFBgMICQoDDAUGByABAgMEBQYDCAkKAwwFBgcQERIDFAUGBxgJCgsMDQ4HAAECAQQBAgMIAQIDBAUGAxABAgMEBQYDCAkKAwwFBgcgAQIDBAUGAwgJCgMMBQYHEBESAxQFBgcYCQoLDA0OB0ABAgMEBQYDCAkKAwwFBgcQERIDFAUGBxgJCgsMDQ4HICEiAyQFBgcoCQoLDA0OBzAREhMUFRYHGBkaCxwNDg8AQcilAwugB/v//08cNJasKc1gn5V2/DYuRnl4b6NuZi/fB5rBdwoOBgAAoHfBS5dno1jasnE38S4SCAlHouFR+sApR7HWWSKL79yelz11fyCRR7EsFz9fbmwJdHlisY3PCME5NXs3Kz98rbXiSq34voXLg//GYC33KZRdK/122anZmj/nfEAkA48vdHx9tvTMaNBj3C0baGpX+xvvvOWM/jy20lEpfBZkTFe/sfcUIvJ9MfcvI/kozXWtsKiEdeUDbRfcWfuBK0KecG6u8VG1znHA3RMpmJsOBYBC6VZzZO31B/wGuNMJgFNdsQYNFKuXWzG8zDovjE+ZBJIlN1l4NCbiWfDzshwAnKOeMZOPf4JXzPlZECV7fFP7zWe9g1asm6gYrsbsFzMECZKPksjJo/TZf6YBR9mLJ4/9+1Xmzt4OLRdwRY4VE6UgZnX5WZ2ZVwHqo0XnM2zdv2C/4paJx+I1twLvpiIudgBd/OlRSeWuZMGCrX128iJOQvGv4V+XE7D47etlI9kBPlZnQaSjJboMUrpemCwhbXCfkuALYy7ljTRjrYwPGmYZCIlu6JiUND20wnGJpQyvbkFNfcvYJ1nvfCLUBAERlgf+kG8TKjJxjFo7lZGQN1CWNzfy380mlBQCXqEpDNRyDoJMZGltDMJyc8g9YzCdm1pCQQw7VxcnCqB/QlgeELjTUZK0AZScwI809Zg83oOT1AeLGbXPYwx/RlvO7CngQ+GA5vdXj3vbSsX5Loork99rO4/jEMoAAl1nXrctKecj6qy4yOYv8R6NjwW1zvfwzRJ8H4QnUTCoubd9byIhzi1+AHOxdSTqeQVkX6otYtxn8e7Xdq71fylqiLEQ7iUzR54WRLPrASD4tYlq3XaJ3TQOTAP7n6IA4mGcFayzGX0R+krdZAdiV5Mti3GsHJG6+FYYISp3CMFg9aFV9WgXZIs6zEmo7UWQbqVH9LpafStbw6/v4Ua/Pkg47qP9/RfvaMRqvM7HsG9Jryf2s34eEapUzcyjkkpfuMOubR1HFMwGf4lFmV7tafi5x3bRxWN5uYLSR51EFtxVzV1/hyoj2h08y2o/HLkYoHNUZKTEngzfD2tkXfnp9i7EyNy6ei9uxcz31cVAdqfy89gf8xbnR/8w9Pae3HbbOE42ZfQcIrN9xQ6tQO/ha7dA7s7CGs1m0ftNi8+MHDB7M+wTiPEQuP45tsXHMpaZ8g8NQONcmNjssAEAiN2yKc6YbQ0HaR0AQeisAwugB/v//08cNJasKc1gn5V2/DYuRnl4b6NuZi/fB5rBdwoO/v//H9gUPHjdHo0Mby+Yr0VP/fySdF+PrL+cPRpjNx////8PbAoevG6PRoa3F8zXoqd+fkm6r0fWX84ejbGbDwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAQYi0AwuAAgCAQMAgoGDgEJBQ0DCwcPAIiEjIKKho6BiYWNg4uHj4BIRExCSkZOQUlFTUNLR09AyMTMwsrGzsHJxc3Dy8fPwCgkLCIqJi4hKSUtIysnLyCopKyiqqauoamlraOrp6+gaGRsYmpmbmFpZW1ja2dvYOjk7OLq5u7h6eXt4+vn7+AYFBwSGhYeERkVHRMbFx8QmJSckpqWnpGZlZ2Tm5efkFhUXFJaVl5RWVVdU1tXX1DY1NzS2tbe0dnV3dPb19/QODQ8Mjo2PjE5NT0zOzc/MLi0vLK6tr6xubW9s7u3v7B4dHxyenZ+cXl1fXN7d39w+PT88vr2/vH59f3z+/f/8AQci3Awsgqu/tEolIw2hPv6pyaH8IjTESCAlHouFR+sApR7HWWSIAQcjJBguAAgAAAAIABAQGAAgICggMDAwAEBASEBQUFBAYGBgYGBgcACAgIiAkJCQgKCgoKCgoLCAwMDAwMDA0MDAwODA4ODgAQEBCQEREREBISEhISEhMQFBQUFBQUFRQUFBYUFhYWEBgYGBgYGBkYGBgaGBoaGhgYGBwYHBwcGBwcHBwcHB4AICAgoCEhISAiIiIiIiIjICQkJCQkJCUkJCQmJCYmJiAoKCgoKCgpKCgoKigqKiooKCgsKCwsLCgsLCwsLCwuIDAwMDAwMDEwMDAyMDIyMjAwMDQwNDQ0MDQ0NDQ0NDYwMDA4MDg4ODA4ODg4ODg6MDg4ODg4ODw4ODg8ODw8PAAQcjLBguAAgAAAAEAAQIBAAECAQQBAgMAAQIBBAECAwgBAgMEBQYDAAECAQQBAgMIAQIDBAUGAxABAgMEBQYDCAkKAwwFBgcAAQIBBAECAwgBAgMEBQYDEAECAwQFBgMICQoDDAUGByABAgMEBQYDCAkKAwwFBgcQERIDFAUGBxgJCgsMDQ4HAAECAQQBAgMIAQIDBAUGAxABAgMEBQYDCAkKAwwFBgcgAQIDBAUGAwgJCgMMBQYHEBESAxQFBgcYCQoLDA0OB0ABAgMEBQYDCAkKAwwFBgcQERIDFAUGBxgJCgsMDQ4HICEiAyQFBgcoCQoLDA0OBzAREhMUFRYHGBkaCxwNDg8=", "base64"); + groth16_wasm$1.pq = 1000; + groth16_wasm$1.pr = 1768; + +/* + Copyright 2019 0KIMS association. + + This file is part of websnark (Web Assembly zkSnark Prover). + + websnark is a free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + websnark is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with websnark. If not, see . +*/ + +/* globals WebAssembly, Blob, Worker, navigator, Promise, window */ +const bigInt = BigIntegerExports; +const groth16_wasm = groth16_wasm$1; +const assert = assert$6; + +const inBrowser = (typeof window !== "undefined"); +let NodeWorker; +let NodeCrypto; +if (!inBrowser) { + NodeWorker = threads.Worker; + NodeCrypto = require$$5; +} + + +class Deferred { + constructor() { + this.promise = new Promise((resolve, reject)=> { + this.reject = reject; + this.resolve = resolve; + }); + } +} + +/* +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} +*/ + +function thread(self) { + let instance; + let memory; + let i32; + + async function init(data) { + const code = new Uint8Array(data.code); + const wasmModule = await WebAssembly.compile(code); + memory = new WebAssembly.Memory({initial:data.init}); + i32 = new Uint32Array(memory.buffer); + + instance = await WebAssembly.instantiate(wasmModule, { + env: { + "memory": memory + } + }); + } + + function alloc(length) { + while (i32[0] & 3) i32[0]++; // Return always aligned pointers + const res = i32[0]; + i32[0] += length; + while (i32[0] > memory.buffer.byteLength) { + memory.grow(100); + } + i32 = new Uint32Array(memory.buffer); + return res; + } + + function putBin(b) { + const p = alloc(b.byteLength); + const s32 = new Uint32Array(b); + i32.set(s32, p/4); + return p; + } + + function getBin(p, l) { + return memory.buffer.slice(p, p+l); + } + + self.onmessage = function(e) { + let data; + if (e.data) { + data = e.data; + } else { + data = e; + } + + if (data.command == "INIT") { + init(data).then(function() { + self.postMessage(data.result); + }); + } else if (data.command == "G1_MULTIEXP") { + + const oldAlloc = i32[0]; + const pScalars = putBin(data.scalars); + const pPoints = putBin(data.points); + const pRes = alloc(96); + instance.exports.g1_zero(pRes); + instance.exports.g1_multiexp2(pScalars, pPoints, data.n, 7, pRes); + + data.result = getBin(pRes, 96); + i32[0] = oldAlloc; + self.postMessage(data.result, [data.result]); + } else if (data.command == "G2_MULTIEXP") { + + const oldAlloc = i32[0]; + const pScalars = putBin(data.scalars); + const pPoints = putBin(data.points); + const pRes = alloc(192); + instance.exports.g2_zero(pRes); + instance.exports.g2_multiexp(pScalars, pPoints, data.n, 7, pRes); + + data.result = getBin(pRes, 192); + i32[0] = oldAlloc; + self.postMessage(data.result, [data.result]); + } else if (data.command == "CALC_H") { + const oldAlloc = i32[0]; + const pSignals = putBin(data.signals); + const pPolsA = putBin(data.polsA); + const pPolsB = putBin(data.polsB); + const nSignals = data.nSignals; + const domainSize = data.domainSize; + const pSignalsM = alloc(nSignals*32); + const pPolA = alloc(domainSize*32); + const pPolB = alloc(domainSize*32); + const pPolA2 = alloc(domainSize*32*2); + const pPolB2 = alloc(domainSize*32*2); + + instance.exports.fft_toMontgomeryN(pSignals, pSignalsM, nSignals); + + instance.exports.pol_zero(pPolA, domainSize); + instance.exports.pol_zero(pPolB, domainSize); + + instance.exports.pol_constructLC(pPolsA, pSignalsM, nSignals, pPolA); + instance.exports.pol_constructLC(pPolsB, pSignalsM, nSignals, pPolB); + + instance.exports.fft_copyNInterleaved(pPolA, pPolA2, domainSize); + instance.exports.fft_copyNInterleaved(pPolB, pPolB2, domainSize); + + instance.exports.fft_ifft(pPolA, domainSize, 0); + instance.exports.fft_ifft(pPolB, domainSize, 0); + instance.exports.fft_fft(pPolA, domainSize, 1); + instance.exports.fft_fft(pPolB, domainSize, 1); + + instance.exports.fft_copyNInterleaved(pPolA, pPolA2+32, domainSize); + instance.exports.fft_copyNInterleaved(pPolB, pPolB2+32, domainSize); + + instance.exports.fft_mulN(pPolA2, pPolB2, domainSize*2, pPolA2); + + instance.exports.fft_ifft(pPolA2, domainSize*2, 0); + + instance.exports.fft_fromMontgomeryN(pPolA2+domainSize*32, pPolA2+domainSize*32, domainSize); + + data.result = getBin(pPolA2+domainSize*32, domainSize*32); + i32[0] = oldAlloc; + self.postMessage(data.result, [data.result]); + } else if (data.command == "TERMINATE") { + process.exit(); + } + }; +} + +// We use the Object.assign approach for the backwards compatibility +// @params Number wasmInitialMemory +async function build(params) { + const defaultParams = { wasmInitialMemory: 5000 }; + Object.assign(defaultParams, params); + const groth16 = new Groth16(); + + groth16.q = bigInt("21888242871839275222246405745257275088696311157297823662689037894645226208583"); + groth16.r = bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617"); + groth16.n64 = Math.floor((groth16.q.minus(1).bitLength() - 1)/64) +1; + groth16.n32 = groth16.n64*2; + groth16.n8 = groth16.n64*8; + + groth16.memory = new WebAssembly.Memory({initial:defaultParams.wasmInitialMemory}); + groth16.i32 = new Uint32Array(groth16.memory.buffer); + + const wasmModule = await WebAssembly.compile(groth16_wasm.code); + + groth16.instance = await WebAssembly.instantiate(wasmModule, { + env: { + "memory": groth16.memory + } + }); + + groth16.pq = groth16_wasm.pq; + groth16.pr = groth16_wasm.pr; + + groth16.pr0 = groth16.alloc(192); + groth16.pr1 = groth16.alloc(192); + + groth16.workers = []; + groth16.pendingDeferreds = []; + groth16.working = []; + + let concurrency; + + if ((typeof(navigator) === "object") && navigator.hardwareConcurrency) { + concurrency = navigator.hardwareConcurrency; + } else { + concurrency = 8; + } + + function getOnMsg(i) { + return function(e) { + let data; + if ((e)&&(e.data)) { + data = e.data; + } else { + data = e; + } + + groth16.working[i]=false; + groth16.pendingDeferreds[i].resolve(data); + groth16.processWorks(); + }; + } + + for (let i = 0; i 0); i++) { + if (this.working[i] == false) { + const work = this.actionQueue.shift(); + this.postAction(i, work.data, work.transfers, work.deferred); + } + } + } + + queueAction(actionData, transfers) { + const d = new Deferred(); + this.actionQueue.push({ + data: actionData, + transfers: transfers, + deferred: d + }); + this.processWorks(); + return d.promise; + } + + alloc(length) { + while (this.i32[0] & 3) this.i32[0]++; // Return always aligned pointers + const res = this.i32[0]; + this.i32[0] += length; + return res; + } + + + putBin(p, b) { + const s32 = new Uint32Array(b); + this.i32.set(s32, p/4); + } + + getBin(p, l) { + return this.memory.buffer.slice(p, p+l); + } + + bin2int(b) { + const i32 = new Uint32Array(b); + let acc = bigInt(i32[7]); + for (let i=6; i>=0; i--) { + acc = acc.shiftLeft(32); + acc = acc.add(i32[i]); + } + return acc.toString(); + } + + bin2g1(b) { + return [ + this.bin2int(b.slice(0,32)), + this.bin2int(b.slice(32,64)), + this.bin2int(b.slice(64,96)), + ]; + } + bin2g2(b) { + return [ + [ + this.bin2int(b.slice(0,32)), + this.bin2int(b.slice(32,64)) + ], + [ + this.bin2int(b.slice(64,96)), + this.bin2int(b.slice(96,128)) + ], + [ + this.bin2int(b.slice(128,160)), + this.bin2int(b.slice(160,192)) + ], + ]; + } + + async g1_multiexp(scalars, points) { + const nPoints = scalars.byteLength /32; + const nPointsPerThread = Math.floor(nPoints / this.workers.length); + const opPromises = []; + for (let i=0; i { + /* Debug code to print the result of h + for (let i=0; i " + a.toString()); + } +*/ + return this.g1_multiexp(h, pointsHExps); + }); + + const pA = this.g1_multiexp(signals.slice(0), pointsA); + const pB1 = this.g1_multiexp(signals.slice(0), pointsB1); + const pB2 = this.g2_multiexp(signals.slice(0), pointsB2); + const pC = this.g1_multiexp(signals.slice((nPublic+1)*32), pointsC); + + const res = await Promise.all([pA, pB1, pB2, pC, pH]); + + const pi_a = this.alloc(96); + const pi_b = this.alloc(192); + const pi_c = this.alloc(96); + const pib1 = this.alloc(96); + + + this.putBin(pi_a, res[0]); + this.putBin(pib1, res[1]); + this.putBin(pi_b, res[2]); + this.putBin(pi_c, res[3]); + + const pAlfa1 = this.loadPoint1(alfa1); + const pBeta1 = this.loadPoint1(beta1); + const pDelta1 = this.loadPoint1(delta1); + const pBeta2 = this.loadPoint2(beta2); + const pDelta2 = this.loadPoint2(delta2); + + + let rnd = new Uint32Array(8); + + const aux1 = this.alloc(96); + const aux2 = this.alloc(192); + + const pr = this.alloc(32); + const ps = this.alloc(32); + + if (inBrowser) { + window.crypto.getRandomValues(rnd); + this.putBin(pr, rnd); + + window.crypto.getRandomValues(rnd); + this.putBin(ps, rnd); + } else { + const br = NodeCrypto.randomBytes(32); + this.putBin(pr, br); + const bs = NodeCrypto.randomBytes(32); + this.putBin(ps, bs); + } + + /// Uncoment it to debug and check it works + // this.instance.exports.f1m_zero(pr); + // this.instance.exports.f1m_zero(ps); + + // pi_a = pi_a + Alfa1 + r*Delta1 + this.instance.exports.g1_add(pAlfa1, pi_a, pi_a); + this.instance.exports.g1_timesScalar(pDelta1, pr, 32, aux1); + this.instance.exports.g1_add(aux1, pi_a, pi_a); + + // pi_b = pi_b + Beta2 + s*Delta2 + this.instance.exports.g2_add(pBeta2, pi_b, pi_b); + this.instance.exports.g2_timesScalar(pDelta2, ps, 32, aux2); + this.instance.exports.g2_add(aux2, pi_b, pi_b); + + // pib1 = pib1 + Beta1 + s*Delta1 + this.instance.exports.g1_add(pBeta1, pib1, pib1); + this.instance.exports.g1_timesScalar(pDelta1, ps, 32, aux1); + this.instance.exports.g1_add(aux1, pib1, pib1); + + + // pi_c = pi_c + pH + this.putBin(aux1, res[4]); + this.instance.exports.g1_add(aux1, pi_c, pi_c); + + + // pi_c = pi_c + s*pi_a + this.instance.exports.g1_timesScalar(pi_a, ps, 32, aux1); + this.instance.exports.g1_add(aux1, pi_c, pi_c); + + // pi_c = pi_c + r*pib1 + this.instance.exports.g1_timesScalar(pib1, pr, 32, aux1); + this.instance.exports.g1_add(aux1, pi_c, pi_c); + + // pi_c = pi_c - r*s*delta1 + const prs = this.alloc(64); + this.instance.exports.int_mul(pr, ps, prs); + this.instance.exports.g1_timesScalar(pDelta1, prs, 64, aux1); + this.instance.exports.g1_neg(aux1, aux1); + this.instance.exports.g1_add(aux1, pi_c, pi_c); + + this.instance.exports.g1_affine(pi_a, pi_a); + this.instance.exports.g2_affine(pi_b, pi_b); + this.instance.exports.g1_affine(pi_c, pi_c); + + this.instance.exports.g1_fromMontgomery(pi_a, pi_a); + this.instance.exports.g2_fromMontgomery(pi_b, pi_b); + this.instance.exports.g1_fromMontgomery(pi_c, pi_c); + + return { + pi_a: this.bin2g1(this.getBin(pi_a, 96)), + pi_b: this.bin2g2(this.getBin(pi_b, 192)), + pi_c: this.bin2g1(this.getBin(pi_c, 96)), + }; + + } + +} + +var groth16$1 = build; + +var websnarkGroth = /*@__PURE__*/getDefaultExportFromCjs(groth16$1); + +var __async$1 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +let groth16; +const groth16Promise = (() => __async$1(void 0, null, function* () { + if (!groth16) { + groth16 = yield websnarkGroth({ wasmInitialMemory: 2e3 }); + } +}))(); +function calculateSnarkProof(input, circuit, provingKey) { + return __async$1(this, null, function* () { + yield groth16Promise; + const snarkInput = { + root: input.root, + nullifierHash: BigInt(input.nullifierHex).toString(), + recipient: BigInt(input.recipient), + relayer: BigInt(input.relayer), + fee: input.fee, + refund: input.refund, + nullifier: input.nullifier, + secret: input.secret, + pathElements: input.pathElements, + pathIndices: input.pathIndices + }; + console.log("Start generating SNARK proof", snarkInput); + console.time("SNARK proof time"); + const proofData = yield utils.genWitnessAndProve(groth16, snarkInput, circuit, provingKey); + const proof = utils.toSolidityInput(proofData).proof; + console.timeEnd("SNARK proof time"); + const args = [ + toFixedHex(input.root, 32), + toFixedHex(input.nullifierHex, 32), + input.recipient, + input.relayer, + toFixedHex(input.fee, 32), + toFixedHex(input.refund, 32) + ]; + return { proof, args }; + }); +} + +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); +var __async = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +const DEFAULT_GAS_LIMIT = 6e5; +const RELAYER_NETWORK = 1; +const TOKEN_PRICE_ORACLE = "0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8"; +const STATIC_DIR = process$2.env.CACHE_DIR || path$3.join(__dirname, "../static"); +const EVENTS_DIR = path$3.join(STATIC_DIR, "./events"); +path$3.join(STATIC_DIR, "./trees"); +const MERKLE_WORKER_PATH = process$2.env.DISABLE_MERKLE_WORKER === "true" ? void 0 : path$3.join(STATIC_DIR, "./merkleTreeWorker.js"); +const USER_DIR = process$2.env.USER_DIR || "."; +const SAVED_DIR = path$3.join(USER_DIR, "./events"); +const CIRCUIT_PATH = path$3.join(__dirname, "../static/tornado.json"); +const KEY_PATH = path$3.join(__dirname, "../static/tornadoProvingKey.bin"); +function promptConfirmation(nonInteractive) { + return __async(this, null, function* () { + if (nonInteractive) { + return; + } + const prompt = readline.createInterface({ input: process$2.stdin, output: process$2.stdout }); + const query = "Confirm? [Y/n]\n"; + const confirmation = yield new Promise((resolve) => prompt.question(query, resolve)); + if (!confirmation || confirmation.toUpperCase() !== "Y") { + throw new Error("User canceled"); + } + }); +} +function getIPAddress(fetchDataOptions2) { + return __async(this, null, function* () { + const htmlIPInfo = yield fetchData("https://check.torproject.org", __spreadProps(__spreadValues({}, fetchDataOptions2), { + method: "GET", + headers: { + "Content-Type": "text/html; charset=utf-8" + } + })); + const ip = htmlIPInfo.split("Your IP address appears to be: ").pop().split(" { + const value = options[key]; + if (typeof value !== "undefined") { + return [key, options[key]]; + } + }).filter((r) => r) + ); + console.log("\n" + optionsTable.toString() + "\n"); + yield promptConfirmation(options.nonInteractive); + return { + options, + fetchDataOptions: fetchDataOptions2 + }; + }); +} +function getProgramGraphAPI(options, config) { + if (options.disableGraph) { + return ""; + } + if (!options.graph) { + return Object.values(config.subgraphs)[0].url; + } + return options.graph; +} +function getProgramProvider(netId, rpcUrl = "", config, providerOptions) { + if (!rpcUrl) { + rpcUrl = Object.values(config.rpcUrls)[0].url; + } + return getProviderWithNetId(netId, rpcUrl, config, providerOptions); +} +function getProgramSigner({ + options, + provider +}) { + if (options.viewOnly) { + return new TornadoVoidSigner(options.viewOnly, provider); + } + if (options.privateKey) { + return new TornadoWallet(options.privateKey, provider); + } + if (options.mnemonic) { + return TornadoWallet.fromMnemonic(options.mnemonic, provider, options.mnemonicIndex); + } +} +function getProgramRelayer(_0) { + return __async(this, arguments, function* ({ + options, + fetchDataOptions: fetchDataOptions2, + netId + }) { + const { ethRpc, ethGraph, relayer, disableGraph } = options; + const netConfig = networkConfig[`netId${netId}`]; + const ethConfig = networkConfig[`netId${RELAYER_NETWORK}`]; + const { + aggregatorContract, + registryContract, + registrySubgraph, + constants: { REGISTRY_BLOCK } + } = ethConfig; + const provider = getProgramProvider(1, ethRpc, ethConfig, __spreadValues({}, fetchDataOptions2)); + const graphApi = getProgramGraphAPI( + { + disableGraph, + graph: ethGraph + }, + ethConfig + ); + const registryService = new NodeRegistryService({ + netId: RELAYER_NETWORK, + provider, + graphApi, + subgraphName: registrySubgraph, + RelayerRegistry: RelayerRegistry__factory.connect(registryContract, provider), + deployedBlock: REGISTRY_BLOCK, + fetchDataOptions: fetchDataOptions2, + cacheDirectory: EVENTS_DIR, + userDirectory: SAVED_DIR + }); + const relayerClient = new RelayerClient({ + netId, + config: netConfig, + Aggregator: Aggregator__factory.connect(aggregatorContract, provider), + fetchDataOptions: fetchDataOptions2 + }); + if (relayer) { + if (!relayer.endsWith(".eth")) { + const relayerStatus2 = yield relayerClient.askRelayerStatus({ + hostname: new URL(relayer).hostname + }); + if (relayerStatus2) { + relayerClient.selectedRelayer = { + netId: relayerStatus2.netId, + url: relayerStatus2.url, + rewardAccount: relayerStatus2.rewardAccount, + currentQueue: relayerStatus2.currentQueue, + tornadoServiceFee: relayerStatus2.tornadoServiceFee + }; + } + return { + validRelayers: relayerClient.selectedRelayer ? [relayerClient.selectedRelayer] : [], + invalidRelayers: [], + relayerClient + }; + } else { + const { validRelayers: validRelayers2 } = yield relayerClient.getValidRelayers([{ ensName: relayer }], subdomains, true); + const relayerStatus2 = validRelayers2[0]; + if (relayerStatus2) { + relayerClient.selectedRelayer = { + netId: relayerStatus2.netId, + url: relayerStatus2.url, + rewardAccount: relayerStatus2.rewardAccount, + currentQueue: relayerStatus2.currentQueue, + tornadoServiceFee: relayerStatus2.tornadoServiceFee + }; + } + return { + validRelayers: validRelayers2, + invalidRelayers: [], + relayerClient + }; + } + } + console.log("\nGetting valid relayers from registry, would take some time\n"); + const { validRelayers, invalidRelayers } = yield relayerClient.getValidRelayers( + yield registryService.fetchRelayers(), + subdomains + ); + const relayerStatus = relayerClient.pickWeightedRandomRelayer(validRelayers); + if (relayerStatus) { + relayerClient.selectedRelayer = { + netId: relayerStatus.netId, + url: relayerStatus.url, + rewardAccount: relayerStatus.rewardAccount, + currentQueue: relayerStatus.currentQueue, + tornadoServiceFee: relayerStatus.tornadoServiceFee + }; + } + return { + validRelayers, + invalidRelayers, + relayerClient + }; + }); +} +function programSendTransaction(_0) { + return __async(this, arguments, function* ({ + signer, + options, + populatedTransaction + }) { + const txTable = new Table(); + const txObject = !populatedTransaction.gasLimit || !populatedTransaction.from ? JSON.parse(JSON.stringify(yield signer.populateTransaction(populatedTransaction))) : JSON.parse(JSON.stringify(populatedTransaction, null, 2)); + const txKeys = Object.keys(txObject); + const txValues = Object.values(txObject); + const txType = signer instanceof VoidSigner ? "Unsigned Transaction" : options.localRpc ? "Unbroadcasted Transaction" : "Send Transaction?"; + txTable.push( + [{ colSpan: 2, content: txType, hAlign: "center" }], + ...txKeys.map((key, index) => { + if (key === "data" && txValues[index]) { + return ["data", substring(txValues[index], 40)]; + } + return [key, txValues[index]]; + }) + ); + if (txType === "Unsigned Transaction") { + delete txObject.from; + const transaction = Transaction.from(txObject); + console.log("\n" + txTable.toString() + "\n"); + console.log("Sign this transaction:\n"); + console.log(`${transaction.unsignedSerialized} +`); + return; + } + if (txType === "Unbroadcasted Transaction") { + const signedTx = yield signer.signTransaction(txObject); + console.log("\n" + txTable.toString() + "\n"); + console.log("Broadcast transaction:\n"); + console.log(`${signedTx} +`); + return; + } + console.log("\n" + txTable.toString() + "\n"); + yield promptConfirmation(options.nonInteractive); + const { hash } = yield signer.sendTransaction(txObject); + console.log(`Sent transaction ${hash} +`); + }); +} +function tornadoProgram() { + const { name, version, description } = packageJson; + const program = new Command(); + program.name(name).version(version).description(description); + program.command("create").description("Creates Tornado Cash deposit note and deposit invoice").argument("", "Network Chain ID to connect with (see https://chainlist.org for examples)", parseNumber).argument("", "Currency to deposit on Tornado Cash").argument("", "Amount to deposit on Tornado Cash").action((netId, currency, amount) => __async(this, null, function* () { + currency = currency.toLowerCase(); + const config = networkConfig[`netId${netId}`]; + const { + routerContract, + nativeCurrency, + tokens: { [currency]: currencyConfig } + } = config; + const { + decimals, + tokenAddress, + instanceAddress: { [amount]: instanceAddress } + } = currencyConfig; + const isEth = nativeCurrency === currency; + const denomination = parseUnits$1(amount, decimals); + const deposit = yield Deposit.createNote({ currency, amount, netId }); + const { noteHex, note, commitmentHex } = deposit; + const ERC20Interface = ERC20__factory.createInterface(); + const TornadoRouterInterface = TornadoRouter__factory.createInterface(); + console.log(`New deposit: ${deposit.toString()} +`); + yield promises.writeFile(`./backup-tornado-${currency}-${amount}-${netId}-${noteHex.slice(0, 10)}.txt`, note, { + encoding: "utf8" + }); + const depositData = TornadoRouterInterface.encodeFunctionData("deposit", [instanceAddress, commitmentHex, "0x"]); + if (!isEth) { + const approveData = ERC20Interface.encodeFunctionData("approve", [routerContract, MaxUint256]); + console.log(`Approve Data: ${JSON.stringify({ to: tokenAddress, data: approveData }, null, 2)}] +`); + console.log(`Transaction Data: ${JSON.stringify({ to: routerContract, data: depositData }, null, 2)} +`); + } else { + console.log( + `Transaction Data: ${JSON.stringify({ to: routerContract, value: denomination.toString(), data: depositData }, null, 2)}` + ); + } + process$2.exit(0); + })); + program.command("deposit").description( + "Submit a deposit of specified currency and amount from default eth account and return the resulting note. \n\nThe currency is one of (ETH|DAI|cDAI|USDC|cUSDC|USDT). \n\nThe amount depends on currency, see config.js file or see Tornado Cash UI." + ).argument("", "Network Chain ID to connect with (see https://chainlist.org for examples)", parseNumber).argument("", "Currency to deposit on Tornado Cash").argument("", "Amount to deposit on Tornado Cash").action((netId, currency, amount, cmdOptions) => __async(this, null, function* () { + const { options, fetchDataOptions: fetchDataOptions2 } = yield getProgramOptions(cmdOptions); + currency = currency.toLowerCase(); + const { rpc } = options; + const config = networkConfig[`netId${netId}`]; + const { + multicall: multicallAddress, + routerContract, + nativeCurrency, + tokens: { [currency]: currencyConfig } + } = config; + const { + decimals, + tokenAddress, + instanceAddress: { [amount]: instanceAddress } + } = currencyConfig; + const isEth = nativeCurrency === currency; + const denomination = parseUnits$1(amount, decimals); + const provider = getProgramProvider(netId, rpc, config, __spreadValues({}, fetchDataOptions2)); + const signer = getProgramSigner({ + options, + provider + }); + if (!signer) { + throw new Error( + "Signer not defined, make sure you have either viewOnly address, mnemonic, or private key configured" + ); + } + const TornadoProxy = TornadoRouter__factory.connect(routerContract, signer); + const Multicall = Multicall__factory.connect(multicallAddress, provider); + const Token = tokenAddress ? ERC20__factory.connect(tokenAddress, signer) : void 0; + const [ethBalance, tokenBalance, tokenApprovals] = yield multicall(Multicall, [ + { + contract: Multicall, + name: "getEthBalance", + params: [signer.address] + }, + /* eslint-disable prettier/prettier */ + ...!isEth ? [ + { + contract: Token, + name: "balanceOf", + params: [signer.address] + }, + { + contract: Token, + name: "allowance", + params: [signer.address, routerContract] + } + ] : [] + /* eslint-enable prettier/prettier */ + ]); + if (isEth && denomination > ethBalance) { + const errMsg = `Invalid ${currency.toUpperCase()} balance, wants ${amount} have ${formatUnits(ethBalance, decimals)}`; + throw new Error(errMsg); + } else if (!isEth && denomination > tokenBalance) { + const errMsg = `Invalid ${currency.toUpperCase()} balance, wants ${amount} have ${formatUnits(tokenBalance, decimals)}`; + throw new Error(errMsg); + } + if (!isEth && denomination > tokenApprovals) { + yield programSendTransaction({ + signer, + options, + populatedTransaction: yield Token.approve.populateTransaction(routerContract, MaxUint256) + }); + if (signer instanceof VoidSigner || options.localRpc) { + console.log( + "Signer can not sign or broadcast transactions, please send the token approve transaction first and try again.\n" + ); + process$2.exit(0); + } + } + const deposit = yield Deposit.createNote({ currency, amount, netId }); + const { note, noteHex, commitmentHex } = deposit; + console.log(`New deposit: ${deposit.toString()} +`); + yield promises.writeFile(`./backup-tornado-${currency}-${amount}-${netId}-${noteHex.slice(0, 10)}.txt`, note, { + encoding: "utf8" + }); + yield programSendTransaction({ + signer, + options, + populatedTransaction: yield TornadoProxy.deposit.populateTransaction(instanceAddress, commitmentHex, "0x", { + value: isEth ? denomination : BigInt(0) + }) + }); + process$2.exit(0); + })); + program.command("depositInvoice").description( + "Submit a deposit of tornado invoice from default eth account and return the resulting note. \n\nUseful to deposit on online computer without exposing note" + ).argument("", "Tornado Cash Invoice generated from create command").action((invoiceString, cmdOptions) => __async(this, null, function* () { + const { options, fetchDataOptions: fetchDataOptions2 } = yield getProgramOptions(cmdOptions); + const { rpc } = options; + const { currency, amount, netId, commitment } = new Invoice(invoiceString); + const config = networkConfig[`netId${netId}`]; + const { + multicall: multicallAddress, + routerContract, + nativeCurrency, + tokens: { [currency]: currencyConfig } + } = config; + const { + decimals, + tokenAddress, + instanceAddress: { [amount]: instanceAddress } + } = currencyConfig; + const isEth = nativeCurrency === currency; + const denomination = parseUnits$1(amount, decimals); + const provider = getProgramProvider(netId, rpc, config, __spreadValues({}, fetchDataOptions2)); + const signer = getProgramSigner({ + options, + provider + }); + if (!signer) { + throw new Error( + "Signer not defined, make sure you have either viewOnly address, mnemonic, or private key configured" + ); + } + const TornadoProxy = TornadoRouter__factory.connect(routerContract, signer); + const Multicall = Multicall__factory.connect(multicallAddress, provider); + const Token = tokenAddress ? ERC20__factory.connect(tokenAddress, signer) : void 0; + const [ethBalance, tokenBalance, tokenApprovals] = yield multicall(Multicall, [ + { + contract: Multicall, + name: "getEthBalance", + params: [signer.address] + }, + /* eslint-disable prettier/prettier */ + ...!isEth ? [ + { + contract: Token, + name: "balanceOf", + params: [signer.address] + }, + { + contract: Token, + name: "allowance", + params: [signer.address, routerContract] + } + ] : [] + /* eslint-enable prettier/prettier */ + ]); + if (isEth && denomination > ethBalance) { + const errMsg = `Invalid ${currency.toUpperCase()} balance, wants ${amount} have ${formatUnits(ethBalance, decimals)}`; + throw new Error(errMsg); + } else if (!isEth && denomination > tokenBalance) { + const errMsg = `Invalid ${currency.toUpperCase()} balance, wants ${amount} have ${formatUnits(tokenBalance, decimals)}`; + throw new Error(errMsg); + } + if (!isEth && denomination > tokenApprovals) { + yield programSendTransaction({ + signer, + options, + populatedTransaction: yield Token.approve.populateTransaction(routerContract, MaxUint256) + }); + if (signer instanceof VoidSigner) { + console.log( + "Signer can not sign transactions, please send the token approve transaction first and try again.\n" + ); + process$2.exit(0); + } + } + yield programSendTransaction({ + signer, + options, + populatedTransaction: yield TornadoProxy.deposit.populateTransaction(instanceAddress, commitment, "0x", { + value: isEth ? denomination : BigInt(0) + }) + }); + process$2.exit(0); + })); + program.command("withdraw").description( + "Withdraw a note to a recipient account using relayer or specified private key. \n\nYou can exchange some of your deposit`s tokens to ETH during the withdrawal by specifing ETH_purchase (e.g. 0.01) to pay for gas in future transactions. \n\nAlso see the --relayer option.\n\n" + ).argument("", "Tornado Cash Deposit Note").argument("", "Recipient to receive withdrawn amount", parseAddress).argument("[ETH_purchase]", "ETH to purchase", parseNumber).action( + (note, recipient, ethPurchase, cmdOptions) => __async(this, null, function* () { + const { options, fetchDataOptions: fetchDataOptions2 } = yield getProgramOptions(cmdOptions); + const { rpc, walletWithdrawal } = options; + const deposit = yield Deposit.parseNote(note); + const { netId, currency, amount, commitmentHex, nullifierHex, nullifier, secret } = deposit; + const config = networkConfig[`netId${netId}`]; + const { + tornadoSubgraph, + deployedBlock, + nativeCurrency, + routerContract, + multicall: multicallAddress, + ovmGasPriceOracleContract, + tokens: { [currency]: currencyConfig } + } = config; + const { + decimals, + tokenAddress, + gasLimit: instanceGasLimit, + tokenGasLimit, + instanceAddress: { [amount]: instanceAddress } + } = currencyConfig; + const isEth = nativeCurrency === currency; + const denomination = parseUnits$1(amount, decimals); + const firstAmount = Object.keys(currencyConfig.instanceAddress).sort((a, b) => Number(a) - Number(b))[0]; + const isFirstAmount = Number(amount) === Number(firstAmount); + const provider = getProgramProvider(netId, rpc, config, __spreadValues({}, fetchDataOptions2)); + const signer = getProgramSigner({ + options, + provider + }); + const noSigner = Boolean(!signer || signer instanceof VoidSigner); + if (walletWithdrawal && noSigner) { + throw new Error("Wallet withdrawal is configured however could not find any wallets"); + } + const graphApi = getProgramGraphAPI(options, config); + const Tornado = Tornado__factory.connect(instanceAddress, provider); + const TornadoProxy = TornadoRouter__factory.connect(routerContract, !walletWithdrawal ? provider : signer); + const Multicall = Multicall__factory.connect(multicallAddress, provider); + const tornadoFeeOracle = new TornadoFeeOracle( + ovmGasPriceOracleContract ? OvmGasPriceOracle__factory.connect(ovmGasPriceOracleContract, provider) : void 0 + ); + const tokenPriceOracle = new TokenPriceOracle( + provider, + Multicall, + OffchainOracle__factory.connect(TOKEN_PRICE_ORACLE, provider) + ); + const depositsServiceConstructor = { + netId, + provider, + graphApi, + subgraphName: tornadoSubgraph, + Tornado, + amount, + currency, + deployedBlock, + fetchDataOptions: fetchDataOptions2, + cacheDirectory: EVENTS_DIR, + userDirectory: SAVED_DIR + }; + const depositsService = new NodeDepositsService(__spreadProps(__spreadValues({}, depositsServiceConstructor), { + type: "Deposit" + })); + const withdrawalsService = new NodeDepositsService(__spreadProps(__spreadValues({}, depositsServiceConstructor), { + type: "Withdrawal" + })); + const merkleTreeService = new MerkleTreeService({ + netId, + amount, + currency, + Tornado, + merkleWorkerPath: MERKLE_WORKER_PATH + }); + const depositEvents = (yield depositsService.updateEvents()).events; + const depositTreeInitiator = yield (() => __async(this, null, function* () { + if (MERKLE_WORKER_PATH) { + return () => merkleTreeService.verifyTree({ events: depositEvents }); + } + return yield merkleTreeService.verifyTree({ events: depositEvents }); + }))(); + let depositTreePromise; + if (typeof depositTreeInitiator === "function") { + depositTreePromise = depositTreeInitiator(); + } else { + depositTreePromise = depositTreeInitiator; + } + const withdrawalEvents = (yield withdrawalsService.updateEvents()).events; + const depositEvent = depositEvents.find(({ commitment }) => commitment === commitmentHex); + const withdrawalEvent = withdrawalEvents.find(({ nullifierHash }) => nullifierHash === nullifierHex); + if (!depositEvent) { + throw new Error("Deposit not found"); + } + const complianceTable = new Table(); + const depositDate = new Date(depositEvent.timestamp * 1e3); + complianceTable.push( + [{ colSpan: 2, content: "Deposit", hAlign: "center" }], + ["Deposit", `${amount} ${currency.toUpperCase()}`], + [ + "Date", + `${depositDate.toLocaleDateString()} ${depositDate.toLocaleTimeString()} (${moment.unix(depositEvent.timestamp).fromNow()})` + ], + ["From", depositEvent.from], + ["Transaction", depositEvent.transactionHash], + ["Commitment", commitmentHex], + ["Spent", Boolean(withdrawalEvent)] + ); + if (withdrawalEvent) { + const withdrawalDate = new Date(withdrawalEvent.timestamp * 1e3); + complianceTable.push( + [{ colSpan: 2, content: "Withdraw", hAlign: "center" }], + ["Withdrawal", `${amount} ${currency.toUpperCase()}`], + ["Relayer Fee", `${formatUnits(withdrawalEvent.fee, decimals)} ${currency.toUpperCase()}`], + [ + "Date", + `${withdrawalDate.toLocaleDateString()} ${withdrawalDate.toLocaleTimeString()} (${moment.unix(withdrawalEvent.timestamp).fromNow()})` + ], + ["To", withdrawalEvent.to], + ["Transaction", withdrawalEvent.transactionHash], + ["Nullifier", nullifierHex] + ); + } + console.log("\n\n" + complianceTable.toString() + "\n"); + if (withdrawalEvent) { + throw new Error("Note is already spent"); + } + const [circuit, provingKey, tree, relayerClient, l1Fee, tokenPriceInWei, feeData] = yield Promise.all([ + promises.readFile(CIRCUIT_PATH, { encoding: "utf8" }).then((s) => JSON.parse(s)), + promises.readFile(KEY_PATH).then((b) => new Uint8Array(b).buffer), + depositTreePromise, + /* eslint-disable prettier/prettier */ + !walletWithdrawal ? getProgramRelayer({ + options, + fetchDataOptions: fetchDataOptions2, + netId + }).then(({ relayerClient: relayerClient2 }) => relayerClient2) : void 0, + /* eslint-enable prettier/prettier */ + tornadoFeeOracle.fetchL1OptimismFee(), + !isEth ? tokenPriceOracle.fetchPrices([tokenAddress]).then((p) => p[0]) : BigInt(0), + provider.getFeeData() + ]); + if (!walletWithdrawal && !(relayerClient == null ? void 0 : relayerClient.selectedRelayer)) { + throw new Error( + "No valid relayer found for the network, you can either try again, or find any relayers using the relayers command and set with --relayer option" + ); + } + const { url, rewardAccount, tornadoServiceFee } = (relayerClient == null ? void 0 : relayerClient.selectedRelayer) || {}; + let gasPrice = feeData.maxFeePerGas ? feeData.maxFeePerGas + (feeData.maxPriorityFeePerGas || BigInt(0)) : feeData.gasPrice; + if (netId === 56 && gasPrice < parseUnits$1("3.3", "gwei")) { + gasPrice = parseUnits$1("3.3", "gwei"); + } + const defaultGasLimit = instanceGasLimit ? BigInt(instanceGasLimit) : BigInt(DEFAULT_GAS_LIMIT); + let gasLimit = defaultGasLimit; + const refundGasLimit = isFirstAmount && tokenGasLimit ? BigInt(tokenGasLimit) : void 0; + const ethRefund = ethPurchase ? parseEther(`${ethPurchase}`) : !isEth ? tornadoFeeOracle.defaultEthRefund(gasPrice, refundGasLimit) : BigInt(0); + if (isEth && ethRefund) { + throw new Error("Can not purchase native assets on native asset withdrawal"); + } + function getProof() { + return __async(this, null, function* () { + let relayerFee2 = BigInt(0); + if (!walletWithdrawal) { + relayerFee2 = tornadoFeeOracle.calculateRelayerFee({ + gasPrice, + gasLimit, + l1Fee, + denomination, + ethRefund, + tokenPriceInWei, + tokenDecimals: decimals, + relayerFeePercent: tornadoServiceFee, + isEth + }); + if (relayerFee2 > denomination) { + const errMsg = `Relayer fee ${formatUnits(relayerFee2, decimals)} ${currency.toUpperCase()} exceeds the deposit amount ${amount} ${currency.toUpperCase()}.`; + throw new Error(errMsg); + } + } + const { pathElements, pathIndices } = tree.path(depositEvent.leafIndex); + const { proof: proof2, args: args2 } = yield calculateSnarkProof( + { + root: tree.root, + nullifierHex, + recipient, + relayer: !walletWithdrawal ? rewardAccount : ZeroAddress, + fee: relayerFee2, + refund: ethRefund, + nullifier, + secret, + pathElements, + pathIndices + }, + circuit, + provingKey + ); + return { + relayerFee: relayerFee2, + proof: proof2, + args: args2 + }; + }); + } + let { relayerFee, proof, args } = yield getProof(); + const withdrawOverrides = { + from: !walletWithdrawal ? rewardAccount : signer == null ? void 0 : signer.address, + value: args[5] || 0 + }; + gasLimit = yield TornadoProxy.withdraw.estimateGas(instanceAddress, proof, ...args, withdrawOverrides); + if (gasLimit > defaultGasLimit) { + ({ relayerFee, proof, args } = yield getProof()); + gasLimit = yield TornadoProxy.withdraw.estimateGas(instanceAddress, proof, ...args, withdrawOverrides); + } + const withdrawTable = new Table(); + withdrawTable.push([{ colSpan: 2, content: "Withdrawal Info", hAlign: "center" }]); + if (!walletWithdrawal && relayerClient) { + withdrawTable.push( + [{ colSpan: 2, content: "Withdraw", hAlign: "center" }], + ["Withdrawal", `${amount} ${currency.toUpperCase()}`], + ["Relayer", `${url}`], + [ + "Relayer Fee", + `${formatUnits(relayerFee, decimals)} ${currency.toUpperCase()} (${(Number(relayerFee) / Number(denomination) * 100).toFixed(5)}%)` + ], + ["Relayer Fee Percent", `${tornadoServiceFee}%`], + [ + "Amount to receive", + `${Number(formatUnits(denomination - relayerFee, decimals)).toFixed(5)} ${currency.toUpperCase()}` + ], + [`${nativeCurrency.toUpperCase()} purchase`, `${formatEther(ethRefund)} ${nativeCurrency.toUpperCase()}`], + ["To", recipient], + ["Nullifier", nullifierHex] + ); + console.log("\n" + withdrawTable.toString() + "\n"); + yield promptConfirmation(options.nonInteractive); + console.log("Sending withdraw transaction through relay\n"); + yield relayerClient.tornadoWithdraw({ + contract: instanceAddress, + proof, + args + }); + } else { + const txFee = gasPrice * gasLimit; + const txFeeInToken = !isEth ? tornadoFeeOracle.calculateTokenAmount(txFee, tokenPriceInWei, decimals) : BigInt(0); + const txFeeString = !isEth ? `(${Number(formatUnits(txFeeInToken, decimals)).toFixed(5)} ${currency.toUpperCase()} worth) (${(Number(formatUnits(txFeeInToken, decimals)) / Number(amount) * 100).toFixed(5)}%)` : `(${(Number(formatUnits(txFee, decimals)) / Number(amount) * 100).toFixed(5)}%)`; + withdrawTable.push( + [{ colSpan: 2, content: "Withdraw", hAlign: "center" }], + ["Withdrawal", `${amount} ${currency.toUpperCase()}`], + ["From", `${signer == null ? void 0 : signer.address}`], + [ + "Transaction Fee", + `${Number(formatEther(txFee)).toFixed(5)} ${nativeCurrency.toUpperCase()} ` + txFeeString + ], + ["Amount to receive", `${amount} ${currency.toUpperCase()}`], + ["To", recipient], + ["Nullifier", nullifierHex] + ); + console.log("\n" + withdrawTable.toString() + "\n"); + yield promptConfirmation(options.nonInteractive); + console.log("Sending withdraw transaction through wallet\n"); + yield programSendTransaction({ + signer, + options, + populatedTransaction: yield TornadoProxy.withdraw.populateTransaction(instanceAddress, proof, ...args) + }); + } + process$2.exit(0); + }) + ); + program.command("compliance").description( + "Shows the deposit and withdrawal of the provided note. \n\nThis might be necessary to show the origin of assets held in your withdrawal address. \n\n" + ).argument("", "Tornado Cash Deposit Note").action((note, cmdOptions) => __async(this, null, function* () { + const { options, fetchDataOptions: fetchDataOptions2 } = yield getProgramOptions(cmdOptions); + const { rpc } = options; + const deposit = yield Deposit.parseNote(note); + const { netId, currency, amount, commitmentHex, nullifierHex } = deposit; + const config = networkConfig[`netId${netId}`]; + const { + tornadoSubgraph, + deployedBlock, + tokens: { [currency]: currencyConfig } + } = config; + const { + decimals, + instanceAddress: { [amount]: instanceAddress } + } = currencyConfig; + const provider = getProgramProvider(netId, rpc, config, __spreadValues({}, fetchDataOptions2)); + const graphApi = getProgramGraphAPI(options, config); + const Tornado = Tornado__factory.connect(instanceAddress, provider); + const depositsServiceConstructor = { + netId, + provider, + graphApi, + subgraphName: tornadoSubgraph, + Tornado, + amount, + currency, + deployedBlock, + fetchDataOptions: fetchDataOptions2, + cacheDirectory: EVENTS_DIR, + userDirectory: SAVED_DIR + }; + const depositsService = new NodeDepositsService(__spreadProps(__spreadValues({}, depositsServiceConstructor), { + type: "Deposit" + })); + const withdrawalsService = new NodeDepositsService(__spreadProps(__spreadValues({}, depositsServiceConstructor), { + type: "Withdrawal" + })); + const merkleTreeService = new MerkleTreeService({ + netId, + amount, + currency, + Tornado, + merkleWorkerPath: MERKLE_WORKER_PATH + }); + const depositEvents = (yield depositsService.updateEvents()).events; + const depositTreePromise = yield (() => __async(this, null, function* () { + if (MERKLE_WORKER_PATH) { + return () => merkleTreeService.verifyTree({ events: depositEvents }); + } + return yield merkleTreeService.verifyTree({ events: depositEvents }); + }))(); + const [withdrawalEvents] = yield Promise.all([ + withdrawalsService.updateEvents().then(({ events }) => events), + typeof depositTreePromise === "function" ? depositTreePromise() : depositTreePromise + ]); + const depositEvent = depositEvents.find(({ commitment }) => commitment === commitmentHex); + const withdrawalEvent = withdrawalEvents.find(({ nullifierHash }) => nullifierHash === nullifierHex); + const complianceTable = new Table(); + complianceTable.push([{ colSpan: 2, content: "Compliance Info", hAlign: "center" }]); + if (!depositEvent) { + complianceTable.push([{ colSpan: 2, content: "Deposit", hAlign: "center" }], ["Deposit", "Not Found"]); + } else { + const depositDate = new Date(depositEvent.timestamp * 1e3); + complianceTable.push( + [{ colSpan: 2, content: "Deposit", hAlign: "center" }], + ["Deposit", `${amount} ${currency.toUpperCase()}`], + [ + "Date", + `${depositDate.toLocaleDateString()} ${depositDate.toLocaleTimeString()} (${moment.unix(depositEvent.timestamp).fromNow()})` + ], + ["From", depositEvent.from], + ["Transaction", depositEvent.transactionHash], + ["Commitment", commitmentHex], + ["Spent", Boolean(withdrawalEvent)] + ); + } + if (withdrawalEvent) { + const withdrawalDate = new Date(withdrawalEvent.timestamp * 1e3); + complianceTable.push( + [{ colSpan: 2, content: "Withdraw", hAlign: "center" }], + ["Withdrawal", `${amount} ${currency.toUpperCase()}`], + ["Relayer Fee", `${formatUnits(withdrawalEvent.fee, decimals)} ${currency.toUpperCase()}`], + [ + "Date", + `${withdrawalDate.toLocaleDateString()} ${withdrawalDate.toLocaleTimeString()} (${moment.unix(withdrawalEvent.timestamp).fromNow()})` + ], + ["To", withdrawalEvent.to], + ["Transaction", withdrawalEvent.transactionHash], + ["Nullifier", nullifierHex] + ); + } + console.log("\n\n" + complianceTable.toString() + "\n"); + process$2.exit(0); + })); + program.command("syncEvents").description("Sync the local cache file of tornado cash events.\n\n").argument("[netId]", "Network Chain ID to connect with (see https://chainlist.org for examples)", parseNumber).argument("[currency]", "Currency to sync events").action( + (netIdOpts, currencyOpts, cmdOptions) => __async(this, null, function* () { + const { options, fetchDataOptions: fetchDataOptions2 } = yield getProgramOptions(cmdOptions); + const { rpc } = options; + const networks = netIdOpts ? [netIdOpts] : enabledChains; + for (const netId of networks) { + const config = networkConfig[`netId${netId}`]; + const { + tornadoSubgraph, + registrySubgraph, + tokens, + routerContract, + registryContract, + ["governance.contract.tornadocash.eth"]: governanceContract, + deployedBlock, + constants: { GOVERNANCE_BLOCK, REGISTRY_BLOCK, ENCRYPTED_NOTES_BLOCK } + } = config; + const provider = getProgramProvider(netId, rpc, config, __spreadValues({}, fetchDataOptions2)); + const graphApi = getProgramGraphAPI(options, config); + if (governanceContract) { + const governanceService = new NodeGovernanceService({ + netId, + provider, + // to-do connect governance with subgraph + graphApi: "", + subgraphName: "", + Governance: Governance__factory.connect(governanceContract, provider), + deployedBlock: GOVERNANCE_BLOCK, + fetchDataOptions: fetchDataOptions2, + cacheDirectory: EVENTS_DIR, + userDirectory: SAVED_DIR + }); + yield governanceService.updateEvents(); + } + if (registryContract) { + const registryService = new NodeRegistryService({ + netId, + provider, + graphApi, + subgraphName: registrySubgraph, + RelayerRegistry: RelayerRegistry__factory.connect(registryContract, provider), + deployedBlock: REGISTRY_BLOCK, + fetchDataOptions: fetchDataOptions2, + cacheDirectory: EVENTS_DIR, + userDirectory: SAVED_DIR + }); + yield registryService.updateEvents(); + } + const encryptedNotesService = new NodeEncryptedNotesService({ + netId, + provider, + graphApi, + subgraphName: tornadoSubgraph, + Router: TornadoRouter__factory.connect(routerContract, provider), + deployedBlock: ENCRYPTED_NOTES_BLOCK, + fetchDataOptions: fetchDataOptions2, + cacheDirectory: EVENTS_DIR, + userDirectory: SAVED_DIR + }); + yield encryptedNotesService.updateEvents(); + const currencies = currencyOpts ? [currencyOpts.toLowerCase()] : Object.keys(tokens); + for (const currency of currencies) { + const currencyConfig = tokens[currency]; + const amounts = Object.keys(currencyConfig.instanceAddress); + for (const amount of amounts) { + const instanceAddress = currencyConfig.instanceAddress[amount]; + const Tornado = Tornado__factory.connect(instanceAddress, provider); + const depositsServiceConstructor = { + netId, + provider, + graphApi, + subgraphName: tornadoSubgraph, + Tornado, + amount, + currency, + deployedBlock, + fetchDataOptions: fetchDataOptions2, + cacheDirectory: EVENTS_DIR, + userDirectory: SAVED_DIR + }; + const depositsService = new NodeDepositsService(__spreadProps(__spreadValues({}, depositsServiceConstructor), { + type: "Deposit" + })); + const withdrawalsService = new NodeDepositsService(__spreadProps(__spreadValues({}, depositsServiceConstructor), { + type: "Withdrawal" + })); + const merkleTreeService = new MerkleTreeService({ + netId, + amount, + currency, + Tornado, + merkleWorkerPath: MERKLE_WORKER_PATH + }); + const depositEvents = (yield depositsService.updateEvents()).events; + const depositTreePromise = yield (() => __async(this, null, function* () { + if (MERKLE_WORKER_PATH) { + return () => merkleTreeService.verifyTree({ events: depositEvents }); + } + return yield merkleTreeService.verifyTree({ + events: depositEvents + }); + }))(); + yield Promise.all([ + withdrawalsService.updateEvents(), + typeof depositTreePromise === "function" ? depositTreePromise() : depositTreePromise + ]); + } + } + } + process$2.exit(0); + }) + ); + program.command("relayers").description("List all registered relayers from the tornado cash registry.\n\n").argument("", "Network Chain ID to connect with (see https://chainlist.org for examples)", parseNumber).action((netIdOpts, cmdOptions) => __async(this, null, function* () { + const { options, fetchDataOptions: fetchDataOptions2 } = yield getProgramOptions(cmdOptions); + const allRelayers = yield getProgramRelayer({ + options, + fetchDataOptions: fetchDataOptions2, + netId: netIdOpts + }); + const validRelayers = allRelayers.validRelayers; + const invalidRelayers = allRelayers.invalidRelayers; + const relayersTable = new Table(); + relayersTable.push( + [{ colSpan: 8, content: "Relayers", hAlign: "center" }], + [ + "netId", + "url", + "ensName", + "stakeBalance", + "relayerAddress", + "rewardAccount", + "currentQueue", + "serviceFee" + ].map((content) => ({ content: colors.red.bold(content) })), + ...validRelayers.map( + ({ netId, url, ensName, stakeBalance, relayerAddress, rewardAccount, currentQueue, tornadoServiceFee }) => { + return [ + netId, + url, + ensName, + stakeBalance ? `${Number(formatEther(stakeBalance)).toFixed(5)} TORN` : "", + relayerAddress, + rewardAccount, + currentQueue, + `${tornadoServiceFee}%` + ]; + } + ) + ); + const invalidRelayersTable = new Table(); + invalidRelayersTable.push( + [{ colSpan: 3, content: "Invalid Relayers", hAlign: "center" }], + ["hostname", "relayerAddress", "errorMessage"].map((content) => ({ content: colors.red.bold(content) })), + ...invalidRelayers.map(({ hostname, relayerAddress, errorMessage }) => { + return [hostname, relayerAddress, errorMessage ? substring(errorMessage, 40) : ""]; + }) + ); + console.log(relayersTable.toString() + "\n"); + console.log(invalidRelayersTable.toString() + "\n"); + process$2.exit(0); + })); + program.command("send").description("Send ETH or ERC20 token to address.\n\n").argument("", "Network Chain ID to connect with (see https://chainlist.org for examples)", parseNumber).argument("", "To address", parseAddress).argument("[amount]", "Sending amounts", parseNumber).argument("[token]", "ERC20 Token Contract to check Token Balance", parseAddress).action( + (netId, to, amountArgs, tokenArgs, cmdOptions) => __async(this, null, function* () { + const { options, fetchDataOptions: fetchDataOptions2 } = yield getProgramOptions(cmdOptions); + const { rpc, token: tokenOpts } = options; + const config = networkConfig[`netId${netId}`]; + const { currencyName, multicall: multicallAddress } = config; + const provider = getProgramProvider(netId, rpc, config, __spreadValues({}, fetchDataOptions2)); + const signer = getProgramSigner({ options, provider }); + if (!signer) { + throw new Error( + "Signer not defined, make sure you have either viewOnly address, mnemonic, or private key configured" + ); + } + const tokenAddress = tokenArgs ? parseAddress(tokenArgs) : tokenOpts; + const Multicall = Multicall__factory.connect(multicallAddress, provider); + const Token = tokenAddress ? ERC20__factory.connect(tokenAddress, signer) : void 0; + const [feeData, nonce, [{ balance: ethBalance }, tokenResults]] = yield Promise.all([ + provider.getFeeData(), + provider.getTransactionCount(signer.address, "pending"), + getTokenBalances({ + provider, + Multicall, + currencyName, + userAddress: signer.address, + tokenAddresses: tokenAddress ? [tokenAddress] : [] + }) + ]); + const { + symbol: tokenSymbol, + decimals: tokenDecimals, + balance: tokenBalance + } = tokenResults || {}; + const txType = feeData.maxFeePerGas ? 2 : 0; + const txGasPrice = feeData.maxFeePerGas ? feeData.maxFeePerGas + (feeData.maxPriorityFeePerGas || BigInt(0)) : feeData.gasPrice || BigInt(0); + const txFees = feeData.maxFeePerGas ? { + maxFeePerGas: feeData.maxFeePerGas, + maxPriorityFeePerGas: feeData.maxPriorityFeePerGas + } : { + gasPrice: feeData.gasPrice + }; + let toSend; + if (amountArgs) { + if (tokenAddress) { + toSend = parseUnits$1(`${amountArgs}`, tokenDecimals); + if (toSend > tokenBalance) { + const errMsg = `Invalid ${tokenSymbol} balance, wants ${amountArgs} have ${formatUnits(tokenBalance, tokenDecimals)}`; + throw new Error(errMsg); + } + } else { + toSend = parseEther(`${amountArgs}`); + if (toSend > ethBalance) { + const errMsg = `Invalid ${currencyName} balance, wants ${amountArgs} have ${formatEther(ethBalance)}`; + throw new Error(errMsg); + } + } + } else { + if (tokenAddress) { + toSend = tokenBalance; + } else { + const initCost = txGasPrice * BigInt("400000"); + toSend = ethBalance - initCost; + const estimatedGas = yield provider.estimateGas(__spreadValues({ + type: txType, + from: signer.address, + to, + value: toSend, + nonce + }, txFees)); + const bumpedGas = estimatedGas !== BigInt(21e3) && signer.gasLimitBump ? estimatedGas * (BigInt(1e4) + BigInt(signer.gasLimitBump)) / BigInt(1e4) : estimatedGas; + toSend = ethBalance - txGasPrice * bumpedGas; + } + } + yield programSendTransaction({ + signer, + options, + populatedTransaction: tokenAddress ? yield Token.transfer.populateTransaction(to, toSend) : yield signer.populateTransaction(__spreadValues({ + type: txType, + from: signer.address, + to, + value: toSend, + nonce + }, txFees)) + }); + process$2.exit(0); + }) + ); + program.command("balance").description("Check ETH and ERC20 balance.\n\n").argument("", "Network Chain ID to connect with (see https://chainlist.org for examples)", parseNumber).argument("[address]", "ETH Address to check balance", parseAddress).argument("[token]", "ERC20 Token Contract to check Token Balance", parseAddress).action( + (netId, addressArgs, tokenArgs, cmdOptions) => __async(this, null, function* () { + var _a; + const { options, fetchDataOptions: fetchDataOptions2 } = yield getProgramOptions(cmdOptions); + const { rpc, token: tokenOpts } = options; + const config = networkConfig[`netId${netId}`]; + const { + currencyName, + multicall: multicallAddress, + ["torn.contract.tornadocash.eth"]: tornTokenAddress, + tokens + } = config; + const provider = getProgramProvider(netId, rpc, config, __spreadValues({}, fetchDataOptions2)); + const userAddress = addressArgs ? parseAddress(addressArgs) : (_a = getProgramSigner({ options, provider })) == null ? void 0 : _a.address; + const tokenAddress = tokenArgs ? parseAddress(tokenArgs) : tokenOpts; + if (!userAddress) { + throw new Error("Address is required however no user address is supplied"); + } + const Multicall = Multicall__factory.connect(multicallAddress, provider); + const tokenAddresses = Object.values(tokens).map(({ tokenAddress: tokenAddress2 }) => tokenAddress2).filter((t) => t); + if (tornTokenAddress) { + tokenAddresses.push(tornTokenAddress); + } + const tokenBalances2 = yield getTokenBalances({ + provider, + Multicall, + currencyName, + userAddress, + tokenAddresses: [...tokenAddress ? [tokenAddress] : tokenAddresses] + }); + const balanceTable = new Table({ head: ["Token", "Contract Address", "Balance"] }); + balanceTable.push( + [{ colSpan: 3, content: `User: ${userAddress}`, hAlign: "center" }], + ...tokenBalances2.map(({ address, name: name2, symbol, decimals, balance }) => { + return [`${name2} (${symbol})`, address, `${formatUnits(balance, decimals)} ${symbol}`]; + }) + ); + console.log(balanceTable.toString()); + process$2.exit(0); + }) + ); + program.command("sign").description("Sign unsigned transaction with signer.\n\n").argument("", "Unsigned Transaction").action((unsignedTx, cmdOptions) => __async(this, null, function* () { + const { options, fetchDataOptions: fetchDataOptions2 } = yield getProgramOptions(cmdOptions); + const { rpc } = options; + const deserializedTx = Transaction.from(unsignedTx).toJSON(); + const netId = Number(deserializedTx.chainId); + const config = networkConfig[`netId${netId}`]; + const provider = getProgramProvider(netId, rpc, config, __spreadValues({}, fetchDataOptions2)); + const signer = getProgramSigner({ options, provider }); + if (!signer || signer instanceof VoidSigner) { + throw new Error("Signer not defined or not signable signer"); + } + yield programSendTransaction({ + signer, + options, + populatedTransaction: deserializedTx + }); + process$2.exit(0); + })); + program.command("broadcast").description("Broadcast signed transaction.\n\n").argument("", "Signed Transaction").action((signedTx, cmdOptions) => __async(this, null, function* () { + const { options, fetchDataOptions: fetchDataOptions2 } = yield getProgramOptions(cmdOptions); + const { rpc } = options; + const netId = Number(Transaction.from(signedTx).chainId); + if (!netId) { + throw new Error("NetId for the transaction is invalid, this command only supports EIP-155 transactions"); + } + const config = networkConfig[`netId${netId}`]; + const provider = getProgramProvider(netId, rpc, config, __spreadValues({}, fetchDataOptions2)); + const { hash } = yield provider.broadcastTransaction(signedTx); + console.log(` +Broadcastd tx: ${hash} +`); + process$2.exit(0); + })); + program.commands.forEach((cmd) => { + cmd.option("-r, --rpc ", "The RPC that CLI should interact with", parseUrl); + cmd.option("-e, --eth-rpc ", "The Ethereum Mainnet RPC that CLI should interact with", parseUrl); + cmd.option("-g, --graph ", "The Subgraph API that CLI should interact with", parseUrl); + cmd.option("-G, --eth-graph ", "The Ethereum Mainnet Subgraph API that CLI should interact with", parseUrl); + cmd.option("-d, --disable-graph", "Disable Graph API - Does not enable Subgraph API and use only local RPC as an event source"); + cmd.option("-R, --relayer ", "Withdraw via relayer (Should be either .eth name or URL)", parseRelayer); + cmd.option("-w, --wallet-withdrawal", "Withdrawal via wallet (Should not be linked with deposits)"); + cmd.option("-T, --tor-port ", "Optional tor port", parseNumber); + cmd.option("-t, --token ", "Token Contract address to view token balance", parseAddress); + cmd.option( + "-v, --view-only ", + "Wallet address to view balance or to create unsigned transactions", + parseAddress + ); + cmd.option( + "-m, --mnemonic ", + "Wallet BIP39 Mnemonic Phrase - If you didn't add it to .env file and it is needed for operation", + parseMnemonic + ); + cmd.option("-i, --mnemonic-index ", "Optional wallet mnemonic index", parseNumber); + cmd.option( + "-p, --private-key ", + "Wallet private key - If you didn't add it to .env file and it is needed for operation", + parseKey + ); + cmd.option( + "-n, --non-interactive", + "No confirmation mode - Does not show prompt for confirmation and allow to use scripts non-interactive" + ); + cmd.option("-l, --local-rpc", "Local node mode - Does not submit signed transaction to the node"); + }); + return program; +} + +figlet$1.parseFont("Standard", figletStandard); +console.log(` +==================================================================== + +${figlet$1.textSync("Tornado CLI", { font: "Standard" })} + +==================================================================== + +`); +tornadoProgram().parse(); diff --git a/dist/fonts/figletStandard.d.ts b/dist/fonts/figletStandard.d.ts new file mode 100644 index 0000000..f980782 --- /dev/null +++ b/dist/fonts/figletStandard.d.ts @@ -0,0 +1,2 @@ +export declare const figletStandard: string; +export default figletStandard; diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..d96cebf --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,2 @@ +export * from './services'; +export * from './typechain'; diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..764f8f9 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,7128 @@ +'use strict'; + +var ethers = require('ethers'); +var crossFetch = require('cross-fetch'); +var httpProxyAgent = require('http-proxy-agent'); +var httpsProxyAgent = require('https-proxy-agent'); +var socksProxyAgent = require('socks-proxy-agent'); +var url = require('url'); +var BN = require('bn.js'); +var Table = require('cli-table3'); +var moment = require('moment'); +var path = require('path'); +var promises = require('fs/promises'); +var fflate = require('fflate'); +var Ajv = require('ajv'); +var circomlibjs = require('circomlibjs'); +var worker_threads = require('worker_threads'); +var fixedMerkleTree = require('@tornado/fixed-merkle-tree'); +var commander = require('commander'); +var websnarkUtils = require('@tornado/websnark/src/utils'); +var websnarkGroth = require('@tornado/websnark/src/groth16'); + +function _interopNamespaceDefault(e) { + var n = Object.create(null); + if (e) { + Object.keys(e).forEach(function (k) { + if (k !== 'default') { + var d = Object.getOwnPropertyDescriptor(e, k); + Object.defineProperty(n, k, d.get ? d : { + enumerable: true, + get: function () { return e[k]; } + }); + } + }); + } + n.default = e; + return Object.freeze(n); +} + +var websnarkUtils__namespace = /*#__PURE__*/_interopNamespaceDefault(websnarkUtils); + +const _abi$6 = [ + { + constant: true, + inputs: [ + { + internalType: "bytes4", + name: "interfaceID", + type: "bytes4" + } + ], + name: "supportsInterface", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + payable: false, + stateMutability: "pure", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "string", + name: "key", + type: "string" + }, + { + internalType: "string", + name: "value", + type: "string" + } + ], + name: "setText", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "bytes4", + name: "interfaceID", + type: "bytes4" + } + ], + name: "interfaceImplementer", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "uint256", + name: "contentTypes", + type: "uint256" + } + ], + name: "ABI", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + }, + { + internalType: "bytes", + name: "", + type: "bytes" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "x", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "y", + type: "bytes32" + } + ], + name: "setPubkey", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "bytes", + name: "hash", + type: "bytes" + } + ], + name: "setContenthash", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "addr", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bool", + name: "isAuthorised", + type: "bool" + } + ], + name: "setAuthorisation", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "string", + name: "key", + type: "string" + } + ], + name: "text", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "uint256", + name: "contentType", + type: "uint256" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "setABI", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "string", + name: "name", + type: "string" + } + ], + name: "setName", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "uint256", + name: "coinType", + type: "uint256" + }, + { + internalType: "bytes", + name: "a", + type: "bytes" + } + ], + name: "setAddr", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "contenthash", + outputs: [ + { + internalType: "bytes", + name: "", + type: "bytes" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "pubkey", + outputs: [ + { + internalType: "bytes32", + name: "x", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "y", + type: "bytes32" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "address", + name: "a", + type: "address" + } + ], + name: "setAddr", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "bytes4", + name: "interfaceID", + type: "bytes4" + }, + { + internalType: "address", + name: "implementer", + type: "address" + } + ], + name: "setInterface", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "uint256", + name: "coinType", + type: "uint256" + } + ], + name: "addr", + outputs: [ + { + internalType: "bytes", + name: "", + type: "bytes" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + }, + { + internalType: "address", + name: "", + type: "address" + }, + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "authorisations", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ENS", + name: "_ens", + type: "address" + } + ], + payable: false, + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "target", + type: "address" + }, + { + indexed: false, + internalType: "bool", + name: "isAuthorised", + type: "bool" + } + ], + name: "AuthorisationChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: false, + internalType: "string", + name: "indexedKey", + type: "string" + }, + { + indexed: false, + internalType: "string", + name: "key", + type: "string" + } + ], + name: "TextChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: false, + internalType: "bytes32", + name: "x", + type: "bytes32" + }, + { + indexed: false, + internalType: "bytes32", + name: "y", + type: "bytes32" + } + ], + name: "PubkeyChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: false, + internalType: "string", + name: "name", + type: "string" + } + ], + name: "NameChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: true, + internalType: "bytes4", + name: "interfaceID", + type: "bytes4" + }, + { + indexed: false, + internalType: "address", + name: "implementer", + type: "address" + } + ], + name: "InterfaceChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: false, + internalType: "bytes", + name: "hash", + type: "bytes" + } + ], + name: "ContenthashChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: false, + internalType: "address", + name: "a", + type: "address" + } + ], + name: "AddrChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: false, + internalType: "uint256", + name: "coinType", + type: "uint256" + }, + { + indexed: false, + internalType: "bytes", + name: "newAddress", + type: "bytes" + } + ], + name: "AddressChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: true, + internalType: "uint256", + name: "contentType", + type: "uint256" + } + ], + name: "ABIChanged", + type: "event" + } +]; +class ENS__factory { + static createInterface() { + return new ethers.Interface(_abi$6); + } + static connect(address, runner) { + return new ethers.Contract(address, _abi$6, runner); + } +} +ENS__factory.abi = _abi$6; + +const _abi$5 = [ + { + constant: true, + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [], + name: "_totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "address", + name: "who", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transfer", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + constant: true, + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "approve", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + } + ], + name: "nonces", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "permit", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class ERC20__factory { + static createInterface() { + return new ethers.Interface(_abi$5); + } + static connect(address, runner) { + return new ethers.Contract(address, _abi$5, runner); + } +} +ERC20__factory.abi = _abi$5; + +const _abi$4 = [ + { + inputs: [], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [], + name: "GAS_UNIT", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint32", + name: "_derivationThresold", + type: "uint32" + } + ], + name: "changeDerivationThresold", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint32", + name: "_gasUnit", + type: "uint32" + } + ], + name: "changeGasUnit", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint32", + name: "_heartbeat", + type: "uint32" + } + ], + name: "changeHeartbeat", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address" + } + ], + name: "changeOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "derivationThresold", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "gasPrice", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "heartbeat", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "maxFeePerGas", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "maxPriorityFeePerGas", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "pastGasPrice", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint32", + name: "_gasPrice", + type: "uint32" + } + ], + name: "setGasPrice", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "timestamp", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + } +]; +class GasPriceOracle__factory { + static createInterface() { + return new ethers.Interface(_abi$4); + } + static connect(address, runner) { + return new ethers.Contract(address, _abi$4, runner); + } +} +GasPriceOracle__factory.abi = _abi$4; + +const _abi$3 = [ + { + inputs: [ + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call[]", + name: "calls", + type: "tuple[]" + } + ], + name: "aggregate", + outputs: [ + { + internalType: "uint256", + name: "blockNumber", + type: "uint256" + }, + { + internalType: "bytes[]", + name: "returnData", + type: "bytes[]" + } + ], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bool", + name: "allowFailure", + type: "bool" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call3[]", + name: "calls", + type: "tuple[]" + } + ], + name: "aggregate3", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "success", + type: "bool" + }, + { + internalType: "bytes", + name: "returnData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Result[]", + name: "returnData", + type: "tuple[]" + } + ], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bool", + name: "allowFailure", + type: "bool" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call3Value[]", + name: "calls", + type: "tuple[]" + } + ], + name: "aggregate3Value", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "success", + type: "bool" + }, + { + internalType: "bytes", + name: "returnData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Result[]", + name: "returnData", + type: "tuple[]" + } + ], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call[]", + name: "calls", + type: "tuple[]" + } + ], + name: "blockAndAggregate", + outputs: [ + { + internalType: "uint256", + name: "blockNumber", + type: "uint256" + }, + { + internalType: "bytes32", + name: "blockHash", + type: "bytes32" + }, + { + components: [ + { + internalType: "bool", + name: "success", + type: "bool" + }, + { + internalType: "bytes", + name: "returnData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Result[]", + name: "returnData", + type: "tuple[]" + } + ], + stateMutability: "payable", + type: "function" + }, + { + inputs: [], + name: "getBasefee", + outputs: [ + { + internalType: "uint256", + name: "basefee", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "blockNumber", + type: "uint256" + } + ], + name: "getBlockHash", + outputs: [ + { + internalType: "bytes32", + name: "blockHash", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getBlockNumber", + outputs: [ + { + internalType: "uint256", + name: "blockNumber", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getChainId", + outputs: [ + { + internalType: "uint256", + name: "chainid", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getCurrentBlockCoinbase", + outputs: [ + { + internalType: "address", + name: "coinbase", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getCurrentBlockDifficulty", + outputs: [ + { + internalType: "uint256", + name: "difficulty", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getCurrentBlockGasLimit", + outputs: [ + { + internalType: "uint256", + name: "gaslimit", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getCurrentBlockTimestamp", + outputs: [ + { + internalType: "uint256", + name: "timestamp", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "addr", + type: "address" + } + ], + name: "getEthBalance", + outputs: [ + { + internalType: "uint256", + name: "balance", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getLastBlockHash", + outputs: [ + { + internalType: "bytes32", + name: "blockHash", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bool", + name: "requireSuccess", + type: "bool" + }, + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call[]", + name: "calls", + type: "tuple[]" + } + ], + name: "tryAggregate", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "success", + type: "bool" + }, + { + internalType: "bytes", + name: "returnData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Result[]", + name: "returnData", + type: "tuple[]" + } + ], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "bool", + name: "requireSuccess", + type: "bool" + }, + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call[]", + name: "calls", + type: "tuple[]" + } + ], + name: "tryBlockAndAggregate", + outputs: [ + { + internalType: "uint256", + name: "blockNumber", + type: "uint256" + }, + { + internalType: "bytes32", + name: "blockHash", + type: "bytes32" + }, + { + components: [ + { + internalType: "bool", + name: "success", + type: "bool" + }, + { + internalType: "bytes", + name: "returnData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Result[]", + name: "returnData", + type: "tuple[]" + } + ], + stateMutability: "payable", + type: "function" + } +]; +class Multicall__factory { + static createInterface() { + return new ethers.Interface(_abi$3); + } + static connect(address, runner) { + return new ethers.Contract(address, _abi$3, runner); + } +} +Multicall__factory.abi = _abi$3; + +const _abi$2 = [ + { + inputs: [ + { + internalType: "contract MultiWrapper", + name: "_multiWrapper", + type: "address" + }, + { + internalType: "contract IOracle[]", + name: "existingOracles", + type: "address[]" + }, + { + internalType: "enum OffchainOracle.OracleType[]", + name: "oracleTypes", + type: "uint8[]" + }, + { + internalType: "contract IERC20[]", + name: "existingConnectors", + type: "address[]" + }, + { + internalType: "contract IERC20", + name: "wBase", + type: "address" + }, + { + internalType: "address", + name: "owner", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [], + name: "ArraysLengthMismatch", + type: "error" + }, + { + inputs: [], + name: "ConnectorAlreadyAdded", + type: "error" + }, + { + inputs: [], + name: "InvalidOracleTokenKind", + type: "error" + }, + { + inputs: [], + name: "OracleAlreadyAdded", + type: "error" + }, + { + inputs: [], + name: "SameTokens", + type: "error" + }, + { + inputs: [], + name: "TooBigThreshold", + type: "error" + }, + { + inputs: [], + name: "UnknownConnector", + type: "error" + }, + { + inputs: [], + name: "UnknownOracle", + type: "error" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "contract IERC20", + name: "connector", + type: "address" + } + ], + name: "ConnectorAdded", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "contract IERC20", + name: "connector", + type: "address" + } + ], + name: "ConnectorRemoved", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "contract MultiWrapper", + name: "multiWrapper", + type: "address" + } + ], + name: "MultiWrapperUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "contract IOracle", + name: "oracle", + type: "address" + }, + { + indexed: false, + internalType: "enum OffchainOracle.OracleType", + name: "oracleType", + type: "uint8" + } + ], + name: "OracleAdded", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "contract IOracle", + name: "oracle", + type: "address" + }, + { + indexed: false, + internalType: "enum OffchainOracle.OracleType", + name: "oracleType", + type: "uint8" + } + ], + name: "OracleRemoved", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "OwnershipTransferred", + type: "event" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "connector", + type: "address" + } + ], + name: "addConnector", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IOracle", + name: "oracle", + type: "address" + }, + { + internalType: "enum OffchainOracle.OracleType", + name: "oracleKind", + type: "uint8" + } + ], + name: "addOracle", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "connectors", + outputs: [ + { + internalType: "contract IERC20[]", + name: "allConnectors", + type: "address[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "contract IERC20", + name: "dstToken", + type: "address" + }, + { + internalType: "bool", + name: "useWrappers", + type: "bool" + } + ], + name: "getRate", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "bool", + name: "useSrcWrappers", + type: "bool" + } + ], + name: "getRateToEth", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "bool", + name: "useSrcWrappers", + type: "bool" + }, + { + internalType: "contract IERC20[]", + name: "customConnectors", + type: "address[]" + }, + { + internalType: "uint256", + name: "thresholdFilter", + type: "uint256" + } + ], + name: "getRateToEthWithCustomConnectors", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "bool", + name: "useSrcWrappers", + type: "bool" + }, + { + internalType: "uint256", + name: "thresholdFilter", + type: "uint256" + } + ], + name: "getRateToEthWithThreshold", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "contract IERC20", + name: "dstToken", + type: "address" + }, + { + internalType: "bool", + name: "useWrappers", + type: "bool" + }, + { + internalType: "contract IERC20[]", + name: "customConnectors", + type: "address[]" + }, + { + internalType: "uint256", + name: "thresholdFilter", + type: "uint256" + } + ], + name: "getRateWithCustomConnectors", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "contract IERC20", + name: "dstToken", + type: "address" + }, + { + internalType: "bool", + name: "useWrappers", + type: "bool" + }, + { + internalType: "uint256", + name: "thresholdFilter", + type: "uint256" + } + ], + name: "getRateWithThreshold", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "multiWrapper", + outputs: [ + { + internalType: "contract MultiWrapper", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "oracles", + outputs: [ + { + internalType: "contract IOracle[]", + name: "allOracles", + type: "address[]" + }, + { + internalType: "enum OffchainOracle.OracleType[]", + name: "oracleTypes", + type: "uint8[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "connector", + type: "address" + } + ], + name: "removeConnector", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IOracle", + name: "oracle", + type: "address" + }, + { + internalType: "enum OffchainOracle.OracleType", + name: "oracleKind", + type: "uint8" + } + ], + name: "removeOracle", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract MultiWrapper", + name: "_multiWrapper", + type: "address" + } + ], + name: "setMultiWrapper", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class OffchainOracle__factory { + static createInterface() { + return new ethers.Interface(_abi$2); + } + static connect(address, runner) { + return new ethers.Contract(address, _abi$2, runner); + } +} +OffchainOracle__factory.abi = _abi$2; + +const _abi$1 = [ + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "DecimalsUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "GasPriceUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "L1BaseFeeUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "OverheadUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "OwnershipTransferred", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "ScalarUpdated", + type: "event" + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "gasPrice", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes", + name: "_data", + type: "bytes" + } + ], + name: "getL1Fee", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes", + name: "_data", + type: "bytes" + } + ], + name: "getL1GasUsed", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "l1BaseFee", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "overhead", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "scalar", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_decimals", + type: "uint256" + } + ], + name: "setDecimals", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_gasPrice", + type: "uint256" + } + ], + name: "setGasPrice", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_baseFee", + type: "uint256" + } + ], + name: "setL1BaseFee", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_overhead", + type: "uint256" + } + ], + name: "setOverhead", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_scalar", + type: "uint256" + } + ], + name: "setScalar", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class OvmGasPriceOracle__factory { + static createInterface() { + return new ethers.Interface(_abi$1); + } + static connect(address, runner) { + return new ethers.Contract(address, _abi$1, runner); + } +} +OvmGasPriceOracle__factory.abi = _abi$1; + +const _abi = [ + { + inputs: [ + { + internalType: "contract ENS", + name: "_ens", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [ + { + internalType: "address[]", + name: "addresses", + type: "address[]" + } + ], + name: "getNames", + outputs: [ + { + internalType: "string[]", + name: "r", + type: "string[]" + } + ], + stateMutability: "view", + type: "function" + } +]; +class ReverseRecords__factory { + static createInterface() { + return new ethers.Interface(_abi); + } + static connect(address, runner) { + return new ethers.Contract(address, _abi, runner); + } +} +ReverseRecords__factory.abi = _abi; + +var index = /*#__PURE__*/Object.freeze({ + __proto__: null, + ENS__factory: ENS__factory, + ERC20__factory: ERC20__factory, + GasPriceOracle__factory: GasPriceOracle__factory, + Multicall__factory: Multicall__factory, + OffchainOracle__factory: OffchainOracle__factory, + OvmGasPriceOracle__factory: OvmGasPriceOracle__factory, + ReverseRecords__factory: ReverseRecords__factory +}); + +BigInt.prototype.toJSON = function() { + return this.toString(); +}; +const isNode = !process.browser && typeof globalThis.window === "undefined"; +const chunk = (arr, size) => [...Array(Math.ceil(arr.length / size))].map((_, i) => arr.slice(size * i, size + size * i)); +function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} +function validateUrl(url$1, protocols) { + try { + const parsedUrl = new url.URL(url$1); + if (protocols && protocols.length) { + return protocols.map((p) => p.toLowerCase()).includes(parsedUrl.protocol); + } + return true; + } catch (e) { + return false; + } +} +function bufferToBytes(b) { + return new Uint8Array(b.buffer); +} +function bytesToBase64(bytes) { + let binary = ""; + const len = bytes.byteLength; + for (let i = 0; i < len; ++i) { + binary += String.fromCharCode(bytes[i]); + } + return btoa(binary); +} +function base64ToBytes(base64) { + const binaryString = atob(base64); + const bytes = new Uint8Array(binaryString.length); + for (let i = 0; i < binaryString.length; i++) { + bytes[i] = binaryString.charCodeAt(i); + } + return bytes; +} +function bytesToHex(bytes) { + return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join(""); +} +function bytesToBN(bytes) { + return BigInt(bytesToHex(bytes)); +} +function bnToBytes(bigint) { + let hexString = typeof bigint === "bigint" ? bigint.toString(16) : bigint; + if (hexString.startsWith("0x")) { + hexString = hexString.replace("0x", ""); + } + if (hexString.length % 2 !== 0) { + hexString = "0" + hexString; + } + return Uint8Array.from(hexString.match(/.{1,2}/g).map((byte) => parseInt(byte, 16))); +} +function leBuff2Int(bytes) { + return new BN(bytes, 16, "le"); +} +function leInt2Buff(bigint) { + return Uint8Array.from(new BN(bigint).toArray("le", 31)); +} +function toFixedHex(numberish, length = 32) { + return "0x" + BigInt(numberish).toString(16).padStart(length * 2, "0"); +} +function toFixedLength(string, length = 32) { + string = string.replace("0x", ""); + return "0x" + string.padStart(length * 2, "0"); +} +function rBigInt(nbytes = 31) { + return bytesToBN(crypto.getRandomValues(new Uint8Array(nbytes))); +} +function bigIntReplacer(key, value) { + return typeof value === "bigint" ? value.toString() : value; +} +function substring(str, length = 10) { + if (str.length < length * 2) { + return str; + } + return `${str.substring(0, length)}...${str.substring(str.length - length)}`; +} + +var __async$d = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +function multicall(Multicall2, calls) { + return __async$d(this, null, function* () { + const calldata = calls.map((call) => { + var _a, _b, _c; + const target = ((_a = call.contract) == null ? void 0 : _a.target) || call.address; + const callInterface = ((_b = call.contract) == null ? void 0 : _b.interface) || call.interface; + return { + target, + callData: callInterface.encodeFunctionData(call.name, call.params), + allowFailure: (_c = call.allowFailure) != null ? _c : false + }; + }); + const returnData = yield Multicall2.aggregate3.staticCall(calldata); + const res = returnData.map((call, i) => { + var _a; + const callInterface = ((_a = calls[i].contract) == null ? void 0 : _a.interface) || calls[i].interface; + const [result, data] = call; + const decodeResult = result && data && data !== "0x" ? callInterface.decodeFunctionResult(calls[i].name, data) : null; + return !decodeResult ? null : decodeResult.length === 1 ? decodeResult[0] : decodeResult; + }); + return res; + }); +} + +var __defProp$3 = Object.defineProperty; +var __defProps$3 = Object.defineProperties; +var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols; +var __getProtoOf$1 = Object.getPrototypeOf; +var __hasOwnProp$3 = Object.prototype.hasOwnProperty; +var __propIsEnum$3 = Object.prototype.propertyIsEnumerable; +var __reflectGet$1 = Reflect.get; +var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues$3 = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp$3.call(b, prop)) + __defNormalProp$3(a, prop, b[prop]); + if (__getOwnPropSymbols$3) + for (var prop of __getOwnPropSymbols$3(b)) { + if (__propIsEnum$3.call(b, prop)) + __defNormalProp$3(a, prop, b[prop]); + } + return a; +}; +var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b)); +var __superGet$1 = (cls, obj, key) => __reflectGet$1(__getProtoOf$1(cls), key, obj); +var __async$c = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +const defaultUserAgent = "Mozilla/5.0 (Windows NT 10.0; rv:109.0) Gecko/20100101 Firefox/115.0"; +const fetch = crossFetch; +function getHttpAgent({ + fetchUrl, + proxyUrl, + torPort, + retry +}) { + if (torPort) { + return new socksProxyAgent.SocksProxyAgent(`socks5h://tor${retry}@127.0.0.1:${torPort}`); + } + if (!proxyUrl) { + return; + } + const isHttps = fetchUrl.includes("https://"); + if (proxyUrl.includes("socks://") || proxyUrl.includes("socks4://") || proxyUrl.includes("socks5://")) { + return new socksProxyAgent.SocksProxyAgent(proxyUrl); + } + if (proxyUrl.includes("http://") || proxyUrl.includes("https://")) { + if (isHttps) { + return new httpsProxyAgent.HttpsProxyAgent(proxyUrl); + } + return new httpProxyAgent.HttpProxyAgent(proxyUrl); + } +} +function fetchData(_0) { + return __async$c(this, arguments, function* (url, options = {}) { + var _a, _b, _c; + const MAX_RETRY = (_a = options.maxRetry) != null ? _a : 3; + const RETRY_ON = (_b = options.retryOn) != null ? _b : 500; + const userAgent = (_c = options.userAgent) != null ? _c : defaultUserAgent; + let retry = 0; + let errorObject; + if (!options.method) { + if (!options.body) { + options.method = "GET"; + } else { + options.method = "POST"; + } + } + if (!options.headers) { + options.headers = {}; + } + if (isNode && !options.headers["User-Agent"]) { + options.headers["User-Agent"] = userAgent; + } + while (retry < MAX_RETRY + 1) { + let timeout; + if (!options.signal && options.timeout) { + const controller = new AbortController(); + options.signal = controller.signal; + timeout = setTimeout(() => { + controller.abort(); + }, options.timeout); + } + if (!options.agent && isNode && (options.proxy || options.torPort)) { + options.agent = getHttpAgent({ + fetchUrl: url, + proxyUrl: options.proxy, + torPort: options.torPort, + retry + }); + } + if (options.debug && typeof options.debug === "function") { + options.debug("request", { + url, + retry, + errorObject, + options + }); + } + try { + const resp = yield fetch(url, { + method: options.method, + headers: options.headers, + body: options.body, + redirect: options.redirect, + signal: options.signal, + agent: options.agent + }); + if (options.debug && typeof options.debug === "function") { + options.debug("response", resp); + } + if (!resp.ok) { + const errMsg = `Request to ${url} failed with error code ${resp.status}: +` + (yield resp.text()); + throw new Error(errMsg); + } + if (options.returnResponse) { + return resp; + } + const contentType = resp.headers.get("content-type"); + if (contentType == null ? void 0 : contentType.includes("application/json")) { + return yield resp.json(); + } + if (contentType == null ? void 0 : contentType.includes("text")) { + return yield resp.text(); + } + return resp; + } catch (error) { + if (timeout) { + clearTimeout(timeout); + } + errorObject = error; + retry++; + yield sleep(RETRY_ON); + } finally { + if (timeout) { + clearTimeout(timeout); + } + } + } + if (options.debug && typeof options.debug === "function") { + options.debug("error", errorObject); + } + throw errorObject; + }); +} +const fetchGetUrlFunc = (options = {}) => (req, _signal) => __async$c(void 0, null, function* () { + let signal; + if (_signal) { + const controller = new AbortController(); + signal = controller.signal; + _signal.addListener(() => { + controller.abort(); + }); + } + const init = __spreadProps$3(__spreadValues$3({}, options), { + method: req.method || "POST", + headers: req.headers, + body: req.body || void 0, + signal, + returnResponse: true + }); + const resp = yield fetchData(req.url, init); + const headers = {}; + resp.headers.forEach((value, key) => { + headers[key.toLowerCase()] = value; + }); + const respBody = yield resp.arrayBuffer(); + const body = respBody == null ? null : new Uint8Array(respBody); + return { + statusCode: resp.status, + statusMessage: resp.statusText, + headers, + body + }; +}); +const oracleMapper = /* @__PURE__ */ new Map(); +const multicallMapper = /* @__PURE__ */ new Map(); +function getGasOraclePlugin(networkKey, fetchOptions) { + const gasStationApi = (fetchOptions == null ? void 0 : fetchOptions.gasStationApi) || "https://gasstation.polygon.technology/v2"; + return new ethers.FetchUrlFeeDataNetworkPlugin(gasStationApi, (fetchFeeData, provider, request) => __async$c(this, null, function* () { + if (!oracleMapper.has(networkKey)) { + oracleMapper.set(networkKey, GasPriceOracle__factory.connect(fetchOptions == null ? void 0 : fetchOptions.gasPriceOracle, provider)); + } + if (!multicallMapper.has(networkKey)) { + multicallMapper.set( + networkKey, + Multicall__factory.connect("0xcA11bde05977b3631167028862bE2a173976CA11", provider) + ); + } + const Oracle = oracleMapper.get(networkKey); + const Multicall2 = multicallMapper.get(networkKey); + const [timestamp, heartbeat, feePerGas, priorityFeePerGas] = yield multicall(Multicall2, [ + { + contract: Oracle, + name: "timestamp" + }, + { + contract: Oracle, + name: "heartbeat" + }, + { + contract: Oracle, + name: "maxFeePerGas" + }, + { + contract: Oracle, + name: "maxPriorityFeePerGas" + } + ]); + const isOutdated = Number(timestamp) <= Date.now() / 1e3 - Number(heartbeat); + if (!isOutdated) { + const maxPriorityFeePerGas = priorityFeePerGas * BigInt(13) / BigInt(10); + const maxFeePerGas = feePerGas * BigInt(2) + maxPriorityFeePerGas; + return { + gasPrice: maxFeePerGas, + maxFeePerGas, + maxPriorityFeePerGas + }; + } + const fetchReq = new ethers.FetchRequest(gasStationApi); + fetchReq.getUrlFunc = fetchGetUrlFunc(fetchOptions); + if (isNode) { + fetchReq.setHeader("User-Agent", "ethers"); + } + const [ + { + bodyJson: { fast } + }, + { gasPrice } + ] = yield Promise.all([fetchReq.send(), fetchFeeData()]); + return { + gasPrice, + maxFeePerGas: ethers.parseUnits(`${fast.maxFee}`, 9), + maxPriorityFeePerGas: ethers.parseUnits(`${fast.maxPriorityFee}`, 9) + }; + })); +} +function getProvider(rpcUrl, fetchOptions) { + return __async$c(this, null, function* () { + const fetchReq = new ethers.FetchRequest(rpcUrl); + fetchReq.getUrlFunc = fetchGetUrlFunc(fetchOptions); + const _staticNetwork = yield new ethers.JsonRpcProvider(fetchReq).getNetwork(); + const ensPlugin = _staticNetwork.getPlugin("org.ethers.plugins.network.Ens"); + const gasCostPlugin = _staticNetwork.getPlugin("org.ethers.plugins.network.GasCost"); + const gasStationPlugin = _staticNetwork.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin"); + const staticNetwork = new ethers.Network(_staticNetwork.name, _staticNetwork.chainId); + if (ensPlugin) { + staticNetwork.attachPlugin(ensPlugin); + } + if (gasCostPlugin) { + staticNetwork.attachPlugin(gasCostPlugin); + } + if (fetchOptions == null ? void 0 : fetchOptions.gasPriceOracle) { + staticNetwork.attachPlugin(getGasOraclePlugin(`${_staticNetwork.chainId}_${rpcUrl}`, fetchOptions)); + } else if (gasStationPlugin) { + staticNetwork.attachPlugin(gasStationPlugin); + } + const provider = new ethers.JsonRpcProvider(fetchReq, staticNetwork, { + staticNetwork + }); + provider.pollingInterval = (fetchOptions == null ? void 0 : fetchOptions.pollingInterval) || 1e3; + return provider; + }); +} +function getProviderWithNetId(netId, rpcUrl, config, fetchOptions) { + const { networkName, reverseRecordsContract, gasPriceOracleContract, gasStationApi, pollInterval } = config; + const hasEns = Boolean(reverseRecordsContract); + const fetchReq = new ethers.FetchRequest(rpcUrl); + fetchReq.getUrlFunc = fetchGetUrlFunc(fetchOptions); + const staticNetwork = new ethers.Network(networkName, netId); + if (hasEns) { + staticNetwork.attachPlugin(new ethers.EnsPlugin(null, Number(netId))); + } + staticNetwork.attachPlugin(new ethers.GasCostPlugin()); + if (gasPriceOracleContract) { + staticNetwork.attachPlugin( + getGasOraclePlugin(`${netId}_${rpcUrl}`, { + gasPriceOracle: gasPriceOracleContract, + gasStationApi + }) + ); + } + const provider = new ethers.JsonRpcProvider(fetchReq, staticNetwork, { + staticNetwork + }); + provider.pollingInterval = (fetchOptions == null ? void 0 : fetchOptions.pollingInterval) || pollInterval * 1e3; + return provider; +} +const populateTransaction = (signer, tx) => __async$c(void 0, null, function* () { + const provider = signer.provider; + if (!tx.from) { + tx.from = signer.address; + } else if (tx.from !== signer.address) { + const errMsg = `populateTransaction: signer mismatch for tx, wants ${tx.from} have ${signer.address}`; + throw new Error(errMsg); + } + const [feeData, nonce] = yield Promise.all([ + (() => __async$c(void 0, null, function* () { + if (tx.maxFeePerGas && tx.maxPriorityFeePerGas) { + return new ethers.FeeData(null, BigInt(tx.maxFeePerGas), BigInt(tx.maxPriorityFeePerGas)); + } + if (tx.gasPrice) { + return new ethers.FeeData(BigInt(tx.gasPrice), null, null); + } + const fetchedFeeData = yield provider.getFeeData(); + if (fetchedFeeData.maxFeePerGas && fetchedFeeData.maxPriorityFeePerGas) { + return new ethers.FeeData( + null, + fetchedFeeData.maxFeePerGas * (BigInt(1e4) + BigInt(signer.gasPriceBump)) / BigInt(1e4), + fetchedFeeData.maxPriorityFeePerGas + ); + } else { + return new ethers.FeeData( + fetchedFeeData.gasPrice * (BigInt(1e4) + BigInt(signer.gasPriceBump)) / BigInt(1e4), + null, + null + ); + } + }))(), + (() => __async$c(void 0, null, function* () { + if (tx.nonce) { + return tx.nonce; + } + let fetchedNonce = yield provider.getTransactionCount(signer.address, "pending"); + if (signer.bumpNonce && signer.nonce && signer.nonce >= fetchedNonce) { + console.log( + `populateTransaction: bumping nonce from ${fetchedNonce} to ${fetchedNonce + 1} for ${signer.address}` + ); + fetchedNonce++; + } + return fetchedNonce; + }))() + ]); + tx.nonce = nonce; + if (feeData.maxFeePerGas && feeData.maxPriorityFeePerGas) { + tx.maxFeePerGas = feeData.maxFeePerGas; + tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; + if (!tx.type) { + tx.type = 2; + } + delete tx.gasPrice; + } else if (feeData.gasPrice) { + tx.gasPrice = feeData.gasPrice; + if (!tx.type) { + tx.type = 0; + } + delete tx.maxFeePerGas; + delete tx.maxPriorityFeePerGas; + } + tx.gasLimit = tx.gasLimit || (yield (() => __async$c(void 0, null, function* () { + try { + const gasLimit = yield provider.estimateGas(tx); + return gasLimit === BigInt(21e3) ? gasLimit : gasLimit * (BigInt(1e4) + BigInt(signer.gasLimitBump)) / BigInt(1e4); + } catch (err) { + if (signer.gasFailover) { + console.log("populateTransaction: warning gas estimation failed falling back to 3M gas"); + return BigInt("3000000"); + } + throw err; + } + }))()); + return tx; +}); +class TornadoWallet extends ethers.Wallet { + constructor(key, provider, { gasPriceBump, gasLimitBump, gasFailover, bumpNonce } = {}) { + super(key, provider); + this.gasPriceBump = gasPriceBump != null ? gasPriceBump : 1e3; + this.gasLimitBump = gasLimitBump != null ? gasLimitBump : 3e3; + this.gasFailover = gasFailover != null ? gasFailover : false; + this.bumpNonce = bumpNonce != null ? bumpNonce : false; + } + static fromMnemonic(mneomnic, provider, index = 0, options) { + const defaultPath = `m/44'/60'/0'/0/${index}`; + const { privateKey } = ethers.HDNodeWallet.fromPhrase(mneomnic, void 0, defaultPath); + return new TornadoWallet(privateKey, provider, options); + } + populateTransaction(tx) { + return __async$c(this, null, function* () { + const txObject = yield populateTransaction(this, tx); + this.nonce = txObject.nonce; + return __superGet$1(TornadoWallet.prototype, this, "populateTransaction").call(this, txObject); + }); + } +} +class TornadoVoidSigner extends ethers.VoidSigner { + constructor(address, provider, { gasPriceBump, gasLimitBump, gasFailover, bumpNonce } = {}) { + super(address, provider); + this.gasPriceBump = gasPriceBump != null ? gasPriceBump : 1e3; + this.gasLimitBump = gasLimitBump != null ? gasLimitBump : 3e3; + this.gasFailover = gasFailover != null ? gasFailover : false; + this.bumpNonce = bumpNonce != null ? bumpNonce : false; + } + populateTransaction(tx) { + return __async$c(this, null, function* () { + const txObject = yield populateTransaction(this, tx); + this.nonce = txObject.nonce; + return __superGet$1(TornadoVoidSigner.prototype, this, "populateTransaction").call(this, txObject); + }); + } +} +class TornadoRpcSigner extends ethers.JsonRpcSigner { + constructor(provider, address, { gasPriceBump, gasLimitBump, gasFailover, bumpNonce } = {}) { + super(provider, address); + this.gasPriceBump = gasPriceBump != null ? gasPriceBump : 1e3; + this.gasLimitBump = gasLimitBump != null ? gasLimitBump : 3e3; + this.gasFailover = gasFailover != null ? gasFailover : false; + this.bumpNonce = bumpNonce != null ? bumpNonce : false; + } + sendUncheckedTransaction(tx) { + return __async$c(this, null, function* () { + return __superGet$1(TornadoRpcSigner.prototype, this, "sendUncheckedTransaction").call(this, yield populateTransaction(this, tx)); + }); + } +} +class TornadoBrowserProvider extends ethers.BrowserProvider { + constructor(ethereum, network, options) { + super(ethereum, network); + this.options = options; + } + getSigner(address) { + return __async$c(this, null, function* () { + var _a, _b, _c, _d, _e, _f, _g, _h, _i; + const signerAddress = (yield __superGet$1(TornadoBrowserProvider.prototype, this, "getSigner").call(this, address)).address; + if (((_a = this.options) == null ? void 0 : _a.webChainId) && ((_b = this.options) == null ? void 0 : _b.connectWallet) && Number(yield __superGet$1(TornadoBrowserProvider.prototype, this, "send").call(this, "eth_chainId", [])) !== Number((_c = this.options) == null ? void 0 : _c.webChainId)) { + yield this.options.connectWallet(); + } + if ((_d = this.options) == null ? void 0 : _d.handleNetworkChanges) { + (_e = window == null ? void 0 : window.ethereum) == null ? void 0 : _e.on("chainChanged", this.options.handleNetworkChanges); + } + if ((_f = this.options) == null ? void 0 : _f.handleAccountChanges) { + (_g = window == null ? void 0 : window.ethereum) == null ? void 0 : _g.on("accountsChanged", this.options.handleAccountChanges); + } + if ((_h = this.options) == null ? void 0 : _h.handleAccountDisconnect) { + (_i = window == null ? void 0 : window.ethereum) == null ? void 0 : _i.on("disconnect", this.options.handleAccountDisconnect); + } + return new TornadoRpcSigner(this, signerAddress, this.options); + }); + } +} + +const GET_STATISTIC = ` + query getStatistic($currency: String!, $amount: String!, $first: Int, $orderBy: BigInt, $orderDirection: String) { + deposits(first: $first, orderBy: $orderBy, orderDirection: $orderDirection, where: { currency: $currency, amount: $amount }) { + index + timestamp + blockNumber + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const _META = ` + query getMeta { + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const GET_REGISTERED = ` + query getRegistered($first: Int, $fromBlock: Int) { + relayers(first: $first, orderBy: blockRegistration, orderDirection: asc, where: { + blockRegistration_gte: $fromBlock + }) { + id + address + ensName + blockRegistration + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const GET_DEPOSITS = ` + query getDeposits($currency: String!, $amount: String!, $first: Int, $fromBlock: Int) { + deposits(first: $first, orderBy: index, orderDirection: asc, where: { + amount: $amount, + currency: $currency, + blockNumber_gte: $fromBlock + }) { + id + blockNumber + commitment + index + timestamp + from + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const GET_WITHDRAWALS = ` + query getWithdrawals($currency: String!, $amount: String!, $first: Int, $fromBlock: Int!) { + withdrawals(first: $first, orderBy: blockNumber, orderDirection: asc, where: { + currency: $currency, + amount: $amount, + blockNumber_gte: $fromBlock + }) { + id + blockNumber + nullifier + to + fee + timestamp + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const GET_NOTE_ACCOUNTS = ` + query getNoteAccount($address: String!) { + noteAccounts(where: { address: $address }) { + id + index + address + encryptedAccount + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const GET_ENCRYPTED_NOTES = ` + query getEncryptedNotes($first: Int, $fromBlock: Int) { + encryptedNotes(first: $first, orderBy: blockNumber, orderDirection: asc, where: { blockNumber_gte: $fromBlock }) { + blockNumber + index + transactionHash + encryptedNote + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; + +var __defProp$2 = Object.defineProperty; +var __defProps$2 = Object.defineProperties; +var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols; +var __hasOwnProp$2 = Object.prototype.hasOwnProperty; +var __propIsEnum$2 = Object.prototype.propertyIsEnumerable; +var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues$2 = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp$2.call(b, prop)) + __defNormalProp$2(a, prop, b[prop]); + if (__getOwnPropSymbols$2) + for (var prop of __getOwnPropSymbols$2(b)) { + if (__propIsEnum$2.call(b, prop)) + __defNormalProp$2(a, prop, b[prop]); + } + return a; +}; +var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b)); +var __async$b = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +const isEmptyArray = (arr) => !Array.isArray(arr) || !arr.length; +const first = 1e3; +function queryGraph(_0) { + return __async$b(this, arguments, function* ({ + graphApi, + subgraphName, + query, + variables, + fetchDataOptions: fetchDataOptions2 + }) { + var _a; + const graphUrl = `${graphApi}/subgraphs/name/${subgraphName}`; + const { data, errors } = yield fetchData(graphUrl, __spreadProps$2(__spreadValues$2({}, fetchDataOptions2), { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + query, + variables + }) + })); + if (errors) { + throw new Error(JSON.stringify(errors)); + } + if ((_a = data == null ? void 0 : data._meta) == null ? void 0 : _a.hasIndexingErrors) { + throw new Error("Subgraph has indexing errors"); + } + return data; + }); +} +function getStatistic(_0) { + return __async$b(this, arguments, function* ({ + graphApi, + subgraphName, + currency, + amount, + fetchDataOptions: fetchDataOptions2 + }) { + try { + const { + deposits, + _meta: { + block: { number: lastSyncBlock } + } + } = yield queryGraph({ + graphApi, + subgraphName, + query: GET_STATISTIC, + variables: { + currency, + first: 10, + orderBy: "index", + orderDirection: "desc", + amount + }, + fetchDataOptions: fetchDataOptions2 + }); + const events = deposits.map((e) => ({ + timestamp: Number(e.timestamp), + leafIndex: Number(e.index), + blockNumber: Number(e.blockNumber) + })).reverse(); + const [lastEvent] = events.slice(-1); + return { + events, + lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock + }; + } catch (err) { + console.log("Error from getStatistic query"); + console.log(err); + return { + events: [], + lastSyncBlock: null + }; + } + }); +} +function getMeta(_0) { + return __async$b(this, arguments, function* ({ graphApi, subgraphName, fetchDataOptions: fetchDataOptions2 }) { + try { + const { + _meta: { + block: { number: lastSyncBlock }, + hasIndexingErrors + } + } = yield queryGraph({ + graphApi, + subgraphName, + query: _META, + fetchDataOptions: fetchDataOptions2 + }); + return { + lastSyncBlock, + hasIndexingErrors + }; + } catch (err) { + console.log("Error from getMeta query"); + console.log(err); + return { + lastSyncBlock: null, + hasIndexingErrors: null + }; + } + }); +} +function getRegisters({ + graphApi, + subgraphName, + fromBlock, + fetchDataOptions: fetchDataOptions2 +}) { + return queryGraph({ + graphApi, + subgraphName, + query: GET_REGISTERED, + variables: { + first, + fromBlock + }, + fetchDataOptions: fetchDataOptions2 + }); +} +function getAllRegisters(_0) { + return __async$b(this, arguments, function* ({ + graphApi, + subgraphName, + fromBlock, + fetchDataOptions: fetchDataOptions2, + onProgress + }) { + try { + const events = []; + let lastSyncBlock = fromBlock; + while (true) { + let { + relayers: result2, + _meta: { + // eslint-disable-next-line prefer-const + block: { number: currentBlock } + } + } = yield getRegisters({ graphApi, subgraphName, fromBlock, fetchDataOptions: fetchDataOptions2 }); + lastSyncBlock = currentBlock; + if (isEmptyArray(result2)) { + break; + } + const [firstEvent] = result2; + const [lastEvent] = result2.slice(-1); + if (typeof onProgress === "function") { + onProgress({ + type: "Registers", + fromBlock: Number(firstEvent.blockRegistration), + toBlock: Number(lastEvent.blockRegistration), + count: result2.length + }); + } + if (result2.length < 900) { + events.push(...result2); + break; + } + result2 = result2.filter(({ blockRegistration }) => blockRegistration !== lastEvent.blockRegistration); + fromBlock = Number(lastEvent.blockRegistration); + events.push(...result2); + } + if (!events.length) { + return { + events: [], + lastSyncBlock + }; + } + const result = events.map(({ id, address, ensName, blockRegistration }) => { + const [transactionHash, logIndex] = id.split("-"); + return { + blockNumber: Number(blockRegistration), + logIndex: Number(logIndex), + transactionHash, + ensName, + relayerAddress: ethers.getAddress(address) + }; + }); + return { + events: result, + lastSyncBlock + }; + } catch (err) { + console.log("Error from getAllRegisters query"); + console.log(err); + return { events: [], lastSyncBlock: fromBlock }; + } + }); +} +function getDeposits({ + graphApi, + subgraphName, + currency, + amount, + fromBlock, + fetchDataOptions: fetchDataOptions2 +}) { + return queryGraph({ + graphApi, + subgraphName, + query: GET_DEPOSITS, + variables: { + currency, + amount, + first, + fromBlock + }, + fetchDataOptions: fetchDataOptions2 + }); +} +function getAllDeposits(_0) { + return __async$b(this, arguments, function* ({ + graphApi, + subgraphName, + currency, + amount, + fromBlock, + fetchDataOptions: fetchDataOptions2, + onProgress + }) { + try { + const events = []; + let lastSyncBlock = fromBlock; + while (true) { + let { + deposits: result2, + _meta: { + // eslint-disable-next-line prefer-const + block: { number: currentBlock } + } + } = yield getDeposits({ graphApi, subgraphName, currency, amount, fromBlock, fetchDataOptions: fetchDataOptions2 }); + lastSyncBlock = currentBlock; + if (isEmptyArray(result2)) { + break; + } + const [firstEvent] = result2; + const [lastEvent2] = result2.slice(-1); + if (typeof onProgress === "function") { + onProgress({ + type: "Deposits", + fromBlock: Number(firstEvent.blockNumber), + toBlock: Number(lastEvent2.blockNumber), + count: result2.length + }); + } + if (result2.length < 900) { + events.push(...result2); + break; + } + result2 = result2.filter(({ blockNumber }) => blockNumber !== lastEvent2.blockNumber); + fromBlock = Number(lastEvent2.blockNumber); + events.push(...result2); + } + if (!events.length) { + return { + events: [], + lastSyncBlock + }; + } + const result = events.map(({ id, blockNumber, commitment, index, timestamp, from }) => { + const [transactionHash, logIndex] = id.split("-"); + return { + blockNumber: Number(blockNumber), + logIndex: Number(logIndex), + transactionHash, + commitment, + leafIndex: Number(index), + timestamp: Number(timestamp), + from: ethers.getAddress(from) + }; + }); + const [lastEvent] = result.slice(-1); + return { + events: result, + lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock + }; + } catch (err) { + console.log("Error from getAllDeposits query"); + console.log(err); + return { + events: [], + lastSyncBlock: fromBlock + }; + } + }); +} +function getWithdrawals({ + graphApi, + subgraphName, + currency, + amount, + fromBlock, + fetchDataOptions: fetchDataOptions2 +}) { + return queryGraph({ + graphApi, + subgraphName, + query: GET_WITHDRAWALS, + variables: { + currency, + amount, + first, + fromBlock + }, + fetchDataOptions: fetchDataOptions2 + }); +} +function getAllWithdrawals(_0) { + return __async$b(this, arguments, function* ({ + graphApi, + subgraphName, + currency, + amount, + fromBlock, + fetchDataOptions: fetchDataOptions2, + onProgress + }) { + try { + const events = []; + let lastSyncBlock = fromBlock; + while (true) { + let { + withdrawals: result2, + _meta: { + // eslint-disable-next-line prefer-const + block: { number: currentBlock } + } + } = yield getWithdrawals({ graphApi, subgraphName, currency, amount, fromBlock, fetchDataOptions: fetchDataOptions2 }); + lastSyncBlock = currentBlock; + if (isEmptyArray(result2)) { + break; + } + const [firstEvent] = result2; + const [lastEvent2] = result2.slice(-1); + if (typeof onProgress === "function") { + onProgress({ + type: "Withdrawals", + fromBlock: Number(firstEvent.blockNumber), + toBlock: Number(lastEvent2.blockNumber), + count: result2.length + }); + } + if (result2.length < 900) { + events.push(...result2); + break; + } + result2 = result2.filter(({ blockNumber }) => blockNumber !== lastEvent2.blockNumber); + fromBlock = Number(lastEvent2.blockNumber); + events.push(...result2); + } + if (!events.length) { + return { + events: [], + lastSyncBlock + }; + } + const result = events.map(({ id, blockNumber, nullifier, to, fee, timestamp }) => { + const [transactionHash, logIndex] = id.split("-"); + return { + blockNumber: Number(blockNumber), + logIndex: Number(logIndex), + transactionHash, + nullifierHash: nullifier, + to: ethers.getAddress(to), + fee, + timestamp: Number(timestamp) + }; + }); + const [lastEvent] = result.slice(-1); + return { + events: result, + lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock + }; + } catch (err) { + console.log("Error from getAllWithdrawals query"); + console.log(err); + return { + events: [], + lastSyncBlock: fromBlock + }; + } + }); +} +function getNoteAccounts(_0) { + return __async$b(this, arguments, function* ({ + graphApi, + subgraphName, + address, + fetchDataOptions: fetchDataOptions2 + }) { + try { + const { + noteAccounts: events, + _meta: { + block: { number: lastSyncBlock } + } + } = yield queryGraph({ + graphApi, + subgraphName, + query: GET_NOTE_ACCOUNTS, + variables: { + address + }, + fetchDataOptions: fetchDataOptions2 + }); + return { + events, + lastSyncBlock + }; + } catch (err) { + console.log("Error from getNoteAccounts query"); + console.log(err); + return { + events: [], + lastSyncBlock: null + }; + } + }); +} +function getEncryptedNotes({ + graphApi, + subgraphName, + fromBlock, + fetchDataOptions: fetchDataOptions2 +}) { + return queryGraph({ + graphApi, + subgraphName, + query: GET_ENCRYPTED_NOTES, + variables: { + first, + fromBlock + }, + fetchDataOptions: fetchDataOptions2 + }); +} +function getAllEncryptedNotes(_0) { + return __async$b(this, arguments, function* ({ + graphApi, + subgraphName, + fromBlock, + fetchDataOptions: fetchDataOptions2, + onProgress + }) { + try { + const events = []; + let lastSyncBlock = fromBlock; + while (true) { + let { + encryptedNotes: result2, + _meta: { + // eslint-disable-next-line prefer-const + block: { number: currentBlock } + } + } = yield getEncryptedNotes({ graphApi, subgraphName, fromBlock, fetchDataOptions: fetchDataOptions2 }); + lastSyncBlock = currentBlock; + if (isEmptyArray(result2)) { + break; + } + const [firstEvent] = result2; + const [lastEvent2] = result2.slice(-1); + if (typeof onProgress === "function") { + onProgress({ + type: "EncryptedNotes", + fromBlock: Number(firstEvent.blockNumber), + toBlock: Number(lastEvent2.blockNumber), + count: result2.length + }); + } + if (result2.length < 900) { + events.push(...result2); + break; + } + result2 = result2.filter(({ blockNumber }) => blockNumber !== lastEvent2.blockNumber); + fromBlock = Number(lastEvent2.blockNumber); + events.push(...result2); + } + if (!events.length) { + return { + events: [], + lastSyncBlock + }; + } + const result = events.map((e) => ({ + blockNumber: Number(e.blockNumber), + logIndex: Number(e.index), + transactionHash: e.transactionHash, + encryptedNote: e.encryptedNote + })); + const [lastEvent] = result.slice(-1); + return { + events: result, + lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock + }; + } catch (err) { + console.log("Error from getAllEncryptedNotes query"); + console.log(err); + return { + events: [], + lastSyncBlock: fromBlock + }; + } + }); +} + +var graph = /*#__PURE__*/Object.freeze({ + __proto__: null, + GET_DEPOSITS: GET_DEPOSITS, + GET_ENCRYPTED_NOTES: GET_ENCRYPTED_NOTES, + GET_NOTE_ACCOUNTS: GET_NOTE_ACCOUNTS, + GET_REGISTERED: GET_REGISTERED, + GET_STATISTIC: GET_STATISTIC, + GET_WITHDRAWALS: GET_WITHDRAWALS, + _META: _META, + getAllDeposits: getAllDeposits, + getAllEncryptedNotes: getAllEncryptedNotes, + getAllRegisters: getAllRegisters, + getAllWithdrawals: getAllWithdrawals, + getDeposits: getDeposits, + getEncryptedNotes: getEncryptedNotes, + getMeta: getMeta, + getNoteAccounts: getNoteAccounts, + getRegisters: getRegisters, + getStatistic: getStatistic, + getWithdrawals: getWithdrawals, + queryGraph: queryGraph +}); + +var __async$a = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +class BatchBlockService { + constructor({ + provider, + onProgress, + concurrencySize = 10, + batchSize = 10, + shouldRetry = true, + retryMax = 5, + retryOn = 500 + }) { + this.provider = provider; + this.onProgress = onProgress; + this.concurrencySize = concurrencySize; + this.batchSize = batchSize; + this.shouldRetry = shouldRetry; + this.retryMax = retryMax; + this.retryOn = retryOn; + } + getBlock(blockTag) { + return __async$a(this, null, function* () { + const blockObject = yield this.provider.getBlock(blockTag); + if (!blockObject) { + const errMsg = `No block for ${blockTag}`; + throw new Error(errMsg); + } + return blockObject; + }); + } + createBatchRequest(batchArray) { + return batchArray.map((blocks, index) => __async$a(this, null, function* () { + yield sleep(20 * index); + return (() => __async$a(this, null, function* () { + let retries = 0; + let err; + while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) { + try { + return yield Promise.all(blocks.map((b) => this.getBlock(b))); + } catch (e) { + retries++; + err = e; + yield sleep(this.retryOn); + } + } + throw err; + }))(); + })); + } + getBatchBlocks(blocks) { + return __async$a(this, null, function* () { + let blockCount = 0; + const results = []; + for (const chunks of chunk(blocks, this.concurrencySize * this.batchSize)) { + const chunksResult = (yield Promise.all(this.createBatchRequest(chunk(chunks, this.batchSize)))).flat(); + results.push(...chunksResult); + blockCount += chunks.length; + if (typeof this.onProgress === "function") { + this.onProgress({ + percentage: blockCount / blocks.length, + currentIndex: blockCount, + totalIndex: blocks.length + }); + } + } + return results; + }); + } +} +class BatchTransactionService { + constructor({ + provider, + onProgress, + concurrencySize = 10, + batchSize = 10, + shouldRetry = true, + retryMax = 5, + retryOn = 500 + }) { + this.provider = provider; + this.onProgress = onProgress; + this.concurrencySize = concurrencySize; + this.batchSize = batchSize; + this.shouldRetry = shouldRetry; + this.retryMax = retryMax; + this.retryOn = retryOn; + } + getTransaction(txHash) { + return __async$a(this, null, function* () { + const txObject = yield this.provider.getTransaction(txHash); + if (!txObject) { + const errMsg = `No transaction for ${txHash}`; + throw new Error(errMsg); + } + return txObject; + }); + } + createBatchRequest(batchArray) { + return batchArray.map((txs, index) => __async$a(this, null, function* () { + yield sleep(20 * index); + return (() => __async$a(this, null, function* () { + let retries = 0; + let err; + while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) { + try { + return yield Promise.all(txs.map((tx) => this.getTransaction(tx))); + } catch (e) { + retries++; + err = e; + yield sleep(this.retryOn); + } + } + throw err; + }))(); + })); + } + getBatchTransactions(txs) { + return __async$a(this, null, function* () { + let txCount = 0; + const results = []; + for (const chunks of chunk(txs, this.concurrencySize * this.batchSize)) { + const chunksResult = (yield Promise.all(this.createBatchRequest(chunk(chunks, this.batchSize)))).flat(); + results.push(...chunksResult); + txCount += chunks.length; + if (typeof this.onProgress === "function") { + this.onProgress({ percentage: txCount / txs.length, currentIndex: txCount, totalIndex: txs.length }); + } + } + return results; + }); + } +} +class BatchEventsService { + constructor({ + provider, + contract, + onProgress, + concurrencySize = 10, + blocksPerRequest = 2e3, + shouldRetry = true, + retryMax = 5, + retryOn = 500 + }) { + this.provider = provider; + this.contract = contract; + this.onProgress = onProgress; + this.concurrencySize = concurrencySize; + this.blocksPerRequest = blocksPerRequest; + this.shouldRetry = shouldRetry; + this.retryMax = retryMax; + this.retryOn = retryOn; + } + getPastEvents(_0) { + return __async$a(this, arguments, function* ({ fromBlock, toBlock, type }) { + let err; + let retries = 0; + while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) { + try { + return yield this.contract.queryFilter(type, fromBlock, toBlock); + } catch (e) { + err = e; + retries++; + if (e.message.includes("after last accepted block")) { + const acceptedBlock = parseInt(e.message.split("after last accepted block ")[1]); + toBlock = acceptedBlock; + } + yield sleep(this.retryOn); + } + } + throw err; + }); + } + createBatchRequest(batchArray) { + return batchArray.map((event, index) => __async$a(this, null, function* () { + yield sleep(20 * index); + return this.getPastEvents(event); + })); + } + getBatchEvents(_0) { + return __async$a(this, arguments, function* ({ fromBlock, toBlock, type = "*" }) { + if (!toBlock) { + toBlock = yield this.provider.getBlockNumber(); + } + const eventsToSync = []; + for (let i = fromBlock; i < toBlock; i += this.blocksPerRequest) { + const j = i + this.blocksPerRequest - 1 > toBlock ? toBlock : i + this.blocksPerRequest - 1; + eventsToSync.push({ fromBlock: i, toBlock: j, type }); + } + const events = []; + const eventChunk = chunk(eventsToSync, this.concurrencySize); + let chunkCount = 0; + for (const chunk2 of eventChunk) { + chunkCount++; + const fetchedEvents = (yield Promise.all(this.createBatchRequest(chunk2))).flat(); + events.push(...fetchedEvents); + if (typeof this.onProgress === "function") { + this.onProgress({ + percentage: chunkCount / eventChunk.length, + type, + fromBlock: chunk2[0].fromBlock, + toBlock: chunk2[chunk2.length - 1].toBlock, + count: fetchedEvents.length + }); + } + } + return events; + }); + } +} + +var __defProp$1 = Object.defineProperty; +var __defProps$1 = Object.defineProperties; +var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp$1 = Object.prototype.hasOwnProperty; +var __propIsEnum$1 = Object.prototype.propertyIsEnumerable; +var __reflectGet = Reflect.get; +var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues$1 = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp$1.call(b, prop)) + __defNormalProp$1(a, prop, b[prop]); + if (__getOwnPropSymbols$1) + for (var prop of __getOwnPropSymbols$1(b)) { + if (__propIsEnum$1.call(b, prop)) + __defNormalProp$1(a, prop, b[prop]); + } + return a; +}; +var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b)); +var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj); +var __async$9 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +const DEPOSIT = "deposit"; +const WITHDRAWAL = "withdrawal"; +class BaseEventsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + contract, + type = "", + deployedBlock = 0, + fetchDataOptions: fetchDataOptions2 + }) { + this.netId = netId; + this.provider = provider; + this.graphApi = graphApi; + this.subgraphName = subgraphName; + this.fetchDataOptions = fetchDataOptions2; + this.contract = contract; + this.type = type; + this.deployedBlock = deployedBlock; + this.batchEventsService = new BatchEventsService({ + provider, + contract, + onProgress: this.updateEventProgress + }); + } + getInstanceName() { + return ""; + } + getType() { + return this.type || ""; + } + getGraphMethod() { + return ""; + } + getGraphParams() { + return { + graphApi: this.graphApi || "", + subgraphName: this.subgraphName || "", + fetchDataOptions: this.fetchDataOptions, + onProgress: this.updateGraphProgress + }; + } + /* eslint-disable @typescript-eslint/no-unused-vars */ + updateEventProgress({ percentage, type, fromBlock, toBlock, count }) { + } + updateBlockProgress({ percentage, currentIndex, totalIndex }) { + } + updateTransactionProgress({ percentage, currentIndex, totalIndex }) { + } + updateGraphProgress({ type, fromBlock, toBlock, count }) { + } + /* eslint-enable @typescript-eslint/no-unused-vars */ + formatEvents(events) { + return __async$9(this, null, function* () { + return yield new Promise((resolve) => resolve(events)); + }); + } + /** + * Get saved or cached events + */ + getEventsFromDB() { + return __async$9(this, null, function* () { + return { + events: [], + lastBlock: null + }; + }); + } + getEventsFromCache() { + return __async$9(this, null, function* () { + return { + events: [], + lastBlock: null + }; + }); + } + getSavedEvents() { + return __async$9(this, null, function* () { + let cachedEvents = yield this.getEventsFromDB(); + if (!cachedEvents || !cachedEvents.events.length) { + cachedEvents = yield this.getEventsFromCache(); + } + return cachedEvents; + }); + } + /** + * Get latest events + */ + getEventsFromGraph(_0) { + return __async$9(this, arguments, function* ({ + fromBlock, + methodName = "" + }) { + if (!this.graphApi || !this.subgraphName) { + return { + events: [], + lastBlock: fromBlock + }; + } + const { events, lastSyncBlock } = yield graph[methodName || this.getGraphMethod()](__spreadValues$1({ + fromBlock + }, this.getGraphParams())); + return { + events, + lastBlock: lastSyncBlock + }; + }); + } + getEventsFromRpc(_0) { + return __async$9(this, arguments, function* ({ + fromBlock, + toBlock + }) { + try { + if (!toBlock) { + toBlock = yield this.provider.getBlockNumber(); + } + if (fromBlock >= toBlock) { + return { + events: [], + lastBlock: toBlock + }; + } + this.updateEventProgress({ percentage: 0, type: this.getType() }); + const events = yield this.formatEvents( + yield this.batchEventsService.getBatchEvents({ fromBlock, toBlock, type: this.getType() }) + ); + if (!events.length) { + return { + events, + lastBlock: toBlock + }; + } + return { + events, + lastBlock: toBlock + }; + } catch (err) { + console.log(err); + return { + events: [], + lastBlock: fromBlock + }; + } + }); + } + getLatestEvents(_0) { + return __async$9(this, arguments, function* ({ fromBlock }) { + const allEvents = []; + const graphEvents = yield this.getEventsFromGraph({ fromBlock }); + const lastSyncBlock = graphEvents.lastBlock && graphEvents.lastBlock >= fromBlock ? graphEvents.lastBlock : fromBlock; + const rpcEvents = yield this.getEventsFromRpc({ fromBlock: lastSyncBlock }); + allEvents.push(...graphEvents.events); + allEvents.push(...rpcEvents.events); + const lastBlock = rpcEvents ? rpcEvents.lastBlock : allEvents[allEvents.length - 1] ? allEvents[allEvents.length - 1].blockNumber : fromBlock; + return { + events: allEvents, + lastBlock + }; + }); + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + validateEvents({ events, lastBlock }) { + } + /** + * Handle saving events + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + saveEvents(_0) { + return __async$9(this, arguments, function* ({ events, lastBlock }) { + }); + } + /** + * Trigger saving and receiving latest events + */ + updateEvents() { + return __async$9(this, null, function* () { + const savedEvents = yield this.getSavedEvents(); + let fromBlock = this.deployedBlock; + if (savedEvents && savedEvents.lastBlock) { + fromBlock = savedEvents.lastBlock + 1; + } + const newEvents = yield this.getLatestEvents({ fromBlock }); + const eventSet = /* @__PURE__ */ new Set(); + let allEvents = []; + allEvents.push(...savedEvents.events); + allEvents.push(...newEvents.events); + allEvents = allEvents.sort((a, b) => { + if (a.blockNumber === b.blockNumber) { + return a.logIndex - b.logIndex; + } + return a.blockNumber - b.blockNumber; + }).filter(({ transactionHash, logIndex }) => { + const eventKey = `${transactionHash}_${logIndex}`; + const hasEvent = eventSet.has(eventKey); + eventSet.add(eventKey); + return !hasEvent; + }); + const lastBlock = newEvents ? newEvents.lastBlock : allEvents[allEvents.length - 1] ? allEvents[allEvents.length - 1].blockNumber : null; + this.validateEvents({ events: allEvents, lastBlock }); + yield this.saveEvents({ events: allEvents, lastBlock }); + return { + events: allEvents, + lastBlock + }; + }); + } +} +class BaseDepositsService extends BaseEventsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Tornado, + type, + amount, + currency, + deployedBlock, + fetchDataOptions: fetchDataOptions2 + }) { + super({ netId, provider, graphApi, subgraphName, contract: Tornado, type, deployedBlock, fetchDataOptions: fetchDataOptions2 }); + this.amount = amount; + this.currency = currency; + this.batchTransactionService = new BatchTransactionService({ + provider, + onProgress: this.updateTransactionProgress + }); + this.batchBlockService = new BatchBlockService({ + provider, + onProgress: this.updateBlockProgress + }); + } + getInstanceName() { + return `${this.getType().toLowerCase()}s_${this.netId}_${this.currency}_${this.amount}`; + } + getGraphMethod() { + return `getAll${this.getType()}s`; + } + getGraphParams() { + return { + graphApi: this.graphApi || "", + subgraphName: this.subgraphName || "", + amount: this.amount, + currency: this.currency, + fetchDataOptions: this.fetchDataOptions, + onProgress: this.updateGraphProgress + }; + } + formatEvents(events) { + return __async$9(this, null, function* () { + const type = this.getType().toLowerCase(); + if (type === DEPOSIT) { + const formattedEvents = events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { + const { commitment, leafIndex, timestamp } = args; + return { + blockNumber, + logIndex, + transactionHash, + commitment, + leafIndex: Number(leafIndex), + timestamp: Number(timestamp) + }; + }); + const txs = yield this.batchTransactionService.getBatchTransactions([ + ...new Set(formattedEvents.map(({ transactionHash }) => transactionHash)) + ]); + return formattedEvents.map((event) => { + const { from } = txs.find(({ hash }) => hash === event.transactionHash); + return __spreadProps$1(__spreadValues$1({}, event), { + from + }); + }); + } else { + const formattedEvents = events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { + const { nullifierHash, to, fee } = args; + return { + blockNumber, + logIndex, + transactionHash, + nullifierHash: String(nullifierHash), + to: ethers.getAddress(to), + fee: String(fee) + }; + }); + const blocks = yield this.batchBlockService.getBatchBlocks([ + ...new Set(formattedEvents.map(({ blockNumber }) => blockNumber)) + ]); + return formattedEvents.map((event) => { + const { timestamp } = blocks.find(({ number }) => number === event.blockNumber); + return __spreadProps$1(__spreadValues$1({}, event), { + timestamp + }); + }); + } + }); + } + validateEvents({ events }) { + if (events.length && this.getType().toLowerCase() === DEPOSIT) { + const lastEvent = events[events.length - 1]; + if (lastEvent.leafIndex !== events.length - 1) { + const errMsg = `Deposit events invalid wants ${events.length - 1} leafIndex have ${lastEvent.leafIndex}`; + throw new Error(errMsg); + } + } + } +} +class BaseEncryptedNotesService extends BaseEventsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Router, + deployedBlock, + fetchDataOptions: fetchDataOptions2 + }) { + super({ netId, provider, graphApi, subgraphName, contract: Router, deployedBlock, fetchDataOptions: fetchDataOptions2 }); + } + getInstanceName() { + return `encrypted_notes_${this.netId}`; + } + getType() { + return "EncryptedNote"; + } + getGraphMethod() { + return "getAllEncryptedNotes"; + } + formatEvents(events) { + return __async$9(this, null, function* () { + return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { + const { encryptedNote } = args; + if (encryptedNote) { + const eventObjects = { + blockNumber, + logIndex, + transactionHash + }; + return __spreadProps$1(__spreadValues$1({}, eventObjects), { + encryptedNote + }); + } + }).filter((e) => e); + }); + } +} +class BaseGovernanceService extends BaseEventsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Governance, + deployedBlock, + fetchDataOptions: fetchDataOptions2 + }) { + super({ netId, provider, graphApi, subgraphName, contract: Governance, deployedBlock, fetchDataOptions: fetchDataOptions2 }); + this.batchTransactionService = new BatchTransactionService({ + provider, + onProgress: this.updateTransactionProgress + }); + } + getInstanceName() { + return `governance_${this.netId}`; + } + getType() { + return "*"; + } + getGraphMethod() { + return "governanceEvents"; + } + formatEvents(events) { + return __async$9(this, null, function* () { + const formattedEvents = events.map(({ blockNumber, index: logIndex, transactionHash, args, eventName: event }) => { + const eventObjects = { + blockNumber, + logIndex, + transactionHash, + event + }; + if (event === "ProposalCreated") { + const { id, proposer, target, startTime, endTime, description } = args; + return __spreadProps$1(__spreadValues$1({}, eventObjects), { + id, + proposer, + target, + startTime, + endTime, + description + }); + } + if (event === "Voted") { + const { proposalId, voter, support, votes } = args; + return __spreadProps$1(__spreadValues$1({}, eventObjects), { + proposalId, + voter, + support, + votes + }); + } + if (event === "Delegated") { + const { account, to: delegateTo } = args; + return __spreadProps$1(__spreadValues$1({}, eventObjects), { + account, + delegateTo + }); + } + if (event === "Undelegated") { + const { account, from: delegateFrom } = args; + return __spreadProps$1(__spreadValues$1({}, eventObjects), { + account, + delegateFrom + }); + } + }).filter((e) => e); + const votedEvents = formattedEvents.map((event, index) => __spreadProps$1(__spreadValues$1({}, event), { index })).filter(({ event }) => event === "Voted"); + if (votedEvents.length) { + this.updateTransactionProgress({ percentage: 0 }); + const txs = yield this.batchTransactionService.getBatchTransactions([ + ...new Set(votedEvents.map(({ transactionHash }) => transactionHash)) + ]); + votedEvents.forEach((event) => { + let { data: input, from } = txs.find((t) => t.hash === event.transactionHash); + if (!input || input.length > 2048) { + input = ""; + } + formattedEvents[event.index].from = from; + formattedEvents[event.index].input = input; + }); + } + return formattedEvents; + }); + } + getEventsFromGraph(_0) { + return __async$9(this, arguments, function* ({ fromBlock }) { + if (!this.graphApi || this.graphApi.includes("api.thegraph.com")) { + return { + events: [], + lastBlock: fromBlock + }; + } + return __superGet(BaseGovernanceService.prototype, this, "getEventsFromGraph").call(this, { fromBlock }); + }); + } +} +class BaseRegistryService extends BaseEventsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + RelayerRegistry, + deployedBlock, + fetchDataOptions: fetchDataOptions2 + }) { + super({ netId, provider, graphApi, subgraphName, contract: RelayerRegistry, deployedBlock, fetchDataOptions: fetchDataOptions2 }); + } + getInstanceName() { + return `registered_${this.netId}`; + } + // Name of type used for events + getType() { + return "RelayerRegistered"; + } + // Name of method used for graph + getGraphMethod() { + return "getAllRegisters"; + } + formatEvents(events) { + return __async$9(this, null, function* () { + return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { + const eventObjects = { + blockNumber, + logIndex, + transactionHash + }; + return __spreadProps$1(__spreadValues$1({}, eventObjects), { + ensName: args.ensName, + relayerAddress: args.relayerAddress + }); + }); + }); + } + fetchRelayers() { + return __async$9(this, null, function* () { + return (yield this.updateEvents()).events; + }); + } +} + +var __async$8 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +function existsAsync(fileOrDir) { + return __async$8(this, null, function* () { + try { + yield promises.stat(fileOrDir); + return true; + } catch (e) { + return false; + } + }); +} +function zipAsync(file) { + return new Promise((res, rej) => { + fflate.zip(file, { mtime: /* @__PURE__ */ new Date("1/1/1980") }, (err, data) => { + if (err) { + rej(err); + return; + } + res(data); + }); + }); +} +function unzipAsync(data) { + return new Promise((res, rej) => { + fflate.unzip(data, {}, (err, data2) => { + if (err) { + rej(err); + return; + } + res(data2); + }); + }); +} +function saveEvents(_0) { + return __async$8(this, arguments, function* ({ + name, + userDirectory, + events + }) { + const fileName = `${name}.json`.toLowerCase(); + const filePath = path.join(userDirectory, fileName); + const stringEvents = JSON.stringify(events, null, 2) + "\n"; + const payload = yield zipAsync({ + [fileName]: new TextEncoder().encode(stringEvents) + }); + if (!(yield existsAsync(userDirectory))) { + yield promises.mkdir(userDirectory, { recursive: true }); + } + yield promises.writeFile(filePath + ".zip", payload); + yield promises.writeFile(filePath, stringEvents); + }); +} +function loadSavedEvents(_0) { + return __async$8(this, arguments, function* ({ + name, + userDirectory, + deployedBlock + }) { + const filePath = path.join(userDirectory, `${name}.json`.toLowerCase()); + if (!(yield existsAsync(filePath))) { + return { + events: [], + lastBlock: null + }; + } + try { + const events = JSON.parse(yield promises.readFile(filePath, { encoding: "utf8" })); + return { + events, + lastBlock: events && events.length ? events[events.length - 1].blockNumber : deployedBlock + }; + } catch (err) { + console.log("Method loadSavedEvents has error"); + console.log(err); + return { + events: [], + lastBlock: deployedBlock + }; + } + }); +} +function download(_0) { + return __async$8(this, arguments, function* ({ name, cacheDirectory }) { + const fileName = `${name}.json`.toLowerCase(); + const zipName = `${fileName}.zip`; + const zipPath = path.join(cacheDirectory, zipName); + const data = yield promises.readFile(zipPath); + const { [fileName]: content } = yield unzipAsync(data); + return new TextDecoder().decode(content); + }); +} +function loadCachedEvents(_0) { + return __async$8(this, arguments, function* ({ + name, + cacheDirectory, + deployedBlock + }) { + try { + const module = yield download({ cacheDirectory, name }); + if (module) { + const events = JSON.parse(module); + const lastBlock = events && events.length ? events[events.length - 1].blockNumber : deployedBlock; + return { + events, + lastBlock + }; + } + return { + events: [], + lastBlock: deployedBlock + }; + } catch (err) { + console.log("Method loadCachedEvents has error"); + console.log(err); + return { + events: [], + lastBlock: deployedBlock + }; + } + }); +} + +var __async$7 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +class NodeDepositsService extends BaseDepositsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Tornado, + type, + amount, + currency, + deployedBlock, + fetchDataOptions, + cacheDirectory, + userDirectory + }) { + super({ + netId, + provider, + graphApi, + subgraphName, + Tornado, + type, + amount, + currency, + deployedBlock, + fetchDataOptions + }); + this.cacheDirectory = cacheDirectory; + this.userDirectory = userDirectory; + } + updateEventProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} +`); + } + } + } + updateTransactionProgress({ currentIndex, totalIndex }) { + if (totalIndex) { + console.log(`Fetched ${currentIndex} deposit txs of ${totalIndex}`); + } + } + updateBlockProgress({ currentIndex, totalIndex }) { + if (totalIndex) { + console.log(`Fetched ${currentIndex} withdrawal blocks of ${totalIndex}`); + } + } + updateGraphProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events from graph node count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} +`); + } + } + } + getEventsFromDB() { + return __async$7(this, null, function* () { + if (!this.userDirectory) { + console.log( + "Updating events for", + this.amount, + this.currency.toUpperCase(), + `${this.getType().toLowerCase()}s +` + ); + console.log(`savedEvents count - ${0}`); + console.log(`savedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const savedEvents = yield loadSavedEvents({ + name: this.getInstanceName(), + userDirectory: this.userDirectory, + deployedBlock: this.deployedBlock + }); + console.log("Updating events for", this.amount, this.currency.toUpperCase(), `${this.getType().toLowerCase()}s +`); + console.log(`savedEvents count - ${savedEvents.events.length}`); + console.log(`savedEvents lastBlock - ${savedEvents.lastBlock} +`); + return savedEvents; + }); + } + getEventsFromCache() { + return __async$7(this, null, function* () { + if (!this.cacheDirectory) { + console.log(`cachedEvents count - ${0}`); + console.log(`cachedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const cachedEvents = yield loadCachedEvents({ + name: this.getInstanceName(), + cacheDirectory: this.cacheDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`cachedEvents count - ${cachedEvents.events.length}`); + console.log(`cachedEvents lastBlock - ${cachedEvents.lastBlock} +`); + return cachedEvents; + }); + } + saveEvents(_0) { + return __async$7(this, arguments, function* ({ events, lastBlock }) { + const instanceName = this.getInstanceName(); + console.log("\ntotalEvents count - ", events.length); + console.log( + `totalEvents lastBlock - ${events[events.length - 1] ? events[events.length - 1].blockNumber : lastBlock} +` + ); + const eventTable = new Table(); + eventTable.push( + [{ colSpan: 2, content: `${this.getType()}s`, hAlign: "center" }], + ["Instance", `${this.netId} chain ${this.amount} ${this.currency.toUpperCase()}`], + ["Anonymity set", `${events.length} equal user ${this.getType().toLowerCase()}s`], + [{ colSpan: 2, content: `Latest ${this.getType().toLowerCase()}s` }], + ...events.slice(events.length - 10).reverse().map(({ timestamp }, index) => { + const eventIndex = events.length - index; + const eventTime = moment.unix(timestamp).fromNow(); + return [eventIndex, eventTime]; + }) + ); + console.log(eventTable.toString() + "\n"); + if (this.userDirectory) { + yield saveEvents({ + name: instanceName, + userDirectory: this.userDirectory, + events + }); + } + }); + } +} +class NodeEncryptedNotesService extends BaseEncryptedNotesService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Router, + deployedBlock, + fetchDataOptions, + cacheDirectory, + userDirectory + }) { + super({ + netId, + provider, + graphApi, + subgraphName, + Router, + deployedBlock, + fetchDataOptions + }); + this.cacheDirectory = cacheDirectory; + this.userDirectory = userDirectory; + } + updateEventProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} +`); + } + } + } + updateGraphProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events from graph node count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} +`); + } + } + } + getEventsFromDB() { + return __async$7(this, null, function* () { + if (!this.userDirectory) { + console.log(`Updating events for ${this.netId} chain encrypted events +`); + console.log(`savedEvents count - ${0}`); + console.log(`savedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const savedEvents = yield loadSavedEvents({ + name: this.getInstanceName(), + userDirectory: this.userDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`Updating events for ${this.netId} chain encrypted events +`); + console.log(`savedEvents count - ${savedEvents.events.length}`); + console.log(`savedEvents lastBlock - ${savedEvents.lastBlock} +`); + return savedEvents; + }); + } + getEventsFromCache() { + return __async$7(this, null, function* () { + if (!this.cacheDirectory) { + console.log(`cachedEvents count - ${0}`); + console.log(`cachedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const cachedEvents = yield loadCachedEvents({ + name: this.getInstanceName(), + cacheDirectory: this.cacheDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`cachedEvents count - ${cachedEvents.events.length}`); + console.log(`cachedEvents lastBlock - ${cachedEvents.lastBlock} +`); + return cachedEvents; + }); + } + saveEvents(_0) { + return __async$7(this, arguments, function* ({ events, lastBlock }) { + const instanceName = this.getInstanceName(); + console.log("\ntotalEvents count - ", events.length); + console.log( + `totalEvents lastBlock - ${events[events.length - 1] ? events[events.length - 1].blockNumber : lastBlock} +` + ); + const eventTable = new Table(); + eventTable.push( + [{ colSpan: 2, content: "Encrypted Notes", hAlign: "center" }], + ["Network", `${this.netId} chain`], + ["Events", `${events.length} events`], + [{ colSpan: 2, content: "Latest events" }], + ...events.slice(events.length - 10).reverse().map(({ blockNumber }, index) => { + const eventIndex = events.length - index; + return [eventIndex, blockNumber]; + }) + ); + console.log(eventTable.toString() + "\n"); + if (this.userDirectory) { + yield saveEvents({ + name: instanceName, + userDirectory: this.userDirectory, + events + }); + } + }); + } +} +class NodeGovernanceService extends BaseGovernanceService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Governance, + deployedBlock, + fetchDataOptions, + cacheDirectory, + userDirectory + }) { + super({ + netId, + provider, + graphApi, + subgraphName, + Governance, + deployedBlock, + fetchDataOptions + }); + this.cacheDirectory = cacheDirectory; + this.userDirectory = userDirectory; + } + updateEventProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} +`); + } + } + } + updateGraphProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events from graph node count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} +`); + } + } + } + updateTransactionProgress({ currentIndex, totalIndex }) { + if (totalIndex) { + console.log(`Fetched ${currentIndex} governance txs of ${totalIndex}`); + } + } + getEventsFromDB() { + return __async$7(this, null, function* () { + if (!this.userDirectory) { + console.log(`Updating events for ${this.netId} chain governance events +`); + console.log(`savedEvents count - ${0}`); + console.log(`savedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const savedEvents = yield loadSavedEvents({ + name: this.getInstanceName(), + userDirectory: this.userDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`Updating events for ${this.netId} chain governance events +`); + console.log(`savedEvents count - ${savedEvents.events.length}`); + console.log(`savedEvents lastBlock - ${savedEvents.lastBlock} +`); + return savedEvents; + }); + } + getEventsFromCache() { + return __async$7(this, null, function* () { + if (!this.cacheDirectory) { + console.log(`cachedEvents count - ${0}`); + console.log(`cachedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const cachedEvents = yield loadCachedEvents({ + name: this.getInstanceName(), + cacheDirectory: this.cacheDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`cachedEvents count - ${cachedEvents.events.length}`); + console.log(`cachedEvents lastBlock - ${cachedEvents.lastBlock} +`); + return cachedEvents; + }); + } + saveEvents(_0) { + return __async$7(this, arguments, function* ({ events, lastBlock }) { + const instanceName = this.getInstanceName(); + console.log("\ntotalEvents count - ", events.length); + console.log( + `totalEvents lastBlock - ${events[events.length - 1] ? events[events.length - 1].blockNumber : lastBlock} +` + ); + const eventTable = new Table(); + eventTable.push( + [{ colSpan: 2, content: "Governance Events", hAlign: "center" }], + ["Network", `${this.netId} chain`], + ["Events", `${events.length} events`], + [{ colSpan: 2, content: "Latest events" }], + ...events.slice(events.length - 10).reverse().map(({ blockNumber }, index) => { + const eventIndex = events.length - index; + return [eventIndex, blockNumber]; + }) + ); + console.log(eventTable.toString() + "\n"); + if (this.userDirectory) { + yield saveEvents({ + name: instanceName, + userDirectory: this.userDirectory, + events + }); + } + }); + } +} +class NodeRegistryService extends BaseRegistryService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + RelayerRegistry, + deployedBlock, + fetchDataOptions, + cacheDirectory, + userDirectory + }) { + super({ + netId, + provider, + graphApi, + subgraphName, + RelayerRegistry, + deployedBlock, + fetchDataOptions + }); + this.cacheDirectory = cacheDirectory; + this.userDirectory = userDirectory; + } + updateEventProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} +`); + } + } + } + updateGraphProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events from graph node count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} +`); + } + } + } + getEventsFromDB() { + return __async$7(this, null, function* () { + if (!this.userDirectory) { + console.log(`Updating events for ${this.netId} chain registry events +`); + console.log(`savedEvents count - ${0}`); + console.log(`savedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const savedEvents = yield loadSavedEvents({ + name: this.getInstanceName(), + userDirectory: this.userDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`Updating events for ${this.netId} chain registry events +`); + console.log(`savedEvents count - ${savedEvents.events.length}`); + console.log(`savedEvents lastBlock - ${savedEvents.lastBlock} +`); + return savedEvents; + }); + } + getEventsFromCache() { + return __async$7(this, null, function* () { + if (!this.cacheDirectory) { + console.log(`cachedEvents count - ${0}`); + console.log(`cachedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const cachedEvents = yield loadCachedEvents({ + name: this.getInstanceName(), + cacheDirectory: this.cacheDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`cachedEvents count - ${cachedEvents.events.length}`); + console.log(`cachedEvents lastBlock - ${cachedEvents.lastBlock} +`); + return cachedEvents; + }); + } + saveEvents(_0) { + return __async$7(this, arguments, function* ({ events, lastBlock }) { + const instanceName = this.getInstanceName(); + console.log("\ntotalEvents count - ", events.length); + console.log( + `totalEvents lastBlock - ${events[events.length - 1] ? events[events.length - 1].blockNumber : lastBlock} +` + ); + const eventTable = new Table(); + eventTable.push( + [{ colSpan: 2, content: "Registered Relayers", hAlign: "center" }], + ["Network", `${this.netId} chain`], + ["Events", `${events.length} events`], + [{ colSpan: 2, content: "Latest events" }], + ...events.slice(events.length - 10).reverse().map(({ blockNumber }, index) => { + const eventIndex = events.length - index; + return [eventIndex, blockNumber]; + }) + ); + console.log(eventTable.toString() + "\n"); + if (this.userDirectory) { + yield saveEvents({ + name: instanceName, + userDirectory: this.userDirectory, + events + }); + } + }); + } +} + +const addressType = { type: "string", pattern: "^0x[a-fA-F0-9]{40}$" }; +const bnType = { type: "string", BN: true }; +const statusSchema = { + type: "object", + properties: { + rewardAccount: addressType, + gasPrices: { + type: "object", + properties: { + fast: { type: "number" }, + additionalProperties: { type: "number" } + }, + required: ["fast"] + }, + netId: { type: "integer" }, + tornadoServiceFee: { type: "number", maximum: 20, minimum: 0 }, + latestBlock: { type: "number" }, + version: { type: "string" }, + health: { + type: "object", + properties: { + status: { const: "true" }, + error: { type: "string" } + }, + required: ["status"] + }, + currentQueue: { type: "number" } + }, + required: ["rewardAccount", "instances", "netId", "tornadoServiceFee", "version", "health"] +}; +function getStatusSchema(netId, config) { + const { tokens, optionalTokens = [], nativeCurrency } = config; + const schema = JSON.parse(JSON.stringify(statusSchema)); + const instances = Object.keys(tokens).reduce( + (acc, token) => { + const { instanceAddress, tokenAddress, symbol, decimals, optionalInstances = [] } = tokens[token]; + const amounts = Object.keys(instanceAddress); + const instanceProperties = { + type: "object", + properties: { + instanceAddress: { + type: "object", + properties: amounts.reduce((acc2, cur) => { + acc2[cur] = addressType; + return acc2; + }, {}), + required: amounts.filter((amount) => !optionalInstances.includes(amount)) + }, + decimals: { enum: [decimals] } + }, + required: ["instanceAddress", "decimals"].concat( + tokenAddress ? ["tokenAddress"] : [], + symbol ? ["symbol"] : [] + ) + }; + if (tokenAddress) { + instanceProperties.properties.tokenAddress = addressType; + } + if (symbol) { + instanceProperties.properties.symbol = { enum: [symbol] }; + } + acc.properties[token] = instanceProperties; + if (!optionalTokens.includes(token)) { + acc.required.push(token); + } + return acc; + }, + { + type: "object", + properties: {}, + required: [] + } + ); + schema.properties.instances = instances; + if (Number(netId) === 1) { + const _tokens = Object.keys(tokens).filter((t) => t !== nativeCurrency); + const ethPrices = { + type: "object", + properties: _tokens.reduce((acc, token) => { + acc[token] = bnType; + return acc; + }, {}) + // required: _tokens + }; + schema.properties.ethPrices = ethPrices; + } + return schema; +} + +const jobsSchema = { + type: "object", + properties: { + error: { type: "string" }, + id: { type: "string" }, + type: { type: "string" }, + status: { type: "string" }, + contract: { type: "string" }, + proof: { type: "string" }, + args: { + type: "array", + items: { type: "string" } + }, + txHash: { type: "string" }, + confirmations: { type: "number" }, + failedReason: { type: "string" } + }, + required: ["id", "status"] +}; + +const ajv = new Ajv({ allErrors: true }); +ajv.addKeyword({ + keyword: "BN", + // eslint-disable-next-line @typescript-eslint/no-explicit-any + validate: (schema, data) => { + try { + BigInt(data); + return true; + } catch (e) { + return false; + } + }, + errors: true +}); + +var __async$6 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +class Pedersen { + constructor() { + this.pedersenPromise = this.initPedersen(); + } + initPedersen() { + return __async$6(this, null, function* () { + this.pedersenHash = yield circomlibjs.buildPedersenHash(); + this.babyJub = this.pedersenHash.babyJub; + }); + } + unpackPoint(buffer) { + return __async$6(this, null, function* () { + var _a, _b; + yield this.pedersenPromise; + return (_b = this.babyJub) == null ? void 0 : _b.unpackPoint((_a = this.pedersenHash) == null ? void 0 : _a.hash(buffer)); + }); + } + toStringBuffer(buffer) { + var _a; + return (_a = this.babyJub) == null ? void 0 : _a.F.toString(buffer); + } +} +const pedersen = new Pedersen(); +function buffPedersenHash(buffer) { + return __async$6(this, null, function* () { + const [hash] = yield pedersen.unpackPoint(buffer); + return pedersen.toStringBuffer(hash); + }); +} + +var __async$5 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +function createDeposit(_0) { + return __async$5(this, arguments, function* ({ nullifier, secret }) { + const preimage = new Uint8Array([...leInt2Buff(nullifier), ...leInt2Buff(secret)]); + const noteHex = toFixedHex(bytesToBN(preimage), 62); + const commitment = BigInt(yield buffPedersenHash(preimage)); + const commitmentHex = toFixedHex(commitment); + const nullifierHash = BigInt(yield buffPedersenHash(leInt2Buff(nullifier))); + const nullifierHex = toFixedHex(nullifierHash); + return { + preimage, + noteHex, + commitment, + commitmentHex, + nullifierHash, + nullifierHex + }; + }); +} +class Deposit { + constructor({ + currency, + amount, + netId, + nullifier, + secret, + note, + noteHex, + invoice, + commitmentHex, + nullifierHex + }) { + this.currency = currency; + this.amount = amount; + this.netId = netId; + this.nullifier = nullifier; + this.secret = secret; + this.note = note; + this.noteHex = noteHex; + this.invoice = invoice; + this.commitmentHex = commitmentHex; + this.nullifierHex = nullifierHex; + } + toString() { + return JSON.stringify( + { + currency: this.currency, + amount: this.amount, + netId: this.netId, + nullifier: this.nullifier, + secret: this.secret, + note: this.note, + noteHex: this.noteHex, + invoice: this.invoice, + commitmentHex: this.commitmentHex, + nullifierHex: this.nullifierHex + }, + null, + 2 + ); + } + static createNote(_0) { + return __async$5(this, arguments, function* ({ currency, amount, netId, nullifier, secret }) { + if (!nullifier) { + nullifier = rBigInt(31); + } + if (!secret) { + secret = rBigInt(31); + } + const depositObject = yield createDeposit({ + nullifier, + secret + }); + const newDeposit = new Deposit({ + currency: currency.toLowerCase(), + amount, + netId: Number(netId), + note: `tornado-${currency.toLowerCase()}-${amount}-${netId}-${depositObject.noteHex}`, + noteHex: depositObject.noteHex, + invoice: `tornadoInvoice-${currency.toLowerCase()}-${amount}-${netId}-${depositObject.commitmentHex}`, + nullifier, + secret, + commitmentHex: depositObject.commitmentHex, + nullifierHex: depositObject.nullifierHex + }); + return newDeposit; + }); + } + static parseNote(noteString) { + return __async$5(this, null, function* () { + const noteRegex = new RegExp("tornado-(?\\w+)-(?[\\d.]+)-(?\\d+)-0x(?[0-9a-fA-F]{124})", "g"); + const match = noteRegex.exec(noteString); + if (!match) { + throw new Error("The note has invalid format"); + } + const matchGroup = match == null ? void 0 : match.groups; + const currency = matchGroup.currency.toLowerCase(); + const amount = matchGroup.amount; + const netId = Number(matchGroup.netId); + const bytes = bnToBytes("0x" + matchGroup.note); + const nullifier = BigInt(leBuff2Int(bytes.slice(0, 31)).toString()); + const secret = BigInt(leBuff2Int(bytes.slice(31, 62)).toString()); + const depositObject = yield createDeposit({ nullifier, secret }); + const invoice = `tornadoInvoice-${currency}-${amount}-${netId}-${depositObject.commitmentHex}`; + const newDeposit = new Deposit({ + currency, + amount, + netId, + note: noteString, + noteHex: depositObject.noteHex, + invoice, + nullifier, + secret, + commitmentHex: depositObject.commitmentHex, + nullifierHex: depositObject.nullifierHex + }); + return newDeposit; + }); + } +} +class Invoice { + constructor(invoiceString) { + const invoiceRegex = new RegExp("tornadoInvoice-(?\\w+)-(?[\\d.]+)-(?\\d+)-0x(?[0-9a-fA-F]{64})", "g"); + const match = invoiceRegex.exec(invoiceString); + if (!match) { + throw new Error("The note has invalid format"); + } + const matchGroup = match == null ? void 0 : match.groups; + const currency = matchGroup.currency.toLowerCase(); + const amount = matchGroup.amount; + const netId = Number(matchGroup.netId); + this.currency = currency; + this.amount = amount; + this.netId = netId; + this.commitment = "0x" + matchGroup.commitment; + this.invoice = invoiceString; + } + toString() { + return JSON.stringify( + { + currency: this.currency, + amount: this.amount, + netId: this.netId, + commitment: this.commitment, + invoice: this.invoice + }, + null, + 2 + ); + } +} + +const DUMMY_ADDRESS = "0x1111111111111111111111111111111111111111"; +const DUMMY_NONCE = "0x1111111111111111111111111111111111111111111111111111111111111111"; +const DUMMY_WITHDRAW_DATA = "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"; +function convertETHToTokenAmount(amountInWei, tokenPriceInWei, tokenDecimals = 18) { + const tokenDecimalsMultiplier = BigInt(10 ** Number(tokenDecimals)); + return BigInt(amountInWei) * tokenDecimalsMultiplier / BigInt(tokenPriceInWei); +} +class TornadoFeeOracle { + constructor(ovmGasPriceOracle) { + if (ovmGasPriceOracle) { + this.ovmGasPriceOracle = ovmGasPriceOracle; + } + } + /** + * Calculate L1 fee for op-stack chains + * + * This is required since relayers would pay the full transaction fees for users + */ + fetchL1OptimismFee(tx) { + if (!this.ovmGasPriceOracle) { + return new Promise((resolve) => resolve(BigInt(0))); + } + if (!tx) { + tx = { + type: 0, + gasLimit: 1e6, + nonce: Number(DUMMY_NONCE), + data: DUMMY_WITHDRAW_DATA, + gasPrice: ethers.parseUnits("1", "gwei"), + from: DUMMY_ADDRESS, + to: DUMMY_ADDRESS + }; + } + return this.ovmGasPriceOracle.getL1Fee.staticCall(ethers.Transaction.from(tx).unsignedSerialized); + } + /** + * We don't need to distinguish default refunds by tokens since most users interact with other defi protocols after withdrawal + * So we default with 1M gas which is enough for two or three swaps + * Using 30 gwei for default but it is recommended to supply cached gasPrice value from the UI + */ + defaultEthRefund(gasPrice, gasLimit) { + return (gasPrice ? BigInt(gasPrice) : ethers.parseUnits("30", "gwei")) * BigInt(gasLimit || 1e6); + } + /** + * Calculates token amount for required ethRefund purchases required to calculate fees + */ + calculateTokenAmount(ethRefund, tokenPriceInEth, tokenDecimals) { + return convertETHToTokenAmount(ethRefund, tokenPriceInEth, tokenDecimals); + } + /** + * Warning: For tokens you need to check if the fees are above denomination + * (Usually happens for small denomination pool or if the gas price is high) + */ + calculateRelayerFee({ + gasPrice, + gasLimit = 6e5, + l1Fee = 0, + denomination, + ethRefund = BigInt(0), + tokenPriceInWei, + tokenDecimals = 18, + relayerFeePercent = 0.33, + isEth = true, + premiumPercent = 20 + }) { + const gasCosts = BigInt(gasPrice) * BigInt(gasLimit) + BigInt(l1Fee); + const relayerFee = BigInt(denomination) * BigInt(Math.floor(1e4 * relayerFeePercent)) / BigInt(1e4 * 100); + if (isEth) { + return (gasCosts + relayerFee) * BigInt(premiumPercent ? 100 + premiumPercent : 100) / BigInt(100); + } + const feeInEth = gasCosts + BigInt(ethRefund); + return (convertETHToTokenAmount(feeInEth, tokenPriceInWei, tokenDecimals) + relayerFee) * BigInt(premiumPercent ? 100 + premiumPercent : 100) / BigInt(100); + } +} + +var __async$4 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +class Mimc { + constructor() { + this.mimcPromise = this.initMimc(); + } + initMimc() { + return __async$4(this, null, function* () { + this.sponge = yield circomlibjs.buildMimcSponge(); + this.hash = (left, right) => { + var _a, _b; + return (_b = this.sponge) == null ? void 0 : _b.F.toString((_a = this.sponge) == null ? void 0 : _a.multiHash([BigInt(left), BigInt(right)])); + }; + }); + } + getHash() { + return __async$4(this, null, function* () { + yield this.mimcPromise; + return { + sponge: this.sponge, + hash: this.hash + }; + }); + } +} +const mimc = new Mimc(); + +var __async$3 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +class MerkleTreeService { + constructor({ + netId, + amount, + currency, + Tornado, + commitment, + merkleTreeHeight = 20, + emptyElement = "21663839004416932945382355908790599225266501822907911457504978515578255421292", + merkleWorkerPath + }) { + const instanceName = `${netId}_${currency}_${amount}`; + this.currency = currency; + this.amount = amount; + this.netId = Number(netId); + this.Tornado = Tornado; + this.instanceName = instanceName; + this.commitment = commitment; + this.merkleTreeHeight = merkleTreeHeight; + this.emptyElement = emptyElement; + this.merkleWorkerPath = merkleWorkerPath; + } + createTree(_0) { + return __async$3(this, arguments, function* ({ events }) { + const { hash: hashFunction } = yield mimc.getHash(); + if (this.merkleWorkerPath) { + console.log("Using merkleWorker\n"); + try { + if (isNode) { + const merkleWorkerPromise = new Promise((resolve, reject) => { + const worker = new worker_threads.Worker(this.merkleWorkerPath, { + workerData: { + merkleTreeHeight: this.merkleTreeHeight, + elements: events, + zeroElement: this.emptyElement + } + }); + worker.on("message", resolve); + worker.on("error", reject); + worker.on("exit", (code) => { + if (code !== 0) { + reject(new Error(`Worker stopped with exit code ${code}`)); + } + }); + }); + return fixedMerkleTree.MerkleTree.deserialize(JSON.parse(yield merkleWorkerPromise), hashFunction); + } else { + const merkleWorkerPromise = new Promise((resolve, reject) => { + const worker = new Worker(this.merkleWorkerPath); + worker.onmessage = (e) => { + resolve(e.data); + }; + worker.onerror = (e) => { + reject(e); + }; + worker.postMessage({ + merkleTreeHeight: this.merkleTreeHeight, + elements: events, + zeroElement: this.emptyElement + }); + }); + return fixedMerkleTree.MerkleTree.deserialize(JSON.parse(yield merkleWorkerPromise), hashFunction); + } + } catch (err) { + console.log("merkleWorker failed, falling back to synchronous merkle tree"); + console.log(err); + } + } + return new fixedMerkleTree.MerkleTree(this.merkleTreeHeight, events, { + zeroElement: this.emptyElement, + hashFunction + }); + }); + } + verifyTree(_0) { + return __async$3(this, arguments, function* ({ events }) { + console.log( + ` +Creating deposit tree for ${this.netId} ${this.amount} ${this.currency.toUpperCase()} would take a while +` + ); + console.time("Created tree in"); + const tree = yield this.createTree({ events: events.map(({ commitment }) => BigInt(commitment).toString()) }); + console.timeEnd("Created tree in"); + console.log(""); + const isKnownRoot = yield this.Tornado.isKnownRoot(toFixedHex(BigInt(tree.root))); + if (!isKnownRoot) { + const errMsg = `Deposit Event ${this.netId} ${this.amount} ${this.currency} is invalid`; + throw new Error(errMsg); + } + return tree; + }); + } +} + +const blockSyncInterval = 1e4; +const enabledChains = ["1", "10", "56", "100", "137", "42161", "43114", "11155111"]; +const theGraph = { + name: "Hosted Graph", + url: "https://api.thegraph.com" +}; +const tornado = { + name: "Tornado Subgraphs", + url: "https://tornadocash-rpc.com" +}; +const networkConfig = { + netId1: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 80, + fast: 50, + standard: 25, + low: 8 + }, + nativeCurrency: "eth", + currencyName: "ETH", + explorerUrl: { + tx: "https://etherscan.io/tx/", + address: "https://etherscan.io/address/", + block: "https://etherscan.io/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Ethereum Mainnet", + deployedBlock: 9116966, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com" + }, + chainnodes: { + name: "Tornado RPC", + url: "https://mainnet.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + mevblockerRPC: { + name: "MevblockerRPC", + url: "https://rpc.mevblocker.io" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/ethereum-mainnet" + }, + noderealRPC: { + name: "NodeReal RPC", + url: "https://eth-mainnet.nodereal.io/v1/1659dfb40aa24bbb8153a677b98064d7" + }, + notadegenRPC: { + name: "NotADegen RPC", + url: "https://rpc.notadegen.com/eth" + }, + keydonixRPC: { + name: "Keydonix RPC", + url: "https://ethereum.keydonix.com/v1/mainnet" + }, + oneRPC: { + name: "1RPC", + url: "https://1rpc.io/eth" + } + }, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + routerContract: "0xd90e2f925DA726b50C4Ed8D0Fb90Ad053324F31b", + registryContract: "0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2", + echoContract: "0x9B27DD5Bb15d42DC224FCD0B7caEbBe16161Df42", + aggregatorContract: "0xE8F47A78A6D52D317D0D2FFFac56739fE14D1b49", + reverseRecordsContract: "0x3671aE578E63FdF66ad4F3E12CC0c0d71Ac7510C", + tornadoSubgraph: "tornadocash/mainnet-tornado-subgraph", + registrySubgraph: "tornadocash/tornado-relayer-registry", + subgraphs: { + tornado, + theGraph + }, + tokens: { + eth: { + instanceAddress: { + "0.1": "0x12D66f87A04A9E220743712cE6d9bB1B5616B8Fc", + "1": "0x47CE0C6eD5B0Ce3d3A51fdb1C52DC66a7c3c2936", + "10": "0x910Cbd523D972eb0a6f4cAe4618aD62622b39DbF", + "100": "0xA160cdAB225685dA1d56aa342Ad8841c3b53f291" + }, + symbol: "ETH", + decimals: 18 + }, + dai: { + instanceAddress: { + "100": "0xD4B88Df4D29F5CedD6857912842cff3b20C8Cfa3", + "1000": "0xFD8610d20aA15b7B2E3Be39B396a1bC3516c7144", + "10000": "0x07687e702b410Fa43f4cB4Af7FA097918ffD2730", + "100000": "0x23773E65ed146A459791799d01336DB287f25334" + }, + tokenAddress: "0x6B175474E89094C44Da98b954EedeAC495271d0F", + tokenGasLimit: 7e4, + symbol: "DAI", + decimals: 18, + gasLimit: 7e5 + }, + cdai: { + instanceAddress: { + "5000": "0x22aaA7720ddd5388A3c0A3333430953C68f1849b", + "50000": "0x03893a7c7463AE47D46bc7f091665f1893656003", + "500000": "0x2717c5e28cf931547B621a5dddb772Ab6A35B701", + "5000000": "0xD21be7248e0197Ee08E0c20D4a96DEBdaC3D20Af" + }, + tokenAddress: "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643", + tokenGasLimit: 2e5, + symbol: "cDAI", + decimals: 8, + gasLimit: 7e5 + }, + usdc: { + instanceAddress: { + "100": "0xd96f2B1c14Db8458374d9Aca76E26c3D18364307", + "1000": "0x4736dCf1b7A3d580672CcE6E7c65cd5cc9cFBa9D" + }, + tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", + tokenGasLimit: 7e4, + symbol: "USDC", + decimals: 6, + gasLimit: 7e5 + }, + usdt: { + instanceAddress: { + "100": "0x169AD27A470D064DEDE56a2D3ff727986b15D52B", + "1000": "0x0836222F2B2B24A3F36f98668Ed8F0B38D1a872f" + }, + tokenAddress: "0xdAC17F958D2ee523a2206206994597C13D831ec7", + tokenGasLimit: 7e4, + symbol: "USDT", + decimals: 6, + gasLimit: 7e5 + }, + wbtc: { + instanceAddress: { + "0.1": "0x178169B423a011fff22B9e3F3abeA13414dDD0F1", + "1": "0x610B717796ad172B316836AC95a2ffad065CeaB4", + "10": "0xbB93e510BbCD0B7beb5A853875f9eC60275CF498" + }, + tokenAddress: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", + tokenGasLimit: 7e4, + symbol: "WBTC", + decimals: 8, + gasLimit: 7e5 + } + }, + ensSubdomainKey: "mainnet-tornado", + pollInterval: 15, + constants: { + GOVERNANCE_BLOCK: 11474695, + NOTE_ACCOUNT_BLOCK: 11842486, + ENCRYPTED_NOTES_BLOCK: 14248730, + REGISTRY_BLOCK: 14173129, + MINING_BLOCK_TIME: 15 + }, + "torn.contract.tornadocash.eth": "0x77777FeDdddFfC19Ff86DB637967013e6C6A116C", + "governance.contract.tornadocash.eth": "0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce", + "tornado-router.contract.tornadocash.eth": "0xd90e2f925DA726b50C4Ed8D0Fb90Ad053324F31b", + "staking-rewards.contract.tornadocash.eth": "0x5B3f656C80E8ddb9ec01Dd9018815576E9238c29" + }, + netId56: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 5, + fast: 5, + standard: 5, + low: 5 + }, + nativeCurrency: "bnb", + currencyName: "BNB", + explorerUrl: { + tx: "https://bscscan.com/tx/", + address: "https://bscscan.com/address/", + block: "https://bscscan.com/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Binance Smart Chain", + deployedBlock: 8158799, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + tornadoSubgraph: "tornadocash/bsc-tornado-subgraph", + subgraphs: { + tornado, + theGraph + }, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com/bsc" + }, + chainnodes: { + name: "Tornado RPC", + url: "https://bsc-mainnet.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/bsc-mainnet" + }, + noderealRPC: { + name: "NodeReal RPC", + url: "https://bsc-mainnet.nodereal.io/v1/64a9df0874fb4a93b9d0a3849de012d3" + }, + oneRPC: { + name: "1RPC", + url: "https://1rpc.io/bnb" + } + }, + tokens: { + bnb: { + instanceAddress: { + "0.1": "0x84443CFd09A48AF6eF360C6976C5392aC5023a1F", + "1": "0xd47438C816c9E7f2E2888E060936a499Af9582b3", + "10": "0x330bdFADE01eE9bF63C209Ee33102DD334618e0a", + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD" + }, + symbol: "BNB", + decimals: 18 + } + }, + ensSubdomainKey: "bsc-tornado", + pollInterval: 10, + constants: { + NOTE_ACCOUNT_BLOCK: 8159269, + ENCRYPTED_NOTES_BLOCK: 8159269 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId137: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 100, + fast: 75, + standard: 50, + low: 30 + }, + nativeCurrency: "matic", + currencyName: "MATIC", + explorerUrl: { + tx: "https://polygonscan.com/tx/", + address: "https://polygonscan.com/address/", + block: "https://polygonscan.com/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Polygon (Matic) Network", + deployedBlock: 16257962, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + gasPriceOracleContract: "0xF81A8D8D3581985D3969fe53bFA67074aDFa8F3C", + tornadoSubgraph: "tornadocash/matic-tornado-subgraph", + subgraphs: { + tornado, + theGraph + }, + rpcUrls: { + chainnodes: { + name: "Tornado RPC", + url: "https://polygon-mainnet.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/polygon-mainnet" + }, + oneRpc: { + name: "1RPC", + url: "https://1rpc.io/matic" + } + }, + tokens: { + matic: { + instanceAddress: { + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD", + "1000": "0xdf231d99Ff8b6c6CBF4E9B9a945CBAcEF9339178", + "10000": "0xaf4c0B70B2Ea9FB7487C7CbB37aDa259579fe040", + "100000": "0xa5C2254e4253490C54cef0a4347fddb8f75A4998" + }, + symbol: "MATIC", + decimals: 18 + } + }, + ensSubdomainKey: "polygon-tornado", + pollInterval: 10, + constants: { + NOTE_ACCOUNT_BLOCK: 16257996, + ENCRYPTED_NOTES_BLOCK: 16257996 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId10: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 1e-3, + fast: 1e-3, + standard: 1e-3, + low: 1e-3 + }, + nativeCurrency: "eth", + currencyName: "ETH", + explorerUrl: { + tx: "https://optimistic.etherscan.io/tx/", + address: "https://optimistic.etherscan.io/address/", + block: "https://optimistic.etherscan.io/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Optimism", + deployedBlock: 2243689, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + ovmGasPriceOracleContract: "0x420000000000000000000000000000000000000F", + tornadoSubgraph: "tornadocash/optimism-tornado-subgraph", + subgraphs: { + tornado, + theGraph + }, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com/op" + }, + chainnodes: { + name: "Tornado RPC", + url: "https://optimism-mainnet.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + optimism: { + name: "Optimism RPC", + url: "https://mainnet.optimism.io" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/optimism-mainnet" + }, + oneRpc: { + name: "1RPC", + url: "https://1rpc.io/op" + } + }, + tokens: { + eth: { + instanceAddress: { + "0.1": "0x84443CFd09A48AF6eF360C6976C5392aC5023a1F", + "1": "0xd47438C816c9E7f2E2888E060936a499Af9582b3", + "10": "0x330bdFADE01eE9bF63C209Ee33102DD334618e0a", + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD" + }, + symbol: "ETH", + decimals: 18 + } + }, + ensSubdomainKey: "optimism-tornado", + pollInterval: 15, + constants: { + NOTE_ACCOUNT_BLOCK: 2243694, + ENCRYPTED_NOTES_BLOCK: 2243694 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId42161: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 4, + fast: 3, + standard: 2.52, + low: 2.29 + }, + nativeCurrency: "eth", + currencyName: "ETH", + explorerUrl: { + tx: "https://arbiscan.io/tx/", + address: "https://arbiscan.io/address/", + block: "https://arbiscan.io/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Arbitrum One", + deployedBlock: 3430648, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + tornadoSubgraph: "tornadocash/arbitrum-tornado-subgraph", + subgraphs: { + tornado, + theGraph + }, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com/arbitrum" + }, + chainnodes: { + name: "Tornado RPC", + url: "https://arbitrum-one.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + arbitrum: { + name: "Arbitrum RPC", + url: "https://arb1.arbitrum.io/rpc" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/arbitrum-one" + }, + oneRpc: { + name: "1rpc", + url: "https://1rpc.io/arb" + } + }, + tokens: { + eth: { + instanceAddress: { + "0.1": "0x84443CFd09A48AF6eF360C6976C5392aC5023a1F", + "1": "0xd47438C816c9E7f2E2888E060936a499Af9582b3", + "10": "0x330bdFADE01eE9bF63C209Ee33102DD334618e0a", + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD" + }, + symbol: "ETH", + decimals: 18 + } + }, + ensSubdomainKey: "arbitrum-tornado", + pollInterval: 15, + constants: { + NOTE_ACCOUNT_BLOCK: 3430605, + ENCRYPTED_NOTES_BLOCK: 3430605 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId100: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 6, + fast: 5, + standard: 4, + low: 1 + }, + nativeCurrency: "xdai", + currencyName: "xDAI", + explorerUrl: { + tx: "https://blockscout.com/xdai/mainnet/tx/", + address: "https://blockscout.com/xdai/mainnet/address/", + block: "https://blockscout.com/xdai/mainnet/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Gnosis Chain", + deployedBlock: 17754561, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + tornadoSubgraph: "tornadocash/xdai-tornado-subgraph", + subgraphs: { + tornado, + theGraph + }, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com/gnosis" + }, + chainnodes: { + name: "Tornado RPC", + url: "https://gnosis-mainnet.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + gnosis: { + name: "Gnosis RPC", + url: "https://rpc.gnosischain.com" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/arbitrum-one" + }, + blockPi: { + name: "BlockPi", + url: "https://gnosis.blockpi.network/v1/rpc/public" + } + }, + tokens: { + xdai: { + instanceAddress: { + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD", + "1000": "0xdf231d99Ff8b6c6CBF4E9B9a945CBAcEF9339178", + "10000": "0xaf4c0B70B2Ea9FB7487C7CbB37aDa259579fe040", + "100000": "0xa5C2254e4253490C54cef0a4347fddb8f75A4998" + }, + symbol: "xDAI", + decimals: 18 + } + }, + ensSubdomainKey: "gnosis-tornado", + pollInterval: 15, + constants: { + NOTE_ACCOUNT_BLOCK: 17754564, + ENCRYPTED_NOTES_BLOCK: 17754564 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId43114: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 225, + fast: 35, + standard: 25, + low: 25 + }, + nativeCurrency: "avax", + currencyName: "AVAX", + explorerUrl: { + tx: "https://snowtrace.io/tx/", + address: "https://snowtrace.io/address/", + block: "https://snowtrace.io/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Avalanche Mainnet", + deployedBlock: 4429818, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + tornadoSubgraph: "tornadocash/avalanche-tornado-subgraph", + subgraphs: { + theGraph + }, + rpcUrls: { + oneRPC: { + name: "OneRPC", + url: "https://1rpc.io/avax/c" + }, + avalancheRPC: { + name: "Avalanche RPC", + url: "https://api.avax.network/ext/bc/C/rpc" + }, + meowRPC: { + name: "Meow RPC", + url: "https://avax.meowrpc.com" + } + }, + tokens: { + avax: { + instanceAddress: { + "10": "0x330bdFADE01eE9bF63C209Ee33102DD334618e0a", + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD", + "500": "0xaf8d1839c3c67cf571aa74B5c12398d4901147B3" + }, + symbol: "AVAX", + decimals: 18 + } + }, + ensSubdomainKey: "avalanche-tornado", + pollInterval: 10, + constants: { + NOTE_ACCOUNT_BLOCK: 4429813, + ENCRYPTED_NOTES_BLOCK: 4429813 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId11155111: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 2, + fast: 2, + standard: 2, + low: 2 + }, + nativeCurrency: "eth", + currencyName: "SepoliaETH", + explorerUrl: { + tx: "https://sepolia.etherscan.io/tx/", + address: "https://sepolia.etherscan.io/address/", + block: "https://sepolia.etherscan.io/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Ethereum Sepolia", + deployedBlock: 5594395, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + routerContract: "0x1572AFE6949fdF51Cb3E0856216670ae9Ee160Ee", + registryContract: "0x1428e5d2356b13778A13108b10c440C83011dfB8", + echoContract: "0xcDD1fc3F5ac2782D83449d3AbE80D6b7B273B0e5", + aggregatorContract: "0x4088712AC9fad39ea133cdb9130E465d235e9642", + reverseRecordsContract: "0xEc29700C0283e5Be64AcdFe8077d6cC95dE23C23", + tornadoSubgraph: "tornadocash/sepolia-tornado-subgraph", + subgraphs: { + tornado + }, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com/sepolia" + }, + sepolia: { + name: "Sepolia RPC", + url: "https://rpc.sepolia.org" + }, + chainnodes: { + name: "Chainnodes RPC", + url: "https://sepolia.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + } + }, + tokens: { + eth: { + instanceAddress: { + "0.1": "0x8C4A04d872a6C1BE37964A21ba3a138525dFF50b", + "1": "0x8cc930096B4Df705A007c4A039BDFA1320Ed2508", + "10": "0x8D10d506D29Fc62ABb8A290B99F66dB27Fc43585", + "100": "0x44c5C92ed73dB43888210264f0C8b36Fd68D8379" + }, + symbol: "ETH", + decimals: 18 + }, + dai: { + instanceAddress: { + "100": "0x6921fd1a97441dd603a997ED6DDF388658daf754", + "1000": "0x50a637770F5d161999420F7d70d888DE47207145", + "10000": "0xecD649870407cD43923A816Cc6334a5bdf113621", + "100000": "0x73B4BD04bF83206B6e979BE2507098F92EDf4F90" + }, + tokenAddress: "0xFF34B3d4Aee8ddCd6F9AFFFB6Fe49bD371b8a357", + tokenGasLimit: 7e4, + symbol: "DAI", + decimals: 18, + gasLimit: 7e5 + } + }, + ensSubdomainKey: "sepolia-tornado", + pollInterval: 15, + constants: { + GOVERNANCE_BLOCK: 5594395, + NOTE_ACCOUNT_BLOCK: 5594395, + ENCRYPTED_NOTES_BLOCK: 5594395, + MINING_BLOCK_TIME: 15 + }, + "torn.contract.tornadocash.eth": "0x3AE6667167C0f44394106E197904519D808323cA", + "governance.contract.tornadocash.eth": "0xe5324cD7602eeb387418e594B87aCADee08aeCAD", + "tornado-router.contract.tornadocash.eth": "0x1572AFE6949fdF51Cb3E0856216670ae9Ee160Ee" + } +}; +const subdomains = enabledChains.map((chain) => networkConfig[`netId${chain}`].ensSubdomainKey); + +function parseNumber(value) { + if (!value || isNaN(Number(value))) { + throw new commander.InvalidArgumentError("Invalid Number"); + } + return Number(value); +} +function parseUrl(value) { + if (!value || !validateUrl(value, ["http:", "https:"])) { + throw new commander.InvalidArgumentError("Invalid URL"); + } + return value; +} +function parseRelayer(value) { + if (!value || !(value.endsWith(".eth") || validateUrl(value, ["http:", "https:"]))) { + throw new commander.InvalidArgumentError("Invalid Relayer ETH address or URL"); + } + return value; +} +function parseAddress(value) { + if (!value) { + throw new commander.InvalidArgumentError("Invalid Address"); + } + try { + return ethers.getAddress(value); + } catch (e) { + throw new commander.InvalidArgumentError("Invalid Address"); + } +} +function parseMnemonic(value) { + if (!value) { + throw new commander.InvalidArgumentError("Invalid Mnemonic"); + } + try { + ethers.Mnemonic.fromPhrase(value); + } catch (e) { + throw new commander.InvalidArgumentError("Invalid Mnemonic"); + } + return value; +} +function parseKey(value) { + if (!value) { + throw new commander.InvalidArgumentError("Invalid Private Key"); + } + if (value.length === 64) { + value = "0x" + value; + } + try { + ethers.computeAddress(value); + } catch (e) { + throw new commander.InvalidArgumentError("Invalid Private Key"); + } + return value; +} + +class TokenPriceOracle { + constructor(provider, multicall2, oracle) { + this.provider = provider; + this.multicall = multicall2; + this.oracle = oracle; + } + fetchPrices(tokens) { + if (!this.oracle) { + return new Promise((resolve) => resolve(tokens.map(() => ethers.parseEther("0.0001")))); + } + return multicall( + this.multicall, + tokens.map((token) => ({ + contract: this.oracle, + name: "getRateToEth", + params: [token, true] + })) + ); + } +} + +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); +var __async$2 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +const MIN_STAKE_BALANCE = ethers.parseEther("500"); +const semVerRegex = new RegExp("^(?0|[1-9]\\d*)\\.(?0|[1-9]\\d*)\\.(?0|[1-9]\\d*)(?:-(?(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+(?[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"); +function parseSemanticVersion(version) { + const { groups } = semVerRegex.exec(version); + return groups; +} +function isRelayerUpdated(relayerVersion, netId) { + const { major, patch, prerelease } = parseSemanticVersion(relayerVersion); + const requiredMajor = netId === 1 ? "4" : "5"; + const isUpdatedMajor = major === requiredMajor; + if (prerelease) + return false; + return isUpdatedMajor && (Number(patch) >= 5 || Number(netId) !== 1); +} +function calculateScore({ stakeBalance, tornadoServiceFee }, minFee = 0.33, maxFee = 0.53) { + if (tornadoServiceFee < minFee) { + tornadoServiceFee = minFee; + } else if (tornadoServiceFee >= maxFee) { + return BigInt(0); + } + const serviceFeeCoefficient = (tornadoServiceFee - minFee) ** 2; + const feeDiffCoefficient = 1 / (maxFee - minFee) ** 2; + const coefficientsMultiplier = 1 - feeDiffCoefficient * serviceFeeCoefficient; + return BigInt(Math.floor(Number(stakeBalance) * coefficientsMultiplier)); +} +function getWeightRandom(weightsScores, random) { + for (let i = 0; i < weightsScores.length; i++) { + if (random < weightsScores[i]) { + return i; + } + random = random - weightsScores[i]; + } + return Math.floor(Math.random() * weightsScores.length); +} +function pickWeightedRandomRelayer(relayers, netId) { + let minFee, maxFee; + if (Number(netId) !== 1) { + minFee = 0.01; + maxFee = 0.3; + } + const weightsScores = relayers.map((el) => calculateScore(el, minFee, maxFee)); + const totalWeight = weightsScores.reduce((acc, curr) => { + return acc = acc + curr; + }, BigInt("0")); + const random = BigInt(Number(totalWeight) * Math.random()); + const weightRandomIndex = getWeightRandom(weightsScores, random); + return relayers[weightRandomIndex]; +} +class RelayerClient { + constructor({ netId, config, Aggregator, fetchDataOptions: fetchDataOptions2 }) { + this.netId = Number(netId); + this.config = config; + this.Aggregator = Aggregator; + this.fetchDataOptions = fetchDataOptions2; + } + askRelayerStatus(_0) { + return __async$2(this, arguments, function* ({ + hostname, + relayerAddress + }) { + var _a, _b; + const url = `https://${!hostname.endsWith("/") ? hostname + "/" : hostname}`; + const rawStatus = yield fetchData(`${url}status`, __spreadProps(__spreadValues({}, this.fetchDataOptions), { + headers: { + "Content-Type": "application/json, application/x-www-form-urlencoded" + }, + timeout: ((_a = this.fetchDataOptions) == null ? void 0 : _a.torPort) ? 1e4 : 3e3, + maxRetry: ((_b = this.fetchDataOptions) == null ? void 0 : _b.torPort) ? 2 : 0 + })); + const statusValidator = ajv.compile(getStatusSchema(this.netId, this.config)); + if (!statusValidator(rawStatus)) { + throw new Error("Invalid status schema"); + } + const status = __spreadProps(__spreadValues({}, rawStatus), { + url + }); + if (status.currentQueue > 5) { + throw new Error("Withdrawal queue is overloaded"); + } + if (status.netId !== this.netId) { + throw new Error("This relayer serves a different network"); + } + if (relayerAddress && this.netId === 1 && status.rewardAccount !== relayerAddress) { + throw new Error("The Relayer reward address must match registered address"); + } + if (!isRelayerUpdated(status.version, this.netId)) { + throw new Error("Outdated version."); + } + return status; + }); + } + filterRelayer(curr, relayer, subdomains, debugRelayer = false) { + return __async$2(this, null, function* () { + const { ensSubdomainKey } = this.config; + const subdomainIndex = subdomains.indexOf(ensSubdomainKey); + const mainnetSubdomain = curr.records[0]; + const hostname = curr.records[subdomainIndex]; + const isHostWithProtocol = hostname.includes("http"); + const { owner, balance: stakeBalance, isRegistered } = curr; + const { ensName, relayerAddress } = relayer; + const isOwner = !relayerAddress || relayerAddress === owner; + const hasMinBalance = stakeBalance >= MIN_STAKE_BALANCE; + const preCondition = hostname && isOwner && mainnetSubdomain && isRegistered && hasMinBalance && !isHostWithProtocol; + if (preCondition || debugRelayer) { + try { + const status = yield this.askRelayerStatus({ hostname, relayerAddress }); + return { + netId: status.netId, + url: status.url, + hostname, + ensName, + stakeBalance, + relayerAddress, + rewardAccount: status.rewardAccount, + ethPrices: status.ethPrices, + currentQueue: status.currentQueue, + tornadoServiceFee: status.tornadoServiceFee + }; + } catch (err) { + if (debugRelayer) { + throw err; + } + return { + hostname, + relayerAddress, + errorMessage: err.message + }; + } + } else { + if (debugRelayer) { + const errMsg = `Relayer ${hostname} condition not met`; + throw new Error(errMsg); + } + return { + hostname, + relayerAddress, + errorMessage: `Relayer ${hostname} condition not met` + }; + } + }); + } + getValidRelayers(relayers, subdomains, debugRelayer = false) { + return __async$2(this, null, function* () { + const relayersSet = /* @__PURE__ */ new Set(); + const uniqueRelayers = relayers.reverse().filter(({ ensName }) => { + if (!relayersSet.has(ensName)) { + relayersSet.add(ensName); + return true; + } + return false; + }); + const relayerNameHashes = uniqueRelayers.map((r) => ethers.namehash(r.ensName)); + const relayersData = yield this.Aggregator.relayersData.staticCall(relayerNameHashes, subdomains); + const invalidRelayers = []; + const validRelayers = (yield Promise.all( + relayersData.map((curr, index) => this.filterRelayer(curr, uniqueRelayers[index], subdomains, debugRelayer)) + )).filter((r) => { + if (r.errorMessage) { + invalidRelayers.push(r); + return false; + } + return true; + }); + return { + validRelayers, + invalidRelayers + }; + }); + } + pickWeightedRandomRelayer(relayers) { + return pickWeightedRandomRelayer(relayers, this.netId); + } + tornadoWithdraw(_0) { + return __async$2(this, arguments, function* ({ contract, proof, args }) { + const { url } = this.selectedRelayer; + const withdrawResponse = yield fetchData(`${url}v1/tornadoWithdraw`, __spreadProps(__spreadValues({}, this.fetchDataOptions), { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + contract, + proof, + args + }) + })); + const { id, error } = withdrawResponse; + if (error) { + throw new Error(error); + } + let relayerStatus; + const jobUrl = `${url}v1/jobs/${id}`; + console.log(`Job submitted: ${jobUrl} +`); + while (!relayerStatus || !["FAILED", "CONFIRMED"].includes(relayerStatus)) { + const jobResponse = yield fetchData(jobUrl, __spreadProps(__spreadValues({}, this.fetchDataOptions), { + method: "GET", + headers: { + "Content-Type": "application/json" + } + })); + if (jobResponse.error) { + throw new Error(error); + } + const jobValidator = ajv.compile(jobsSchema); + if (!jobValidator(jobResponse)) { + const errMsg = `${jobUrl} has an invalid job response`; + throw new Error(errMsg); + } + const { status, txHash, confirmations, failedReason } = jobResponse; + if (relayerStatus !== status) { + if (status === "FAILED") { + const errMsg = `Job ${status}: ${jobUrl} failed reason: ${failedReason}`; + throw new Error(errMsg); + } else if (status === "SENT") { + console.log(`Job ${status}: ${jobUrl}, txhash: ${txHash} +`); + } else if (status === "MINED") { + console.log(`Job ${status}: ${jobUrl}, txhash: ${txHash}, confirmations: ${confirmations} +`); + } else if (status === "CONFIRMED") { + console.log(`Job ${status}: ${jobUrl}, txhash: ${txHash}, confirmations: ${confirmations} +`); + } else { + console.log(`Job ${status}: ${jobUrl} +`); + } + relayerStatus = status; + } + yield sleep(3e3); + } + }); + } +} + +var __async$1 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +function getTokenBalances(_0) { + return __async$1(this, arguments, function* ({ + provider, + Multicall: Multicall2, + currencyName, + userAddress, + tokenAddresses = [] + }) { + const tokenCalls = tokenAddresses.map((tokenAddress) => { + const Token = ERC20__factory.connect(tokenAddress, provider); + return [ + { + contract: Token, + name: "balanceOf", + params: [userAddress] + }, + { + contract: Token, + name: "name" + }, + { + contract: Token, + name: "symbol" + }, + { + contract: Token, + name: "decimals" + } + ]; + }).flat(); + const multicallResults = yield multicall(Multicall2, [ + { + contract: Multicall2, + name: "getEthBalance", + params: [userAddress] + }, + ...tokenCalls.length ? tokenCalls : [] + ]); + const ethResults = multicallResults[0]; + const tokenResults = multicallResults.slice(1).length ? chunk(multicallResults.slice(1), tokenCalls.length / tokenAddresses.length) : []; + const tokenBalances = tokenResults.map((tokenResult, index) => { + const [tokenBalance, tokenName, tokenSymbol, tokenDecimals] = tokenResult; + const tokenAddress = tokenAddresses[index]; + return { + address: tokenAddress, + name: tokenName, + symbol: tokenSymbol, + decimals: Number(tokenDecimals), + balance: tokenBalance + }; + }); + return [ + { + address: ethers.ZeroAddress, + name: currencyName, + symbol: currencyName, + decimals: 18, + balance: ethResults + }, + ...tokenBalances + ]; + }); +} + +var __async = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +let groth16; +const groth16Promise = (() => __async(void 0, null, function* () { + if (!groth16) { + groth16 = yield websnarkGroth({ wasmInitialMemory: 2e3 }); + } +}))(); +function calculateSnarkProof(input, circuit, provingKey) { + return __async(this, null, function* () { + yield groth16Promise; + const snarkInput = { + root: input.root, + nullifierHash: BigInt(input.nullifierHex).toString(), + recipient: BigInt(input.recipient), + relayer: BigInt(input.relayer), + fee: input.fee, + refund: input.refund, + nullifier: input.nullifier, + secret: input.secret, + pathElements: input.pathElements, + pathIndices: input.pathIndices + }; + console.log("Start generating SNARK proof", snarkInput); + console.time("SNARK proof time"); + const proofData = yield websnarkUtils__namespace.genWitnessAndProve(groth16, snarkInput, circuit, provingKey); + const proof = websnarkUtils__namespace.toSolidityInput(proofData).proof; + console.timeEnd("SNARK proof time"); + const args = [ + toFixedHex(input.root, 32), + toFixedHex(input.nullifierHex, 32), + input.recipient, + input.relayer, + toFixedHex(input.fee, 32), + toFixedHex(input.refund, 32) + ]; + return { proof, args }; + }); +} + +exports.BaseDepositsService = BaseDepositsService; +exports.BaseEncryptedNotesService = BaseEncryptedNotesService; +exports.BaseEventsService = BaseEventsService; +exports.BaseGovernanceService = BaseGovernanceService; +exports.BaseRegistryService = BaseRegistryService; +exports.BatchBlockService = BatchBlockService; +exports.BatchEventsService = BatchEventsService; +exports.BatchTransactionService = BatchTransactionService; +exports.DEPOSIT = DEPOSIT; +exports.Deposit = Deposit; +exports.ENS__factory = ENS__factory; +exports.ERC20__factory = ERC20__factory; +exports.GET_DEPOSITS = GET_DEPOSITS; +exports.GET_ENCRYPTED_NOTES = GET_ENCRYPTED_NOTES; +exports.GET_NOTE_ACCOUNTS = GET_NOTE_ACCOUNTS; +exports.GET_REGISTERED = GET_REGISTERED; +exports.GET_STATISTIC = GET_STATISTIC; +exports.GET_WITHDRAWALS = GET_WITHDRAWALS; +exports.GasPriceOracle__factory = GasPriceOracle__factory; +exports.Invoice = Invoice; +exports.MIN_STAKE_BALANCE = MIN_STAKE_BALANCE; +exports.MerkleTreeService = MerkleTreeService; +exports.Mimc = Mimc; +exports.Multicall__factory = Multicall__factory; +exports.NodeDepositsService = NodeDepositsService; +exports.NodeEncryptedNotesService = NodeEncryptedNotesService; +exports.NodeGovernanceService = NodeGovernanceService; +exports.NodeRegistryService = NodeRegistryService; +exports.OffchainOracle__factory = OffchainOracle__factory; +exports.OvmGasPriceOracle__factory = OvmGasPriceOracle__factory; +exports.Pedersen = Pedersen; +exports.RelayerClient = RelayerClient; +exports.ReverseRecords__factory = ReverseRecords__factory; +exports.TokenPriceOracle = TokenPriceOracle; +exports.TornadoBrowserProvider = TornadoBrowserProvider; +exports.TornadoFeeOracle = TornadoFeeOracle; +exports.TornadoRpcSigner = TornadoRpcSigner; +exports.TornadoVoidSigner = TornadoVoidSigner; +exports.TornadoWallet = TornadoWallet; +exports.WITHDRAWAL = WITHDRAWAL; +exports._META = _META; +exports.ajv = ajv; +exports.base64ToBytes = base64ToBytes; +exports.bigIntReplacer = bigIntReplacer; +exports.blockSyncInterval = blockSyncInterval; +exports.bnToBytes = bnToBytes; +exports.buffPedersenHash = buffPedersenHash; +exports.bufferToBytes = bufferToBytes; +exports.bytesToBN = bytesToBN; +exports.bytesToBase64 = bytesToBase64; +exports.bytesToHex = bytesToHex; +exports.calculateScore = calculateScore; +exports.calculateSnarkProof = calculateSnarkProof; +exports.chunk = chunk; +exports.convertETHToTokenAmount = convertETHToTokenAmount; +exports.createDeposit = createDeposit; +exports.defaultUserAgent = defaultUserAgent; +exports.download = download; +exports.enabledChains = enabledChains; +exports.existsAsync = existsAsync; +exports.factories = index; +exports.fetch = fetch; +exports.fetchData = fetchData; +exports.fetchGetUrlFunc = fetchGetUrlFunc; +exports.getAllDeposits = getAllDeposits; +exports.getAllEncryptedNotes = getAllEncryptedNotes; +exports.getAllRegisters = getAllRegisters; +exports.getAllWithdrawals = getAllWithdrawals; +exports.getDeposits = getDeposits; +exports.getEncryptedNotes = getEncryptedNotes; +exports.getGasOraclePlugin = getGasOraclePlugin; +exports.getHttpAgent = getHttpAgent; +exports.getMeta = getMeta; +exports.getNoteAccounts = getNoteAccounts; +exports.getProvider = getProvider; +exports.getProviderWithNetId = getProviderWithNetId; +exports.getRegisters = getRegisters; +exports.getStatistic = getStatistic; +exports.getStatusSchema = getStatusSchema; +exports.getTokenBalances = getTokenBalances; +exports.getWeightRandom = getWeightRandom; +exports.getWithdrawals = getWithdrawals; +exports.isNode = isNode; +exports.isRelayerUpdated = isRelayerUpdated; +exports.jobsSchema = jobsSchema; +exports.leBuff2Int = leBuff2Int; +exports.leInt2Buff = leInt2Buff; +exports.loadCachedEvents = loadCachedEvents; +exports.loadSavedEvents = loadSavedEvents; +exports.mimc = mimc; +exports.multicall = multicall; +exports.networkConfig = networkConfig; +exports.parseAddress = parseAddress; +exports.parseKey = parseKey; +exports.parseMnemonic = parseMnemonic; +exports.parseNumber = parseNumber; +exports.parseRelayer = parseRelayer; +exports.parseSemanticVersion = parseSemanticVersion; +exports.parseUrl = parseUrl; +exports.pedersen = pedersen; +exports.pickWeightedRandomRelayer = pickWeightedRandomRelayer; +exports.populateTransaction = populateTransaction; +exports.queryGraph = queryGraph; +exports.rBigInt = rBigInt; +exports.saveEvents = saveEvents; +exports.sleep = sleep; +exports.subdomains = subdomains; +exports.substring = substring; +exports.toFixedHex = toFixedHex; +exports.toFixedLength = toFixedLength; +exports.unzipAsync = unzipAsync; +exports.validateUrl = validateUrl; +exports.zipAsync = zipAsync; diff --git a/dist/index.mjs b/dist/index.mjs new file mode 100644 index 0000000..432eedc --- /dev/null +++ b/dist/index.mjs @@ -0,0 +1,6995 @@ +import { Interface, Contract, FetchUrlFeeDataNetworkPlugin, FetchRequest, Network, EnsPlugin, GasCostPlugin, JsonRpcProvider, Wallet, HDNodeWallet, VoidSigner, JsonRpcSigner, BrowserProvider, parseUnits, FeeData, getAddress, Transaction, Mnemonic, computeAddress, parseEther, namehash, ZeroAddress } from 'ethers'; +import crossFetch from 'cross-fetch'; +import { HttpProxyAgent } from 'http-proxy-agent'; +import { HttpsProxyAgent } from 'https-proxy-agent'; +import { SocksProxyAgent } from 'socks-proxy-agent'; +import { URL } from 'url'; +import BN from 'bn.js'; +import Table from 'cli-table3'; +import moment from 'moment'; +import path from 'path'; +import { stat, mkdir, writeFile, readFile } from 'fs/promises'; +import { zip, unzip } from 'fflate'; +import Ajv from 'ajv'; +import { buildPedersenHash, buildMimcSponge } from 'circomlibjs'; +import { Worker as Worker$1 } from 'worker_threads'; +import { MerkleTree } from '@tornado/fixed-merkle-tree'; +import { InvalidArgumentError } from 'commander'; +import * as websnarkUtils from '@tornado/websnark/src/utils'; +import websnarkGroth from '@tornado/websnark/src/groth16'; + +const _abi$6 = [ + { + constant: true, + inputs: [ + { + internalType: "bytes4", + name: "interfaceID", + type: "bytes4" + } + ], + name: "supportsInterface", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + payable: false, + stateMutability: "pure", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "string", + name: "key", + type: "string" + }, + { + internalType: "string", + name: "value", + type: "string" + } + ], + name: "setText", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "bytes4", + name: "interfaceID", + type: "bytes4" + } + ], + name: "interfaceImplementer", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "uint256", + name: "contentTypes", + type: "uint256" + } + ], + name: "ABI", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + }, + { + internalType: "bytes", + name: "", + type: "bytes" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "x", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "y", + type: "bytes32" + } + ], + name: "setPubkey", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "bytes", + name: "hash", + type: "bytes" + } + ], + name: "setContenthash", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "addr", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bool", + name: "isAuthorised", + type: "bool" + } + ], + name: "setAuthorisation", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "string", + name: "key", + type: "string" + } + ], + name: "text", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "uint256", + name: "contentType", + type: "uint256" + }, + { + internalType: "bytes", + name: "data", + type: "bytes" + } + ], + name: "setABI", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "string", + name: "name", + type: "string" + } + ], + name: "setName", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "uint256", + name: "coinType", + type: "uint256" + }, + { + internalType: "bytes", + name: "a", + type: "bytes" + } + ], + name: "setAddr", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "contenthash", + outputs: [ + { + internalType: "bytes", + name: "", + type: "bytes" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + } + ], + name: "pubkey", + outputs: [ + { + internalType: "bytes32", + name: "x", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "y", + type: "bytes32" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "address", + name: "a", + type: "address" + } + ], + name: "setAddr", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "bytes4", + name: "interfaceID", + type: "bytes4" + }, + { + internalType: "address", + name: "implementer", + type: "address" + } + ], + name: "setInterface", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + internalType: "uint256", + name: "coinType", + type: "uint256" + } + ], + name: "addr", + outputs: [ + { + internalType: "bytes", + name: "", + type: "bytes" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "bytes32", + name: "", + type: "bytes32" + }, + { + internalType: "address", + name: "", + type: "address" + }, + { + internalType: "address", + name: "", + type: "address" + } + ], + name: "authorisations", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract ENS", + name: "_ens", + type: "address" + } + ], + payable: false, + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "target", + type: "address" + }, + { + indexed: false, + internalType: "bool", + name: "isAuthorised", + type: "bool" + } + ], + name: "AuthorisationChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: false, + internalType: "string", + name: "indexedKey", + type: "string" + }, + { + indexed: false, + internalType: "string", + name: "key", + type: "string" + } + ], + name: "TextChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: false, + internalType: "bytes32", + name: "x", + type: "bytes32" + }, + { + indexed: false, + internalType: "bytes32", + name: "y", + type: "bytes32" + } + ], + name: "PubkeyChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: false, + internalType: "string", + name: "name", + type: "string" + } + ], + name: "NameChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: true, + internalType: "bytes4", + name: "interfaceID", + type: "bytes4" + }, + { + indexed: false, + internalType: "address", + name: "implementer", + type: "address" + } + ], + name: "InterfaceChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: false, + internalType: "bytes", + name: "hash", + type: "bytes" + } + ], + name: "ContenthashChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: false, + internalType: "address", + name: "a", + type: "address" + } + ], + name: "AddrChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: false, + internalType: "uint256", + name: "coinType", + type: "uint256" + }, + { + indexed: false, + internalType: "bytes", + name: "newAddress", + type: "bytes" + } + ], + name: "AddressChanged", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "bytes32", + name: "node", + type: "bytes32" + }, + { + indexed: true, + internalType: "uint256", + name: "contentType", + type: "uint256" + } + ], + name: "ABIChanged", + type: "event" + } +]; +class ENS__factory { + static createInterface() { + return new Interface(_abi$6); + } + static connect(address, runner) { + return new Contract(address, _abi$6, runner); + } +} +ENS__factory.abi = _abi$6; + +const _abi$5 = [ + { + constant: true, + inputs: [], + name: "totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [], + name: "_totalSupply", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [ + { + internalType: "address", + name: "who", + type: "address" + } + ], + name: "balanceOf", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [], + name: "name", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [], + name: "symbol", + outputs: [ + { + internalType: "string", + name: "", + type: "string" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: true, + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint8", + name: "", + type: "uint8" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transfer", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "owner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "spender", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Approval", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "from", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "to", + type: "address" + }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "Transfer", + type: "event" + }, + { + constant: true, + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + } + ], + name: "allowance", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + payable: false, + stateMutability: "view", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "address", + name: "from", + type: "address" + }, + { + internalType: "address", + name: "to", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "transferFrom", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + constant: false, + inputs: [ + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + } + ], + name: "approve", + outputs: [], + payable: false, + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + } + ], + name: "nonces", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "owner", + type: "address" + }, + { + internalType: "address", + name: "spender", + type: "address" + }, + { + internalType: "uint256", + name: "amount", + type: "uint256" + }, + { + internalType: "uint256", + name: "deadline", + type: "uint256" + }, + { + internalType: "uint8", + name: "v", + type: "uint8" + }, + { + internalType: "bytes32", + name: "r", + type: "bytes32" + }, + { + internalType: "bytes32", + name: "s", + type: "bytes32" + } + ], + name: "permit", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class ERC20__factory { + static createInterface() { + return new Interface(_abi$5); + } + static connect(address, runner) { + return new Contract(address, _abi$5, runner); + } +} +ERC20__factory.abi = _abi$5; + +const _abi$4 = [ + { + inputs: [], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [], + name: "GAS_UNIT", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint32", + name: "_derivationThresold", + type: "uint32" + } + ], + name: "changeDerivationThresold", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint32", + name: "_gasUnit", + type: "uint32" + } + ], + name: "changeGasUnit", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint32", + name: "_heartbeat", + type: "uint32" + } + ], + name: "changeHeartbeat", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address" + } + ], + name: "changeOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "derivationThresold", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "gasPrice", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "heartbeat", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "maxFeePerGas", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "maxPriorityFeePerGas", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "pastGasPrice", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint32", + name: "_gasPrice", + type: "uint32" + } + ], + name: "setGasPrice", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "timestamp", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32" + } + ], + stateMutability: "view", + type: "function" + } +]; +class GasPriceOracle__factory { + static createInterface() { + return new Interface(_abi$4); + } + static connect(address, runner) { + return new Contract(address, _abi$4, runner); + } +} +GasPriceOracle__factory.abi = _abi$4; + +const _abi$3 = [ + { + inputs: [ + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call[]", + name: "calls", + type: "tuple[]" + } + ], + name: "aggregate", + outputs: [ + { + internalType: "uint256", + name: "blockNumber", + type: "uint256" + }, + { + internalType: "bytes[]", + name: "returnData", + type: "bytes[]" + } + ], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bool", + name: "allowFailure", + type: "bool" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call3[]", + name: "calls", + type: "tuple[]" + } + ], + name: "aggregate3", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "success", + type: "bool" + }, + { + internalType: "bytes", + name: "returnData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Result[]", + name: "returnData", + type: "tuple[]" + } + ], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bool", + name: "allowFailure", + type: "bool" + }, + { + internalType: "uint256", + name: "value", + type: "uint256" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call3Value[]", + name: "calls", + type: "tuple[]" + } + ], + name: "aggregate3Value", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "success", + type: "bool" + }, + { + internalType: "bytes", + name: "returnData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Result[]", + name: "returnData", + type: "tuple[]" + } + ], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call[]", + name: "calls", + type: "tuple[]" + } + ], + name: "blockAndAggregate", + outputs: [ + { + internalType: "uint256", + name: "blockNumber", + type: "uint256" + }, + { + internalType: "bytes32", + name: "blockHash", + type: "bytes32" + }, + { + components: [ + { + internalType: "bool", + name: "success", + type: "bool" + }, + { + internalType: "bytes", + name: "returnData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Result[]", + name: "returnData", + type: "tuple[]" + } + ], + stateMutability: "payable", + type: "function" + }, + { + inputs: [], + name: "getBasefee", + outputs: [ + { + internalType: "uint256", + name: "basefee", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "blockNumber", + type: "uint256" + } + ], + name: "getBlockHash", + outputs: [ + { + internalType: "bytes32", + name: "blockHash", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getBlockNumber", + outputs: [ + { + internalType: "uint256", + name: "blockNumber", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getChainId", + outputs: [ + { + internalType: "uint256", + name: "chainid", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getCurrentBlockCoinbase", + outputs: [ + { + internalType: "address", + name: "coinbase", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getCurrentBlockDifficulty", + outputs: [ + { + internalType: "uint256", + name: "difficulty", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getCurrentBlockGasLimit", + outputs: [ + { + internalType: "uint256", + name: "gaslimit", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getCurrentBlockTimestamp", + outputs: [ + { + internalType: "uint256", + name: "timestamp", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "addr", + type: "address" + } + ], + name: "getEthBalance", + outputs: [ + { + internalType: "uint256", + name: "balance", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "getLastBlockHash", + outputs: [ + { + internalType: "bytes32", + name: "blockHash", + type: "bytes32" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bool", + name: "requireSuccess", + type: "bool" + }, + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call[]", + name: "calls", + type: "tuple[]" + } + ], + name: "tryAggregate", + outputs: [ + { + components: [ + { + internalType: "bool", + name: "success", + type: "bool" + }, + { + internalType: "bytes", + name: "returnData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Result[]", + name: "returnData", + type: "tuple[]" + } + ], + stateMutability: "payable", + type: "function" + }, + { + inputs: [ + { + internalType: "bool", + name: "requireSuccess", + type: "bool" + }, + { + components: [ + { + internalType: "address", + name: "target", + type: "address" + }, + { + internalType: "bytes", + name: "callData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Call[]", + name: "calls", + type: "tuple[]" + } + ], + name: "tryBlockAndAggregate", + outputs: [ + { + internalType: "uint256", + name: "blockNumber", + type: "uint256" + }, + { + internalType: "bytes32", + name: "blockHash", + type: "bytes32" + }, + { + components: [ + { + internalType: "bool", + name: "success", + type: "bool" + }, + { + internalType: "bytes", + name: "returnData", + type: "bytes" + } + ], + internalType: "struct Multicall3.Result[]", + name: "returnData", + type: "tuple[]" + } + ], + stateMutability: "payable", + type: "function" + } +]; +class Multicall__factory { + static createInterface() { + return new Interface(_abi$3); + } + static connect(address, runner) { + return new Contract(address, _abi$3, runner); + } +} +Multicall__factory.abi = _abi$3; + +const _abi$2 = [ + { + inputs: [ + { + internalType: "contract MultiWrapper", + name: "_multiWrapper", + type: "address" + }, + { + internalType: "contract IOracle[]", + name: "existingOracles", + type: "address[]" + }, + { + internalType: "enum OffchainOracle.OracleType[]", + name: "oracleTypes", + type: "uint8[]" + }, + { + internalType: "contract IERC20[]", + name: "existingConnectors", + type: "address[]" + }, + { + internalType: "contract IERC20", + name: "wBase", + type: "address" + }, + { + internalType: "address", + name: "owner", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [], + name: "ArraysLengthMismatch", + type: "error" + }, + { + inputs: [], + name: "ConnectorAlreadyAdded", + type: "error" + }, + { + inputs: [], + name: "InvalidOracleTokenKind", + type: "error" + }, + { + inputs: [], + name: "OracleAlreadyAdded", + type: "error" + }, + { + inputs: [], + name: "SameTokens", + type: "error" + }, + { + inputs: [], + name: "TooBigThreshold", + type: "error" + }, + { + inputs: [], + name: "UnknownConnector", + type: "error" + }, + { + inputs: [], + name: "UnknownOracle", + type: "error" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "contract IERC20", + name: "connector", + type: "address" + } + ], + name: "ConnectorAdded", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "contract IERC20", + name: "connector", + type: "address" + } + ], + name: "ConnectorRemoved", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "contract MultiWrapper", + name: "multiWrapper", + type: "address" + } + ], + name: "MultiWrapperUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "contract IOracle", + name: "oracle", + type: "address" + }, + { + indexed: false, + internalType: "enum OffchainOracle.OracleType", + name: "oracleType", + type: "uint8" + } + ], + name: "OracleAdded", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "contract IOracle", + name: "oracle", + type: "address" + }, + { + indexed: false, + internalType: "enum OffchainOracle.OracleType", + name: "oracleType", + type: "uint8" + } + ], + name: "OracleRemoved", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "OwnershipTransferred", + type: "event" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "connector", + type: "address" + } + ], + name: "addConnector", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IOracle", + name: "oracle", + type: "address" + }, + { + internalType: "enum OffchainOracle.OracleType", + name: "oracleKind", + type: "uint8" + } + ], + name: "addOracle", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "connectors", + outputs: [ + { + internalType: "contract IERC20[]", + name: "allConnectors", + type: "address[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "contract IERC20", + name: "dstToken", + type: "address" + }, + { + internalType: "bool", + name: "useWrappers", + type: "bool" + } + ], + name: "getRate", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "bool", + name: "useSrcWrappers", + type: "bool" + } + ], + name: "getRateToEth", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "bool", + name: "useSrcWrappers", + type: "bool" + }, + { + internalType: "contract IERC20[]", + name: "customConnectors", + type: "address[]" + }, + { + internalType: "uint256", + name: "thresholdFilter", + type: "uint256" + } + ], + name: "getRateToEthWithCustomConnectors", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "bool", + name: "useSrcWrappers", + type: "bool" + }, + { + internalType: "uint256", + name: "thresholdFilter", + type: "uint256" + } + ], + name: "getRateToEthWithThreshold", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "contract IERC20", + name: "dstToken", + type: "address" + }, + { + internalType: "bool", + name: "useWrappers", + type: "bool" + }, + { + internalType: "contract IERC20[]", + name: "customConnectors", + type: "address[]" + }, + { + internalType: "uint256", + name: "thresholdFilter", + type: "uint256" + } + ], + name: "getRateWithCustomConnectors", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "srcToken", + type: "address" + }, + { + internalType: "contract IERC20", + name: "dstToken", + type: "address" + }, + { + internalType: "bool", + name: "useWrappers", + type: "bool" + }, + { + internalType: "uint256", + name: "thresholdFilter", + type: "uint256" + } + ], + name: "getRateWithThreshold", + outputs: [ + { + internalType: "uint256", + name: "weightedRate", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "multiWrapper", + outputs: [ + { + internalType: "contract MultiWrapper", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "oracles", + outputs: [ + { + internalType: "contract IOracle[]", + name: "allOracles", + type: "address[]" + }, + { + internalType: "enum OffchainOracle.OracleType[]", + name: "oracleTypes", + type: "uint8[]" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IERC20", + name: "connector", + type: "address" + } + ], + name: "removeConnector", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract IOracle", + name: "oracle", + type: "address" + }, + { + internalType: "enum OffchainOracle.OracleType", + name: "oracleKind", + type: "uint8" + } + ], + name: "removeOracle", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "contract MultiWrapper", + name: "_multiWrapper", + type: "address" + } + ], + name: "setMultiWrapper", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class OffchainOracle__factory { + static createInterface() { + return new Interface(_abi$2); + } + static connect(address, runner) { + return new Contract(address, _abi$2, runner); + } +} +OffchainOracle__factory.abi = _abi$2; + +const _abi$1 = [ + { + inputs: [ + { + internalType: "address", + name: "_owner", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "DecimalsUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "GasPriceUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "L1BaseFeeUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "OverheadUpdated", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "previousOwner", + type: "address" + }, + { + indexed: true, + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "OwnershipTransferred", + type: "event" + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "", + type: "uint256" + } + ], + name: "ScalarUpdated", + type: "event" + }, + { + inputs: [], + name: "decimals", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "gasPrice", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes", + name: "_data", + type: "bytes" + } + ], + name: "getL1Fee", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "bytes", + name: "_data", + type: "bytes" + } + ], + name: "getL1GasUsed", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "l1BaseFee", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "overhead", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "owner", + outputs: [ + { + internalType: "address", + name: "", + type: "address" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [], + name: "scalar", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256" + } + ], + stateMutability: "view", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_decimals", + type: "uint256" + } + ], + name: "setDecimals", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_gasPrice", + type: "uint256" + } + ], + name: "setGasPrice", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_baseFee", + type: "uint256" + } + ], + name: "setL1BaseFee", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_overhead", + type: "uint256" + } + ], + name: "setOverhead", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "uint256", + name: "_scalar", + type: "uint256" + } + ], + name: "setScalar", + outputs: [], + stateMutability: "nonpayable", + type: "function" + }, + { + inputs: [ + { + internalType: "address", + name: "newOwner", + type: "address" + } + ], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function" + } +]; +class OvmGasPriceOracle__factory { + static createInterface() { + return new Interface(_abi$1); + } + static connect(address, runner) { + return new Contract(address, _abi$1, runner); + } +} +OvmGasPriceOracle__factory.abi = _abi$1; + +const _abi = [ + { + inputs: [ + { + internalType: "contract ENS", + name: "_ens", + type: "address" + } + ], + stateMutability: "nonpayable", + type: "constructor" + }, + { + inputs: [ + { + internalType: "address[]", + name: "addresses", + type: "address[]" + } + ], + name: "getNames", + outputs: [ + { + internalType: "string[]", + name: "r", + type: "string[]" + } + ], + stateMutability: "view", + type: "function" + } +]; +class ReverseRecords__factory { + static createInterface() { + return new Interface(_abi); + } + static connect(address, runner) { + return new Contract(address, _abi, runner); + } +} +ReverseRecords__factory.abi = _abi; + +var index = /*#__PURE__*/Object.freeze({ + __proto__: null, + ENS__factory: ENS__factory, + ERC20__factory: ERC20__factory, + GasPriceOracle__factory: GasPriceOracle__factory, + Multicall__factory: Multicall__factory, + OffchainOracle__factory: OffchainOracle__factory, + OvmGasPriceOracle__factory: OvmGasPriceOracle__factory, + ReverseRecords__factory: ReverseRecords__factory +}); + +BigInt.prototype.toJSON = function() { + return this.toString(); +}; +const isNode = !process.browser && typeof globalThis.window === "undefined"; +const chunk = (arr, size) => [...Array(Math.ceil(arr.length / size))].map((_, i) => arr.slice(size * i, size + size * i)); +function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} +function validateUrl(url, protocols) { + try { + const parsedUrl = new URL(url); + if (protocols && protocols.length) { + return protocols.map((p) => p.toLowerCase()).includes(parsedUrl.protocol); + } + return true; + } catch (e) { + return false; + } +} +function bufferToBytes(b) { + return new Uint8Array(b.buffer); +} +function bytesToBase64(bytes) { + let binary = ""; + const len = bytes.byteLength; + for (let i = 0; i < len; ++i) { + binary += String.fromCharCode(bytes[i]); + } + return btoa(binary); +} +function base64ToBytes(base64) { + const binaryString = atob(base64); + const bytes = new Uint8Array(binaryString.length); + for (let i = 0; i < binaryString.length; i++) { + bytes[i] = binaryString.charCodeAt(i); + } + return bytes; +} +function bytesToHex(bytes) { + return "0x" + Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join(""); +} +function bytesToBN(bytes) { + return BigInt(bytesToHex(bytes)); +} +function bnToBytes(bigint) { + let hexString = typeof bigint === "bigint" ? bigint.toString(16) : bigint; + if (hexString.startsWith("0x")) { + hexString = hexString.replace("0x", ""); + } + if (hexString.length % 2 !== 0) { + hexString = "0" + hexString; + } + return Uint8Array.from(hexString.match(/.{1,2}/g).map((byte) => parseInt(byte, 16))); +} +function leBuff2Int(bytes) { + return new BN(bytes, 16, "le"); +} +function leInt2Buff(bigint) { + return Uint8Array.from(new BN(bigint).toArray("le", 31)); +} +function toFixedHex(numberish, length = 32) { + return "0x" + BigInt(numberish).toString(16).padStart(length * 2, "0"); +} +function toFixedLength(string, length = 32) { + string = string.replace("0x", ""); + return "0x" + string.padStart(length * 2, "0"); +} +function rBigInt(nbytes = 31) { + return bytesToBN(crypto.getRandomValues(new Uint8Array(nbytes))); +} +function bigIntReplacer(key, value) { + return typeof value === "bigint" ? value.toString() : value; +} +function substring(str, length = 10) { + if (str.length < length * 2) { + return str; + } + return `${str.substring(0, length)}...${str.substring(str.length - length)}`; +} + +var __async$d = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +function multicall(Multicall2, calls) { + return __async$d(this, null, function* () { + const calldata = calls.map((call) => { + var _a, _b, _c; + const target = ((_a = call.contract) == null ? void 0 : _a.target) || call.address; + const callInterface = ((_b = call.contract) == null ? void 0 : _b.interface) || call.interface; + return { + target, + callData: callInterface.encodeFunctionData(call.name, call.params), + allowFailure: (_c = call.allowFailure) != null ? _c : false + }; + }); + const returnData = yield Multicall2.aggregate3.staticCall(calldata); + const res = returnData.map((call, i) => { + var _a; + const callInterface = ((_a = calls[i].contract) == null ? void 0 : _a.interface) || calls[i].interface; + const [result, data] = call; + const decodeResult = result && data && data !== "0x" ? callInterface.decodeFunctionResult(calls[i].name, data) : null; + return !decodeResult ? null : decodeResult.length === 1 ? decodeResult[0] : decodeResult; + }); + return res; + }); +} + +var __defProp$3 = Object.defineProperty; +var __defProps$3 = Object.defineProperties; +var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols; +var __getProtoOf$1 = Object.getPrototypeOf; +var __hasOwnProp$3 = Object.prototype.hasOwnProperty; +var __propIsEnum$3 = Object.prototype.propertyIsEnumerable; +var __reflectGet$1 = Reflect.get; +var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues$3 = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp$3.call(b, prop)) + __defNormalProp$3(a, prop, b[prop]); + if (__getOwnPropSymbols$3) + for (var prop of __getOwnPropSymbols$3(b)) { + if (__propIsEnum$3.call(b, prop)) + __defNormalProp$3(a, prop, b[prop]); + } + return a; +}; +var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b)); +var __superGet$1 = (cls, obj, key) => __reflectGet$1(__getProtoOf$1(cls), key, obj); +var __async$c = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +const defaultUserAgent = "Mozilla/5.0 (Windows NT 10.0; rv:109.0) Gecko/20100101 Firefox/115.0"; +const fetch = crossFetch; +function getHttpAgent({ + fetchUrl, + proxyUrl, + torPort, + retry +}) { + if (torPort) { + return new SocksProxyAgent(`socks5h://tor${retry}@127.0.0.1:${torPort}`); + } + if (!proxyUrl) { + return; + } + const isHttps = fetchUrl.includes("https://"); + if (proxyUrl.includes("socks://") || proxyUrl.includes("socks4://") || proxyUrl.includes("socks5://")) { + return new SocksProxyAgent(proxyUrl); + } + if (proxyUrl.includes("http://") || proxyUrl.includes("https://")) { + if (isHttps) { + return new HttpsProxyAgent(proxyUrl); + } + return new HttpProxyAgent(proxyUrl); + } +} +function fetchData(_0) { + return __async$c(this, arguments, function* (url, options = {}) { + var _a, _b, _c; + const MAX_RETRY = (_a = options.maxRetry) != null ? _a : 3; + const RETRY_ON = (_b = options.retryOn) != null ? _b : 500; + const userAgent = (_c = options.userAgent) != null ? _c : defaultUserAgent; + let retry = 0; + let errorObject; + if (!options.method) { + if (!options.body) { + options.method = "GET"; + } else { + options.method = "POST"; + } + } + if (!options.headers) { + options.headers = {}; + } + if (isNode && !options.headers["User-Agent"]) { + options.headers["User-Agent"] = userAgent; + } + while (retry < MAX_RETRY + 1) { + let timeout; + if (!options.signal && options.timeout) { + const controller = new AbortController(); + options.signal = controller.signal; + timeout = setTimeout(() => { + controller.abort(); + }, options.timeout); + } + if (!options.agent && isNode && (options.proxy || options.torPort)) { + options.agent = getHttpAgent({ + fetchUrl: url, + proxyUrl: options.proxy, + torPort: options.torPort, + retry + }); + } + if (options.debug && typeof options.debug === "function") { + options.debug("request", { + url, + retry, + errorObject, + options + }); + } + try { + const resp = yield fetch(url, { + method: options.method, + headers: options.headers, + body: options.body, + redirect: options.redirect, + signal: options.signal, + agent: options.agent + }); + if (options.debug && typeof options.debug === "function") { + options.debug("response", resp); + } + if (!resp.ok) { + const errMsg = `Request to ${url} failed with error code ${resp.status}: +` + (yield resp.text()); + throw new Error(errMsg); + } + if (options.returnResponse) { + return resp; + } + const contentType = resp.headers.get("content-type"); + if (contentType == null ? void 0 : contentType.includes("application/json")) { + return yield resp.json(); + } + if (contentType == null ? void 0 : contentType.includes("text")) { + return yield resp.text(); + } + return resp; + } catch (error) { + if (timeout) { + clearTimeout(timeout); + } + errorObject = error; + retry++; + yield sleep(RETRY_ON); + } finally { + if (timeout) { + clearTimeout(timeout); + } + } + } + if (options.debug && typeof options.debug === "function") { + options.debug("error", errorObject); + } + throw errorObject; + }); +} +const fetchGetUrlFunc = (options = {}) => (req, _signal) => __async$c(void 0, null, function* () { + let signal; + if (_signal) { + const controller = new AbortController(); + signal = controller.signal; + _signal.addListener(() => { + controller.abort(); + }); + } + const init = __spreadProps$3(__spreadValues$3({}, options), { + method: req.method || "POST", + headers: req.headers, + body: req.body || void 0, + signal, + returnResponse: true + }); + const resp = yield fetchData(req.url, init); + const headers = {}; + resp.headers.forEach((value, key) => { + headers[key.toLowerCase()] = value; + }); + const respBody = yield resp.arrayBuffer(); + const body = respBody == null ? null : new Uint8Array(respBody); + return { + statusCode: resp.status, + statusMessage: resp.statusText, + headers, + body + }; +}); +const oracleMapper = /* @__PURE__ */ new Map(); +const multicallMapper = /* @__PURE__ */ new Map(); +function getGasOraclePlugin(networkKey, fetchOptions) { + const gasStationApi = (fetchOptions == null ? void 0 : fetchOptions.gasStationApi) || "https://gasstation.polygon.technology/v2"; + return new FetchUrlFeeDataNetworkPlugin(gasStationApi, (fetchFeeData, provider, request) => __async$c(this, null, function* () { + if (!oracleMapper.has(networkKey)) { + oracleMapper.set(networkKey, GasPriceOracle__factory.connect(fetchOptions == null ? void 0 : fetchOptions.gasPriceOracle, provider)); + } + if (!multicallMapper.has(networkKey)) { + multicallMapper.set( + networkKey, + Multicall__factory.connect("0xcA11bde05977b3631167028862bE2a173976CA11", provider) + ); + } + const Oracle = oracleMapper.get(networkKey); + const Multicall2 = multicallMapper.get(networkKey); + const [timestamp, heartbeat, feePerGas, priorityFeePerGas] = yield multicall(Multicall2, [ + { + contract: Oracle, + name: "timestamp" + }, + { + contract: Oracle, + name: "heartbeat" + }, + { + contract: Oracle, + name: "maxFeePerGas" + }, + { + contract: Oracle, + name: "maxPriorityFeePerGas" + } + ]); + const isOutdated = Number(timestamp) <= Date.now() / 1e3 - Number(heartbeat); + if (!isOutdated) { + const maxPriorityFeePerGas = priorityFeePerGas * BigInt(13) / BigInt(10); + const maxFeePerGas = feePerGas * BigInt(2) + maxPriorityFeePerGas; + return { + gasPrice: maxFeePerGas, + maxFeePerGas, + maxPriorityFeePerGas + }; + } + const fetchReq = new FetchRequest(gasStationApi); + fetchReq.getUrlFunc = fetchGetUrlFunc(fetchOptions); + if (isNode) { + fetchReq.setHeader("User-Agent", "ethers"); + } + const [ + { + bodyJson: { fast } + }, + { gasPrice } + ] = yield Promise.all([fetchReq.send(), fetchFeeData()]); + return { + gasPrice, + maxFeePerGas: parseUnits(`${fast.maxFee}`, 9), + maxPriorityFeePerGas: parseUnits(`${fast.maxPriorityFee}`, 9) + }; + })); +} +function getProvider(rpcUrl, fetchOptions) { + return __async$c(this, null, function* () { + const fetchReq = new FetchRequest(rpcUrl); + fetchReq.getUrlFunc = fetchGetUrlFunc(fetchOptions); + const _staticNetwork = yield new JsonRpcProvider(fetchReq).getNetwork(); + const ensPlugin = _staticNetwork.getPlugin("org.ethers.plugins.network.Ens"); + const gasCostPlugin = _staticNetwork.getPlugin("org.ethers.plugins.network.GasCost"); + const gasStationPlugin = _staticNetwork.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin"); + const staticNetwork = new Network(_staticNetwork.name, _staticNetwork.chainId); + if (ensPlugin) { + staticNetwork.attachPlugin(ensPlugin); + } + if (gasCostPlugin) { + staticNetwork.attachPlugin(gasCostPlugin); + } + if (fetchOptions == null ? void 0 : fetchOptions.gasPriceOracle) { + staticNetwork.attachPlugin(getGasOraclePlugin(`${_staticNetwork.chainId}_${rpcUrl}`, fetchOptions)); + } else if (gasStationPlugin) { + staticNetwork.attachPlugin(gasStationPlugin); + } + const provider = new JsonRpcProvider(fetchReq, staticNetwork, { + staticNetwork + }); + provider.pollingInterval = (fetchOptions == null ? void 0 : fetchOptions.pollingInterval) || 1e3; + return provider; + }); +} +function getProviderWithNetId(netId, rpcUrl, config, fetchOptions) { + const { networkName, reverseRecordsContract, gasPriceOracleContract, gasStationApi, pollInterval } = config; + const hasEns = Boolean(reverseRecordsContract); + const fetchReq = new FetchRequest(rpcUrl); + fetchReq.getUrlFunc = fetchGetUrlFunc(fetchOptions); + const staticNetwork = new Network(networkName, netId); + if (hasEns) { + staticNetwork.attachPlugin(new EnsPlugin(null, Number(netId))); + } + staticNetwork.attachPlugin(new GasCostPlugin()); + if (gasPriceOracleContract) { + staticNetwork.attachPlugin( + getGasOraclePlugin(`${netId}_${rpcUrl}`, { + gasPriceOracle: gasPriceOracleContract, + gasStationApi + }) + ); + } + const provider = new JsonRpcProvider(fetchReq, staticNetwork, { + staticNetwork + }); + provider.pollingInterval = (fetchOptions == null ? void 0 : fetchOptions.pollingInterval) || pollInterval * 1e3; + return provider; +} +const populateTransaction = (signer, tx) => __async$c(void 0, null, function* () { + const provider = signer.provider; + if (!tx.from) { + tx.from = signer.address; + } else if (tx.from !== signer.address) { + const errMsg = `populateTransaction: signer mismatch for tx, wants ${tx.from} have ${signer.address}`; + throw new Error(errMsg); + } + const [feeData, nonce] = yield Promise.all([ + (() => __async$c(void 0, null, function* () { + if (tx.maxFeePerGas && tx.maxPriorityFeePerGas) { + return new FeeData(null, BigInt(tx.maxFeePerGas), BigInt(tx.maxPriorityFeePerGas)); + } + if (tx.gasPrice) { + return new FeeData(BigInt(tx.gasPrice), null, null); + } + const fetchedFeeData = yield provider.getFeeData(); + if (fetchedFeeData.maxFeePerGas && fetchedFeeData.maxPriorityFeePerGas) { + return new FeeData( + null, + fetchedFeeData.maxFeePerGas * (BigInt(1e4) + BigInt(signer.gasPriceBump)) / BigInt(1e4), + fetchedFeeData.maxPriorityFeePerGas + ); + } else { + return new FeeData( + fetchedFeeData.gasPrice * (BigInt(1e4) + BigInt(signer.gasPriceBump)) / BigInt(1e4), + null, + null + ); + } + }))(), + (() => __async$c(void 0, null, function* () { + if (tx.nonce) { + return tx.nonce; + } + let fetchedNonce = yield provider.getTransactionCount(signer.address, "pending"); + if (signer.bumpNonce && signer.nonce && signer.nonce >= fetchedNonce) { + console.log( + `populateTransaction: bumping nonce from ${fetchedNonce} to ${fetchedNonce + 1} for ${signer.address}` + ); + fetchedNonce++; + } + return fetchedNonce; + }))() + ]); + tx.nonce = nonce; + if (feeData.maxFeePerGas && feeData.maxPriorityFeePerGas) { + tx.maxFeePerGas = feeData.maxFeePerGas; + tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; + if (!tx.type) { + tx.type = 2; + } + delete tx.gasPrice; + } else if (feeData.gasPrice) { + tx.gasPrice = feeData.gasPrice; + if (!tx.type) { + tx.type = 0; + } + delete tx.maxFeePerGas; + delete tx.maxPriorityFeePerGas; + } + tx.gasLimit = tx.gasLimit || (yield (() => __async$c(void 0, null, function* () { + try { + const gasLimit = yield provider.estimateGas(tx); + return gasLimit === BigInt(21e3) ? gasLimit : gasLimit * (BigInt(1e4) + BigInt(signer.gasLimitBump)) / BigInt(1e4); + } catch (err) { + if (signer.gasFailover) { + console.log("populateTransaction: warning gas estimation failed falling back to 3M gas"); + return BigInt("3000000"); + } + throw err; + } + }))()); + return tx; +}); +class TornadoWallet extends Wallet { + constructor(key, provider, { gasPriceBump, gasLimitBump, gasFailover, bumpNonce } = {}) { + super(key, provider); + this.gasPriceBump = gasPriceBump != null ? gasPriceBump : 1e3; + this.gasLimitBump = gasLimitBump != null ? gasLimitBump : 3e3; + this.gasFailover = gasFailover != null ? gasFailover : false; + this.bumpNonce = bumpNonce != null ? bumpNonce : false; + } + static fromMnemonic(mneomnic, provider, index = 0, options) { + const defaultPath = `m/44'/60'/0'/0/${index}`; + const { privateKey } = HDNodeWallet.fromPhrase(mneomnic, void 0, defaultPath); + return new TornadoWallet(privateKey, provider, options); + } + populateTransaction(tx) { + return __async$c(this, null, function* () { + const txObject = yield populateTransaction(this, tx); + this.nonce = txObject.nonce; + return __superGet$1(TornadoWallet.prototype, this, "populateTransaction").call(this, txObject); + }); + } +} +class TornadoVoidSigner extends VoidSigner { + constructor(address, provider, { gasPriceBump, gasLimitBump, gasFailover, bumpNonce } = {}) { + super(address, provider); + this.gasPriceBump = gasPriceBump != null ? gasPriceBump : 1e3; + this.gasLimitBump = gasLimitBump != null ? gasLimitBump : 3e3; + this.gasFailover = gasFailover != null ? gasFailover : false; + this.bumpNonce = bumpNonce != null ? bumpNonce : false; + } + populateTransaction(tx) { + return __async$c(this, null, function* () { + const txObject = yield populateTransaction(this, tx); + this.nonce = txObject.nonce; + return __superGet$1(TornadoVoidSigner.prototype, this, "populateTransaction").call(this, txObject); + }); + } +} +class TornadoRpcSigner extends JsonRpcSigner { + constructor(provider, address, { gasPriceBump, gasLimitBump, gasFailover, bumpNonce } = {}) { + super(provider, address); + this.gasPriceBump = gasPriceBump != null ? gasPriceBump : 1e3; + this.gasLimitBump = gasLimitBump != null ? gasLimitBump : 3e3; + this.gasFailover = gasFailover != null ? gasFailover : false; + this.bumpNonce = bumpNonce != null ? bumpNonce : false; + } + sendUncheckedTransaction(tx) { + return __async$c(this, null, function* () { + return __superGet$1(TornadoRpcSigner.prototype, this, "sendUncheckedTransaction").call(this, yield populateTransaction(this, tx)); + }); + } +} +class TornadoBrowserProvider extends BrowserProvider { + constructor(ethereum, network, options) { + super(ethereum, network); + this.options = options; + } + getSigner(address) { + return __async$c(this, null, function* () { + var _a, _b, _c, _d, _e, _f, _g, _h, _i; + const signerAddress = (yield __superGet$1(TornadoBrowserProvider.prototype, this, "getSigner").call(this, address)).address; + if (((_a = this.options) == null ? void 0 : _a.webChainId) && ((_b = this.options) == null ? void 0 : _b.connectWallet) && Number(yield __superGet$1(TornadoBrowserProvider.prototype, this, "send").call(this, "eth_chainId", [])) !== Number((_c = this.options) == null ? void 0 : _c.webChainId)) { + yield this.options.connectWallet(); + } + if ((_d = this.options) == null ? void 0 : _d.handleNetworkChanges) { + (_e = window == null ? void 0 : window.ethereum) == null ? void 0 : _e.on("chainChanged", this.options.handleNetworkChanges); + } + if ((_f = this.options) == null ? void 0 : _f.handleAccountChanges) { + (_g = window == null ? void 0 : window.ethereum) == null ? void 0 : _g.on("accountsChanged", this.options.handleAccountChanges); + } + if ((_h = this.options) == null ? void 0 : _h.handleAccountDisconnect) { + (_i = window == null ? void 0 : window.ethereum) == null ? void 0 : _i.on("disconnect", this.options.handleAccountDisconnect); + } + return new TornadoRpcSigner(this, signerAddress, this.options); + }); + } +} + +const GET_STATISTIC = ` + query getStatistic($currency: String!, $amount: String!, $first: Int, $orderBy: BigInt, $orderDirection: String) { + deposits(first: $first, orderBy: $orderBy, orderDirection: $orderDirection, where: { currency: $currency, amount: $amount }) { + index + timestamp + blockNumber + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const _META = ` + query getMeta { + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const GET_REGISTERED = ` + query getRegistered($first: Int, $fromBlock: Int) { + relayers(first: $first, orderBy: blockRegistration, orderDirection: asc, where: { + blockRegistration_gte: $fromBlock + }) { + id + address + ensName + blockRegistration + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const GET_DEPOSITS = ` + query getDeposits($currency: String!, $amount: String!, $first: Int, $fromBlock: Int) { + deposits(first: $first, orderBy: index, orderDirection: asc, where: { + amount: $amount, + currency: $currency, + blockNumber_gte: $fromBlock + }) { + id + blockNumber + commitment + index + timestamp + from + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const GET_WITHDRAWALS = ` + query getWithdrawals($currency: String!, $amount: String!, $first: Int, $fromBlock: Int!) { + withdrawals(first: $first, orderBy: blockNumber, orderDirection: asc, where: { + currency: $currency, + amount: $amount, + blockNumber_gte: $fromBlock + }) { + id + blockNumber + nullifier + to + fee + timestamp + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const GET_NOTE_ACCOUNTS = ` + query getNoteAccount($address: String!) { + noteAccounts(where: { address: $address }) { + id + index + address + encryptedAccount + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; +const GET_ENCRYPTED_NOTES = ` + query getEncryptedNotes($first: Int, $fromBlock: Int) { + encryptedNotes(first: $first, orderBy: blockNumber, orderDirection: asc, where: { blockNumber_gte: $fromBlock }) { + blockNumber + index + transactionHash + encryptedNote + } + _meta { + block { + number + } + hasIndexingErrors + } + } +`; + +var __defProp$2 = Object.defineProperty; +var __defProps$2 = Object.defineProperties; +var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols; +var __hasOwnProp$2 = Object.prototype.hasOwnProperty; +var __propIsEnum$2 = Object.prototype.propertyIsEnumerable; +var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues$2 = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp$2.call(b, prop)) + __defNormalProp$2(a, prop, b[prop]); + if (__getOwnPropSymbols$2) + for (var prop of __getOwnPropSymbols$2(b)) { + if (__propIsEnum$2.call(b, prop)) + __defNormalProp$2(a, prop, b[prop]); + } + return a; +}; +var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b)); +var __async$b = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +const isEmptyArray = (arr) => !Array.isArray(arr) || !arr.length; +const first = 1e3; +function queryGraph(_0) { + return __async$b(this, arguments, function* ({ + graphApi, + subgraphName, + query, + variables, + fetchDataOptions: fetchDataOptions2 + }) { + var _a; + const graphUrl = `${graphApi}/subgraphs/name/${subgraphName}`; + const { data, errors } = yield fetchData(graphUrl, __spreadProps$2(__spreadValues$2({}, fetchDataOptions2), { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + query, + variables + }) + })); + if (errors) { + throw new Error(JSON.stringify(errors)); + } + if ((_a = data == null ? void 0 : data._meta) == null ? void 0 : _a.hasIndexingErrors) { + throw new Error("Subgraph has indexing errors"); + } + return data; + }); +} +function getStatistic(_0) { + return __async$b(this, arguments, function* ({ + graphApi, + subgraphName, + currency, + amount, + fetchDataOptions: fetchDataOptions2 + }) { + try { + const { + deposits, + _meta: { + block: { number: lastSyncBlock } + } + } = yield queryGraph({ + graphApi, + subgraphName, + query: GET_STATISTIC, + variables: { + currency, + first: 10, + orderBy: "index", + orderDirection: "desc", + amount + }, + fetchDataOptions: fetchDataOptions2 + }); + const events = deposits.map((e) => ({ + timestamp: Number(e.timestamp), + leafIndex: Number(e.index), + blockNumber: Number(e.blockNumber) + })).reverse(); + const [lastEvent] = events.slice(-1); + return { + events, + lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock + }; + } catch (err) { + console.log("Error from getStatistic query"); + console.log(err); + return { + events: [], + lastSyncBlock: null + }; + } + }); +} +function getMeta(_0) { + return __async$b(this, arguments, function* ({ graphApi, subgraphName, fetchDataOptions: fetchDataOptions2 }) { + try { + const { + _meta: { + block: { number: lastSyncBlock }, + hasIndexingErrors + } + } = yield queryGraph({ + graphApi, + subgraphName, + query: _META, + fetchDataOptions: fetchDataOptions2 + }); + return { + lastSyncBlock, + hasIndexingErrors + }; + } catch (err) { + console.log("Error from getMeta query"); + console.log(err); + return { + lastSyncBlock: null, + hasIndexingErrors: null + }; + } + }); +} +function getRegisters({ + graphApi, + subgraphName, + fromBlock, + fetchDataOptions: fetchDataOptions2 +}) { + return queryGraph({ + graphApi, + subgraphName, + query: GET_REGISTERED, + variables: { + first, + fromBlock + }, + fetchDataOptions: fetchDataOptions2 + }); +} +function getAllRegisters(_0) { + return __async$b(this, arguments, function* ({ + graphApi, + subgraphName, + fromBlock, + fetchDataOptions: fetchDataOptions2, + onProgress + }) { + try { + const events = []; + let lastSyncBlock = fromBlock; + while (true) { + let { + relayers: result2, + _meta: { + // eslint-disable-next-line prefer-const + block: { number: currentBlock } + } + } = yield getRegisters({ graphApi, subgraphName, fromBlock, fetchDataOptions: fetchDataOptions2 }); + lastSyncBlock = currentBlock; + if (isEmptyArray(result2)) { + break; + } + const [firstEvent] = result2; + const [lastEvent] = result2.slice(-1); + if (typeof onProgress === "function") { + onProgress({ + type: "Registers", + fromBlock: Number(firstEvent.blockRegistration), + toBlock: Number(lastEvent.blockRegistration), + count: result2.length + }); + } + if (result2.length < 900) { + events.push(...result2); + break; + } + result2 = result2.filter(({ blockRegistration }) => blockRegistration !== lastEvent.blockRegistration); + fromBlock = Number(lastEvent.blockRegistration); + events.push(...result2); + } + if (!events.length) { + return { + events: [], + lastSyncBlock + }; + } + const result = events.map(({ id, address, ensName, blockRegistration }) => { + const [transactionHash, logIndex] = id.split("-"); + return { + blockNumber: Number(blockRegistration), + logIndex: Number(logIndex), + transactionHash, + ensName, + relayerAddress: getAddress(address) + }; + }); + return { + events: result, + lastSyncBlock + }; + } catch (err) { + console.log("Error from getAllRegisters query"); + console.log(err); + return { events: [], lastSyncBlock: fromBlock }; + } + }); +} +function getDeposits({ + graphApi, + subgraphName, + currency, + amount, + fromBlock, + fetchDataOptions: fetchDataOptions2 +}) { + return queryGraph({ + graphApi, + subgraphName, + query: GET_DEPOSITS, + variables: { + currency, + amount, + first, + fromBlock + }, + fetchDataOptions: fetchDataOptions2 + }); +} +function getAllDeposits(_0) { + return __async$b(this, arguments, function* ({ + graphApi, + subgraphName, + currency, + amount, + fromBlock, + fetchDataOptions: fetchDataOptions2, + onProgress + }) { + try { + const events = []; + let lastSyncBlock = fromBlock; + while (true) { + let { + deposits: result2, + _meta: { + // eslint-disable-next-line prefer-const + block: { number: currentBlock } + } + } = yield getDeposits({ graphApi, subgraphName, currency, amount, fromBlock, fetchDataOptions: fetchDataOptions2 }); + lastSyncBlock = currentBlock; + if (isEmptyArray(result2)) { + break; + } + const [firstEvent] = result2; + const [lastEvent2] = result2.slice(-1); + if (typeof onProgress === "function") { + onProgress({ + type: "Deposits", + fromBlock: Number(firstEvent.blockNumber), + toBlock: Number(lastEvent2.blockNumber), + count: result2.length + }); + } + if (result2.length < 900) { + events.push(...result2); + break; + } + result2 = result2.filter(({ blockNumber }) => blockNumber !== lastEvent2.blockNumber); + fromBlock = Number(lastEvent2.blockNumber); + events.push(...result2); + } + if (!events.length) { + return { + events: [], + lastSyncBlock + }; + } + const result = events.map(({ id, blockNumber, commitment, index, timestamp, from }) => { + const [transactionHash, logIndex] = id.split("-"); + return { + blockNumber: Number(blockNumber), + logIndex: Number(logIndex), + transactionHash, + commitment, + leafIndex: Number(index), + timestamp: Number(timestamp), + from: getAddress(from) + }; + }); + const [lastEvent] = result.slice(-1); + return { + events: result, + lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock + }; + } catch (err) { + console.log("Error from getAllDeposits query"); + console.log(err); + return { + events: [], + lastSyncBlock: fromBlock + }; + } + }); +} +function getWithdrawals({ + graphApi, + subgraphName, + currency, + amount, + fromBlock, + fetchDataOptions: fetchDataOptions2 +}) { + return queryGraph({ + graphApi, + subgraphName, + query: GET_WITHDRAWALS, + variables: { + currency, + amount, + first, + fromBlock + }, + fetchDataOptions: fetchDataOptions2 + }); +} +function getAllWithdrawals(_0) { + return __async$b(this, arguments, function* ({ + graphApi, + subgraphName, + currency, + amount, + fromBlock, + fetchDataOptions: fetchDataOptions2, + onProgress + }) { + try { + const events = []; + let lastSyncBlock = fromBlock; + while (true) { + let { + withdrawals: result2, + _meta: { + // eslint-disable-next-line prefer-const + block: { number: currentBlock } + } + } = yield getWithdrawals({ graphApi, subgraphName, currency, amount, fromBlock, fetchDataOptions: fetchDataOptions2 }); + lastSyncBlock = currentBlock; + if (isEmptyArray(result2)) { + break; + } + const [firstEvent] = result2; + const [lastEvent2] = result2.slice(-1); + if (typeof onProgress === "function") { + onProgress({ + type: "Withdrawals", + fromBlock: Number(firstEvent.blockNumber), + toBlock: Number(lastEvent2.blockNumber), + count: result2.length + }); + } + if (result2.length < 900) { + events.push(...result2); + break; + } + result2 = result2.filter(({ blockNumber }) => blockNumber !== lastEvent2.blockNumber); + fromBlock = Number(lastEvent2.blockNumber); + events.push(...result2); + } + if (!events.length) { + return { + events: [], + lastSyncBlock + }; + } + const result = events.map(({ id, blockNumber, nullifier, to, fee, timestamp }) => { + const [transactionHash, logIndex] = id.split("-"); + return { + blockNumber: Number(blockNumber), + logIndex: Number(logIndex), + transactionHash, + nullifierHash: nullifier, + to: getAddress(to), + fee, + timestamp: Number(timestamp) + }; + }); + const [lastEvent] = result.slice(-1); + return { + events: result, + lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock + }; + } catch (err) { + console.log("Error from getAllWithdrawals query"); + console.log(err); + return { + events: [], + lastSyncBlock: fromBlock + }; + } + }); +} +function getNoteAccounts(_0) { + return __async$b(this, arguments, function* ({ + graphApi, + subgraphName, + address, + fetchDataOptions: fetchDataOptions2 + }) { + try { + const { + noteAccounts: events, + _meta: { + block: { number: lastSyncBlock } + } + } = yield queryGraph({ + graphApi, + subgraphName, + query: GET_NOTE_ACCOUNTS, + variables: { + address + }, + fetchDataOptions: fetchDataOptions2 + }); + return { + events, + lastSyncBlock + }; + } catch (err) { + console.log("Error from getNoteAccounts query"); + console.log(err); + return { + events: [], + lastSyncBlock: null + }; + } + }); +} +function getEncryptedNotes({ + graphApi, + subgraphName, + fromBlock, + fetchDataOptions: fetchDataOptions2 +}) { + return queryGraph({ + graphApi, + subgraphName, + query: GET_ENCRYPTED_NOTES, + variables: { + first, + fromBlock + }, + fetchDataOptions: fetchDataOptions2 + }); +} +function getAllEncryptedNotes(_0) { + return __async$b(this, arguments, function* ({ + graphApi, + subgraphName, + fromBlock, + fetchDataOptions: fetchDataOptions2, + onProgress + }) { + try { + const events = []; + let lastSyncBlock = fromBlock; + while (true) { + let { + encryptedNotes: result2, + _meta: { + // eslint-disable-next-line prefer-const + block: { number: currentBlock } + } + } = yield getEncryptedNotes({ graphApi, subgraphName, fromBlock, fetchDataOptions: fetchDataOptions2 }); + lastSyncBlock = currentBlock; + if (isEmptyArray(result2)) { + break; + } + const [firstEvent] = result2; + const [lastEvent2] = result2.slice(-1); + if (typeof onProgress === "function") { + onProgress({ + type: "EncryptedNotes", + fromBlock: Number(firstEvent.blockNumber), + toBlock: Number(lastEvent2.blockNumber), + count: result2.length + }); + } + if (result2.length < 900) { + events.push(...result2); + break; + } + result2 = result2.filter(({ blockNumber }) => blockNumber !== lastEvent2.blockNumber); + fromBlock = Number(lastEvent2.blockNumber); + events.push(...result2); + } + if (!events.length) { + return { + events: [], + lastSyncBlock + }; + } + const result = events.map((e) => ({ + blockNumber: Number(e.blockNumber), + logIndex: Number(e.index), + transactionHash: e.transactionHash, + encryptedNote: e.encryptedNote + })); + const [lastEvent] = result.slice(-1); + return { + events: result, + lastSyncBlock: lastEvent && lastEvent.blockNumber >= lastSyncBlock ? lastEvent.blockNumber + 1 : lastSyncBlock + }; + } catch (err) { + console.log("Error from getAllEncryptedNotes query"); + console.log(err); + return { + events: [], + lastSyncBlock: fromBlock + }; + } + }); +} + +var graph = /*#__PURE__*/Object.freeze({ + __proto__: null, + GET_DEPOSITS: GET_DEPOSITS, + GET_ENCRYPTED_NOTES: GET_ENCRYPTED_NOTES, + GET_NOTE_ACCOUNTS: GET_NOTE_ACCOUNTS, + GET_REGISTERED: GET_REGISTERED, + GET_STATISTIC: GET_STATISTIC, + GET_WITHDRAWALS: GET_WITHDRAWALS, + _META: _META, + getAllDeposits: getAllDeposits, + getAllEncryptedNotes: getAllEncryptedNotes, + getAllRegisters: getAllRegisters, + getAllWithdrawals: getAllWithdrawals, + getDeposits: getDeposits, + getEncryptedNotes: getEncryptedNotes, + getMeta: getMeta, + getNoteAccounts: getNoteAccounts, + getRegisters: getRegisters, + getStatistic: getStatistic, + getWithdrawals: getWithdrawals, + queryGraph: queryGraph +}); + +var __async$a = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +class BatchBlockService { + constructor({ + provider, + onProgress, + concurrencySize = 10, + batchSize = 10, + shouldRetry = true, + retryMax = 5, + retryOn = 500 + }) { + this.provider = provider; + this.onProgress = onProgress; + this.concurrencySize = concurrencySize; + this.batchSize = batchSize; + this.shouldRetry = shouldRetry; + this.retryMax = retryMax; + this.retryOn = retryOn; + } + getBlock(blockTag) { + return __async$a(this, null, function* () { + const blockObject = yield this.provider.getBlock(blockTag); + if (!blockObject) { + const errMsg = `No block for ${blockTag}`; + throw new Error(errMsg); + } + return blockObject; + }); + } + createBatchRequest(batchArray) { + return batchArray.map((blocks, index) => __async$a(this, null, function* () { + yield sleep(20 * index); + return (() => __async$a(this, null, function* () { + let retries = 0; + let err; + while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) { + try { + return yield Promise.all(blocks.map((b) => this.getBlock(b))); + } catch (e) { + retries++; + err = e; + yield sleep(this.retryOn); + } + } + throw err; + }))(); + })); + } + getBatchBlocks(blocks) { + return __async$a(this, null, function* () { + let blockCount = 0; + const results = []; + for (const chunks of chunk(blocks, this.concurrencySize * this.batchSize)) { + const chunksResult = (yield Promise.all(this.createBatchRequest(chunk(chunks, this.batchSize)))).flat(); + results.push(...chunksResult); + blockCount += chunks.length; + if (typeof this.onProgress === "function") { + this.onProgress({ + percentage: blockCount / blocks.length, + currentIndex: blockCount, + totalIndex: blocks.length + }); + } + } + return results; + }); + } +} +class BatchTransactionService { + constructor({ + provider, + onProgress, + concurrencySize = 10, + batchSize = 10, + shouldRetry = true, + retryMax = 5, + retryOn = 500 + }) { + this.provider = provider; + this.onProgress = onProgress; + this.concurrencySize = concurrencySize; + this.batchSize = batchSize; + this.shouldRetry = shouldRetry; + this.retryMax = retryMax; + this.retryOn = retryOn; + } + getTransaction(txHash) { + return __async$a(this, null, function* () { + const txObject = yield this.provider.getTransaction(txHash); + if (!txObject) { + const errMsg = `No transaction for ${txHash}`; + throw new Error(errMsg); + } + return txObject; + }); + } + createBatchRequest(batchArray) { + return batchArray.map((txs, index) => __async$a(this, null, function* () { + yield sleep(20 * index); + return (() => __async$a(this, null, function* () { + let retries = 0; + let err; + while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) { + try { + return yield Promise.all(txs.map((tx) => this.getTransaction(tx))); + } catch (e) { + retries++; + err = e; + yield sleep(this.retryOn); + } + } + throw err; + }))(); + })); + } + getBatchTransactions(txs) { + return __async$a(this, null, function* () { + let txCount = 0; + const results = []; + for (const chunks of chunk(txs, this.concurrencySize * this.batchSize)) { + const chunksResult = (yield Promise.all(this.createBatchRequest(chunk(chunks, this.batchSize)))).flat(); + results.push(...chunksResult); + txCount += chunks.length; + if (typeof this.onProgress === "function") { + this.onProgress({ percentage: txCount / txs.length, currentIndex: txCount, totalIndex: txs.length }); + } + } + return results; + }); + } +} +class BatchEventsService { + constructor({ + provider, + contract, + onProgress, + concurrencySize = 10, + blocksPerRequest = 2e3, + shouldRetry = true, + retryMax = 5, + retryOn = 500 + }) { + this.provider = provider; + this.contract = contract; + this.onProgress = onProgress; + this.concurrencySize = concurrencySize; + this.blocksPerRequest = blocksPerRequest; + this.shouldRetry = shouldRetry; + this.retryMax = retryMax; + this.retryOn = retryOn; + } + getPastEvents(_0) { + return __async$a(this, arguments, function* ({ fromBlock, toBlock, type }) { + let err; + let retries = 0; + while (!this.shouldRetry && retries === 0 || this.shouldRetry && retries < this.retryMax) { + try { + return yield this.contract.queryFilter(type, fromBlock, toBlock); + } catch (e) { + err = e; + retries++; + if (e.message.includes("after last accepted block")) { + const acceptedBlock = parseInt(e.message.split("after last accepted block ")[1]); + toBlock = acceptedBlock; + } + yield sleep(this.retryOn); + } + } + throw err; + }); + } + createBatchRequest(batchArray) { + return batchArray.map((event, index) => __async$a(this, null, function* () { + yield sleep(20 * index); + return this.getPastEvents(event); + })); + } + getBatchEvents(_0) { + return __async$a(this, arguments, function* ({ fromBlock, toBlock, type = "*" }) { + if (!toBlock) { + toBlock = yield this.provider.getBlockNumber(); + } + const eventsToSync = []; + for (let i = fromBlock; i < toBlock; i += this.blocksPerRequest) { + const j = i + this.blocksPerRequest - 1 > toBlock ? toBlock : i + this.blocksPerRequest - 1; + eventsToSync.push({ fromBlock: i, toBlock: j, type }); + } + const events = []; + const eventChunk = chunk(eventsToSync, this.concurrencySize); + let chunkCount = 0; + for (const chunk2 of eventChunk) { + chunkCount++; + const fetchedEvents = (yield Promise.all(this.createBatchRequest(chunk2))).flat(); + events.push(...fetchedEvents); + if (typeof this.onProgress === "function") { + this.onProgress({ + percentage: chunkCount / eventChunk.length, + type, + fromBlock: chunk2[0].fromBlock, + toBlock: chunk2[chunk2.length - 1].toBlock, + count: fetchedEvents.length + }); + } + } + return events; + }); + } +} + +var __defProp$1 = Object.defineProperty; +var __defProps$1 = Object.defineProperties; +var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp$1 = Object.prototype.hasOwnProperty; +var __propIsEnum$1 = Object.prototype.propertyIsEnumerable; +var __reflectGet = Reflect.get; +var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues$1 = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp$1.call(b, prop)) + __defNormalProp$1(a, prop, b[prop]); + if (__getOwnPropSymbols$1) + for (var prop of __getOwnPropSymbols$1(b)) { + if (__propIsEnum$1.call(b, prop)) + __defNormalProp$1(a, prop, b[prop]); + } + return a; +}; +var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b)); +var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj); +var __async$9 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +const DEPOSIT = "deposit"; +const WITHDRAWAL = "withdrawal"; +class BaseEventsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + contract, + type = "", + deployedBlock = 0, + fetchDataOptions: fetchDataOptions2 + }) { + this.netId = netId; + this.provider = provider; + this.graphApi = graphApi; + this.subgraphName = subgraphName; + this.fetchDataOptions = fetchDataOptions2; + this.contract = contract; + this.type = type; + this.deployedBlock = deployedBlock; + this.batchEventsService = new BatchEventsService({ + provider, + contract, + onProgress: this.updateEventProgress + }); + } + getInstanceName() { + return ""; + } + getType() { + return this.type || ""; + } + getGraphMethod() { + return ""; + } + getGraphParams() { + return { + graphApi: this.graphApi || "", + subgraphName: this.subgraphName || "", + fetchDataOptions: this.fetchDataOptions, + onProgress: this.updateGraphProgress + }; + } + /* eslint-disable @typescript-eslint/no-unused-vars */ + updateEventProgress({ percentage, type, fromBlock, toBlock, count }) { + } + updateBlockProgress({ percentage, currentIndex, totalIndex }) { + } + updateTransactionProgress({ percentage, currentIndex, totalIndex }) { + } + updateGraphProgress({ type, fromBlock, toBlock, count }) { + } + /* eslint-enable @typescript-eslint/no-unused-vars */ + formatEvents(events) { + return __async$9(this, null, function* () { + return yield new Promise((resolve) => resolve(events)); + }); + } + /** + * Get saved or cached events + */ + getEventsFromDB() { + return __async$9(this, null, function* () { + return { + events: [], + lastBlock: null + }; + }); + } + getEventsFromCache() { + return __async$9(this, null, function* () { + return { + events: [], + lastBlock: null + }; + }); + } + getSavedEvents() { + return __async$9(this, null, function* () { + let cachedEvents = yield this.getEventsFromDB(); + if (!cachedEvents || !cachedEvents.events.length) { + cachedEvents = yield this.getEventsFromCache(); + } + return cachedEvents; + }); + } + /** + * Get latest events + */ + getEventsFromGraph(_0) { + return __async$9(this, arguments, function* ({ + fromBlock, + methodName = "" + }) { + if (!this.graphApi || !this.subgraphName) { + return { + events: [], + lastBlock: fromBlock + }; + } + const { events, lastSyncBlock } = yield graph[methodName || this.getGraphMethod()](__spreadValues$1({ + fromBlock + }, this.getGraphParams())); + return { + events, + lastBlock: lastSyncBlock + }; + }); + } + getEventsFromRpc(_0) { + return __async$9(this, arguments, function* ({ + fromBlock, + toBlock + }) { + try { + if (!toBlock) { + toBlock = yield this.provider.getBlockNumber(); + } + if (fromBlock >= toBlock) { + return { + events: [], + lastBlock: toBlock + }; + } + this.updateEventProgress({ percentage: 0, type: this.getType() }); + const events = yield this.formatEvents( + yield this.batchEventsService.getBatchEvents({ fromBlock, toBlock, type: this.getType() }) + ); + if (!events.length) { + return { + events, + lastBlock: toBlock + }; + } + return { + events, + lastBlock: toBlock + }; + } catch (err) { + console.log(err); + return { + events: [], + lastBlock: fromBlock + }; + } + }); + } + getLatestEvents(_0) { + return __async$9(this, arguments, function* ({ fromBlock }) { + const allEvents = []; + const graphEvents = yield this.getEventsFromGraph({ fromBlock }); + const lastSyncBlock = graphEvents.lastBlock && graphEvents.lastBlock >= fromBlock ? graphEvents.lastBlock : fromBlock; + const rpcEvents = yield this.getEventsFromRpc({ fromBlock: lastSyncBlock }); + allEvents.push(...graphEvents.events); + allEvents.push(...rpcEvents.events); + const lastBlock = rpcEvents ? rpcEvents.lastBlock : allEvents[allEvents.length - 1] ? allEvents[allEvents.length - 1].blockNumber : fromBlock; + return { + events: allEvents, + lastBlock + }; + }); + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + validateEvents({ events, lastBlock }) { + } + /** + * Handle saving events + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + saveEvents(_0) { + return __async$9(this, arguments, function* ({ events, lastBlock }) { + }); + } + /** + * Trigger saving and receiving latest events + */ + updateEvents() { + return __async$9(this, null, function* () { + const savedEvents = yield this.getSavedEvents(); + let fromBlock = this.deployedBlock; + if (savedEvents && savedEvents.lastBlock) { + fromBlock = savedEvents.lastBlock + 1; + } + const newEvents = yield this.getLatestEvents({ fromBlock }); + const eventSet = /* @__PURE__ */ new Set(); + let allEvents = []; + allEvents.push(...savedEvents.events); + allEvents.push(...newEvents.events); + allEvents = allEvents.sort((a, b) => { + if (a.blockNumber === b.blockNumber) { + return a.logIndex - b.logIndex; + } + return a.blockNumber - b.blockNumber; + }).filter(({ transactionHash, logIndex }) => { + const eventKey = `${transactionHash}_${logIndex}`; + const hasEvent = eventSet.has(eventKey); + eventSet.add(eventKey); + return !hasEvent; + }); + const lastBlock = newEvents ? newEvents.lastBlock : allEvents[allEvents.length - 1] ? allEvents[allEvents.length - 1].blockNumber : null; + this.validateEvents({ events: allEvents, lastBlock }); + yield this.saveEvents({ events: allEvents, lastBlock }); + return { + events: allEvents, + lastBlock + }; + }); + } +} +class BaseDepositsService extends BaseEventsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Tornado, + type, + amount, + currency, + deployedBlock, + fetchDataOptions: fetchDataOptions2 + }) { + super({ netId, provider, graphApi, subgraphName, contract: Tornado, type, deployedBlock, fetchDataOptions: fetchDataOptions2 }); + this.amount = amount; + this.currency = currency; + this.batchTransactionService = new BatchTransactionService({ + provider, + onProgress: this.updateTransactionProgress + }); + this.batchBlockService = new BatchBlockService({ + provider, + onProgress: this.updateBlockProgress + }); + } + getInstanceName() { + return `${this.getType().toLowerCase()}s_${this.netId}_${this.currency}_${this.amount}`; + } + getGraphMethod() { + return `getAll${this.getType()}s`; + } + getGraphParams() { + return { + graphApi: this.graphApi || "", + subgraphName: this.subgraphName || "", + amount: this.amount, + currency: this.currency, + fetchDataOptions: this.fetchDataOptions, + onProgress: this.updateGraphProgress + }; + } + formatEvents(events) { + return __async$9(this, null, function* () { + const type = this.getType().toLowerCase(); + if (type === DEPOSIT) { + const formattedEvents = events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { + const { commitment, leafIndex, timestamp } = args; + return { + blockNumber, + logIndex, + transactionHash, + commitment, + leafIndex: Number(leafIndex), + timestamp: Number(timestamp) + }; + }); + const txs = yield this.batchTransactionService.getBatchTransactions([ + ...new Set(formattedEvents.map(({ transactionHash }) => transactionHash)) + ]); + return formattedEvents.map((event) => { + const { from } = txs.find(({ hash }) => hash === event.transactionHash); + return __spreadProps$1(__spreadValues$1({}, event), { + from + }); + }); + } else { + const formattedEvents = events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { + const { nullifierHash, to, fee } = args; + return { + blockNumber, + logIndex, + transactionHash, + nullifierHash: String(nullifierHash), + to: getAddress(to), + fee: String(fee) + }; + }); + const blocks = yield this.batchBlockService.getBatchBlocks([ + ...new Set(formattedEvents.map(({ blockNumber }) => blockNumber)) + ]); + return formattedEvents.map((event) => { + const { timestamp } = blocks.find(({ number }) => number === event.blockNumber); + return __spreadProps$1(__spreadValues$1({}, event), { + timestamp + }); + }); + } + }); + } + validateEvents({ events }) { + if (events.length && this.getType().toLowerCase() === DEPOSIT) { + const lastEvent = events[events.length - 1]; + if (lastEvent.leafIndex !== events.length - 1) { + const errMsg = `Deposit events invalid wants ${events.length - 1} leafIndex have ${lastEvent.leafIndex}`; + throw new Error(errMsg); + } + } + } +} +class BaseEncryptedNotesService extends BaseEventsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Router, + deployedBlock, + fetchDataOptions: fetchDataOptions2 + }) { + super({ netId, provider, graphApi, subgraphName, contract: Router, deployedBlock, fetchDataOptions: fetchDataOptions2 }); + } + getInstanceName() { + return `encrypted_notes_${this.netId}`; + } + getType() { + return "EncryptedNote"; + } + getGraphMethod() { + return "getAllEncryptedNotes"; + } + formatEvents(events) { + return __async$9(this, null, function* () { + return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { + const { encryptedNote } = args; + if (encryptedNote) { + const eventObjects = { + blockNumber, + logIndex, + transactionHash + }; + return __spreadProps$1(__spreadValues$1({}, eventObjects), { + encryptedNote + }); + } + }).filter((e) => e); + }); + } +} +class BaseGovernanceService extends BaseEventsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Governance, + deployedBlock, + fetchDataOptions: fetchDataOptions2 + }) { + super({ netId, provider, graphApi, subgraphName, contract: Governance, deployedBlock, fetchDataOptions: fetchDataOptions2 }); + this.batchTransactionService = new BatchTransactionService({ + provider, + onProgress: this.updateTransactionProgress + }); + } + getInstanceName() { + return `governance_${this.netId}`; + } + getType() { + return "*"; + } + getGraphMethod() { + return "governanceEvents"; + } + formatEvents(events) { + return __async$9(this, null, function* () { + const formattedEvents = events.map(({ blockNumber, index: logIndex, transactionHash, args, eventName: event }) => { + const eventObjects = { + blockNumber, + logIndex, + transactionHash, + event + }; + if (event === "ProposalCreated") { + const { id, proposer, target, startTime, endTime, description } = args; + return __spreadProps$1(__spreadValues$1({}, eventObjects), { + id, + proposer, + target, + startTime, + endTime, + description + }); + } + if (event === "Voted") { + const { proposalId, voter, support, votes } = args; + return __spreadProps$1(__spreadValues$1({}, eventObjects), { + proposalId, + voter, + support, + votes + }); + } + if (event === "Delegated") { + const { account, to: delegateTo } = args; + return __spreadProps$1(__spreadValues$1({}, eventObjects), { + account, + delegateTo + }); + } + if (event === "Undelegated") { + const { account, from: delegateFrom } = args; + return __spreadProps$1(__spreadValues$1({}, eventObjects), { + account, + delegateFrom + }); + } + }).filter((e) => e); + const votedEvents = formattedEvents.map((event, index) => __spreadProps$1(__spreadValues$1({}, event), { index })).filter(({ event }) => event === "Voted"); + if (votedEvents.length) { + this.updateTransactionProgress({ percentage: 0 }); + const txs = yield this.batchTransactionService.getBatchTransactions([ + ...new Set(votedEvents.map(({ transactionHash }) => transactionHash)) + ]); + votedEvents.forEach((event) => { + let { data: input, from } = txs.find((t) => t.hash === event.transactionHash); + if (!input || input.length > 2048) { + input = ""; + } + formattedEvents[event.index].from = from; + formattedEvents[event.index].input = input; + }); + } + return formattedEvents; + }); + } + getEventsFromGraph(_0) { + return __async$9(this, arguments, function* ({ fromBlock }) { + if (!this.graphApi || this.graphApi.includes("api.thegraph.com")) { + return { + events: [], + lastBlock: fromBlock + }; + } + return __superGet(BaseGovernanceService.prototype, this, "getEventsFromGraph").call(this, { fromBlock }); + }); + } +} +class BaseRegistryService extends BaseEventsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + RelayerRegistry, + deployedBlock, + fetchDataOptions: fetchDataOptions2 + }) { + super({ netId, provider, graphApi, subgraphName, contract: RelayerRegistry, deployedBlock, fetchDataOptions: fetchDataOptions2 }); + } + getInstanceName() { + return `registered_${this.netId}`; + } + // Name of type used for events + getType() { + return "RelayerRegistered"; + } + // Name of method used for graph + getGraphMethod() { + return "getAllRegisters"; + } + formatEvents(events) { + return __async$9(this, null, function* () { + return events.map(({ blockNumber, index: logIndex, transactionHash, args }) => { + const eventObjects = { + blockNumber, + logIndex, + transactionHash + }; + return __spreadProps$1(__spreadValues$1({}, eventObjects), { + ensName: args.ensName, + relayerAddress: args.relayerAddress + }); + }); + }); + } + fetchRelayers() { + return __async$9(this, null, function* () { + return (yield this.updateEvents()).events; + }); + } +} + +var __async$8 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +function existsAsync(fileOrDir) { + return __async$8(this, null, function* () { + try { + yield stat(fileOrDir); + return true; + } catch (e) { + return false; + } + }); +} +function zipAsync(file) { + return new Promise((res, rej) => { + zip(file, { mtime: /* @__PURE__ */ new Date("1/1/1980") }, (err, data) => { + if (err) { + rej(err); + return; + } + res(data); + }); + }); +} +function unzipAsync(data) { + return new Promise((res, rej) => { + unzip(data, {}, (err, data2) => { + if (err) { + rej(err); + return; + } + res(data2); + }); + }); +} +function saveEvents(_0) { + return __async$8(this, arguments, function* ({ + name, + userDirectory, + events + }) { + const fileName = `${name}.json`.toLowerCase(); + const filePath = path.join(userDirectory, fileName); + const stringEvents = JSON.stringify(events, null, 2) + "\n"; + const payload = yield zipAsync({ + [fileName]: new TextEncoder().encode(stringEvents) + }); + if (!(yield existsAsync(userDirectory))) { + yield mkdir(userDirectory, { recursive: true }); + } + yield writeFile(filePath + ".zip", payload); + yield writeFile(filePath, stringEvents); + }); +} +function loadSavedEvents(_0) { + return __async$8(this, arguments, function* ({ + name, + userDirectory, + deployedBlock + }) { + const filePath = path.join(userDirectory, `${name}.json`.toLowerCase()); + if (!(yield existsAsync(filePath))) { + return { + events: [], + lastBlock: null + }; + } + try { + const events = JSON.parse(yield readFile(filePath, { encoding: "utf8" })); + return { + events, + lastBlock: events && events.length ? events[events.length - 1].blockNumber : deployedBlock + }; + } catch (err) { + console.log("Method loadSavedEvents has error"); + console.log(err); + return { + events: [], + lastBlock: deployedBlock + }; + } + }); +} +function download(_0) { + return __async$8(this, arguments, function* ({ name, cacheDirectory }) { + const fileName = `${name}.json`.toLowerCase(); + const zipName = `${fileName}.zip`; + const zipPath = path.join(cacheDirectory, zipName); + const data = yield readFile(zipPath); + const { [fileName]: content } = yield unzipAsync(data); + return new TextDecoder().decode(content); + }); +} +function loadCachedEvents(_0) { + return __async$8(this, arguments, function* ({ + name, + cacheDirectory, + deployedBlock + }) { + try { + const module = yield download({ cacheDirectory, name }); + if (module) { + const events = JSON.parse(module); + const lastBlock = events && events.length ? events[events.length - 1].blockNumber : deployedBlock; + return { + events, + lastBlock + }; + } + return { + events: [], + lastBlock: deployedBlock + }; + } catch (err) { + console.log("Method loadCachedEvents has error"); + console.log(err); + return { + events: [], + lastBlock: deployedBlock + }; + } + }); +} + +var __async$7 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +class NodeDepositsService extends BaseDepositsService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Tornado, + type, + amount, + currency, + deployedBlock, + fetchDataOptions, + cacheDirectory, + userDirectory + }) { + super({ + netId, + provider, + graphApi, + subgraphName, + Tornado, + type, + amount, + currency, + deployedBlock, + fetchDataOptions + }); + this.cacheDirectory = cacheDirectory; + this.userDirectory = userDirectory; + } + updateEventProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} +`); + } + } + } + updateTransactionProgress({ currentIndex, totalIndex }) { + if (totalIndex) { + console.log(`Fetched ${currentIndex} deposit txs of ${totalIndex}`); + } + } + updateBlockProgress({ currentIndex, totalIndex }) { + if (totalIndex) { + console.log(`Fetched ${currentIndex} withdrawal blocks of ${totalIndex}`); + } + } + updateGraphProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events from graph node count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} +`); + } + } + } + getEventsFromDB() { + return __async$7(this, null, function* () { + if (!this.userDirectory) { + console.log( + "Updating events for", + this.amount, + this.currency.toUpperCase(), + `${this.getType().toLowerCase()}s +` + ); + console.log(`savedEvents count - ${0}`); + console.log(`savedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const savedEvents = yield loadSavedEvents({ + name: this.getInstanceName(), + userDirectory: this.userDirectory, + deployedBlock: this.deployedBlock + }); + console.log("Updating events for", this.amount, this.currency.toUpperCase(), `${this.getType().toLowerCase()}s +`); + console.log(`savedEvents count - ${savedEvents.events.length}`); + console.log(`savedEvents lastBlock - ${savedEvents.lastBlock} +`); + return savedEvents; + }); + } + getEventsFromCache() { + return __async$7(this, null, function* () { + if (!this.cacheDirectory) { + console.log(`cachedEvents count - ${0}`); + console.log(`cachedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const cachedEvents = yield loadCachedEvents({ + name: this.getInstanceName(), + cacheDirectory: this.cacheDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`cachedEvents count - ${cachedEvents.events.length}`); + console.log(`cachedEvents lastBlock - ${cachedEvents.lastBlock} +`); + return cachedEvents; + }); + } + saveEvents(_0) { + return __async$7(this, arguments, function* ({ events, lastBlock }) { + const instanceName = this.getInstanceName(); + console.log("\ntotalEvents count - ", events.length); + console.log( + `totalEvents lastBlock - ${events[events.length - 1] ? events[events.length - 1].blockNumber : lastBlock} +` + ); + const eventTable = new Table(); + eventTable.push( + [{ colSpan: 2, content: `${this.getType()}s`, hAlign: "center" }], + ["Instance", `${this.netId} chain ${this.amount} ${this.currency.toUpperCase()}`], + ["Anonymity set", `${events.length} equal user ${this.getType().toLowerCase()}s`], + [{ colSpan: 2, content: `Latest ${this.getType().toLowerCase()}s` }], + ...events.slice(events.length - 10).reverse().map(({ timestamp }, index) => { + const eventIndex = events.length - index; + const eventTime = moment.unix(timestamp).fromNow(); + return [eventIndex, eventTime]; + }) + ); + console.log(eventTable.toString() + "\n"); + if (this.userDirectory) { + yield saveEvents({ + name: instanceName, + userDirectory: this.userDirectory, + events + }); + } + }); + } +} +class NodeEncryptedNotesService extends BaseEncryptedNotesService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Router, + deployedBlock, + fetchDataOptions, + cacheDirectory, + userDirectory + }) { + super({ + netId, + provider, + graphApi, + subgraphName, + Router, + deployedBlock, + fetchDataOptions + }); + this.cacheDirectory = cacheDirectory; + this.userDirectory = userDirectory; + } + updateEventProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} +`); + } + } + } + updateGraphProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events from graph node count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} +`); + } + } + } + getEventsFromDB() { + return __async$7(this, null, function* () { + if (!this.userDirectory) { + console.log(`Updating events for ${this.netId} chain encrypted events +`); + console.log(`savedEvents count - ${0}`); + console.log(`savedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const savedEvents = yield loadSavedEvents({ + name: this.getInstanceName(), + userDirectory: this.userDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`Updating events for ${this.netId} chain encrypted events +`); + console.log(`savedEvents count - ${savedEvents.events.length}`); + console.log(`savedEvents lastBlock - ${savedEvents.lastBlock} +`); + return savedEvents; + }); + } + getEventsFromCache() { + return __async$7(this, null, function* () { + if (!this.cacheDirectory) { + console.log(`cachedEvents count - ${0}`); + console.log(`cachedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const cachedEvents = yield loadCachedEvents({ + name: this.getInstanceName(), + cacheDirectory: this.cacheDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`cachedEvents count - ${cachedEvents.events.length}`); + console.log(`cachedEvents lastBlock - ${cachedEvents.lastBlock} +`); + return cachedEvents; + }); + } + saveEvents(_0) { + return __async$7(this, arguments, function* ({ events, lastBlock }) { + const instanceName = this.getInstanceName(); + console.log("\ntotalEvents count - ", events.length); + console.log( + `totalEvents lastBlock - ${events[events.length - 1] ? events[events.length - 1].blockNumber : lastBlock} +` + ); + const eventTable = new Table(); + eventTable.push( + [{ colSpan: 2, content: "Encrypted Notes", hAlign: "center" }], + ["Network", `${this.netId} chain`], + ["Events", `${events.length} events`], + [{ colSpan: 2, content: "Latest events" }], + ...events.slice(events.length - 10).reverse().map(({ blockNumber }, index) => { + const eventIndex = events.length - index; + return [eventIndex, blockNumber]; + }) + ); + console.log(eventTable.toString() + "\n"); + if (this.userDirectory) { + yield saveEvents({ + name: instanceName, + userDirectory: this.userDirectory, + events + }); + } + }); + } +} +class NodeGovernanceService extends BaseGovernanceService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + Governance, + deployedBlock, + fetchDataOptions, + cacheDirectory, + userDirectory + }) { + super({ + netId, + provider, + graphApi, + subgraphName, + Governance, + deployedBlock, + fetchDataOptions + }); + this.cacheDirectory = cacheDirectory; + this.userDirectory = userDirectory; + } + updateEventProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} +`); + } + } + } + updateGraphProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events from graph node count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} +`); + } + } + } + updateTransactionProgress({ currentIndex, totalIndex }) { + if (totalIndex) { + console.log(`Fetched ${currentIndex} governance txs of ${totalIndex}`); + } + } + getEventsFromDB() { + return __async$7(this, null, function* () { + if (!this.userDirectory) { + console.log(`Updating events for ${this.netId} chain governance events +`); + console.log(`savedEvents count - ${0}`); + console.log(`savedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const savedEvents = yield loadSavedEvents({ + name: this.getInstanceName(), + userDirectory: this.userDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`Updating events for ${this.netId} chain governance events +`); + console.log(`savedEvents count - ${savedEvents.events.length}`); + console.log(`savedEvents lastBlock - ${savedEvents.lastBlock} +`); + return savedEvents; + }); + } + getEventsFromCache() { + return __async$7(this, null, function* () { + if (!this.cacheDirectory) { + console.log(`cachedEvents count - ${0}`); + console.log(`cachedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const cachedEvents = yield loadCachedEvents({ + name: this.getInstanceName(), + cacheDirectory: this.cacheDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`cachedEvents count - ${cachedEvents.events.length}`); + console.log(`cachedEvents lastBlock - ${cachedEvents.lastBlock} +`); + return cachedEvents; + }); + } + saveEvents(_0) { + return __async$7(this, arguments, function* ({ events, lastBlock }) { + const instanceName = this.getInstanceName(); + console.log("\ntotalEvents count - ", events.length); + console.log( + `totalEvents lastBlock - ${events[events.length - 1] ? events[events.length - 1].blockNumber : lastBlock} +` + ); + const eventTable = new Table(); + eventTable.push( + [{ colSpan: 2, content: "Governance Events", hAlign: "center" }], + ["Network", `${this.netId} chain`], + ["Events", `${events.length} events`], + [{ colSpan: 2, content: "Latest events" }], + ...events.slice(events.length - 10).reverse().map(({ blockNumber }, index) => { + const eventIndex = events.length - index; + return [eventIndex, blockNumber]; + }) + ); + console.log(eventTable.toString() + "\n"); + if (this.userDirectory) { + yield saveEvents({ + name: instanceName, + userDirectory: this.userDirectory, + events + }); + } + }); + } +} +class NodeRegistryService extends BaseRegistryService { + constructor({ + netId, + provider, + graphApi, + subgraphName, + RelayerRegistry, + deployedBlock, + fetchDataOptions, + cacheDirectory, + userDirectory + }) { + super({ + netId, + provider, + graphApi, + subgraphName, + RelayerRegistry, + deployedBlock, + fetchDataOptions + }); + this.cacheDirectory = cacheDirectory; + this.userDirectory = userDirectory; + } + updateEventProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from ${fromBlock} to ${toBlock} +`); + } + } + } + updateGraphProgress({ type, fromBlock, toBlock, count }) { + if (toBlock) { + console.log(`fromBlock - ${fromBlock}`); + console.log(`toBlock - ${toBlock}`); + if (count) { + console.log(`downloaded ${type} events from graph node count - ${count}`); + console.log("____________________________________________"); + console.log(`Fetched ${type} events from graph node ${fromBlock} to ${toBlock} +`); + } + } + } + getEventsFromDB() { + return __async$7(this, null, function* () { + if (!this.userDirectory) { + console.log(`Updating events for ${this.netId} chain registry events +`); + console.log(`savedEvents count - ${0}`); + console.log(`savedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const savedEvents = yield loadSavedEvents({ + name: this.getInstanceName(), + userDirectory: this.userDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`Updating events for ${this.netId} chain registry events +`); + console.log(`savedEvents count - ${savedEvents.events.length}`); + console.log(`savedEvents lastBlock - ${savedEvents.lastBlock} +`); + return savedEvents; + }); + } + getEventsFromCache() { + return __async$7(this, null, function* () { + if (!this.cacheDirectory) { + console.log(`cachedEvents count - ${0}`); + console.log(`cachedEvents lastBlock - ${this.deployedBlock} +`); + return { + events: [], + lastBlock: this.deployedBlock + }; + } + const cachedEvents = yield loadCachedEvents({ + name: this.getInstanceName(), + cacheDirectory: this.cacheDirectory, + deployedBlock: this.deployedBlock + }); + console.log(`cachedEvents count - ${cachedEvents.events.length}`); + console.log(`cachedEvents lastBlock - ${cachedEvents.lastBlock} +`); + return cachedEvents; + }); + } + saveEvents(_0) { + return __async$7(this, arguments, function* ({ events, lastBlock }) { + const instanceName = this.getInstanceName(); + console.log("\ntotalEvents count - ", events.length); + console.log( + `totalEvents lastBlock - ${events[events.length - 1] ? events[events.length - 1].blockNumber : lastBlock} +` + ); + const eventTable = new Table(); + eventTable.push( + [{ colSpan: 2, content: "Registered Relayers", hAlign: "center" }], + ["Network", `${this.netId} chain`], + ["Events", `${events.length} events`], + [{ colSpan: 2, content: "Latest events" }], + ...events.slice(events.length - 10).reverse().map(({ blockNumber }, index) => { + const eventIndex = events.length - index; + return [eventIndex, blockNumber]; + }) + ); + console.log(eventTable.toString() + "\n"); + if (this.userDirectory) { + yield saveEvents({ + name: instanceName, + userDirectory: this.userDirectory, + events + }); + } + }); + } +} + +const addressType = { type: "string", pattern: "^0x[a-fA-F0-9]{40}$" }; +const bnType = { type: "string", BN: true }; +const statusSchema = { + type: "object", + properties: { + rewardAccount: addressType, + gasPrices: { + type: "object", + properties: { + fast: { type: "number" }, + additionalProperties: { type: "number" } + }, + required: ["fast"] + }, + netId: { type: "integer" }, + tornadoServiceFee: { type: "number", maximum: 20, minimum: 0 }, + latestBlock: { type: "number" }, + version: { type: "string" }, + health: { + type: "object", + properties: { + status: { const: "true" }, + error: { type: "string" } + }, + required: ["status"] + }, + currentQueue: { type: "number" } + }, + required: ["rewardAccount", "instances", "netId", "tornadoServiceFee", "version", "health"] +}; +function getStatusSchema(netId, config) { + const { tokens, optionalTokens = [], nativeCurrency } = config; + const schema = JSON.parse(JSON.stringify(statusSchema)); + const instances = Object.keys(tokens).reduce( + (acc, token) => { + const { instanceAddress, tokenAddress, symbol, decimals, optionalInstances = [] } = tokens[token]; + const amounts = Object.keys(instanceAddress); + const instanceProperties = { + type: "object", + properties: { + instanceAddress: { + type: "object", + properties: amounts.reduce((acc2, cur) => { + acc2[cur] = addressType; + return acc2; + }, {}), + required: amounts.filter((amount) => !optionalInstances.includes(amount)) + }, + decimals: { enum: [decimals] } + }, + required: ["instanceAddress", "decimals"].concat( + tokenAddress ? ["tokenAddress"] : [], + symbol ? ["symbol"] : [] + ) + }; + if (tokenAddress) { + instanceProperties.properties.tokenAddress = addressType; + } + if (symbol) { + instanceProperties.properties.symbol = { enum: [symbol] }; + } + acc.properties[token] = instanceProperties; + if (!optionalTokens.includes(token)) { + acc.required.push(token); + } + return acc; + }, + { + type: "object", + properties: {}, + required: [] + } + ); + schema.properties.instances = instances; + if (Number(netId) === 1) { + const _tokens = Object.keys(tokens).filter((t) => t !== nativeCurrency); + const ethPrices = { + type: "object", + properties: _tokens.reduce((acc, token) => { + acc[token] = bnType; + return acc; + }, {}) + // required: _tokens + }; + schema.properties.ethPrices = ethPrices; + } + return schema; +} + +const jobsSchema = { + type: "object", + properties: { + error: { type: "string" }, + id: { type: "string" }, + type: { type: "string" }, + status: { type: "string" }, + contract: { type: "string" }, + proof: { type: "string" }, + args: { + type: "array", + items: { type: "string" } + }, + txHash: { type: "string" }, + confirmations: { type: "number" }, + failedReason: { type: "string" } + }, + required: ["id", "status"] +}; + +const ajv = new Ajv({ allErrors: true }); +ajv.addKeyword({ + keyword: "BN", + // eslint-disable-next-line @typescript-eslint/no-explicit-any + validate: (schema, data) => { + try { + BigInt(data); + return true; + } catch (e) { + return false; + } + }, + errors: true +}); + +var __async$6 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +class Pedersen { + constructor() { + this.pedersenPromise = this.initPedersen(); + } + initPedersen() { + return __async$6(this, null, function* () { + this.pedersenHash = yield buildPedersenHash(); + this.babyJub = this.pedersenHash.babyJub; + }); + } + unpackPoint(buffer) { + return __async$6(this, null, function* () { + var _a, _b; + yield this.pedersenPromise; + return (_b = this.babyJub) == null ? void 0 : _b.unpackPoint((_a = this.pedersenHash) == null ? void 0 : _a.hash(buffer)); + }); + } + toStringBuffer(buffer) { + var _a; + return (_a = this.babyJub) == null ? void 0 : _a.F.toString(buffer); + } +} +const pedersen = new Pedersen(); +function buffPedersenHash(buffer) { + return __async$6(this, null, function* () { + const [hash] = yield pedersen.unpackPoint(buffer); + return pedersen.toStringBuffer(hash); + }); +} + +var __async$5 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +function createDeposit(_0) { + return __async$5(this, arguments, function* ({ nullifier, secret }) { + const preimage = new Uint8Array([...leInt2Buff(nullifier), ...leInt2Buff(secret)]); + const noteHex = toFixedHex(bytesToBN(preimage), 62); + const commitment = BigInt(yield buffPedersenHash(preimage)); + const commitmentHex = toFixedHex(commitment); + const nullifierHash = BigInt(yield buffPedersenHash(leInt2Buff(nullifier))); + const nullifierHex = toFixedHex(nullifierHash); + return { + preimage, + noteHex, + commitment, + commitmentHex, + nullifierHash, + nullifierHex + }; + }); +} +class Deposit { + constructor({ + currency, + amount, + netId, + nullifier, + secret, + note, + noteHex, + invoice, + commitmentHex, + nullifierHex + }) { + this.currency = currency; + this.amount = amount; + this.netId = netId; + this.nullifier = nullifier; + this.secret = secret; + this.note = note; + this.noteHex = noteHex; + this.invoice = invoice; + this.commitmentHex = commitmentHex; + this.nullifierHex = nullifierHex; + } + toString() { + return JSON.stringify( + { + currency: this.currency, + amount: this.amount, + netId: this.netId, + nullifier: this.nullifier, + secret: this.secret, + note: this.note, + noteHex: this.noteHex, + invoice: this.invoice, + commitmentHex: this.commitmentHex, + nullifierHex: this.nullifierHex + }, + null, + 2 + ); + } + static createNote(_0) { + return __async$5(this, arguments, function* ({ currency, amount, netId, nullifier, secret }) { + if (!nullifier) { + nullifier = rBigInt(31); + } + if (!secret) { + secret = rBigInt(31); + } + const depositObject = yield createDeposit({ + nullifier, + secret + }); + const newDeposit = new Deposit({ + currency: currency.toLowerCase(), + amount, + netId: Number(netId), + note: `tornado-${currency.toLowerCase()}-${amount}-${netId}-${depositObject.noteHex}`, + noteHex: depositObject.noteHex, + invoice: `tornadoInvoice-${currency.toLowerCase()}-${amount}-${netId}-${depositObject.commitmentHex}`, + nullifier, + secret, + commitmentHex: depositObject.commitmentHex, + nullifierHex: depositObject.nullifierHex + }); + return newDeposit; + }); + } + static parseNote(noteString) { + return __async$5(this, null, function* () { + const noteRegex = new RegExp("tornado-(?\\w+)-(?[\\d.]+)-(?\\d+)-0x(?[0-9a-fA-F]{124})", "g"); + const match = noteRegex.exec(noteString); + if (!match) { + throw new Error("The note has invalid format"); + } + const matchGroup = match == null ? void 0 : match.groups; + const currency = matchGroup.currency.toLowerCase(); + const amount = matchGroup.amount; + const netId = Number(matchGroup.netId); + const bytes = bnToBytes("0x" + matchGroup.note); + const nullifier = BigInt(leBuff2Int(bytes.slice(0, 31)).toString()); + const secret = BigInt(leBuff2Int(bytes.slice(31, 62)).toString()); + const depositObject = yield createDeposit({ nullifier, secret }); + const invoice = `tornadoInvoice-${currency}-${amount}-${netId}-${depositObject.commitmentHex}`; + const newDeposit = new Deposit({ + currency, + amount, + netId, + note: noteString, + noteHex: depositObject.noteHex, + invoice, + nullifier, + secret, + commitmentHex: depositObject.commitmentHex, + nullifierHex: depositObject.nullifierHex + }); + return newDeposit; + }); + } +} +class Invoice { + constructor(invoiceString) { + const invoiceRegex = new RegExp("tornadoInvoice-(?\\w+)-(?[\\d.]+)-(?\\d+)-0x(?[0-9a-fA-F]{64})", "g"); + const match = invoiceRegex.exec(invoiceString); + if (!match) { + throw new Error("The note has invalid format"); + } + const matchGroup = match == null ? void 0 : match.groups; + const currency = matchGroup.currency.toLowerCase(); + const amount = matchGroup.amount; + const netId = Number(matchGroup.netId); + this.currency = currency; + this.amount = amount; + this.netId = netId; + this.commitment = "0x" + matchGroup.commitment; + this.invoice = invoiceString; + } + toString() { + return JSON.stringify( + { + currency: this.currency, + amount: this.amount, + netId: this.netId, + commitment: this.commitment, + invoice: this.invoice + }, + null, + 2 + ); + } +} + +const DUMMY_ADDRESS = "0x1111111111111111111111111111111111111111"; +const DUMMY_NONCE = "0x1111111111111111111111111111111111111111111111111111111111111111"; +const DUMMY_WITHDRAW_DATA = "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"; +function convertETHToTokenAmount(amountInWei, tokenPriceInWei, tokenDecimals = 18) { + const tokenDecimalsMultiplier = BigInt(10 ** Number(tokenDecimals)); + return BigInt(amountInWei) * tokenDecimalsMultiplier / BigInt(tokenPriceInWei); +} +class TornadoFeeOracle { + constructor(ovmGasPriceOracle) { + if (ovmGasPriceOracle) { + this.ovmGasPriceOracle = ovmGasPriceOracle; + } + } + /** + * Calculate L1 fee for op-stack chains + * + * This is required since relayers would pay the full transaction fees for users + */ + fetchL1OptimismFee(tx) { + if (!this.ovmGasPriceOracle) { + return new Promise((resolve) => resolve(BigInt(0))); + } + if (!tx) { + tx = { + type: 0, + gasLimit: 1e6, + nonce: Number(DUMMY_NONCE), + data: DUMMY_WITHDRAW_DATA, + gasPrice: parseUnits("1", "gwei"), + from: DUMMY_ADDRESS, + to: DUMMY_ADDRESS + }; + } + return this.ovmGasPriceOracle.getL1Fee.staticCall(Transaction.from(tx).unsignedSerialized); + } + /** + * We don't need to distinguish default refunds by tokens since most users interact with other defi protocols after withdrawal + * So we default with 1M gas which is enough for two or three swaps + * Using 30 gwei for default but it is recommended to supply cached gasPrice value from the UI + */ + defaultEthRefund(gasPrice, gasLimit) { + return (gasPrice ? BigInt(gasPrice) : parseUnits("30", "gwei")) * BigInt(gasLimit || 1e6); + } + /** + * Calculates token amount for required ethRefund purchases required to calculate fees + */ + calculateTokenAmount(ethRefund, tokenPriceInEth, tokenDecimals) { + return convertETHToTokenAmount(ethRefund, tokenPriceInEth, tokenDecimals); + } + /** + * Warning: For tokens you need to check if the fees are above denomination + * (Usually happens for small denomination pool or if the gas price is high) + */ + calculateRelayerFee({ + gasPrice, + gasLimit = 6e5, + l1Fee = 0, + denomination, + ethRefund = BigInt(0), + tokenPriceInWei, + tokenDecimals = 18, + relayerFeePercent = 0.33, + isEth = true, + premiumPercent = 20 + }) { + const gasCosts = BigInt(gasPrice) * BigInt(gasLimit) + BigInt(l1Fee); + const relayerFee = BigInt(denomination) * BigInt(Math.floor(1e4 * relayerFeePercent)) / BigInt(1e4 * 100); + if (isEth) { + return (gasCosts + relayerFee) * BigInt(premiumPercent ? 100 + premiumPercent : 100) / BigInt(100); + } + const feeInEth = gasCosts + BigInt(ethRefund); + return (convertETHToTokenAmount(feeInEth, tokenPriceInWei, tokenDecimals) + relayerFee) * BigInt(premiumPercent ? 100 + premiumPercent : 100) / BigInt(100); + } +} + +var __async$4 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +class Mimc { + constructor() { + this.mimcPromise = this.initMimc(); + } + initMimc() { + return __async$4(this, null, function* () { + this.sponge = yield buildMimcSponge(); + this.hash = (left, right) => { + var _a, _b; + return (_b = this.sponge) == null ? void 0 : _b.F.toString((_a = this.sponge) == null ? void 0 : _a.multiHash([BigInt(left), BigInt(right)])); + }; + }); + } + getHash() { + return __async$4(this, null, function* () { + yield this.mimcPromise; + return { + sponge: this.sponge, + hash: this.hash + }; + }); + } +} +const mimc = new Mimc(); + +var __async$3 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +class MerkleTreeService { + constructor({ + netId, + amount, + currency, + Tornado, + commitment, + merkleTreeHeight = 20, + emptyElement = "21663839004416932945382355908790599225266501822907911457504978515578255421292", + merkleWorkerPath + }) { + const instanceName = `${netId}_${currency}_${amount}`; + this.currency = currency; + this.amount = amount; + this.netId = Number(netId); + this.Tornado = Tornado; + this.instanceName = instanceName; + this.commitment = commitment; + this.merkleTreeHeight = merkleTreeHeight; + this.emptyElement = emptyElement; + this.merkleWorkerPath = merkleWorkerPath; + } + createTree(_0) { + return __async$3(this, arguments, function* ({ events }) { + const { hash: hashFunction } = yield mimc.getHash(); + if (this.merkleWorkerPath) { + console.log("Using merkleWorker\n"); + try { + if (isNode) { + const merkleWorkerPromise = new Promise((resolve, reject) => { + const worker = new Worker$1(this.merkleWorkerPath, { + workerData: { + merkleTreeHeight: this.merkleTreeHeight, + elements: events, + zeroElement: this.emptyElement + } + }); + worker.on("message", resolve); + worker.on("error", reject); + worker.on("exit", (code) => { + if (code !== 0) { + reject(new Error(`Worker stopped with exit code ${code}`)); + } + }); + }); + return MerkleTree.deserialize(JSON.parse(yield merkleWorkerPromise), hashFunction); + } else { + const merkleWorkerPromise = new Promise((resolve, reject) => { + const worker = new Worker(this.merkleWorkerPath); + worker.onmessage = (e) => { + resolve(e.data); + }; + worker.onerror = (e) => { + reject(e); + }; + worker.postMessage({ + merkleTreeHeight: this.merkleTreeHeight, + elements: events, + zeroElement: this.emptyElement + }); + }); + return MerkleTree.deserialize(JSON.parse(yield merkleWorkerPromise), hashFunction); + } + } catch (err) { + console.log("merkleWorker failed, falling back to synchronous merkle tree"); + console.log(err); + } + } + return new MerkleTree(this.merkleTreeHeight, events, { + zeroElement: this.emptyElement, + hashFunction + }); + }); + } + verifyTree(_0) { + return __async$3(this, arguments, function* ({ events }) { + console.log( + ` +Creating deposit tree for ${this.netId} ${this.amount} ${this.currency.toUpperCase()} would take a while +` + ); + console.time("Created tree in"); + const tree = yield this.createTree({ events: events.map(({ commitment }) => BigInt(commitment).toString()) }); + console.timeEnd("Created tree in"); + console.log(""); + const isKnownRoot = yield this.Tornado.isKnownRoot(toFixedHex(BigInt(tree.root))); + if (!isKnownRoot) { + const errMsg = `Deposit Event ${this.netId} ${this.amount} ${this.currency} is invalid`; + throw new Error(errMsg); + } + return tree; + }); + } +} + +const blockSyncInterval = 1e4; +const enabledChains = ["1", "10", "56", "100", "137", "42161", "43114", "11155111"]; +const theGraph = { + name: "Hosted Graph", + url: "https://api.thegraph.com" +}; +const tornado = { + name: "Tornado Subgraphs", + url: "https://tornadocash-rpc.com" +}; +const networkConfig = { + netId1: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 80, + fast: 50, + standard: 25, + low: 8 + }, + nativeCurrency: "eth", + currencyName: "ETH", + explorerUrl: { + tx: "https://etherscan.io/tx/", + address: "https://etherscan.io/address/", + block: "https://etherscan.io/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Ethereum Mainnet", + deployedBlock: 9116966, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com" + }, + chainnodes: { + name: "Tornado RPC", + url: "https://mainnet.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + mevblockerRPC: { + name: "MevblockerRPC", + url: "https://rpc.mevblocker.io" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/ethereum-mainnet" + }, + noderealRPC: { + name: "NodeReal RPC", + url: "https://eth-mainnet.nodereal.io/v1/1659dfb40aa24bbb8153a677b98064d7" + }, + notadegenRPC: { + name: "NotADegen RPC", + url: "https://rpc.notadegen.com/eth" + }, + keydonixRPC: { + name: "Keydonix RPC", + url: "https://ethereum.keydonix.com/v1/mainnet" + }, + oneRPC: { + name: "1RPC", + url: "https://1rpc.io/eth" + } + }, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + routerContract: "0xd90e2f925DA726b50C4Ed8D0Fb90Ad053324F31b", + registryContract: "0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2", + echoContract: "0x9B27DD5Bb15d42DC224FCD0B7caEbBe16161Df42", + aggregatorContract: "0xE8F47A78A6D52D317D0D2FFFac56739fE14D1b49", + reverseRecordsContract: "0x3671aE578E63FdF66ad4F3E12CC0c0d71Ac7510C", + tornadoSubgraph: "tornadocash/mainnet-tornado-subgraph", + registrySubgraph: "tornadocash/tornado-relayer-registry", + subgraphs: { + tornado, + theGraph + }, + tokens: { + eth: { + instanceAddress: { + "0.1": "0x12D66f87A04A9E220743712cE6d9bB1B5616B8Fc", + "1": "0x47CE0C6eD5B0Ce3d3A51fdb1C52DC66a7c3c2936", + "10": "0x910Cbd523D972eb0a6f4cAe4618aD62622b39DbF", + "100": "0xA160cdAB225685dA1d56aa342Ad8841c3b53f291" + }, + symbol: "ETH", + decimals: 18 + }, + dai: { + instanceAddress: { + "100": "0xD4B88Df4D29F5CedD6857912842cff3b20C8Cfa3", + "1000": "0xFD8610d20aA15b7B2E3Be39B396a1bC3516c7144", + "10000": "0x07687e702b410Fa43f4cB4Af7FA097918ffD2730", + "100000": "0x23773E65ed146A459791799d01336DB287f25334" + }, + tokenAddress: "0x6B175474E89094C44Da98b954EedeAC495271d0F", + tokenGasLimit: 7e4, + symbol: "DAI", + decimals: 18, + gasLimit: 7e5 + }, + cdai: { + instanceAddress: { + "5000": "0x22aaA7720ddd5388A3c0A3333430953C68f1849b", + "50000": "0x03893a7c7463AE47D46bc7f091665f1893656003", + "500000": "0x2717c5e28cf931547B621a5dddb772Ab6A35B701", + "5000000": "0xD21be7248e0197Ee08E0c20D4a96DEBdaC3D20Af" + }, + tokenAddress: "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643", + tokenGasLimit: 2e5, + symbol: "cDAI", + decimals: 8, + gasLimit: 7e5 + }, + usdc: { + instanceAddress: { + "100": "0xd96f2B1c14Db8458374d9Aca76E26c3D18364307", + "1000": "0x4736dCf1b7A3d580672CcE6E7c65cd5cc9cFBa9D" + }, + tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", + tokenGasLimit: 7e4, + symbol: "USDC", + decimals: 6, + gasLimit: 7e5 + }, + usdt: { + instanceAddress: { + "100": "0x169AD27A470D064DEDE56a2D3ff727986b15D52B", + "1000": "0x0836222F2B2B24A3F36f98668Ed8F0B38D1a872f" + }, + tokenAddress: "0xdAC17F958D2ee523a2206206994597C13D831ec7", + tokenGasLimit: 7e4, + symbol: "USDT", + decimals: 6, + gasLimit: 7e5 + }, + wbtc: { + instanceAddress: { + "0.1": "0x178169B423a011fff22B9e3F3abeA13414dDD0F1", + "1": "0x610B717796ad172B316836AC95a2ffad065CeaB4", + "10": "0xbB93e510BbCD0B7beb5A853875f9eC60275CF498" + }, + tokenAddress: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", + tokenGasLimit: 7e4, + symbol: "WBTC", + decimals: 8, + gasLimit: 7e5 + } + }, + ensSubdomainKey: "mainnet-tornado", + pollInterval: 15, + constants: { + GOVERNANCE_BLOCK: 11474695, + NOTE_ACCOUNT_BLOCK: 11842486, + ENCRYPTED_NOTES_BLOCK: 14248730, + REGISTRY_BLOCK: 14173129, + MINING_BLOCK_TIME: 15 + }, + "torn.contract.tornadocash.eth": "0x77777FeDdddFfC19Ff86DB637967013e6C6A116C", + "governance.contract.tornadocash.eth": "0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce", + "tornado-router.contract.tornadocash.eth": "0xd90e2f925DA726b50C4Ed8D0Fb90Ad053324F31b", + "staking-rewards.contract.tornadocash.eth": "0x5B3f656C80E8ddb9ec01Dd9018815576E9238c29" + }, + netId56: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 5, + fast: 5, + standard: 5, + low: 5 + }, + nativeCurrency: "bnb", + currencyName: "BNB", + explorerUrl: { + tx: "https://bscscan.com/tx/", + address: "https://bscscan.com/address/", + block: "https://bscscan.com/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Binance Smart Chain", + deployedBlock: 8158799, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + tornadoSubgraph: "tornadocash/bsc-tornado-subgraph", + subgraphs: { + tornado, + theGraph + }, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com/bsc" + }, + chainnodes: { + name: "Tornado RPC", + url: "https://bsc-mainnet.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/bsc-mainnet" + }, + noderealRPC: { + name: "NodeReal RPC", + url: "https://bsc-mainnet.nodereal.io/v1/64a9df0874fb4a93b9d0a3849de012d3" + }, + oneRPC: { + name: "1RPC", + url: "https://1rpc.io/bnb" + } + }, + tokens: { + bnb: { + instanceAddress: { + "0.1": "0x84443CFd09A48AF6eF360C6976C5392aC5023a1F", + "1": "0xd47438C816c9E7f2E2888E060936a499Af9582b3", + "10": "0x330bdFADE01eE9bF63C209Ee33102DD334618e0a", + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD" + }, + symbol: "BNB", + decimals: 18 + } + }, + ensSubdomainKey: "bsc-tornado", + pollInterval: 10, + constants: { + NOTE_ACCOUNT_BLOCK: 8159269, + ENCRYPTED_NOTES_BLOCK: 8159269 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId137: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 100, + fast: 75, + standard: 50, + low: 30 + }, + nativeCurrency: "matic", + currencyName: "MATIC", + explorerUrl: { + tx: "https://polygonscan.com/tx/", + address: "https://polygonscan.com/address/", + block: "https://polygonscan.com/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Polygon (Matic) Network", + deployedBlock: 16257962, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + gasPriceOracleContract: "0xF81A8D8D3581985D3969fe53bFA67074aDFa8F3C", + tornadoSubgraph: "tornadocash/matic-tornado-subgraph", + subgraphs: { + tornado, + theGraph + }, + rpcUrls: { + chainnodes: { + name: "Tornado RPC", + url: "https://polygon-mainnet.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/polygon-mainnet" + }, + oneRpc: { + name: "1RPC", + url: "https://1rpc.io/matic" + } + }, + tokens: { + matic: { + instanceAddress: { + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD", + "1000": "0xdf231d99Ff8b6c6CBF4E9B9a945CBAcEF9339178", + "10000": "0xaf4c0B70B2Ea9FB7487C7CbB37aDa259579fe040", + "100000": "0xa5C2254e4253490C54cef0a4347fddb8f75A4998" + }, + symbol: "MATIC", + decimals: 18 + } + }, + ensSubdomainKey: "polygon-tornado", + pollInterval: 10, + constants: { + NOTE_ACCOUNT_BLOCK: 16257996, + ENCRYPTED_NOTES_BLOCK: 16257996 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId10: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 1e-3, + fast: 1e-3, + standard: 1e-3, + low: 1e-3 + }, + nativeCurrency: "eth", + currencyName: "ETH", + explorerUrl: { + tx: "https://optimistic.etherscan.io/tx/", + address: "https://optimistic.etherscan.io/address/", + block: "https://optimistic.etherscan.io/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Optimism", + deployedBlock: 2243689, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + ovmGasPriceOracleContract: "0x420000000000000000000000000000000000000F", + tornadoSubgraph: "tornadocash/optimism-tornado-subgraph", + subgraphs: { + tornado, + theGraph + }, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com/op" + }, + chainnodes: { + name: "Tornado RPC", + url: "https://optimism-mainnet.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + optimism: { + name: "Optimism RPC", + url: "https://mainnet.optimism.io" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/optimism-mainnet" + }, + oneRpc: { + name: "1RPC", + url: "https://1rpc.io/op" + } + }, + tokens: { + eth: { + instanceAddress: { + "0.1": "0x84443CFd09A48AF6eF360C6976C5392aC5023a1F", + "1": "0xd47438C816c9E7f2E2888E060936a499Af9582b3", + "10": "0x330bdFADE01eE9bF63C209Ee33102DD334618e0a", + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD" + }, + symbol: "ETH", + decimals: 18 + } + }, + ensSubdomainKey: "optimism-tornado", + pollInterval: 15, + constants: { + NOTE_ACCOUNT_BLOCK: 2243694, + ENCRYPTED_NOTES_BLOCK: 2243694 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId42161: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 4, + fast: 3, + standard: 2.52, + low: 2.29 + }, + nativeCurrency: "eth", + currencyName: "ETH", + explorerUrl: { + tx: "https://arbiscan.io/tx/", + address: "https://arbiscan.io/address/", + block: "https://arbiscan.io/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Arbitrum One", + deployedBlock: 3430648, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + tornadoSubgraph: "tornadocash/arbitrum-tornado-subgraph", + subgraphs: { + tornado, + theGraph + }, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com/arbitrum" + }, + chainnodes: { + name: "Tornado RPC", + url: "https://arbitrum-one.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + arbitrum: { + name: "Arbitrum RPC", + url: "https://arb1.arbitrum.io/rpc" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/arbitrum-one" + }, + oneRpc: { + name: "1rpc", + url: "https://1rpc.io/arb" + } + }, + tokens: { + eth: { + instanceAddress: { + "0.1": "0x84443CFd09A48AF6eF360C6976C5392aC5023a1F", + "1": "0xd47438C816c9E7f2E2888E060936a499Af9582b3", + "10": "0x330bdFADE01eE9bF63C209Ee33102DD334618e0a", + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD" + }, + symbol: "ETH", + decimals: 18 + } + }, + ensSubdomainKey: "arbitrum-tornado", + pollInterval: 15, + constants: { + NOTE_ACCOUNT_BLOCK: 3430605, + ENCRYPTED_NOTES_BLOCK: 3430605 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId100: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 6, + fast: 5, + standard: 4, + low: 1 + }, + nativeCurrency: "xdai", + currencyName: "xDAI", + explorerUrl: { + tx: "https://blockscout.com/xdai/mainnet/tx/", + address: "https://blockscout.com/xdai/mainnet/address/", + block: "https://blockscout.com/xdai/mainnet/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Gnosis Chain", + deployedBlock: 17754561, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + tornadoSubgraph: "tornadocash/xdai-tornado-subgraph", + subgraphs: { + tornado, + theGraph + }, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com/gnosis" + }, + chainnodes: { + name: "Tornado RPC", + url: "https://gnosis-mainnet.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + }, + gnosis: { + name: "Gnosis RPC", + url: "https://rpc.gnosischain.com" + }, + stackup: { + name: "Stackup RPC", + url: "https://public.stackup.sh/api/v1/node/arbitrum-one" + }, + blockPi: { + name: "BlockPi", + url: "https://gnosis.blockpi.network/v1/rpc/public" + } + }, + tokens: { + xdai: { + instanceAddress: { + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD", + "1000": "0xdf231d99Ff8b6c6CBF4E9B9a945CBAcEF9339178", + "10000": "0xaf4c0B70B2Ea9FB7487C7CbB37aDa259579fe040", + "100000": "0xa5C2254e4253490C54cef0a4347fddb8f75A4998" + }, + symbol: "xDAI", + decimals: 18 + } + }, + ensSubdomainKey: "gnosis-tornado", + pollInterval: 15, + constants: { + NOTE_ACCOUNT_BLOCK: 17754564, + ENCRYPTED_NOTES_BLOCK: 17754564 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId43114: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 225, + fast: 35, + standard: 25, + low: 25 + }, + nativeCurrency: "avax", + currencyName: "AVAX", + explorerUrl: { + tx: "https://snowtrace.io/tx/", + address: "https://snowtrace.io/address/", + block: "https://snowtrace.io/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Avalanche Mainnet", + deployedBlock: 4429818, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + echoContract: "0xa75BF2815618872f155b7C4B0C81bF990f5245E4", + routerContract: "0x0D5550d52428E7e3175bfc9550207e4ad3859b17", + tornadoSubgraph: "tornadocash/avalanche-tornado-subgraph", + subgraphs: { + theGraph + }, + rpcUrls: { + oneRPC: { + name: "OneRPC", + url: "https://1rpc.io/avax/c" + }, + avalancheRPC: { + name: "Avalanche RPC", + url: "https://api.avax.network/ext/bc/C/rpc" + }, + meowRPC: { + name: "Meow RPC", + url: "https://avax.meowrpc.com" + } + }, + tokens: { + avax: { + instanceAddress: { + "10": "0x330bdFADE01eE9bF63C209Ee33102DD334618e0a", + "100": "0x1E34A77868E19A6647b1f2F47B51ed72dEDE95DD", + "500": "0xaf8d1839c3c67cf571aa74B5c12398d4901147B3" + }, + symbol: "AVAX", + decimals: 18 + } + }, + ensSubdomainKey: "avalanche-tornado", + pollInterval: 10, + constants: { + NOTE_ACCOUNT_BLOCK: 4429813, + ENCRYPTED_NOTES_BLOCK: 4429813 + }, + "tornado-proxy-light.contract.tornadocash.eth": "0x0D5550d52428E7e3175bfc9550207e4ad3859b17" + }, + netId11155111: { + rpcCallRetryAttempt: 15, + gasPrices: { + instant: 2, + fast: 2, + standard: 2, + low: 2 + }, + nativeCurrency: "eth", + currencyName: "SepoliaETH", + explorerUrl: { + tx: "https://sepolia.etherscan.io/tx/", + address: "https://sepolia.etherscan.io/address/", + block: "https://sepolia.etherscan.io/block/" + }, + merkleTreeHeight: 20, + emptyElement: "21663839004416932945382355908790599225266501822907911457504978515578255421292", + networkName: "Ethereum Sepolia", + deployedBlock: 5594395, + multicall: "0xcA11bde05977b3631167028862bE2a173976CA11", + routerContract: "0x1572AFE6949fdF51Cb3E0856216670ae9Ee160Ee", + registryContract: "0x1428e5d2356b13778A13108b10c440C83011dfB8", + echoContract: "0xcDD1fc3F5ac2782D83449d3AbE80D6b7B273B0e5", + aggregatorContract: "0x4088712AC9fad39ea133cdb9130E465d235e9642", + reverseRecordsContract: "0xEc29700C0283e5Be64AcdFe8077d6cC95dE23C23", + tornadoSubgraph: "tornadocash/sepolia-tornado-subgraph", + subgraphs: { + tornado + }, + rpcUrls: { + tornado: { + name: "Tornado RPC", + url: "https://tornadocash-rpc.com/sepolia" + }, + sepolia: { + name: "Sepolia RPC", + url: "https://rpc.sepolia.org" + }, + chainnodes: { + name: "Chainnodes RPC", + url: "https://sepolia.chainnodes.org/d692ae63-0a7e-43e0-9da9-fe4f4cc6c607" + } + }, + tokens: { + eth: { + instanceAddress: { + "0.1": "0x8C4A04d872a6C1BE37964A21ba3a138525dFF50b", + "1": "0x8cc930096B4Df705A007c4A039BDFA1320Ed2508", + "10": "0x8D10d506D29Fc62ABb8A290B99F66dB27Fc43585", + "100": "0x44c5C92ed73dB43888210264f0C8b36Fd68D8379" + }, + symbol: "ETH", + decimals: 18 + }, + dai: { + instanceAddress: { + "100": "0x6921fd1a97441dd603a997ED6DDF388658daf754", + "1000": "0x50a637770F5d161999420F7d70d888DE47207145", + "10000": "0xecD649870407cD43923A816Cc6334a5bdf113621", + "100000": "0x73B4BD04bF83206B6e979BE2507098F92EDf4F90" + }, + tokenAddress: "0xFF34B3d4Aee8ddCd6F9AFFFB6Fe49bD371b8a357", + tokenGasLimit: 7e4, + symbol: "DAI", + decimals: 18, + gasLimit: 7e5 + } + }, + ensSubdomainKey: "sepolia-tornado", + pollInterval: 15, + constants: { + GOVERNANCE_BLOCK: 5594395, + NOTE_ACCOUNT_BLOCK: 5594395, + ENCRYPTED_NOTES_BLOCK: 5594395, + MINING_BLOCK_TIME: 15 + }, + "torn.contract.tornadocash.eth": "0x3AE6667167C0f44394106E197904519D808323cA", + "governance.contract.tornadocash.eth": "0xe5324cD7602eeb387418e594B87aCADee08aeCAD", + "tornado-router.contract.tornadocash.eth": "0x1572AFE6949fdF51Cb3E0856216670ae9Ee160Ee" + } +}; +const subdomains = enabledChains.map((chain) => networkConfig[`netId${chain}`].ensSubdomainKey); + +function parseNumber(value) { + if (!value || isNaN(Number(value))) { + throw new InvalidArgumentError("Invalid Number"); + } + return Number(value); +} +function parseUrl(value) { + if (!value || !validateUrl(value, ["http:", "https:"])) { + throw new InvalidArgumentError("Invalid URL"); + } + return value; +} +function parseRelayer(value) { + if (!value || !(value.endsWith(".eth") || validateUrl(value, ["http:", "https:"]))) { + throw new InvalidArgumentError("Invalid Relayer ETH address or URL"); + } + return value; +} +function parseAddress(value) { + if (!value) { + throw new InvalidArgumentError("Invalid Address"); + } + try { + return getAddress(value); + } catch (e) { + throw new InvalidArgumentError("Invalid Address"); + } +} +function parseMnemonic(value) { + if (!value) { + throw new InvalidArgumentError("Invalid Mnemonic"); + } + try { + Mnemonic.fromPhrase(value); + } catch (e) { + throw new InvalidArgumentError("Invalid Mnemonic"); + } + return value; +} +function parseKey(value) { + if (!value) { + throw new InvalidArgumentError("Invalid Private Key"); + } + if (value.length === 64) { + value = "0x" + value; + } + try { + computeAddress(value); + } catch (e) { + throw new InvalidArgumentError("Invalid Private Key"); + } + return value; +} + +class TokenPriceOracle { + constructor(provider, multicall2, oracle) { + this.provider = provider; + this.multicall = multicall2; + this.oracle = oracle; + } + fetchPrices(tokens) { + if (!this.oracle) { + return new Promise((resolve) => resolve(tokens.map(() => parseEther("0.0001")))); + } + return multicall( + this.multicall, + tokens.map((token) => ({ + contract: this.oracle, + name: "getRateToEth", + params: [token, true] + })) + ); + } +} + +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); +var __async$2 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +const MIN_STAKE_BALANCE = parseEther("500"); +const semVerRegex = new RegExp("^(?0|[1-9]\\d*)\\.(?0|[1-9]\\d*)\\.(?0|[1-9]\\d*)(?:-(?(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+(?[0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"); +function parseSemanticVersion(version) { + const { groups } = semVerRegex.exec(version); + return groups; +} +function isRelayerUpdated(relayerVersion, netId) { + const { major, patch, prerelease } = parseSemanticVersion(relayerVersion); + const requiredMajor = netId === 1 ? "4" : "5"; + const isUpdatedMajor = major === requiredMajor; + if (prerelease) + return false; + return isUpdatedMajor && (Number(patch) >= 5 || Number(netId) !== 1); +} +function calculateScore({ stakeBalance, tornadoServiceFee }, minFee = 0.33, maxFee = 0.53) { + if (tornadoServiceFee < minFee) { + tornadoServiceFee = minFee; + } else if (tornadoServiceFee >= maxFee) { + return BigInt(0); + } + const serviceFeeCoefficient = (tornadoServiceFee - minFee) ** 2; + const feeDiffCoefficient = 1 / (maxFee - minFee) ** 2; + const coefficientsMultiplier = 1 - feeDiffCoefficient * serviceFeeCoefficient; + return BigInt(Math.floor(Number(stakeBalance) * coefficientsMultiplier)); +} +function getWeightRandom(weightsScores, random) { + for (let i = 0; i < weightsScores.length; i++) { + if (random < weightsScores[i]) { + return i; + } + random = random - weightsScores[i]; + } + return Math.floor(Math.random() * weightsScores.length); +} +function pickWeightedRandomRelayer(relayers, netId) { + let minFee, maxFee; + if (Number(netId) !== 1) { + minFee = 0.01; + maxFee = 0.3; + } + const weightsScores = relayers.map((el) => calculateScore(el, minFee, maxFee)); + const totalWeight = weightsScores.reduce((acc, curr) => { + return acc = acc + curr; + }, BigInt("0")); + const random = BigInt(Number(totalWeight) * Math.random()); + const weightRandomIndex = getWeightRandom(weightsScores, random); + return relayers[weightRandomIndex]; +} +class RelayerClient { + constructor({ netId, config, Aggregator, fetchDataOptions: fetchDataOptions2 }) { + this.netId = Number(netId); + this.config = config; + this.Aggregator = Aggregator; + this.fetchDataOptions = fetchDataOptions2; + } + askRelayerStatus(_0) { + return __async$2(this, arguments, function* ({ + hostname, + relayerAddress + }) { + var _a, _b; + const url = `https://${!hostname.endsWith("/") ? hostname + "/" : hostname}`; + const rawStatus = yield fetchData(`${url}status`, __spreadProps(__spreadValues({}, this.fetchDataOptions), { + headers: { + "Content-Type": "application/json, application/x-www-form-urlencoded" + }, + timeout: ((_a = this.fetchDataOptions) == null ? void 0 : _a.torPort) ? 1e4 : 3e3, + maxRetry: ((_b = this.fetchDataOptions) == null ? void 0 : _b.torPort) ? 2 : 0 + })); + const statusValidator = ajv.compile(getStatusSchema(this.netId, this.config)); + if (!statusValidator(rawStatus)) { + throw new Error("Invalid status schema"); + } + const status = __spreadProps(__spreadValues({}, rawStatus), { + url + }); + if (status.currentQueue > 5) { + throw new Error("Withdrawal queue is overloaded"); + } + if (status.netId !== this.netId) { + throw new Error("This relayer serves a different network"); + } + if (relayerAddress && this.netId === 1 && status.rewardAccount !== relayerAddress) { + throw new Error("The Relayer reward address must match registered address"); + } + if (!isRelayerUpdated(status.version, this.netId)) { + throw new Error("Outdated version."); + } + return status; + }); + } + filterRelayer(curr, relayer, subdomains, debugRelayer = false) { + return __async$2(this, null, function* () { + const { ensSubdomainKey } = this.config; + const subdomainIndex = subdomains.indexOf(ensSubdomainKey); + const mainnetSubdomain = curr.records[0]; + const hostname = curr.records[subdomainIndex]; + const isHostWithProtocol = hostname.includes("http"); + const { owner, balance: stakeBalance, isRegistered } = curr; + const { ensName, relayerAddress } = relayer; + const isOwner = !relayerAddress || relayerAddress === owner; + const hasMinBalance = stakeBalance >= MIN_STAKE_BALANCE; + const preCondition = hostname && isOwner && mainnetSubdomain && isRegistered && hasMinBalance && !isHostWithProtocol; + if (preCondition || debugRelayer) { + try { + const status = yield this.askRelayerStatus({ hostname, relayerAddress }); + return { + netId: status.netId, + url: status.url, + hostname, + ensName, + stakeBalance, + relayerAddress, + rewardAccount: status.rewardAccount, + ethPrices: status.ethPrices, + currentQueue: status.currentQueue, + tornadoServiceFee: status.tornadoServiceFee + }; + } catch (err) { + if (debugRelayer) { + throw err; + } + return { + hostname, + relayerAddress, + errorMessage: err.message + }; + } + } else { + if (debugRelayer) { + const errMsg = `Relayer ${hostname} condition not met`; + throw new Error(errMsg); + } + return { + hostname, + relayerAddress, + errorMessage: `Relayer ${hostname} condition not met` + }; + } + }); + } + getValidRelayers(relayers, subdomains, debugRelayer = false) { + return __async$2(this, null, function* () { + const relayersSet = /* @__PURE__ */ new Set(); + const uniqueRelayers = relayers.reverse().filter(({ ensName }) => { + if (!relayersSet.has(ensName)) { + relayersSet.add(ensName); + return true; + } + return false; + }); + const relayerNameHashes = uniqueRelayers.map((r) => namehash(r.ensName)); + const relayersData = yield this.Aggregator.relayersData.staticCall(relayerNameHashes, subdomains); + const invalidRelayers = []; + const validRelayers = (yield Promise.all( + relayersData.map((curr, index) => this.filterRelayer(curr, uniqueRelayers[index], subdomains, debugRelayer)) + )).filter((r) => { + if (r.errorMessage) { + invalidRelayers.push(r); + return false; + } + return true; + }); + return { + validRelayers, + invalidRelayers + }; + }); + } + pickWeightedRandomRelayer(relayers) { + return pickWeightedRandomRelayer(relayers, this.netId); + } + tornadoWithdraw(_0) { + return __async$2(this, arguments, function* ({ contract, proof, args }) { + const { url } = this.selectedRelayer; + const withdrawResponse = yield fetchData(`${url}v1/tornadoWithdraw`, __spreadProps(__spreadValues({}, this.fetchDataOptions), { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + contract, + proof, + args + }) + })); + const { id, error } = withdrawResponse; + if (error) { + throw new Error(error); + } + let relayerStatus; + const jobUrl = `${url}v1/jobs/${id}`; + console.log(`Job submitted: ${jobUrl} +`); + while (!relayerStatus || !["FAILED", "CONFIRMED"].includes(relayerStatus)) { + const jobResponse = yield fetchData(jobUrl, __spreadProps(__spreadValues({}, this.fetchDataOptions), { + method: "GET", + headers: { + "Content-Type": "application/json" + } + })); + if (jobResponse.error) { + throw new Error(error); + } + const jobValidator = ajv.compile(jobsSchema); + if (!jobValidator(jobResponse)) { + const errMsg = `${jobUrl} has an invalid job response`; + throw new Error(errMsg); + } + const { status, txHash, confirmations, failedReason } = jobResponse; + if (relayerStatus !== status) { + if (status === "FAILED") { + const errMsg = `Job ${status}: ${jobUrl} failed reason: ${failedReason}`; + throw new Error(errMsg); + } else if (status === "SENT") { + console.log(`Job ${status}: ${jobUrl}, txhash: ${txHash} +`); + } else if (status === "MINED") { + console.log(`Job ${status}: ${jobUrl}, txhash: ${txHash}, confirmations: ${confirmations} +`); + } else if (status === "CONFIRMED") { + console.log(`Job ${status}: ${jobUrl}, txhash: ${txHash}, confirmations: ${confirmations} +`); + } else { + console.log(`Job ${status}: ${jobUrl} +`); + } + relayerStatus = status; + } + yield sleep(3e3); + } + }); + } +} + +var __async$1 = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +function getTokenBalances(_0) { + return __async$1(this, arguments, function* ({ + provider, + Multicall: Multicall2, + currencyName, + userAddress, + tokenAddresses = [] + }) { + const tokenCalls = tokenAddresses.map((tokenAddress) => { + const Token = ERC20__factory.connect(tokenAddress, provider); + return [ + { + contract: Token, + name: "balanceOf", + params: [userAddress] + }, + { + contract: Token, + name: "name" + }, + { + contract: Token, + name: "symbol" + }, + { + contract: Token, + name: "decimals" + } + ]; + }).flat(); + const multicallResults = yield multicall(Multicall2, [ + { + contract: Multicall2, + name: "getEthBalance", + params: [userAddress] + }, + ...tokenCalls.length ? tokenCalls : [] + ]); + const ethResults = multicallResults[0]; + const tokenResults = multicallResults.slice(1).length ? chunk(multicallResults.slice(1), tokenCalls.length / tokenAddresses.length) : []; + const tokenBalances = tokenResults.map((tokenResult, index) => { + const [tokenBalance, tokenName, tokenSymbol, tokenDecimals] = tokenResult; + const tokenAddress = tokenAddresses[index]; + return { + address: tokenAddress, + name: tokenName, + symbol: tokenSymbol, + decimals: Number(tokenDecimals), + balance: tokenBalance + }; + }); + return [ + { + address: ZeroAddress, + name: currencyName, + symbol: currencyName, + decimals: 18, + balance: ethResults + }, + ...tokenBalances + ]; + }); +} + +var __async = (__this, __arguments, generator) => { + return new Promise((resolve, reject) => { + var fulfilled = (value) => { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + }; + var rejected = (value) => { + try { + step(generator.throw(value)); + } catch (e) { + reject(e); + } + }; + var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); + step((generator = generator.apply(__this, __arguments)).next()); + }); +}; +let groth16; +const groth16Promise = (() => __async(void 0, null, function* () { + if (!groth16) { + groth16 = yield websnarkGroth({ wasmInitialMemory: 2e3 }); + } +}))(); +function calculateSnarkProof(input, circuit, provingKey) { + return __async(this, null, function* () { + yield groth16Promise; + const snarkInput = { + root: input.root, + nullifierHash: BigInt(input.nullifierHex).toString(), + recipient: BigInt(input.recipient), + relayer: BigInt(input.relayer), + fee: input.fee, + refund: input.refund, + nullifier: input.nullifier, + secret: input.secret, + pathElements: input.pathElements, + pathIndices: input.pathIndices + }; + console.log("Start generating SNARK proof", snarkInput); + console.time("SNARK proof time"); + const proofData = yield websnarkUtils.genWitnessAndProve(groth16, snarkInput, circuit, provingKey); + const proof = websnarkUtils.toSolidityInput(proofData).proof; + console.timeEnd("SNARK proof time"); + const args = [ + toFixedHex(input.root, 32), + toFixedHex(input.nullifierHex, 32), + input.recipient, + input.relayer, + toFixedHex(input.fee, 32), + toFixedHex(input.refund, 32) + ]; + return { proof, args }; + }); +} + +export { BaseDepositsService, BaseEncryptedNotesService, BaseEventsService, BaseGovernanceService, BaseRegistryService, BatchBlockService, BatchEventsService, BatchTransactionService, DEPOSIT, Deposit, ENS__factory, ERC20__factory, GET_DEPOSITS, GET_ENCRYPTED_NOTES, GET_NOTE_ACCOUNTS, GET_REGISTERED, GET_STATISTIC, GET_WITHDRAWALS, GasPriceOracle__factory, Invoice, MIN_STAKE_BALANCE, MerkleTreeService, Mimc, Multicall__factory, NodeDepositsService, NodeEncryptedNotesService, NodeGovernanceService, NodeRegistryService, OffchainOracle__factory, OvmGasPriceOracle__factory, Pedersen, RelayerClient, ReverseRecords__factory, TokenPriceOracle, TornadoBrowserProvider, TornadoFeeOracle, TornadoRpcSigner, TornadoVoidSigner, TornadoWallet, WITHDRAWAL, _META, ajv, base64ToBytes, bigIntReplacer, blockSyncInterval, bnToBytes, buffPedersenHash, bufferToBytes, bytesToBN, bytesToBase64, bytesToHex, calculateScore, calculateSnarkProof, chunk, convertETHToTokenAmount, createDeposit, defaultUserAgent, download, enabledChains, existsAsync, index as factories, fetch, fetchData, fetchGetUrlFunc, getAllDeposits, getAllEncryptedNotes, getAllRegisters, getAllWithdrawals, getDeposits, getEncryptedNotes, getGasOraclePlugin, getHttpAgent, getMeta, getNoteAccounts, getProvider, getProviderWithNetId, getRegisters, getStatistic, getStatusSchema, getTokenBalances, getWeightRandom, getWithdrawals, isNode, isRelayerUpdated, jobsSchema, leBuff2Int, leInt2Buff, loadCachedEvents, loadSavedEvents, mimc, multicall, networkConfig, parseAddress, parseKey, parseMnemonic, parseNumber, parseRelayer, parseSemanticVersion, parseUrl, pedersen, pickWeightedRandomRelayer, populateTransaction, queryGraph, rBigInt, saveEvents, sleep, subdomains, substring, toFixedHex, toFixedLength, unzipAsync, validateUrl, zipAsync }; diff --git a/dist/merkleTreeWorker.d.ts b/dist/merkleTreeWorker.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/merkleTreeWorker.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/program.d.ts b/dist/program.d.ts new file mode 100644 index 0000000..9f141e4 --- /dev/null +++ b/dist/program.d.ts @@ -0,0 +1,51 @@ +import 'dotenv/config'; +import { Command } from 'commander'; +import { JsonRpcProvider, Provider, TransactionLike, Wallet, VoidSigner, BigNumberish } from 'ethers'; +import { getProviderOptions, TornadoWallet, TornadoVoidSigner, Relayer, RelayerInfo, RelayerError, RelayerClient, fetchDataOptions, Config } from './services'; +export type commonProgramOptions = { + rpc?: string; + ethRpc?: string; + graph?: string; + ethGraph?: string; + disableGraph?: boolean; + relayer?: string; + walletWithdrawal?: boolean; + torPort?: number; + token?: string; + viewOnly?: string; + mnemonic?: string; + mnemonicIndex?: number; + privateKey?: string; + nonInteractive?: boolean; + localRpc?: boolean; +}; +export declare function promptConfirmation(nonInteractive?: boolean): Promise; +export declare function getIPAddress(fetchDataOptions: fetchDataOptions): Promise<{ + ip: any; + isTor: boolean; +}>; +export declare function getProgramOptions(options: commonProgramOptions): Promise<{ + options: commonProgramOptions; + fetchDataOptions: fetchDataOptions; +}>; +export declare function getProgramGraphAPI(options: commonProgramOptions, config: Config): string; +export declare function getProgramProvider(netId: BigNumberish, rpcUrl: string | undefined, config: Config, providerOptions?: getProviderOptions): JsonRpcProvider; +export declare function getProgramSigner({ options, provider, }: { + options: commonProgramOptions; + provider: Provider; +}): TornadoVoidSigner | TornadoWallet | undefined; +export declare function getProgramRelayer({ options, fetchDataOptions, netId, }: { + options: commonProgramOptions; + fetchDataOptions?: fetchDataOptions; + netId: number | string; +}): Promise<{ + validRelayers?: RelayerInfo[] | Relayer[]; + invalidRelayers?: RelayerError[]; + relayerClient?: RelayerClient; +}>; +export declare function programSendTransaction({ signer, options, populatedTransaction, }: { + signer: VoidSigner | Wallet; + options: commonProgramOptions; + populatedTransaction: TransactionLike; +}): Promise; +export declare function tornadoProgram(): Command; diff --git a/dist/services/batch.d.ts b/dist/services/batch.d.ts new file mode 100644 index 0000000..e32cb17 --- /dev/null +++ b/dist/services/batch.d.ts @@ -0,0 +1,86 @@ +import type { Provider, BlockTag, Block, TransactionResponse, BaseContract, ContractEventName, EventLog } from 'ethers'; +export interface BatchBlockServiceConstructor { + provider: Provider; + onProgress?: BatchBlockOnProgress; + concurrencySize?: number; + batchSize?: number; + shouldRetry?: boolean; + retryMax?: number; + retryOn?: number; +} +export type BatchBlockOnProgress = ({ percentage, currentIndex, totalIndex, }: { + percentage: number; + currentIndex?: number; + totalIndex?: number; +}) => void; +/** + * Fetch blocks from web3 provider on batches + */ +export declare class BatchBlockService { + provider: Provider; + onProgress?: BatchBlockOnProgress; + concurrencySize: number; + batchSize: number; + shouldRetry: boolean; + retryMax: number; + retryOn: number; + constructor({ provider, onProgress, concurrencySize, batchSize, shouldRetry, retryMax, retryOn, }: BatchBlockServiceConstructor); + getBlock(blockTag: BlockTag): Promise; + createBatchRequest(batchArray: BlockTag[][]): Promise[]; + getBatchBlocks(blocks: BlockTag[]): Promise; +} +/** + * Fetch transactions from web3 provider on batches + */ +export declare class BatchTransactionService { + provider: Provider; + onProgress?: BatchBlockOnProgress; + concurrencySize: number; + batchSize: number; + shouldRetry: boolean; + retryMax: number; + retryOn: number; + constructor({ provider, onProgress, concurrencySize, batchSize, shouldRetry, retryMax, retryOn, }: BatchBlockServiceConstructor); + getTransaction(txHash: string): Promise; + createBatchRequest(batchArray: string[][]): Promise[]; + getBatchTransactions(txs: string[]): Promise; +} +export interface BatchEventServiceConstructor { + provider: Provider; + contract: BaseContract; + onProgress?: BatchEventOnProgress; + concurrencySize?: number; + blocksPerRequest?: number; + shouldRetry?: boolean; + retryMax?: number; + retryOn?: number; +} +export type BatchEventOnProgress = ({ percentage, type, fromBlock, toBlock, count, }: { + percentage: number; + type?: ContractEventName; + fromBlock?: number; + toBlock?: number; + count?: number; +}) => void; +export type EventInput = { + fromBlock: number; + toBlock: number; + type: ContractEventName; +}; +/** + * Fetch events from web3 provider on bulk + */ +export declare class BatchEventsService { + provider: Provider; + contract: BaseContract; + onProgress?: BatchEventOnProgress; + concurrencySize: number; + blocksPerRequest: number; + shouldRetry: boolean; + retryMax: number; + retryOn: number; + constructor({ provider, contract, onProgress, concurrencySize, blocksPerRequest, shouldRetry, retryMax, retryOn, }: BatchEventServiceConstructor); + getPastEvents({ fromBlock, toBlock, type }: EventInput): Promise; + createBatchRequest(batchArray: EventInput[]): Promise[]; + getBatchEvents({ fromBlock, toBlock, type }: EventInput): Promise; +} diff --git a/dist/services/data.d.ts b/dist/services/data.d.ts new file mode 100644 index 0000000..3f83108 --- /dev/null +++ b/dist/services/data.d.ts @@ -0,0 +1,24 @@ +import { AsyncZippable, Unzipped } from 'fflate'; +import { BaseEvents, MinimalEvents } from './events'; +export declare function existsAsync(fileOrDir: string): Promise; +export declare function zipAsync(file: AsyncZippable): Promise; +export declare function unzipAsync(data: Uint8Array): Promise; +export declare function saveEvents({ name, userDirectory, events, }: { + name: string; + userDirectory: string; + events: T[]; +}): Promise; +export declare function loadSavedEvents({ name, userDirectory, deployedBlock, }: { + name: string; + userDirectory: string; + deployedBlock: number; +}): Promise>; +export declare function download({ name, cacheDirectory }: { + name: string; + cacheDirectory: string; +}): Promise; +export declare function loadCachedEvents({ name, cacheDirectory, deployedBlock, }: { + name: string; + cacheDirectory: string; + deployedBlock: number; +}): Promise>; diff --git a/dist/services/deposits.d.ts b/dist/services/deposits.d.ts new file mode 100644 index 0000000..ce399c8 --- /dev/null +++ b/dist/services/deposits.d.ts @@ -0,0 +1,73 @@ +export type DepositType = { + currency: string; + amount: string; + netId: string | number; +}; +export type createDepositParams = { + nullifier: bigint; + secret: bigint; +}; +export type createDepositObject = { + preimage: Uint8Array; + noteHex: string; + commitment: bigint; + commitmentHex: string; + nullifierHash: bigint; + nullifierHex: string; +}; +export type createNoteParams = DepositType & { + nullifier?: bigint; + secret?: bigint; +}; +export type parsedNoteExec = DepositType & { + note: string; +}; +export type depositTx = { + from: string; + transactionHash: string; +}; +export type withdrawalTx = { + to: string; + transactionHash: string; +}; +export declare function createDeposit({ nullifier, secret }: createDepositParams): Promise; +export interface DepositConstructor { + currency: string; + amount: string; + netId: number; + nullifier: bigint; + secret: bigint; + note: string; + noteHex: string; + invoice: string; + commitmentHex: string; + nullifierHex: string; +} +export declare class Deposit { + currency: string; + amount: string; + netId: number; + nullifier: bigint; + secret: bigint; + note: string; + noteHex: string; + invoice: string; + commitmentHex: string; + nullifierHex: string; + constructor({ currency, amount, netId, nullifier, secret, note, noteHex, invoice, commitmentHex, nullifierHex, }: DepositConstructor); + toString(): string; + static createNote({ currency, amount, netId, nullifier, secret }: createNoteParams): Promise; + static parseNote(noteString: string): Promise; +} +export type parsedInvoiceExec = DepositType & { + commitment: string; +}; +export declare class Invoice { + currency: string; + amount: string; + netId: number; + commitment: string; + invoice: string; + constructor(invoiceString: string); + toString(): string; +} diff --git a/dist/services/events/base.d.ts b/dist/services/events/base.d.ts new file mode 100644 index 0000000..7ad9138 --- /dev/null +++ b/dist/services/events/base.d.ts @@ -0,0 +1,172 @@ +import { BaseContract, Provider, EventLog, ContractEventName } from 'ethers'; +import type { Tornado, TornadoRouter, TornadoProxyLight, Governance, RelayerRegistry } from '@tornado/contracts'; +import { BatchEventsService, BatchBlockService, BatchTransactionService, BatchEventOnProgress, BatchBlockOnProgress } from '../batch'; +import { fetchDataOptions } from '../providers'; +import type { BaseEvents, MinimalEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, GovernanceProposalCreatedEvents, GovernanceVotedEvents, GovernanceDelegatedEvents, GovernanceUndelegatedEvents, RegistersEvents } from './types'; +export declare const DEPOSIT = "deposit"; +export declare const WITHDRAWAL = "withdrawal"; +export type BaseEventsServiceConstructor = { + netId: number | string; + provider: Provider; + graphApi?: string; + subgraphName?: string; + contract: BaseContract; + type?: string; + deployedBlock?: number; + fetchDataOptions?: fetchDataOptions; +}; +export type BatchGraphOnProgress = ({ type, fromBlock, toBlock, count, }: { + type?: ContractEventName; + fromBlock?: number; + toBlock?: number; + count?: number; +}) => void; +export type BaseGraphParams = { + graphApi: string; + subgraphName: string; + fetchDataOptions?: fetchDataOptions; + onProgress?: BatchGraphOnProgress; +}; +export declare class BaseEventsService { + netId: number | string; + provider: Provider; + graphApi?: string; + subgraphName?: string; + contract: BaseContract; + type: string; + deployedBlock: number; + batchEventsService: BatchEventsService; + fetchDataOptions?: fetchDataOptions; + constructor({ netId, provider, graphApi, subgraphName, contract, type, deployedBlock, fetchDataOptions, }: BaseEventsServiceConstructor); + getInstanceName(): string; + getType(): string; + getGraphMethod(): string; + getGraphParams(): BaseGraphParams; + updateEventProgress({ percentage, type, fromBlock, toBlock, count }: Parameters[0]): void; + updateBlockProgress({ percentage, currentIndex, totalIndex }: Parameters[0]): void; + updateTransactionProgress({ percentage, currentIndex, totalIndex }: Parameters[0]): void; + updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; + formatEvents(events: EventLog[]): Promise; + /** + * Get saved or cached events + */ + getEventsFromDB(): Promise>; + getEventsFromCache(): Promise>; + getSavedEvents(): Promise>; + /** + * Get latest events + */ + getEventsFromGraph({ fromBlock, methodName, }: { + fromBlock: number; + methodName?: string; + }): Promise>; + getEventsFromRpc({ fromBlock, toBlock, }: { + fromBlock: number; + toBlock?: number; + }): Promise>; + getLatestEvents({ fromBlock }: { + fromBlock: number; + }): Promise>; + validateEvents({ events, lastBlock }: BaseEvents): void; + /** + * Handle saving events + */ + saveEvents({ events, lastBlock }: BaseEvents): Promise; + /** + * Trigger saving and receiving latest events + */ + updateEvents(): Promise<{ + events: EventType[]; + lastBlock: number | null; + }>; +} +export type BaseDepositsServiceConstructor = { + netId: number | string; + provider: Provider; + graphApi?: string; + subgraphName?: string; + Tornado: Tornado; + type: string; + amount: string; + currency: string; + deployedBlock?: number; + fetchDataOptions?: fetchDataOptions; +}; +export type DepositsGraphParams = BaseGraphParams & { + amount: string; + currency: string; +}; +export declare class BaseDepositsService extends BaseEventsService { + amount: string; + currency: string; + batchTransactionService: BatchTransactionService; + batchBlockService: BatchBlockService; + constructor({ netId, provider, graphApi, subgraphName, Tornado, type, amount, currency, deployedBlock, fetchDataOptions, }: BaseDepositsServiceConstructor); + getInstanceName(): string; + getGraphMethod(): string; + getGraphParams(): DepositsGraphParams; + formatEvents(events: EventLog[]): Promise<(DepositsEvents | WithdrawalsEvents)[]>; + validateEvents({ events }: { + events: (DepositsEvents | WithdrawalsEvents)[]; + }): void; +} +export type BaseEncryptedNotesServiceConstructor = { + netId: number | string; + provider: Provider; + graphApi?: string; + subgraphName?: string; + Router: TornadoRouter | TornadoProxyLight; + deployedBlock?: number; + fetchDataOptions?: fetchDataOptions; +}; +export declare class BaseEncryptedNotesService extends BaseEventsService { + constructor({ netId, provider, graphApi, subgraphName, Router, deployedBlock, fetchDataOptions, }: BaseEncryptedNotesServiceConstructor); + getInstanceName(): string; + getType(): string; + getGraphMethod(): string; + formatEvents(events: EventLog[]): Promise; +} +export type BaseGovernanceEventTypes = GovernanceProposalCreatedEvents | GovernanceVotedEvents | GovernanceDelegatedEvents | GovernanceUndelegatedEvents; +export type BaseGovernanceServiceConstructor = { + netId: number | string; + provider: Provider; + graphApi?: string; + subgraphName?: string; + Governance: Governance; + deployedBlock?: number; + fetchDataOptions?: fetchDataOptions; +}; +export declare class BaseGovernanceService extends BaseEventsService { + batchTransactionService: BatchTransactionService; + constructor({ netId, provider, graphApi, subgraphName, Governance, deployedBlock, fetchDataOptions, }: BaseGovernanceServiceConstructor); + getInstanceName(): string; + getType(): string; + getGraphMethod(): string; + formatEvents(events: EventLog[]): Promise; + getEventsFromGraph({ fromBlock }: { + fromBlock: number; + }): Promise>; +} +export type BaseRegistryServiceConstructor = { + netId: number | string; + provider: Provider; + graphApi?: string; + subgraphName?: string; + RelayerRegistry: RelayerRegistry; + deployedBlock?: number; + fetchDataOptions?: fetchDataOptions; +}; +export declare class BaseRegistryService extends BaseEventsService { + constructor({ netId, provider, graphApi, subgraphName, RelayerRegistry, deployedBlock, fetchDataOptions, }: BaseRegistryServiceConstructor); + getInstanceName(): string; + getType(): string; + getGraphMethod(): string; + formatEvents(events: EventLog[]): Promise<{ + ensName: any; + relayerAddress: any; + blockNumber: number; + logIndex: number; + transactionHash: string; + }[]>; + fetchRelayers(): Promise; +} diff --git a/dist/services/events/index.d.ts b/dist/services/events/index.d.ts new file mode 100644 index 0000000..c386db6 --- /dev/null +++ b/dist/services/events/index.d.ts @@ -0,0 +1,3 @@ +export * from './types'; +export * from './base'; +export * from './node'; diff --git a/dist/services/events/node.d.ts b/dist/services/events/node.d.ts new file mode 100644 index 0000000..f30de86 --- /dev/null +++ b/dist/services/events/node.d.ts @@ -0,0 +1,62 @@ +import { BatchBlockOnProgress, BatchEventOnProgress } from '../batch'; +import { BaseDepositsService, BaseEncryptedNotesService, BaseGovernanceService, BaseRegistryService, BaseDepositsServiceConstructor, BaseEncryptedNotesServiceConstructor, BaseGovernanceServiceConstructor, BaseRegistryServiceConstructor, BaseGovernanceEventTypes } from './base'; +import type { BaseEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, RegistersEvents } from './types'; +export type NodeDepositsServiceConstructor = BaseDepositsServiceConstructor & { + cacheDirectory?: string; + userDirectory?: string; +}; +export declare class NodeDepositsService extends BaseDepositsService { + cacheDirectory?: string; + userDirectory?: string; + constructor({ netId, provider, graphApi, subgraphName, Tornado, type, amount, currency, deployedBlock, fetchDataOptions, cacheDirectory, userDirectory, }: NodeDepositsServiceConstructor); + updateEventProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; + updateTransactionProgress({ currentIndex, totalIndex }: Parameters[0]): void; + updateBlockProgress({ currentIndex, totalIndex }: Parameters[0]): void; + updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; + getEventsFromDB(): Promise>; + getEventsFromCache(): Promise>; + saveEvents({ events, lastBlock }: BaseEvents): Promise; +} +export type NodeEncryptedNotesServiceConstructor = BaseEncryptedNotesServiceConstructor & { + cacheDirectory?: string; + userDirectory?: string; +}; +export declare class NodeEncryptedNotesService extends BaseEncryptedNotesService { + cacheDirectory?: string; + userDirectory?: string; + constructor({ netId, provider, graphApi, subgraphName, Router, deployedBlock, fetchDataOptions, cacheDirectory, userDirectory, }: NodeEncryptedNotesServiceConstructor); + updateEventProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; + updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; + getEventsFromDB(): Promise>; + getEventsFromCache(): Promise>; + saveEvents({ events, lastBlock }: BaseEvents): Promise; +} +export type NodeGovernanceServiceConstructor = BaseGovernanceServiceConstructor & { + cacheDirectory?: string; + userDirectory?: string; +}; +export declare class NodeGovernanceService extends BaseGovernanceService { + cacheDirectory?: string; + userDirectory?: string; + constructor({ netId, provider, graphApi, subgraphName, Governance, deployedBlock, fetchDataOptions, cacheDirectory, userDirectory, }: NodeGovernanceServiceConstructor); + updateEventProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; + updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; + updateTransactionProgress({ currentIndex, totalIndex }: Parameters[0]): void; + getEventsFromDB(): Promise>; + getEventsFromCache(): Promise>; + saveEvents({ events, lastBlock }: BaseEvents): Promise; +} +export type NodeRegistryServiceConstructor = BaseRegistryServiceConstructor & { + cacheDirectory?: string; + userDirectory?: string; +}; +export declare class NodeRegistryService extends BaseRegistryService { + cacheDirectory?: string; + userDirectory?: string; + constructor({ netId, provider, graphApi, subgraphName, RelayerRegistry, deployedBlock, fetchDataOptions, cacheDirectory, userDirectory, }: NodeRegistryServiceConstructor); + updateEventProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; + updateGraphProgress({ type, fromBlock, toBlock, count }: Parameters[0]): void; + getEventsFromDB(): Promise>; + getEventsFromCache(): Promise>; + saveEvents({ events, lastBlock }: BaseEvents): Promise; +} diff --git a/dist/services/events/types.d.ts b/dist/services/events/types.d.ts new file mode 100644 index 0000000..b49179a --- /dev/null +++ b/dist/services/events/types.d.ts @@ -0,0 +1,57 @@ +import { RelayerParams } from '../relayerClient'; +export interface BaseEvents { + events: T[]; + lastBlock: number | null; +} +export interface BaseGraphEvents { + events: T[]; + lastSyncBlock: number; +} +export interface MinimalEvents { + blockNumber: number; + logIndex: number; + transactionHash: string; +} +export type GovernanceEvents = MinimalEvents & { + event: string; +}; +export type GovernanceProposalCreatedEvents = GovernanceEvents & { + id: number; + proposer: string; + target: string; + startTime: number; + endTime: number; + description: string; +}; +export type GovernanceVotedEvents = GovernanceEvents & { + proposalId: number; + voter: string; + support: boolean; + votes: string; + from: string; + input: string; +}; +export type GovernanceDelegatedEvents = GovernanceEvents & { + account: string; + delegateTo: string; +}; +export type GovernanceUndelegatedEvents = GovernanceEvents & { + account: string; + delegateFrom: string; +}; +export type RegistersEvents = MinimalEvents & RelayerParams; +export type DepositsEvents = MinimalEvents & { + commitment: string; + leafIndex: number; + timestamp: number; + from: string; +}; +export type WithdrawalsEvents = MinimalEvents & { + nullifierHash: string; + to: string; + fee: string; + timestamp: number; +}; +export type EncryptedNotesEvents = MinimalEvents & { + encryptedNote: string; +}; diff --git a/dist/services/fees.d.ts b/dist/services/fees.d.ts new file mode 100644 index 0000000..2319786 --- /dev/null +++ b/dist/services/fees.d.ts @@ -0,0 +1,45 @@ +import type { BigNumberish, TransactionLike } from 'ethers'; +import { OvmGasPriceOracle } from '../typechain'; +/** + * Example: + * + * amountInWei (0.1 ETH) * tokenDecimals (18) * tokenPriceInWei (0.0008) = 125 TOKEN + */ +export declare function convertETHToTokenAmount(amountInWei: BigNumberish, tokenPriceInWei: BigNumberish, tokenDecimals?: number): bigint; +export interface RelayerFeeParams { + gasPrice: BigNumberish; + gasLimit?: BigNumberish; + l1Fee?: BigNumberish; + denomination: BigNumberish; + ethRefund: BigNumberish; + tokenPriceInWei: BigNumberish; + tokenDecimals: number; + relayerFeePercent?: number; + isEth?: boolean; + premiumPercent?: number; +} +export declare class TornadoFeeOracle { + ovmGasPriceOracle?: OvmGasPriceOracle; + constructor(ovmGasPriceOracle?: OvmGasPriceOracle); + /** + * Calculate L1 fee for op-stack chains + * + * This is required since relayers would pay the full transaction fees for users + */ + fetchL1OptimismFee(tx?: TransactionLike): Promise; + /** + * We don't need to distinguish default refunds by tokens since most users interact with other defi protocols after withdrawal + * So we default with 1M gas which is enough for two or three swaps + * Using 30 gwei for default but it is recommended to supply cached gasPrice value from the UI + */ + defaultEthRefund(gasPrice?: BigNumberish, gasLimit?: BigNumberish): bigint; + /** + * Calculates token amount for required ethRefund purchases required to calculate fees + */ + calculateTokenAmount(ethRefund: BigNumberish, tokenPriceInEth: BigNumberish, tokenDecimals?: number): bigint; + /** + * Warning: For tokens you need to check if the fees are above denomination + * (Usually happens for small denomination pool or if the gas price is high) + */ + calculateRelayerFee({ gasPrice, gasLimit, l1Fee, denomination, ethRefund, tokenPriceInWei, tokenDecimals, relayerFeePercent, isEth, premiumPercent, }: RelayerFeeParams): bigint; +} diff --git a/dist/services/graphql/index.d.ts b/dist/services/graphql/index.d.ts new file mode 100644 index 0000000..38cbb8b --- /dev/null +++ b/dist/services/graphql/index.d.ts @@ -0,0 +1,190 @@ +import { fetchDataOptions } from '../providers'; +import type { BaseGraphEvents, RegistersEvents, DepositsEvents, WithdrawalsEvents, EncryptedNotesEvents, BatchGraphOnProgress } from '../events'; +export * from './queries'; +export type queryGraphParams = { + graphApi: string; + subgraphName: string; + query: string; + variables?: { + [key: string]: string | number; + }; + fetchDataOptions?: fetchDataOptions; +}; +export declare function queryGraph({ graphApi, subgraphName, query, variables, fetchDataOptions, }: queryGraphParams): Promise; +export interface GraphStatistic { + deposits: { + index: string; + timestamp: string; + blockNumber: string; + }[]; + _meta: { + block: { + number: number; + }; + hasIndexingErrors: boolean; + }; +} +export interface getStatisticParams { + graphApi: string; + subgraphName: string; + currency: string; + amount: string; + fetchDataOptions?: fetchDataOptions; +} +export interface getStatisticReturns { + events: { + timestamp: number; + leafIndex: number; + blockNumber: number; + }[]; + lastSyncBlock: null | number; +} +export declare function getStatistic({ graphApi, subgraphName, currency, amount, fetchDataOptions, }: getStatisticParams): Promise; +export interface GraphMeta { + _meta: { + block: { + number: number; + }; + hasIndexingErrors: boolean; + }; +} +export interface getMetaParams { + graphApi: string; + subgraphName: string; + fetchDataOptions?: fetchDataOptions; +} +export interface getMetaReturns { + lastSyncBlock: null | number; + hasIndexingErrors: null | boolean; +} +export declare function getMeta({ graphApi, subgraphName, fetchDataOptions }: getMetaParams): Promise; +export interface GraphRegisters { + relayers: { + id: string; + address: string; + ensName: string; + blockRegistration: string; + }[]; + _meta: { + block: { + number: number; + }; + hasIndexingErrors: boolean; + }; +} +export interface getRegistersParams { + graphApi: string; + subgraphName: string; + fromBlock: number; + fetchDataOptions?: fetchDataOptions; + onProgress?: BatchGraphOnProgress; +} +export declare function getRegisters({ graphApi, subgraphName, fromBlock, fetchDataOptions, }: getRegistersParams): Promise; +export declare function getAllRegisters({ graphApi, subgraphName, fromBlock, fetchDataOptions, onProgress, }: getRegistersParams): Promise>; +export interface GraphDeposits { + deposits: { + id: string; + blockNumber: string; + commitment: string; + index: string; + timestamp: string; + from: string; + }[]; + _meta: { + block: { + number: number; + }; + hasIndexingErrors: boolean; + }; +} +export interface getDepositsParams { + graphApi: string; + subgraphName: string; + currency: string; + amount: string; + fromBlock: number; + fetchDataOptions?: fetchDataOptions; + onProgress?: BatchGraphOnProgress; +} +export declare function getDeposits({ graphApi, subgraphName, currency, amount, fromBlock, fetchDataOptions, }: getDepositsParams): Promise; +export declare function getAllDeposits({ graphApi, subgraphName, currency, amount, fromBlock, fetchDataOptions, onProgress, }: getDepositsParams): Promise>; +export interface GraphWithdrawals { + withdrawals: { + id: string; + blockNumber: string; + nullifier: string; + to: string; + fee: string; + timestamp: string; + }[]; + _meta: { + block: { + number: number; + }; + hasIndexingErrors: boolean; + }; +} +export interface getWithdrawalParams { + graphApi: string; + subgraphName: string; + currency: string; + amount: string; + fromBlock: number; + fetchDataOptions?: fetchDataOptions; + onProgress?: BatchGraphOnProgress; +} +export declare function getWithdrawals({ graphApi, subgraphName, currency, amount, fromBlock, fetchDataOptions, }: getWithdrawalParams): Promise; +export declare function getAllWithdrawals({ graphApi, subgraphName, currency, amount, fromBlock, fetchDataOptions, onProgress, }: getWithdrawalParams): Promise>; +export interface GraphNoteAccounts { + noteAccounts: { + id: string; + index: string; + address: string; + encryptedAccount: string; + }[]; + _meta: { + block: { + number: number; + }; + hasIndexingErrors: boolean; + }; +} +export interface getNoteAccountsParams { + graphApi: string; + subgraphName: string; + address: string; + fetchDataOptions?: fetchDataOptions; +} +export interface getNoteAccountsReturns { + events: { + id: string; + index: string; + address: string; + encryptedAccount: string; + }[]; + lastSyncBlock: null | number; +} +export declare function getNoteAccounts({ graphApi, subgraphName, address, fetchDataOptions, }: getNoteAccountsParams): Promise; +export interface GraphEncryptedNotes { + encryptedNotes: { + blockNumber: string; + index: string; + transactionHash: string; + encryptedNote: string; + }[]; + _meta: { + block: { + number: number; + }; + hasIndexingErrors: boolean; + }; +} +export interface getEncryptedNotesParams { + graphApi: string; + subgraphName: string; + fromBlock: number; + fetchDataOptions?: fetchDataOptions; + onProgress?: BatchGraphOnProgress; +} +export declare function getEncryptedNotes({ graphApi, subgraphName, fromBlock, fetchDataOptions, }: getEncryptedNotesParams): Promise; +export declare function getAllEncryptedNotes({ graphApi, subgraphName, fromBlock, fetchDataOptions, onProgress, }: getEncryptedNotesParams): Promise>; diff --git a/dist/services/graphql/queries.d.ts b/dist/services/graphql/queries.d.ts new file mode 100644 index 0000000..3193fc1 --- /dev/null +++ b/dist/services/graphql/queries.d.ts @@ -0,0 +1,7 @@ +export declare const GET_STATISTIC = "\n query getStatistic($currency: String!, $amount: String!, $first: Int, $orderBy: BigInt, $orderDirection: String) {\n deposits(first: $first, orderBy: $orderBy, orderDirection: $orderDirection, where: { currency: $currency, amount: $amount }) {\n index\n timestamp\n blockNumber\n }\n _meta {\n block {\n number\n }\n hasIndexingErrors\n }\n }\n"; +export declare const _META = "\n query getMeta {\n _meta {\n block {\n number\n }\n hasIndexingErrors\n }\n }\n"; +export declare const GET_REGISTERED = "\n query getRegistered($first: Int, $fromBlock: Int) {\n relayers(first: $first, orderBy: blockRegistration, orderDirection: asc, where: {\n blockRegistration_gte: $fromBlock\n }) {\n id\n address\n ensName\n blockRegistration\n }\n _meta {\n block {\n number\n }\n hasIndexingErrors\n }\n }\n"; +export declare const GET_DEPOSITS = "\n query getDeposits($currency: String!, $amount: String!, $first: Int, $fromBlock: Int) {\n deposits(first: $first, orderBy: index, orderDirection: asc, where: { \n amount: $amount,\n currency: $currency,\n blockNumber_gte: $fromBlock\n }) {\n id\n blockNumber\n commitment\n index\n timestamp\n from\n }\n _meta {\n block {\n number\n }\n hasIndexingErrors\n }\n }\n"; +export declare const GET_WITHDRAWALS = "\n query getWithdrawals($currency: String!, $amount: String!, $first: Int, $fromBlock: Int!) {\n withdrawals(first: $first, orderBy: blockNumber, orderDirection: asc, where: { \n currency: $currency,\n amount: $amount,\n blockNumber_gte: $fromBlock\n }) {\n id\n blockNumber\n nullifier\n to\n fee\n timestamp\n }\n _meta {\n block {\n number\n }\n hasIndexingErrors\n }\n }\n"; +export declare const GET_NOTE_ACCOUNTS = "\n query getNoteAccount($address: String!) {\n noteAccounts(where: { address: $address }) {\n id\n index\n address\n encryptedAccount\n }\n _meta {\n block {\n number\n }\n hasIndexingErrors\n }\n }\n"; +export declare const GET_ENCRYPTED_NOTES = "\n query getEncryptedNotes($first: Int, $fromBlock: Int) {\n encryptedNotes(first: $first, orderBy: blockNumber, orderDirection: asc, where: { blockNumber_gte: $fromBlock }) {\n blockNumber\n index\n transactionHash\n encryptedNote\n }\n _meta {\n block {\n number\n }\n hasIndexingErrors\n }\n }\n"; diff --git a/dist/services/index.d.ts b/dist/services/index.d.ts new file mode 100644 index 0000000..764eed9 --- /dev/null +++ b/dist/services/index.d.ts @@ -0,0 +1,19 @@ +export * from './events'; +export * from './graphql'; +export * from './schemas'; +export * from './batch'; +export * from './data'; +export * from './deposits'; +export * from './fees'; +export * from './merkleTree'; +export * from './mimc'; +export * from './multicall'; +export * from './networkConfig'; +export * from './parser'; +export * from './pedersen'; +export * from './prices'; +export * from './providers'; +export * from './relayerClient'; +export * from './tokens'; +export * from './utils'; +export * from './websnark'; diff --git a/dist/services/merkleTree.d.ts b/dist/services/merkleTree.d.ts new file mode 100644 index 0000000..be26649 --- /dev/null +++ b/dist/services/merkleTree.d.ts @@ -0,0 +1,29 @@ +import { MerkleTree, Element } from '@tornado/fixed-merkle-tree'; +import type { Tornado } from '@tornado/contracts'; +import type { DepositType } from './deposits'; +import type { DepositsEvents } from './events'; +export type MerkleTreeConstructor = DepositType & { + Tornado: Tornado; + commitment?: string; + merkleTreeHeight?: number; + emptyElement?: string; + merkleWorkerPath?: string; +}; +export declare class MerkleTreeService { + currency: string; + amount: string; + netId: number; + Tornado: Tornado; + commitment?: string; + instanceName: string; + merkleTreeHeight: number; + emptyElement: string; + merkleWorkerPath?: string; + constructor({ netId, amount, currency, Tornado, commitment, merkleTreeHeight, emptyElement, merkleWorkerPath, }: MerkleTreeConstructor); + createTree({ events }: { + events: Element[]; + }): Promise; + verifyTree({ events }: { + events: DepositsEvents[]; + }): Promise; +} diff --git a/dist/services/mimc.d.ts b/dist/services/mimc.d.ts new file mode 100644 index 0000000..11a506f --- /dev/null +++ b/dist/services/mimc.d.ts @@ -0,0 +1,14 @@ +import { MimcSponge } from 'circomlibjs'; +import type { Element, HashFunction } from '@tornado/fixed-merkle-tree'; +export declare class Mimc { + sponge?: MimcSponge; + hash?: HashFunction; + mimcPromise: Promise; + constructor(); + initMimc(): Promise; + getHash(): Promise<{ + sponge: MimcSponge | undefined; + hash: HashFunction | undefined; + }>; +} +export declare const mimc: Mimc; diff --git a/dist/services/multicall.d.ts b/dist/services/multicall.d.ts new file mode 100644 index 0000000..2ed00a1 --- /dev/null +++ b/dist/services/multicall.d.ts @@ -0,0 +1,11 @@ +import { BaseContract, Interface } from 'ethers'; +import { Multicall } from '../typechain'; +export interface Call3 { + contract?: BaseContract; + address?: string; + interface?: Interface; + name: string; + params?: any[]; + allowFailure?: boolean; +} +export declare function multicall(Multicall: Multicall, calls: Call3[]): Promise; diff --git a/dist/services/networkConfig.d.ts b/dist/services/networkConfig.d.ts new file mode 100644 index 0000000..28c1626 --- /dev/null +++ b/dist/services/networkConfig.d.ts @@ -0,0 +1,86 @@ +export interface RpcUrl { + name: string; + url: string; +} +export type RpcUrls = { + [key in string]: RpcUrl; +}; +export interface SubgraphUrl { + name: string; + url: string; +} +export type SubgraphUrls = { + [key in string]: SubgraphUrl; +}; +export type TornadoInstance = { + instanceAddress: { + [key in string]: string; + }; + optionalInstances?: string[]; + tokenAddress?: string; + tokenGasLimit?: number; + symbol: string; + decimals: number; + gasLimit?: number; +}; +export type TokenInstances = { + [key in string]: TornadoInstance; +}; +export type Config = { + rpcCallRetryAttempt?: number; + gasPrices: { + instant: number; + fast?: number; + standard?: number; + low?: number; + maxPriorityFeePerGas?: number; + }; + nativeCurrency: string; + currencyName: string; + explorerUrl: { + tx: string; + address: string; + block: string; + }; + merkleTreeHeight: number; + emptyElement: string; + networkName: string; + deployedBlock: number; + rpcUrls: RpcUrls; + multicall: string; + routerContract: string; + registryContract?: string; + echoContract: string; + aggregatorContract?: string; + reverseRecordsContract?: string; + gasPriceOracleContract?: string; + gasStationApi?: string; + ovmGasPriceOracleContract?: string; + tornadoSubgraph: string; + registrySubgraph?: string; + subgraphs: SubgraphUrls; + tokens: TokenInstances; + optionalTokens?: string[]; + ensSubdomainKey: string; + pollInterval: number; + constants: { + GOVERNANCE_BLOCK?: number; + NOTE_ACCOUNT_BLOCK?: number; + ENCRYPTED_NOTES_BLOCK?: number; + REGISTRY_BLOCK?: number; + MINING_BLOCK_TIME?: number; + }; + 'torn.contract.tornadocash.eth'?: string; + 'governance.contract.tornadocash.eth'?: string; + 'staking-rewards.contract.tornadocash.eth'?: string; + 'tornado-router.contract.tornadocash.eth'?: string; + 'tornado-proxy-light.contract.tornadocash.eth'?: string; +}; +export type networkConfig = { + [key in string]: Config; +}; +export declare const blockSyncInterval = 10000; +export declare const enabledChains: string[]; +export declare const networkConfig: networkConfig; +export declare const subdomains: string[]; +export default networkConfig; diff --git a/dist/services/parser.d.ts b/dist/services/parser.d.ts new file mode 100644 index 0000000..1f191a7 --- /dev/null +++ b/dist/services/parser.d.ts @@ -0,0 +1,6 @@ +export declare function parseNumber(value?: string | number): number; +export declare function parseUrl(value?: string): string; +export declare function parseRelayer(value?: string): string; +export declare function parseAddress(value?: string): string; +export declare function parseMnemonic(value?: string): string; +export declare function parseKey(value?: string): string; diff --git a/dist/services/pedersen.d.ts b/dist/services/pedersen.d.ts new file mode 100644 index 0000000..18eef7a --- /dev/null +++ b/dist/services/pedersen.d.ts @@ -0,0 +1,12 @@ +import { BabyJub, PedersenHash, Point } from 'circomlibjs'; +export declare class Pedersen { + pedersenHash?: PedersenHash; + babyJub?: BabyJub; + pedersenPromise: Promise; + constructor(); + initPedersen(): Promise; + unpackPoint(buffer: Uint8Array): Promise; + toStringBuffer(buffer: Uint8Array): string; +} +export declare const pedersen: Pedersen; +export declare function buffPedersenHash(buffer: Uint8Array): Promise; diff --git a/dist/services/prices.d.ts b/dist/services/prices.d.ts new file mode 100644 index 0000000..f943d44 --- /dev/null +++ b/dist/services/prices.d.ts @@ -0,0 +1,9 @@ +import { type Provider } from 'ethers'; +import type { OffchainOracle, Multicall } from '../typechain'; +export declare class TokenPriceOracle { + oracle?: OffchainOracle; + multicall: Multicall; + provider: Provider; + constructor(provider: Provider, multicall: Multicall, oracle?: OffchainOracle); + fetchPrices(tokens: string[]): Promise; +} diff --git a/dist/services/providers.d.ts b/dist/services/providers.d.ts new file mode 100644 index 0000000..3396d13 --- /dev/null +++ b/dist/services/providers.d.ts @@ -0,0 +1,93 @@ +/// +/// +/// +import type { EventEmitter } from 'stream'; +import type { RequestOptions } from 'http'; +import { JsonRpcApiProvider, JsonRpcProvider, Wallet, FetchGetUrlFunc, Provider, SigningKey, TransactionRequest, JsonRpcSigner, BrowserProvider, Networkish, Eip1193Provider, VoidSigner, FetchUrlFeeDataNetworkPlugin, BigNumberish } from 'ethers'; +import type { RequestInfo, RequestInit, Response, HeadersInit } from 'node-fetch'; +import type { Config } from './networkConfig'; +declare global { + interface Window { + ethereum?: Eip1193Provider & EventEmitter; + } +} +export declare const defaultUserAgent = "Mozilla/5.0 (Windows NT 10.0; rv:109.0) Gecko/20100101 Firefox/115.0"; +export declare const fetch: nodeFetch; +export type nodeFetch = (url: RequestInfo, init?: RequestInit) => Promise; +export type fetchDataOptions = RequestInit & { + headers?: HeadersInit | any; + maxRetry?: number; + retryOn?: number; + userAgent?: string; + timeout?: number; + proxy?: string; + torPort?: number; + debug?: Function; + returnResponse?: boolean; +}; +export type NodeAgent = RequestOptions['agent'] | ((parsedUrl: URL) => RequestOptions['agent']); +export declare function getHttpAgent({ fetchUrl, proxyUrl, torPort, retry, }: { + fetchUrl: string; + proxyUrl?: string; + torPort?: number; + retry: number; +}): NodeAgent | undefined; +export declare function fetchData(url: string, options?: fetchDataOptions): Promise; +export declare const fetchGetUrlFunc: (options?: fetchDataOptions) => FetchGetUrlFunc; +export type getProviderOptions = fetchDataOptions & { + pollingInterval?: number; + gasPriceOracle?: string; + gasStationApi?: string; +}; +export declare function getGasOraclePlugin(networkKey: string, fetchOptions?: getProviderOptions): FetchUrlFeeDataNetworkPlugin; +export declare function getProvider(rpcUrl: string, fetchOptions?: getProviderOptions): Promise; +export declare function getProviderWithNetId(netId: BigNumberish, rpcUrl: string, config: Config, fetchOptions?: getProviderOptions): JsonRpcProvider; +export declare const populateTransaction: (signer: TornadoWallet | TornadoVoidSigner | TornadoRpcSigner, tx: TransactionRequest) => Promise; +export type TornadoWalletOptions = { + gasPriceBump?: number; + gasLimitBump?: number; + gasFailover?: boolean; + bumpNonce?: boolean; +}; +export declare class TornadoWallet extends Wallet { + nonce?: number | null; + gasPriceBump: number; + gasLimitBump: number; + gasFailover: boolean; + bumpNonce: boolean; + constructor(key: string | SigningKey, provider?: null | Provider, { gasPriceBump, gasLimitBump, gasFailover, bumpNonce }?: TornadoWalletOptions); + static fromMnemonic(mneomnic: string, provider: Provider, index?: number, options?: TornadoWalletOptions): TornadoWallet; + populateTransaction(tx: TransactionRequest): Promise>; +} +export declare class TornadoVoidSigner extends VoidSigner { + nonce?: number | null; + gasPriceBump: number; + gasLimitBump: number; + gasFailover: boolean; + bumpNonce: boolean; + constructor(address: string, provider?: null | Provider, { gasPriceBump, gasLimitBump, gasFailover, bumpNonce }?: TornadoWalletOptions); + populateTransaction(tx: TransactionRequest): Promise>; +} +export declare class TornadoRpcSigner extends JsonRpcSigner { + nonce?: number | null; + gasPriceBump: number; + gasLimitBump: number; + gasFailover: boolean; + bumpNonce: boolean; + constructor(provider: JsonRpcApiProvider, address: string, { gasPriceBump, gasLimitBump, gasFailover, bumpNonce }?: TornadoWalletOptions); + sendUncheckedTransaction(tx: TransactionRequest): Promise; +} +export type connectWalletFunc = (...args: any[]) => Promise; +export type handleWalletFunc = (...args: any[]) => void; +export type TornadoBrowserProviderOptions = TornadoWalletOptions & { + webChainId?: BigNumberish; + connectWallet?: connectWalletFunc; + handleNetworkChanges?: handleWalletFunc; + handleAccountChanges?: handleWalletFunc; + handleAccountDisconnect?: handleWalletFunc; +}; +export declare class TornadoBrowserProvider extends BrowserProvider { + options?: TornadoBrowserProviderOptions; + constructor(ethereum: Eip1193Provider, network?: Networkish, options?: TornadoBrowserProviderOptions); + getSigner(address: string): Promise; +} diff --git a/dist/services/relayerClient.d.ts b/dist/services/relayerClient.d.ts new file mode 100644 index 0000000..a663fa8 --- /dev/null +++ b/dist/services/relayerClient.d.ts @@ -0,0 +1,118 @@ +import type { Aggregator } from '@tornado/contracts'; +import type { RelayerStructOutput } from '@tornado/contracts/dist/contracts/Governance/Aggregator/Aggregator'; +import type { Config } from './networkConfig'; +import { fetchDataOptions } from './providers'; +import type { snarkProofs } from './websnark'; +export declare const MIN_STAKE_BALANCE: bigint; +export interface RelayerParams { + ensName: string; + relayerAddress?: string; +} +export interface Relayer { + netId: number; + url: string; + rewardAccount: string; + currentQueue: number; + tornadoServiceFee: number; +} +export type RelayerInfo = Relayer & { + hostname: string; + ensName: string; + stakeBalance: bigint; + relayerAddress: string; + ethPrices?: { + [key in string]: string; + }; +}; +export type RelayerError = { + hostname: string; + relayerAddress?: string; + errorMessage?: string; +}; +export interface RelayerStatus { + url: string; + rewardAccount: string; + instances: { + [key in string]: { + instanceAddress: { + [key in string]: string; + }; + tokenAddress?: string; + symbol: string; + decimals: number; + }; + }; + gasPrices?: { + fast: number; + additionalProperties?: number; + }; + netId: number; + ethPrices?: { + [key in string]: string; + }; + tornadoServiceFee: number; + latestBlock?: number; + version: string; + health: { + status: string; + error: string; + errorsLog: any[]; + }; + currentQueue: number; +} +export interface RelayerTornadoWithdraw { + id?: string; + error?: string; +} +export interface RelayerTornadoJobs { + error?: string; + id: string; + type?: string; + status: string; + contract?: string; + proof?: string; + args?: string[]; + txHash?: string; + confirmations?: number; + failedReason?: string; +} +export interface semanticVersion { + major: string; + minor: string; + patch: string; + prerelease?: string; + buildmetadata?: string; +} +export declare function parseSemanticVersion(version: string): semanticVersion; +export declare function isRelayerUpdated(relayerVersion: string, netId: number | string): boolean; +export declare function calculateScore({ stakeBalance, tornadoServiceFee }: RelayerInfo, minFee?: number, maxFee?: number): bigint; +export declare function getWeightRandom(weightsScores: bigint[], random: bigint): number; +export declare function pickWeightedRandomRelayer(relayers: RelayerInfo[], netId: string | number): RelayerInfo; +export interface RelayerClientConstructor { + netId: number | string; + config: Config; + Aggregator: Aggregator; + fetchDataOptions?: fetchDataOptions; +} +export type RelayerClientWithdraw = snarkProofs & { + contract: string; +}; +export declare class RelayerClient { + netId: number; + config: Config; + Aggregator: Aggregator; + selectedRelayer?: Relayer; + fetchDataOptions?: fetchDataOptions; + constructor({ netId, config, Aggregator, fetchDataOptions }: RelayerClientConstructor); + askRelayerStatus({ hostname, relayerAddress, }: { + hostname: string; + relayerAddress?: string; + }): Promise; + filterRelayer(curr: RelayerStructOutput, relayer: RelayerParams, subdomains: string[], debugRelayer?: boolean): Promise; + getValidRelayers(relayers: RelayerParams[], subdomains: string[], debugRelayer?: boolean): Promise<{ + validRelayers: RelayerInfo[]; + invalidRelayers: RelayerError[]; + }>; + pickWeightedRandomRelayer(relayers: RelayerInfo[]): RelayerInfo; + tornadoWithdraw({ contract, proof, args }: RelayerClientWithdraw): Promise; +} diff --git a/dist/services/schemas/index.d.ts b/dist/services/schemas/index.d.ts new file mode 100644 index 0000000..b3c1810 --- /dev/null +++ b/dist/services/schemas/index.d.ts @@ -0,0 +1,4 @@ +import Ajv from 'ajv'; +export declare const ajv: Ajv; +export * from './status'; +export * from './jobs'; diff --git a/dist/services/schemas/jobs.d.ts b/dist/services/schemas/jobs.d.ts new file mode 100644 index 0000000..15a2220 --- /dev/null +++ b/dist/services/schemas/jobs.d.ts @@ -0,0 +1,40 @@ +export type jobsSchema = { + type: string; + properties: { + error: { + type: string; + }; + id: { + type: string; + }; + type: { + type: string; + }; + status: { + type: string; + }; + contract: { + type: string; + }; + proof: { + type: string; + }; + args: { + type: string; + items: { + type: string; + }; + }; + txHash: { + type: string; + }; + confirmations: { + type: string; + }; + failedReason: { + type: string; + }; + }; + required: string[]; +}; +export declare const jobsSchema: jobsSchema; diff --git a/dist/services/schemas/status.d.ts b/dist/services/schemas/status.d.ts new file mode 100644 index 0000000..83912ee --- /dev/null +++ b/dist/services/schemas/status.d.ts @@ -0,0 +1,92 @@ +import type { Config } from '../networkConfig'; +export type statusInstanceType = { + type: string; + properties: { + instanceAddress: { + type: string; + properties: { + [key in string]: typeof addressType; + }; + required: string[]; + }; + tokenAddress?: typeof addressType; + symbol?: { + enum: string[]; + }; + decimals: { + enum: number[]; + }; + }; + required: string[]; +}; +export type statusInstancesType = { + type: string; + properties: { + [key in string]: statusInstanceType; + }; + required: string[]; +}; +export type statusEthPricesType = { + type: string; + properties: { + [key in string]: typeof bnType; + }; + required?: string[]; +}; +export type statusSchema = { + type: string; + properties: { + rewardAccount: typeof addressType; + instances?: statusInstancesType; + gasPrices: { + type: string; + properties: { + [key in string]: { + type: string; + }; + }; + required: string[]; + }; + netId: { + type: string; + }; + ethPrices?: statusEthPricesType; + tornadoServiceFee?: { + type: string; + maximum: number; + minimum: number; + }; + latestBlock?: { + type: string; + }; + version: { + type: string; + }; + health: { + type: string; + properties: { + status: { + const: string; + }; + error: { + type: string; + }; + }; + required: string[]; + }; + currentQueue: { + type: string; + }; + }; + required: string[]; +}; +declare const addressType: { + type: string; + pattern: string; +}; +declare const bnType: { + type: string; + BN: boolean; +}; +export declare function getStatusSchema(netId: number | string, config: Config): statusSchema; +export {}; diff --git a/dist/services/tokens.d.ts b/dist/services/tokens.d.ts new file mode 100644 index 0000000..2c8a2af --- /dev/null +++ b/dist/services/tokens.d.ts @@ -0,0 +1,16 @@ +import { Provider } from 'ethers'; +import { Multicall } from '../typechain'; +export interface tokenBalances { + address: string; + name: string; + symbol: string; + decimals: number; + balance: bigint; +} +export declare function getTokenBalances({ provider, Multicall, currencyName, userAddress, tokenAddresses, }: { + provider: Provider; + Multicall: Multicall; + currencyName: string; + userAddress: string; + tokenAddresses: string[]; +}): Promise; diff --git a/dist/services/utils.d.ts b/dist/services/utils.d.ts new file mode 100644 index 0000000..6795036 --- /dev/null +++ b/dist/services/utils.d.ts @@ -0,0 +1,22 @@ +/// +import BN from 'bn.js'; +import type { BigNumberish } from 'ethers'; +type bnInput = number | string | number[] | Uint8Array | Buffer | BN; +export declare const isNode: boolean; +export declare const chunk: (arr: T[], size: number) => T[][]; +export declare function sleep(ms: number): Promise; +export declare function validateUrl(url: string, protocols?: string[]): boolean; +export declare function bufferToBytes(b: Buffer): Uint8Array; +export declare function bytesToBase64(bytes: Uint8Array): string; +export declare function base64ToBytes(base64: string): Uint8Array; +export declare function bytesToHex(bytes: Uint8Array): string; +export declare function bytesToBN(bytes: Uint8Array): bigint; +export declare function bnToBytes(bigint: bigint | string): Uint8Array; +export declare function leBuff2Int(bytes: Uint8Array): BN; +export declare function leInt2Buff(bigint: bnInput | bigint): Uint8Array; +export declare function toFixedHex(numberish: BigNumberish, length?: number): string; +export declare function toFixedLength(string: string, length?: number): string; +export declare function rBigInt(nbytes?: number): bigint; +export declare function bigIntReplacer(key: any, value: any): any; +export declare function substring(str: string, length?: number): string; +export {}; diff --git a/dist/services/websnark.d.ts b/dist/services/websnark.d.ts new file mode 100644 index 0000000..461d57a --- /dev/null +++ b/dist/services/websnark.d.ts @@ -0,0 +1,27 @@ +import type { Element } from '@tornado/fixed-merkle-tree'; +import type { AddressLike, BytesLike, BigNumberish } from 'ethers'; +export type snarkInputs = { + root: Element; + nullifierHex: string; + recipient: AddressLike; + relayer: AddressLike; + fee: bigint; + refund: bigint; + nullifier: bigint; + secret: bigint; + pathElements: Element[]; + pathIndices: Element[]; +}; +export type snarkArgs = [ + _root: BytesLike, + _nullifierHash: BytesLike, + _recipient: AddressLike, + _relayer: AddressLike, + _fee: BigNumberish, + _refund: BigNumberish +]; +export type snarkProofs = { + proof: BytesLike; + args: snarkArgs; +}; +export declare function calculateSnarkProof(input: snarkInputs, circuit: object, provingKey: ArrayBuffer): Promise; diff --git a/dist/typechain/ENS.d.ts b/dist/typechain/ENS.d.ts new file mode 100644 index 0000000..9f65210 --- /dev/null +++ b/dist/typechain/ENS.d.ts @@ -0,0 +1,423 @@ +import type { BaseContract, BigNumberish, BytesLike, FunctionFragment, Result, Interface, EventFragment, AddressLike, ContractRunner, ContractMethod, Listener } from "ethers"; +import type { TypedContractEvent, TypedDeferredTopicFilter, TypedEventLog, TypedLogDescription, TypedListener, TypedContractMethod } from "./common"; +export interface ENSInterface extends Interface { + getFunction(nameOrSignature: "supportsInterface" | "setText" | "interfaceImplementer" | "ABI" | "setPubkey" | "setContenthash" | "addr(bytes32)" | "addr(bytes32,uint256)" | "setAuthorisation" | "text" | "setABI" | "name" | "setName" | "setAddr(bytes32,uint256,bytes)" | "setAddr(bytes32,address)" | "contenthash" | "pubkey" | "setInterface" | "authorisations"): FunctionFragment; + getEvent(nameOrSignatureOrTopic: "AuthorisationChanged" | "TextChanged" | "PubkeyChanged" | "NameChanged" | "InterfaceChanged" | "ContenthashChanged" | "AddrChanged" | "AddressChanged" | "ABIChanged"): EventFragment; + encodeFunctionData(functionFragment: "supportsInterface", values: [BytesLike]): string; + encodeFunctionData(functionFragment: "setText", values: [BytesLike, string, string]): string; + encodeFunctionData(functionFragment: "interfaceImplementer", values: [BytesLike, BytesLike]): string; + encodeFunctionData(functionFragment: "ABI", values: [BytesLike, BigNumberish]): string; + encodeFunctionData(functionFragment: "setPubkey", values: [BytesLike, BytesLike, BytesLike]): string; + encodeFunctionData(functionFragment: "setContenthash", values: [BytesLike, BytesLike]): string; + encodeFunctionData(functionFragment: "addr(bytes32)", values: [BytesLike]): string; + encodeFunctionData(functionFragment: "addr(bytes32,uint256)", values: [BytesLike, BigNumberish]): string; + encodeFunctionData(functionFragment: "setAuthorisation", values: [BytesLike, AddressLike, boolean]): string; + encodeFunctionData(functionFragment: "text", values: [BytesLike, string]): string; + encodeFunctionData(functionFragment: "setABI", values: [BytesLike, BigNumberish, BytesLike]): string; + encodeFunctionData(functionFragment: "name", values: [BytesLike]): string; + encodeFunctionData(functionFragment: "setName", values: [BytesLike, string]): string; + encodeFunctionData(functionFragment: "setAddr(bytes32,uint256,bytes)", values: [BytesLike, BigNumberish, BytesLike]): string; + encodeFunctionData(functionFragment: "setAddr(bytes32,address)", values: [BytesLike, AddressLike]): string; + encodeFunctionData(functionFragment: "contenthash", values: [BytesLike]): string; + encodeFunctionData(functionFragment: "pubkey", values: [BytesLike]): string; + encodeFunctionData(functionFragment: "setInterface", values: [BytesLike, BytesLike, AddressLike]): string; + encodeFunctionData(functionFragment: "authorisations", values: [BytesLike, AddressLike, AddressLike]): string; + decodeFunctionResult(functionFragment: "supportsInterface", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setText", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "interfaceImplementer", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "ABI", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setPubkey", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setContenthash", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "addr(bytes32)", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "addr(bytes32,uint256)", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setAuthorisation", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "text", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setABI", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "name", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setName", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setAddr(bytes32,uint256,bytes)", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setAddr(bytes32,address)", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "contenthash", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "pubkey", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setInterface", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "authorisations", data: BytesLike): Result; +} +export declare namespace AuthorisationChangedEvent { + type InputTuple = [ + node: BytesLike, + owner: AddressLike, + target: AddressLike, + isAuthorised: boolean + ]; + type OutputTuple = [ + node: string, + owner: string, + target: string, + isAuthorised: boolean + ]; + interface OutputObject { + node: string; + owner: string; + target: string; + isAuthorised: boolean; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace TextChangedEvent { + type InputTuple = [node: BytesLike, indexedKey: string, key: string]; + type OutputTuple = [node: string, indexedKey: string, key: string]; + interface OutputObject { + node: string; + indexedKey: string; + key: string; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace PubkeyChangedEvent { + type InputTuple = [node: BytesLike, x: BytesLike, y: BytesLike]; + type OutputTuple = [node: string, x: string, y: string]; + interface OutputObject { + node: string; + x: string; + y: string; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace NameChangedEvent { + type InputTuple = [node: BytesLike, name: string]; + type OutputTuple = [node: string, name: string]; + interface OutputObject { + node: string; + name: string; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace InterfaceChangedEvent { + type InputTuple = [ + node: BytesLike, + interfaceID: BytesLike, + implementer: AddressLike + ]; + type OutputTuple = [ + node: string, + interfaceID: string, + implementer: string + ]; + interface OutputObject { + node: string; + interfaceID: string; + implementer: string; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace ContenthashChangedEvent { + type InputTuple = [node: BytesLike, hash: BytesLike]; + type OutputTuple = [node: string, hash: string]; + interface OutputObject { + node: string; + hash: string; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace AddrChangedEvent { + type InputTuple = [node: BytesLike, a: AddressLike]; + type OutputTuple = [node: string, a: string]; + interface OutputObject { + node: string; + a: string; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace AddressChangedEvent { + type InputTuple = [ + node: BytesLike, + coinType: BigNumberish, + newAddress: BytesLike + ]; + type OutputTuple = [ + node: string, + coinType: bigint, + newAddress: string + ]; + interface OutputObject { + node: string; + coinType: bigint; + newAddress: string; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace ABIChangedEvent { + type InputTuple = [node: BytesLike, contentType: BigNumberish]; + type OutputTuple = [node: string, contentType: bigint]; + interface OutputObject { + node: string; + contentType: bigint; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export interface ENS extends BaseContract { + connect(runner?: ContractRunner | null): ENS; + waitForDeployment(): Promise; + interface: ENSInterface; + queryFilter(event: TCEvent, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise>>; + queryFilter(filter: TypedDeferredTopicFilter, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise>>; + on(event: TCEvent, listener: TypedListener): Promise; + on(filter: TypedDeferredTopicFilter, listener: TypedListener): Promise; + once(event: TCEvent, listener: TypedListener): Promise; + once(filter: TypedDeferredTopicFilter, listener: TypedListener): Promise; + listeners(event: TCEvent): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners(event?: TCEvent): Promise; + supportsInterface: TypedContractMethod<[ + interfaceID: BytesLike + ], [ + boolean + ], "view">; + setText: TypedContractMethod<[ + node: BytesLike, + key: string, + value: string + ], [ + void + ], "nonpayable">; + interfaceImplementer: TypedContractMethod<[ + node: BytesLike, + interfaceID: BytesLike + ], [ + string + ], "view">; + ABI: TypedContractMethod<[ + node: BytesLike, + contentTypes: BigNumberish + ], [ + [bigint, string] + ], "view">; + setPubkey: TypedContractMethod<[ + node: BytesLike, + x: BytesLike, + y: BytesLike + ], [ + void + ], "nonpayable">; + setContenthash: TypedContractMethod<[ + node: BytesLike, + hash: BytesLike + ], [ + void + ], "nonpayable">; + "addr(bytes32)": TypedContractMethod<[node: BytesLike], [string], "view">; + "addr(bytes32,uint256)": TypedContractMethod<[ + node: BytesLike, + coinType: BigNumberish + ], [ + string + ], "view">; + setAuthorisation: TypedContractMethod<[ + node: BytesLike, + target: AddressLike, + isAuthorised: boolean + ], [ + void + ], "nonpayable">; + text: TypedContractMethod<[node: BytesLike, key: string], [string], "view">; + setABI: TypedContractMethod<[ + node: BytesLike, + contentType: BigNumberish, + data: BytesLike + ], [ + void + ], "nonpayable">; + name: TypedContractMethod<[node: BytesLike], [string], "view">; + setName: TypedContractMethod<[ + node: BytesLike, + name: string + ], [ + void + ], "nonpayable">; + "setAddr(bytes32,uint256,bytes)": TypedContractMethod<[ + node: BytesLike, + coinType: BigNumberish, + a: BytesLike + ], [ + void + ], "nonpayable">; + "setAddr(bytes32,address)": TypedContractMethod<[ + node: BytesLike, + a: AddressLike + ], [ + void + ], "nonpayable">; + contenthash: TypedContractMethod<[node: BytesLike], [string], "view">; + pubkey: TypedContractMethod<[ + node: BytesLike + ], [ + [string, string] & { + x: string; + y: string; + } + ], "view">; + setInterface: TypedContractMethod<[ + node: BytesLike, + interfaceID: BytesLike, + implementer: AddressLike + ], [ + void + ], "nonpayable">; + authorisations: TypedContractMethod<[ + arg0: BytesLike, + arg1: AddressLike, + arg2: AddressLike + ], [ + boolean + ], "view">; + getFunction(key: string | FunctionFragment): T; + getFunction(nameOrSignature: "supportsInterface"): TypedContractMethod<[interfaceID: BytesLike], [boolean], "view">; + getFunction(nameOrSignature: "setText"): TypedContractMethod<[ + node: BytesLike, + key: string, + value: string + ], [ + void + ], "nonpayable">; + getFunction(nameOrSignature: "interfaceImplementer"): TypedContractMethod<[ + node: BytesLike, + interfaceID: BytesLike + ], [ + string + ], "view">; + getFunction(nameOrSignature: "ABI"): TypedContractMethod<[ + node: BytesLike, + contentTypes: BigNumberish + ], [ + [bigint, string] + ], "view">; + getFunction(nameOrSignature: "setPubkey"): TypedContractMethod<[ + node: BytesLike, + x: BytesLike, + y: BytesLike + ], [ + void + ], "nonpayable">; + getFunction(nameOrSignature: "setContenthash"): TypedContractMethod<[ + node: BytesLike, + hash: BytesLike + ], [ + void + ], "nonpayable">; + getFunction(nameOrSignature: "addr(bytes32)"): TypedContractMethod<[node: BytesLike], [string], "view">; + getFunction(nameOrSignature: "addr(bytes32,uint256)"): TypedContractMethod<[ + node: BytesLike, + coinType: BigNumberish + ], [ + string + ], "view">; + getFunction(nameOrSignature: "setAuthorisation"): TypedContractMethod<[ + node: BytesLike, + target: AddressLike, + isAuthorised: boolean + ], [ + void + ], "nonpayable">; + getFunction(nameOrSignature: "text"): TypedContractMethod<[node: BytesLike, key: string], [string], "view">; + getFunction(nameOrSignature: "setABI"): TypedContractMethod<[ + node: BytesLike, + contentType: BigNumberish, + data: BytesLike + ], [ + void + ], "nonpayable">; + getFunction(nameOrSignature: "name"): TypedContractMethod<[node: BytesLike], [string], "view">; + getFunction(nameOrSignature: "setName"): TypedContractMethod<[node: BytesLike, name: string], [void], "nonpayable">; + getFunction(nameOrSignature: "setAddr(bytes32,uint256,bytes)"): TypedContractMethod<[ + node: BytesLike, + coinType: BigNumberish, + a: BytesLike + ], [ + void + ], "nonpayable">; + getFunction(nameOrSignature: "setAddr(bytes32,address)"): TypedContractMethod<[ + node: BytesLike, + a: AddressLike + ], [ + void + ], "nonpayable">; + getFunction(nameOrSignature: "contenthash"): TypedContractMethod<[node: BytesLike], [string], "view">; + getFunction(nameOrSignature: "pubkey"): TypedContractMethod<[ + node: BytesLike + ], [ + [string, string] & { + x: string; + y: string; + } + ], "view">; + getFunction(nameOrSignature: "setInterface"): TypedContractMethod<[ + node: BytesLike, + interfaceID: BytesLike, + implementer: AddressLike + ], [ + void + ], "nonpayable">; + getFunction(nameOrSignature: "authorisations"): TypedContractMethod<[ + arg0: BytesLike, + arg1: AddressLike, + arg2: AddressLike + ], [ + boolean + ], "view">; + getEvent(key: "AuthorisationChanged"): TypedContractEvent; + getEvent(key: "TextChanged"): TypedContractEvent; + getEvent(key: "PubkeyChanged"): TypedContractEvent; + getEvent(key: "NameChanged"): TypedContractEvent; + getEvent(key: "InterfaceChanged"): TypedContractEvent; + getEvent(key: "ContenthashChanged"): TypedContractEvent; + getEvent(key: "AddrChanged"): TypedContractEvent; + getEvent(key: "AddressChanged"): TypedContractEvent; + getEvent(key: "ABIChanged"): TypedContractEvent; + filters: { + "AuthorisationChanged(bytes32,address,address,bool)": TypedContractEvent; + AuthorisationChanged: TypedContractEvent; + "TextChanged(bytes32,string,string)": TypedContractEvent; + TextChanged: TypedContractEvent; + "PubkeyChanged(bytes32,bytes32,bytes32)": TypedContractEvent; + PubkeyChanged: TypedContractEvent; + "NameChanged(bytes32,string)": TypedContractEvent; + NameChanged: TypedContractEvent; + "InterfaceChanged(bytes32,bytes4,address)": TypedContractEvent; + InterfaceChanged: TypedContractEvent; + "ContenthashChanged(bytes32,bytes)": TypedContractEvent; + ContenthashChanged: TypedContractEvent; + "AddrChanged(bytes32,address)": TypedContractEvent; + AddrChanged: TypedContractEvent; + "AddressChanged(bytes32,uint256,bytes)": TypedContractEvent; + AddressChanged: TypedContractEvent; + "ABIChanged(bytes32,uint256)": TypedContractEvent; + ABIChanged: TypedContractEvent; + }; +} diff --git a/dist/typechain/ERC20.d.ts b/dist/typechain/ERC20.d.ts new file mode 100644 index 0000000..6e3ee80 --- /dev/null +++ b/dist/typechain/ERC20.d.ts @@ -0,0 +1,181 @@ +import type { BaseContract, BigNumberish, BytesLike, FunctionFragment, Result, Interface, EventFragment, AddressLike, ContractRunner, ContractMethod, Listener } from "ethers"; +import type { TypedContractEvent, TypedDeferredTopicFilter, TypedEventLog, TypedLogDescription, TypedListener, TypedContractMethod } from "./common"; +export interface ERC20Interface extends Interface { + getFunction(nameOrSignature: "totalSupply" | "_totalSupply" | "balanceOf" | "name" | "symbol" | "decimals" | "transfer" | "allowance" | "transferFrom" | "approve" | "nonces" | "permit"): FunctionFragment; + getEvent(nameOrSignatureOrTopic: "Approval" | "Transfer"): EventFragment; + encodeFunctionData(functionFragment: "totalSupply", values?: undefined): string; + encodeFunctionData(functionFragment: "_totalSupply", values?: undefined): string; + encodeFunctionData(functionFragment: "balanceOf", values: [AddressLike]): string; + encodeFunctionData(functionFragment: "name", values?: undefined): string; + encodeFunctionData(functionFragment: "symbol", values?: undefined): string; + encodeFunctionData(functionFragment: "decimals", values?: undefined): string; + encodeFunctionData(functionFragment: "transfer", values: [AddressLike, BigNumberish]): string; + encodeFunctionData(functionFragment: "allowance", values: [AddressLike, AddressLike]): string; + encodeFunctionData(functionFragment: "transferFrom", values: [AddressLike, AddressLike, BigNumberish]): string; + encodeFunctionData(functionFragment: "approve", values: [AddressLike, BigNumberish]): string; + encodeFunctionData(functionFragment: "nonces", values: [AddressLike]): string; + encodeFunctionData(functionFragment: "permit", values: [ + AddressLike, + AddressLike, + BigNumberish, + BigNumberish, + BigNumberish, + BytesLike, + BytesLike + ]): string; + decodeFunctionResult(functionFragment: "totalSupply", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "_totalSupply", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "balanceOf", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "name", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "symbol", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "decimals", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "transfer", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "allowance", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "transferFrom", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "approve", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "nonces", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "permit", data: BytesLike): Result; +} +export declare namespace ApprovalEvent { + type InputTuple = [ + owner: AddressLike, + spender: AddressLike, + value: BigNumberish + ]; + type OutputTuple = [owner: string, spender: string, value: bigint]; + interface OutputObject { + owner: string; + spender: string; + value: bigint; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace TransferEvent { + type InputTuple = [ + from: AddressLike, + to: AddressLike, + value: BigNumberish + ]; + type OutputTuple = [from: string, to: string, value: bigint]; + interface OutputObject { + from: string; + to: string; + value: bigint; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export interface ERC20 extends BaseContract { + connect(runner?: ContractRunner | null): ERC20; + waitForDeployment(): Promise; + interface: ERC20Interface; + queryFilter(event: TCEvent, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise>>; + queryFilter(filter: TypedDeferredTopicFilter, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise>>; + on(event: TCEvent, listener: TypedListener): Promise; + on(filter: TypedDeferredTopicFilter, listener: TypedListener): Promise; + once(event: TCEvent, listener: TypedListener): Promise; + once(filter: TypedDeferredTopicFilter, listener: TypedListener): Promise; + listeners(event: TCEvent): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners(event?: TCEvent): Promise; + totalSupply: TypedContractMethod<[], [bigint], "view">; + _totalSupply: TypedContractMethod<[], [bigint], "view">; + balanceOf: TypedContractMethod<[who: AddressLike], [bigint], "view">; + name: TypedContractMethod<[], [string], "view">; + symbol: TypedContractMethod<[], [string], "view">; + decimals: TypedContractMethod<[], [bigint], "view">; + transfer: TypedContractMethod<[ + to: AddressLike, + value: BigNumberish + ], [ + void + ], "nonpayable">; + allowance: TypedContractMethod<[ + owner: AddressLike, + spender: AddressLike + ], [ + bigint + ], "view">; + transferFrom: TypedContractMethod<[ + from: AddressLike, + to: AddressLike, + value: BigNumberish + ], [ + void + ], "nonpayable">; + approve: TypedContractMethod<[ + spender: AddressLike, + value: BigNumberish + ], [ + void + ], "nonpayable">; + nonces: TypedContractMethod<[owner: AddressLike], [bigint], "view">; + permit: TypedContractMethod<[ + owner: AddressLike, + spender: AddressLike, + amount: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike + ], [ + void + ], "nonpayable">; + getFunction(key: string | FunctionFragment): T; + getFunction(nameOrSignature: "totalSupply"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "_totalSupply"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "balanceOf"): TypedContractMethod<[who: AddressLike], [bigint], "view">; + getFunction(nameOrSignature: "name"): TypedContractMethod<[], [string], "view">; + getFunction(nameOrSignature: "symbol"): TypedContractMethod<[], [string], "view">; + getFunction(nameOrSignature: "decimals"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "transfer"): TypedContractMethod<[ + to: AddressLike, + value: BigNumberish + ], [ + void + ], "nonpayable">; + getFunction(nameOrSignature: "allowance"): TypedContractMethod<[ + owner: AddressLike, + spender: AddressLike + ], [ + bigint + ], "view">; + getFunction(nameOrSignature: "transferFrom"): TypedContractMethod<[ + from: AddressLike, + to: AddressLike, + value: BigNumberish + ], [ + void + ], "nonpayable">; + getFunction(nameOrSignature: "approve"): TypedContractMethod<[ + spender: AddressLike, + value: BigNumberish + ], [ + void + ], "nonpayable">; + getFunction(nameOrSignature: "nonces"): TypedContractMethod<[owner: AddressLike], [bigint], "view">; + getFunction(nameOrSignature: "permit"): TypedContractMethod<[ + owner: AddressLike, + spender: AddressLike, + amount: BigNumberish, + deadline: BigNumberish, + v: BigNumberish, + r: BytesLike, + s: BytesLike + ], [ + void + ], "nonpayable">; + getEvent(key: "Approval"): TypedContractEvent; + getEvent(key: "Transfer"): TypedContractEvent; + filters: { + "Approval(address,address,uint256)": TypedContractEvent; + Approval: TypedContractEvent; + "Transfer(address,address,uint256)": TypedContractEvent; + Transfer: TypedContractEvent; + }; +} diff --git a/dist/typechain/GasPriceOracle.d.ts b/dist/typechain/GasPriceOracle.d.ts new file mode 100644 index 0000000..0ff65c8 --- /dev/null +++ b/dist/typechain/GasPriceOracle.d.ts @@ -0,0 +1,101 @@ +import type { BaseContract, BigNumberish, BytesLike, FunctionFragment, Result, Interface, AddressLike, ContractRunner, ContractMethod, Listener } from "ethers"; +import type { TypedContractEvent, TypedDeferredTopicFilter, TypedEventLog, TypedListener, TypedContractMethod } from "./common"; +export interface GasPriceOracleInterface extends Interface { + getFunction(nameOrSignature: "GAS_UNIT" | "changeDerivationThresold" | "changeGasUnit" | "changeHeartbeat" | "changeOwnership" | "derivationThresold" | "gasPrice" | "heartbeat" | "maxFeePerGas" | "maxPriorityFeePerGas" | "owner" | "pastGasPrice" | "setGasPrice" | "timestamp"): FunctionFragment; + encodeFunctionData(functionFragment: "GAS_UNIT", values?: undefined): string; + encodeFunctionData(functionFragment: "changeDerivationThresold", values: [BigNumberish]): string; + encodeFunctionData(functionFragment: "changeGasUnit", values: [BigNumberish]): string; + encodeFunctionData(functionFragment: "changeHeartbeat", values: [BigNumberish]): string; + encodeFunctionData(functionFragment: "changeOwnership", values: [AddressLike]): string; + encodeFunctionData(functionFragment: "derivationThresold", values?: undefined): string; + encodeFunctionData(functionFragment: "gasPrice", values?: undefined): string; + encodeFunctionData(functionFragment: "heartbeat", values?: undefined): string; + encodeFunctionData(functionFragment: "maxFeePerGas", values?: undefined): string; + encodeFunctionData(functionFragment: "maxPriorityFeePerGas", values?: undefined): string; + encodeFunctionData(functionFragment: "owner", values?: undefined): string; + encodeFunctionData(functionFragment: "pastGasPrice", values?: undefined): string; + encodeFunctionData(functionFragment: "setGasPrice", values: [BigNumberish]): string; + encodeFunctionData(functionFragment: "timestamp", values?: undefined): string; + decodeFunctionResult(functionFragment: "GAS_UNIT", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "changeDerivationThresold", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "changeGasUnit", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "changeHeartbeat", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "changeOwnership", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "derivationThresold", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "gasPrice", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "heartbeat", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "maxFeePerGas", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "maxPriorityFeePerGas", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "pastGasPrice", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setGasPrice", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "timestamp", data: BytesLike): Result; +} +export interface GasPriceOracle extends BaseContract { + connect(runner?: ContractRunner | null): GasPriceOracle; + waitForDeployment(): Promise; + interface: GasPriceOracleInterface; + queryFilter(event: TCEvent, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise>>; + queryFilter(filter: TypedDeferredTopicFilter, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise>>; + on(event: TCEvent, listener: TypedListener): Promise; + on(filter: TypedDeferredTopicFilter, listener: TypedListener): Promise; + once(event: TCEvent, listener: TypedListener): Promise; + once(filter: TypedDeferredTopicFilter, listener: TypedListener): Promise; + listeners(event: TCEvent): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners(event?: TCEvent): Promise; + GAS_UNIT: TypedContractMethod<[], [bigint], "view">; + changeDerivationThresold: TypedContractMethod<[ + _derivationThresold: BigNumberish + ], [ + void + ], "nonpayable">; + changeGasUnit: TypedContractMethod<[ + _gasUnit: BigNumberish + ], [ + void + ], "nonpayable">; + changeHeartbeat: TypedContractMethod<[ + _heartbeat: BigNumberish + ], [ + void + ], "nonpayable">; + changeOwnership: TypedContractMethod<[ + _owner: AddressLike + ], [ + void + ], "nonpayable">; + derivationThresold: TypedContractMethod<[], [bigint], "view">; + gasPrice: TypedContractMethod<[], [bigint], "view">; + heartbeat: TypedContractMethod<[], [bigint], "view">; + maxFeePerGas: TypedContractMethod<[], [bigint], "view">; + maxPriorityFeePerGas: TypedContractMethod<[], [bigint], "view">; + owner: TypedContractMethod<[], [string], "view">; + pastGasPrice: TypedContractMethod<[], [bigint], "view">; + setGasPrice: TypedContractMethod<[ + _gasPrice: BigNumberish + ], [ + void + ], "nonpayable">; + timestamp: TypedContractMethod<[], [bigint], "view">; + getFunction(key: string | FunctionFragment): T; + getFunction(nameOrSignature: "GAS_UNIT"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "changeDerivationThresold"): TypedContractMethod<[ + _derivationThresold: BigNumberish + ], [ + void + ], "nonpayable">; + getFunction(nameOrSignature: "changeGasUnit"): TypedContractMethod<[_gasUnit: BigNumberish], [void], "nonpayable">; + getFunction(nameOrSignature: "changeHeartbeat"): TypedContractMethod<[_heartbeat: BigNumberish], [void], "nonpayable">; + getFunction(nameOrSignature: "changeOwnership"): TypedContractMethod<[_owner: AddressLike], [void], "nonpayable">; + getFunction(nameOrSignature: "derivationThresold"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "gasPrice"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "heartbeat"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "maxFeePerGas"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "maxPriorityFeePerGas"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "owner"): TypedContractMethod<[], [string], "view">; + getFunction(nameOrSignature: "pastGasPrice"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "setGasPrice"): TypedContractMethod<[_gasPrice: BigNumberish], [void], "nonpayable">; + getFunction(nameOrSignature: "timestamp"): TypedContractMethod<[], [bigint], "view">; + filters: {}; +} diff --git a/dist/typechain/Multicall.d.ts b/dist/typechain/Multicall.d.ts new file mode 100644 index 0000000..e1bfd18 --- /dev/null +++ b/dist/typechain/Multicall.d.ts @@ -0,0 +1,228 @@ +import type { BaseContract, BigNumberish, BytesLike, FunctionFragment, Result, Interface, AddressLike, ContractRunner, ContractMethod, Listener } from "ethers"; +import type { TypedContractEvent, TypedDeferredTopicFilter, TypedEventLog, TypedListener, TypedContractMethod } from "./common"; +export declare namespace Multicall3 { + type CallStruct = { + target: AddressLike; + callData: BytesLike; + }; + type CallStructOutput = [target: string, callData: string] & { + target: string; + callData: string; + }; + type Call3Struct = { + target: AddressLike; + allowFailure: boolean; + callData: BytesLike; + }; + type Call3StructOutput = [ + target: string, + allowFailure: boolean, + callData: string + ] & { + target: string; + allowFailure: boolean; + callData: string; + }; + type ResultStruct = { + success: boolean; + returnData: BytesLike; + }; + type ResultStructOutput = [success: boolean, returnData: string] & { + success: boolean; + returnData: string; + }; + type Call3ValueStruct = { + target: AddressLike; + allowFailure: boolean; + value: BigNumberish; + callData: BytesLike; + }; + type Call3ValueStructOutput = [ + target: string, + allowFailure: boolean, + value: bigint, + callData: string + ] & { + target: string; + allowFailure: boolean; + value: bigint; + callData: string; + }; +} +export interface MulticallInterface extends Interface { + getFunction(nameOrSignature: "aggregate" | "aggregate3" | "aggregate3Value" | "blockAndAggregate" | "getBasefee" | "getBlockHash" | "getBlockNumber" | "getChainId" | "getCurrentBlockCoinbase" | "getCurrentBlockDifficulty" | "getCurrentBlockGasLimit" | "getCurrentBlockTimestamp" | "getEthBalance" | "getLastBlockHash" | "tryAggregate" | "tryBlockAndAggregate"): FunctionFragment; + encodeFunctionData(functionFragment: "aggregate", values: [Multicall3.CallStruct[]]): string; + encodeFunctionData(functionFragment: "aggregate3", values: [Multicall3.Call3Struct[]]): string; + encodeFunctionData(functionFragment: "aggregate3Value", values: [Multicall3.Call3ValueStruct[]]): string; + encodeFunctionData(functionFragment: "blockAndAggregate", values: [Multicall3.CallStruct[]]): string; + encodeFunctionData(functionFragment: "getBasefee", values?: undefined): string; + encodeFunctionData(functionFragment: "getBlockHash", values: [BigNumberish]): string; + encodeFunctionData(functionFragment: "getBlockNumber", values?: undefined): string; + encodeFunctionData(functionFragment: "getChainId", values?: undefined): string; + encodeFunctionData(functionFragment: "getCurrentBlockCoinbase", values?: undefined): string; + encodeFunctionData(functionFragment: "getCurrentBlockDifficulty", values?: undefined): string; + encodeFunctionData(functionFragment: "getCurrentBlockGasLimit", values?: undefined): string; + encodeFunctionData(functionFragment: "getCurrentBlockTimestamp", values?: undefined): string; + encodeFunctionData(functionFragment: "getEthBalance", values: [AddressLike]): string; + encodeFunctionData(functionFragment: "getLastBlockHash", values?: undefined): string; + encodeFunctionData(functionFragment: "tryAggregate", values: [boolean, Multicall3.CallStruct[]]): string; + encodeFunctionData(functionFragment: "tryBlockAndAggregate", values: [boolean, Multicall3.CallStruct[]]): string; + decodeFunctionResult(functionFragment: "aggregate", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "aggregate3", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "aggregate3Value", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "blockAndAggregate", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getBasefee", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getBlockHash", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getBlockNumber", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getChainId", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getCurrentBlockCoinbase", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getCurrentBlockDifficulty", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getCurrentBlockGasLimit", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getCurrentBlockTimestamp", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getEthBalance", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getLastBlockHash", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "tryAggregate", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "tryBlockAndAggregate", data: BytesLike): Result; +} +export interface Multicall extends BaseContract { + connect(runner?: ContractRunner | null): Multicall; + waitForDeployment(): Promise; + interface: MulticallInterface; + queryFilter(event: TCEvent, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise>>; + queryFilter(filter: TypedDeferredTopicFilter, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise>>; + on(event: TCEvent, listener: TypedListener): Promise; + on(filter: TypedDeferredTopicFilter, listener: TypedListener): Promise; + once(event: TCEvent, listener: TypedListener): Promise; + once(filter: TypedDeferredTopicFilter, listener: TypedListener): Promise; + listeners(event: TCEvent): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners(event?: TCEvent): Promise; + aggregate: TypedContractMethod<[ + calls: Multicall3.CallStruct[] + ], [ + [bigint, string[]] & { + blockNumber: bigint; + returnData: string[]; + } + ], "payable">; + aggregate3: TypedContractMethod<[ + calls: Multicall3.Call3Struct[] + ], [ + Multicall3.ResultStructOutput[] + ], "payable">; + aggregate3Value: TypedContractMethod<[ + calls: Multicall3.Call3ValueStruct[] + ], [ + Multicall3.ResultStructOutput[] + ], "payable">; + blockAndAggregate: TypedContractMethod<[ + calls: Multicall3.CallStruct[] + ], [ + [ + bigint, + string, + Multicall3.ResultStructOutput[] + ] & { + blockNumber: bigint; + blockHash: string; + returnData: Multicall3.ResultStructOutput[]; + } + ], "payable">; + getBasefee: TypedContractMethod<[], [bigint], "view">; + getBlockHash: TypedContractMethod<[ + blockNumber: BigNumberish + ], [ + string + ], "view">; + getBlockNumber: TypedContractMethod<[], [bigint], "view">; + getChainId: TypedContractMethod<[], [bigint], "view">; + getCurrentBlockCoinbase: TypedContractMethod<[], [string], "view">; + getCurrentBlockDifficulty: TypedContractMethod<[], [bigint], "view">; + getCurrentBlockGasLimit: TypedContractMethod<[], [bigint], "view">; + getCurrentBlockTimestamp: TypedContractMethod<[], [bigint], "view">; + getEthBalance: TypedContractMethod<[addr: AddressLike], [bigint], "view">; + getLastBlockHash: TypedContractMethod<[], [string], "view">; + tryAggregate: TypedContractMethod<[ + requireSuccess: boolean, + calls: Multicall3.CallStruct[] + ], [ + Multicall3.ResultStructOutput[] + ], "payable">; + tryBlockAndAggregate: TypedContractMethod<[ + requireSuccess: boolean, + calls: Multicall3.CallStruct[] + ], [ + [ + bigint, + string, + Multicall3.ResultStructOutput[] + ] & { + blockNumber: bigint; + blockHash: string; + returnData: Multicall3.ResultStructOutput[]; + } + ], "payable">; + getFunction(key: string | FunctionFragment): T; + getFunction(nameOrSignature: "aggregate"): TypedContractMethod<[ + calls: Multicall3.CallStruct[] + ], [ + [bigint, string[]] & { + blockNumber: bigint; + returnData: string[]; + } + ], "payable">; + getFunction(nameOrSignature: "aggregate3"): TypedContractMethod<[ + calls: Multicall3.Call3Struct[] + ], [ + Multicall3.ResultStructOutput[] + ], "payable">; + getFunction(nameOrSignature: "aggregate3Value"): TypedContractMethod<[ + calls: Multicall3.Call3ValueStruct[] + ], [ + Multicall3.ResultStructOutput[] + ], "payable">; + getFunction(nameOrSignature: "blockAndAggregate"): TypedContractMethod<[ + calls: Multicall3.CallStruct[] + ], [ + [ + bigint, + string, + Multicall3.ResultStructOutput[] + ] & { + blockNumber: bigint; + blockHash: string; + returnData: Multicall3.ResultStructOutput[]; + } + ], "payable">; + getFunction(nameOrSignature: "getBasefee"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "getBlockHash"): TypedContractMethod<[blockNumber: BigNumberish], [string], "view">; + getFunction(nameOrSignature: "getBlockNumber"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "getChainId"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "getCurrentBlockCoinbase"): TypedContractMethod<[], [string], "view">; + getFunction(nameOrSignature: "getCurrentBlockDifficulty"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "getCurrentBlockGasLimit"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "getCurrentBlockTimestamp"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "getEthBalance"): TypedContractMethod<[addr: AddressLike], [bigint], "view">; + getFunction(nameOrSignature: "getLastBlockHash"): TypedContractMethod<[], [string], "view">; + getFunction(nameOrSignature: "tryAggregate"): TypedContractMethod<[ + requireSuccess: boolean, + calls: Multicall3.CallStruct[] + ], [ + Multicall3.ResultStructOutput[] + ], "payable">; + getFunction(nameOrSignature: "tryBlockAndAggregate"): TypedContractMethod<[ + requireSuccess: boolean, + calls: Multicall3.CallStruct[] + ], [ + [ + bigint, + string, + Multicall3.ResultStructOutput[] + ] & { + blockNumber: bigint; + blockHash: string; + returnData: Multicall3.ResultStructOutput[]; + } + ], "payable">; + filters: {}; +} diff --git a/dist/typechain/OffchainOracle.d.ts b/dist/typechain/OffchainOracle.d.ts new file mode 100644 index 0000000..853f317 --- /dev/null +++ b/dist/typechain/OffchainOracle.d.ts @@ -0,0 +1,304 @@ +import type { BaseContract, BigNumberish, BytesLike, FunctionFragment, Result, Interface, EventFragment, AddressLike, ContractRunner, ContractMethod, Listener } from "ethers"; +import type { TypedContractEvent, TypedDeferredTopicFilter, TypedEventLog, TypedLogDescription, TypedListener, TypedContractMethod } from "./common"; +export interface OffchainOracleInterface extends Interface { + getFunction(nameOrSignature: "addConnector" | "addOracle" | "connectors" | "getRate" | "getRateToEth" | "getRateToEthWithCustomConnectors" | "getRateToEthWithThreshold" | "getRateWithCustomConnectors" | "getRateWithThreshold" | "multiWrapper" | "oracles" | "owner" | "removeConnector" | "removeOracle" | "renounceOwnership" | "setMultiWrapper" | "transferOwnership"): FunctionFragment; + getEvent(nameOrSignatureOrTopic: "ConnectorAdded" | "ConnectorRemoved" | "MultiWrapperUpdated" | "OracleAdded" | "OracleRemoved" | "OwnershipTransferred"): EventFragment; + encodeFunctionData(functionFragment: "addConnector", values: [AddressLike]): string; + encodeFunctionData(functionFragment: "addOracle", values: [AddressLike, BigNumberish]): string; + encodeFunctionData(functionFragment: "connectors", values?: undefined): string; + encodeFunctionData(functionFragment: "getRate", values: [AddressLike, AddressLike, boolean]): string; + encodeFunctionData(functionFragment: "getRateToEth", values: [AddressLike, boolean]): string; + encodeFunctionData(functionFragment: "getRateToEthWithCustomConnectors", values: [AddressLike, boolean, AddressLike[], BigNumberish]): string; + encodeFunctionData(functionFragment: "getRateToEthWithThreshold", values: [AddressLike, boolean, BigNumberish]): string; + encodeFunctionData(functionFragment: "getRateWithCustomConnectors", values: [AddressLike, AddressLike, boolean, AddressLike[], BigNumberish]): string; + encodeFunctionData(functionFragment: "getRateWithThreshold", values: [AddressLike, AddressLike, boolean, BigNumberish]): string; + encodeFunctionData(functionFragment: "multiWrapper", values?: undefined): string; + encodeFunctionData(functionFragment: "oracles", values?: undefined): string; + encodeFunctionData(functionFragment: "owner", values?: undefined): string; + encodeFunctionData(functionFragment: "removeConnector", values: [AddressLike]): string; + encodeFunctionData(functionFragment: "removeOracle", values: [AddressLike, BigNumberish]): string; + encodeFunctionData(functionFragment: "renounceOwnership", values?: undefined): string; + encodeFunctionData(functionFragment: "setMultiWrapper", values: [AddressLike]): string; + encodeFunctionData(functionFragment: "transferOwnership", values: [AddressLike]): string; + decodeFunctionResult(functionFragment: "addConnector", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "addOracle", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "connectors", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getRate", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getRateToEth", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getRateToEthWithCustomConnectors", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getRateToEthWithThreshold", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getRateWithCustomConnectors", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getRateWithThreshold", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "multiWrapper", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "oracles", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "removeConnector", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "removeOracle", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "renounceOwnership", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setMultiWrapper", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "transferOwnership", data: BytesLike): Result; +} +export declare namespace ConnectorAddedEvent { + type InputTuple = [connector: AddressLike]; + type OutputTuple = [connector: string]; + interface OutputObject { + connector: string; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace ConnectorRemovedEvent { + type InputTuple = [connector: AddressLike]; + type OutputTuple = [connector: string]; + interface OutputObject { + connector: string; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace MultiWrapperUpdatedEvent { + type InputTuple = [multiWrapper: AddressLike]; + type OutputTuple = [multiWrapper: string]; + interface OutputObject { + multiWrapper: string; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace OracleAddedEvent { + type InputTuple = [oracle: AddressLike, oracleType: BigNumberish]; + type OutputTuple = [oracle: string, oracleType: bigint]; + interface OutputObject { + oracle: string; + oracleType: bigint; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace OracleRemovedEvent { + type InputTuple = [oracle: AddressLike, oracleType: BigNumberish]; + type OutputTuple = [oracle: string, oracleType: bigint]; + interface OutputObject { + oracle: string; + oracleType: bigint; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace OwnershipTransferredEvent { + type InputTuple = [previousOwner: AddressLike, newOwner: AddressLike]; + type OutputTuple = [previousOwner: string, newOwner: string]; + interface OutputObject { + previousOwner: string; + newOwner: string; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export interface OffchainOracle extends BaseContract { + connect(runner?: ContractRunner | null): OffchainOracle; + waitForDeployment(): Promise; + interface: OffchainOracleInterface; + queryFilter(event: TCEvent, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise>>; + queryFilter(filter: TypedDeferredTopicFilter, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise>>; + on(event: TCEvent, listener: TypedListener): Promise; + on(filter: TypedDeferredTopicFilter, listener: TypedListener): Promise; + once(event: TCEvent, listener: TypedListener): Promise; + once(filter: TypedDeferredTopicFilter, listener: TypedListener): Promise; + listeners(event: TCEvent): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners(event?: TCEvent): Promise; + addConnector: TypedContractMethod<[ + connector: AddressLike + ], [ + void + ], "nonpayable">; + addOracle: TypedContractMethod<[ + oracle: AddressLike, + oracleKind: BigNumberish + ], [ + void + ], "nonpayable">; + connectors: TypedContractMethod<[], [string[]], "view">; + getRate: TypedContractMethod<[ + srcToken: AddressLike, + dstToken: AddressLike, + useWrappers: boolean + ], [ + bigint + ], "view">; + getRateToEth: TypedContractMethod<[ + srcToken: AddressLike, + useSrcWrappers: boolean + ], [ + bigint + ], "view">; + getRateToEthWithCustomConnectors: TypedContractMethod<[ + srcToken: AddressLike, + useSrcWrappers: boolean, + customConnectors: AddressLike[], + thresholdFilter: BigNumberish + ], [ + bigint + ], "view">; + getRateToEthWithThreshold: TypedContractMethod<[ + srcToken: AddressLike, + useSrcWrappers: boolean, + thresholdFilter: BigNumberish + ], [ + bigint + ], "view">; + getRateWithCustomConnectors: TypedContractMethod<[ + srcToken: AddressLike, + dstToken: AddressLike, + useWrappers: boolean, + customConnectors: AddressLike[], + thresholdFilter: BigNumberish + ], [ + bigint + ], "view">; + getRateWithThreshold: TypedContractMethod<[ + srcToken: AddressLike, + dstToken: AddressLike, + useWrappers: boolean, + thresholdFilter: BigNumberish + ], [ + bigint + ], "view">; + multiWrapper: TypedContractMethod<[], [string], "view">; + oracles: TypedContractMethod<[ + ], [ + [string[], bigint[]] & { + allOracles: string[]; + oracleTypes: bigint[]; + } + ], "view">; + owner: TypedContractMethod<[], [string], "view">; + removeConnector: TypedContractMethod<[ + connector: AddressLike + ], [ + void + ], "nonpayable">; + removeOracle: TypedContractMethod<[ + oracle: AddressLike, + oracleKind: BigNumberish + ], [ + void + ], "nonpayable">; + renounceOwnership: TypedContractMethod<[], [void], "nonpayable">; + setMultiWrapper: TypedContractMethod<[ + _multiWrapper: AddressLike + ], [ + void + ], "nonpayable">; + transferOwnership: TypedContractMethod<[ + newOwner: AddressLike + ], [ + void + ], "nonpayable">; + getFunction(key: string | FunctionFragment): T; + getFunction(nameOrSignature: "addConnector"): TypedContractMethod<[connector: AddressLike], [void], "nonpayable">; + getFunction(nameOrSignature: "addOracle"): TypedContractMethod<[ + oracle: AddressLike, + oracleKind: BigNumberish + ], [ + void + ], "nonpayable">; + getFunction(nameOrSignature: "connectors"): TypedContractMethod<[], [string[]], "view">; + getFunction(nameOrSignature: "getRate"): TypedContractMethod<[ + srcToken: AddressLike, + dstToken: AddressLike, + useWrappers: boolean + ], [ + bigint + ], "view">; + getFunction(nameOrSignature: "getRateToEth"): TypedContractMethod<[ + srcToken: AddressLike, + useSrcWrappers: boolean + ], [ + bigint + ], "view">; + getFunction(nameOrSignature: "getRateToEthWithCustomConnectors"): TypedContractMethod<[ + srcToken: AddressLike, + useSrcWrappers: boolean, + customConnectors: AddressLike[], + thresholdFilter: BigNumberish + ], [ + bigint + ], "view">; + getFunction(nameOrSignature: "getRateToEthWithThreshold"): TypedContractMethod<[ + srcToken: AddressLike, + useSrcWrappers: boolean, + thresholdFilter: BigNumberish + ], [ + bigint + ], "view">; + getFunction(nameOrSignature: "getRateWithCustomConnectors"): TypedContractMethod<[ + srcToken: AddressLike, + dstToken: AddressLike, + useWrappers: boolean, + customConnectors: AddressLike[], + thresholdFilter: BigNumberish + ], [ + bigint + ], "view">; + getFunction(nameOrSignature: "getRateWithThreshold"): TypedContractMethod<[ + srcToken: AddressLike, + dstToken: AddressLike, + useWrappers: boolean, + thresholdFilter: BigNumberish + ], [ + bigint + ], "view">; + getFunction(nameOrSignature: "multiWrapper"): TypedContractMethod<[], [string], "view">; + getFunction(nameOrSignature: "oracles"): TypedContractMethod<[ + ], [ + [string[], bigint[]] & { + allOracles: string[]; + oracleTypes: bigint[]; + } + ], "view">; + getFunction(nameOrSignature: "owner"): TypedContractMethod<[], [string], "view">; + getFunction(nameOrSignature: "removeConnector"): TypedContractMethod<[connector: AddressLike], [void], "nonpayable">; + getFunction(nameOrSignature: "removeOracle"): TypedContractMethod<[ + oracle: AddressLike, + oracleKind: BigNumberish + ], [ + void + ], "nonpayable">; + getFunction(nameOrSignature: "renounceOwnership"): TypedContractMethod<[], [void], "nonpayable">; + getFunction(nameOrSignature: "setMultiWrapper"): TypedContractMethod<[_multiWrapper: AddressLike], [void], "nonpayable">; + getFunction(nameOrSignature: "transferOwnership"): TypedContractMethod<[newOwner: AddressLike], [void], "nonpayable">; + getEvent(key: "ConnectorAdded"): TypedContractEvent; + getEvent(key: "ConnectorRemoved"): TypedContractEvent; + getEvent(key: "MultiWrapperUpdated"): TypedContractEvent; + getEvent(key: "OracleAdded"): TypedContractEvent; + getEvent(key: "OracleRemoved"): TypedContractEvent; + getEvent(key: "OwnershipTransferred"): TypedContractEvent; + filters: { + "ConnectorAdded(address)": TypedContractEvent; + ConnectorAdded: TypedContractEvent; + "ConnectorRemoved(address)": TypedContractEvent; + ConnectorRemoved: TypedContractEvent; + "MultiWrapperUpdated(address)": TypedContractEvent; + MultiWrapperUpdated: TypedContractEvent; + "OracleAdded(address,uint8)": TypedContractEvent; + OracleAdded: TypedContractEvent; + "OracleRemoved(address,uint8)": TypedContractEvent; + OracleRemoved: TypedContractEvent; + "OwnershipTransferred(address,address)": TypedContractEvent; + OwnershipTransferred: TypedContractEvent; + }; +} diff --git a/dist/typechain/OvmGasPriceOracle.d.ts b/dist/typechain/OvmGasPriceOracle.d.ts new file mode 100644 index 0000000..b67f111 --- /dev/null +++ b/dist/typechain/OvmGasPriceOracle.d.ts @@ -0,0 +1,188 @@ +import type { BaseContract, BigNumberish, BytesLike, FunctionFragment, Result, Interface, EventFragment, AddressLike, ContractRunner, ContractMethod, Listener } from "ethers"; +import type { TypedContractEvent, TypedDeferredTopicFilter, TypedEventLog, TypedLogDescription, TypedListener, TypedContractMethod } from "./common"; +export interface OvmGasPriceOracleInterface extends Interface { + getFunction(nameOrSignature: "decimals" | "gasPrice" | "getL1Fee" | "getL1GasUsed" | "l1BaseFee" | "overhead" | "owner" | "renounceOwnership" | "scalar" | "setDecimals" | "setGasPrice" | "setL1BaseFee" | "setOverhead" | "setScalar" | "transferOwnership"): FunctionFragment; + getEvent(nameOrSignatureOrTopic: "DecimalsUpdated" | "GasPriceUpdated" | "L1BaseFeeUpdated" | "OverheadUpdated" | "OwnershipTransferred" | "ScalarUpdated"): EventFragment; + encodeFunctionData(functionFragment: "decimals", values?: undefined): string; + encodeFunctionData(functionFragment: "gasPrice", values?: undefined): string; + encodeFunctionData(functionFragment: "getL1Fee", values: [BytesLike]): string; + encodeFunctionData(functionFragment: "getL1GasUsed", values: [BytesLike]): string; + encodeFunctionData(functionFragment: "l1BaseFee", values?: undefined): string; + encodeFunctionData(functionFragment: "overhead", values?: undefined): string; + encodeFunctionData(functionFragment: "owner", values?: undefined): string; + encodeFunctionData(functionFragment: "renounceOwnership", values?: undefined): string; + encodeFunctionData(functionFragment: "scalar", values?: undefined): string; + encodeFunctionData(functionFragment: "setDecimals", values: [BigNumberish]): string; + encodeFunctionData(functionFragment: "setGasPrice", values: [BigNumberish]): string; + encodeFunctionData(functionFragment: "setL1BaseFee", values: [BigNumberish]): string; + encodeFunctionData(functionFragment: "setOverhead", values: [BigNumberish]): string; + encodeFunctionData(functionFragment: "setScalar", values: [BigNumberish]): string; + encodeFunctionData(functionFragment: "transferOwnership", values: [AddressLike]): string; + decodeFunctionResult(functionFragment: "decimals", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "gasPrice", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getL1Fee", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "getL1GasUsed", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "l1BaseFee", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "overhead", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "renounceOwnership", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "scalar", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setDecimals", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setGasPrice", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setL1BaseFee", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setOverhead", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "setScalar", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "transferOwnership", data: BytesLike): Result; +} +export declare namespace DecimalsUpdatedEvent { + type InputTuple = [arg0: BigNumberish]; + type OutputTuple = [arg0: bigint]; + interface OutputObject { + arg0: bigint; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace GasPriceUpdatedEvent { + type InputTuple = [arg0: BigNumberish]; + type OutputTuple = [arg0: bigint]; + interface OutputObject { + arg0: bigint; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace L1BaseFeeUpdatedEvent { + type InputTuple = [arg0: BigNumberish]; + type OutputTuple = [arg0: bigint]; + interface OutputObject { + arg0: bigint; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace OverheadUpdatedEvent { + type InputTuple = [arg0: BigNumberish]; + type OutputTuple = [arg0: bigint]; + interface OutputObject { + arg0: bigint; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace OwnershipTransferredEvent { + type InputTuple = [previousOwner: AddressLike, newOwner: AddressLike]; + type OutputTuple = [previousOwner: string, newOwner: string]; + interface OutputObject { + previousOwner: string; + newOwner: string; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export declare namespace ScalarUpdatedEvent { + type InputTuple = [arg0: BigNumberish]; + type OutputTuple = [arg0: bigint]; + interface OutputObject { + arg0: bigint; + } + type Event = TypedContractEvent; + type Filter = TypedDeferredTopicFilter; + type Log = TypedEventLog; + type LogDescription = TypedLogDescription; +} +export interface OvmGasPriceOracle extends BaseContract { + connect(runner?: ContractRunner | null): OvmGasPriceOracle; + waitForDeployment(): Promise; + interface: OvmGasPriceOracleInterface; + queryFilter(event: TCEvent, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise>>; + queryFilter(filter: TypedDeferredTopicFilter, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise>>; + on(event: TCEvent, listener: TypedListener): Promise; + on(filter: TypedDeferredTopicFilter, listener: TypedListener): Promise; + once(event: TCEvent, listener: TypedListener): Promise; + once(filter: TypedDeferredTopicFilter, listener: TypedListener): Promise; + listeners(event: TCEvent): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners(event?: TCEvent): Promise; + decimals: TypedContractMethod<[], [bigint], "view">; + gasPrice: TypedContractMethod<[], [bigint], "view">; + getL1Fee: TypedContractMethod<[_data: BytesLike], [bigint], "view">; + getL1GasUsed: TypedContractMethod<[_data: BytesLike], [bigint], "view">; + l1BaseFee: TypedContractMethod<[], [bigint], "view">; + overhead: TypedContractMethod<[], [bigint], "view">; + owner: TypedContractMethod<[], [string], "view">; + renounceOwnership: TypedContractMethod<[], [void], "nonpayable">; + scalar: TypedContractMethod<[], [bigint], "view">; + setDecimals: TypedContractMethod<[ + _decimals: BigNumberish + ], [ + void + ], "nonpayable">; + setGasPrice: TypedContractMethod<[ + _gasPrice: BigNumberish + ], [ + void + ], "nonpayable">; + setL1BaseFee: TypedContractMethod<[ + _baseFee: BigNumberish + ], [ + void + ], "nonpayable">; + setOverhead: TypedContractMethod<[ + _overhead: BigNumberish + ], [ + void + ], "nonpayable">; + setScalar: TypedContractMethod<[_scalar: BigNumberish], [void], "nonpayable">; + transferOwnership: TypedContractMethod<[ + newOwner: AddressLike + ], [ + void + ], "nonpayable">; + getFunction(key: string | FunctionFragment): T; + getFunction(nameOrSignature: "decimals"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "gasPrice"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "getL1Fee"): TypedContractMethod<[_data: BytesLike], [bigint], "view">; + getFunction(nameOrSignature: "getL1GasUsed"): TypedContractMethod<[_data: BytesLike], [bigint], "view">; + getFunction(nameOrSignature: "l1BaseFee"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "overhead"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "owner"): TypedContractMethod<[], [string], "view">; + getFunction(nameOrSignature: "renounceOwnership"): TypedContractMethod<[], [void], "nonpayable">; + getFunction(nameOrSignature: "scalar"): TypedContractMethod<[], [bigint], "view">; + getFunction(nameOrSignature: "setDecimals"): TypedContractMethod<[_decimals: BigNumberish], [void], "nonpayable">; + getFunction(nameOrSignature: "setGasPrice"): TypedContractMethod<[_gasPrice: BigNumberish], [void], "nonpayable">; + getFunction(nameOrSignature: "setL1BaseFee"): TypedContractMethod<[_baseFee: BigNumberish], [void], "nonpayable">; + getFunction(nameOrSignature: "setOverhead"): TypedContractMethod<[_overhead: BigNumberish], [void], "nonpayable">; + getFunction(nameOrSignature: "setScalar"): TypedContractMethod<[_scalar: BigNumberish], [void], "nonpayable">; + getFunction(nameOrSignature: "transferOwnership"): TypedContractMethod<[newOwner: AddressLike], [void], "nonpayable">; + getEvent(key: "DecimalsUpdated"): TypedContractEvent; + getEvent(key: "GasPriceUpdated"): TypedContractEvent; + getEvent(key: "L1BaseFeeUpdated"): TypedContractEvent; + getEvent(key: "OverheadUpdated"): TypedContractEvent; + getEvent(key: "OwnershipTransferred"): TypedContractEvent; + getEvent(key: "ScalarUpdated"): TypedContractEvent; + filters: { + "DecimalsUpdated(uint256)": TypedContractEvent; + DecimalsUpdated: TypedContractEvent; + "GasPriceUpdated(uint256)": TypedContractEvent; + GasPriceUpdated: TypedContractEvent; + "L1BaseFeeUpdated(uint256)": TypedContractEvent; + L1BaseFeeUpdated: TypedContractEvent; + "OverheadUpdated(uint256)": TypedContractEvent; + OverheadUpdated: TypedContractEvent; + "OwnershipTransferred(address,address)": TypedContractEvent; + OwnershipTransferred: TypedContractEvent; + "ScalarUpdated(uint256)": TypedContractEvent; + ScalarUpdated: TypedContractEvent; + }; +} diff --git a/dist/typechain/ReverseRecords.d.ts b/dist/typechain/ReverseRecords.d.ts new file mode 100644 index 0000000..b26cfb5 --- /dev/null +++ b/dist/typechain/ReverseRecords.d.ts @@ -0,0 +1,25 @@ +import type { BaseContract, BytesLike, FunctionFragment, Result, Interface, AddressLike, ContractRunner, ContractMethod, Listener } from "ethers"; +import type { TypedContractEvent, TypedDeferredTopicFilter, TypedEventLog, TypedListener, TypedContractMethod } from "./common"; +export interface ReverseRecordsInterface extends Interface { + getFunction(nameOrSignature: "getNames"): FunctionFragment; + encodeFunctionData(functionFragment: "getNames", values: [AddressLike[]]): string; + decodeFunctionResult(functionFragment: "getNames", data: BytesLike): Result; +} +export interface ReverseRecords extends BaseContract { + connect(runner?: ContractRunner | null): ReverseRecords; + waitForDeployment(): Promise; + interface: ReverseRecordsInterface; + queryFilter(event: TCEvent, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise>>; + queryFilter(filter: TypedDeferredTopicFilter, fromBlockOrBlockhash?: string | number | undefined, toBlock?: string | number | undefined): Promise>>; + on(event: TCEvent, listener: TypedListener): Promise; + on(filter: TypedDeferredTopicFilter, listener: TypedListener): Promise; + once(event: TCEvent, listener: TypedListener): Promise; + once(filter: TypedDeferredTopicFilter, listener: TypedListener): Promise; + listeners(event: TCEvent): Promise>>; + listeners(eventName?: string): Promise>; + removeAllListeners(event?: TCEvent): Promise; + getNames: TypedContractMethod<[addresses: AddressLike[]], [string[]], "view">; + getFunction(key: string | FunctionFragment): T; + getFunction(nameOrSignature: "getNames"): TypedContractMethod<[addresses: AddressLike[]], [string[]], "view">; + filters: {}; +} diff --git a/dist/typechain/common.d.ts b/dist/typechain/common.d.ts new file mode 100644 index 0000000..d6c302a --- /dev/null +++ b/dist/typechain/common.d.ts @@ -0,0 +1,50 @@ +import type { FunctionFragment, Typed, EventFragment, ContractTransaction, ContractTransactionResponse, DeferredTopicFilter, EventLog, TransactionRequest, LogDescription } from "ethers"; +export interface TypedDeferredTopicFilter<_TCEvent extends TypedContractEvent> extends DeferredTopicFilter { +} +export interface TypedContractEvent = any, OutputTuple extends Array = any, OutputObject = any> { + (...args: Partial): TypedDeferredTopicFilter>; + name: string; + fragment: EventFragment; + getFragment(...args: Partial): EventFragment; +} +type __TypechainAOutputTuple = T extends TypedContractEvent ? W : never; +type __TypechainOutputObject = T extends TypedContractEvent ? V : never; +export interface TypedEventLog extends Omit { + args: __TypechainAOutputTuple & __TypechainOutputObject; +} +export interface TypedLogDescription extends Omit { + args: __TypechainAOutputTuple & __TypechainOutputObject; +} +export type TypedListener = (...listenerArg: [ + ...__TypechainAOutputTuple, + TypedEventLog, + ...undefined[] +]) => void; +export type MinEthersFactory = { + deploy(...a: ARGS[]): Promise; +}; +export type GetContractTypeFromFactory = F extends MinEthersFactory ? C : never; +export type GetARGsTypeFromFactory = F extends MinEthersFactory ? Parameters : never; +export type StateMutability = "nonpayable" | "payable" | "view"; +export type BaseOverrides = Omit; +export type NonPayableOverrides = Omit; +export type PayableOverrides = Omit; +export type ViewOverrides = Omit; +export type Overrides = S extends "nonpayable" ? NonPayableOverrides : S extends "payable" ? PayableOverrides : ViewOverrides; +export type PostfixOverrides, S extends StateMutability> = A | [...A, Overrides]; +export type ContractMethodArgs, S extends StateMutability> = PostfixOverrides<{ + [I in keyof A]-?: A[I] | Typed; +}, S>; +export type DefaultReturnType = R extends Array ? R[0] : R; +export interface TypedContractMethod = Array, R = any, S extends StateMutability = "payable"> { + (...args: ContractMethodArgs): S extends "view" ? Promise> : Promise; + name: string; + fragment: FunctionFragment; + getFragment(...args: ContractMethodArgs): FunctionFragment; + populateTransaction(...args: ContractMethodArgs): Promise; + staticCall(...args: ContractMethodArgs): Promise>; + send(...args: ContractMethodArgs): Promise; + estimateGas(...args: ContractMethodArgs): Promise; + staticCallResult(...args: ContractMethodArgs): Promise; +} +export {}; diff --git a/dist/typechain/factories/ENS__factory.d.ts b/dist/typechain/factories/ENS__factory.d.ts new file mode 100644 index 0000000..7a6db54 --- /dev/null +++ b/dist/typechain/factories/ENS__factory.d.ts @@ -0,0 +1,541 @@ +import { type ContractRunner } from "ethers"; +import type { ENS, ENSInterface } from "../ENS"; +export declare class ENS__factory { + static readonly abi: readonly [{ + readonly constant: true; + readonly inputs: readonly [{ + readonly internalType: "bytes4"; + readonly name: "interfaceID"; + readonly type: "bytes4"; + }]; + readonly name: "supportsInterface"; + readonly outputs: readonly [{ + readonly internalType: "bool"; + readonly name: ""; + readonly type: "bool"; + }]; + readonly payable: false; + readonly stateMutability: "pure"; + readonly type: "function"; + }, { + readonly constant: false; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly internalType: "string"; + readonly name: "key"; + readonly type: "string"; + }, { + readonly internalType: "string"; + readonly name: "value"; + readonly type: "string"; + }]; + readonly name: "setText"; + readonly outputs: readonly []; + readonly payable: false; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly constant: true; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly internalType: "bytes4"; + readonly name: "interfaceID"; + readonly type: "bytes4"; + }]; + readonly name: "interfaceImplementer"; + readonly outputs: readonly [{ + readonly internalType: "address"; + readonly name: ""; + readonly type: "address"; + }]; + readonly payable: false; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly constant: true; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly internalType: "uint256"; + readonly name: "contentTypes"; + readonly type: "uint256"; + }]; + readonly name: "ABI"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }, { + readonly internalType: "bytes"; + readonly name: ""; + readonly type: "bytes"; + }]; + readonly payable: false; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly constant: false; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly internalType: "bytes32"; + readonly name: "x"; + readonly type: "bytes32"; + }, { + readonly internalType: "bytes32"; + readonly name: "y"; + readonly type: "bytes32"; + }]; + readonly name: "setPubkey"; + readonly outputs: readonly []; + readonly payable: false; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly constant: false; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly internalType: "bytes"; + readonly name: "hash"; + readonly type: "bytes"; + }]; + readonly name: "setContenthash"; + readonly outputs: readonly []; + readonly payable: false; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly constant: true; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }]; + readonly name: "addr"; + readonly outputs: readonly [{ + readonly internalType: "address"; + readonly name: ""; + readonly type: "address"; + }]; + readonly payable: false; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly constant: false; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly internalType: "address"; + readonly name: "target"; + readonly type: "address"; + }, { + readonly internalType: "bool"; + readonly name: "isAuthorised"; + readonly type: "bool"; + }]; + readonly name: "setAuthorisation"; + readonly outputs: readonly []; + readonly payable: false; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly constant: true; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly internalType: "string"; + readonly name: "key"; + readonly type: "string"; + }]; + readonly name: "text"; + readonly outputs: readonly [{ + readonly internalType: "string"; + readonly name: ""; + readonly type: "string"; + }]; + readonly payable: false; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly constant: false; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly internalType: "uint256"; + readonly name: "contentType"; + readonly type: "uint256"; + }, { + readonly internalType: "bytes"; + readonly name: "data"; + readonly type: "bytes"; + }]; + readonly name: "setABI"; + readonly outputs: readonly []; + readonly payable: false; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly constant: true; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }]; + readonly name: "name"; + readonly outputs: readonly [{ + readonly internalType: "string"; + readonly name: ""; + readonly type: "string"; + }]; + readonly payable: false; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly constant: false; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly internalType: "string"; + readonly name: "name"; + readonly type: "string"; + }]; + readonly name: "setName"; + readonly outputs: readonly []; + readonly payable: false; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly constant: false; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly internalType: "uint256"; + readonly name: "coinType"; + readonly type: "uint256"; + }, { + readonly internalType: "bytes"; + readonly name: "a"; + readonly type: "bytes"; + }]; + readonly name: "setAddr"; + readonly outputs: readonly []; + readonly payable: false; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly constant: true; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }]; + readonly name: "contenthash"; + readonly outputs: readonly [{ + readonly internalType: "bytes"; + readonly name: ""; + readonly type: "bytes"; + }]; + readonly payable: false; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly constant: true; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }]; + readonly name: "pubkey"; + readonly outputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "x"; + readonly type: "bytes32"; + }, { + readonly internalType: "bytes32"; + readonly name: "y"; + readonly type: "bytes32"; + }]; + readonly payable: false; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly constant: false; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly internalType: "address"; + readonly name: "a"; + readonly type: "address"; + }]; + readonly name: "setAddr"; + readonly outputs: readonly []; + readonly payable: false; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly constant: false; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly internalType: "bytes4"; + readonly name: "interfaceID"; + readonly type: "bytes4"; + }, { + readonly internalType: "address"; + readonly name: "implementer"; + readonly type: "address"; + }]; + readonly name: "setInterface"; + readonly outputs: readonly []; + readonly payable: false; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly constant: true; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly internalType: "uint256"; + readonly name: "coinType"; + readonly type: "uint256"; + }]; + readonly name: "addr"; + readonly outputs: readonly [{ + readonly internalType: "bytes"; + readonly name: ""; + readonly type: "bytes"; + }]; + readonly payable: false; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly constant: true; + readonly inputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: ""; + readonly type: "bytes32"; + }, { + readonly internalType: "address"; + readonly name: ""; + readonly type: "address"; + }, { + readonly internalType: "address"; + readonly name: ""; + readonly type: "address"; + }]; + readonly name: "authorisations"; + readonly outputs: readonly [{ + readonly internalType: "bool"; + readonly name: ""; + readonly type: "bool"; + }]; + readonly payable: false; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "contract ENS"; + readonly name: "_ens"; + readonly type: "address"; + }]; + readonly payable: false; + readonly stateMutability: "nonpayable"; + readonly type: "constructor"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: true; + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly indexed: true; + readonly internalType: "address"; + readonly name: "owner"; + readonly type: "address"; + }, { + readonly indexed: true; + readonly internalType: "address"; + readonly name: "target"; + readonly type: "address"; + }, { + readonly indexed: false; + readonly internalType: "bool"; + readonly name: "isAuthorised"; + readonly type: "bool"; + }]; + readonly name: "AuthorisationChanged"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: true; + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly indexed: false; + readonly internalType: "string"; + readonly name: "indexedKey"; + readonly type: "string"; + }, { + readonly indexed: false; + readonly internalType: "string"; + readonly name: "key"; + readonly type: "string"; + }]; + readonly name: "TextChanged"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: true; + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly indexed: false; + readonly internalType: "bytes32"; + readonly name: "x"; + readonly type: "bytes32"; + }, { + readonly indexed: false; + readonly internalType: "bytes32"; + readonly name: "y"; + readonly type: "bytes32"; + }]; + readonly name: "PubkeyChanged"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: true; + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly indexed: false; + readonly internalType: "string"; + readonly name: "name"; + readonly type: "string"; + }]; + readonly name: "NameChanged"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: true; + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly indexed: true; + readonly internalType: "bytes4"; + readonly name: "interfaceID"; + readonly type: "bytes4"; + }, { + readonly indexed: false; + readonly internalType: "address"; + readonly name: "implementer"; + readonly type: "address"; + }]; + readonly name: "InterfaceChanged"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: true; + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly indexed: false; + readonly internalType: "bytes"; + readonly name: "hash"; + readonly type: "bytes"; + }]; + readonly name: "ContenthashChanged"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: true; + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly indexed: false; + readonly internalType: "address"; + readonly name: "a"; + readonly type: "address"; + }]; + readonly name: "AddrChanged"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: true; + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly indexed: false; + readonly internalType: "uint256"; + readonly name: "coinType"; + readonly type: "uint256"; + }, { + readonly indexed: false; + readonly internalType: "bytes"; + readonly name: "newAddress"; + readonly type: "bytes"; + }]; + readonly name: "AddressChanged"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: true; + readonly internalType: "bytes32"; + readonly name: "node"; + readonly type: "bytes32"; + }, { + readonly indexed: true; + readonly internalType: "uint256"; + readonly name: "contentType"; + readonly type: "uint256"; + }]; + readonly name: "ABIChanged"; + readonly type: "event"; + }]; + static createInterface(): ENSInterface; + static connect(address: string, runner?: ContractRunner | null): ENS; +} diff --git a/dist/typechain/factories/ERC20__factory.d.ts b/dist/typechain/factories/ERC20__factory.d.ts new file mode 100644 index 0000000..218af25 --- /dev/null +++ b/dist/typechain/factories/ERC20__factory.d.ts @@ -0,0 +1,243 @@ +import { type ContractRunner } from "ethers"; +import type { ERC20, ERC20Interface } from "../ERC20"; +export declare class ERC20__factory { + static readonly abi: readonly [{ + readonly constant: true; + readonly inputs: readonly []; + readonly name: "totalSupply"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly payable: false; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly constant: true; + readonly inputs: readonly []; + readonly name: "_totalSupply"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly payable: false; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly constant: true; + readonly inputs: readonly [{ + readonly internalType: "address"; + readonly name: "who"; + readonly type: "address"; + }]; + readonly name: "balanceOf"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly payable: false; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly constant: true; + readonly inputs: readonly []; + readonly name: "name"; + readonly outputs: readonly [{ + readonly internalType: "string"; + readonly name: ""; + readonly type: "string"; + }]; + readonly payable: false; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly constant: true; + readonly inputs: readonly []; + readonly name: "symbol"; + readonly outputs: readonly [{ + readonly internalType: "string"; + readonly name: ""; + readonly type: "string"; + }]; + readonly payable: false; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly constant: true; + readonly inputs: readonly []; + readonly name: "decimals"; + readonly outputs: readonly [{ + readonly internalType: "uint8"; + readonly name: ""; + readonly type: "uint8"; + }]; + readonly payable: false; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly constant: false; + readonly inputs: readonly [{ + readonly internalType: "address"; + readonly name: "to"; + readonly type: "address"; + }, { + readonly internalType: "uint256"; + readonly name: "value"; + readonly type: "uint256"; + }]; + readonly name: "transfer"; + readonly outputs: readonly []; + readonly payable: false; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: true; + readonly internalType: "address"; + readonly name: "owner"; + readonly type: "address"; + }, { + readonly indexed: true; + readonly internalType: "address"; + readonly name: "spender"; + readonly type: "address"; + }, { + readonly indexed: false; + readonly internalType: "uint256"; + readonly name: "value"; + readonly type: "uint256"; + }]; + readonly name: "Approval"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: true; + readonly internalType: "address"; + readonly name: "from"; + readonly type: "address"; + }, { + readonly indexed: true; + readonly internalType: "address"; + readonly name: "to"; + readonly type: "address"; + }, { + readonly indexed: false; + readonly internalType: "uint256"; + readonly name: "value"; + readonly type: "uint256"; + }]; + readonly name: "Transfer"; + readonly type: "event"; + }, { + readonly constant: true; + readonly inputs: readonly [{ + readonly internalType: "address"; + readonly name: "owner"; + readonly type: "address"; + }, { + readonly internalType: "address"; + readonly name: "spender"; + readonly type: "address"; + }]; + readonly name: "allowance"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly payable: false; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly constant: false; + readonly inputs: readonly [{ + readonly internalType: "address"; + readonly name: "from"; + readonly type: "address"; + }, { + readonly internalType: "address"; + readonly name: "to"; + readonly type: "address"; + }, { + readonly internalType: "uint256"; + readonly name: "value"; + readonly type: "uint256"; + }]; + readonly name: "transferFrom"; + readonly outputs: readonly []; + readonly payable: false; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly constant: false; + readonly inputs: readonly [{ + readonly internalType: "address"; + readonly name: "spender"; + readonly type: "address"; + }, { + readonly internalType: "uint256"; + readonly name: "value"; + readonly type: "uint256"; + }]; + readonly name: "approve"; + readonly outputs: readonly []; + readonly payable: false; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "address"; + readonly name: "owner"; + readonly type: "address"; + }]; + readonly name: "nonces"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "address"; + readonly name: "owner"; + readonly type: "address"; + }, { + readonly internalType: "address"; + readonly name: "spender"; + readonly type: "address"; + }, { + readonly internalType: "uint256"; + readonly name: "amount"; + readonly type: "uint256"; + }, { + readonly internalType: "uint256"; + readonly name: "deadline"; + readonly type: "uint256"; + }, { + readonly internalType: "uint8"; + readonly name: "v"; + readonly type: "uint8"; + }, { + readonly internalType: "bytes32"; + readonly name: "r"; + readonly type: "bytes32"; + }, { + readonly internalType: "bytes32"; + readonly name: "s"; + readonly type: "bytes32"; + }]; + readonly name: "permit"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }]; + static createInterface(): ERC20Interface; + static connect(address: string, runner?: ContractRunner | null): ERC20; +} diff --git a/dist/typechain/factories/GasPriceOracle__factory.d.ts b/dist/typechain/factories/GasPriceOracle__factory.d.ts new file mode 100644 index 0000000..8d623de --- /dev/null +++ b/dist/typechain/factories/GasPriceOracle__factory.d.ts @@ -0,0 +1,151 @@ +import { type ContractRunner } from "ethers"; +import type { GasPriceOracle, GasPriceOracleInterface } from "../GasPriceOracle"; +export declare class GasPriceOracle__factory { + static readonly abi: readonly [{ + readonly inputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "constructor"; + }, { + readonly inputs: readonly []; + readonly name: "GAS_UNIT"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "uint32"; + readonly name: "_derivationThresold"; + readonly type: "uint32"; + }]; + readonly name: "changeDerivationThresold"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "uint32"; + readonly name: "_gasUnit"; + readonly type: "uint32"; + }]; + readonly name: "changeGasUnit"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "uint32"; + readonly name: "_heartbeat"; + readonly type: "uint32"; + }]; + readonly name: "changeHeartbeat"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "address"; + readonly name: "_owner"; + readonly type: "address"; + }]; + readonly name: "changeOwnership"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "derivationThresold"; + readonly outputs: readonly [{ + readonly internalType: "uint32"; + readonly name: ""; + readonly type: "uint32"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "gasPrice"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "heartbeat"; + readonly outputs: readonly [{ + readonly internalType: "uint32"; + readonly name: ""; + readonly type: "uint32"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "maxFeePerGas"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "maxPriorityFeePerGas"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "owner"; + readonly outputs: readonly [{ + readonly internalType: "address"; + readonly name: ""; + readonly type: "address"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "pastGasPrice"; + readonly outputs: readonly [{ + readonly internalType: "uint32"; + readonly name: ""; + readonly type: "uint32"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "uint32"; + readonly name: "_gasPrice"; + readonly type: "uint32"; + }]; + readonly name: "setGasPrice"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "timestamp"; + readonly outputs: readonly [{ + readonly internalType: "uint32"; + readonly name: ""; + readonly type: "uint32"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }]; + static createInterface(): GasPriceOracleInterface; + static connect(address: string, runner?: ContractRunner | null): GasPriceOracle; +} diff --git a/dist/typechain/factories/Multicall__factory.d.ts b/dist/typechain/factories/Multicall__factory.d.ts new file mode 100644 index 0000000..2a1d4a1 --- /dev/null +++ b/dist/typechain/factories/Multicall__factory.d.ts @@ -0,0 +1,338 @@ +import { type ContractRunner } from "ethers"; +import type { Multicall, MulticallInterface } from "../Multicall"; +export declare class Multicall__factory { + static readonly abi: readonly [{ + readonly inputs: readonly [{ + readonly components: readonly [{ + readonly internalType: "address"; + readonly name: "target"; + readonly type: "address"; + }, { + readonly internalType: "bytes"; + readonly name: "callData"; + readonly type: "bytes"; + }]; + readonly internalType: "struct Multicall3.Call[]"; + readonly name: "calls"; + readonly type: "tuple[]"; + }]; + readonly name: "aggregate"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "blockNumber"; + readonly type: "uint256"; + }, { + readonly internalType: "bytes[]"; + readonly name: "returnData"; + readonly type: "bytes[]"; + }]; + readonly stateMutability: "payable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly components: readonly [{ + readonly internalType: "address"; + readonly name: "target"; + readonly type: "address"; + }, { + readonly internalType: "bool"; + readonly name: "allowFailure"; + readonly type: "bool"; + }, { + readonly internalType: "bytes"; + readonly name: "callData"; + readonly type: "bytes"; + }]; + readonly internalType: "struct Multicall3.Call3[]"; + readonly name: "calls"; + readonly type: "tuple[]"; + }]; + readonly name: "aggregate3"; + readonly outputs: readonly [{ + readonly components: readonly [{ + readonly internalType: "bool"; + readonly name: "success"; + readonly type: "bool"; + }, { + readonly internalType: "bytes"; + readonly name: "returnData"; + readonly type: "bytes"; + }]; + readonly internalType: "struct Multicall3.Result[]"; + readonly name: "returnData"; + readonly type: "tuple[]"; + }]; + readonly stateMutability: "payable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly components: readonly [{ + readonly internalType: "address"; + readonly name: "target"; + readonly type: "address"; + }, { + readonly internalType: "bool"; + readonly name: "allowFailure"; + readonly type: "bool"; + }, { + readonly internalType: "uint256"; + readonly name: "value"; + readonly type: "uint256"; + }, { + readonly internalType: "bytes"; + readonly name: "callData"; + readonly type: "bytes"; + }]; + readonly internalType: "struct Multicall3.Call3Value[]"; + readonly name: "calls"; + readonly type: "tuple[]"; + }]; + readonly name: "aggregate3Value"; + readonly outputs: readonly [{ + readonly components: readonly [{ + readonly internalType: "bool"; + readonly name: "success"; + readonly type: "bool"; + }, { + readonly internalType: "bytes"; + readonly name: "returnData"; + readonly type: "bytes"; + }]; + readonly internalType: "struct Multicall3.Result[]"; + readonly name: "returnData"; + readonly type: "tuple[]"; + }]; + readonly stateMutability: "payable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly components: readonly [{ + readonly internalType: "address"; + readonly name: "target"; + readonly type: "address"; + }, { + readonly internalType: "bytes"; + readonly name: "callData"; + readonly type: "bytes"; + }]; + readonly internalType: "struct Multicall3.Call[]"; + readonly name: "calls"; + readonly type: "tuple[]"; + }]; + readonly name: "blockAndAggregate"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "blockNumber"; + readonly type: "uint256"; + }, { + readonly internalType: "bytes32"; + readonly name: "blockHash"; + readonly type: "bytes32"; + }, { + readonly components: readonly [{ + readonly internalType: "bool"; + readonly name: "success"; + readonly type: "bool"; + }, { + readonly internalType: "bytes"; + readonly name: "returnData"; + readonly type: "bytes"; + }]; + readonly internalType: "struct Multicall3.Result[]"; + readonly name: "returnData"; + readonly type: "tuple[]"; + }]; + readonly stateMutability: "payable"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "getBasefee"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "basefee"; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "blockNumber"; + readonly type: "uint256"; + }]; + readonly name: "getBlockHash"; + readonly outputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "blockHash"; + readonly type: "bytes32"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "getBlockNumber"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "blockNumber"; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "getChainId"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "chainid"; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "getCurrentBlockCoinbase"; + readonly outputs: readonly [{ + readonly internalType: "address"; + readonly name: "coinbase"; + readonly type: "address"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "getCurrentBlockDifficulty"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "difficulty"; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "getCurrentBlockGasLimit"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "gaslimit"; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "getCurrentBlockTimestamp"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "timestamp"; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "address"; + readonly name: "addr"; + readonly type: "address"; + }]; + readonly name: "getEthBalance"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "balance"; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "getLastBlockHash"; + readonly outputs: readonly [{ + readonly internalType: "bytes32"; + readonly name: "blockHash"; + readonly type: "bytes32"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "bool"; + readonly name: "requireSuccess"; + readonly type: "bool"; + }, { + readonly components: readonly [{ + readonly internalType: "address"; + readonly name: "target"; + readonly type: "address"; + }, { + readonly internalType: "bytes"; + readonly name: "callData"; + readonly type: "bytes"; + }]; + readonly internalType: "struct Multicall3.Call[]"; + readonly name: "calls"; + readonly type: "tuple[]"; + }]; + readonly name: "tryAggregate"; + readonly outputs: readonly [{ + readonly components: readonly [{ + readonly internalType: "bool"; + readonly name: "success"; + readonly type: "bool"; + }, { + readonly internalType: "bytes"; + readonly name: "returnData"; + readonly type: "bytes"; + }]; + readonly internalType: "struct Multicall3.Result[]"; + readonly name: "returnData"; + readonly type: "tuple[]"; + }]; + readonly stateMutability: "payable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "bool"; + readonly name: "requireSuccess"; + readonly type: "bool"; + }, { + readonly components: readonly [{ + readonly internalType: "address"; + readonly name: "target"; + readonly type: "address"; + }, { + readonly internalType: "bytes"; + readonly name: "callData"; + readonly type: "bytes"; + }]; + readonly internalType: "struct Multicall3.Call[]"; + readonly name: "calls"; + readonly type: "tuple[]"; + }]; + readonly name: "tryBlockAndAggregate"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "blockNumber"; + readonly type: "uint256"; + }, { + readonly internalType: "bytes32"; + readonly name: "blockHash"; + readonly type: "bytes32"; + }, { + readonly components: readonly [{ + readonly internalType: "bool"; + readonly name: "success"; + readonly type: "bool"; + }, { + readonly internalType: "bytes"; + readonly name: "returnData"; + readonly type: "bytes"; + }]; + readonly internalType: "struct Multicall3.Result[]"; + readonly name: "returnData"; + readonly type: "tuple[]"; + }]; + readonly stateMutability: "payable"; + readonly type: "function"; + }]; + static createInterface(): MulticallInterface; + static connect(address: string, runner?: ContractRunner | null): Multicall; +} diff --git a/dist/typechain/factories/OffchainOracle__factory.d.ts b/dist/typechain/factories/OffchainOracle__factory.d.ts new file mode 100644 index 0000000..0ffeac3 --- /dev/null +++ b/dist/typechain/factories/OffchainOracle__factory.d.ts @@ -0,0 +1,404 @@ +import { type ContractRunner } from "ethers"; +import type { OffchainOracle, OffchainOracleInterface } from "../OffchainOracle"; +export declare class OffchainOracle__factory { + static readonly abi: readonly [{ + readonly inputs: readonly [{ + readonly internalType: "contract MultiWrapper"; + readonly name: "_multiWrapper"; + readonly type: "address"; + }, { + readonly internalType: "contract IOracle[]"; + readonly name: "existingOracles"; + readonly type: "address[]"; + }, { + readonly internalType: "enum OffchainOracle.OracleType[]"; + readonly name: "oracleTypes"; + readonly type: "uint8[]"; + }, { + readonly internalType: "contract IERC20[]"; + readonly name: "existingConnectors"; + readonly type: "address[]"; + }, { + readonly internalType: "contract IERC20"; + readonly name: "wBase"; + readonly type: "address"; + }, { + readonly internalType: "address"; + readonly name: "owner"; + readonly type: "address"; + }]; + readonly stateMutability: "nonpayable"; + readonly type: "constructor"; + }, { + readonly inputs: readonly []; + readonly name: "ArraysLengthMismatch"; + readonly type: "error"; + }, { + readonly inputs: readonly []; + readonly name: "ConnectorAlreadyAdded"; + readonly type: "error"; + }, { + readonly inputs: readonly []; + readonly name: "InvalidOracleTokenKind"; + readonly type: "error"; + }, { + readonly inputs: readonly []; + readonly name: "OracleAlreadyAdded"; + readonly type: "error"; + }, { + readonly inputs: readonly []; + readonly name: "SameTokens"; + readonly type: "error"; + }, { + readonly inputs: readonly []; + readonly name: "TooBigThreshold"; + readonly type: "error"; + }, { + readonly inputs: readonly []; + readonly name: "UnknownConnector"; + readonly type: "error"; + }, { + readonly inputs: readonly []; + readonly name: "UnknownOracle"; + readonly type: "error"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: false; + readonly internalType: "contract IERC20"; + readonly name: "connector"; + readonly type: "address"; + }]; + readonly name: "ConnectorAdded"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: false; + readonly internalType: "contract IERC20"; + readonly name: "connector"; + readonly type: "address"; + }]; + readonly name: "ConnectorRemoved"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: false; + readonly internalType: "contract MultiWrapper"; + readonly name: "multiWrapper"; + readonly type: "address"; + }]; + readonly name: "MultiWrapperUpdated"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: false; + readonly internalType: "contract IOracle"; + readonly name: "oracle"; + readonly type: "address"; + }, { + readonly indexed: false; + readonly internalType: "enum OffchainOracle.OracleType"; + readonly name: "oracleType"; + readonly type: "uint8"; + }]; + readonly name: "OracleAdded"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: false; + readonly internalType: "contract IOracle"; + readonly name: "oracle"; + readonly type: "address"; + }, { + readonly indexed: false; + readonly internalType: "enum OffchainOracle.OracleType"; + readonly name: "oracleType"; + readonly type: "uint8"; + }]; + readonly name: "OracleRemoved"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: true; + readonly internalType: "address"; + readonly name: "previousOwner"; + readonly type: "address"; + }, { + readonly indexed: true; + readonly internalType: "address"; + readonly name: "newOwner"; + readonly type: "address"; + }]; + readonly name: "OwnershipTransferred"; + readonly type: "event"; + }, { + readonly inputs: readonly [{ + readonly internalType: "contract IERC20"; + readonly name: "connector"; + readonly type: "address"; + }]; + readonly name: "addConnector"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "contract IOracle"; + readonly name: "oracle"; + readonly type: "address"; + }, { + readonly internalType: "enum OffchainOracle.OracleType"; + readonly name: "oracleKind"; + readonly type: "uint8"; + }]; + readonly name: "addOracle"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "connectors"; + readonly outputs: readonly [{ + readonly internalType: "contract IERC20[]"; + readonly name: "allConnectors"; + readonly type: "address[]"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "contract IERC20"; + readonly name: "srcToken"; + readonly type: "address"; + }, { + readonly internalType: "contract IERC20"; + readonly name: "dstToken"; + readonly type: "address"; + }, { + readonly internalType: "bool"; + readonly name: "useWrappers"; + readonly type: "bool"; + }]; + readonly name: "getRate"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "weightedRate"; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "contract IERC20"; + readonly name: "srcToken"; + readonly type: "address"; + }, { + readonly internalType: "bool"; + readonly name: "useSrcWrappers"; + readonly type: "bool"; + }]; + readonly name: "getRateToEth"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "weightedRate"; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "contract IERC20"; + readonly name: "srcToken"; + readonly type: "address"; + }, { + readonly internalType: "bool"; + readonly name: "useSrcWrappers"; + readonly type: "bool"; + }, { + readonly internalType: "contract IERC20[]"; + readonly name: "customConnectors"; + readonly type: "address[]"; + }, { + readonly internalType: "uint256"; + readonly name: "thresholdFilter"; + readonly type: "uint256"; + }]; + readonly name: "getRateToEthWithCustomConnectors"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "weightedRate"; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "contract IERC20"; + readonly name: "srcToken"; + readonly type: "address"; + }, { + readonly internalType: "bool"; + readonly name: "useSrcWrappers"; + readonly type: "bool"; + }, { + readonly internalType: "uint256"; + readonly name: "thresholdFilter"; + readonly type: "uint256"; + }]; + readonly name: "getRateToEthWithThreshold"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "weightedRate"; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "contract IERC20"; + readonly name: "srcToken"; + readonly type: "address"; + }, { + readonly internalType: "contract IERC20"; + readonly name: "dstToken"; + readonly type: "address"; + }, { + readonly internalType: "bool"; + readonly name: "useWrappers"; + readonly type: "bool"; + }, { + readonly internalType: "contract IERC20[]"; + readonly name: "customConnectors"; + readonly type: "address[]"; + }, { + readonly internalType: "uint256"; + readonly name: "thresholdFilter"; + readonly type: "uint256"; + }]; + readonly name: "getRateWithCustomConnectors"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "weightedRate"; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "contract IERC20"; + readonly name: "srcToken"; + readonly type: "address"; + }, { + readonly internalType: "contract IERC20"; + readonly name: "dstToken"; + readonly type: "address"; + }, { + readonly internalType: "bool"; + readonly name: "useWrappers"; + readonly type: "bool"; + }, { + readonly internalType: "uint256"; + readonly name: "thresholdFilter"; + readonly type: "uint256"; + }]; + readonly name: "getRateWithThreshold"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "weightedRate"; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "multiWrapper"; + readonly outputs: readonly [{ + readonly internalType: "contract MultiWrapper"; + readonly name: ""; + readonly type: "address"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "oracles"; + readonly outputs: readonly [{ + readonly internalType: "contract IOracle[]"; + readonly name: "allOracles"; + readonly type: "address[]"; + }, { + readonly internalType: "enum OffchainOracle.OracleType[]"; + readonly name: "oracleTypes"; + readonly type: "uint8[]"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "owner"; + readonly outputs: readonly [{ + readonly internalType: "address"; + readonly name: ""; + readonly type: "address"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "contract IERC20"; + readonly name: "connector"; + readonly type: "address"; + }]; + readonly name: "removeConnector"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "contract IOracle"; + readonly name: "oracle"; + readonly type: "address"; + }, { + readonly internalType: "enum OffchainOracle.OracleType"; + readonly name: "oracleKind"; + readonly type: "uint8"; + }]; + readonly name: "removeOracle"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "renounceOwnership"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "contract MultiWrapper"; + readonly name: "_multiWrapper"; + readonly type: "address"; + }]; + readonly name: "setMultiWrapper"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "address"; + readonly name: "newOwner"; + readonly type: "address"; + }]; + readonly name: "transferOwnership"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }]; + static createInterface(): OffchainOracleInterface; + static connect(address: string, runner?: ContractRunner | null): OffchainOracle; +} diff --git a/dist/typechain/factories/OvmGasPriceOracle__factory.d.ts b/dist/typechain/factories/OvmGasPriceOracle__factory.d.ts new file mode 100644 index 0000000..73cc6a7 --- /dev/null +++ b/dist/typechain/factories/OvmGasPriceOracle__factory.d.ts @@ -0,0 +1,234 @@ +import { type ContractRunner } from "ethers"; +import type { OvmGasPriceOracle, OvmGasPriceOracleInterface } from "../OvmGasPriceOracle"; +export declare class OvmGasPriceOracle__factory { + static readonly abi: readonly [{ + readonly inputs: readonly [{ + readonly internalType: "address"; + readonly name: "_owner"; + readonly type: "address"; + }]; + readonly stateMutability: "nonpayable"; + readonly type: "constructor"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: false; + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly name: "DecimalsUpdated"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: false; + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly name: "GasPriceUpdated"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: false; + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly name: "L1BaseFeeUpdated"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: false; + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly name: "OverheadUpdated"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: true; + readonly internalType: "address"; + readonly name: "previousOwner"; + readonly type: "address"; + }, { + readonly indexed: true; + readonly internalType: "address"; + readonly name: "newOwner"; + readonly type: "address"; + }]; + readonly name: "OwnershipTransferred"; + readonly type: "event"; + }, { + readonly anonymous: false; + readonly inputs: readonly [{ + readonly indexed: false; + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly name: "ScalarUpdated"; + readonly type: "event"; + }, { + readonly inputs: readonly []; + readonly name: "decimals"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "gasPrice"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "bytes"; + readonly name: "_data"; + readonly type: "bytes"; + }]; + readonly name: "getL1Fee"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "bytes"; + readonly name: "_data"; + readonly type: "bytes"; + }]; + readonly name: "getL1GasUsed"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "l1BaseFee"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "overhead"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "owner"; + readonly outputs: readonly [{ + readonly internalType: "address"; + readonly name: ""; + readonly type: "address"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "renounceOwnership"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly []; + readonly name: "scalar"; + readonly outputs: readonly [{ + readonly internalType: "uint256"; + readonly name: ""; + readonly type: "uint256"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "_decimals"; + readonly type: "uint256"; + }]; + readonly name: "setDecimals"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "_gasPrice"; + readonly type: "uint256"; + }]; + readonly name: "setGasPrice"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "_baseFee"; + readonly type: "uint256"; + }]; + readonly name: "setL1BaseFee"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "_overhead"; + readonly type: "uint256"; + }]; + readonly name: "setOverhead"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "uint256"; + readonly name: "_scalar"; + readonly type: "uint256"; + }]; + readonly name: "setScalar"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }, { + readonly inputs: readonly [{ + readonly internalType: "address"; + readonly name: "newOwner"; + readonly type: "address"; + }]; + readonly name: "transferOwnership"; + readonly outputs: readonly []; + readonly stateMutability: "nonpayable"; + readonly type: "function"; + }]; + static createInterface(): OvmGasPriceOracleInterface; + static connect(address: string, runner?: ContractRunner | null): OvmGasPriceOracle; +} diff --git a/dist/typechain/factories/ReverseRecords__factory.d.ts b/dist/typechain/factories/ReverseRecords__factory.d.ts new file mode 100644 index 0000000..bed38f0 --- /dev/null +++ b/dist/typechain/factories/ReverseRecords__factory.d.ts @@ -0,0 +1,29 @@ +import { type ContractRunner } from "ethers"; +import type { ReverseRecords, ReverseRecordsInterface } from "../ReverseRecords"; +export declare class ReverseRecords__factory { + static readonly abi: readonly [{ + readonly inputs: readonly [{ + readonly internalType: "contract ENS"; + readonly name: "_ens"; + readonly type: "address"; + }]; + readonly stateMutability: "nonpayable"; + readonly type: "constructor"; + }, { + readonly inputs: readonly [{ + readonly internalType: "address[]"; + readonly name: "addresses"; + readonly type: "address[]"; + }]; + readonly name: "getNames"; + readonly outputs: readonly [{ + readonly internalType: "string[]"; + readonly name: "r"; + readonly type: "string[]"; + }]; + readonly stateMutability: "view"; + readonly type: "function"; + }]; + static createInterface(): ReverseRecordsInterface; + static connect(address: string, runner?: ContractRunner | null): ReverseRecords; +} diff --git a/dist/typechain/factories/index.d.ts b/dist/typechain/factories/index.d.ts new file mode 100644 index 0000000..ab90b86 --- /dev/null +++ b/dist/typechain/factories/index.d.ts @@ -0,0 +1,7 @@ +export { ENS__factory } from "./ENS__factory"; +export { ERC20__factory } from "./ERC20__factory"; +export { GasPriceOracle__factory } from "./GasPriceOracle__factory"; +export { Multicall__factory } from "./Multicall__factory"; +export { OffchainOracle__factory } from "./OffchainOracle__factory"; +export { OvmGasPriceOracle__factory } from "./OvmGasPriceOracle__factory"; +export { ReverseRecords__factory } from "./ReverseRecords__factory"; diff --git a/dist/typechain/index.d.ts b/dist/typechain/index.d.ts new file mode 100644 index 0000000..7f5f66e --- /dev/null +++ b/dist/typechain/index.d.ts @@ -0,0 +1,15 @@ +export type { ENS } from "./ENS"; +export type { ERC20 } from "./ERC20"; +export type { GasPriceOracle } from "./GasPriceOracle"; +export type { Multicall } from "./Multicall"; +export type { OffchainOracle } from "./OffchainOracle"; +export type { OvmGasPriceOracle } from "./OvmGasPriceOracle"; +export type { ReverseRecords } from "./ReverseRecords"; +export * as factories from "./factories"; +export { ENS__factory } from "./factories/ENS__factory"; +export { ERC20__factory } from "./factories/ERC20__factory"; +export { GasPriceOracle__factory } from "./factories/GasPriceOracle__factory"; +export { Multicall__factory } from "./factories/Multicall__factory"; +export { OffchainOracle__factory } from "./factories/OffchainOracle__factory"; +export { OvmGasPriceOracle__factory } from "./factories/OvmGasPriceOracle__factory"; +export { ReverseRecords__factory } from "./factories/ReverseRecords__factory";