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ACR,EAEA,oBAAsB,SAAU,EAAgB,GAI/C,IAFA,IAAI,EAAI,EAAe,OACnB,EAAS,IAAI,WAAW,GACnB,EAAI,EAAG,EAAI,EAAG,IAAK,CAG3B,IAFA,IAAI,EAAY,KAAK,MAAM,QAAQ,EAAe,IAC9C,EAAc,EACT,EAAI,EAAG,EAAI,EAAG,IAClB,GAAK,IACR,EAAc,KAAK,MAAM,SAAS,EAAa,UAAU,cAAc,EAAG,KAAK,MAAM,SAAS,EAAe,GAAI,MAGnH,EAAO,GAAK,KAAK,MAAM,SAAS,EAAe,WAAW,GAAY,KAAK,MAAM,QAAQ,IACxD,IAA7B,KAAK,MAAM,gBACd,EAAO,GAAK,KAAK,MAAM,SAAS,EAAO,GAAI,GAE7C,CACA,OAAO,CACR,GAgBD,UAAU,cAAgB,MAAK,WAAc,OAAO,IAAI,UAAU,KAAQ,KAAM,EAAG,IACnF,UAAU,cAAgB,MAAK,WAAc,OAAO,IAAI,UAAU,KAAO,KAAM,EAAG,IAClF,UAAU,aAAe,MAAK,WAAc,OAAO,IAAI,UAAU,GAAM,GAAI,EAAG,IAC9E,UAAU,YAAc,MAAK,WAAa,OAAO,IAAI,UAAU,GAAM,GAAI,EAAG,IAC5E,UAAU,kBAAoB,MAAK,WAAc,OAAO,IAAI,UAAU,IAAQ,IAAK,EAAG,IACtF,UAAU,sBAAwB,MAAK,WAAc,OAAO,IAAI,UAAU,IAAQ,IAAK,EAAG,IAC1F,UAAU,aAAe,UAAU,sBACnC,UAAU,kBAAoB,UAAU,aAExC,KAAK,UAAY,UACjB,KAAK,cAAgB,cACrB,KAAK,mBAAqB,mBAC1B,KAAK,mBAAqB","file":"/npm/reedsolomon@1.0.0/reedsolomon.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/reedsolomon@1.0.0/reedsolomon.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*#!/usr/bin/env node\n * Original implementation is ZXing and ported to JavaScript by cho45.\n * Copyright 2007 ZXing authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nvar GenericGF = function () { this.init.apply(this, arguments) };\nGenericGF.prototype = {\n\tinit : function (primitive, size, b) {\n\t\tthis.primitive = primitive;\n\t\tthis.size = size;\n\t\tthis.generatorBase = b;\n\n\t\tthis.expTable = new Int32Array(size);\n\t\tthis.logTable = new Int32Array(size);\n\n\t\tvar x = 1;\n\t\tfor (var i = 0; i < size; i++) {\n\t\t\tthis.expTable[i] = x;\n\t\t\tx *= 2; // we're assuming the generator alpha is 2\n\t\t\tif (x >= size) {\n\t\t\t\tx ^= primitive;\n\t\t\t\tx &= size-1;\n\t\t\t}\n\t\t}\n\t\tfor (var i = 0; i < size-1; i++) {\n\t\t\tthis.logTable[this.expTable[i]] = i;\n\t\t}\n\t\t// logTable[0] == 0 but this should never be used\n\n\t\tthis.zero = new GenericGFPoly(this, GenericGFPoly.COEFFICIENTS_ZERO);\n\t\tthis.one = new GenericGFPoly(this, GenericGFPoly.COEFFICIENTS_ONE);\n\t},\n\n\tbuildMonomial : function (degree, coefficient) {\n\t\tif (degree < 0) {\n\t\t\tthrow new Error(\"IllegalArgumentException()\");\n\t\t}\n\t\tif (coefficient === 0) {\n\t\t\treturn this.zero;\n\t\t}\n\t\tvar coefficients = new Int32Array(degree + 1);\n\t\tcoefficients[0] = coefficient;\n\t\treturn new GenericGFPoly(this, coefficients);\n\t},\n\n\tgetZero : function () {\n\t\treturn this.zero;\n\t},\n\n\tgetOne : function () {\n\t\treturn this.one;\n\t},\n\n\texp : function (a) {\n\t\treturn this.expTable[a];\n\t},\n\n\tlog : function (a) {\n\t\tif (a === 0) {\n\t\t\tthrow new Error(\"IllegalArgumentException()\");\n\t\t}\n\t\treturn this.logTable[a];\n\t},\n\n\tinverse: function (a) {\n\t\tif (a === 0) {\n\t\t\tthrow new Error(\"ArithmeticException()\");\n\t\t}\n\t\treturn this.expTable[this.size - this.logTable[a] - 1];\n\t},\n\n\tmultiply: function (a, b) {\n\t\tif (a === 0 || b === 0) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn this.expTable[(this.logTable[a] + this.logTable[b]) % (this.size - 1)];\n\t},\n\n\tgetSize : function () {\n\t\treturn this.size;\n\t},\n\n\tgetGeneratorBase : function () {\n\t\treturn this.generatorBase;\n\t},\n\n\ttoString: function () {\n\t\treturn \"GF(0x\" + this.primitive.toString(16) + ',' + this.size + ')';\n\t}\n};\nGenericGF.addOrSubtract = function (a, b) { return a ^ b };\n\nvar GenericGFPoly = function () { this.init.apply(this, arguments) };\nGenericGFPoly.prototype = {\n\tinit : function (field, coefficients) {\n\t\tif (coefficients.length === 0) {\n\t\t\tthrow new Error(\"IllegalArgumentException()\");\n\t\t}\n\t\tthis.field = field;\n\t\tvar coefficientsLength = coefficients.length;\n\t\tif (coefficientsLength > 1 && coefficients[0] === 0) {\n\t\t\t// Leading term must be non-zero for anything except the constant polynomial \"0\"\n\t\t\tvar firstNonZero = 1;\n\t\t\twhile (firstNonZero < coefficientsLength && coefficients[firstNonZero] === 0) {\n\t\t\t\tfirstNonZero++;\n\t\t\t}\n\t\t\tif (firstNonZero == coefficientsLength) {\n\t\t\t\tthis.coefficients = GenericGFPoly.COEFFICIENTS_ZERO;\n\t\t\t} else {\n\t\t\t\tthis.coefficients = coefficients.subarray(firstNonZero, coefficientsLength);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.coefficients = coefficients;\n\t\t}\n\t\tthis.degree = this.coefficients.length - 1;\n\t},\n\n\tgetCoefficients : function () {\n\t\treturn this.coefficients;\n\t},\n\n\tgetDegree : function () {\n\t\treturn this.degree;\n\t},\n\n\tisZero : function () {\n\t\treturn this.coefficients[0] === 0;\n\t},\n\n\tgetCoefficient : function (degree) {\n\t\treturn this.coefficients[this.coefficients.length - 1 - degree];\n\t},\n\n\tevaluateAt : function (a) {\n\t\tif (a === 0) {\n\t\t\t// Just return the x^0 coefficient\n\t\t\treturn this.getCoefficient(0);\n\t\t}\n\t\tvar coefficients = this.coefficients;\n\t\tvar size = coefficients.length;\n\t\tvar result;\n\t\tif (a == 1) {\n\t\t\t// Just the sum of the coefficients\n\t\t\tresult = 0;\n\t\t\tfor (var i = 0, len = coefficients.length; i < len; i++) {\n\t\t\t\tresult = GenericGF.addOrSubtract(result, coefficients[i]);\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\n\t\tresult = coefficients[0];\n\t\tfor (var i = 1; i < size; i++) {\n\t\t\tresult = GenericGF.addOrSubtract(this.field.multiply(a, result), coefficients[i]);\n\t\t}\n\t\treturn result;\n\t},\n\n\taddOrSubtract : function (other, buf) {\n\t\tif (this.field !== other.field) {\n\t\t\tthrow new Error('IllegalArgumentException(\"GenericGFPolys do not have same GenericGF field\")');\n\t\t}\n\t\tif (this.isZero()) {\n\t\t\treturn other;\n\t\t}\n\t\tif (other.isZero()) {\n\t\t\treturn this;\n\t\t}\n\n\t\tvar smallerCoefficients = this.coefficients;\n\t\tvar largerCoefficients = other.coefficients;\n\t\tif (smallerCoefficients.length > largerCoefficients.length) {\n\t\t\tvar temp = smallerCoefficients;\n\t\t\tsmallerCoefficients = largerCoefficients;\n\t\t\tlargerCoefficients = temp;\n\t\t}\n\t\tvar sumDiff = buf ? buf.subarray(0, largerCoefficients.length) : new Int32Array(largerCoefficients.length);\n\t\tvar lengthDiff = largerCoefficients.length - smallerCoefficients.length;\n\t\tfor (var i = lengthDiff; i < largerCoefficients.length; i++) {\n\t\t\tsumDiff[i] = GenericGF.addOrSubtract(smallerCoefficients[i - lengthDiff], largerCoefficients[i]);\n\t\t}\n\t\t// Copy high-order terms only found in higher-degree polynomial's coefficients\n\t\tsumDiff.set(largerCoefficients.subarray(0, lengthDiff));\n\n\t\treturn new GenericGFPoly(this.field, sumDiff);\n\t},\n\n\tmultiply : function (other) {\n\t\tif (other instanceof GenericGFPoly) {\n\t\t\treturn this.multiplyGenericGFPoly(other);\n\t\t} else {\n\t\t\treturn this.multiplyScalar(other);\n\t\t}\n\t},\n\n\tmultiplyGenericGFPoly : function (other) {\n\t\tif (this.field !== other.field) {\n\t\t\tthrow new Error('IllegalArgumentException(\"GenericGFPolys do not have same GenericGF field\")');\n\t\t}\n\t\tif (this.isZero() || other.isZero()) {\n\t\t\treturn this.field.zero;\n\t\t}\n\t\tvar aCoefficients = this.coefficients;\n\t\tvar aLength = aCoefficients.length;\n\t\tvar bCoefficients = other.coefficients;\n\t\tvar bLength = bCoefficients.length;\n\t\tvar product = new Int32Array(aLength + bLength - 1);\n\t\tfor (var i = 0; i < aLength; i++) {\n\t\t\tvar aCoeff = aCoefficients[i];\n\t\t\tfor (var j = 0; j < bLength; j++) {\n\t\t\t\tproduct[i + j] = GenericGF.addOrSubtract(product[i + j], this.field.multiply(aCoeff, bCoefficients[j]));\n\t\t\t}\n\t\t}\n\t\treturn new GenericGFPoly(this.field, product);\n\t},\n\n\tmultiplyScalar : function (scalar) {\n\t\tif (scalar === 0) {\n\t\t\treturn this.field.zero;\n\t\t}\n\t\tif (scalar == 1) {\n\t\t\treturn this;\n\t\t}\n\t\tvar size = this.coefficients.length;\n\t\tvar product = new Int32Array(size);\n\t\tfor (var i = 0; i < size; i++) {\n\t\t\tproduct[i] = this.field.multiply(this.coefficients[i], scalar);\n\t\t}\n\t\treturn new GenericGFPoly(this.field, product);\n\t},\n\n\tmultiplyByMonomial : function (degree, coefficient) {\n\t\tif (degree < 0) {\n\t\t\tthrow new Error('IllegalArgumentException()');\n\t\t}\n\t\tif (coefficient === 0) {\n\t\t\treturn this.field.zero;\n\t\t}\n\t\tvar size = this.coefficients.length;\n\t\tvar product = new Int32Array(size + degree);\n\t\tfor (var i = 0; i < size; i++) {\n\t\t\tproduct[i] = this.field.multiply(this.coefficients[i], coefficient);\n\t\t}\n\t\treturn new GenericGFPoly(this.field, product);\n\t},\n\n\tdivide : function (other) {\n\t\tif (this.field !== other.field) {\n\t\t\tthrow new Error('IllegalArgumentException(\"GenericGFPolys do not have same GenericGF field\")');\n\t\t}\n\t\tif (other.isZero()) {\n\t\t\tthrow new Error('IllegalArgumentException(\"Divide by 0\")');\n\t\t}\n\n\t\tvar quotient = this.field.getZero();\n\t\tvar remainder = this;\n \n\t\tvar denominatorLeadingTerm = other.getCoefficient(other.degree);\n\t\tvar inverseDenominatorLeadingTerm = this.field.inverse(denominatorLeadingTerm);\n\n\t\twhile (remainder.degree >= other.degree && !remainder.isZero()) {\n\t\t\tvar degreeDifference = remainder.degree - other.degree;\n\t\t\tvar scale = this.field.multiply(remainder.getCoefficient(remainder.degree), inverseDenominatorLeadingTerm);\n\t\t\tvar term = other.multiplyByMonomial(degreeDifference, scale);\n\t\t\tvar iterationQuotient = this.field.buildMonomial(degreeDifference, scale);\n\t\t\tquotient = quotient.addOrSubtract(iterationQuotient, quotient.coefficients);\n\t\t\tremainder = remainder.addOrSubtract(term, remainder.coefficients);\n\t\t}\n\n\t\treturn [ quotient, remainder ];\n\t},\n\n\ttoString : function () {\n\t\tvar result = '';\n\t\tfor (var degree = this.degree; degree >= 0; degree--) {\n\t\t\tvar coefficient = this.getCoefficient(degree);\n\t\t\tif (coefficient !== 0) {\n\t\t\t\tif (coefficient < 0) {\n\t\t\t\t\tresult += \" - \";\n\t\t\t\t\tcoefficient = -coefficient;\n\t\t\t\t} else {\n\t\t\t\t\tif (result.length > 0) {\n\t\t\t\t\t\tresult += \" + \";\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (degree === 0 || coefficient != 1) {\n\t\t\t\t\tvar alphaPower = this.field.log(coefficient);\n\t\t\t\t\tif (alphaPower === 0) {\n\t\t\t\t\t\tresult += '1';\n\t\t\t\t\t} else if (alphaPower == 1) {\n\t\t\t\t\t\tresult += 'a';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult += \"a^\";\n\t\t\t\t\t\tresult += alphaPower;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (degree !== 0) {\n\t\t\t\t\tif (degree == 1) {\n\t\t\t\t\t\tresult += 'x';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresult += \"x^\";\n\t\t\t\t\t\tresult += degree;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn result.toString();\n\t}\n};\nGenericGFPoly.COEFFICIENTS_ZERO = new Int32Array([ 0 ]);\nGenericGFPoly.COEFFICIENTS_ONE  = new Int32Array([ 1 ]);\n\nvar ReedSolomonEncoder = function () { this.init.apply(this, arguments) };\nReedSolomonEncoder.prototype = {\n\tinit : function (field) {\n\t\tthis.field = field;\n\t\tthis.cachedGenerators = [];\n\t\tthis.cachedGenerators.push(new GenericGFPoly(field, new Int32Array([1])));\n\t},\n\n\tbuildGenerator : function (degree) {\n\t\tif (degree >= this.cachedGenerators.length) {\n\t\t\tvar lastGenerator = this.cachedGenerators[this.cachedGenerators.length - 1];\n\t\t\tfor (var d = this.cachedGenerators.length; d <= degree; d++) {\n\t\t\t\tvar nextGenerator = lastGenerator.multiply(new GenericGFPoly(this.field, new Int32Array([ 1, this.field.exp(d - 1 + this.field.generatorBase) ]) ));\n\t\t\t\tthis.cachedGenerators.push(nextGenerator);\n\t\t\t\tlastGenerator = nextGenerator;\n\t\t\t}\n\t\t}\n\t\treturn this.cachedGenerators[degree];\n\t},\n\n\tencode : function (toEncode, ecBytes) {\n\t\tif (ecBytes === 0) {\n\t\t\tthrow new Error('IllegalArgumentException(\"No error correction bytes\")');\n\t\t}\n\t\tvar dataBytes = toEncode.length - ecBytes;\n\t\tif (dataBytes <= 0) {\n\t\t\tthrow new Error('IllegalArgumentException(\"No data bytes provided\")');\n\t\t}\n\t\tvar generator = this.buildGenerator(ecBytes);\n\t\tvar infoCoefficients = new Int32Array(dataBytes);\n\t\tinfoCoefficients.set(toEncode.subarray(0, dataBytes));\n\n\t\tvar info = new GenericGFPoly(this.field, infoCoefficients);\n\t\tinfo = info.multiplyByMonomial(ecBytes, 1);\n\t\tvar remainder = info.divide(generator)[1];\n\t\tvar coefficients = remainder.coefficients;\n\t\tvar numZeroCoefficients = ecBytes - coefficients.length;\n\t\tfor (var i = 0; i < numZeroCoefficients; i++) {\n\t\t\ttoEncode[dataBytes + i] = 0;\n\t\t}\n\t\ttoEncode.set(coefficients.subarray(0, coefficients.length), dataBytes + numZeroCoefficients);\n\t}\n};\n\nvar ReedSolomonDecoder = function () { this.init.apply(this, arguments) };\nReedSolomonDecoder.prototype = {\n\tinit : function (field) {\n\t\tthis.field = field;\n\t},\n\n\tdecode : function (received, twoS) {\n\t\tvar poly = new GenericGFPoly(this.field, received);\n\t\tvar syndromeCoefficients = new Int32Array(twoS);\n\t\tvar noError = true;\n\t\tfor (var i = 0; i < twoS; i++) {\n\t\t\tvar eval_ = poly.evaluateAt(this.field.exp(i + this.field.generatorBase));\n\t\t\tsyndromeCoefficients[syndromeCoefficients.length - 1 - i] = eval_;\n\t\t\tif (eval_ !== 0) {\n\t\t\t\tnoError = false;\n\t\t\t}\n\t\t}\n\n\t\tif (noError) {\n\t\t\treturn;\n\t\t}\n\t\tvar syndrome = new GenericGFPoly(this.field, syndromeCoefficients);\n\t\tvar sigmaOmega = this.runEuclideanAlgorithm(this.field.buildMonomial(twoS, 1), syndrome, twoS);\n\t\tvar sigma = sigmaOmega[0];\n\t\tvar omega = sigmaOmega[1];\n\t\tvar errorLocations = this.findErrorLocations(sigma);\n\t\tvar errorMagnitudes = this.findErrorMagnitudes(omega, errorLocations);\n\t\tfor (var i = 0; i < errorLocations.length; i++) {\n\t\t\tvar position = received.length - 1 - this.field.log(errorLocations[i]);\n\t\t\tif (position < 0) {\n\t\t\t\tthrow new Error('ReedSolomonException(\"Bad error location\")');\n\t\t\t}\n\t\t\treceived[position] = GenericGF.addOrSubtract(received[position], errorMagnitudes[i]);\n\t\t}\n\t},\n\n\trunEuclideanAlgorithm : function (a, b, R) {\n\t\t// Assume a's degree is >= b's\n\t\tif (a.degree < b.degree) {\n\t\t\tvar temp = a;\n\t\t\ta = b;\n\t\t\tb = temp;\n\t\t}\n\n\t\tvar rLast = a;\n\t\tvar r = b;\n\t\tvar tLast = this.field.zero;\n\t\tvar t = this.field.one;\n\n\t\t// Run Euclidean algorithm until r's degree is less than R/2\n\t\twhile (r.degree >= R / 2) {\n\t\t\tvar rLastLast = rLast;\n\t\t\tvar tLastLast = tLast;\n\t\t\trLast = r;\n\t\t\ttLast = t;\n\n\t\t\t// Divide rLastLast by rLast, with quotient in q and remainder in r\n\t\t\tif (rLast.isZero()) {\n\t\t\t\t// Oops, Euclidean algorithm already terminated?\n\t\t\t\tthrow new Error('ReedSolomonException(\"r_{i-1} was zero\")');\n\t\t\t}\n\t\t\tr = rLastLast;\n\t\t\tvar q = this.field.zero;\n\t\t\tvar denominatorLeadingTerm = rLast.getCoefficient(rLast.degree);\n\t\t\tvar dltInverse = this.field.inverse(denominatorLeadingTerm);\n\t\t\twhile (r.degree >= rLast.degree && !r.isZero()) {\n\t\t\t\tvar degreeDiff = r.degree - rLast.degree;\n\t\t\t\tvar scale = this.field.multiply(r.getCoefficient(r.degree), dltInverse);\n\t\t\t\tq = q.addOrSubtract(this.field.buildMonomial(degreeDiff, scale));\n\t\t\t\tr = r.addOrSubtract(rLast.multiplyByMonomial(degreeDiff, scale));\n\t\t\t}\n\n\t\t\tt = q.multiply(tLast).addOrSubtract(tLastLast);\n\n\t\t\tif (r.degree >= rLast.degree) {\n\t\t\t\tthrow new Error('IllegalStateException(\"Division algorithm failed to reduce polynomial?\")');\n\t\t\t}\n\t\t}\n\n\t\tvar sigmaTildeAtZero = t.getCoefficient(0);\n\t\tif (sigmaTildeAtZero === 0) {\n\t\t\tthrow new Error('ReedSolomonException(\"sigmaTilde(0) was zero\")');\n\t\t}\n\n\t\tvar inverse = this.field.inverse(sigmaTildeAtZero);\n\t\tvar sigma = t.multiply(inverse);\n\t\tvar omega = r.multiply(inverse);\n\t\treturn [ sigma, omega ];\n\t},\n\n\tfindErrorLocations : function (errorLocator) {\n\t\t// This is a direct application of Chien's search\n\t\tvar numErrors = errorLocator.degree;\n\t\tif (numErrors == 1) { // shortcut\n\t\t\treturn new Int32Array([  errorLocator.getCoefficient(1)  ]);\n\t\t}\n\t\tvar result = new Int32Array(numErrors);\n\t\tvar e = 0;\n\t\tfor (var i = 1; i < this.field.size && e < numErrors; i++) {\n\t\t\tif (errorLocator.evaluateAt(i) === 0) {\n\t\t\t\tresult[e] = this.field.inverse(i);\n\t\t\t\te++;\n\t\t\t}\n\t\t}\n\t\tif (e != numErrors) {\n\t\t\tthrow new Error('ReedSolomonException(\"Error locator degree does not match number of roots\")');\n\t\t}\n\t\treturn result;\n\t},\n\n\tfindErrorMagnitudes : function (errorEvaluator, errorLocations) {\n\t\t// This is directly applying Forney's Formula\n\t\tvar s = errorLocations.length;\n\t\tvar result = new Int32Array(s);\n\t\tfor (var i = 0; i < s; i++) {\n\t\t\tvar xiInverse = this.field.inverse(errorLocations[i]);\n\t\t\tvar denominator = 1;\n\t\t\tfor (var j = 0; j < s; j++) {\n\t\t\t\tif (i != j) {\n\t\t\t\t\tdenominator = this.field.multiply(denominator, GenericGF.addOrSubtract(1, this.field.multiply(errorLocations[j], xiInverse)));\n\t\t\t\t}\n\t\t\t}\n\t\t\tresult[i] = this.field.multiply(errorEvaluator.evaluateAt(xiInverse), this.field.inverse(denominator));\n\t\t\tif (this.field.generatorBase !== 0) {\n\t\t\t\tresult[i] = this.field.multiply(result[i], xiInverse);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n};\n\n// System.arraycopy(src, srcPos, dest, destPos, length);\n// dest.set(src.subarray(srcPos, srcPos + length), destPos);\n\nfunction lazy (func) {\n\tvar val;\n\treturn function () {\n\t\tif (!val) {\n\t\t\tval = func();\n\t\t}\n\t\treturn val;\n\t};\n}\n\nGenericGF.AZTEC_DATA_12 = lazy(function () { return new GenericGF(0x1069, 4096, 1) }); // x^12 + x^6 + x^5 + x^3 + 1\nGenericGF.AZTEC_DATA_10 = lazy(function () { return new GenericGF(0x409, 1024, 1) }); // x^10 + x^3 + 1\nGenericGF.AZTEC_DATA_6 = lazy(function () { return new GenericGF(0x43, 64, 1) }); // x^6 + x + 1\nGenericGF.AZTEC_PARAM = lazy(function() { return new GenericGF(0x13, 16, 1) }); // x^4 + x + 1\nGenericGF.QR_CODE_FIELD_256 = lazy(function () { return new GenericGF(0x011D, 256, 0) }); // x^8 + x^4 + x^3 + x^2 + 1\nGenericGF.DATA_MATRIX_FIELD_256 = lazy(function () { return new GenericGF(0x012D, 256, 1) }); // x^8 + x^5 + x^3 + x^2 + 1\nGenericGF.AZTEC_DATA_8 = GenericGF.DATA_MATRIX_FIELD_256;\nGenericGF.MAXICODE_FIELD_64 = GenericGF.AZTEC_DATA_6;\n\nthis.GenericGF = GenericGF;\nthis.GenericGFPoly = GenericGFPoly;\nthis.ReedSolomonEncoder = ReedSolomonEncoder;\nthis.ReedSolomonDecoder = ReedSolomonDecoder;\n\nfunction dump (array) {\n\tconsole.log(Array.prototype.join.call(array));\n}\n"]}