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,GAE3G,EAAyB,KAAK,OAAO,EACzC,CAEA,IAAI,EAAgB,GAAG,OAAO,EAAsB,MAAM,OAAO,EAAwB,YACrF,EAAkB,GAAG,OAAO,GAAqB,OAAO,GAG5D,MAAO,CAAE,SAFc,GAAG,OAAO,GAAiB,OAAO,GAAc,OAAO,EAAK,gBAAkB,WAAW,EAAK,iBAAmB,IAEnG,gBAAiB,EAAc,IAAK,EAC7E,EAMA,SAAS,WAAW,GAEhB,IAAI,EAAQ,GACR,EAAS,GAQb,OANA,EAAK,SAAQ,SAAU,GACnB,EAAM,KAAK,EAAI,MACf,EAAO,KAAK,EAAI,MACpB,KAEe,IAAI,SAAS,OAAO,MAAM,UACzB,OAAO,EAAO,GAAQ,QAAQ,QAAS,GAC3D,CAEA,QAAiB,QAAI","file":"/npm/huffc@0.0.25/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/huffc@0.0.25/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nexports.__esModule = true;\nvar bytes_1 = require(\"./utils/bytes\");\nvar compiler_1 = require(\"./compiler/compiler\");\nvar high_level_1 = require(\"./parser/high-level\");\nvar ethers_1 = require(\"ethers\");\nvar output_1 = require(\"./output\");\n/**\n * Compile a Huff file.\n * @param filePath The path to the file.\n * @param args An array containing the arguments to the macro.\n * @returns The compiled bytecode.\n */\nvar compile = function (args) {\n    // Parse the file and generate definitions.\n    var _a = (0, high_level_1.parseFile)(args.filePath), macros = _a.macros, constants = _a.constants, tables = _a.tables, functions = _a.functions, events = _a.events;\n    // Generate the contract ABI.\n    var abi = args.generateAbi ? (0, output_1.generateAbi)(functions, events) : \"\";\n    // Set storage pointer constants.\n    constants.data = (0, high_level_1.setStoragePointerConstants)([\"CONSTRUCTOR\", \"MAIN\"], macros.data, constants);\n    // Compile the macros.\n    var mainBytecode = macros.data[\"MAIN\"]\n        ? (0, compiler_1.compileMacro)(\"MAIN\", [], macros.data, constants.data, tables.data)\n        : \"\";\n    var constructorBytecode = macros.data[\"CONSTRUCTOR\"]\n        ? (0, compiler_1.compileMacro)(\"CONSTRUCTOR\", [], macros.data, constants.data, tables.data)\n        : \"\";\n    // Store the sizes of the bytecode.\n    var contractLength = mainBytecode.length / 2;\n    var constructorLength = constructorBytecode.length / 2;\n    // Bootstrap code variables\n    var bootStrapCodeSize = 9;\n    var pushContractSizeCode;\n    var pushContractCodeOffset;\n    // Compute pushX(contract size)\n    if (contractLength < 256) {\n        // Convert the size and offset to bytes.\n        var contractSize = (0, bytes_1.padNBytes)((0, bytes_1.toHex)(contractLength), 1);\n        // push1(contract size)\n        pushContractSizeCode = \"60\".concat(contractSize);\n    }\n    else {\n        // Increment bootstrap code size\n        bootStrapCodeSize++;\n        // Convert the size and offset to bytes.\n        var contractSize = (0, bytes_1.padNBytes)((0, bytes_1.toHex)(contractLength), 2);\n        // push2(contract size)\n        pushContractSizeCode = \"61\".concat(contractSize);\n    }\n    // Compute pushX(offset to code)\n    if ((bootStrapCodeSize + constructorLength) < 256) {\n        // Convert the size and offset to bytes.\n        var contractCodeOffset = (0, bytes_1.padNBytes)((0, bytes_1.toHex)(bootStrapCodeSize + constructorLength), 1);\n        // push1(offset to code)\n        pushContractCodeOffset = \"60\".concat(contractCodeOffset);\n    }\n    else {\n        // Increment bootstrap code size\n        bootStrapCodeSize++;\n        // Convert the size and offset to bytes.\n        var contractCodeOffset = (0, bytes_1.padNBytes)((0, bytes_1.toHex)(bootStrapCodeSize + constructorLength), 2);\n        // push2(offset to code)\n        pushContractCodeOffset = \"61\".concat(contractCodeOffset);\n    }\n    // pushX(contract size) dup1 pushX(offset to code) returndatsize codecopy returndatasize return\n    var bootstrapCode = \"\".concat(pushContractSizeCode, \"80\").concat(pushContractCodeOffset, \"3d393df3\");\n    var constructorCode = \"\".concat(constructorBytecode).concat(bootstrapCode);\n    var deployedBytecode = \"\".concat(constructorCode).concat(mainBytecode).concat(args.constructorArgs ? encodeArgs(args.constructorArgs) : \"\");\n    // Return the bytecode.\n    return { bytecode: deployedBytecode, runtimeBytecode: mainBytecode, abi: abi };\n};\n/**\n * Encode arguments.\n * @param args The arguments to encode.\n * @returns The encoded arguments.\n */\nfunction encodeArgs(args) {\n    // Instantiate two arrays.\n    var types = [];\n    var values = [];\n    // Split the array of arguments into arrays of types and values.\n    args.forEach(function (arg) {\n        types.push(arg.type);\n        values.push(arg.value);\n    });\n    // Encode and array the types and values.\n    var abiCoder = new ethers_1.ethers.utils.AbiCoder();\n    return abiCoder.encode(types, values).replace(/^(0x)/, \"\");\n}\n// Export compiler function as default.\nexports[\"default\"] = compile;\n"]}