@hinkal/common 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/snarkjsWorkerLauncher-SrStwJvX.js +1 -0
- package/assets/snarkjsWorkerLogic-DtIjisbE.js +132 -0
- package/assets/utxoWorkerLauncher-CIBeBAML.js +1 -0
- package/assets/utxoWorkerLogic-C8R4GSaf.js +199 -0
- package/assets/zkProofWorkerLauncher-DfwteloJ.js +1 -0
- package/assets/zkProofWorkerLogic-CY9y6rOV.js +199 -0
- package/common/src/constants/vite.constants.cjs +1 -1
- package/common/src/constants/vite.constants.mjs +23 -5
- package/common/src/data-structures/Hinkal/hinkalSolanaClaimUtxo.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaClaimUtxo.mjs +50 -97
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaDepositAndWithdraw.mjs +90 -128
- package/common/src/data-structures/Hinkal/hinkalSolanaSwap.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaSwap.mjs +56 -110
- package/common/src/data-structures/Hinkal/hinkalSolanaTransact.cjs +1 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaTransact.d.ts +3 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaTransact.mjs +117 -0
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.d.ts +2 -31
- package/common/src/data-structures/Hinkal/hinkalSolanaTransfer.mjs +45 -121
- package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalSolanaWithdraw.mjs +41 -83
- package/common/src/data-structures/Hinkal/hinkalTransact.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalTransact.mjs +41 -42
- package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.cjs +1 -1
- package/common/src/data-structures/Hinkal/hinkalWithdrawStuckUtxos.mjs +106 -125
- package/common/src/data-structures/IndexedDB/pay-activity-db.cjs +1 -1
- package/common/src/data-structures/IndexedDB/pay-activity-db.mjs +43 -1
- package/common/src/functions/index.cjs +1 -1
- package/common/src/functions/index.mjs +0 -1
- package/common/src/functions/pre-transaction/ensureAmountChanges.cjs +1 -1
- package/common/src/functions/pre-transaction/ensureAmountChanges.mjs +3 -10
- package/common/src/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
- package/common/src/functions/pre-transaction/outputUtxoProcessing.d.ts +1 -0
- package/common/src/functions/pre-transaction/outputUtxoProcessing.mjs +13 -9
- package/common/src/functions/snarkjs/constructSolanaZkProof.cjs +1 -1
- package/common/src/functions/snarkjs/constructSolanaZkProof.d.ts +1 -1
- package/common/src/functions/snarkjs/constructSolanaZkProof.mjs +35 -35
- package/common/src/functions/snarkjs/constructTxEnclave.cjs +1 -1
- package/common/src/functions/snarkjs/constructTxEnclave.d.ts +2 -0
- package/common/src/functions/snarkjs/constructTxEnclave.mjs +40 -40
- package/common/src/functions/utils/enum.utils.cjs +1 -0
- package/common/src/functions/utils/enum.utils.mjs +12 -0
- package/common/src/functions/utils/index.cjs +1 -1
- package/common/src/functions/utils/index.mjs +0 -1
- package/common/src/types/index.cjs +1 -1
- package/common/src/types/index.d.ts +1 -0
- package/common/src/types/index.mjs +1 -0
- package/common/src/types/pay-activities.types.d.ts +18 -3
- package/common/src/types/solana-transact.types.cjs +1 -0
- package/common/src/types/solana-transact.types.d.ts +35 -0
- package/common/src/types/solana-transact.types.mjs +6 -0
- package/common/src/webworker/logError-Dex6ch32.js +2 -0
- package/common/src/webworker/package.json +5 -3
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/snarkjsWorker/snarkjsWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/snarkjsWorkerNode.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/utxoWorker/utxoWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/utxoWorkerNode.cjs +1 -1
- package/common/src/webworker/viteWorkerURL.constant.cjs +1 -28
- package/common/src/webworker/viteWorkerURL.constant.mjs +13 -27
- package/common/src/webworker/workerProxy-BuJUMCQ4.js +1 -0
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.cjs +1 -1
- package/common/src/webworker/zkProofWorker/zkProofWorkerLauncher.ts?worker&url.mjs +1 -1
- package/common/src/webworker/zkProofWorkerNode.cjs +1 -1
- package/package.json +5 -3
- package/common/src/webworker/logError-CxZzSALU.js +0 -2
- package/common/src/webworker/workerProxy-swwPYw6e.js +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import{i as e,n as t,r as n,t as r}from"./snarkjsWorkerLauncher-SrStwJvX.js";var i=r(((e,t)=>{var n=typeof Reflect==`object`?Reflect:null,r=n&&typeof n.apply==`function`?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},i=n&&typeof n.ownKeys==`function`?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function a(e){console&&console.warn&&console.warn(e)}var o=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}t.exports=s,t.exports.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function l(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(s,`defaultMaxListeners`,{enumerable:!0,get:function(){return c},set:function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);c=e}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function u(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)r(c,this,t);else for(var l=c.length,u=g(c,l),n=0;n<l;++n)r(u[n],this,t);return!0};function d(e,t,n,r){var i,o,s;if(l(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),s=o[t]),s===void 0)s=o[t]=n,++e._eventsCount;else if(typeof s==`function`?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=u(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=Error(`Possible EventEmitter memory leak detected. `+s.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);c.name=`MaxListenersExceededWarning`,c.emitter=e,c.type=t,c.count=s.length,a(c)}return e}s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,a,o;if(l(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():_(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function m(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?v(i):g(i,i.length)}s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h;function h(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function g(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function y(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}x(e,t,a,{once:!0}),t!==`error`&&b(e,i,{once:!0})})}function b(e,t,n){typeof e.on==`function`&&x(e,`error`,t,n)}function x(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}})),a=r(((e,t)=>{t.exports={}})),o=class{isNode=!1;onmessage=null;onerror=null;_eventEmitter;get eventEmitter(){if(this._eventEmitter)return this._eventEmitter;if(this.isNode){let e=i();this._eventEmitter=new e}else this._eventEmitter=new EventTarget;return this._eventEmitter}constructor(){this.isNode=typeof process<`u`&&process.versions!=null&&process.versions.node!=null}terminate(){}postMessage(e){this.isNode?this.eventEmitter.emit(`message`,e):postMessage(e)}postMessageToMainThread(e){this.isNode?this.parentPort.postMessage(e):postMessage(e)}postErrorToMainThread(e){this.isNode?this.parentPort.postMessage({error:e}):postMessage(e)}get parentPort(){return a().parentPort}};const s=(e,t=null,n)=>JSON.stringify(e,(e,n)=>{let r=typeof t==`function`?t(e,n):n;return typeof r==`bigint`?r.toString():r},n);function c(e,t){return Object.values(e).includes(t)}function l(e,t,n=!1){if(c(e,t))return t;let r=`Value ${s(t)} is not a valid member of enum ${s(e)}.`;if(n)throw Error(r)}var u=n({browser:()=>E,default:()=>D,description:()=>p,devDependencies:()=>w,engines:()=>T,exports:()=>g,funding:()=>b,homepage:()=>y,keywords:()=>x,license:()=>C,main:()=>m,name:()=>d,readmeFilename:()=>S,repository:()=>v,scripts:()=>_,types:()=>h,version:()=>f}),d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O=t((()=>{d=`dotenv`,f=`16.6.1`,p=`Loads environment variables from .env file`,m=`lib/main.js`,h=`lib/main.d.ts`,g={".":{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`},_={"dts-check":`tsc --project tests/types/tsconfig.json`,lint:`standard`,pretest:`npm run lint && npm run dts-check`,test:`tap run --allow-empty-coverage --disable-coverage --timeout=60000`,"test:coverage":`tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov`,prerelease:`npm test`,release:`standard-version`},v={type:`git`,url:`git://github.com/motdotla/dotenv.git`},y=`https://github.com/motdotla/dotenv#readme`,b=`https://dotenvx.com`,x=[`dotenv`,`env`,`.env`,`environment`,`variables`,`config`,`settings`],S=`README.md`,C=`BSD-2-Clause`,w={"@types/node":`^18.11.3`,decache:`^4.6.2`,sinon:`^14.0.1`,standard:`^17.0.0`,"standard-version":`^9.5.0`,tap:`^19.2.0`,typescript:`^4.8.4`},T={node:`>=12`},E={fs:!1},D={name:d,version:f,description:p,main:m,types:h,exports:g,scripts:_,repository:v,homepage:y,funding:b,keywords:x,readmeFilename:S,license:C,devDependencies:w,engines:T,browser:E}})),k=r(((t,n)=>{let r=a(),i=a(),o=a(),s=a(),c=(O(),e(u).default).version,l=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function d(e){let t={},n=e.toString();n=n.replace(/\r\n?/gm,`
|
|
2
|
+
`);let r;for(;(r=l.exec(n))!=null;){let e=r[1],n=r[2]||``;n=n.trim();let i=n[0];n=n.replace(/^(['"`])([\s\S]*)\1$/gm,`$2`),i===`"`&&(n=n.replace(/\\n/g,`
|
|
3
|
+
`),n=n.replace(/\\r/g,`\r`)),t[e]=n}return t}function f(e){e||={};let t=v(e);e.path=t;let n=T.configDotenv(e);if(!n.parsed){let e=Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw e.code=`MISSING_DATA`,e}let r=g(e).split(`,`),i=r.length,a;for(let e=0;e<i;e++)try{let t=_(n,r[e].trim());a=T.decrypt(t.ciphertext,t.key);break}catch(t){if(e+1>=i)throw t}return T.parse(a)}function p(e){console.log(`[dotenv@${c}][WARN] ${e}`)}function m(e){console.log(`[dotenv@${c}][DEBUG] ${e}`)}function h(e){console.log(`[dotenv@${c}] ${e}`)}function g(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:``}function _(e,t){let n;try{n=new URL(t)}catch(e){if(e.code===`ERR_INVALID_URL`){let e=Error(`INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development`);throw e.code=`INVALID_DOTENV_KEY`,e}throw e}let r=n.password;if(!r){let e=Error(`INVALID_DOTENV_KEY: Missing key part`);throw e.code=`INVALID_DOTENV_KEY`,e}let i=n.searchParams.get(`environment`);if(!i){let e=Error(`INVALID_DOTENV_KEY: Missing environment part`);throw e.code=`INVALID_DOTENV_KEY`,e}let a=`DOTENV_VAULT_${i.toUpperCase()}`,o=e.parsed[a];if(!o){let e=Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw e.code=`NOT_FOUND_DOTENV_ENVIRONMENT`,e}return{ciphertext:o,key:r}}function v(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let n of e.path)r.existsSync(n)&&(t=n.endsWith(`.vault`)?n:`${n}.vault`);else t=e.path.endsWith(`.vault`)?e.path:`${e.path}.vault`;else t=i.resolve(process.cwd(),`.env.vault`);return r.existsSync(t)?t:null}function y(e){return e[0]===`~`?i.join(o.homedir(),e.slice(1)):e}function b(e){let t=!!(e&&e.debug),n=e&&`quiet`in e?e.quiet:!0;(t||!n)&&h(`Loading env from encrypted .env.vault`);let r=T._parseVault(e),i=process.env;return e&&e.processEnv!=null&&(i=e.processEnv),T.populate(i,r,e),{parsed:r}}function x(e){let t=i.resolve(process.cwd(),`.env`),n=`utf8`,a=!!(e&&e.debug),o=e&&`quiet`in e?e.quiet:!0;e&&e.encoding?n=e.encoding:a&&m(`No encoding is specified. UTF-8 is used by default`);let s=[t];if(e&&e.path)if(!Array.isArray(e.path))s=[y(e.path)];else{s=[];for(let t of e.path)s.push(y(t))}let c,l={};for(let t of s)try{let i=T.parse(r.readFileSync(t,{encoding:n}));T.populate(l,i,e)}catch(e){a&&m(`Failed to load ${t} ${e.message}`),c=e}let u=process.env;if(e&&e.processEnv!=null&&(u=e.processEnv),T.populate(u,l,e),a||!o){let e=Object.keys(l).length,t=[];for(let e of s)try{let n=i.relative(process.cwd(),e);t.push(n)}catch(t){a&&m(`Failed to load ${e} ${t.message}`),c=t}h(`injecting env (${e}) from ${t.join(`,`)}`)}return c?{parsed:l,error:c}:{parsed:l}}function S(e){if(g(e).length===0)return T.configDotenv(e);let t=v(e);return t?T._configVault(e):(p(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`),T.configDotenv(e))}function C(e,t){let n=Buffer.from(t.slice(-64),`hex`),r=Buffer.from(e,`base64`),i=r.subarray(0,12),a=r.subarray(-16);r=r.subarray(12,-16);try{let e=s.createDecipheriv(`aes-256-gcm`,n,i);return e.setAuthTag(a),`${e.update(r)}${e.final()}`}catch(e){let t=e instanceof RangeError,n=e.message===`Invalid key length`,r=e.message===`Unsupported state or unable to authenticate data`;if(t||n){let e=Error(`INVALID_DOTENV_KEY: It must be 64 characters long (or more)`);throw e.code=`INVALID_DOTENV_KEY`,e}else if(r){let e=Error(`DECRYPTION_FAILED: Please check your DOTENV_KEY`);throw e.code=`DECRYPTION_FAILED`,e}else throw e}}function w(e,t,n={}){let r=!!(n&&n.debug),i=!!(n&&n.override);if(typeof t!=`object`){let e=Error(`OBJECT_REQUIRED: Please check the processEnv argument being passed to populate`);throw e.code=`OBJECT_REQUIRED`,e}for(let n of Object.keys(t))Object.prototype.hasOwnProperty.call(e,n)?(i===!0&&(e[n]=t[n]),r&&m(i===!0?`"${n}" is already defined and WAS overwritten`:`"${n}" is already defined and was NOT overwritten`)):e[n]=t[n]}let T={configDotenv:x,_configVault:b,_parseVault:f,config:S,decrypt:C,parse:d,populate:w};n.exports.configDotenv=T.configDotenv,n.exports._configVault=T._configVault,n.exports._parseVault=T._parseVault,n.exports.config=T.config,n.exports.decrypt=T.decrypt,n.exports.parse=T.parse,n.exports.populate=T.populate,n.exports=T}));let A=function(e){return e.DEVELOPMENT=`development`,e.PLAYGROUND=`playground`,e.PRODUCTION=`production`,e.STAGING=`staging`,e}({});const j={[A.DEVELOPMENT]:[`localhost`,`192.`,`127.`],[A.PLAYGROUND]:[`playground`],[A.STAGING]:[`working`,`staging`]},ee=typeof process<`u`&&process?.release?.name===`node`,M=typeof process<`u`&&process.versions!=null&&process.versions.node!=null,N=typeof __webpack_require__<`u`;typeof window<`u`&&window?.location?.protocol;function P(e,t){return t.some(t=>e.includes(t))}const F=()=>(k().config({path:`DOTENV_OVERRIDE`in process.env?process.env.DOTENV_OVERRIDE:void 0}),process.env.DEPLOYMENT_MODE?.startsWith(`production`)?A.PRODUCTION:l(A,process.env.DEPLOYMENT_MODE)||A.DEVELOPMENT),te=(()=>{if(!ee&&typeof window>`u`)return;if(ee)return F();if(window?.location?.protocol===`chrome-extension:`)return l(A,WALLET_DEPLOYMENT_MODE)||A.STAGING;let e=window?.location?.host;return e?P(e,j[A.DEVELOPMENT])?A.DEVELOPMENT:P(e,j[A.PLAYGROUND])?A.PLAYGROUND:P(e,j[A.STAGING])?A.STAGING:A.PRODUCTION:A.PRODUCTION})(),I=te===A.DEVELOPMENT,L=te===A.PLAYGROUND,ne=te===A.STAGING||I||L;typeof navigator<`u`&&navigator.product,ne||ee&&A.PRODUCTION;const re=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];function ie(e,t){if(!t||t==10)return BigInt(e);if(t==16)return e.slice(0,2)==`0x`?BigInt(e):BigInt(`0x`+e)}const R=ie;function ae(e,t){let n=BigInt(0);t=BigInt(t);for(let r=0;r<e.length;r++)n=n*t+BigInt(e[r]);return n}function oe(e){let t=e.toString(16);return(t.length-1)*4+re[parseInt(t[0],16)]}function se(e){return BigInt(e)<BigInt(0)}function ce(e){return!e}function le(e,t){return BigInt(e)<<BigInt(t)}function ue(e,t){return BigInt(e)>>BigInt(t)}const de=le,fe=ue;function pe(e){return(BigInt(e)&BigInt(1))==BigInt(1)}function me(e){let t=BigInt(e),n=[];for(;t;){if(t&BigInt(1)){let e=2-Number(t%BigInt(4));n.push(e),t-=BigInt(e)}else n.push(0);t>>=BigInt(1)}return n}function he(e){let t=BigInt(e),n=[];for(;t;)t&BigInt(1)?n.push(1):n.push(0),t>>=BigInt(1);return n}function ge(e){if(e>BigInt(2**53-1))throw Error(`Number too big`);return Number(e)}function _e(e,t){let n=[],r=BigInt(e);for(t=BigInt(t);r;)n.unshift(Number(r%t)),r/=t;return n}function ve(e,t){return BigInt(e)+BigInt(t)}function ye(e,t){return BigInt(e)-BigInt(t)}function be(e){return-BigInt(e)}function xe(e,t){return BigInt(e)*BigInt(t)}function Se(e){return BigInt(e)*BigInt(e)}function Ce(e,t){return BigInt(e)**BigInt(t)}function we(e,t){return BigInt(e)**BigInt(t)}function Te(e){return BigInt(e)>=0?BigInt(e):-BigInt(e)}function Ee(e,t){return BigInt(e)/BigInt(t)}function De(e,t){return BigInt(e)%BigInt(t)}function Oe(e,t){return BigInt(e)==BigInt(t)}function ke(e,t){return BigInt(e)!=BigInt(t)}function Ae(e,t){return BigInt(e)<BigInt(t)}function je(e,t){return BigInt(e)>BigInt(t)}function Me(e,t){return BigInt(e)<=BigInt(t)}function Ne(e,t){return BigInt(e)>=BigInt(t)}function Pe(e,t){return BigInt(e)&BigInt(t)}function Fe(e,t){return BigInt(e)|BigInt(t)}function Ie(e,t){return BigInt(e)^BigInt(t)}function Le(e,t){return BigInt(e)&&BigInt(t)}function Re(e,t){return BigInt(e)||BigInt(t)}function ze(e){return!BigInt(e)}function Be(e,t,n,r){let i=`0000000`+n.toString(16),a=new Uint32Array(e.buffer,e.byteOffset+t,r/4),o=((i.length-7)*4-1>>5)+1;for(let e=0;e<o;e++)a[e]=parseInt(i.substring(i.length-8*e-8,i.length-8*e),16);for(let e=o;e<a.length;e++)a[e]=0;for(let t=a.length*4;t<r;t++)e[t]=ge(Pe(ue(n,t*8),255))}function Ve(e,t,n,r){let i=`0000000`+n.toString(16),a=new DataView(e.buffer,e.byteOffset+t,r),o=((i.length-7)*4-1>>5)+1;for(let e=0;e<o;e++)a.setUint32(r-e*4-4,parseInt(i.substring(i.length-8*e-8,i.length-8*e),16),!1);for(let e=0;e<r/4-o;e++)a[e]=0}function He(e,t,n){n||=e.byteLength,t||=0;let r=new Uint32Array(e.buffer,e.byteOffset+t,n/4),i=Array(n/4);return r.forEach((e,t)=>i[i.length-t-1]=e.toString(16).padStart(8,`0`)),ie(i.join(``),16)}function Ue(e,t,n){n||=e.byteLength,t||=0;let r=new DataView(e.buffer,e.byteOffset+t,n),i=Array(n/4);for(let e=0;e<n/4;e++)i[e]=r.getUint32(e*4,!1).toString(16).padStart(8,`0`);return ie(i.join(``),16)}function We(e,t){return e.toString(t)}function Ge(e){let t=new Uint8Array(Math.floor((oe(e)-1)/8)+1);return Be(t,0,e,t.byteLength),t}const Ke=R(0),qe=R(1);var Je=Object.freeze({__proto__:null,abs:Te,add:ve,band:Pe,bitLength:oe,bits:he,bor:Fe,bxor:Ie,div:Ee,e:R,eq:Oe,exp:we,fromArray:ae,fromRprBE:Ue,fromRprLE:He,fromString:ie,geq:Ne,gt:je,isNegative:se,isOdd:pe,isZero:ce,land:Le,leq:Me,lnot:ze,lor:Re,lt:Ae,mod:De,mul:xe,naf:me,neg:be,neq:ke,one:qe,pow:Ce,shiftLeft:le,shiftRight:ue,shl:de,shr:fe,square:Se,sub:ye,toArray:_e,toLEBuff:Ge,toNumber:ge,toRprBE:Ve,toRprLE:Be,toString:We,zero:Ke});const Ye=[];for(let e=0;e<256;e++)Ye[e]=Xe(e,8);function Xe(e,t){let n=0,r=e;for(let e=0;e<t;e++)n<<=1,n|=r&1,r>>=1;return n}function Ze(e,t,n){if(ce(n))return e.one;let r=he(n);if(r.length==0)return e.one;let i=t;for(let n=r.length-2;n>=0;n--)i=e.square(i),r[n]&&(i=e.mul(i,t));return i}function Qe(e){if(e.m%2==1)if(Oe(De(e.p,4),1))if(Oe(De(e.p,8),1))if(Oe(De(e.p,16),1))$e(e);else if(Oe(De(e.p,16),9))et(e);else throw Error(`Field withot sqrt`);else if(Oe(De(e.p,8),5))tt(e);else throw Error(`Field withot sqrt`);else Oe(De(e.p,4),3)&&nt(e);else{let t=De(Ce(e.p,e.m/2),4);t==1?rt(e):t==3?it(e):at(e)}}function $e(e){for(e.sqrt_q=Ce(e.p,e.m),e.sqrt_s=0,e.sqrt_t=ye(e.sqrt_q,1);!pe(e.sqrt_t);)e.sqrt_s+=1,e.sqrt_t=Ee(e.sqrt_t,2);let t=e.one;for(;e.eq(t,e.one);){let n=e.random();e.sqrt_z=e.pow(n,e.sqrt_t),t=e.pow(e.sqrt_z,2**(e.sqrt_s-1))}e.sqrt_tm1d2=Ee(ye(e.sqrt_t,1),2),e.sqrt=function(e){let t=this;if(t.isZero(e))return t.zero;let n=t.pow(e,t.sqrt_tm1d2),r=t.pow(t.mul(t.square(n),e),2**(t.sqrt_s-1));if(t.eq(r,t.negone))return null;let i=t.sqrt_s,a=t.mul(e,n),o=t.mul(a,n),s=t.sqrt_z;for(;!t.eq(o,t.one);){let e=t.square(o),r=1;for(;!t.eq(e,t.one);)e=t.square(e),r++;n=s;for(let e=0;e<i-r-1;e++)n=t.square(n);s=t.square(n),o=t.mul(o,s),a=t.mul(a,n),i=r}return t.geq(a,t.zero)?a:t.neg(a)}}function et(e){e.sqrt=function(){throw Error(`Sqrt alg 4 not implemented`)}}function tt(e){e.sqrt=function(){throw Error(`Sqrt alg 3 not implemented`)}}function nt(e){e.sqrt_q=Ce(e.p,e.m),e.sqrt_e1=Ee(ye(e.sqrt_q,3),4),e.sqrt=function(t){if(this.isZero(t))return this.zero;let n=this.pow(t,this.sqrt_e1),r=this.mul(this.square(n),t);if(this.eq(r,this.negone))return null;let i=this.mul(n,t);return e.geq(i,e.zero)?i:e.neg(i)}}function rt(e){e.sqrt=function(){throw Error(`Sqrt alg 10 not implemented`)}}function it(e){e.sqrt_q=Ce(e.p,e.m/2),e.sqrt_e34=Ee(ye(e.sqrt_q,3),4),e.sqrt_e12=Ee(ye(e.sqrt_q,1),2),e.frobenius=function(t,n){return t%2==1?e.conjugate(n):n},e.sqrt=function(e){let t=this,n=t.pow(e,t.sqrt_e34),r=t.mul(t.square(n),e),i=t.mul(t.frobenius(1,r),r);if(t.eq(i,t.negone))return null;let a=t.mul(n,e),o;if(t.eq(r,t.negone))o=t.mul(a,[t.F.zero,t.F.one]);else{let e=t.pow(t.add(t.one,r),t.sqrt_e12);o=t.mul(e,a)}return t.geq(o,t.zero)?o:t.neg(o)}}function at(e){e.sqrt=function(){throw Error(`Sqrt alg 8 not implemented`)}}function ot(e,t,n,r,i){e[t]=e[t]+e[n]>>>0,e[i]=(e[i]^e[t])>>>0,e[i]=(e[i]<<16|e[i]>>>16&65535)>>>0,e[r]=e[r]+e[i]>>>0,e[n]=(e[n]^e[r])>>>0,e[n]=(e[n]<<12|e[n]>>>20&4095)>>>0,e[t]=e[t]+e[n]>>>0,e[i]=(e[i]^e[t])>>>0,e[i]=(e[i]<<8|e[i]>>>24&255)>>>0,e[r]=e[r]+e[i]>>>0,e[n]=(e[n]^e[r])>>>0,e[n]=(e[n]<<7|e[n]>>>25&127)>>>0}function st(e){ot(e,0,4,8,12),ot(e,1,5,9,13),ot(e,2,6,10,14),ot(e,3,7,11,15),ot(e,0,5,10,15),ot(e,1,6,11,12),ot(e,2,7,8,13),ot(e,3,4,9,14)}var ct=class{constructor(e){e||=[0,0,0,0,0,0,0,0],this.state=[1634760805,857760878,2036477234,1797285236,e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],0,0,0,0],this.idx=16,this.buff=Array(16)}nextU32(){return this.idx==16&&this.update(),this.buff[this.idx++]}nextU64(){return ve(xe(this.nextU32(),4294967296),this.nextU32())}nextBool(){return(this.nextU32()&1)==1}update(){for(let e=0;e<16;e++)this.buff[e]=this.state[e];for(let e=0;e<10;e++)st(this.buff);for(let e=0;e<16;e++)this.buff[e]=this.buff[e]+this.state[e]>>>0;this.idx=0,this.state[12]=this.state[12]+1>>>0,this.state[12]==0&&(this.state[13]=this.state[13]+1>>>0,this.state[13]==0&&(this.state[14]=this.state[14]+1>>>0,this.state[14]==0&&(this.state[15]=this.state[15]+1>>>0)))}};function lt(e){let t=new Uint8Array(e);if(globalThis.crypto!==void 0)globalThis.crypto.getRandomValues(t);else for(let n=0;n<e;n++)t[n]=Math.random()*4294967296>>>0;return t}function ut(){let e=lt(32),t=new Uint32Array(e.buffer),n=[];for(let e=0;e<8;e++)n.push(t[e]);return n}let dt=null;function ft(){return dt||(dt=new ct(ut()),dt)}var pt=class{constructor(e,t,n){this.F=t,this.G=e,this.opMulGF=n;let r=t.sqrt_t||t.t,i=t.sqrt_s||t.s,a=t.one;for(;t.eq(t.pow(a,t.half),t.one);)a=t.add(a,t.one);this.w=Array(i+1),this.wi=Array(i+1),this.w[i]=this.F.pow(a,r),this.wi[i]=this.F.inv(this.w[i]);let o=i-1;for(;o>=0;)this.w[o]=this.F.square(this.w[o+1]),this.wi[o]=this.F.square(this.wi[o+1]),o--;this.roots=[],this._setRoots(Math.min(i,15))}_setRoots(e){for(let t=e;t>=0&&!this.roots[t];t--){let e=this.F.one,n=1<<t,r=Array(n);for(let i=0;i<n;i++)r[i]=e,e=this.F.mul(e,this.w[t]);this.roots[t]=r}}fft(e){if(e.length<=1)return e;let t=mt(e.length-1)+1;this._setRoots(t);let n=1<<t;if(e.length!=n)throw Error(`Size must be multiple of 2`);return ht(this,e,t,0,1)}ifft(e){if(e.length<=1)return e;let t=mt(e.length-1)+1;this._setRoots(t);let n=1<<t;if(e.length!=n)throw Error(`Size must be multiple of 2`);let r=ht(this,e,t,0,1),i=this.F.inv(this.F.mulScalar(this.F.one,n)),a=Array(n);for(let e=0;e<n;e++)a[e]=this.opMulGF(r[(n-e)%n],i);return a}};function mt(e){return(e&4294901760?(e&=4294901760,16):0)|(e&4278255360?(e&=4278255360,8):0)|(e&4042322160?(e&=4042322160,4):0)|(e&3435973836?(e&=3435973836,2):0)|(e&2863311530)!=0}function ht(e,t,n,r,i){let a=1<<n;if(a==1)return[t[r]];if(a==2)return[e.G.add(t[r],t[r+i]),e.G.sub(t[r],t[r+i])];let o=a>>1,s=ht(e,t,n-1,r,i*2),c=ht(e,t,n-1,r+i,i*2),l=Array(a);for(let t=0;t<o;t++)l[t]=e.G.add(s[t],e.opMulGF(c[t],e.roots[n][t])),l[t+o]=e.G.sub(s[t],e.opMulGF(c[t],e.roots[n][t]));return l}var gt=class{constructor(e){this.type=`F1`,this.one=BigInt(1),this.zero=BigInt(0),this.p=BigInt(e),this.m=1,this.negone=this.p-this.one,this.two=BigInt(2),this.half=this.p>>this.one,this.bitLength=oe(this.p),this.mask=(this.one<<BigInt(this.bitLength))-this.one,this.n64=Math.floor((this.bitLength-1)/64)+1,this.n32=this.n64*2,this.n8=this.n64*8,this.R=this.e(this.one<<BigInt(this.n64*64)),this.Ri=this.inv(this.R);let t=this.negone>>this.one;this.nqr=this.two;let n=this.pow(this.nqr,t);for(;!this.eq(n,this.negone);)this.nqr+=this.one,n=this.pow(this.nqr,t);for(this.s=0,this.t=this.negone;(this.t&this.one)==this.zero;)this.s+=1,this.t>>=this.one;this.nqr_to_t=this.pow(this.nqr,this.t),Qe(this),this.FFT=new pt(this,this,this.mul.bind(this)),this.fft=this.FFT.fft.bind(this.FFT),this.ifft=this.FFT.ifft.bind(this.FFT),this.w=this.FFT.w,this.wi=this.FFT.wi,this.shift=this.square(this.nqr),this.k=this.exp(this.nqr,2**this.s)}e(e,t){let n;if(t?t==16&&(n=BigInt(`0x`+e)):n=BigInt(e),n<0){let e=-n;return e>=this.p&&(e%=this.p),this.p-e}else return n>=this.p?n%this.p:n}add(e,t){let n=e+t;return n>=this.p?n-this.p:n}sub(e,t){return e>=t?e-t:this.p-t+e}neg(e){return e&&this.p-e}mul(e,t){return e*t%this.p}mulScalar(e,t){return e*this.e(t)%this.p}square(e){return e*e%this.p}eq(e,t){return e==t}neq(e,t){return e!=t}lt(e,t){return(e>this.half?e-this.p:e)<(t>this.half?t-this.p:t)}gt(e,t){return(e>this.half?e-this.p:e)>(t>this.half?t-this.p:t)}leq(e,t){return(e>this.half?e-this.p:e)<=(t>this.half?t-this.p:t)}geq(e,t){return(e>this.half?e-this.p:e)>=(t>this.half?t-this.p:t)}div(e,t){return this.mul(e,this.inv(t))}idiv(e,t){if(!t)throw Error(`Division by zero`);return e/t}inv(e){if(!e)throw Error(`Division by zero`);let t=this.zero,n=this.p,r=this.one,i=e%this.p;for(;i;){let e=n/i;[t,r]=[r,t-e*r],[n,i]=[i,n-e*i]}return t<this.zero&&(t+=this.p),t}mod(e,t){return e%t}pow(e,t){return Ze(this,e,t)}exp(e,t){return Ze(this,e,t)}band(e,t){let n=e&t&this.mask;return n>=this.p?n-this.p:n}bor(e,t){let n=(e|t)&this.mask;return n>=this.p?n-this.p:n}bxor(e,t){let n=(e^t)&this.mask;return n>=this.p?n-this.p:n}bnot(e){let t=e^this.mask;return t>=this.p?t-this.p:t}shl(e,t){if(Number(t)<this.bitLength){let n=e<<t&this.mask;return n>=this.p?n-this.p:n}else{let n=this.p-t;return Number(n)<this.bitLength?e>>n:this.zero}}shr(e,t){if(Number(t)<this.bitLength)return e>>t;{let n=this.p-t;if(Number(n)<this.bitLength){let t=e<<n&this.mask;return t>=this.p?t-this.p:t}else return 0}}land(e,t){return e&&t?this.one:this.zero}lor(e,t){return e||t?this.one:this.zero}lnot(e){return e?this.zero:this.one}sqrt_old(e){if(e==this.zero)return this.zero;if(this.pow(e,this.negone>>this.one)!=this.one)return null;let t=this.s,n=this.nqr_to_t,r=this.pow(e,this.t),i=this.pow(e,this.add(this.t,this.one)>>this.one);for(;r!=this.one;){let e=this.square(r),a=1;for(;e!=this.one;)a++,e=this.square(e);let o=n;for(let e=0;e<t-a-1;e++)o=this.square(o);t=a,n=this.square(o),r=this.mul(r,n),i=this.mul(i,o)}return i>this.p>>this.one&&(i=this.neg(i)),i}normalize(e,t){if(e=BigInt(e,t),e<0){let t=-e;return t>=this.p&&(t%=this.p),this.p-t}else return e>=this.p?e%this.p:e}random(){let e=this.bitLength*2/8,t=this.zero;for(let n=0;n<e;n++)t=(t<<BigInt(8))+BigInt(lt(1)[0]);return t%this.p}toString(e,t){t||=10;let n;return n=e>this.half&&t==10?`-`+(this.p-e).toString(t):e.toString(t),n}isZero(e){return e==this.zero}fromRng(e){let t;do{t=this.zero;for(let n=0;n<this.n64;n++)t+=e.nextU64()<<BigInt(64*n);t&=this.mask}while(t>=this.p);return t=t*this.Ri%this.p,t}fft(e){return this.FFT.fft(e)}ifft(e){return this.FFT.ifft(e)}toRprLE(e,t,n){Be(e,t,n,this.n64*8)}toRprBE(e,t,n){Ve(e,t,n,this.n64*8)}toRprBEM(e,t,n){return this.toRprBE(e,t,this.mul(this.R,n))}toRprLEM(e,t,n){return this.toRprLE(e,t,this.mul(this.R,n))}fromRprLE(e,t){return He(e,t,this.n8)}fromRprBE(e,t){return Ue(e,t,this.n8)}fromRprLEM(e,t){return this.mul(this.fromRprLE(e,t),this.Ri)}fromRprBEM(e,t){return this.mul(this.fromRprBE(e,t),this.Ri)}toObject(e){return e}},_t={};_t.bigInt2BytesLE=function(e,t){let n=Array(t),r=BigInt(e);for(let e=0;e<t;e++)n[e]=Number(r&255n),r>>=8n;return n},_t.bigInt2U32LE=function(e,t){let n=Array(t),r=BigInt(e);for(let e=0;e<t;e++)n[e]=Number(r&4294967295n),r>>=32n;return n},_t.isOcamNum=function(e){return!(!Array.isArray(e)||e.length!=3||typeof e[0]!=`number`||typeof e[1]!=`number`||!Array.isArray(e[2]))};var vt=function(e,t,n){let r=n||`int`;if(e.modules[r])return r;e.modules[r]={};let i=t*2,a=t*8;function o(){let n=e.addFunction(r+`_copy`);n.addParam(`px`,`i32`),n.addParam(`pr`,`i32`);let i=n.getCodeBuilder();for(let e=0;e<t;e++)n.addCode(i.i64_store(i.getLocal(`pr`),e*8,i.i64_load(i.getLocal(`px`),e*8)))}function s(){let n=e.addFunction(r+`_zero`);n.addParam(`pr`,`i32`);let i=n.getCodeBuilder();for(let e=0;e<t;e++)n.addCode(i.i64_store(i.getLocal(`pr`),e*8,i.i64_const(0)))}function c(){let n=e.addFunction(r+`_one`);n.addParam(`pr`,`i32`);let i=n.getCodeBuilder();n.addCode(i.i64_store(i.getLocal(`pr`),0,i.i64_const(1)));for(let e=1;e<t;e++)n.addCode(i.i64_store(i.getLocal(`pr`),e*8,i.i64_const(0)))}function l(){let n=e.addFunction(r+`_isZero`);n.addParam(`px`,`i32`),n.setReturnType(`i32`);let i=n.getCodeBuilder();function a(e){return e==0?i.ret(i.i64_eqz(i.i64_load(i.getLocal(`px`)))):i.if(i.i64_eqz(i.i64_load(i.getLocal(`px`),e*8)),a(e-1),i.ret(i.i32_const(0)))}n.addCode(a(t-1)),n.addCode(i.ret(i.i32_const(0)))}function u(){let n=e.addFunction(r+`_eq`);n.addParam(`px`,`i32`),n.addParam(`py`,`i32`),n.setReturnType(`i32`);let i=n.getCodeBuilder();function a(e){return e==0?i.ret(i.i64_eq(i.i64_load(i.getLocal(`px`)),i.i64_load(i.getLocal(`py`)))):i.if(i.i64_eq(i.i64_load(i.getLocal(`px`),e*8),i.i64_load(i.getLocal(`py`),e*8)),a(e-1),i.ret(i.i32_const(0)))}n.addCode(a(t-1)),n.addCode(i.ret(i.i32_const(0)))}function d(){let n=e.addFunction(r+`_gte`);n.addParam(`px`,`i32`),n.addParam(`py`,`i32`),n.setReturnType(`i32`);let i=n.getCodeBuilder();function a(e){return e==0?i.ret(i.i64_ge_u(i.i64_load(i.getLocal(`px`)),i.i64_load(i.getLocal(`py`)))):i.if(i.i64_lt_u(i.i64_load(i.getLocal(`px`),e*8),i.i64_load(i.getLocal(`py`),e*8)),i.ret(i.i32_const(0)),i.if(i.i64_gt_u(i.i64_load(i.getLocal(`px`),e*8),i.i64_load(i.getLocal(`py`),e*8)),i.ret(i.i32_const(1)),a(e-1)))}n.addCode(a(t-1)),n.addCode(i.ret(i.i32_const(0)))}function f(){let t=e.addFunction(r+`_add`);t.addParam(`x`,`i32`),t.addParam(`y`,`i32`),t.addParam(`r`,`i32`),t.setReturnType(`i32`),t.addLocal(`c`,`i64`);let n=t.getCodeBuilder();t.addCode(n.setLocal(`c`,n.i64_add(n.i64_load32_u(n.getLocal(`x`)),n.i64_load32_u(n.getLocal(`y`))))),t.addCode(n.i64_store32(n.getLocal(`r`),n.getLocal(`c`)));for(let e=1;e<i;e++)t.addCode(n.setLocal(`c`,n.i64_add(n.i64_add(n.i64_load32_u(n.getLocal(`x`),4*e),n.i64_load32_u(n.getLocal(`y`),4*e)),n.i64_shr_u(n.getLocal(`c`),n.i64_const(32))))),t.addCode(n.i64_store32(n.getLocal(`r`),e*4,n.getLocal(`c`)));t.addCode(n.i32_wrap_i64(n.i64_shr_u(n.getLocal(`c`),n.i64_const(32))))}function p(){let t=e.addFunction(r+`_sub`);t.addParam(`x`,`i32`),t.addParam(`y`,`i32`),t.addParam(`r`,`i32`),t.setReturnType(`i32`),t.addLocal(`c`,`i64`);let n=t.getCodeBuilder();t.addCode(n.setLocal(`c`,n.i64_sub(n.i64_load32_u(n.getLocal(`x`)),n.i64_load32_u(n.getLocal(`y`))))),t.addCode(n.i64_store32(n.getLocal(`r`),n.i64_and(n.getLocal(`c`),n.i64_const(`0xFFFFFFFF`))));for(let e=1;e<i;e++)t.addCode(n.setLocal(`c`,n.i64_add(n.i64_sub(n.i64_load32_u(n.getLocal(`x`),4*e),n.i64_load32_u(n.getLocal(`y`),4*e)),n.i64_shr_s(n.getLocal(`c`),n.i64_const(32))))),t.addCode(n.i64_store32(n.getLocal(`r`),e*4,n.i64_and(n.getLocal(`c`),n.i64_const(`0xFFFFFFFF`))));t.addCode(n.i32_wrap_i64(n.i64_shr_s(n.getLocal(`c`),n.i64_const(32))))}function m(){let t=e.addFunction(r+`_mul`);t.addParam(`x`,`i32`),t.addParam(`y`,`i32`),t.addParam(`r`,`i32`),t.addLocal(`c0`,`i64`),t.addLocal(`c1`,`i64`);for(let e=0;e<i;e++)t.addLocal(`x`+e,`i64`),t.addLocal(`y`+e,`i64`);let n=t.getCodeBuilder(),a=[],o=[];function s(e,t){let r,i;return a[e]?r=n.getLocal(`x`+e):(r=n.teeLocal(`x`+e,n.i64_load32_u(n.getLocal(`x`),e*4)),a[e]=!0),o[t]?i=n.getLocal(`y`+t):(i=n.teeLocal(`y`+t,n.i64_load32_u(n.getLocal(`y`),t*4)),o[t]=!0),n.i64_mul(r,i)}let c=`c0`,l=`c1`;for(let e=0;e<i*2-1;e++){for(let r=Math.max(0,e-i+1);r<=e&&r<i;r++){let i=e-r;t.addCode(n.setLocal(c,n.i64_add(n.i64_and(n.getLocal(c),n.i64_const(4294967295)),s(r,i)))),t.addCode(n.setLocal(l,n.i64_add(n.getLocal(l),n.i64_shr_u(n.getLocal(c),n.i64_const(32)))))}t.addCode(n.i64_store32(n.getLocal(`r`),e*4,n.getLocal(c))),[c,l]=[l,c],t.addCode(n.setLocal(l,n.i64_shr_u(n.getLocal(c),n.i64_const(32))))}t.addCode(n.i64_store32(n.getLocal(`r`),i*4*2-4,n.getLocal(c)))}function h(){let t=e.addFunction(r+`_square`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`),t.addLocal(`c0`,`i64`),t.addLocal(`c1`,`i64`),t.addLocal(`c0_old`,`i64`),t.addLocal(`c1_old`,`i64`);for(let e=0;e<i;e++)t.addLocal(`x`+e,`i64`);let n=t.getCodeBuilder(),a=[];function o(e,t){let r,i;return a[e]?r=n.getLocal(`x`+e):(r=n.teeLocal(`x`+e,n.i64_load32_u(n.getLocal(`x`),e*4)),a[e]=!0),a[t]?i=n.getLocal(`x`+t):(i=n.teeLocal(`x`+t,n.i64_load32_u(n.getLocal(`x`),t*4)),a[t]=!0),n.i64_mul(r,i)}let s=`c0_old`,c=`c1_old`;for(let e=0;e<i*2-1;e++){t.addCode(n.setLocal(`c0`,n.i64_const(0)),n.setLocal(`c1`,n.i64_const(0)));for(let r=Math.max(0,e-i+1);r<e+1>>1&&r<i;r++){let i=e-r;t.addCode(n.setLocal(`c0`,n.i64_add(n.i64_and(n.getLocal(`c0`),n.i64_const(4294967295)),o(r,i)))),t.addCode(n.setLocal(`c1`,n.i64_add(n.getLocal(`c1`),n.i64_shr_u(n.getLocal(`c0`),n.i64_const(32)))))}t.addCode(n.setLocal(`c0`,n.i64_shl(n.i64_and(n.getLocal(`c0`),n.i64_const(4294967295)),n.i64_const(1)))),t.addCode(n.setLocal(`c1`,n.i64_add(n.i64_shl(n.getLocal(`c1`),n.i64_const(1)),n.i64_shr_u(n.getLocal(`c0`),n.i64_const(32))))),e%2==0&&(t.addCode(n.setLocal(`c0`,n.i64_add(n.i64_and(n.getLocal(`c0`),n.i64_const(4294967295)),o(e>>1,e>>1)))),t.addCode(n.setLocal(`c1`,n.i64_add(n.getLocal(`c1`),n.i64_shr_u(n.getLocal(`c0`),n.i64_const(32)))))),e>0&&(t.addCode(n.setLocal(`c0`,n.i64_add(n.i64_and(n.getLocal(`c0`),n.i64_const(4294967295)),n.i64_and(n.getLocal(s),n.i64_const(4294967295))))),t.addCode(n.setLocal(`c1`,n.i64_add(n.i64_add(n.getLocal(`c1`),n.i64_shr_u(n.getLocal(`c0`),n.i64_const(32))),n.getLocal(c))))),t.addCode(n.i64_store32(n.getLocal(`r`),e*4,n.getLocal(`c0`))),t.addCode(n.setLocal(s,n.getLocal(`c1`)),n.setLocal(c,n.i64_shr_u(n.getLocal(s),n.i64_const(32))))}t.addCode(n.i64_store32(n.getLocal(`r`),i*4*2-4,n.getLocal(s)))}function g(){let t=e.addFunction(r+`_squareOld`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let n=t.getCodeBuilder();t.addCode(n.call(r+`_mul`,n.getLocal(`x`),n.getLocal(`x`),n.getLocal(`r`)))}function _(){let t=e.addFunction(r+`__mul1`);t.addParam(`px`,`i32`),t.addParam(`y`,`i64`),t.addParam(`pr`,`i32`),t.addLocal(`c`,`i64`);let n=t.getCodeBuilder();t.addCode(n.setLocal(`c`,n.i64_mul(n.i64_load32_u(n.getLocal(`px`),0,0),n.getLocal(`y`)))),t.addCode(n.i64_store32(n.getLocal(`pr`),0,0,n.getLocal(`c`)));for(let e=1;e<i;e++)t.addCode(n.setLocal(`c`,n.i64_add(n.i64_mul(n.i64_load32_u(n.getLocal(`px`),4*e,0),n.getLocal(`y`)),n.i64_shr_u(n.getLocal(`c`),n.i64_const(32))))),t.addCode(n.i64_store32(n.getLocal(`pr`),e*4,0,n.getLocal(`c`)))}function v(){let t=e.addFunction(r+`__add1`);t.addParam(`x`,`i32`),t.addParam(`y`,`i64`),t.addLocal(`c`,`i64`),t.addLocal(`px`,`i32`);let n=t.getCodeBuilder();t.addCode(n.setLocal(`px`,n.getLocal(`x`))),t.addCode(n.setLocal(`c`,n.i64_add(n.i64_load32_u(n.getLocal(`px`),0,0),n.getLocal(`y`)))),t.addCode(n.i64_store32(n.getLocal(`px`),0,0,n.getLocal(`c`))),t.addCode(n.setLocal(`c`,n.i64_shr_u(n.getLocal(`c`),n.i64_const(32)))),t.addCode(n.block(n.loop(n.br_if(1,n.i64_eqz(n.getLocal(`c`))),n.setLocal(`px`,n.i32_add(n.getLocal(`px`),n.i32_const(4))),n.setLocal(`c`,n.i64_add(n.i64_load32_u(n.getLocal(`px`),0,0),n.getLocal(`c`))),n.i64_store32(n.getLocal(`px`),0,0,n.getLocal(`c`)),n.setLocal(`c`,n.i64_shr_u(n.getLocal(`c`),n.i64_const(32))),n.br(0))))}function y(){_(),v();let t=e.addFunction(r+`_div`);t.addParam(`x`,`i32`),t.addParam(`y`,`i32`),t.addParam(`c`,`i32`),t.addParam(`r`,`i32`),t.addLocal(`rr`,`i32`),t.addLocal(`cc`,`i32`),t.addLocal(`eX`,`i32`),t.addLocal(`eY`,`i32`),t.addLocal(`sy`,`i64`),t.addLocal(`sx`,`i64`),t.addLocal(`ec`,`i32`);let n=t.getCodeBuilder(),i=n.i32_const(e.alloc(a)),o=n.i32_const(e.alloc(a)),s=n.i32_const(e.alloc(a)),c=n.getLocal(`cc`),l=n.getLocal(`rr`),u=e.alloc(a*2),d=n.i32_const(u),f=n.i32_const(u+a);t.addCode(n.if(n.getLocal(`c`),n.setLocal(`cc`,n.getLocal(`c`)),n.setLocal(`cc`,o))),t.addCode(n.if(n.getLocal(`r`),n.setLocal(`rr`,n.getLocal(`r`)),n.setLocal(`rr`,s))),t.addCode(n.call(r+`_copy`,n.getLocal(`x`),l)),t.addCode(n.call(r+`_copy`,n.getLocal(`y`),i)),t.addCode(n.call(r+`_zero`,c)),t.addCode(n.call(r+`_zero`,d)),t.addCode(n.setLocal(`eX`,n.i32_const(a-1))),t.addCode(n.setLocal(`eY`,n.i32_const(a-1))),t.addCode(n.block(n.loop(n.br_if(1,n.i32_or(n.i32_load8_u(n.i32_add(i,n.getLocal(`eY`)),0,0),n.i32_eq(n.getLocal(`eY`),n.i32_const(3)))),n.setLocal(`eY`,n.i32_sub(n.getLocal(`eY`),n.i32_const(1))),n.br(0)))),t.addCode(n.setLocal(`sy`,n.i64_add(n.i64_load32_u(n.i32_sub(n.i32_add(i,n.getLocal(`eY`)),n.i32_const(3)),0,0),n.i64_const(1)))),t.addCode(n.if(n.i64_eq(n.getLocal(`sy`),n.i64_const(1)),n.drop(n.i64_div_u(n.i64_const(0),n.i64_const(0))))),t.addCode(n.block(n.loop(n.block(n.loop(n.br_if(1,n.i32_or(n.i32_load8_u(n.i32_add(l,n.getLocal(`eX`)),0,0),n.i32_eq(n.getLocal(`eX`),n.i32_const(7)))),n.setLocal(`eX`,n.i32_sub(n.getLocal(`eX`),n.i32_const(1))),n.br(0))),n.setLocal(`sx`,n.i64_load(n.i32_sub(n.i32_add(l,n.getLocal(`eX`)),n.i32_const(7)),0,0)),n.setLocal(`sx`,n.i64_div_u(n.getLocal(`sx`),n.getLocal(`sy`))),n.setLocal(`ec`,n.i32_sub(n.i32_sub(n.getLocal(`eX`),n.getLocal(`eY`)),n.i32_const(4))),n.block(n.loop(n.br_if(1,n.i32_and(n.i64_eqz(n.i64_and(n.getLocal(`sx`),n.i64_const(`0xFFFFFFFF00000000`))),n.i32_ge_s(n.getLocal(`ec`),n.i32_const(0)))),n.setLocal(`sx`,n.i64_shr_u(n.getLocal(`sx`),n.i64_const(8))),n.setLocal(`ec`,n.i32_add(n.getLocal(`ec`),n.i32_const(1))),n.br(0))),n.if(n.i64_eqz(n.getLocal(`sx`)),[...n.br_if(2,n.i32_eqz(n.call(r+`_gte`,l,i))),...n.setLocal(`sx`,n.i64_const(1)),...n.setLocal(`ec`,n.i32_const(0))]),n.call(r+`__mul1`,i,n.getLocal(`sx`),f),n.drop(n.call(r+`_sub`,l,n.i32_sub(f,n.getLocal(`ec`)),l)),n.call(r+`__add1`,n.i32_add(c,n.getLocal(`ec`)),n.getLocal(`sx`)),n.br(0))))}function b(){let t=e.addFunction(r+`_inverseMod`);t.addParam(`px`,`i32`),t.addParam(`pm`,`i32`),t.addParam(`pr`,`i32`),t.addLocal(`t`,`i32`),t.addLocal(`newt`,`i32`),t.addLocal(`r`,`i32`),t.addLocal(`qq`,`i32`),t.addLocal(`qr`,`i32`),t.addLocal(`newr`,`i32`),t.addLocal(`swp`,`i32`),t.addLocal(`x`,`i32`),t.addLocal(`signt`,`i32`),t.addLocal(`signnewt`,`i32`),t.addLocal(`signx`,`i32`);let n=t.getCodeBuilder(),i=n.i32_const(e.alloc(a)),o=n.i32_const(e.alloc(a)),s=n.i32_const(e.alloc(a)),c=n.i32_const(e.alloc(a)),l=n.i32_const(e.alloc(a)),u=n.i32_const(e.alloc(a)),d=n.i32_const(e.alloc(a*2)),f=n.i32_const(e.alloc(a));t.addCode(n.setLocal(`t`,i),n.call(r+`_zero`,i),n.setLocal(`signt`,n.i32_const(0))),t.addCode(n.setLocal(`r`,o),n.call(r+`_copy`,n.getLocal(`pm`),o)),t.addCode(n.setLocal(`newt`,s),n.call(r+`_one`,s),n.setLocal(`signnewt`,n.i32_const(0))),t.addCode(n.setLocal(`newr`,c),n.call(r+`_copy`,n.getLocal(`px`),c)),t.addCode(n.setLocal(`qq`,l)),t.addCode(n.setLocal(`qr`,u)),t.addCode(n.setLocal(`x`,f)),t.addCode(n.block(n.loop(n.br_if(1,n.call(r+`_isZero`,n.getLocal(`newr`))),n.call(r+`_div`,n.getLocal(`r`),n.getLocal(`newr`),n.getLocal(`qq`),n.getLocal(`qr`)),n.call(r+`_mul`,n.getLocal(`qq`),n.getLocal(`newt`),d),n.if(n.getLocal(`signt`),n.if(n.getLocal(`signnewt`),n.if(n.call(r+`_gte`,d,n.getLocal(`t`)),[...n.drop(n.call(r+`_sub`,d,n.getLocal(`t`),n.getLocal(`x`))),...n.setLocal(`signx`,n.i32_const(0))],[...n.drop(n.call(r+`_sub`,n.getLocal(`t`),d,n.getLocal(`x`))),...n.setLocal(`signx`,n.i32_const(1))]),[...n.drop(n.call(r+`_add`,d,n.getLocal(`t`),n.getLocal(`x`))),...n.setLocal(`signx`,n.i32_const(1))]),n.if(n.getLocal(`signnewt`),[...n.drop(n.call(r+`_add`,d,n.getLocal(`t`),n.getLocal(`x`))),...n.setLocal(`signx`,n.i32_const(0))],n.if(n.call(r+`_gte`,n.getLocal(`t`),d),[...n.drop(n.call(r+`_sub`,n.getLocal(`t`),d,n.getLocal(`x`))),...n.setLocal(`signx`,n.i32_const(0))],[...n.drop(n.call(r+`_sub`,d,n.getLocal(`t`),n.getLocal(`x`))),...n.setLocal(`signx`,n.i32_const(1))]))),n.setLocal(`swp`,n.getLocal(`t`)),n.setLocal(`t`,n.getLocal(`newt`)),n.setLocal(`newt`,n.getLocal(`x`)),n.setLocal(`x`,n.getLocal(`swp`)),n.setLocal(`signt`,n.getLocal(`signnewt`)),n.setLocal(`signnewt`,n.getLocal(`signx`)),n.setLocal(`swp`,n.getLocal(`r`)),n.setLocal(`r`,n.getLocal(`newr`)),n.setLocal(`newr`,n.getLocal(`qr`)),n.setLocal(`qr`,n.getLocal(`swp`)),n.br(0)))),t.addCode(n.if(n.getLocal(`signt`),n.drop(n.call(r+`_sub`,n.getLocal(`pm`),n.getLocal(`t`),n.getLocal(`pr`))),n.call(r+`_copy`,n.getLocal(`t`),n.getLocal(`pr`))))}return o(),s(),l(),c(),u(),d(),f(),p(),m(),h(),g(),y(),b(),e.exportFunction(r+`_copy`),e.exportFunction(r+`_zero`),e.exportFunction(r+`_one`),e.exportFunction(r+`_isZero`),e.exportFunction(r+`_eq`),e.exportFunction(r+`_gte`),e.exportFunction(r+`_add`),e.exportFunction(r+`_sub`),e.exportFunction(r+`_mul`),e.exportFunction(r+`_square`),e.exportFunction(r+`_squareOld`),e.exportFunction(r+`_div`),e.exportFunction(r+`_inverseMod`),r},yt=function(e,t,n,r,i,a,o){let s=e.addFunction(t);s.addParam(`base`,`i32`),s.addParam(`scalar`,`i32`),s.addParam(`scalarLength`,`i32`),s.addParam(`r`,`i32`),s.addLocal(`i`,`i32`),s.addLocal(`b`,`i32`);let c=s.getCodeBuilder(),l=c.i32_const(e.alloc(n));s.addCode(c.if(c.i32_eqz(c.getLocal(`scalarLength`)),[...c.call(o,c.getLocal(`r`)),...c.ret([])])),s.addCode(c.call(a,c.getLocal(`base`),l)),s.addCode(c.call(o,c.getLocal(`r`))),s.addCode(c.setLocal(`i`,c.getLocal(`scalarLength`))),s.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`)))),...u(),c.br_if(1,c.i32_eqz(c.getLocal(`i`))),c.br(0))));function u(){let e=[];for(let t=0;t<8;t++)e.push(...c.call(i,c.getLocal(`r`),c.getLocal(`r`)),...c.if(c.i32_ge_u(c.getLocal(`b`),c.i32_const(128>>t)),[...c.setLocal(`b`,c.i32_sub(c.getLocal(`b`),c.i32_const(128>>t))),...c.call(r,c.getLocal(`r`),l,c.getLocal(`r`))]));return e}},bt=xt;function xt(e,t){let n=e.modules[t].n64*8,r=e.addFunction(t+`_batchInverse`);r.addParam(`pIn`,`i32`),r.addParam(`inStep`,`i32`),r.addParam(`n`,`i32`),r.addParam(`pOut`,`i32`),r.addParam(`outStep`,`i32`),r.addLocal(`itAux`,`i32`),r.addLocal(`itIn`,`i32`),r.addLocal(`itOut`,`i32`),r.addLocal(`i`,`i32`);let i=r.getCodeBuilder(),a=i.i32_const(e.alloc(n));r.addCode(i.setLocal(`itAux`,i.i32_load(i.i32_const(0))),i.i32_store(i.i32_const(0),i.i32_add(i.getLocal(`itAux`),i.i32_mul(i.i32_add(i.getLocal(`n`),i.i32_const(1)),i.i32_const(n))))),r.addCode(i.call(t+`_one`,i.getLocal(`itAux`)),i.setLocal(`itIn`,i.getLocal(`pIn`)),i.setLocal(`itAux`,i.i32_add(i.getLocal(`itAux`),i.i32_const(n))),i.setLocal(`i`,i.i32_const(0)),i.block(i.loop(i.br_if(1,i.i32_eq(i.getLocal(`i`),i.getLocal(`n`))),i.if(i.call(t+`_isZero`,i.getLocal(`itIn`)),i.call(t+`_copy`,i.i32_sub(i.getLocal(`itAux`),i.i32_const(n)),i.getLocal(`itAux`)),i.call(t+`_mul`,i.getLocal(`itIn`),i.i32_sub(i.getLocal(`itAux`),i.i32_const(n)),i.getLocal(`itAux`))),i.setLocal(`itIn`,i.i32_add(i.getLocal(`itIn`),i.getLocal(`inStep`))),i.setLocal(`itAux`,i.i32_add(i.getLocal(`itAux`),i.i32_const(n))),i.setLocal(`i`,i.i32_add(i.getLocal(`i`),i.i32_const(1))),i.br(0))),i.setLocal(`itIn`,i.i32_sub(i.getLocal(`itIn`),i.getLocal(`inStep`))),i.setLocal(`itAux`,i.i32_sub(i.getLocal(`itAux`),i.i32_const(n))),i.setLocal(`itOut`,i.i32_add(i.getLocal(`pOut`),i.i32_mul(i.i32_sub(i.getLocal(`n`),i.i32_const(1)),i.getLocal(`outStep`)))),i.call(t+`_inverse`,i.getLocal(`itAux`),i.getLocal(`itAux`)),i.block(i.loop(i.br_if(1,i.i32_eqz(i.getLocal(`i`))),i.if(i.call(t+`_isZero`,i.getLocal(`itIn`)),[...i.call(t+`_copy`,i.getLocal(`itAux`),i.i32_sub(i.getLocal(`itAux`),i.i32_const(n))),...i.call(t+`_zero`,i.getLocal(`itOut`))],[...i.call(t+`_copy`,i.i32_sub(i.getLocal(`itAux`),i.i32_const(n)),a),...i.call(t+`_mul`,i.getLocal(`itAux`),i.getLocal(`itIn`),i.i32_sub(i.getLocal(`itAux`),i.i32_const(n))),...i.call(t+`_mul`,i.getLocal(`itAux`),a,i.getLocal(`itOut`))]),i.setLocal(`itIn`,i.i32_sub(i.getLocal(`itIn`),i.getLocal(`inStep`))),i.setLocal(`itOut`,i.i32_sub(i.getLocal(`itOut`),i.getLocal(`outStep`))),i.setLocal(`itAux`,i.i32_sub(i.getLocal(`itAux`),i.i32_const(n))),i.setLocal(`i`,i.i32_sub(i.getLocal(`i`),i.i32_const(1))),i.br(0)))),r.addCode(i.i32_store(i.i32_const(0),i.getLocal(`itAux`)))}var St=Ct;function Ct(e,t,n,r,i,a){a===void 0&&(a=r<i);let o=e.addFunction(t);o.addParam(`pIn`,`i32`),o.addParam(`n`,`i32`),o.addParam(`pOut`,`i32`),o.addLocal(`i`,`i32`),o.addLocal(`itIn`,`i32`),o.addLocal(`itOut`,`i32`);let s=o.getCodeBuilder();a?o.addCode(s.setLocal(`itIn`,s.i32_add(s.getLocal(`pIn`),s.i32_mul(s.i32_sub(s.getLocal(`n`),s.i32_const(1)),s.i32_const(r)))),s.setLocal(`itOut`,s.i32_add(s.getLocal(`pOut`),s.i32_mul(s.i32_sub(s.getLocal(`n`),s.i32_const(1)),s.i32_const(i)))),s.setLocal(`i`,s.i32_const(0)),s.block(s.loop(s.br_if(1,s.i32_eq(s.getLocal(`i`),s.getLocal(`n`))),s.call(n,s.getLocal(`itIn`),s.getLocal(`itOut`)),s.setLocal(`itIn`,s.i32_sub(s.getLocal(`itIn`),s.i32_const(r))),s.setLocal(`itOut`,s.i32_sub(s.getLocal(`itOut`),s.i32_const(i))),s.setLocal(`i`,s.i32_add(s.getLocal(`i`),s.i32_const(1))),s.br(0)))):o.addCode(s.setLocal(`itIn`,s.getLocal(`pIn`)),s.setLocal(`itOut`,s.getLocal(`pOut`)),s.setLocal(`i`,s.i32_const(0)),s.block(s.loop(s.br_if(1,s.i32_eq(s.getLocal(`i`),s.getLocal(`n`))),s.call(n,s.getLocal(`itIn`),s.getLocal(`itOut`)),s.setLocal(`itIn`,s.i32_add(s.getLocal(`itIn`),s.i32_const(r))),s.setLocal(`itOut`,s.i32_add(s.getLocal(`itOut`),s.i32_const(i))),s.setLocal(`i`,s.i32_add(s.getLocal(`i`),s.i32_const(1))),s.br(0))))}var wt=Tt;function Tt(e,t,n,r,i,a){a===void 0&&(a=r<i);let o=e.addFunction(t);o.addParam(`pIn1`,`i32`),o.addParam(`pIn2`,`i32`),o.addParam(`n`,`i32`),o.addParam(`pOut`,`i32`),o.addLocal(`i`,`i32`),o.addLocal(`itIn1`,`i32`),o.addLocal(`itIn2`,`i32`),o.addLocal(`itOut`,`i32`);let s=o.getCodeBuilder();a?o.addCode(s.setLocal(`itIn1`,s.i32_add(s.getLocal(`pIn1`),s.i32_mul(s.i32_sub(s.getLocal(`n`),s.i32_const(1)),s.i32_const(r)))),s.setLocal(`itIn2`,s.i32_add(s.getLocal(`pIn2`),s.i32_mul(s.i32_sub(s.getLocal(`n`),s.i32_const(1)),s.i32_const(r)))),s.setLocal(`itOut`,s.i32_add(s.getLocal(`pOut`),s.i32_mul(s.i32_sub(s.getLocal(`n`),s.i32_const(1)),s.i32_const(i)))),s.setLocal(`i`,s.i32_const(0)),s.block(s.loop(s.br_if(1,s.i32_eq(s.getLocal(`i`),s.getLocal(`n`))),s.call(n,s.getLocal(`itIn1`),s.getLocal(`itIn2`),s.getLocal(`itOut`)),s.setLocal(`itIn1`,s.i32_sub(s.getLocal(`itIn1`),s.i32_const(r))),s.setLocal(`itIn2`,s.i32_sub(s.getLocal(`itIn2`),s.i32_const(r))),s.setLocal(`itOut`,s.i32_sub(s.getLocal(`itOut`),s.i32_const(i))),s.setLocal(`i`,s.i32_add(s.getLocal(`i`),s.i32_const(1))),s.br(0)))):o.addCode(s.setLocal(`itIn1`,s.getLocal(`pIn1`)),s.setLocal(`itIn2`,s.getLocal(`pIn2`)),s.setLocal(`itOut`,s.getLocal(`pOut`)),s.setLocal(`i`,s.i32_const(0)),s.block(s.loop(s.br_if(1,s.i32_eq(s.getLocal(`i`),s.getLocal(`n`))),s.call(n,s.getLocal(`itIn1`),s.getLocal(`itIn2`),s.getLocal(`itOut`)),s.setLocal(`itIn1`,s.i32_add(s.getLocal(`itIn1`),s.i32_const(r))),s.setLocal(`itIn2`,s.i32_add(s.getLocal(`itIn2`),s.i32_const(r))),s.setLocal(`itOut`,s.i32_add(s.getLocal(`itOut`),s.i32_const(i))),s.setLocal(`i`,s.i32_add(s.getLocal(`i`),s.i32_const(1))),s.br(0))))}var Et={};function Dt(e,t){return e===t?0:e>t?1:-1}function Ot(e){return e*e}function kt(e){return e%2n!=0n}function At(e){return e%2n==0n}function jt(e){return e<0n}function Mt(e){return e>0n}function Nt(e){return jt(e)?e.toString(2).length-1:e.toString(2).length}function Pt(e){return e<0n?-e:e}function Ft(e){return Pt(e)===1n}function It(e,t){for(var n=0n,r=1n,i=t,a=Pt(e),o,s,c;a!==0n;)o=i/a,s=n,c=i,n=r,i=a,r=s-o*r,a=c-o*a;if(!Ft(i))throw Error(e.toString()+` and `+t.toString()+` are not co-prime`);return Dt(n,0n)===-1&&(n+=t),jt(e)?-n:n}function Lt(e,t,n){if(n===0n)throw Error(`Cannot take modPow with modulus 0`);var r=1n,i=e%n;for(jt(t)&&(t*=-1n,i=It(i,n));Mt(t);){if(i===0n)return 0n;kt(t)&&(r=r*i%n),t/=2n,i=Ot(i)%n}return r}function Rt(e,t){return e=e>=0n?e:-e,t=t>=0n?t:-t,e===t?0:e>t?1:-1}function zt(e,t){return t===0n?!1:Ft(t)?!0:Rt(t,2n)===0?At(e):e%t===0n}function Bt(e){var t=Pt(e);if(Ft(t))return!1;if(t===2n||t===3n||t===5n)return!0;if(At(t)||zt(t,3n)||zt(t,5n))return!1;if(t<49n)return!0}function Vt(e){return e-1n}function Ht(e,t){for(var n=Vt(e),r=n,i=0,a,o,s;At(r);)r/=2n,i++;next:for(o=0;o<t.length;o++)if(!(e<t[o])&&(s=Lt(BigInt(t[o]),r,e),!(Ft(s)||s===n))){for(a=i-1;a!=0;a--){if(s=Ot(s)%e,Ft(s))return!1;if(s===n)continue next}return!1}return!0}function Ut(e){var t=Bt(e);if(t!==void 0)return t;var n=Pt(e),r=Nt(n);if(r<=64)return Ht(n,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var i=Math.log(2)*Number(r),a=Math.ceil(i),o=[],s=0;s<a;s++)o.push(BigInt(s+2));return Ht(n,o)}Et.bitLength=Nt,Et.isOdd=kt,Et.isNegative=jt,Et.abs=Pt,Et.isUnit=Ft,Et.compare=Dt,Et.modInv=It,Et.modPow=Lt,Et.isPrime=Ut,Et.square=Ot;const Wt=vt,Gt=_t,Kt=yt,qt=bt,Jt=St,Yt=wt,{bitLength:Xt,modInv:Zt,modPow:Qt,isPrime:$t,isOdd:en,square:tn}=Et;var nn=function(e,t,n,r){let i=BigInt(t),a=Math.floor((Xt(i-1n)-1)/64)+1,o=a*2,s=a*8,c=n||`f1m`;if(e.modules[c])return c;let l=Wt(e,a,r),u=e.alloc(s,Gt.bigInt2BytesLE(i,s)),d=e.alloc(Gt.bigInt2BytesLE(tn(1n<<BigInt(a*64))%i,s)),f=e.alloc(Gt.bigInt2BytesLE((1n<<BigInt(a*64))%i,s)),p=e.alloc(Gt.bigInt2BytesLE(0n,s)),m=i-1n,h=m>>1n,g=e.alloc(s,Gt.bigInt2BytesLE(h,s)),_=h+1n,v=e.alloc(s,Gt.bigInt2BytesLE(_,s));e.modules[c]={pq:u,pR2:d,n64:a,q:i,pOne:f,pZero:p,pePlusOne:v};function y(){let t=e.addFunction(c+`_one`);t.addParam(`pr`,`i32`);let n=t.getCodeBuilder();t.addCode(n.call(l+`_copy`,n.i32_const(f),n.getLocal(`pr`)))}function b(){let t=e.addFunction(c+`_add`);t.addParam(`x`,`i32`),t.addParam(`y`,`i32`),t.addParam(`r`,`i32`);let n=t.getCodeBuilder();t.addCode(n.if(n.call(l+`_add`,n.getLocal(`x`),n.getLocal(`y`),n.getLocal(`r`)),n.drop(n.call(l+`_sub`,n.getLocal(`r`),n.i32_const(u),n.getLocal(`r`))),n.if(n.call(l+`_gte`,n.getLocal(`r`),n.i32_const(u)),n.drop(n.call(l+`_sub`,n.getLocal(`r`),n.i32_const(u),n.getLocal(`r`))))))}function x(){let t=e.addFunction(c+`_sub`);t.addParam(`x`,`i32`),t.addParam(`y`,`i32`),t.addParam(`r`,`i32`);let n=t.getCodeBuilder();t.addCode(n.if(n.call(l+`_sub`,n.getLocal(`x`),n.getLocal(`y`),n.getLocal(`r`)),n.drop(n.call(l+`_add`,n.getLocal(`r`),n.i32_const(u),n.getLocal(`r`)))))}function S(){let t=e.addFunction(c+`_neg`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let n=t.getCodeBuilder();t.addCode(n.call(c+`_sub`,n.i32_const(p),n.getLocal(`x`),n.getLocal(`r`)))}function C(){let t=e.addFunction(c+`_isNegative`);t.addParam(`x`,`i32`),t.setReturnType(`i32`);let n=t.getCodeBuilder(),r=n.i32_const(e.alloc(s));t.addCode(n.call(c+`_fromMontgomery`,n.getLocal(`x`),r),n.call(l+`_gte`,r,n.i32_const(v)))}function w(){let t=e.addFunction(c+`_sign`);t.addParam(`x`,`i32`),t.setReturnType(`i32`);let n=t.getCodeBuilder(),r=n.i32_const(e.alloc(s));t.addCode(n.if(n.call(l+`_isZero`,n.getLocal(`x`)),n.ret(n.i32_const(0))),n.call(c+`_fromMontgomery`,n.getLocal(`x`),r),n.if(n.call(l+`_gte`,r,n.i32_const(v)),n.ret(n.i32_const(-1))),n.ret(n.i32_const(1)))}function T(){let t=e.alloc(o*o*8),n=e.addFunction(c+`_mReduct`);n.addParam(`t`,`i32`),n.addParam(`r`,`i32`),n.addLocal(`np32`,`i64`),n.addLocal(`c`,`i64`),n.addLocal(`m`,`i64`);let r=n.getCodeBuilder(),a=Number(4294967296n-Zt(i,4294967296n));n.addCode(r.setLocal(`np32`,r.i64_const(a)));for(let e=0;e<o;e++){n.addCode(r.setLocal(`c`,r.i64_const(0))),n.addCode(r.setLocal(`m`,r.i64_and(r.i64_mul(r.i64_load32_u(r.getLocal(`t`),e*4),r.getLocal(`np32`)),r.i64_const(`0xFFFFFFFF`))));for(let t=0;t<o;t++)n.addCode(r.setLocal(`c`,r.i64_add(r.i64_add(r.i64_load32_u(r.getLocal(`t`),(e+t)*4),r.i64_shr_u(r.getLocal(`c`),r.i64_const(32))),r.i64_mul(r.i64_load32_u(r.i32_const(u),t*4),r.getLocal(`m`))))),n.addCode(r.i64_store32(r.getLocal(`t`),(e+t)*4,r.getLocal(`c`)));n.addCode(r.i64_store32(r.i32_const(t),e*4,r.i64_shr_u(r.getLocal(`c`),r.i64_const(32))))}n.addCode(r.call(c+`_add`,r.i32_const(t),r.i32_add(r.getLocal(`t`),r.i32_const(o*4)),r.getLocal(`r`)))}function E(){let t=e.addFunction(c+`_mul`);t.addParam(`x`,`i32`),t.addParam(`y`,`i32`),t.addParam(`r`,`i32`),t.addLocal(`c0`,`i64`),t.addLocal(`c1`,`i64`),t.addLocal(`np32`,`i64`);for(let e=0;e<o;e++)t.addLocal(`x`+e,`i64`),t.addLocal(`y`+e,`i64`),t.addLocal(`m`+e,`i64`),t.addLocal(`q`+e,`i64`);let n=t.getCodeBuilder(),r=Number(4294967296n-Zt(i,4294967296n));t.addCode(n.setLocal(`np32`,n.i64_const(r)));let a=[],s=[],d=[];function f(e,t){let r,i;return a[e]?r=n.getLocal(`x`+e):(r=n.teeLocal(`x`+e,n.i64_load32_u(n.getLocal(`x`),e*4)),a[e]=!0),s[t]?i=n.getLocal(`y`+t):(i=n.teeLocal(`y`+t,n.i64_load32_u(n.getLocal(`y`),t*4)),s[t]=!0),n.i64_mul(r,i)}function p(e,t){let r,i;return d[e]?r=n.getLocal(`q`+e):(r=n.teeLocal(`q`+e,n.i64_load32_u(n.i32_const(0),u+e*4)),d[e]=!0),i=n.getLocal(`m`+t),n.i64_mul(r,i)}let m=`c0`,h=`c1`;for(let e=0;e<o*2-1;e++){for(let r=Math.max(0,e-o+1);r<=e&&r<o;r++){let i=e-r;t.addCode(n.setLocal(m,n.i64_add(n.i64_and(n.getLocal(m),n.i64_const(4294967295)),f(r,i)))),t.addCode(n.setLocal(h,n.i64_add(n.getLocal(h),n.i64_shr_u(n.getLocal(m),n.i64_const(32)))))}for(let r=Math.max(1,e-o+1);r<=e&&r<o;r++){let i=e-r;t.addCode(n.setLocal(m,n.i64_add(n.i64_and(n.getLocal(m),n.i64_const(4294967295)),p(r,i)))),t.addCode(n.setLocal(h,n.i64_add(n.getLocal(h),n.i64_shr_u(n.getLocal(m),n.i64_const(32)))))}e<o&&(t.addCode(n.setLocal(`m`+e,n.i64_and(n.i64_mul(n.i64_and(n.getLocal(m),n.i64_const(4294967295)),n.getLocal(`np32`)),n.i64_const(`0xFFFFFFFF`)))),t.addCode(n.setLocal(m,n.i64_add(n.i64_and(n.getLocal(m),n.i64_const(4294967295)),p(0,e)))),t.addCode(n.setLocal(h,n.i64_add(n.getLocal(h),n.i64_shr_u(n.getLocal(m),n.i64_const(32)))))),e>=o&&t.addCode(n.i64_store32(n.getLocal(`r`),(e-o)*4,n.getLocal(m))),[m,h]=[h,m],t.addCode(n.setLocal(h,n.i64_shr_u(n.getLocal(m),n.i64_const(32))))}t.addCode(n.i64_store32(n.getLocal(`r`),o*4-4,n.getLocal(m))),t.addCode(n.if(n.i32_wrap_i64(n.getLocal(h)),n.drop(n.call(l+`_sub`,n.getLocal(`r`),n.i32_const(u),n.getLocal(`r`))),n.if(n.call(l+`_gte`,n.getLocal(`r`),n.i32_const(u)),n.drop(n.call(l+`_sub`,n.getLocal(`r`),n.i32_const(u),n.getLocal(`r`))))))}function D(){let t=e.addFunction(c+`_square`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`),t.addLocal(`c0`,`i64`),t.addLocal(`c1`,`i64`),t.addLocal(`c0_old`,`i64`),t.addLocal(`c1_old`,`i64`),t.addLocal(`np32`,`i64`);for(let e=0;e<o;e++)t.addLocal(`x`+e,`i64`),t.addLocal(`m`+e,`i64`),t.addLocal(`q`+e,`i64`);let n=t.getCodeBuilder(),r=Number(4294967296n-Zt(i,4294967296n));t.addCode(n.setLocal(`np32`,n.i64_const(r)));let a=[],s=[];function d(e,t){let r,i;return a[e]?r=n.getLocal(`x`+e):(r=n.teeLocal(`x`+e,n.i64_load32_u(n.getLocal(`x`),e*4)),a[e]=!0),a[t]?i=n.getLocal(`x`+t):(i=n.teeLocal(`x`+t,n.i64_load32_u(n.getLocal(`x`),t*4)),a[t]=!0),n.i64_mul(r,i)}function f(e,t){let r,i;return s[e]?r=n.getLocal(`q`+e):(r=n.teeLocal(`q`+e,n.i64_load32_u(n.i32_const(0),u+e*4)),s[e]=!0),i=n.getLocal(`m`+t),n.i64_mul(r,i)}let p=`c0_old`,m=`c1_old`;for(let e=0;e<o*2-1;e++){t.addCode(n.setLocal(`c0`,n.i64_const(0)),n.setLocal(`c1`,n.i64_const(0)));for(let r=Math.max(0,e-o+1);r<e+1>>1&&r<o;r++){let i=e-r;t.addCode(n.setLocal(`c0`,n.i64_add(n.i64_and(n.getLocal(`c0`),n.i64_const(4294967295)),d(r,i)))),t.addCode(n.setLocal(`c1`,n.i64_add(n.getLocal(`c1`),n.i64_shr_u(n.getLocal(`c0`),n.i64_const(32)))))}t.addCode(n.setLocal(`c0`,n.i64_shl(n.i64_and(n.getLocal(`c0`),n.i64_const(4294967295)),n.i64_const(1)))),t.addCode(n.setLocal(`c1`,n.i64_add(n.i64_shl(n.getLocal(`c1`),n.i64_const(1)),n.i64_shr_u(n.getLocal(`c0`),n.i64_const(32))))),e%2==0&&(t.addCode(n.setLocal(`c0`,n.i64_add(n.i64_and(n.getLocal(`c0`),n.i64_const(4294967295)),d(e>>1,e>>1)))),t.addCode(n.setLocal(`c1`,n.i64_add(n.getLocal(`c1`),n.i64_shr_u(n.getLocal(`c0`),n.i64_const(32)))))),e>0&&(t.addCode(n.setLocal(`c0`,n.i64_add(n.i64_and(n.getLocal(`c0`),n.i64_const(4294967295)),n.i64_and(n.getLocal(p),n.i64_const(4294967295))))),t.addCode(n.setLocal(`c1`,n.i64_add(n.i64_add(n.getLocal(`c1`),n.i64_shr_u(n.getLocal(`c0`),n.i64_const(32))),n.getLocal(m)))));for(let r=Math.max(1,e-o+1);r<=e&&r<o;r++){let i=e-r;t.addCode(n.setLocal(`c0`,n.i64_add(n.i64_and(n.getLocal(`c0`),n.i64_const(4294967295)),f(r,i)))),t.addCode(n.setLocal(`c1`,n.i64_add(n.getLocal(`c1`),n.i64_shr_u(n.getLocal(`c0`),n.i64_const(32)))))}e<o&&(t.addCode(n.setLocal(`m`+e,n.i64_and(n.i64_mul(n.i64_and(n.getLocal(`c0`),n.i64_const(4294967295)),n.getLocal(`np32`)),n.i64_const(`0xFFFFFFFF`)))),t.addCode(n.setLocal(`c0`,n.i64_add(n.i64_and(n.getLocal(`c0`),n.i64_const(4294967295)),f(0,e)))),t.addCode(n.setLocal(`c1`,n.i64_add(n.getLocal(`c1`),n.i64_shr_u(n.getLocal(`c0`),n.i64_const(32)))))),e>=o&&t.addCode(n.i64_store32(n.getLocal(`r`),(e-o)*4,n.getLocal(`c0`))),t.addCode(n.setLocal(p,n.getLocal(`c1`)),n.setLocal(m,n.i64_shr_u(n.getLocal(p),n.i64_const(32))))}t.addCode(n.i64_store32(n.getLocal(`r`),o*4-4,n.getLocal(p))),t.addCode(n.if(n.i32_wrap_i64(n.getLocal(m)),n.drop(n.call(l+`_sub`,n.getLocal(`r`),n.i32_const(u),n.getLocal(`r`))),n.if(n.call(l+`_gte`,n.getLocal(`r`),n.i32_const(u)),n.drop(n.call(l+`_sub`,n.getLocal(`r`),n.i32_const(u),n.getLocal(`r`))))))}function O(){let t=e.addFunction(c+`_squareOld`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let n=t.getCodeBuilder();t.addCode(n.call(c+`_mul`,n.getLocal(`x`),n.getLocal(`x`),n.getLocal(`r`)))}function k(){let t=e.addFunction(c+`_toMontgomery`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let n=t.getCodeBuilder();t.addCode(n.call(c+`_mul`,n.getLocal(`x`),n.i32_const(d),n.getLocal(`r`)))}function A(){let t=e.alloc(s*2),n=e.addFunction(c+`_fromMontgomery`);n.addParam(`x`,`i32`),n.addParam(`r`,`i32`);let r=n.getCodeBuilder();n.addCode(r.call(l+`_copy`,r.getLocal(`x`),r.i32_const(t))),n.addCode(r.call(l+`_zero`,r.i32_const(t+s))),n.addCode(r.call(c+`_mReduct`,r.i32_const(t),r.getLocal(`r`)))}function j(){let t=e.addFunction(c+`_inverse`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let n=t.getCodeBuilder();t.addCode(n.call(c+`_fromMontgomery`,n.getLocal(`x`),n.getLocal(`r`))),t.addCode(n.call(l+`_inverseMod`,n.getLocal(`r`),n.i32_const(u),n.getLocal(`r`))),t.addCode(n.call(c+`_toMontgomery`,n.getLocal(`r`),n.getLocal(`r`)))}let ee=2n;if($t(i))for(;Qt(ee,h,i)!==m;)ee+=1n;let M=0,N=m;for(;!en(N)&&N!==0n;)M++,N>>=1n;let P=e.alloc(s,Gt.bigInt2BytesLE(N,s)),F=Qt(ee,N,i),te=e.alloc(Gt.bigInt2BytesLE((F<<BigInt(a*64))%i,s)),I=N+1n>>1n,L=e.alloc(s,Gt.bigInt2BytesLE(I,s));function ne(){let t=e.addFunction(c+`_sqrt`);t.addParam(`n`,`i32`),t.addParam(`r`,`i32`),t.addLocal(`m`,`i32`),t.addLocal(`i`,`i32`),t.addLocal(`j`,`i32`);let n=t.getCodeBuilder(),r=n.i32_const(f),i=n.i32_const(e.alloc(s)),a=n.i32_const(e.alloc(s)),o=n.i32_const(e.alloc(s)),l=n.i32_const(e.alloc(s)),u=n.i32_const(e.alloc(s));t.addCode(n.if(n.call(c+`_isZero`,n.getLocal(`n`)),n.ret(n.call(c+`_zero`,n.getLocal(`r`)))),n.setLocal(`m`,n.i32_const(M)),n.call(c+`_copy`,n.i32_const(te),i),n.call(c+`_exp`,n.getLocal(`n`),n.i32_const(P),n.i32_const(s),a),n.call(c+`_exp`,n.getLocal(`n`),n.i32_const(L),n.i32_const(s),o),n.block(n.loop(n.br_if(1,n.call(c+`_eq`,a,r)),n.call(c+`_square`,a,l),n.setLocal(`i`,n.i32_const(1)),n.block(n.loop(n.br_if(1,n.call(c+`_eq`,l,r)),n.call(c+`_square`,l,l),n.setLocal(`i`,n.i32_add(n.getLocal(`i`),n.i32_const(1))),n.br(0))),n.call(c+`_copy`,i,u),n.setLocal(`j`,n.i32_sub(n.i32_sub(n.getLocal(`m`),n.getLocal(`i`)),n.i32_const(1))),n.block(n.loop(n.br_if(1,n.i32_eqz(n.getLocal(`j`))),n.call(c+`_square`,u,u),n.setLocal(`j`,n.i32_sub(n.getLocal(`j`),n.i32_const(1))),n.br(0))),n.setLocal(`m`,n.getLocal(`i`)),n.call(c+`_square`,u,i),n.call(c+`_mul`,a,i,a),n.call(c+`_mul`,o,u,o),n.br(0))),n.if(n.call(c+`_isNegative`,o),n.call(c+`_neg`,o,n.getLocal(`r`)),n.call(c+`_copy`,o,n.getLocal(`r`))))}function re(){let t=e.addFunction(c+`_isSquare`);t.addParam(`n`,`i32`),t.setReturnType(`i32`);let n=t.getCodeBuilder(),r=n.i32_const(f),i=n.i32_const(e.alloc(s));t.addCode(n.if(n.call(c+`_isZero`,n.getLocal(`n`)),n.ret(n.i32_const(1))),n.call(c+`_exp`,n.getLocal(`n`),n.i32_const(g),n.i32_const(s),i),n.call(c+`_eq`,i,r))}function ie(){let t=e.addFunction(c+`_load`);t.addParam(`scalar`,`i32`),t.addParam(`scalarLen`,`i32`),t.addParam(`r`,`i32`),t.addLocal(`p`,`i32`),t.addLocal(`l`,`i32`),t.addLocal(`i`,`i32`),t.addLocal(`j`,`i32`);let n=t.getCodeBuilder(),r=n.i32_const(e.alloc(s)),i=e.alloc(s),a=n.i32_const(i);t.addCode(n.call(l+`_zero`,n.getLocal(`r`)),n.setLocal(`i`,n.i32_const(s)),n.setLocal(`p`,n.getLocal(`scalar`)),n.block(n.loop(n.br_if(1,n.i32_gt_u(n.getLocal(`i`),n.getLocal(`scalarLen`))),n.if(n.i32_eq(n.getLocal(`i`),n.i32_const(s)),n.call(c+`_one`,r),n.call(c+`_mul`,r,n.i32_const(d),r)),n.call(c+`_mul`,n.getLocal(`p`),r,a),n.call(c+`_add`,n.getLocal(`r`),a,n.getLocal(`r`)),n.setLocal(`p`,n.i32_add(n.getLocal(`p`),n.i32_const(s))),n.setLocal(`i`,n.i32_add(n.getLocal(`i`),n.i32_const(s))),n.br(0))),n.setLocal(`l`,n.i32_rem_u(n.getLocal(`scalarLen`),n.i32_const(s))),n.if(n.i32_eqz(n.getLocal(`l`)),n.ret([])),n.call(l+`_zero`,a),n.setLocal(`j`,n.i32_const(0)),n.block(n.loop(n.br_if(1,n.i32_eq(n.getLocal(`j`),n.getLocal(`l`))),n.i32_store8(n.getLocal(`j`),i,n.i32_load8_u(n.getLocal(`p`))),n.setLocal(`p`,n.i32_add(n.getLocal(`p`),n.i32_const(1))),n.setLocal(`j`,n.i32_add(n.getLocal(`j`),n.i32_const(1))),n.br(0))),n.if(n.i32_eq(n.getLocal(`i`),n.i32_const(s)),n.call(c+`_one`,r),n.call(c+`_mul`,r,n.i32_const(d),r)),n.call(c+`_mul`,a,r,a),n.call(c+`_add`,n.getLocal(`r`),a,n.getLocal(`r`)))}function R(){let t=e.addFunction(c+`_timesScalar`);t.addParam(`x`,`i32`),t.addParam(`scalar`,`i32`),t.addParam(`scalarLen`,`i32`),t.addParam(`r`,`i32`);let n=t.getCodeBuilder(),r=n.i32_const(e.alloc(s));t.addCode(n.call(c+`_load`,n.getLocal(`scalar`),n.getLocal(`scalarLen`),r),n.call(c+`_toMontgomery`,r,r),n.call(c+`_mul`,n.getLocal(`x`),r,n.getLocal(`r`)))}function ae(){let t=e.addFunction(c+`_isOne`);t.addParam(`x`,`i32`),t.setReturnType(`i32`);let n=t.getCodeBuilder();t.addCode(n.ret(n.call(l+`_eq`,n.getLocal(`x`),n.i32_const(f))))}return e.exportFunction(l+`_copy`,c+`_copy`),e.exportFunction(l+`_zero`,c+`_zero`),e.exportFunction(l+`_isZero`,c+`_isZero`),e.exportFunction(l+`_eq`,c+`_eq`),ae(),b(),x(),S(),T(),E(),D(),O(),k(),A(),C(),w(),j(),y(),ie(),R(),qt(e,c),Jt(e,c+`_batchToMontgomery`,c+`_toMontgomery`,s,s),Jt(e,c+`_batchFromMontgomery`,c+`_fromMontgomery`,s,s),Jt(e,c+`_batchNeg`,c+`_neg`,s,s),Yt(e,c+`_batchAdd`,c+`_add`,s,s),Yt(e,c+`_batchSub`,c+`_sub`,s,s),Yt(e,c+`_batchMul`,c+`_mul`,s,s),e.exportFunction(c+`_add`),e.exportFunction(c+`_sub`),e.exportFunction(c+`_neg`),e.exportFunction(c+`_isNegative`),e.exportFunction(c+`_isOne`),e.exportFunction(c+`_sign`),e.exportFunction(c+`_mReduct`),e.exportFunction(c+`_mul`),e.exportFunction(c+`_square`),e.exportFunction(c+`_squareOld`),e.exportFunction(c+`_fromMontgomery`),e.exportFunction(c+`_toMontgomery`),e.exportFunction(c+`_inverse`),e.exportFunction(c+`_one`),e.exportFunction(c+`_load`),e.exportFunction(c+`_timesScalar`),Kt(e,c+`_exp`,s,c+`_mul`,c+`_square`,l+`_copy`,c+`_one`),e.exportFunction(c+`_exp`),e.exportFunction(c+`_batchInverse`),$t(i)&&(ne(),re(),e.exportFunction(c+`_sqrt`),e.exportFunction(c+`_isSquare`)),e.exportFunction(c+`_batchToMontgomery`),e.exportFunction(c+`_batchFromMontgomery`),c};const rn=nn,{bitLength:an}=Et;var on=function(e,t,n,r,i){let a=BigInt(t),o=Math.floor((an(a-1n)-1)/64)+1,s=o*8,c=n||`f1`;if(e.modules[c])return c;e.modules[c]={n64:o};let l=i||`int`,u=rn(e,a,r,l),d=e.modules[u].pR2,f=e.modules[u].pq,p=e.modules[u].pePlusOne;function m(){let t=e.alloc(s),n=e.addFunction(c+`_mul`);n.addParam(`x`,`i32`),n.addParam(`y`,`i32`),n.addParam(`r`,`i32`);let r=n.getCodeBuilder();n.addCode(r.call(u+`_mul`,r.getLocal(`x`),r.getLocal(`y`),r.i32_const(t))),n.addCode(r.call(u+`_mul`,r.i32_const(t),r.i32_const(d),r.getLocal(`r`)))}function h(){let t=e.addFunction(c+`_square`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let n=t.getCodeBuilder();t.addCode(n.call(c+`_mul`,n.getLocal(`x`),n.getLocal(`x`),n.getLocal(`r`)))}function g(){let t=e.addFunction(c+`_inverse`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let n=t.getCodeBuilder();t.addCode(n.call(l+`_inverseMod`,n.getLocal(`x`),n.i32_const(f),n.getLocal(`r`)))}function _(){let t=e.addFunction(c+`_isNegative`);t.addParam(`x`,`i32`),t.setReturnType(`i32`);let n=t.getCodeBuilder();t.addCode(n.call(l+`_gte`,n.getLocal(`x`),n.i32_const(p)))}return m(),h(),g(),_(),e.exportFunction(u+`_add`,c+`_add`),e.exportFunction(u+`_sub`,c+`_sub`),e.exportFunction(u+`_neg`,c+`_neg`),e.exportFunction(c+`_mul`),e.exportFunction(c+`_square`),e.exportFunction(c+`_inverse`),e.exportFunction(c+`_isNegative`),e.exportFunction(u+`_copy`,c+`_copy`),e.exportFunction(u+`_zero`,c+`_zero`),e.exportFunction(u+`_one`,c+`_one`),e.exportFunction(u+`_isZero`,c+`_isZero`),e.exportFunction(u+`_eq`,c+`_eq`),c};const sn=yt,cn=bt,ln=_t;var un=function(e,t,n,r){if(e.modules[n])return n;let i=e.modules[r].n64*8,a=e.modules[r].q;e.modules[n]={n64:e.modules[r].n64*2};function o(){let t=e.addFunction(n+`_add`);t.addParam(`x`,`i32`),t.addParam(`y`,`i32`),t.addParam(`r`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.getLocal(`y`),l=a.i32_add(a.getLocal(`y`),a.i32_const(i)),u=a.getLocal(`r`),d=a.i32_add(a.getLocal(`r`),a.i32_const(i));t.addCode(a.call(r+`_add`,o,c,u),a.call(r+`_add`,s,l,d))}function s(){let t=e.addFunction(n+`_timesScalar`);t.addParam(`x`,`i32`),t.addParam(`scalar`,`i32`),t.addParam(`scalarLen`,`i32`),t.addParam(`r`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.getLocal(`r`),l=a.i32_add(a.getLocal(`r`),a.i32_const(i));t.addCode(a.call(r+`_timesScalar`,o,a.getLocal(`scalar`),a.getLocal(`scalarLen`),c),a.call(r+`_timesScalar`,s,a.getLocal(`scalar`),a.getLocal(`scalarLen`),l))}function c(){let t=e.addFunction(n+`_sub`);t.addParam(`x`,`i32`),t.addParam(`y`,`i32`),t.addParam(`r`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.getLocal(`y`),l=a.i32_add(a.getLocal(`y`),a.i32_const(i)),u=a.getLocal(`r`),d=a.i32_add(a.getLocal(`r`),a.i32_const(i));t.addCode(a.call(r+`_sub`,o,c,u),a.call(r+`_sub`,s,l,d))}function l(){let t=e.addFunction(n+`_neg`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.getLocal(`r`),l=a.i32_add(a.getLocal(`r`),a.i32_const(i));t.addCode(a.call(r+`_neg`,o,c),a.call(r+`_neg`,s,l))}function u(){let t=e.addFunction(n+`_conjugate`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.getLocal(`r`),l=a.i32_add(a.getLocal(`r`),a.i32_const(i));t.addCode(a.call(r+`_copy`,o,c),a.call(r+`_neg`,s,l))}function d(){let t=e.addFunction(n+`_isNegative`);t.addParam(`x`,`i32`),t.setReturnType(`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i));t.addCode(a.if(a.call(r+`_isZero`,s),a.ret(a.call(r+`_isNegative`,o))),a.ret(a.call(r+`_isNegative`,s)))}function f(){let a=e.addFunction(n+`_mul`);a.addParam(`x`,`i32`),a.addParam(`y`,`i32`),a.addParam(`r`,`i32`);let o=a.getCodeBuilder(),s=o.getLocal(`x`),c=o.i32_add(o.getLocal(`x`),o.i32_const(i)),l=o.getLocal(`y`),u=o.i32_add(o.getLocal(`y`),o.i32_const(i)),d=o.getLocal(`r`),f=o.i32_add(o.getLocal(`r`),o.i32_const(i)),p=o.i32_const(e.alloc(i)),m=o.i32_const(e.alloc(i)),h=o.i32_const(e.alloc(i)),g=o.i32_const(e.alloc(i));a.addCode(o.call(r+`_mul`,s,l,p),o.call(r+`_mul`,c,u,m),o.call(r+`_add`,s,c,h),o.call(r+`_add`,l,u,g),o.call(r+`_mul`,h,g,h),o.call(t,m,d),o.call(r+`_add`,p,d,d),o.call(r+`_add`,p,m,f),o.call(r+`_sub`,h,f,f))}function p(){let t=e.addFunction(n+`_mul1`);t.addParam(`x`,`i32`),t.addParam(`y`,`i32`),t.addParam(`r`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.getLocal(`y`),l=a.getLocal(`r`),u=a.i32_add(a.getLocal(`r`),a.i32_const(i));t.addCode(a.call(r+`_mul`,o,c,l),a.call(r+`_mul`,s,c,u))}function m(){let a=e.addFunction(n+`_square`);a.addParam(`x`,`i32`),a.addParam(`r`,`i32`);let o=a.getCodeBuilder(),s=o.getLocal(`x`),c=o.i32_add(o.getLocal(`x`),o.i32_const(i)),l=o.getLocal(`r`),u=o.i32_add(o.getLocal(`r`),o.i32_const(i)),d=o.i32_const(e.alloc(i)),f=o.i32_const(e.alloc(i)),p=o.i32_const(e.alloc(i)),m=o.i32_const(e.alloc(i));a.addCode(o.call(r+`_mul`,s,c,d),o.call(r+`_add`,s,c,f),o.call(t,c,p),o.call(r+`_add`,s,p,p),o.call(t,d,m),o.call(r+`_add`,m,d,m),o.call(r+`_mul`,f,p,l),o.call(r+`_sub`,l,m,l),o.call(r+`_add`,d,d,u))}function h(){let t=e.addFunction(n+`_toMontgomery`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.getLocal(`r`),l=a.i32_add(a.getLocal(`r`),a.i32_const(i));t.addCode(a.call(r+`_toMontgomery`,o,c),a.call(r+`_toMontgomery`,s,l))}function g(){let t=e.addFunction(n+`_fromMontgomery`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.getLocal(`r`),l=a.i32_add(a.getLocal(`r`),a.i32_const(i));t.addCode(a.call(r+`_fromMontgomery`,o,c),a.call(r+`_fromMontgomery`,s,l))}function _(){let t=e.addFunction(n+`_copy`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.getLocal(`r`),l=a.i32_add(a.getLocal(`r`),a.i32_const(i));t.addCode(a.call(r+`_copy`,o,c),a.call(r+`_copy`,s,l))}function v(){let t=e.addFunction(n+`_zero`);t.addParam(`x`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i));t.addCode(a.call(r+`_zero`,o),a.call(r+`_zero`,s))}function y(){let t=e.addFunction(n+`_one`);t.addParam(`x`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i));t.addCode(a.call(r+`_one`,o),a.call(r+`_zero`,s))}function b(){let t=e.addFunction(n+`_eq`);t.addParam(`x`,`i32`),t.addParam(`y`,`i32`),t.setReturnType(`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.getLocal(`y`),l=a.i32_add(a.getLocal(`y`),a.i32_const(i));t.addCode(a.i32_and(a.call(r+`_eq`,o,c),a.call(r+`_eq`,s,l)))}function x(){let t=e.addFunction(n+`_isZero`);t.addParam(`x`,`i32`),t.setReturnType(`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i));t.addCode(a.i32_and(a.call(r+`_isZero`,o),a.call(r+`_isZero`,s)))}function S(){let a=e.addFunction(n+`_inverse`);a.addParam(`x`,`i32`),a.addParam(`r`,`i32`);let o=a.getCodeBuilder(),s=o.getLocal(`x`),c=o.i32_add(o.getLocal(`x`),o.i32_const(i)),l=o.getLocal(`r`),u=o.i32_add(o.getLocal(`r`),o.i32_const(i)),d=o.i32_const(e.alloc(i)),f=o.i32_const(e.alloc(i)),p=o.i32_const(e.alloc(i)),m=o.i32_const(e.alloc(i));a.addCode(o.call(r+`_square`,s,d),o.call(r+`_square`,c,f),o.call(t,f,p),o.call(r+`_sub`,d,p,p),o.call(r+`_inverse`,p,m),o.call(r+`_mul`,s,m,l),o.call(r+`_mul`,c,m,u),o.call(r+`_neg`,u,u))}function C(){let t=e.addFunction(n+`_sign`);t.addParam(`x`,`i32`),t.addLocal(`s`,`i32`),t.setReturnType(`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i));t.addCode(a.setLocal(`s`,a.call(r+`_sign`,s)),a.if(a.getLocal(`s`),a.ret(a.getLocal(`s`))),a.ret(a.call(r+`_sign`,o)))}function w(){let t=e.addFunction(n+`_isOne`);t.addParam(`x`,`i32`),t.setReturnType(`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i));t.addCode(a.ret(a.i32_and(a.call(r+`_isOne`,o),a.call(r+`_isZero`,s))))}function T(){let t=e.addFunction(n+`_sqrt`);t.addParam(`a`,`i32`),t.addParam(`pr`,`i32`);let o=t.getCodeBuilder(),s=o.i32_const(e.alloc(ln.bigInt2BytesLE((BigInt(a||0)-3n)/4n,i))),c=o.i32_const(e.alloc(ln.bigInt2BytesLE((BigInt(a||0)-1n)/2n,i))),l=o.getLocal(`a`),u=o.i32_const(e.alloc(i*2)),d=o.i32_const(e.alloc(i*2)),f=o.i32_const(e.alloc(i*2)),p=e.alloc(i*2),m=o.i32_const(p),h=o.i32_const(p),g=o.i32_const(p+i),_=o.i32_const(e.alloc(i*2)),v=o.i32_const(e.alloc(i*2));t.addCode(o.call(n+`_one`,m),o.call(n+`_neg`,m,m),o.call(n+`_exp`,l,s,o.i32_const(i),u),o.call(n+`_square`,u,d),o.call(n+`_mul`,l,d,d),o.call(n+`_conjugate`,d,f),o.call(n+`_mul`,f,d,f),o.if(o.call(n+`_eq`,f,m),o.unreachable()),o.call(n+`_mul`,u,l,_),o.if(o.call(n+`_eq`,d,m),[...o.call(r+`_zero`,h),...o.call(r+`_one`,g),...o.call(n+`_mul`,m,_,o.getLocal(`pr`))],[...o.call(n+`_one`,v),...o.call(n+`_add`,v,d,v),...o.call(n+`_exp`,v,c,o.i32_const(i),v),...o.call(n+`_mul`,v,_,o.getLocal(`pr`))]))}function E(){let t=e.addFunction(n+`_isSquare`);t.addParam(`a`,`i32`),t.setReturnType(`i32`);let r=t.getCodeBuilder(),o=r.i32_const(e.alloc(ln.bigInt2BytesLE((BigInt(a||0)-3n)/4n,i))),s=r.getLocal(`a`),c=r.i32_const(e.alloc(i*2)),l=r.i32_const(e.alloc(i*2)),u=r.i32_const(e.alloc(i*2)),d=e.alloc(i*2),f=r.i32_const(d);t.addCode(r.call(n+`_one`,f),r.call(n+`_neg`,f,f),r.call(n+`_exp`,s,o,r.i32_const(i),c),r.call(n+`_square`,c,l),r.call(n+`_mul`,s,l,l),r.call(n+`_conjugate`,l,u),r.call(n+`_mul`,u,l,u),r.if(r.call(n+`_eq`,u,f),r.ret(r.i32_const(0))),r.ret(r.i32_const(1)))}return x(),w(),v(),y(),_(),f(),p(),m(),o(),c(),l(),u(),h(),g(),b(),S(),s(),C(),d(),e.exportFunction(n+`_isZero`),e.exportFunction(n+`_isOne`),e.exportFunction(n+`_zero`),e.exportFunction(n+`_one`),e.exportFunction(n+`_copy`),e.exportFunction(n+`_mul`),e.exportFunction(n+`_mul1`),e.exportFunction(n+`_square`),e.exportFunction(n+`_add`),e.exportFunction(n+`_sub`),e.exportFunction(n+`_neg`),e.exportFunction(n+`_sign`),e.exportFunction(n+`_conjugate`),e.exportFunction(n+`_fromMontgomery`),e.exportFunction(n+`_toMontgomery`),e.exportFunction(n+`_eq`),e.exportFunction(n+`_inverse`),cn(e,n),sn(e,n+`_exp`,i*2,n+`_mul`,n+`_square`,n+`_copy`,n+`_one`),T(),E(),e.exportFunction(n+`_exp`),e.exportFunction(n+`_timesScalar`),e.exportFunction(n+`_batchInverse`),e.exportFunction(n+`_sqrt`),e.exportFunction(n+`_isSquare`),e.exportFunction(n+`_isNegative`),n};const dn=yt,fn=bt;var pn=function(e,t,n,r){if(e.modules[n])return n;let i=e.modules[r].n64*8;e.modules[n]={n64:e.modules[r].n64*3};function a(){let t=e.addFunction(n+`_add`);t.addParam(`x`,`i32`),t.addParam(`y`,`i32`),t.addParam(`r`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.i32_add(a.getLocal(`x`),a.i32_const(2*i)),l=a.getLocal(`y`),u=a.i32_add(a.getLocal(`y`),a.i32_const(i)),d=a.i32_add(a.getLocal(`y`),a.i32_const(2*i)),f=a.getLocal(`r`),p=a.i32_add(a.getLocal(`r`),a.i32_const(i)),m=a.i32_add(a.getLocal(`r`),a.i32_const(2*i));t.addCode(a.call(r+`_add`,o,l,f),a.call(r+`_add`,s,u,p),a.call(r+`_add`,c,d,m))}function o(){let t=e.addFunction(n+`_timesScalar`);t.addParam(`x`,`i32`),t.addParam(`scalar`,`i32`),t.addParam(`scalarLen`,`i32`),t.addParam(`r`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.i32_add(a.getLocal(`x`),a.i32_const(2*i)),l=a.getLocal(`r`),u=a.i32_add(a.getLocal(`r`),a.i32_const(i)),d=a.i32_add(a.getLocal(`r`),a.i32_const(2*i));t.addCode(a.call(r+`_timesScalar`,o,a.getLocal(`scalar`),a.getLocal(`scalarLen`),l),a.call(r+`_timesScalar`,s,a.getLocal(`scalar`),a.getLocal(`scalarLen`),u),a.call(r+`_timesScalar`,c,a.getLocal(`scalar`),a.getLocal(`scalarLen`),d))}function s(){let t=e.addFunction(n+`_sub`);t.addParam(`x`,`i32`),t.addParam(`y`,`i32`),t.addParam(`r`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.i32_add(a.getLocal(`x`),a.i32_const(2*i)),l=a.getLocal(`y`),u=a.i32_add(a.getLocal(`y`),a.i32_const(i)),d=a.i32_add(a.getLocal(`y`),a.i32_const(2*i)),f=a.getLocal(`r`),p=a.i32_add(a.getLocal(`r`),a.i32_const(i)),m=a.i32_add(a.getLocal(`r`),a.i32_const(2*i));t.addCode(a.call(r+`_sub`,o,l,f),a.call(r+`_sub`,s,u,p),a.call(r+`_sub`,c,d,m))}function c(){let t=e.addFunction(n+`_neg`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.i32_add(a.getLocal(`x`),a.i32_const(2*i)),l=a.getLocal(`r`),u=a.i32_add(a.getLocal(`r`),a.i32_const(i)),d=a.i32_add(a.getLocal(`r`),a.i32_const(2*i));t.addCode(a.call(r+`_neg`,o,l),a.call(r+`_neg`,s,u),a.call(r+`_neg`,c,d))}function l(){let t=e.addFunction(n+`_isNegative`);t.addParam(`x`,`i32`),t.setReturnType(`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.i32_add(a.getLocal(`x`),a.i32_const(2*i));t.addCode(a.if(a.call(r+`_isZero`,c),a.if(a.call(r+`_isZero`,s),a.ret(a.call(r+`_isNegative`,o)),a.ret(a.call(r+`_isNegative`,s)))),a.ret(a.call(r+`_isNegative`,c)))}function u(){let a=e.addFunction(n+`_mul`);a.addParam(`x`,`i32`),a.addParam(`y`,`i32`),a.addParam(`r`,`i32`);let o=a.getCodeBuilder(),s=o.getLocal(`x`),c=o.i32_add(o.getLocal(`x`),o.i32_const(i)),l=o.i32_add(o.getLocal(`x`),o.i32_const(2*i)),u=o.getLocal(`y`),d=o.i32_add(o.getLocal(`y`),o.i32_const(i)),f=o.i32_add(o.getLocal(`y`),o.i32_const(2*i)),p=o.getLocal(`r`),m=o.i32_add(o.getLocal(`r`),o.i32_const(i)),h=o.i32_add(o.getLocal(`r`),o.i32_const(2*i)),g=o.i32_const(e.alloc(i)),_=o.i32_const(e.alloc(i)),v=o.i32_const(e.alloc(i)),y=o.i32_const(e.alloc(i)),b=o.i32_const(e.alloc(i)),x=o.i32_const(e.alloc(i)),S=o.i32_const(e.alloc(i)),C=o.i32_const(e.alloc(i)),w=o.i32_const(e.alloc(i)),T=o.i32_const(e.alloc(i)),E=o.i32_const(e.alloc(i)),D=o.i32_const(e.alloc(i)),O=o.i32_const(e.alloc(i));a.addCode(o.call(r+`_mul`,s,u,g),o.call(r+`_mul`,c,d,_),o.call(r+`_mul`,l,f,v),o.call(r+`_add`,s,c,y),o.call(r+`_add`,u,d,b),o.call(r+`_add`,s,l,x),o.call(r+`_add`,u,f,S),o.call(r+`_add`,c,l,C),o.call(r+`_add`,d,f,w),o.call(r+`_add`,g,_,T),o.call(r+`_add`,g,v,E),o.call(r+`_add`,_,v,D),o.call(r+`_mul`,C,w,p),o.call(r+`_sub`,p,D,p),o.call(t,p,p),o.call(r+`_add`,g,p,p),o.call(r+`_mul`,y,b,m),o.call(r+`_sub`,m,T,m),o.call(t,v,O),o.call(r+`_add`,m,O,m),o.call(r+`_mul`,x,S,h),o.call(r+`_sub`,h,E,h),o.call(r+`_add`,h,_,h))}function d(){let a=e.addFunction(n+`_square`);a.addParam(`x`,`i32`),a.addParam(`r`,`i32`);let o=a.getCodeBuilder(),s=o.getLocal(`x`),c=o.i32_add(o.getLocal(`x`),o.i32_const(i)),l=o.i32_add(o.getLocal(`x`),o.i32_const(2*i)),u=o.getLocal(`r`),d=o.i32_add(o.getLocal(`r`),o.i32_const(i)),f=o.i32_add(o.getLocal(`r`),o.i32_const(2*i)),p=o.i32_const(e.alloc(i)),m=o.i32_const(e.alloc(i)),h=o.i32_const(e.alloc(i)),g=o.i32_const(e.alloc(i)),_=o.i32_const(e.alloc(i)),v=o.i32_const(e.alloc(i)),y=o.i32_const(e.alloc(i));a.addCode(o.call(r+`_square`,s,p),o.call(r+`_mul`,s,c,m),o.call(r+`_add`,m,m,h),o.call(r+`_sub`,s,c,g),o.call(r+`_add`,g,l,g),o.call(r+`_square`,g,g),o.call(r+`_mul`,c,l,_),o.call(r+`_add`,_,_,v),o.call(r+`_square`,l,y),o.call(t,v,u),o.call(r+`_add`,p,u,u),o.call(t,y,d),o.call(r+`_add`,h,d,d),o.call(r+`_add`,p,y,f),o.call(r+`_sub`,v,f,f),o.call(r+`_add`,g,f,f),o.call(r+`_add`,h,f,f))}function f(){let t=e.addFunction(n+`_toMontgomery`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.i32_add(a.getLocal(`x`),a.i32_const(2*i)),l=a.getLocal(`r`),u=a.i32_add(a.getLocal(`r`),a.i32_const(i)),d=a.i32_add(a.getLocal(`r`),a.i32_const(2*i));t.addCode(a.call(r+`_toMontgomery`,o,l),a.call(r+`_toMontgomery`,s,u),a.call(r+`_toMontgomery`,c,d))}function p(){let t=e.addFunction(n+`_fromMontgomery`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.i32_add(a.getLocal(`x`),a.i32_const(2*i)),l=a.getLocal(`r`),u=a.i32_add(a.getLocal(`r`),a.i32_const(i)),d=a.i32_add(a.getLocal(`r`),a.i32_const(2*i));t.addCode(a.call(r+`_fromMontgomery`,o,l),a.call(r+`_fromMontgomery`,s,u),a.call(r+`_fromMontgomery`,c,d))}function m(){let t=e.addFunction(n+`_copy`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.i32_add(a.getLocal(`x`),a.i32_const(2*i)),l=a.getLocal(`r`),u=a.i32_add(a.getLocal(`r`),a.i32_const(i)),d=a.i32_add(a.getLocal(`r`),a.i32_const(2*i));t.addCode(a.call(r+`_copy`,o,l),a.call(r+`_copy`,s,u),a.call(r+`_copy`,c,d))}function h(){let t=e.addFunction(n+`_zero`);t.addParam(`x`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.i32_add(a.getLocal(`x`),a.i32_const(2*i));t.addCode(a.call(r+`_zero`,o),a.call(r+`_zero`,s),a.call(r+`_zero`,c))}function g(){let t=e.addFunction(n+`_one`);t.addParam(`x`,`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.i32_add(a.getLocal(`x`),a.i32_const(2*i));t.addCode(a.call(r+`_one`,o),a.call(r+`_zero`,s),a.call(r+`_zero`,c))}function _(){let t=e.addFunction(n+`_eq`);t.addParam(`x`,`i32`),t.addParam(`y`,`i32`),t.setReturnType(`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.i32_add(a.getLocal(`x`),a.i32_const(2*i)),l=a.getLocal(`y`),u=a.i32_add(a.getLocal(`y`),a.i32_const(i)),d=a.i32_add(a.getLocal(`y`),a.i32_const(2*i));t.addCode(a.i32_and(a.i32_and(a.call(r+`_eq`,o,l),a.call(r+`_eq`,s,u)),a.call(r+`_eq`,c,d)))}function v(){let t=e.addFunction(n+`_isZero`);t.addParam(`x`,`i32`),t.setReturnType(`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.i32_add(a.getLocal(`x`),a.i32_const(2*i));t.addCode(a.i32_and(a.i32_and(a.call(r+`_isZero`,o),a.call(r+`_isZero`,s)),a.call(r+`_isZero`,c)))}function y(){let a=e.addFunction(n+`_inverse`);a.addParam(`x`,`i32`),a.addParam(`r`,`i32`);let o=a.getCodeBuilder(),s=o.getLocal(`x`),c=o.i32_add(o.getLocal(`x`),o.i32_const(i)),l=o.i32_add(o.getLocal(`x`),o.i32_const(2*i)),u=o.getLocal(`r`),d=o.i32_add(o.getLocal(`r`),o.i32_const(i)),f=o.i32_add(o.getLocal(`r`),o.i32_const(2*i)),p=o.i32_const(e.alloc(i)),m=o.i32_const(e.alloc(i)),h=o.i32_const(e.alloc(i)),g=o.i32_const(e.alloc(i)),_=o.i32_const(e.alloc(i)),v=o.i32_const(e.alloc(i)),y=o.i32_const(e.alloc(i)),b=o.i32_const(e.alloc(i)),x=o.i32_const(e.alloc(i)),S=o.i32_const(e.alloc(i)),C=o.i32_const(e.alloc(i));a.addCode(o.call(r+`_square`,s,p),o.call(r+`_square`,c,m),o.call(r+`_square`,l,h),o.call(r+`_mul`,s,c,g),o.call(r+`_mul`,s,l,_),o.call(r+`_mul`,c,l,v),o.call(t,v,y),o.call(r+`_sub`,p,y,y),o.call(t,h,b),o.call(r+`_sub`,b,g,b),o.call(r+`_sub`,m,_,x),o.call(r+`_mul`,l,b,S),o.call(r+`_mul`,c,x,C),o.call(r+`_add`,S,C,S),o.call(t,S,S),o.call(r+`_mul`,s,y,C),o.call(r+`_add`,C,S,S),o.call(r+`_inverse`,S,S),o.call(r+`_mul`,S,y,u),o.call(r+`_mul`,S,b,d),o.call(r+`_mul`,S,x,f))}function b(){let t=e.addFunction(n+`_sign`);t.addParam(`x`,`i32`),t.addLocal(`s`,`i32`),t.setReturnType(`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.i32_add(a.getLocal(`x`),a.i32_const(2*i));t.addCode(a.setLocal(`s`,a.call(r+`_sign`,c)),a.if(a.getLocal(`s`),a.ret(a.getLocal(`s`))),a.setLocal(`s`,a.call(r+`_sign`,s)),a.if(a.getLocal(`s`),a.ret(a.getLocal(`s`))),a.ret(a.call(r+`_sign`,o)))}function x(){let t=e.addFunction(n+`_isOne`);t.addParam(`x`,`i32`),t.setReturnType(`i32`);let a=t.getCodeBuilder(),o=a.getLocal(`x`),s=a.i32_add(a.getLocal(`x`),a.i32_const(i)),c=a.i32_add(a.getLocal(`x`),a.i32_const(i*2));t.addCode(a.ret(a.i32_and(a.i32_and(a.call(r+`_isOne`,o),a.call(r+`_isZero`,s)),a.call(r+`_isZero`,c))))}return v(),x(),h(),g(),m(),u(),d(),a(),s(),c(),b(),f(),p(),_(),y(),o(),l(),e.exportFunction(n+`_isZero`),e.exportFunction(n+`_isOne`),e.exportFunction(n+`_zero`),e.exportFunction(n+`_one`),e.exportFunction(n+`_copy`),e.exportFunction(n+`_mul`),e.exportFunction(n+`_square`),e.exportFunction(n+`_add`),e.exportFunction(n+`_sub`),e.exportFunction(n+`_neg`),e.exportFunction(n+`_sign`),e.exportFunction(n+`_fromMontgomery`),e.exportFunction(n+`_toMontgomery`),e.exportFunction(n+`_eq`),e.exportFunction(n+`_inverse`),fn(e,n),dn(e,n+`_exp`,i*3,n+`_mul`,n+`_square`,n+`_copy`,n+`_one`),e.exportFunction(n+`_exp`),e.exportFunction(n+`_timesScalar`),e.exportFunction(n+`_batchInverse`),e.exportFunction(n+`_isNegative`),n},mn=function(e,t,n,r,i,a,o,s){let c=e.addFunction(t);c.addParam(`base`,`i32`),c.addParam(`scalar`,`i32`),c.addParam(`scalarLength`,`i32`),c.addParam(`r`,`i32`),c.addLocal(`old0`,`i32`),c.addLocal(`nbits`,`i32`),c.addLocal(`i`,`i32`),c.addLocal(`last`,`i32`),c.addLocal(`cur`,`i32`),c.addLocal(`carry`,`i32`),c.addLocal(`p`,`i32`);let l=c.getCodeBuilder(),u=l.i32_const(e.alloc(n));function d(e){return l.i32_and(l.i32_shr_u(l.i32_load(l.i32_add(l.getLocal(`scalar`),l.i32_and(l.i32_shr_u(e,l.i32_const(3)),l.i32_const(4294967292)))),l.i32_and(e,l.i32_const(31))),l.i32_const(1))}function f(e){return[...l.i32_store8(l.getLocal(`p`),l.i32_const(e)),...l.setLocal(`p`,l.i32_add(l.getLocal(`p`),l.i32_const(1)))]}c.addCode(l.if(l.i32_eqz(l.getLocal(`scalarLength`)),[...l.call(s,l.getLocal(`r`)),...l.ret([])]),l.setLocal(`nbits`,l.i32_shl(l.getLocal(`scalarLength`),l.i32_const(3))),l.setLocal(`old0`,l.i32_load(l.i32_const(0))),l.setLocal(`p`,l.getLocal(`old0`)),l.i32_store(l.i32_const(0),l.i32_and(l.i32_add(l.i32_add(l.getLocal(`old0`),l.i32_const(32)),l.getLocal(`nbits`)),l.i32_const(4294967288))),l.setLocal(`i`,l.i32_const(1)),l.setLocal(`last`,d(l.i32_const(0))),l.setLocal(`carry`,l.i32_const(0)),l.block(l.loop(l.br_if(1,l.i32_eq(l.getLocal(`i`),l.getLocal(`nbits`))),l.setLocal(`cur`,d(l.getLocal(`i`))),l.if(l.getLocal(`last`),l.if(l.getLocal(`cur`),l.if(l.getLocal(`carry`),[...l.setLocal(`last`,l.i32_const(0)),...l.setLocal(`carry`,l.i32_const(1)),...f(1)],[...l.setLocal(`last`,l.i32_const(0)),...l.setLocal(`carry`,l.i32_const(1)),...f(255)]),l.if(l.getLocal(`carry`),[...l.setLocal(`last`,l.i32_const(0)),...l.setLocal(`carry`,l.i32_const(1)),...f(255)],[...l.setLocal(`last`,l.i32_const(0)),...l.setLocal(`carry`,l.i32_const(0)),...f(1)])),l.if(l.getLocal(`cur`),l.if(l.getLocal(`carry`),[...l.setLocal(`last`,l.i32_const(0)),...l.setLocal(`carry`,l.i32_const(1)),...f(0)],[...l.setLocal(`last`,l.i32_const(1)),...l.setLocal(`carry`,l.i32_const(0)),...f(0)]),l.if(l.getLocal(`carry`),[...l.setLocal(`last`,l.i32_const(1)),...l.setLocal(`carry`,l.i32_const(0)),...f(0)],[...l.setLocal(`last`,l.i32_const(0)),...l.setLocal(`carry`,l.i32_const(0)),...f(0)]))),l.setLocal(`i`,l.i32_add(l.getLocal(`i`),l.i32_const(1))),l.br(0))),l.if(l.getLocal(`last`),l.if(l.getLocal(`carry`),[...f(255),...f(0),...f(1)],[...f(1)]),l.if(l.getLocal(`carry`),[...f(0),...f(1)])),l.setLocal(`p`,l.i32_sub(l.getLocal(`p`),l.i32_const(1))),l.call(o,l.getLocal(`base`),u),l.call(s,l.getLocal(`r`)),l.block(l.loop(l.call(i,l.getLocal(`r`),l.getLocal(`r`)),l.setLocal(`cur`,l.i32_load8_u(l.getLocal(`p`))),l.if(l.getLocal(`cur`),l.if(l.i32_eq(l.getLocal(`cur`),l.i32_const(1)),l.call(r,l.getLocal(`r`),u,l.getLocal(`r`)),l.call(a,l.getLocal(`r`),u,l.getLocal(`r`)))),l.br_if(1,l.i32_eq(l.getLocal(`old0`),l.getLocal(`p`))),l.setLocal(`p`,l.i32_sub(l.getLocal(`p`),l.i32_const(1))),l.br(0))),l.i32_store(l.i32_const(0),l.getLocal(`old0`)))},hn=function(e,t,n,r,i){let a=e.modules[t].n64*8;function o(){let t=e.addFunction(n+`_getChunk`);t.addParam(`pScalar`,`i32`),t.addParam(`scalarSize`,`i32`),t.addParam(`startBit`,`i32`),t.addParam(`chunkSize`,`i32`),t.addLocal(`bitsToEnd`,`i32`),t.addLocal(`mask`,`i32`),t.setReturnType(`i32`);let r=t.getCodeBuilder();t.addCode(r.setLocal(`bitsToEnd`,r.i32_sub(r.i32_mul(r.getLocal(`scalarSize`),r.i32_const(8)),r.getLocal(`startBit`))),r.if(r.i32_gt_s(r.getLocal(`chunkSize`),r.getLocal(`bitsToEnd`)),r.setLocal(`mask`,r.i32_sub(r.i32_shl(r.i32_const(1),r.getLocal(`bitsToEnd`)),r.i32_const(1))),r.setLocal(`mask`,r.i32_sub(r.i32_shl(r.i32_const(1),r.getLocal(`chunkSize`)),r.i32_const(1)))),r.i32_and(r.i32_shr_u(r.i32_load(r.i32_add(r.getLocal(`pScalar`),r.i32_shr_u(r.getLocal(`startBit`),r.i32_const(3))),0,0),r.i32_and(r.getLocal(`startBit`),r.i32_const(7))),r.getLocal(`mask`)))}function s(){let o=e.addFunction(n+`_chunk`);o.addParam(`pBases`,`i32`),o.addParam(`pScalars`,`i32`),o.addParam(`scalarSize`,`i32`),o.addParam(`n`,`i32`),o.addParam(`startBit`,`i32`),o.addParam(`chunkSize`,`i32`),o.addParam(`pr`,`i32`),o.addLocal(`nChunks`,`i32`),o.addLocal(`itScalar`,`i32`),o.addLocal(`endScalar`,`i32`),o.addLocal(`itBase`,`i32`),o.addLocal(`i`,`i32`),o.addLocal(`j`,`i32`),o.addLocal(`nTable`,`i32`),o.addLocal(`pTable`,`i32`),o.addLocal(`idx`,`i32`),o.addLocal(`pIdxTable`,`i32`);let s=o.getCodeBuilder();o.addCode(s.if(s.i32_eqz(s.getLocal(`n`)),[...s.call(t+`_zero`,s.getLocal(`pr`)),...s.ret([])]),s.setLocal(`nTable`,s.i32_shl(s.i32_const(1),s.getLocal(`chunkSize`))),s.setLocal(`pTable`,s.i32_load(s.i32_const(0))),s.i32_store(s.i32_const(0),s.i32_add(s.getLocal(`pTable`),s.i32_mul(s.getLocal(`nTable`),s.i32_const(a)))),s.setLocal(`j`,s.i32_const(0)),s.block(s.loop(s.br_if(1,s.i32_eq(s.getLocal(`j`),s.getLocal(`nTable`))),s.call(t+`_zero`,s.i32_add(s.getLocal(`pTable`),s.i32_mul(s.getLocal(`j`),s.i32_const(a)))),s.setLocal(`j`,s.i32_add(s.getLocal(`j`),s.i32_const(1))),s.br(0))),s.setLocal(`itBase`,s.getLocal(`pBases`)),s.setLocal(`itScalar`,s.getLocal(`pScalars`)),s.setLocal(`endScalar`,s.i32_add(s.getLocal(`pScalars`),s.i32_mul(s.getLocal(`n`),s.getLocal(`scalarSize`)))),s.block(s.loop(s.br_if(1,s.i32_eq(s.getLocal(`itScalar`),s.getLocal(`endScalar`))),s.setLocal(`idx`,s.call(n+`_getChunk`,s.getLocal(`itScalar`),s.getLocal(`scalarSize`),s.getLocal(`startBit`),s.getLocal(`chunkSize`))),s.if(s.getLocal(`idx`),[...s.setLocal(`pIdxTable`,s.i32_add(s.getLocal(`pTable`),s.i32_mul(s.i32_sub(s.getLocal(`idx`),s.i32_const(1)),s.i32_const(a)))),...s.call(r,s.getLocal(`pIdxTable`),s.getLocal(`itBase`),s.getLocal(`pIdxTable`))]),s.setLocal(`itScalar`,s.i32_add(s.getLocal(`itScalar`),s.getLocal(`scalarSize`))),s.setLocal(`itBase`,s.i32_add(s.getLocal(`itBase`),s.i32_const(i))),s.br(0))),s.call(n+`_reduceTable`,s.getLocal(`pTable`),s.getLocal(`chunkSize`)),s.call(t+`_copy`,s.getLocal(`pTable`),s.getLocal(`pr`)),s.i32_store(s.i32_const(0),s.getLocal(`pTable`)))}function c(){let r=e.addFunction(n);r.addParam(`pBases`,`i32`),r.addParam(`pScalars`,`i32`),r.addParam(`scalarSize`,`i32`),r.addParam(`n`,`i32`),r.addParam(`pr`,`i32`),r.addLocal(`chunkSize`,`i32`),r.addLocal(`nChunks`,`i32`),r.addLocal(`itScalar`,`i32`),r.addLocal(`endScalar`,`i32`),r.addLocal(`itBase`,`i32`),r.addLocal(`itBit`,`i32`),r.addLocal(`i`,`i32`),r.addLocal(`j`,`i32`),r.addLocal(`nTable`,`i32`),r.addLocal(`pTable`,`i32`),r.addLocal(`idx`,`i32`),r.addLocal(`pIdxTable`,`i32`);let i=r.getCodeBuilder(),o=i.i32_const(e.alloc(a)),s=e.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]);r.addCode(i.call(t+`_zero`,i.getLocal(`pr`)),i.if(i.i32_eqz(i.getLocal(`n`)),i.ret([])),i.setLocal(`chunkSize`,i.i32_load8_u(i.i32_clz(i.getLocal(`n`)),s)),i.setLocal(`nChunks`,i.i32_add(i.i32_div_u(i.i32_sub(i.i32_shl(i.getLocal(`scalarSize`),i.i32_const(3)),i.i32_const(1)),i.getLocal(`chunkSize`)),i.i32_const(1))),i.setLocal(`itBit`,i.i32_mul(i.i32_sub(i.getLocal(`nChunks`),i.i32_const(1)),i.getLocal(`chunkSize`))),i.block(i.loop(i.br_if(1,i.i32_lt_s(i.getLocal(`itBit`),i.i32_const(0))),i.if(i.i32_eqz(i.call(t+`_isZero`,i.getLocal(`pr`))),[...i.setLocal(`j`,i.i32_const(0)),...i.block(i.loop(i.br_if(1,i.i32_eq(i.getLocal(`j`),i.getLocal(`chunkSize`))),i.call(t+`_double`,i.getLocal(`pr`),i.getLocal(`pr`)),i.setLocal(`j`,i.i32_add(i.getLocal(`j`),i.i32_const(1))),i.br(0)))]),i.call(n+`_chunk`,i.getLocal(`pBases`),i.getLocal(`pScalars`),i.getLocal(`scalarSize`),i.getLocal(`n`),i.getLocal(`itBit`),i.getLocal(`chunkSize`),o),i.call(t+`_add`,i.getLocal(`pr`),o,i.getLocal(`pr`)),i.setLocal(`itBit`,i.i32_sub(i.getLocal(`itBit`),i.getLocal(`chunkSize`))),i.br(0))))}function l(){let r=e.addFunction(n+`_reduceTable`);r.addParam(`pTable`,`i32`),r.addParam(`p`,`i32`),r.addLocal(`half`,`i32`),r.addLocal(`it1`,`i32`),r.addLocal(`it2`,`i32`),r.addLocal(`pAcc`,`i32`);let i=r.getCodeBuilder();r.addCode(i.if(i.i32_eq(i.getLocal(`p`),i.i32_const(1)),i.ret([])),i.setLocal(`half`,i.i32_shl(i.i32_const(1),i.i32_sub(i.getLocal(`p`),i.i32_const(1)))),i.setLocal(`it1`,i.getLocal(`pTable`)),i.setLocal(`it2`,i.i32_add(i.getLocal(`pTable`),i.i32_mul(i.getLocal(`half`),i.i32_const(a)))),i.setLocal(`pAcc`,i.i32_sub(i.getLocal(`it2`),i.i32_const(a))),i.block(i.loop(i.br_if(1,i.i32_eq(i.getLocal(`it1`),i.getLocal(`pAcc`))),i.call(t+`_add`,i.getLocal(`it1`),i.getLocal(`it2`),i.getLocal(`it1`)),i.call(t+`_add`,i.getLocal(`pAcc`),i.getLocal(`it2`),i.getLocal(`pAcc`)),i.setLocal(`it1`,i.i32_add(i.getLocal(`it1`),i.i32_const(a))),i.setLocal(`it2`,i.i32_add(i.getLocal(`it2`),i.i32_const(a))),i.br(0))),i.call(n+`_reduceTable`,i.getLocal(`pTable`),i.i32_sub(i.getLocal(`p`),i.i32_const(1))),i.setLocal(`p`,i.i32_sub(i.getLocal(`p`),i.i32_const(1))),i.block(i.loop(i.br_if(1,i.i32_eqz(i.getLocal(`p`))),i.call(t+`_double`,i.getLocal(`pAcc`),i.getLocal(`pAcc`)),i.setLocal(`p`,i.i32_sub(i.getLocal(`p`),i.i32_const(1))),i.br(0))),i.call(t+`_add`,i.getLocal(`pTable`),i.getLocal(`pAcc`),i.getLocal(`pTable`)))}o(),l(),s(),c(),e.exportFunction(n),e.exportFunction(n+`_chunk`)};const gn=mn,_n=St,vn=hn;var yn=function(e,t,n,r){let i=e.modules[n].n64,a=i*8;if(e.modules[t])return t;e.modules[t]={n64:i*3};function o(){let r=e.addFunction(t+`_isZero`);r.addParam(`p1`,`i32`),r.setReturnType(`i32`);let i=r.getCodeBuilder();r.addCode(i.call(n+`_isZero`,i.i32_add(i.getLocal(`p1`),i.i32_const(a*2))))}function s(){let r=e.addFunction(t+`_isZeroAffine`);r.addParam(`p1`,`i32`),r.setReturnType(`i32`);let i=r.getCodeBuilder();r.addCode(i.i32_and(i.call(n+`_isZero`,i.getLocal(`p1`)),i.call(n+`_isZero`,i.i32_add(i.getLocal(`p1`),i.i32_const(a)))))}function c(){let n=e.addFunction(t+`_copy`);n.addParam(`ps`,`i32`),n.addParam(`pd`,`i32`);let r=n.getCodeBuilder();for(let e=0;e<i*3;e++)n.addCode(r.i64_store(r.getLocal(`pd`),e*8,r.i64_load(r.getLocal(`ps`),e*8)))}function l(){let n=e.addFunction(t+`_copyAffine`);n.addParam(`ps`,`i32`),n.addParam(`pd`,`i32`);let r=n.getCodeBuilder();for(let e=0;e<i*2;e++)n.addCode(r.i64_store(r.getLocal(`pd`),e*8,r.i64_load(r.getLocal(`ps`),e*8)))}function u(){let r=e.addFunction(t+`_zero`);r.addParam(`pr`,`i32`);let i=r.getCodeBuilder();r.addCode(i.call(n+`_zero`,i.getLocal(`pr`))),r.addCode(i.call(n+`_one`,i.i32_add(i.getLocal(`pr`),i.i32_const(a)))),r.addCode(i.call(n+`_zero`,i.i32_add(i.getLocal(`pr`),i.i32_const(a*2))))}function d(){let r=e.addFunction(t+`_zeroAffine`);r.addParam(`pr`,`i32`);let i=r.getCodeBuilder();r.addCode(i.call(n+`_zero`,i.getLocal(`pr`))),r.addCode(i.call(n+`_zero`,i.i32_add(i.getLocal(`pr`),i.i32_const(a))))}function f(){let r=e.addFunction(t+`_eq`);r.addParam(`p1`,`i32`),r.addParam(`p2`,`i32`),r.setReturnType(`i32`),r.addLocal(`z1`,`i32`),r.addLocal(`z2`,`i32`);let i=r.getCodeBuilder(),o=i.getLocal(`p1`),s=i.i32_add(i.getLocal(`p1`),i.i32_const(a));r.addCode(i.setLocal(`z1`,i.i32_add(i.getLocal(`p1`),i.i32_const(a*2))));let c=i.getLocal(`z1`),l=i.getLocal(`p2`),u=i.i32_add(i.getLocal(`p2`),i.i32_const(a));r.addCode(i.setLocal(`z2`,i.i32_add(i.getLocal(`p2`),i.i32_const(a*2))));let d=i.getLocal(`z2`),f=i.i32_const(e.alloc(a)),p=i.i32_const(e.alloc(a)),m=i.i32_const(e.alloc(a)),h=i.i32_const(e.alloc(a)),g=i.i32_const(e.alloc(a)),_=i.i32_const(e.alloc(a)),v=i.i32_const(e.alloc(a)),y=i.i32_const(e.alloc(a));r.addCode(i.if(i.call(t+`_isZero`,i.getLocal(`p1`)),i.ret(i.call(t+`_isZero`,i.getLocal(`p2`)))),i.if(i.call(t+`_isZero`,i.getLocal(`p2`)),i.ret(i.i32_const(0))),i.if(i.call(n+`_isOne`,c),i.ret(i.call(t+`_eqMixed`,i.getLocal(`p2`),i.getLocal(`p1`)))),i.if(i.call(n+`_isOne`,d),i.ret(i.call(t+`_eqMixed`,i.getLocal(`p1`),i.getLocal(`p2`)))),i.call(n+`_square`,c,f),i.call(n+`_square`,d,p),i.call(n+`_mul`,o,p,m),i.call(n+`_mul`,l,f,h),i.call(n+`_mul`,c,f,g),i.call(n+`_mul`,d,p,_),i.call(n+`_mul`,s,_,v),i.call(n+`_mul`,u,g,y),i.if(i.call(n+`_eq`,m,h),i.if(i.call(n+`_eq`,v,y),i.ret(i.i32_const(1)))),i.ret(i.i32_const(0)))}function p(){let r=e.addFunction(t+`_eqMixed`);r.addParam(`p1`,`i32`),r.addParam(`p2`,`i32`),r.setReturnType(`i32`),r.addLocal(`z1`,`i32`);let i=r.getCodeBuilder(),o=i.getLocal(`p1`),s=i.i32_add(i.getLocal(`p1`),i.i32_const(a));r.addCode(i.setLocal(`z1`,i.i32_add(i.getLocal(`p1`),i.i32_const(a*2))));let c=i.getLocal(`z1`),l=i.getLocal(`p2`),u=i.i32_add(i.getLocal(`p2`),i.i32_const(a)),d=i.i32_const(e.alloc(a)),f=i.i32_const(e.alloc(a)),p=i.i32_const(e.alloc(a)),m=i.i32_const(e.alloc(a));r.addCode(i.if(i.call(t+`_isZero`,i.getLocal(`p1`)),i.ret(i.call(t+`_isZeroAffine`,i.getLocal(`p2`)))),i.if(i.call(t+`_isZeroAffine`,i.getLocal(`p2`)),i.ret(i.i32_const(0))),i.if(i.call(n+`_isOne`,c),i.ret(i.call(t+`_eqAffine`,i.getLocal(`p1`),i.getLocal(`p2`)))),i.call(n+`_square`,c,d),i.call(n+`_mul`,l,d,f),i.call(n+`_mul`,c,d,p),i.call(n+`_mul`,u,p,m),i.if(i.call(n+`_eq`,o,f),i.if(i.call(n+`_eq`,s,m),i.ret(i.i32_const(1)))),i.ret(i.i32_const(0)))}function m(){let r=e.addFunction(t+`_double`);r.addParam(`p1`,`i32`),r.addParam(`pr`,`i32`);let i=r.getCodeBuilder(),o=i.getLocal(`p1`),s=i.i32_add(i.getLocal(`p1`),i.i32_const(a)),c=i.i32_add(i.getLocal(`p1`),i.i32_const(a*2)),l=i.getLocal(`pr`),u=i.i32_add(i.getLocal(`pr`),i.i32_const(a)),d=i.i32_add(i.getLocal(`pr`),i.i32_const(a*2)),f=i.i32_const(e.alloc(a)),p=i.i32_const(e.alloc(a)),m=i.i32_const(e.alloc(a)),h=i.i32_const(e.alloc(a)),g=i.i32_const(e.alloc(a)),_=i.i32_const(e.alloc(a)),v=i.i32_const(e.alloc(a)),y=i.i32_const(e.alloc(a));r.addCode(i.if(i.call(t+`_isZero`,i.getLocal(`p1`)),[...i.call(t+`_copy`,i.getLocal(`p1`),i.getLocal(`pr`)),...i.ret([])]),i.if(i.call(n+`_isOne`,c),[...i.ret(i.call(t+`_doubleAffine`,i.getLocal(`p1`),i.getLocal(`pr`))),...i.ret([])]),i.call(n+`_square`,o,f),i.call(n+`_square`,s,p),i.call(n+`_square`,p,m),i.call(n+`_add`,o,p,h),i.call(n+`_square`,h,h),i.call(n+`_sub`,h,f,h),i.call(n+`_sub`,h,m,h),i.call(n+`_add`,h,h,h),i.call(n+`_add`,f,f,g),i.call(n+`_add`,g,f,g),i.call(n+`_square`,g,_),i.call(n+`_mul`,s,c,v),i.call(n+`_add`,h,h,l),i.call(n+`_sub`,_,l,l),i.call(n+`_add`,m,m,y),i.call(n+`_add`,y,y,y),i.call(n+`_add`,y,y,y),i.call(n+`_sub`,h,l,u),i.call(n+`_mul`,u,g,u),i.call(n+`_sub`,u,y,u),i.call(n+`_add`,v,v,d))}function h(){let r=e.addFunction(t+`_doubleAffine`);r.addParam(`p1`,`i32`),r.addParam(`pr`,`i32`);let i=r.getCodeBuilder(),o=i.getLocal(`p1`),s=i.i32_add(i.getLocal(`p1`),i.i32_const(a)),c=i.getLocal(`pr`),l=i.i32_add(i.getLocal(`pr`),i.i32_const(a)),u=i.i32_add(i.getLocal(`pr`),i.i32_const(a*2)),d=i.i32_const(e.alloc(a)),f=i.i32_const(e.alloc(a)),p=i.i32_const(e.alloc(a)),m=i.i32_const(e.alloc(a)),h=i.i32_const(e.alloc(a)),g=i.i32_const(e.alloc(a));r.addCode(i.if(i.call(t+`_isZeroAffine`,i.getLocal(`p1`)),[...i.call(t+`_toJacobian`,i.getLocal(`p1`),i.getLocal(`pr`)),...i.ret([])]),i.call(n+`_square`,o,d),i.call(n+`_square`,s,f),i.call(n+`_square`,f,p),i.call(n+`_add`,o,f,m),i.call(n+`_square`,m,m),i.call(n+`_sub`,m,d,m),i.call(n+`_sub`,m,p,m),i.call(n+`_add`,m,m,m),i.call(n+`_add`,d,d,h),i.call(n+`_add`,h,d,h),i.call(n+`_add`,s,s,u),i.call(n+`_square`,h,c),i.call(n+`_sub`,c,m,c),i.call(n+`_sub`,c,m,c),i.call(n+`_add`,p,p,g),i.call(n+`_add`,g,g,g),i.call(n+`_add`,g,g,g),i.call(n+`_sub`,m,c,l),i.call(n+`_mul`,l,h,l),i.call(n+`_sub`,l,g,l))}function g(){let r=e.addFunction(t+`_eqAffine`);r.addParam(`p1`,`i32`),r.addParam(`p2`,`i32`),r.setReturnType(`i32`),r.addLocal(`z1`,`i32`);let i=r.getCodeBuilder();r.addCode(i.ret(i.i32_and(i.call(n+`_eq`,i.getLocal(`p1`),i.getLocal(`p2`)),i.call(n+`_eq`,i.i32_add(i.getLocal(`p1`),i.i32_const(a)),i.i32_add(i.getLocal(`p2`),i.i32_const(a))))))}function _(){let r=e.addFunction(t+`_toMontgomery`);r.addParam(`p1`,`i32`),r.addParam(`pr`,`i32`);let i=r.getCodeBuilder();r.addCode(i.call(n+`_toMontgomery`,i.getLocal(`p1`),i.getLocal(`pr`)));for(let e=1;e<3;e++)r.addCode(i.call(n+`_toMontgomery`,i.i32_add(i.getLocal(`p1`),i.i32_const(e*a)),i.i32_add(i.getLocal(`pr`),i.i32_const(e*a))))}function v(){let r=e.addFunction(t+`_toMontgomeryAffine`);r.addParam(`p1`,`i32`),r.addParam(`pr`,`i32`);let i=r.getCodeBuilder();r.addCode(i.call(n+`_toMontgomery`,i.getLocal(`p1`),i.getLocal(`pr`)));for(let e=1;e<2;e++)r.addCode(i.call(n+`_toMontgomery`,i.i32_add(i.getLocal(`p1`),i.i32_const(e*a)),i.i32_add(i.getLocal(`pr`),i.i32_const(e*a))))}function y(){let r=e.addFunction(t+`_fromMontgomery`);r.addParam(`p1`,`i32`),r.addParam(`pr`,`i32`);let i=r.getCodeBuilder();r.addCode(i.call(n+`_fromMontgomery`,i.getLocal(`p1`),i.getLocal(`pr`)));for(let e=1;e<3;e++)r.addCode(i.call(n+`_fromMontgomery`,i.i32_add(i.getLocal(`p1`),i.i32_const(e*a)),i.i32_add(i.getLocal(`pr`),i.i32_const(e*a))))}function b(){let r=e.addFunction(t+`_fromMontgomeryAffine`);r.addParam(`p1`,`i32`),r.addParam(`pr`,`i32`);let i=r.getCodeBuilder();r.addCode(i.call(n+`_fromMontgomery`,i.getLocal(`p1`),i.getLocal(`pr`)));for(let e=1;e<2;e++)r.addCode(i.call(n+`_fromMontgomery`,i.i32_add(i.getLocal(`p1`),i.i32_const(e*a)),i.i32_add(i.getLocal(`pr`),i.i32_const(e*a))))}function x(){let r=e.addFunction(t+`_add`);r.addParam(`p1`,`i32`),r.addParam(`p2`,`i32`),r.addParam(`pr`,`i32`),r.addLocal(`z1`,`i32`),r.addLocal(`z2`,`i32`);let i=r.getCodeBuilder(),o=i.getLocal(`p1`),s=i.i32_add(i.getLocal(`p1`),i.i32_const(a));r.addCode(i.setLocal(`z1`,i.i32_add(i.getLocal(`p1`),i.i32_const(a*2))));let c=i.getLocal(`z1`),l=i.getLocal(`p2`),u=i.i32_add(i.getLocal(`p2`),i.i32_const(a));r.addCode(i.setLocal(`z2`,i.i32_add(i.getLocal(`p2`),i.i32_const(a*2))));let d=i.getLocal(`z2`),f=i.getLocal(`pr`),p=i.i32_add(i.getLocal(`pr`),i.i32_const(a)),m=i.i32_add(i.getLocal(`pr`),i.i32_const(a*2)),h=i.i32_const(e.alloc(a)),g=i.i32_const(e.alloc(a)),_=i.i32_const(e.alloc(a)),v=i.i32_const(e.alloc(a)),y=i.i32_const(e.alloc(a)),b=i.i32_const(e.alloc(a)),x=i.i32_const(e.alloc(a)),S=i.i32_const(e.alloc(a)),C=i.i32_const(e.alloc(a)),w=i.i32_const(e.alloc(a)),T=i.i32_const(e.alloc(a)),E=i.i32_const(e.alloc(a)),D=i.i32_const(e.alloc(a)),O=i.i32_const(e.alloc(a)),k=i.i32_const(e.alloc(a)),A=i.i32_const(e.alloc(a)),j=i.i32_const(e.alloc(a));r.addCode(i.if(i.call(t+`_isZero`,i.getLocal(`p1`)),[...i.call(t+`_copy`,i.getLocal(`p2`),i.getLocal(`pr`)),...i.ret([])]),i.if(i.call(t+`_isZero`,i.getLocal(`p2`)),[...i.call(t+`_copy`,i.getLocal(`p1`),i.getLocal(`pr`)),...i.ret([])]),i.if(i.call(n+`_isOne`,c),[...i.call(t+`_addMixed`,l,o,f),...i.ret([])]),i.if(i.call(n+`_isOne`,d),[...i.call(t+`_addMixed`,o,l,f),...i.ret([])]),i.call(n+`_square`,c,h),i.call(n+`_square`,d,g),i.call(n+`_mul`,o,g,_),i.call(n+`_mul`,l,h,v),i.call(n+`_mul`,c,h,y),i.call(n+`_mul`,d,g,b),i.call(n+`_mul`,s,b,x),i.call(n+`_mul`,u,y,S),i.if(i.call(n+`_eq`,_,v),i.if(i.call(n+`_eq`,x,S),[...i.call(t+`_double`,i.getLocal(`p1`),i.getLocal(`pr`)),...i.ret([])])),i.call(n+`_sub`,v,_,C),i.call(n+`_sub`,S,x,w),i.call(n+`_add`,C,C,T),i.call(n+`_square`,T,T),i.call(n+`_mul`,C,T,E),i.call(n+`_add`,w,w,D),i.call(n+`_mul`,_,T,k),i.call(n+`_square`,D,O),i.call(n+`_add`,k,k,A),i.call(n+`_sub`,O,E,f),i.call(n+`_sub`,f,A,f),i.call(n+`_mul`,x,E,j),i.call(n+`_add`,j,j,j),i.call(n+`_sub`,k,f,p),i.call(n+`_mul`,p,D,p),i.call(n+`_sub`,p,j,p),i.call(n+`_add`,c,d,m),i.call(n+`_square`,m,m),i.call(n+`_sub`,m,h,m),i.call(n+`_sub`,m,g,m),i.call(n+`_mul`,m,C,m))}function S(){let r=e.addFunction(t+`_addMixed`);r.addParam(`p1`,`i32`),r.addParam(`p2`,`i32`),r.addParam(`pr`,`i32`),r.addLocal(`z1`,`i32`);let i=r.getCodeBuilder(),o=i.getLocal(`p1`),s=i.i32_add(i.getLocal(`p1`),i.i32_const(a));r.addCode(i.setLocal(`z1`,i.i32_add(i.getLocal(`p1`),i.i32_const(a*2))));let c=i.getLocal(`z1`),l=i.getLocal(`p2`),u=i.i32_add(i.getLocal(`p2`),i.i32_const(a)),d=i.getLocal(`pr`),f=i.i32_add(i.getLocal(`pr`),i.i32_const(a)),p=i.i32_add(i.getLocal(`pr`),i.i32_const(a*2)),m=i.i32_const(e.alloc(a)),h=i.i32_const(e.alloc(a)),g=i.i32_const(e.alloc(a)),_=i.i32_const(e.alloc(a)),v=i.i32_const(e.alloc(a)),y=i.i32_const(e.alloc(a)),b=i.i32_const(e.alloc(a)),x=i.i32_const(e.alloc(a)),S=i.i32_const(e.alloc(a)),C=i.i32_const(e.alloc(a)),w=i.i32_const(e.alloc(a)),T=i.i32_const(e.alloc(a)),E=i.i32_const(e.alloc(a)),D=i.i32_const(e.alloc(a));r.addCode(i.if(i.call(t+`_isZero`,i.getLocal(`p1`)),[...i.call(t+`_copyAffine`,i.getLocal(`p2`),i.getLocal(`pr`)),...i.call(n+`_one`,i.i32_add(i.getLocal(`pr`),i.i32_const(a*2))),...i.ret([])]),i.if(i.call(t+`_isZeroAffine`,i.getLocal(`p2`)),[...i.call(t+`_copy`,i.getLocal(`p1`),i.getLocal(`pr`)),...i.ret([])]),i.if(i.call(n+`_isOne`,c),[...i.call(t+`_addAffine`,o,l,d),...i.ret([])]),i.call(n+`_square`,c,m),i.call(n+`_mul`,l,m,h),i.call(n+`_mul`,c,m,g),i.call(n+`_mul`,u,g,_),i.if(i.call(n+`_eq`,o,h),i.if(i.call(n+`_eq`,s,_),[...i.call(t+`_doubleAffine`,i.getLocal(`p2`),i.getLocal(`pr`)),...i.ret([])])),i.call(n+`_sub`,h,o,v),i.call(n+`_sub`,_,s,b),i.call(n+`_square`,v,y),i.call(n+`_add`,y,y,x),i.call(n+`_add`,x,x,x),i.call(n+`_mul`,v,x,S),i.call(n+`_add`,b,b,C),i.call(n+`_mul`,o,x,T),i.call(n+`_square`,C,w),i.call(n+`_add`,T,T,E),i.call(n+`_sub`,w,S,d),i.call(n+`_sub`,d,E,d),i.call(n+`_mul`,s,S,D),i.call(n+`_add`,D,D,D),i.call(n+`_sub`,T,d,f),i.call(n+`_mul`,f,C,f),i.call(n+`_sub`,f,D,f),i.call(n+`_add`,c,v,p),i.call(n+`_square`,p,p),i.call(n+`_sub`,p,m,p),i.call(n+`_sub`,p,y,p))}function C(){let r=e.addFunction(t+`_addAffine`);r.addParam(`p1`,`i32`),r.addParam(`p2`,`i32`),r.addParam(`pr`,`i32`),r.addLocal(`z1`,`i32`);let i=r.getCodeBuilder(),o=i.getLocal(`p1`),s=i.i32_add(i.getLocal(`p1`),i.i32_const(a));r.addCode(i.setLocal(`z1`,i.i32_add(i.getLocal(`p1`),i.i32_const(a*2))));let c=i.getLocal(`p2`),l=i.i32_add(i.getLocal(`p2`),i.i32_const(a)),u=i.getLocal(`pr`),d=i.i32_add(i.getLocal(`pr`),i.i32_const(a)),f=i.i32_add(i.getLocal(`pr`),i.i32_const(a*2)),p=i.i32_const(e.alloc(a)),m=i.i32_const(e.alloc(a)),h=i.i32_const(e.alloc(a)),g=i.i32_const(e.alloc(a)),_=i.i32_const(e.alloc(a)),v=i.i32_const(e.alloc(a)),y=i.i32_const(e.alloc(a)),b=i.i32_const(e.alloc(a)),x=i.i32_const(e.alloc(a)),S=i.i32_const(e.alloc(a));r.addCode(i.if(i.call(t+`_isZeroAffine`,i.getLocal(`p1`)),[...i.call(t+`_copyAffine`,i.getLocal(`p2`),i.getLocal(`pr`)),...i.call(n+`_one`,i.i32_add(i.getLocal(`pr`),i.i32_const(a*2))),...i.ret([])]),i.if(i.call(t+`_isZeroAffine`,i.getLocal(`p2`)),[...i.call(t+`_copyAffine`,i.getLocal(`p1`),i.getLocal(`pr`)),...i.call(n+`_one`,i.i32_add(i.getLocal(`pr`),i.i32_const(a*2))),...i.ret([])]),i.if(i.call(n+`_eq`,o,c),i.if(i.call(n+`_eq`,s,l),[...i.call(t+`_doubleAffine`,i.getLocal(`p2`),i.getLocal(`pr`)),...i.ret([])])),i.call(n+`_sub`,c,o,p),i.call(n+`_sub`,l,s,h),i.call(n+`_square`,p,m),i.call(n+`_add`,m,m,g),i.call(n+`_add`,g,g,g),i.call(n+`_mul`,p,g,_),i.call(n+`_add`,h,h,v),i.call(n+`_mul`,o,g,b),i.call(n+`_square`,v,y),i.call(n+`_add`,b,b,x),i.call(n+`_sub`,y,_,u),i.call(n+`_sub`,u,x,u),i.call(n+`_mul`,s,_,S),i.call(n+`_add`,S,S,S),i.call(n+`_sub`,b,u,d),i.call(n+`_mul`,d,v,d),i.call(n+`_sub`,d,S,d),i.call(n+`_add`,p,p,f))}function w(){let r=e.addFunction(t+`_neg`);r.addParam(`p1`,`i32`),r.addParam(`pr`,`i32`);let i=r.getCodeBuilder(),o=i.getLocal(`p1`),s=i.i32_add(i.getLocal(`p1`),i.i32_const(a)),c=i.i32_add(i.getLocal(`p1`),i.i32_const(a*2)),l=i.getLocal(`pr`),u=i.i32_add(i.getLocal(`pr`),i.i32_const(a)),d=i.i32_add(i.getLocal(`pr`),i.i32_const(a*2));r.addCode(i.call(n+`_copy`,o,l),i.call(n+`_neg`,s,u),i.call(n+`_copy`,c,d))}function T(){let r=e.addFunction(t+`_negAffine`);r.addParam(`p1`,`i32`),r.addParam(`pr`,`i32`);let i=r.getCodeBuilder(),o=i.getLocal(`p1`),s=i.i32_add(i.getLocal(`p1`),i.i32_const(a)),c=i.getLocal(`pr`),l=i.i32_add(i.getLocal(`pr`),i.i32_const(a));r.addCode(i.call(n+`_copy`,o,c),i.call(n+`_neg`,s,l))}function E(){let n=e.addFunction(t+`_sub`);n.addParam(`p1`,`i32`),n.addParam(`p2`,`i32`),n.addParam(`pr`,`i32`);let r=n.getCodeBuilder(),i=r.i32_const(e.alloc(a*3));n.addCode(r.call(t+`_neg`,r.getLocal(`p2`),i),r.call(t+`_add`,r.getLocal(`p1`),i,r.getLocal(`pr`)))}function D(){let n=e.addFunction(t+`_subMixed`);n.addParam(`p1`,`i32`),n.addParam(`p2`,`i32`),n.addParam(`pr`,`i32`);let r=n.getCodeBuilder(),i=r.i32_const(e.alloc(a*3));n.addCode(r.call(t+`_negAffine`,r.getLocal(`p2`),i),r.call(t+`_addMixed`,r.getLocal(`p1`),i,r.getLocal(`pr`)))}function O(){let n=e.addFunction(t+`_subAffine`);n.addParam(`p1`,`i32`),n.addParam(`p2`,`i32`),n.addParam(`pr`,`i32`);let r=n.getCodeBuilder(),i=r.i32_const(e.alloc(a*3));n.addCode(r.call(t+`_negAffine`,r.getLocal(`p2`),i),r.call(t+`_addAffine`,r.getLocal(`p1`),i,r.getLocal(`pr`)))}function k(){let r=e.addFunction(t+`_normalize`);r.addParam(`p1`,`i32`),r.addParam(`pr`,`i32`);let i=r.getCodeBuilder(),o=i.getLocal(`p1`),s=i.i32_add(i.getLocal(`p1`),i.i32_const(a)),c=i.i32_add(i.getLocal(`p1`),i.i32_const(a*2)),l=i.getLocal(`pr`),u=i.i32_add(i.getLocal(`pr`),i.i32_const(a)),d=i.i32_add(i.getLocal(`pr`),i.i32_const(a*2)),f=i.i32_const(e.alloc(a)),p=i.i32_const(e.alloc(a)),m=i.i32_const(e.alloc(a));r.addCode(i.if(i.call(t+`_isZero`,i.getLocal(`p1`)),i.call(t+`_zero`,i.getLocal(`pr`)),[...i.call(n+`_inverse`,c,f),...i.call(n+`_square`,f,p),...i.call(n+`_mul`,f,p,m),...i.call(n+`_mul`,o,p,l),...i.call(n+`_mul`,s,m,u),...i.call(n+`_one`,d)]))}function A(){let r=e.addFunction(t+`_toAffine`);r.addParam(`p1`,`i32`),r.addParam(`pr`,`i32`);let i=r.getCodeBuilder(),o=i.getLocal(`p1`),s=i.i32_add(i.getLocal(`p1`),i.i32_const(a)),c=i.i32_add(i.getLocal(`p1`),i.i32_const(a*2)),l=i.getLocal(`pr`),u=i.i32_add(i.getLocal(`pr`),i.i32_const(a)),d=i.i32_const(e.alloc(a)),f=i.i32_const(e.alloc(a)),p=i.i32_const(e.alloc(a));r.addCode(i.if(i.call(t+`_isZero`,i.getLocal(`p1`)),[...i.call(n+`_zero`,l),...i.call(n+`_zero`,u)],[...i.call(n+`_inverse`,c,d),...i.call(n+`_square`,d,f),...i.call(n+`_mul`,d,f,p),...i.call(n+`_mul`,o,f,l),...i.call(n+`_mul`,s,p,u)]))}function j(){let r=e.addFunction(t+`_toJacobian`);r.addParam(`p1`,`i32`),r.addParam(`pr`,`i32`);let i=r.getCodeBuilder(),o=i.getLocal(`p1`),s=i.i32_add(i.getLocal(`p1`),i.i32_const(a)),c=i.getLocal(`pr`),l=i.i32_add(i.getLocal(`pr`),i.i32_const(a)),u=i.i32_add(i.getLocal(`pr`),i.i32_const(a*2));r.addCode(i.if(i.call(t+`_isZeroAffine`,i.getLocal(`p1`)),i.call(t+`_zero`,i.getLocal(`pr`)),[...i.call(n+`_one`,u),...i.call(n+`_copy`,s,l),...i.call(n+`_copy`,o,c)]))}function ee(){let r=e.addFunction(t+`_batchToAffine`);r.addParam(`pIn`,`i32`),r.addParam(`n`,`i32`),r.addParam(`pOut`,`i32`),r.addLocal(`pAux`,`i32`),r.addLocal(`itIn`,`i32`),r.addLocal(`itAux`,`i32`),r.addLocal(`itOut`,`i32`),r.addLocal(`i`,`i32`);let i=r.getCodeBuilder(),o=i.i32_const(e.alloc(a));r.addCode(i.setLocal(`pAux`,i.i32_load(i.i32_const(0))),i.i32_store(i.i32_const(0),i.i32_add(i.getLocal(`pAux`),i.i32_mul(i.getLocal(`n`),i.i32_const(a)))),i.call(n+`_batchInverse`,i.i32_add(i.getLocal(`pIn`),i.i32_const(a*2)),i.i32_const(a*3),i.getLocal(`n`),i.getLocal(`pAux`),i.i32_const(a)),i.setLocal(`itIn`,i.getLocal(`pIn`)),i.setLocal(`itAux`,i.getLocal(`pAux`)),i.setLocal(`itOut`,i.getLocal(`pOut`)),i.setLocal(`i`,i.i32_const(0)),i.block(i.loop(i.br_if(1,i.i32_eq(i.getLocal(`i`),i.getLocal(`n`))),i.if(i.call(n+`_isZero`,i.getLocal(`itAux`)),[...i.call(n+`_zero`,i.getLocal(`itOut`)),...i.call(n+`_zero`,i.i32_add(i.getLocal(`itOut`),i.i32_const(a)))],[...i.call(n+`_mul`,i.getLocal(`itAux`),i.i32_add(i.getLocal(`itIn`),i.i32_const(a)),o),...i.call(n+`_square`,i.getLocal(`itAux`),i.getLocal(`itAux`)),...i.call(n+`_mul`,i.getLocal(`itAux`),i.getLocal(`itIn`),i.getLocal(`itOut`)),...i.call(n+`_mul`,i.getLocal(`itAux`),o,i.i32_add(i.getLocal(`itOut`),i.i32_const(a)))]),i.setLocal(`itIn`,i.i32_add(i.getLocal(`itIn`),i.i32_const(a*3))),i.setLocal(`itOut`,i.i32_add(i.getLocal(`itOut`),i.i32_const(a*2))),i.setLocal(`itAux`,i.i32_add(i.getLocal(`itAux`),i.i32_const(a))),i.setLocal(`i`,i.i32_add(i.getLocal(`i`),i.i32_const(1))),i.br(0))),i.i32_store(i.i32_const(0),i.getLocal(`pAux`)))}function M(){let n=e.addFunction(t+`__reverseBytes`);n.addParam(`pIn`,`i32`),n.addParam(`n`,`i32`),n.addParam(`pOut`,`i32`),n.addLocal(`itOut`,`i32`),n.addLocal(`itIn`,`i32`);let r=n.getCodeBuilder();n.addCode(r.setLocal(`itOut`,r.i32_sub(r.i32_add(r.getLocal(`pOut`),r.getLocal(`n`)),r.i32_const(1))),r.setLocal(`itIn`,r.getLocal(`pIn`)),r.block(r.loop(r.br_if(1,r.i32_lt_s(r.getLocal(`itOut`),r.getLocal(`pOut`))),r.i32_store8(r.getLocal(`itOut`),r.i32_load8_u(r.getLocal(`itIn`))),r.setLocal(`itOut`,r.i32_sub(r.getLocal(`itOut`),r.i32_const(1))),r.setLocal(`itIn`,r.i32_add(r.getLocal(`itIn`),r.i32_const(1))),r.br(0))))}function N(){let r=e.addFunction(t+`_LEMtoC`);r.addParam(`pIn`,`i32`),r.addParam(`pOut`,`i32`);let i=r.getCodeBuilder(),o=i.i32_const(e.alloc(a));r.addCode(i.if(i.call(t+`_isZeroAffine`,i.getLocal(`pIn`)),[...i.call(n+`_zero`,i.getLocal(`pOut`)),...i.i32_store8(i.getLocal(`pOut`),i.i32_const(64)),...i.ret([])]),i.call(n+`_fromMontgomery`,i.getLocal(`pIn`),o),i.call(t+`__reverseBytes`,o,i.i32_const(a),i.getLocal(`pOut`)),i.if(i.i32_eq(i.call(n+`_sign`,i.i32_add(i.getLocal(`pIn`),i.i32_const(a))),i.i32_const(-1)),i.i32_store8(i.getLocal(`pOut`),i.i32_or(i.i32_load8_u(i.getLocal(`pOut`)),i.i32_const(128)))))}function P(){let n=e.addFunction(t+`_LEMtoU`);n.addParam(`pIn`,`i32`),n.addParam(`pOut`,`i32`);let r=n.getCodeBuilder(),i=e.alloc(a*2),o=r.i32_const(i),s=r.i32_const(i),c=r.i32_const(i+a);n.addCode(r.if(r.call(t+`_isZeroAffine`,r.getLocal(`pIn`)),[...r.call(t+`_zeroAffine`,r.getLocal(`pOut`)),...r.ret([])]),r.call(t+`_fromMontgomeryAffine`,r.getLocal(`pIn`),o),r.call(t+`__reverseBytes`,s,r.i32_const(a),r.getLocal(`pOut`)),r.call(t+`__reverseBytes`,c,r.i32_const(a),r.i32_add(r.getLocal(`pOut`),r.i32_const(a))))}function F(){let n=e.addFunction(t+`_UtoLEM`);n.addParam(`pIn`,`i32`),n.addParam(`pOut`,`i32`);let r=n.getCodeBuilder(),i=e.alloc(a*2),o=r.i32_const(i),s=r.i32_const(i),c=r.i32_const(i+a);n.addCode(r.if(r.i32_and(r.i32_load8_u(r.getLocal(`pIn`)),r.i32_const(64)),[...r.call(t+`_zeroAffine`,r.getLocal(`pOut`)),...r.ret([])]),r.call(t+`__reverseBytes`,r.getLocal(`pIn`),r.i32_const(a),s),r.call(t+`__reverseBytes`,r.i32_add(r.getLocal(`pIn`),r.i32_const(a)),r.i32_const(a),c),r.call(t+`_toMontgomeryAffine`,o,r.getLocal(`pOut`)))}function te(){let i=e.addFunction(t+`_CtoLEM`);i.addParam(`pIn`,`i32`),i.addParam(`pOut`,`i32`),i.addLocal(`firstByte`,`i32`),i.addLocal(`greatest`,`i32`);let o=i.getCodeBuilder(),s=e.alloc(a*2),c=o.i32_const(s),l=o.i32_const(s+a);i.addCode(o.setLocal(`firstByte`,o.i32_load8_u(o.getLocal(`pIn`))),o.if(o.i32_and(o.getLocal(`firstByte`),o.i32_const(64)),[...o.call(t+`_zeroAffine`,o.getLocal(`pOut`)),...o.ret([])]),o.setLocal(`greatest`,o.i32_and(o.getLocal(`firstByte`),o.i32_const(128))),o.call(n+`_copy`,o.getLocal(`pIn`),l),o.i32_store8(l,o.i32_and(o.getLocal(`firstByte`),o.i32_const(63))),o.call(t+`__reverseBytes`,l,o.i32_const(a),c),o.call(n+`_toMontgomery`,c,o.getLocal(`pOut`)),o.call(n+`_square`,o.getLocal(`pOut`),l),o.call(n+`_mul`,o.getLocal(`pOut`),l,l),o.call(n+`_add`,l,o.i32_const(r),l),o.call(n+`_sqrt`,l,l),o.call(n+`_neg`,l,c),o.if(o.i32_eq(o.call(n+`_sign`,l),o.i32_const(-1)),o.if(o.getLocal(`greatest`),o.call(n+`_copy`,l,o.i32_add(o.getLocal(`pOut`),o.i32_const(a))),o.call(n+`_neg`,l,o.i32_add(o.getLocal(`pOut`),o.i32_const(a)))),o.if(o.getLocal(`greatest`),o.call(n+`_neg`,l,o.i32_add(o.getLocal(`pOut`),o.i32_const(a))),o.call(n+`_copy`,l,o.i32_add(o.getLocal(`pOut`),o.i32_const(a))))))}function I(){let i=e.addFunction(t+`_inCurveAffine`);i.addParam(`pIn`,`i32`),i.setReturnType(`i32`);let o=i.getCodeBuilder(),s=o.getLocal(`pIn`),c=o.i32_add(o.getLocal(`pIn`),o.i32_const(a)),l=o.i32_const(e.alloc(a)),u=o.i32_const(e.alloc(a));i.addCode(o.call(n+`_square`,c,l),o.call(n+`_square`,s,u),o.call(n+`_mul`,s,u,u),o.call(n+`_add`,u,o.i32_const(r),u),o.ret(o.call(n+`_eq`,l,u)))}function L(){let n=e.addFunction(t+`_inCurve`);n.addParam(`pIn`,`i32`),n.setReturnType(`i32`);let r=n.getCodeBuilder(),i=r.i32_const(e.alloc(a*2));n.addCode(r.call(t+`_toAffine`,r.getLocal(`pIn`),i),r.ret(r.call(t+`_inCurveAffine`,i)))}return s(),o(),d(),u(),l(),c(),j(),g(),p(),f(),h(),m(),C(),S(),x(),T(),w(),O(),D(),E(),b(),y(),v(),_(),A(),I(),L(),ee(),k(),M(),P(),N(),F(),te(),_n(e,t+`_batchLEMtoU`,t+`_LEMtoU`,a*2,a*2),_n(e,t+`_batchLEMtoC`,t+`_LEMtoC`,a*2,a),_n(e,t+`_batchUtoLEM`,t+`_UtoLEM`,a*2,a*2),_n(e,t+`_batchCtoLEM`,t+`_CtoLEM`,a,a*2,!0),_n(e,t+`_batchToJacobian`,t+`_toJacobian`,a*2,a*3,!0),vn(e,t,t+`_multiexp`,t+`_add`,a*3),vn(e,t,t+`_multiexpAffine`,t+`_addMixed`,a*2),gn(e,t+`_timesScalar`,a*3,t+`_add`,t+`_double`,t+`_sub`,t+`_copy`,t+`_zero`),gn(e,t+`_timesScalarAffine`,a*2,t+`_addMixed`,t+`_double`,t+`_subMixed`,t+`_copyAffine`,t+`_zero`),e.exportFunction(t+`_isZero`),e.exportFunction(t+`_isZeroAffine`),e.exportFunction(t+`_eq`),e.exportFunction(t+`_eqMixed`),e.exportFunction(t+`_eqAffine`),e.exportFunction(t+`_copy`),e.exportFunction(t+`_copyAffine`),e.exportFunction(t+`_zero`),e.exportFunction(t+`_zeroAffine`),e.exportFunction(t+`_double`),e.exportFunction(t+`_doubleAffine`),e.exportFunction(t+`_add`),e.exportFunction(t+`_addMixed`),e.exportFunction(t+`_addAffine`),e.exportFunction(t+`_neg`),e.exportFunction(t+`_negAffine`),e.exportFunction(t+`_sub`),e.exportFunction(t+`_subMixed`),e.exportFunction(t+`_subAffine`),e.exportFunction(t+`_fromMontgomery`),e.exportFunction(t+`_fromMontgomeryAffine`),e.exportFunction(t+`_toMontgomery`),e.exportFunction(t+`_toMontgomeryAffine`),e.exportFunction(t+`_timesScalar`),e.exportFunction(t+`_timesScalarAffine`),e.exportFunction(t+`_normalize`),e.exportFunction(t+`_LEMtoU`),e.exportFunction(t+`_LEMtoC`),e.exportFunction(t+`_UtoLEM`),e.exportFunction(t+`_CtoLEM`),e.exportFunction(t+`_batchLEMtoU`),e.exportFunction(t+`_batchLEMtoC`),e.exportFunction(t+`_batchUtoLEM`),e.exportFunction(t+`_batchCtoLEM`),e.exportFunction(t+`_toAffine`),e.exportFunction(t+`_toJacobian`),e.exportFunction(t+`_batchToAffine`),e.exportFunction(t+`_batchToJacobian`),e.exportFunction(t+`_inCurve`),e.exportFunction(t+`_inCurveAffine`),t};const{isOdd:bn,modInv:xn,modPow:Sn}=Et,Cn=_t;var wn=function(e,t,n,r,i){let a=e.modules[r].n64*8,o=e.modules[n].n64*8,s=e.modules[r].q,c=s-1n,l=0;for(;!bn(c);)l++,c>>=1n;let u=2n;for(;Sn(u,s>>1n,s)===1n;)u+=1n;let d=Array(l+1);d[l]=Sn(u,c,s);let f=l-1;for(;f>=0;)d[f]=Sn(d[f+1],2n,s),f--;let p=[],m=(1n<<BigInt(a*8))%s;for(let e=0;e<d.length;e++){let t=d[e]*m%s;p.push(...Cn.bigInt2BytesLE(t,a))}let h=e.alloc(p),g=Array(l+1);g[0]=1n;for(let e=1;e<=l;e++)g[e]=g[e-1]*2n;let _=[];for(let e=0;e<=l;e++){let t=xn(g[e],s)*m%s;_.push(...Cn.bigInt2BytesLE(t,a))}let v=e.alloc(_),y=Sn(u,2n,s),b=[],x=[];for(let e=0;e<=l;e++){let t=Sn(y,2n**BigInt(e),s),n=xn(s+1n-t,s);b.push(...Cn.bigInt2BytesLE(t*m%s,a)),x.push(...Cn.bigInt2BytesLE(n*m%s,a))}let S=e.alloc(b),C=e.alloc(x);function w(e){let t=0;for(let n=0;n<8;n++)e&1<<n&&(t|=128>>n);return t}let T=Array(256);for(let e=0;e<256;e++)T[e]=w(e);let E=e.alloc(T);function D(){let n=e.addFunction(t+`__log2`);n.addParam(`n`,`i32`),n.setReturnType(`i32`),n.addLocal(`bits`,`i32`),n.addLocal(`aux`,`i32`);let r=n.getCodeBuilder();n.addCode(r.setLocal(`aux`,r.i32_shr_u(r.getLocal(`n`),r.i32_const(1)))),n.addCode(r.setLocal(`bits`,r.i32_const(0))),n.addCode(r.block(r.loop(r.br_if(1,r.i32_eqz(r.getLocal(`aux`))),r.setLocal(`aux`,r.i32_shr_u(r.getLocal(`aux`),r.i32_const(1))),r.setLocal(`bits`,r.i32_add(r.getLocal(`bits`),r.i32_const(1))),r.br(0)))),n.addCode(r.if(r.i32_ne(r.getLocal(`n`),r.i32_shl(r.i32_const(1),r.getLocal(`bits`))),r.unreachable())),n.addCode(r.if(r.i32_gt_u(r.getLocal(`bits`),r.i32_const(l)),r.unreachable())),n.addCode(r.getLocal(`bits`))}function O(){let n=e.addFunction(t+`_fft`);n.addParam(`px`,`i32`),n.addParam(`n`,`i32`),n.addLocal(`bits`,`i32`);let i=n.getCodeBuilder(),o=i.i32_const(e.alloc(a));n.addCode(i.setLocal(`bits`,i.call(t+`__log2`,i.getLocal(`n`))),i.call(r+`_one`,o),i.call(t+`_rawfft`,i.getLocal(`px`),i.getLocal(`bits`),i.i32_const(0),o))}function k(){let n=e.addFunction(t+`_ifft`);n.addParam(`px`,`i32`),n.addParam(`n`,`i32`),n.addLocal(`bits`,`i32`),n.addLocal(`pInv2`,`i32`);let r=n.getCodeBuilder();n.addCode(r.setLocal(`bits`,r.call(t+`__log2`,r.getLocal(`n`))),r.setLocal(`pInv2`,r.i32_add(r.i32_const(v),r.i32_mul(r.getLocal(`bits`),r.i32_const(a)))),r.call(t+`_rawfft`,r.getLocal(`px`),r.getLocal(`bits`),r.i32_const(1),r.getLocal(`pInv2`)))}function A(){let s=e.addFunction(t+`_rawfft`);s.addParam(`px`,`i32`),s.addParam(`bits`,`i32`),s.addParam(`reverse`,`i32`),s.addParam(`mulFactor`,`i32`),s.addLocal(`s`,`i32`),s.addLocal(`k`,`i32`),s.addLocal(`j`,`i32`),s.addLocal(`m`,`i32`),s.addLocal(`mdiv2`,`i32`),s.addLocal(`n`,`i32`),s.addLocal(`pwm`,`i32`),s.addLocal(`idx1`,`i32`),s.addLocal(`idx2`,`i32`);let c=s.getCodeBuilder(),l=c.i32_const(e.alloc(a)),u=c.i32_const(e.alloc(o)),d=c.i32_const(e.alloc(o));s.addCode(c.call(t+`__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(h),c.i32_mul(c.getLocal(`s`),c.i32_const(a)))),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(r+`_one`,l),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(o)))),c.setLocal(`idx2`,c.i32_add(c.getLocal(`idx1`),c.i32_mul(c.getLocal(`mdiv2`),c.i32_const(o)))),c.call(i,c.getLocal(`idx2`),l,u),c.call(n+`_copy`,c.getLocal(`idx1`),d),c.call(n+`_add`,d,u,c.getLocal(`idx1`)),c.call(n+`_sub`,d,u,c.getLocal(`idx2`)),c.call(r+`_mul`,l,c.getLocal(`pwm`),l),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(t+`__fftFinal`,c.getLocal(`px`),c.getLocal(`bits`),c.getLocal(`reverse`),c.getLocal(`mulFactor`)))}function j(){let a=e.addFunction(t+`__fftFinal`);a.addParam(`px`,`i32`),a.addParam(`bits`,`i32`),a.addParam(`reverse`,`i32`),a.addParam(`mulFactor`,`i32`),a.addLocal(`n`,`i32`),a.addLocal(`ndiv2`,`i32`),a.addLocal(`pInv2`,`i32`),a.addLocal(`i`,`i32`),a.addLocal(`mask`,`i32`),a.addLocal(`idx1`,`i32`),a.addLocal(`idx2`,`i32`);let s=a.getCodeBuilder(),c=s.i32_const(e.alloc(o));a.addCode(s.if(s.i32_and(s.i32_eqz(s.getLocal(`reverse`)),s.call(r+`_isOne`,s.getLocal(`mulFactor`))),s.ret([])),s.setLocal(`n`,s.i32_shl(s.i32_const(1),s.getLocal(`bits`))),s.setLocal(`mask`,s.i32_sub(s.getLocal(`n`),s.i32_const(1))),s.setLocal(`i`,s.i32_const(1)),s.setLocal(`ndiv2`,s.i32_shr_u(s.getLocal(`n`),s.i32_const(1))),s.block(s.loop(s.br_if(1,s.i32_ge_u(s.getLocal(`i`),s.getLocal(`ndiv2`))),s.setLocal(`idx1`,s.i32_add(s.getLocal(`px`),s.i32_mul(s.getLocal(`i`),s.i32_const(o)))),s.setLocal(`idx2`,s.i32_add(s.getLocal(`px`),s.i32_mul(s.i32_sub(s.getLocal(`n`),s.getLocal(`i`)),s.i32_const(o)))),s.if(s.getLocal(`reverse`),s.if(s.call(r+`_isOne`,s.getLocal(`mulFactor`)),[...s.call(n+`_copy`,s.getLocal(`idx1`),c),...s.call(n+`_copy`,s.getLocal(`idx2`),s.getLocal(`idx1`)),...s.call(n+`_copy`,c,s.getLocal(`idx2`))],[...s.call(n+`_copy`,s.getLocal(`idx1`),c),...s.call(i,s.getLocal(`idx2`),s.getLocal(`mulFactor`),s.getLocal(`idx1`)),...s.call(i,c,s.getLocal(`mulFactor`),s.getLocal(`idx2`))]),s.if(s.call(r+`_isOne`,s.getLocal(`mulFactor`)),[],[...s.call(i,s.getLocal(`idx1`),s.getLocal(`mulFactor`),s.getLocal(`idx1`)),...s.call(i,s.getLocal(`idx2`),s.getLocal(`mulFactor`),s.getLocal(`idx2`))])),s.setLocal(`i`,s.i32_add(s.getLocal(`i`),s.i32_const(1))),s.br(0))),s.if(s.call(r+`_isOne`,s.getLocal(`mulFactor`)),[],[...s.call(i,s.getLocal(`px`),s.getLocal(`mulFactor`),s.getLocal(`px`)),...s.setLocal(`idx2`,s.i32_add(s.getLocal(`px`),s.i32_mul(s.getLocal(`ndiv2`),s.i32_const(o)))),...s.call(i,s.getLocal(`idx2`),s.getLocal(`mulFactor`),s.getLocal(`idx2`))]))}function ee(){let r=e.addFunction(t+`__reversePermutation`);r.addParam(`px`,`i32`),r.addParam(`bits`,`i32`),r.addLocal(`n`,`i32`),r.addLocal(`i`,`i32`),r.addLocal(`ri`,`i32`),r.addLocal(`idx1`,`i32`),r.addLocal(`idx2`,`i32`);let i=r.getCodeBuilder(),a=i.i32_const(e.alloc(o));r.addCode(i.setLocal(`n`,i.i32_shl(i.i32_const(1),i.getLocal(`bits`))),i.setLocal(`i`,i.i32_const(0)),i.block(i.loop(i.br_if(1,i.i32_eq(i.getLocal(`i`),i.getLocal(`n`))),i.setLocal(`idx1`,i.i32_add(i.getLocal(`px`),i.i32_mul(i.getLocal(`i`),i.i32_const(o)))),i.setLocal(`ri`,i.call(t+`__rev`,i.getLocal(`i`),i.getLocal(`bits`))),i.setLocal(`idx2`,i.i32_add(i.getLocal(`px`),i.i32_mul(i.getLocal(`ri`),i.i32_const(o)))),i.if(i.i32_lt_u(i.getLocal(`i`),i.getLocal(`ri`)),[...i.call(n+`_copy`,i.getLocal(`idx1`),a),...i.call(n+`_copy`,i.getLocal(`idx2`),i.getLocal(`idx1`)),...i.call(n+`_copy`,a,i.getLocal(`idx2`))]),i.setLocal(`i`,i.i32_add(i.getLocal(`i`),i.i32_const(1))),i.br(0))))}function M(){let n=e.addFunction(t+`__rev`);n.addParam(`x`,`i32`),n.addParam(`bits`,`i32`),n.setReturnType(`i32`);let r=n.getCodeBuilder();n.addCode(r.i32_rotl(r.i32_add(r.i32_add(r.i32_shl(r.i32_load8_u(r.i32_and(r.getLocal(`x`),r.i32_const(255)),E,0),r.i32_const(24)),r.i32_shl(r.i32_load8_u(r.i32_and(r.i32_shr_u(r.getLocal(`x`),r.i32_const(8)),r.i32_const(255)),E,0),r.i32_const(16))),r.i32_add(r.i32_shl(r.i32_load8_u(r.i32_and(r.i32_shr_u(r.getLocal(`x`),r.i32_const(16)),r.i32_const(255)),E,0),r.i32_const(8)),r.i32_load8_u(r.i32_and(r.i32_shr_u(r.getLocal(`x`),r.i32_const(24)),r.i32_const(255)),E,0))),r.getLocal(`bits`)))}function N(){let s=e.addFunction(t+`_fftJoin`);s.addParam(`pBuff1`,`i32`),s.addParam(`pBuff2`,`i32`),s.addParam(`n`,`i32`),s.addParam(`first`,`i32`),s.addParam(`inc`,`i32`),s.addLocal(`idx1`,`i32`),s.addLocal(`idx2`,`i32`),s.addLocal(`i`,`i32`);let c=s.getCodeBuilder(),l=c.i32_const(e.alloc(a)),u=c.i32_const(e.alloc(o)),d=c.i32_const(e.alloc(o));s.addCode(c.call(r+`_copy`,c.getLocal(`first`),l),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(o)))),c.setLocal(`idx2`,c.i32_add(c.getLocal(`pBuff2`),c.i32_mul(c.getLocal(`i`),c.i32_const(o)))),c.call(i,c.getLocal(`idx2`),l,u),c.call(n+`_copy`,c.getLocal(`idx1`),d),c.call(n+`_add`,d,u,c.getLocal(`idx1`)),c.call(n+`_sub`,d,u,c.getLocal(`idx2`)),c.call(r+`_mul`,l,c.getLocal(`inc`),l),c.setLocal(`i`,c.i32_add(c.getLocal(`i`),c.i32_const(1))),c.br(0))))}function P(){let s=e.addFunction(t+`_fftJoinExt`);s.addParam(`pBuff1`,`i32`),s.addParam(`pBuff2`,`i32`),s.addParam(`n`,`i32`),s.addParam(`first`,`i32`),s.addParam(`inc`,`i32`),s.addParam(`totalBits`,`i32`),s.addLocal(`idx1`,`i32`),s.addLocal(`idx2`,`i32`),s.addLocal(`i`,`i32`),s.addLocal(`pShiftToM`,`i32`);let c=s.getCodeBuilder(),l=c.i32_const(e.alloc(a)),u=c.i32_const(e.alloc(o));s.addCode(c.setLocal(`pShiftToM`,c.i32_add(c.i32_const(S),c.i32_mul(c.getLocal(`totalBits`),c.i32_const(a)))),c.call(r+`_copy`,c.getLocal(`first`),l),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(o)))),c.setLocal(`idx2`,c.i32_add(c.getLocal(`pBuff2`),c.i32_mul(c.getLocal(`i`),c.i32_const(o)))),c.call(n+`_add`,c.getLocal(`idx1`),c.getLocal(`idx2`),u),c.call(i,c.getLocal(`idx2`),c.getLocal(`pShiftToM`),c.getLocal(`idx2`)),c.call(n+`_add`,c.getLocal(`idx1`),c.getLocal(`idx2`),c.getLocal(`idx2`)),c.call(i,c.getLocal(`idx2`),l,c.getLocal(`idx2`)),c.call(n+`_copy`,u,c.getLocal(`idx1`)),c.call(r+`_mul`,l,c.getLocal(`inc`),l),c.setLocal(`i`,c.i32_add(c.getLocal(`i`),c.i32_const(1))),c.br(0))))}function F(){let s=e.addFunction(t+`_fftJoinExtInv`);s.addParam(`pBuff1`,`i32`),s.addParam(`pBuff2`,`i32`),s.addParam(`n`,`i32`),s.addParam(`first`,`i32`),s.addParam(`inc`,`i32`),s.addParam(`totalBits`,`i32`),s.addLocal(`idx1`,`i32`),s.addLocal(`idx2`,`i32`),s.addLocal(`i`,`i32`),s.addLocal(`pShiftToM`,`i32`),s.addLocal(`pSConst`,`i32`);let c=s.getCodeBuilder(),l=c.i32_const(e.alloc(a)),u=c.i32_const(e.alloc(o));s.addCode(c.setLocal(`pShiftToM`,c.i32_add(c.i32_const(S),c.i32_mul(c.getLocal(`totalBits`),c.i32_const(a)))),c.setLocal(`pSConst`,c.i32_add(c.i32_const(C),c.i32_mul(c.getLocal(`totalBits`),c.i32_const(a)))),c.call(r+`_copy`,c.getLocal(`first`),l),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(o)))),c.setLocal(`idx2`,c.i32_add(c.getLocal(`pBuff2`),c.i32_mul(c.getLocal(`i`),c.i32_const(o)))),c.call(i,c.getLocal(`idx2`),l,u),c.call(n+`_sub`,c.getLocal(`idx1`),u,c.getLocal(`idx2`)),c.call(i,c.getLocal(`idx2`),c.getLocal(`pSConst`),c.getLocal(`idx2`)),c.call(i,c.getLocal(`idx1`),c.getLocal(`pShiftToM`),c.getLocal(`idx1`)),c.call(n+`_sub`,u,c.getLocal(`idx1`),c.getLocal(`idx1`)),c.call(i,c.getLocal(`idx1`),c.getLocal(`pSConst`),c.getLocal(`idx1`)),c.call(r+`_mul`,l,c.getLocal(`inc`),l),c.setLocal(`i`,c.i32_add(c.getLocal(`i`),c.i32_const(1))),c.br(0))))}function te(){let s=e.addFunction(t+`_prepareLagrangeEvaluation`);s.addParam(`pBuff1`,`i32`),s.addParam(`pBuff2`,`i32`),s.addParam(`n`,`i32`),s.addParam(`first`,`i32`),s.addParam(`inc`,`i32`),s.addParam(`totalBits`,`i32`),s.addLocal(`idx1`,`i32`),s.addLocal(`idx2`,`i32`),s.addLocal(`i`,`i32`),s.addLocal(`pShiftToM`,`i32`),s.addLocal(`pSConst`,`i32`);let c=s.getCodeBuilder(),l=c.i32_const(e.alloc(a)),u=c.i32_const(e.alloc(o));s.addCode(c.setLocal(`pShiftToM`,c.i32_add(c.i32_const(S),c.i32_mul(c.getLocal(`totalBits`),c.i32_const(a)))),c.setLocal(`pSConst`,c.i32_add(c.i32_const(C),c.i32_mul(c.getLocal(`totalBits`),c.i32_const(a)))),c.call(r+`_copy`,c.getLocal(`first`),l),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(o)))),c.setLocal(`idx2`,c.i32_add(c.getLocal(`pBuff2`),c.i32_mul(c.getLocal(`i`),c.i32_const(o)))),c.call(i,c.getLocal(`idx1`),c.getLocal(`pShiftToM`),u),c.call(n+`_sub`,c.getLocal(`idx2`),u,u),c.call(n+`_sub`,c.getLocal(`idx1`),c.getLocal(`idx2`),c.getLocal(`idx2`)),c.call(i,u,c.getLocal(`pSConst`),c.getLocal(`idx1`)),c.call(i,c.getLocal(`idx2`),l,c.getLocal(`idx2`)),c.call(r+`_mul`,l,c.getLocal(`inc`),l),c.setLocal(`i`,c.i32_add(c.getLocal(`i`),c.i32_const(1))),c.br(0))))}function I(){let s=e.addFunction(t+`_fftMix`);s.addParam(`pBuff`,`i32`),s.addParam(`n`,`i32`),s.addParam(`exp`,`i32`),s.addLocal(`nGroups`,`i32`),s.addLocal(`nPerGroup`,`i32`),s.addLocal(`nPerGroupDiv2`,`i32`),s.addLocal(`pairOffset`,`i32`),s.addLocal(`idx1`,`i32`),s.addLocal(`idx2`,`i32`),s.addLocal(`i`,`i32`),s.addLocal(`j`,`i32`),s.addLocal(`pwm`,`i32`);let c=s.getCodeBuilder(),l=c.i32_const(e.alloc(a)),u=c.i32_const(e.alloc(o)),d=c.i32_const(e.alloc(o));s.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(o))),c.setLocal(`pwm`,c.i32_add(c.i32_const(h),c.i32_mul(c.getLocal(`exp`),c.i32_const(a)))),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(r+`_one`,l),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(o)))),c.setLocal(`idx2`,c.i32_add(c.getLocal(`idx1`),c.getLocal(`pairOffset`))),c.call(i,c.getLocal(`idx2`),l,u),c.call(n+`_copy`,c.getLocal(`idx1`),d),c.call(n+`_add`,d,u,c.getLocal(`idx1`)),c.call(n+`_sub`,d,u,c.getLocal(`idx2`)),c.call(r+`_mul`,l,c.getLocal(`pwm`),l),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))))}function L(){let r=e.addFunction(t+`_fftFinal`);r.addParam(`pBuff`,`i32`),r.addParam(`n`,`i32`),r.addParam(`factor`,`i32`),r.addLocal(`idx1`,`i32`),r.addLocal(`idx2`,`i32`),r.addLocal(`i`,`i32`),r.addLocal(`ndiv2`,`i32`);let a=r.getCodeBuilder(),s=a.i32_const(e.alloc(o));r.addCode(a.setLocal(`ndiv2`,a.i32_shr_u(a.getLocal(`n`),a.i32_const(1))),a.if(a.i32_and(a.getLocal(`n`),a.i32_const(1)),a.call(i,a.i32_add(a.getLocal(`pBuff`),a.i32_mul(a.getLocal(`ndiv2`),a.i32_const(o))),a.getLocal(`factor`),a.i32_add(a.getLocal(`pBuff`),a.i32_mul(a.getLocal(`ndiv2`),a.i32_const(o))))),a.setLocal(`i`,a.i32_const(0)),a.block(a.loop(a.br_if(1,a.i32_ge_u(a.getLocal(`i`),a.getLocal(`ndiv2`))),a.setLocal(`idx1`,a.i32_add(a.getLocal(`pBuff`),a.i32_mul(a.getLocal(`i`),a.i32_const(o)))),a.setLocal(`idx2`,a.i32_add(a.getLocal(`pBuff`),a.i32_mul(a.i32_sub(a.i32_sub(a.getLocal(`n`),a.i32_const(1)),a.getLocal(`i`)),a.i32_const(o)))),a.call(i,a.getLocal(`idx2`),a.getLocal(`factor`),s),a.call(i,a.getLocal(`idx1`),a.getLocal(`factor`),a.getLocal(`idx2`)),a.call(n+`_copy`,s,a.getLocal(`idx1`)),a.setLocal(`i`,a.i32_add(a.getLocal(`i`),a.i32_const(1))),a.br(0))))}M(),ee(),j(),A(),D(),O(),k(),N(),P(),F(),I(),L(),te(),e.exportFunction(t+`_fft`),e.exportFunction(t+`_ifft`),e.exportFunction(t+`_rawfft`),e.exportFunction(t+`_fftJoin`),e.exportFunction(t+`_fftJoinExt`),e.exportFunction(t+`_fftJoinExtInv`),e.exportFunction(t+`_fftMix`),e.exportFunction(t+`_fftFinal`),e.exportFunction(t+`_prepareLagrangeEvaluation`)},Tn=function(e,t,n){let r=e.modules[n].n64*8;function i(){let i=e.addFunction(t+`_zero`);i.addParam(`px`,`i32`),i.addParam(`n`,`i32`),i.addLocal(`lastp`,`i32`),i.addLocal(`p`,`i32`);let a=i.getCodeBuilder();i.addCode(a.setLocal(`p`,a.getLocal(`px`)),a.setLocal(`lastp`,a.i32_add(a.getLocal(`px`),a.i32_mul(a.getLocal(`n`),a.i32_const(r)))),a.block(a.loop(a.br_if(1,a.i32_eq(a.getLocal(`p`),a.getLocal(`lastp`))),a.call(n+`_zero`,a.getLocal(`p`)),a.setLocal(`p`,a.i32_add(a.getLocal(`p`),a.i32_const(r))),a.br(0))))}function a(){let i=e.addFunction(t+`_constructLC`);i.addParam(`ppolynomials`,`i32`),i.addParam(`psignals`,`i32`),i.addParam(`nSignals`,`i32`),i.addParam(`pres`,`i32`),i.addLocal(`i`,`i32`),i.addLocal(`j`,`i32`),i.addLocal(`pp`,`i32`),i.addLocal(`ps`,`i32`),i.addLocal(`pd`,`i32`),i.addLocal(`ncoefs`,`i32`);let a=i.getCodeBuilder(),o=a.i32_const(e.alloc(r));i.addCode(a.setLocal(`i`,a.i32_const(0)),a.setLocal(`pp`,a.getLocal(`ppolynomials`)),a.setLocal(`ps`,a.getLocal(`psignals`)),a.block(a.loop(a.br_if(1,a.i32_eq(a.getLocal(`i`),a.getLocal(`nSignals`))),a.setLocal(`ncoefs`,a.i32_load(a.getLocal(`pp`))),a.setLocal(`pp`,a.i32_add(a.getLocal(`pp`),a.i32_const(4))),a.setLocal(`j`,a.i32_const(0)),a.block(a.loop(a.br_if(1,a.i32_eq(a.getLocal(`j`),a.getLocal(`ncoefs`))),a.setLocal(`pd`,a.i32_add(a.getLocal(`pres`),a.i32_mul(a.i32_load(a.getLocal(`pp`)),a.i32_const(r)))),a.setLocal(`pp`,a.i32_add(a.getLocal(`pp`),a.i32_const(4))),a.call(n+`_mul`,a.getLocal(`ps`),a.getLocal(`pp`),o),a.call(n+`_add`,o,a.getLocal(`pd`),a.getLocal(`pd`)),a.setLocal(`pp`,a.i32_add(a.getLocal(`pp`),a.i32_const(r))),a.setLocal(`j`,a.i32_add(a.getLocal(`j`),a.i32_const(1))),a.br(0))),a.setLocal(`ps`,a.i32_add(a.getLocal(`ps`),a.i32_const(r))),a.setLocal(`i`,a.i32_add(a.getLocal(`i`),a.i32_const(1))),a.br(0))))}return i(),a(),e.exportFunction(t+`_zero`),e.exportFunction(t+`_constructLC`),t},En=function(e,t,n){let r=e.modules[n].n64*8;function i(){let i=e.addFunction(t+`_buildABC`);i.addParam(`pCoefs`,`i32`),i.addParam(`nCoefs`,`i32`),i.addParam(`pWitness`,`i32`),i.addParam(`pA`,`i32`),i.addParam(`pB`,`i32`),i.addParam(`pC`,`i32`),i.addParam(`offsetOut`,`i32`),i.addParam(`nOut`,`i32`),i.addParam(`offsetWitness`,`i32`),i.addParam(`nWitness`,`i32`),i.addLocal(`it`,`i32`),i.addLocal(`ita`,`i32`),i.addLocal(`itb`,`i32`),i.addLocal(`last`,`i32`),i.addLocal(`m`,`i32`),i.addLocal(`c`,`i32`),i.addLocal(`s`,`i32`),i.addLocal(`pOut`,`i32`);let a=i.getCodeBuilder(),o=a.i32_const(e.alloc(r));i.addCode(a.setLocal(`ita`,a.getLocal(`pA`)),a.setLocal(`itb`,a.getLocal(`pB`)),a.setLocal(`last`,a.i32_add(a.getLocal(`pA`),a.i32_mul(a.getLocal(`nOut`),a.i32_const(r)))),a.block(a.loop(a.br_if(1,a.i32_eq(a.getLocal(`ita`),a.getLocal(`last`))),a.call(n+`_zero`,a.getLocal(`ita`)),a.call(n+`_zero`,a.getLocal(`itb`)),a.setLocal(`ita`,a.i32_add(a.getLocal(`ita`),a.i32_const(r))),a.setLocal(`itb`,a.i32_add(a.getLocal(`itb`),a.i32_const(r))),a.br(0))),a.setLocal(`it`,a.getLocal(`pCoefs`)),a.setLocal(`last`,a.i32_add(a.getLocal(`pCoefs`),a.i32_mul(a.getLocal(`nCoefs`),a.i32_const(r+12)))),a.block(a.loop(a.br_if(1,a.i32_eq(a.getLocal(`it`),a.getLocal(`last`))),a.setLocal(`s`,a.i32_load(a.getLocal(`it`),8)),a.if(a.i32_or(a.i32_lt_u(a.getLocal(`s`),a.getLocal(`offsetWitness`)),a.i32_ge_u(a.getLocal(`s`),a.i32_add(a.getLocal(`offsetWitness`),a.getLocal(`nWitness`)))),[...a.setLocal(`it`,a.i32_add(a.getLocal(`it`),a.i32_const(r+12))),...a.br(1)]),a.setLocal(`m`,a.i32_load(a.getLocal(`it`))),a.if(a.i32_eq(a.getLocal(`m`),a.i32_const(0)),a.setLocal(`pOut`,a.getLocal(`pA`)),a.if(a.i32_eq(a.getLocal(`m`),a.i32_const(1)),a.setLocal(`pOut`,a.getLocal(`pB`)),[...a.setLocal(`it`,a.i32_add(a.getLocal(`it`),a.i32_const(r+12))),...a.br(1)])),a.setLocal(`c`,a.i32_load(a.getLocal(`it`),4)),a.if(a.i32_or(a.i32_lt_u(a.getLocal(`c`),a.getLocal(`offsetOut`)),a.i32_ge_u(a.getLocal(`c`),a.i32_add(a.getLocal(`offsetOut`),a.getLocal(`nOut`)))),[...a.setLocal(`it`,a.i32_add(a.getLocal(`it`),a.i32_const(r+12))),...a.br(1)]),a.setLocal(`pOut`,a.i32_add(a.getLocal(`pOut`),a.i32_mul(a.i32_sub(a.getLocal(`c`),a.getLocal(`offsetOut`)),a.i32_const(r)))),a.call(n+`_mul`,a.i32_add(a.getLocal(`pWitness`),a.i32_mul(a.i32_sub(a.getLocal(`s`),a.getLocal(`offsetWitness`)),a.i32_const(r))),a.i32_add(a.getLocal(`it`),a.i32_const(12)),o),a.call(n+`_add`,a.getLocal(`pOut`),o,a.getLocal(`pOut`)),a.setLocal(`it`,a.i32_add(a.getLocal(`it`),a.i32_const(r+12))),a.br(0))),a.setLocal(`ita`,a.getLocal(`pA`)),a.setLocal(`itb`,a.getLocal(`pB`)),a.setLocal(`it`,a.getLocal(`pC`)),a.setLocal(`last`,a.i32_add(a.getLocal(`pA`),a.i32_mul(a.getLocal(`nOut`),a.i32_const(r)))),a.block(a.loop(a.br_if(1,a.i32_eq(a.getLocal(`ita`),a.getLocal(`last`))),a.call(n+`_mul`,a.getLocal(`ita`),a.getLocal(`itb`),a.getLocal(`it`)),a.setLocal(`ita`,a.i32_add(a.getLocal(`ita`),a.i32_const(r))),a.setLocal(`itb`,a.i32_add(a.getLocal(`itb`),a.i32_const(r))),a.setLocal(`it`,a.i32_add(a.getLocal(`it`),a.i32_const(r))),a.br(0))))}function a(){let i=e.addFunction(t+`_joinABC`);i.addParam(`pA`,`i32`),i.addParam(`pB`,`i32`),i.addParam(`pC`,`i32`),i.addParam(`n`,`i32`),i.addParam(`pP`,`i32`),i.addLocal(`ita`,`i32`),i.addLocal(`itb`,`i32`),i.addLocal(`itc`,`i32`),i.addLocal(`itp`,`i32`),i.addLocal(`last`,`i32`);let a=i.getCodeBuilder(),o=a.i32_const(e.alloc(r));i.addCode(a.setLocal(`ita`,a.getLocal(`pA`)),a.setLocal(`itb`,a.getLocal(`pB`)),a.setLocal(`itc`,a.getLocal(`pC`)),a.setLocal(`itp`,a.getLocal(`pP`)),a.setLocal(`last`,a.i32_add(a.getLocal(`pA`),a.i32_mul(a.getLocal(`n`),a.i32_const(r)))),a.block(a.loop(a.br_if(1,a.i32_eq(a.getLocal(`ita`),a.getLocal(`last`))),a.call(n+`_mul`,a.getLocal(`ita`),a.getLocal(`itb`),o),a.call(n+`_sub`,o,a.getLocal(`itc`),a.getLocal(`itp`)),a.setLocal(`ita`,a.i32_add(a.getLocal(`ita`),a.i32_const(r))),a.setLocal(`itb`,a.i32_add(a.getLocal(`itb`),a.i32_const(r))),a.setLocal(`itc`,a.i32_add(a.getLocal(`itc`),a.i32_const(r))),a.setLocal(`itp`,a.i32_add(a.getLocal(`itp`),a.i32_const(r))),a.br(0))))}function o(){let i=e.addFunction(t+`_batchAdd`);i.addParam(`pa`,`i32`),i.addParam(`pb`,`i32`),i.addParam(`n`,`i32`),i.addParam(`pr`,`i32`),i.addLocal(`ita`,`i32`),i.addLocal(`itb`,`i32`),i.addLocal(`itr`,`i32`),i.addLocal(`last`,`i32`);let a=i.getCodeBuilder();i.addCode(a.setLocal(`ita`,a.getLocal(`pa`)),a.setLocal(`itb`,a.getLocal(`pb`)),a.setLocal(`itr`,a.getLocal(`pr`)),a.setLocal(`last`,a.i32_add(a.getLocal(`pa`),a.i32_mul(a.getLocal(`n`),a.i32_const(r)))),a.block(a.loop(a.br_if(1,a.i32_eq(a.getLocal(`ita`),a.getLocal(`last`))),a.call(n+`_add`,a.getLocal(`ita`),a.getLocal(`itb`),a.getLocal(`itr`)),a.setLocal(`ita`,a.i32_add(a.getLocal(`ita`),a.i32_const(r))),a.setLocal(`itb`,a.i32_add(a.getLocal(`itb`),a.i32_const(r))),a.setLocal(`itr`,a.i32_add(a.getLocal(`itr`),a.i32_const(r))),a.br(0))))}return i(),a(),o(),e.exportFunction(t+`_buildABC`),e.exportFunction(t+`_joinABC`),e.exportFunction(t+`_batchAdd`),t},Dn=function(e,t,n,r,i,a,o,s){let c=e.addFunction(t);c.addParam(`pIn`,`i32`),c.addParam(`n`,`i32`),c.addParam(`pFirst`,`i32`),c.addParam(`pInc`,`i32`),c.addParam(`pOut`,`i32`),c.addLocal(`pOldFree`,`i32`),c.addLocal(`i`,`i32`),c.addLocal(`pFrom`,`i32`),c.addLocal(`pTo`,`i32`);let l=c.getCodeBuilder(),u=l.i32_const(e.alloc(o));c.addCode(l.setLocal(`pFrom`,l.getLocal(`pIn`)),l.setLocal(`pTo`,l.getLocal(`pOut`))),c.addCode(l.call(r+`_copy`,l.getLocal(`pFirst`),u)),c.addCode(l.setLocal(`i`,l.i32_const(0)),l.block(l.loop(l.br_if(1,l.i32_eq(l.getLocal(`i`),l.getLocal(`n`))),l.call(s,l.getLocal(`pFrom`),u,l.getLocal(`pTo`)),l.setLocal(`pFrom`,l.i32_add(l.getLocal(`pFrom`),l.i32_const(i))),l.setLocal(`pTo`,l.i32_add(l.getLocal(`pTo`),l.i32_const(a))),l.call(r+`_mul`,u,l.getLocal(`pInc`),u),l.setLocal(`i`,l.i32_add(l.getLocal(`i`),l.i32_const(1))),l.br(0)))),e.exportFunction(t)};const z=_t,On=nn,kn=on,An=un,jn=pn,Mn=yn,Nn=wn,Pn=Tn,Fn=En,In=Dn,{bitLength:Ln,modInv:Rn,isOdd:zn,isNegative:Bn}=Et;var Vn=function(e,t){let n=t||`bn128`;if(e.modules[n])return n;let r=21888242871839275222246405745257275088696311157297823662689037894645226208583n,i=21888242871839275222246405745257275088548364400416034343698204186575808495617n,a=Math.floor((Ln(r-1n)-1)/64)+1,o=a*8,s=o,c=o,l=c*2,u=c*12,d=e.alloc(z.bigInt2BytesLE(i,s)),f=On(e,r,`f1m`);kn(e,i,`fr`,`frm`);let p=e.alloc(z.bigInt2BytesLE(y(3n),c)),m=Mn(e,`g1m`,`f1m`,p);Nn(e,`frm`,`frm`,`frm`,`frm_mul`),Pn(e,`pol`,`frm`),Fn(e,`qap`,`frm`);let h=An(e,`f1m_neg`,`f2m`,`f1m`),g=e.alloc([...z.bigInt2BytesLE(y(19485874751759354771024239261021720505790618469301721065564631296452457478373n),c),...z.bigInt2BytesLE(y(266929791119991161246907387137283842545076965332900288569378510910307636690n),c)]),_=Mn(e,`g2m`,`f2m`,g);function v(t,n){let r=e.addFunction(t);r.addParam(`pG`,`i32`),r.addParam(`pFr`,`i32`),r.addParam(`pr`,`i32`);let i=r.getCodeBuilder(),a=i.i32_const(e.alloc(o));r.addCode(i.call(`frm_fromMontgomery`,i.getLocal(`pFr`),a),i.call(n,i.getLocal(`pG`),a,i.i32_const(o),i.getLocal(`pr`))),e.exportFunction(t)}v(`g1m_timesFr`,`g1m_timesScalar`),Nn(e,`g1m`,`g1m`,`frm`,`g1m_timesFr`),v(`g2m_timesFr`,`g2m_timesScalar`),Nn(e,`g2m`,`g2m`,`frm`,`g2m_timesFr`),v(`g1m_timesFrAffine`,`g1m_timesScalarAffine`),v(`g2m_timesFrAffine`,`g2m_timesScalarAffine`),In(e,`frm_batchApplyKey`,`fmr`,`frm`,o,o,o,`frm_mul`),In(e,`g1m_batchApplyKey`,`g1m`,`frm`,o*3,o*3,o,`g1m_timesFr`),In(e,`g1m_batchApplyKeyMixed`,`g1m`,`frm`,o*2,o*3,o,`g1m_timesFrAffine`),In(e,`g2m_batchApplyKey`,`g2m`,`frm`,o*2*3,o*3*2,o,`g2m_timesFr`),In(e,`g2m_batchApplyKeyMixed`,`g2m`,`frm`,o*2*2,o*3*2,o,`g2m_timesFrAffine`);function y(e){return BigInt(e)*(1n<<BigInt(c*8))%r}let b=[1n,2n,1n],x=e.alloc([...z.bigInt2BytesLE(y(b[0]),c),...z.bigInt2BytesLE(y(b[1]),c),...z.bigInt2BytesLE(y(b[2]),c)]),S=[0n,1n,0n],C=e.alloc([...z.bigInt2BytesLE(y(S[0]),c),...z.bigInt2BytesLE(y(S[1]),c),...z.bigInt2BytesLE(y(S[2]),c)]),w=[[10857046999023057135944570762232829481370756359578518086990519993285655852781n,11559732032986387107991004021392285783925812861821192530917403151452391805634n],[8495653923123431417604973247489272438418190587263600148770280649306958101930n,4082367875863433681332203403145435568316851327593401208105741076214120093531n],[1n,0n]],T=e.alloc([...z.bigInt2BytesLE(y(w[0][0]),c),...z.bigInt2BytesLE(y(w[0][1]),c),...z.bigInt2BytesLE(y(w[1][0]),c),...z.bigInt2BytesLE(y(w[1][1]),c),...z.bigInt2BytesLE(y(w[2][0]),c),...z.bigInt2BytesLE(y(w[2][1]),c)]),E=[[0n,0n],[1n,0n],[0n,0n]],D=e.alloc([...z.bigInt2BytesLE(y(E[0][0]),c),...z.bigInt2BytesLE(y(E[0][1]),c),...z.bigInt2BytesLE(y(E[1][0]),c),...z.bigInt2BytesLE(y(E[1][1]),c),...z.bigInt2BytesLE(y(E[2][0]),c),...z.bigInt2BytesLE(y(E[2][1]),c)]),O=e.alloc([...z.bigInt2BytesLE(y(1),c),...z.bigInt2BytesLE(y(0),c),...z.bigInt2BytesLE(y(0),c),...z.bigInt2BytesLE(y(0),c),...z.bigInt2BytesLE(y(0),c),...z.bigInt2BytesLE(y(0),c),...z.bigInt2BytesLE(y(0),c),...z.bigInt2BytesLE(y(0),c),...z.bigInt2BytesLE(y(0),c),...z.bigInt2BytesLE(y(0),c),...z.bigInt2BytesLE(y(0),c),...z.bigInt2BytesLE(y(0),c)]),k=e.alloc([...z.bigInt2BytesLE(y(9),c),...z.bigInt2BytesLE(y(1),c)]),A=e.alloc([...z.bigInt2BytesLE(y(Rn(2n,r)),c),...z.bigInt2BytesLE(0n,c)]),j=k,ee=e.alloc([...z.bigInt2BytesLE(y(19485874751759354771024239261021720505790618469301721065564631296452457478373n),c),...z.bigInt2BytesLE(y(266929791119991161246907387137283842545076965332900288569378510910307636690n),c)]);function M(){let t=e.addFunction(n+`_mulNR6`);t.addParam(`x`,`i32`),t.addParam(`pr`,`i32`);let r=t.getCodeBuilder();t.addCode(r.call(h+`_mul`,r.i32_const(k),r.getLocal(`x`),r.getLocal(`pr`)))}M();let N=jn(e,n+`_mulNR6`,`f6m`,`f2m`);function P(){let t=e.addFunction(n+`_mulNR12`);t.addParam(`x`,`i32`),t.addParam(`pr`,`i32`);let r=t.getCodeBuilder();t.addCode(r.call(h+`_mul`,r.i32_const(k),r.i32_add(r.getLocal(`x`),r.i32_const(o*4)),r.getLocal(`pr`)),r.call(h+`_copy`,r.getLocal(`x`),r.i32_add(r.getLocal(`pr`),r.i32_const(o*2))),r.call(h+`_copy`,r.i32_add(r.getLocal(`x`),r.i32_const(o*2)),r.i32_add(r.getLocal(`pr`),r.i32_const(o*4))))}P();let F=An(e,n+`_mulNR12`,`ftm`,N),te=oe(29793968203157093288n),I=e.alloc(te),L=3*l,ne=te.length-1,re=te.reduce((e,t)=>e+(t==0?0:1),0)+ne+1,ie=6*o,R=3*o*2+re*L;e.modules[n]={n64:a,pG1gen:x,pG1zero:C,pG1b:p,pG2gen:T,pG2zero:D,pG2b:g,pq:e.modules.f1m.pq,pr:d,pOneT:O,prePSize:ie,preQSize:R,r:`21888242871839275222246405745257275088548364400416034343698204186575808495617`,q:`21888242871839275222246405745257275088696311157297823662689037894645226208583`};function ae(e){let t=e,n=[];for(;t>0n;){if(zn(t)){let e=2-Number(t%4n);n.push(e),t-=BigInt(e)}else n.push(0);t>>=1n}return n}function oe(e){let t=e,n=[];for(;t>0n;)zn(t)?n.push(1):n.push(0),t>>=1n;return n}function se(){let t=e.addFunction(n+`_prepareG1`);t.addParam(`pP`,`i32`),t.addParam(`ppreP`,`i32`);let r=t.getCodeBuilder();t.addCode(r.call(m+`_normalize`,r.getLocal(`pP`),r.getLocal(`ppreP`)))}function ce(){let t=e.addFunction(n+`_prepAddStep`);t.addParam(`pQ`,`i32`),t.addParam(`pR`,`i32`),t.addParam(`pCoef`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`pQ`),a=r.i32_add(r.getLocal(`pQ`),r.i32_const(l)),o=r.getLocal(`pR`),s=r.i32_add(r.getLocal(`pR`),r.i32_const(l)),c=r.i32_add(r.getLocal(`pR`),r.i32_const(2*l)),u=r.getLocal(`pCoef`),d=r.i32_add(r.getLocal(`pCoef`),r.i32_const(l)),f=r.i32_add(r.getLocal(`pCoef`),r.i32_const(2*l)),p=d,m=r.i32_const(e.alloc(l)),g=r.i32_const(e.alloc(l)),_=r.i32_const(e.alloc(l)),v=r.i32_const(e.alloc(l)),y=r.i32_const(e.alloc(l)),b=r.i32_const(e.alloc(l)),x=r.i32_const(e.alloc(l));t.addCode(r.call(h+`_mul`,i,c,p),r.call(h+`_sub`,o,p,p),r.call(h+`_mul`,a,c,m),r.call(h+`_sub`,s,m,m),r.call(h+`_square`,p,g),r.call(h+`_square`,m,_),r.call(h+`_mul`,p,g,v),r.call(h+`_mul`,o,g,y),r.call(h+`_add`,y,y,x),r.call(h+`_mul`,c,_,b),r.call(h+`_add`,v,b,b),r.call(h+`_sub`,b,x,b),r.call(h+`_mul`,p,b,o),r.call(h+`_mul`,v,s,s),r.call(h+`_sub`,y,b,x),r.call(h+`_mul`,m,x,x),r.call(h+`_sub`,x,s,s),r.call(h+`_mul`,c,v,c),r.call(h+`_mul`,p,a,x),r.call(h+`_mul`,m,i,u),r.call(h+`_sub`,u,x,u),r.call(h+`_mul`,u,r.i32_const(j),u),r.call(h+`_neg`,m,f))}function le(){let t=e.addFunction(n+`_prepDblStep`);t.addParam(`pR`,`i32`),t.addParam(`pCoef`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`pR`),a=r.i32_add(r.getLocal(`pR`),r.i32_const(l)),o=r.i32_add(r.getLocal(`pR`),r.i32_const(2*l)),s=r.getLocal(`pCoef`),c=r.i32_add(r.getLocal(`pCoef`),r.i32_const(l)),u=r.i32_add(r.getLocal(`pCoef`),r.i32_const(2*l)),d=r.i32_const(e.alloc(l)),f=r.i32_const(e.alloc(l)),p=r.i32_const(e.alloc(l)),m=r.i32_const(e.alloc(l)),g=r.i32_const(e.alloc(l)),_=r.i32_const(e.alloc(l)),v=r.i32_const(e.alloc(l)),y=r.i32_const(e.alloc(l)),b=r.i32_const(e.alloc(l)),x=r.i32_const(e.alloc(l)),S=r.i32_const(e.alloc(l)),C=r.i32_const(e.alloc(l));t.addCode(r.call(h+`_mul`,a,r.i32_const(A),d),r.call(h+`_mul`,i,d,d),r.call(h+`_square`,a,f),r.call(h+`_square`,o,p),r.call(h+`_add`,p,p,m),r.call(h+`_add`,m,p,m),r.call(h+`_mul`,r.i32_const(ee),m,g),r.call(h+`_add`,g,g,_),r.call(h+`_add`,g,_,_),r.call(h+`_add`,f,_,v),r.call(h+`_mul`,v,r.i32_const(A),v),r.call(h+`_add`,f,p,C),r.call(h+`_add`,a,o,y),r.call(h+`_square`,y,y),r.call(h+`_sub`,y,C,y),r.call(h+`_sub`,g,f,b),r.call(h+`_square`,i,x),r.call(h+`_square`,g,S),r.call(h+`_sub`,f,_,C),r.call(h+`_mul`,d,C,i),r.call(h+`_add`,S,S,C),r.call(h+`_add`,S,C,C),r.call(h+`_square`,v,a),r.call(h+`_sub`,a,C,a),r.call(h+`_mul`,f,y,o),r.call(h+`_mul`,r.i32_const(j),b,s),r.call(h+`_neg`,y,c),r.call(h+`_add`,x,x,u),r.call(h+`_add`,x,u,u))}function ue(){let t=e.addFunction(n+`_mulByQ`);t.addParam(`p1`,`i32`),t.addParam(`pr`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`p1`),a=r.i32_add(r.getLocal(`p1`),r.i32_const(l)),o=r.i32_add(r.getLocal(`p1`),r.i32_const(l*2)),s=r.getLocal(`pr`),u=r.i32_add(r.getLocal(`pr`),r.i32_const(l)),d=r.i32_add(r.getLocal(`pr`),r.i32_const(l*2)),f=r.i32_const(e.alloc([...z.bigInt2BytesLE(y(`21575463638280843010398324269430826099269044274347216827212613867836435027261`),c),...z.bigInt2BytesLE(y(`10307601595873709700152284273816112264069230130616436755625194854815875713954`),c)])),p=r.i32_const(e.alloc([...z.bigInt2BytesLE(y(`2821565182194536844548159561693502659359617185244120367078079554186484126554`),c),...z.bigInt2BytesLE(y(`3505843767911556378687030309984248845540243509899259641013678093033130930403`),c)]));t.addCode(r.call(h+`_conjugate`,i,s),r.call(h+`_mul`,f,s,s),r.call(h+`_conjugate`,a,u),r.call(h+`_mul`,p,u,u),r.call(h+`_conjugate`,o,d))}function de(){ue();let t=e.addFunction(n+`_prepareG2`);t.addParam(`pQ`,`i32`),t.addParam(`ppreQ`,`i32`),t.addLocal(`pCoef`,`i32`),t.addLocal(`i`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`pQ`),a=e.alloc(l*3),o=r.i32_const(a),s=r.i32_const(a),c=r.i32_const(a+l),u=r.i32_const(a+2*l),d=r.i32_add(r.getLocal(`ppreQ`),r.i32_const(0)),f=r.i32_add(r.getLocal(`ppreQ`),r.i32_const(l)),p=e.alloc(l*3),m=r.i32_const(p),g=e.alloc(l*3),v=r.i32_const(g),y=r.i32_const(g+l);t.addCode(r.call(_+`_normalize`,i,d),r.call(h+`_copy`,d,s),r.call(h+`_copy`,f,c),r.call(h+`_one`,u)),t.addCode(r.setLocal(`pCoef`,r.i32_add(r.getLocal(`ppreQ`),r.i32_const(l*3))),r.setLocal(`i`,r.i32_const(te.length-2)),r.block(r.loop(r.call(n+`_prepDblStep`,o,r.getLocal(`pCoef`)),r.setLocal(`pCoef`,r.i32_add(r.getLocal(`pCoef`),r.i32_const(L))),r.if(r.i32_load8_s(r.getLocal(`i`),I),[...r.call(n+`_prepAddStep`,d,o,r.getLocal(`pCoef`)),...r.setLocal(`pCoef`,r.i32_add(r.getLocal(`pCoef`),r.i32_const(L)))]),r.br_if(1,r.i32_eqz(r.getLocal(`i`))),r.setLocal(`i`,r.i32_sub(r.getLocal(`i`),r.i32_const(1))),r.br(0)))),t.addCode(r.call(n+`_mulByQ`,d,m),r.call(n+`_mulByQ`,m,v)),t.addCode(r.call(h+`_neg`,y,y),r.call(n+`_prepAddStep`,m,o,r.getLocal(`pCoef`)),r.setLocal(`pCoef`,r.i32_add(r.getLocal(`pCoef`),r.i32_const(L))),r.call(n+`_prepAddStep`,v,o,r.getLocal(`pCoef`)),r.setLocal(`pCoef`,r.i32_add(r.getLocal(`pCoef`),r.i32_const(L))))}function fe(){let t=e.addFunction(n+`__mulBy024Old`);t.addParam(`pEll0`,`i32`),t.addParam(`pEllVW`,`i32`),t.addParam(`pEllVV`,`i32`),t.addParam(`pR`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`pEll0`),a=r.getLocal(`pEllVV`),o=r.getLocal(`pEllVW`),s=r.getLocal(`pR`),c=e.alloc(u),d=r.i32_const(c),f=r.i32_const(c),p=r.i32_const(c+l),m=r.i32_const(c+l*2),g=r.i32_const(c+l*3),_=r.i32_const(c+l*4),v=r.i32_const(c+l*5);t.addCode(r.call(h+`_copy`,i,f),r.call(h+`_zero`,p),r.call(h+`_copy`,a,m),r.call(h+`_zero`,g),r.call(h+`_copy`,o,_),r.call(h+`_zero`,v),r.call(F+`_mul`,d,s,s))}function pe(){let t=e.addFunction(n+`__mulBy024`);t.addParam(`pEll0`,`i32`),t.addParam(`pEllVW`,`i32`),t.addParam(`pEllVV`,`i32`),t.addParam(`pR`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`pEll0`),a=r.getLocal(`pEllVV`),s=r.getLocal(`pEllVW`),c=r.getLocal(`pR`),u=r.i32_add(r.getLocal(`pR`),r.i32_const(2*o)),d=r.i32_add(r.getLocal(`pR`),r.i32_const(4*o)),f=r.i32_add(r.getLocal(`pR`),r.i32_const(6*o)),p=r.i32_add(r.getLocal(`pR`),r.i32_const(8*o)),m=r.i32_add(r.getLocal(`pR`),r.i32_const(10*o)),g=r.i32_const(e.alloc(l)),_=r.i32_const(e.alloc(l)),v=r.i32_const(e.alloc(l)),y=r.i32_const(e.alloc(l)),b=r.i32_const(e.alloc(l)),x=r.i32_const(e.alloc(l)),S=r.i32_const(e.alloc(l)),C=r.i32_const(e.alloc(l)),w=r.i32_const(e.alloc(l)),T=r.i32_const(e.alloc(l)),E=r.i32_const(e.alloc(l));t.addCode(r.call(h+`_mul`,c,i,S),r.call(h+`_mul`,d,a,C),r.call(h+`_mul`,p,s,w),r.call(h+`_add`,c,p,v),r.call(h+`_add`,c,d,_),r.call(h+`_add`,u,f,y),r.call(h+`_add`,y,m,y),r.call(h+`_mul`,u,a,T),r.call(h+`_add`,T,w,b),r.call(h+`_mul`,r.i32_const(k),b,x),r.call(h+`_add`,x,S,c),r.call(h+`_mul`,m,s,b),r.call(h+`_add`,T,b,T),r.call(h+`_add`,b,C,b),r.call(h+`_mul`,r.i32_const(k),b,x),r.call(h+`_mul`,u,i,b),r.call(h+`_add`,T,b,T),r.call(h+`_add`,x,b,u),r.call(h+`_add`,i,a,g),r.call(h+`_mul`,_,g,b),r.call(h+`_add`,S,C,E),r.call(h+`_sub`,b,E,b),r.call(h+`_mul`,f,s,x),r.call(h+`_add`,T,x,T),r.call(h+`_add`,d,p,g),r.call(h+`_add`,b,x,d),r.call(h+`_add`,a,s,_),r.call(h+`_mul`,_,g,b),r.call(h+`_add`,C,w,E),r.call(h+`_sub`,b,E,b),r.call(h+`_mul`,r.i32_const(k),b,x),r.call(h+`_mul`,f,i,b),r.call(h+`_add`,T,b,T),r.call(h+`_add`,x,b,f),r.call(h+`_mul`,m,a,b),r.call(h+`_add`,T,b,T),r.call(h+`_mul`,r.i32_const(k),b,x),r.call(h+`_add`,i,s,g),r.call(h+`_mul`,v,g,b),r.call(h+`_add`,S,w,E),r.call(h+`_sub`,b,E,b),r.call(h+`_add`,x,b,p),r.call(h+`_add`,i,a,g),r.call(h+`_add`,g,s,g),r.call(h+`_mul`,y,g,b),r.call(h+`_sub`,b,T,m))}function me(){let t=e.addFunction(n+`_millerLoop`);t.addParam(`ppreP`,`i32`),t.addParam(`ppreQ`,`i32`),t.addParam(`r`,`i32`),t.addLocal(`pCoef`,`i32`),t.addLocal(`i`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`ppreP`),a=r.i32_add(r.getLocal(`ppreP`),r.i32_const(c)),o=r.getLocal(`pCoef`),s=r.i32_add(r.getLocal(`pCoef`),r.i32_const(l)),u=r.i32_add(r.getLocal(`pCoef`),r.i32_const(2*l)),d=e.alloc(l),f=r.i32_const(d),p=e.alloc(l),m=r.i32_const(p),g=r.getLocal(`r`);t.addCode(r.call(F+`_one`,g),r.setLocal(`pCoef`,r.i32_add(r.getLocal(`ppreQ`),r.i32_const(l*3))),r.setLocal(`i`,r.i32_const(te.length-2)),r.block(r.loop(r.call(F+`_square`,g,g),r.call(h+`_mul1`,s,a,f),r.call(h+`_mul1`,u,i,m),r.call(n+`__mulBy024`,o,f,m,g),r.setLocal(`pCoef`,r.i32_add(r.getLocal(`pCoef`),r.i32_const(L))),r.if(r.i32_load8_s(r.getLocal(`i`),I),[...r.call(h+`_mul1`,s,a,f),...r.call(h+`_mul1`,u,i,m),...r.call(n+`__mulBy024`,o,f,m,g),...r.setLocal(`pCoef`,r.i32_add(r.getLocal(`pCoef`),r.i32_const(L)))]),r.br_if(1,r.i32_eqz(r.getLocal(`i`))),r.setLocal(`i`,r.i32_sub(r.getLocal(`i`),r.i32_const(1))),r.br(0)))),t.addCode(r.call(h+`_mul1`,s,a,f),r.call(h+`_mul1`,u,i,m),r.call(n+`__mulBy024`,o,f,m,g),r.setLocal(`pCoef`,r.i32_add(r.getLocal(`pCoef`),r.i32_const(L))),r.call(h+`_mul1`,s,a,f),r.call(h+`_mul1`,u,i,m),r.call(n+`__mulBy024`,o,f,m,g),r.setLocal(`pCoef`,r.i32_add(r.getLocal(`pCoef`),r.i32_const(L))))}function he(t){let i=[[[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n]],[[1n,0n],[8376118865763821496583973867626364092589906065868298776909617916018768340080n,16469823323077808223889137241176536799009286646108169935659301613961712198316n],[21888242871839275220042445260109153167277707414472061641714758635765020556617n,0n],[11697423496358154304825782922584725312912383441159505038794027105778954184319n,303847389135065887422783454877609941456349188919719272345083954437860409601n],[21888242871839275220042445260109153167277707414472061641714758635765020556616n,0n],[3321304630594332808241809054958361220322477375291206261884409189760185844239n,5722266937896532885780051958958348231143373700109372999374820235121374419868n],[21888242871839275222246405745257275088696311157297823662689037894645226208582n,0n],[13512124006075453725662431877630910996106405091429524885779419978626457868503n,5418419548761466998357268504080738289687024511189653727029736280683514010267n],[2203960485148121921418603742825762020974279258880205651966n,0n],[10190819375481120917420622822672549775783927716138318623895010788866272024264n,21584395482704209334823622290379665147239961968378104390343953940207365798982n],[2203960485148121921418603742825762020974279258880205651967n,0n],[18566938241244942414004596690298913868373833782006617400804628704885040364344n,16165975933942742336466353786298926857552937457188450663314217659523851788715n]]],a=[[[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n]],[[1n,0n],[21575463638280843010398324269430826099269044274347216827212613867836435027261n,10307601595873709700152284273816112264069230130616436755625194854815875713954n],[21888242871839275220042445260109153167277707414472061641714758635765020556616n,0n],[3772000881919853776433695186713858239009073593817195771773381919316419345261n,2236595495967245188281701248203181795121068902605861227855261137820944008926n],[2203960485148121921418603742825762020974279258880205651966n,0n],[18429021223477853657660792034369865839114504446431234726392080002137598044644n,9344045779998320333812420223237981029506012124075525679208581902008406485703n]],[[1n,0n],[2581911344467009335267311115468803099551665605076196740867805258568234346338n,19937756971775647987995932169929341994314640652964949448313374472400716661030n],[2203960485148121921418603742825762020974279258880205651966n,0n],[5324479202449903542726783395506214481928257762400643279780343368557297135718n,16208900380737693084919495127334387981393726419856888799917914180988844123039n],[21888242871839275220042445260109153167277707414472061641714758635765020556616n,0n],[13981852324922362344252311234282257507216387789820983642040889267519694726527n,7629828391165209371577384193250820201684255241773809077146787135900891633097n]]],o=e.addFunction(n+`__frobeniusMap`+t);o.addParam(`x`,`i32`),o.addParam(`r`,`i32`);let s=o.getCodeBuilder();for(let n=0;n<6;n++){let r=n==0?s.getLocal(`x`):s.i32_add(s.getLocal(`x`),s.i32_const(n*l)),d=r,p=s.i32_add(s.getLocal(`x`),s.i32_const(n*l+c)),m=n==0?s.getLocal(`r`):s.i32_add(s.getLocal(`r`),s.i32_const(n*l)),g=m,_=s.i32_add(s.getLocal(`r`),s.i32_const(n*l+c)),v=u(i[Math.floor(n/3)][t%12],a[n%3][t%6]),b=e.alloc([...z.bigInt2BytesLE(y(v[0]),32),...z.bigInt2BytesLE(y(v[1]),32)]);t%2==1?o.addCode(s.call(f+`_copy`,d,g),s.call(f+`_neg`,p,_),s.call(h+`_mul`,m,s.i32_const(b),m)):o.addCode(s.call(h+`_mul`,r,s.i32_const(b),m))}function u(e,t){let n=BigInt(e[0]),i=BigInt(e[1]),a=BigInt(t[0]),o=BigInt(t[1]),s=[(n*a-i*o)%r,(n*o+i*a)%r];return Bn(s[0])&&(s[0]+=r),s}}function ge(){let t=e.addFunction(n+`__finalExponentiationFirstChunk`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`x`),a=i,s=r.i32_add(i,r.i32_const(o*6)),c=r.getLocal(`r`),l=e.alloc(u),d=r.i32_const(l),f=d,p=r.i32_const(l+o*6),m=r.i32_const(e.alloc(u)),h=r.i32_const(e.alloc(u)),g=r.i32_const(e.alloc(u));t.addCode(r.call(N+`_copy`,a,f),r.call(N+`_neg`,s,p),r.call(F+`_inverse`,i,m),r.call(F+`_mul`,d,m,h),r.call(n+`__frobeniusMap2`,h,g),r.call(F+`_mul`,h,g,c))}function _e(){let t=e.addFunction(n+`__cyclotomicSquare`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`x`),a=r.i32_add(r.getLocal(`x`),r.i32_const(l)),o=r.i32_add(r.getLocal(`x`),r.i32_const(2*l)),s=r.i32_add(r.getLocal(`x`),r.i32_const(3*l)),c=r.i32_add(r.getLocal(`x`),r.i32_const(4*l)),u=r.i32_add(r.getLocal(`x`),r.i32_const(5*l)),d=r.getLocal(`r`),f=r.i32_add(r.getLocal(`r`),r.i32_const(l)),p=r.i32_add(r.getLocal(`r`),r.i32_const(2*l)),m=r.i32_add(r.getLocal(`r`),r.i32_const(3*l)),g=r.i32_add(r.getLocal(`r`),r.i32_const(4*l)),_=r.i32_add(r.getLocal(`r`),r.i32_const(5*l)),v=r.i32_const(e.alloc(l)),y=r.i32_const(e.alloc(l)),b=r.i32_const(e.alloc(l)),x=r.i32_const(e.alloc(l)),S=r.i32_const(e.alloc(l)),C=r.i32_const(e.alloc(l)),w=r.i32_const(e.alloc(l)),T=r.i32_const(e.alloc(l));t.addCode(r.call(h+`_mul`,i,c,w),r.call(h+`_mul`,c,r.i32_const(k),v),r.call(h+`_add`,i,v,v),r.call(h+`_add`,i,c,T),r.call(h+`_mul`,T,v,v),r.call(h+`_mul`,r.i32_const(k),w,T),r.call(h+`_add`,w,T,T),r.call(h+`_sub`,v,T,v),r.call(h+`_add`,w,w,y),r.call(h+`_mul`,s,o,w),r.call(h+`_mul`,o,r.i32_const(k),b),r.call(h+`_add`,s,b,b),r.call(h+`_add`,s,o,T),r.call(h+`_mul`,T,b,b),r.call(h+`_mul`,r.i32_const(k),w,T),r.call(h+`_add`,w,T,T),r.call(h+`_sub`,b,T,b),r.call(h+`_add`,w,w,x),r.call(h+`_mul`,a,u,w),r.call(h+`_mul`,u,r.i32_const(k),S),r.call(h+`_add`,a,S,S),r.call(h+`_add`,a,u,T),r.call(h+`_mul`,T,S,S),r.call(h+`_mul`,r.i32_const(k),w,T),r.call(h+`_add`,w,T,T),r.call(h+`_sub`,S,T,S),r.call(h+`_add`,w,w,C),r.call(h+`_sub`,v,i,d),r.call(h+`_add`,d,d,d),r.call(h+`_add`,v,d,d),r.call(h+`_add`,y,c,g),r.call(h+`_add`,g,g,g),r.call(h+`_add`,y,g,g),r.call(h+`_mul`,C,r.i32_const(j),T),r.call(h+`_add`,T,s,m),r.call(h+`_add`,m,m,m),r.call(h+`_add`,T,m,m),r.call(h+`_sub`,S,o,p),r.call(h+`_add`,p,p,p),r.call(h+`_add`,S,p,p),r.call(h+`_sub`,b,a,f),r.call(h+`_add`,f,f,f),r.call(h+`_add`,b,f,f),r.call(h+`_add`,x,u,_),r.call(h+`_add`,_,_,_),r.call(h+`_add`,x,_,_))}function ve(t,r){let i=ae(t).map(e=>e==-1?255:e),a=e.alloc(i),o=e.addFunction(n+`__cyclotomicExp_`+r);o.addParam(`x`,`i32`),o.addParam(`r`,`i32`),o.addLocal(`bit`,`i32`),o.addLocal(`i`,`i32`);let s=o.getCodeBuilder(),c=s.getLocal(`x`),l=s.getLocal(`r`),d=s.i32_const(e.alloc(u));o.addCode(s.call(F+`_conjugate`,c,d),s.call(F+`_one`,l),s.if(s.teeLocal(`bit`,s.i32_load8_s(s.i32_const(i.length-1),a)),s.if(s.i32_eq(s.getLocal(`bit`),s.i32_const(1)),s.call(F+`_mul`,l,c,l),s.call(F+`_mul`,l,d,l))),s.setLocal(`i`,s.i32_const(i.length-2)),s.block(s.loop(s.call(n+`__cyclotomicSquare`,l,l),s.if(s.teeLocal(`bit`,s.i32_load8_s(s.getLocal(`i`),a)),s.if(s.i32_eq(s.getLocal(`bit`),s.i32_const(1)),s.call(F+`_mul`,l,c,l),s.call(F+`_mul`,l,d,l))),s.br_if(1,s.i32_eqz(s.getLocal(`i`))),s.setLocal(`i`,s.i32_sub(s.getLocal(`i`),s.i32_const(1))),s.br(0))))}function ye(){_e(),ve(4965661367192848881n,`w0`);let t=e.addFunction(n+`__finalExponentiationLastChunk`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`x`),a=r.getLocal(`r`),o=r.i32_const(e.alloc(u)),s=r.i32_const(e.alloc(u)),c=r.i32_const(e.alloc(u)),l=r.i32_const(e.alloc(u)),d=r.i32_const(e.alloc(u)),f=r.i32_const(e.alloc(u)),p=r.i32_const(e.alloc(u)),m=r.i32_const(e.alloc(u)),h=r.i32_const(e.alloc(u)),g=r.i32_const(e.alloc(u)),_=r.i32_const(e.alloc(u)),v=r.i32_const(e.alloc(u)),y=r.i32_const(e.alloc(u)),b=r.i32_const(e.alloc(u)),x=r.i32_const(e.alloc(u)),S=r.i32_const(e.alloc(u)),C=r.i32_const(e.alloc(u)),w=r.i32_const(e.alloc(u)),T=r.i32_const(e.alloc(u)),E=r.i32_const(e.alloc(u)),D=r.i32_const(e.alloc(u));t.addCode(r.call(n+`__cyclotomicExp_w0`,i,o),r.call(F+`_conjugate`,o,o),r.call(n+`__cyclotomicSquare`,o,s),r.call(n+`__cyclotomicSquare`,s,c),r.call(F+`_mul`,c,s,l),r.call(n+`__cyclotomicExp_w0`,l,d),r.call(F+`_conjugate`,d,d),r.call(n+`__cyclotomicSquare`,d,f),r.call(n+`__cyclotomicExp_w0`,f,p),r.call(F+`_conjugate`,p,p),r.call(F+`_conjugate`,l,m),r.call(F+`_conjugate`,p,h),r.call(F+`_mul`,h,d,g),r.call(F+`_mul`,g,m,_),r.call(F+`_mul`,_,s,v),r.call(F+`_mul`,_,d,y),r.call(F+`_mul`,y,i,b),r.call(n+`__frobeniusMap1`,v,x),r.call(F+`_mul`,x,b,S),r.call(n+`__frobeniusMap2`,_,C),r.call(F+`_mul`,C,S,w),r.call(F+`_conjugate`,i,T),r.call(F+`_mul`,T,v,E),r.call(n+`__frobeniusMap3`,E,D),r.call(F+`_mul`,D,w,a))}function be(){ge(),ye();let t=e.addFunction(n+`_finalExponentiation`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`x`),a=r.getLocal(`r`),o=r.i32_const(e.alloc(u));t.addCode(r.call(n+`__finalExponentiationFirstChunk`,i,o),r.call(n+`__finalExponentiationLastChunk`,o,a))}function xe(){let t=e.addFunction(n+`_finalExponentiationOld`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let r=e.alloc(z.bigInt2BytesLE(552484233613224096312617126783173147097382103762957654188882734314196910839907541213974502761540629817009608548654680343627701153829446747810907373256841551006201639677726139946029199968412598804882391702273019083653272047566316584365559776493027495458238373902875937659943504873220554161550525926302303331747463515644711876653177129578303191095900909191624817826566688241804408081892785725967931714097716709526092261278071952560171111444072049229123565057483750161460024353346284167282452756217662335528813519139808291170539072125381230815729071544861602750936964829313608137325426383735122175229541155376346436093930287402089517426973178917569713384748081827255472576937471496195752727188261435633271238710131736096299798168852925540549342330775279877006784354801422249722573783561685179618816480037695005515426162362431072245638324744480n,352)),i=t.getCodeBuilder();t.addCode(i.call(F+`_exp`,i.getLocal(`x`),i.i32_const(r),i.i32_const(352),i.getLocal(`r`)))}let Se=e.alloc(ie),Ce=e.alloc(R);function we(t){let r=e.addFunction(n+`_pairingEq`+t);for(let e=0;e<t;e++)r.addParam(`p_`+e,`i32`),r.addParam(`q_`+e,`i32`);r.addParam(`c`,`i32`),r.setReturnType(`i32`);let i=r.getCodeBuilder(),a=i.i32_const(e.alloc(u)),o=i.i32_const(e.alloc(u));r.addCode(i.call(F+`_one`,a));for(let e=0;e<t;e++)r.addCode(i.call(n+`_prepareG1`,i.getLocal(`p_`+e),i.i32_const(Se))),r.addCode(i.call(n+`_prepareG2`,i.getLocal(`q_`+e),i.i32_const(Ce))),r.addCode(i.call(n+`_millerLoop`,i.i32_const(Se),i.i32_const(Ce),o)),r.addCode(i.call(F+`_mul`,a,o,a));r.addCode(i.call(n+`_finalExponentiation`,a,a)),r.addCode(i.call(F+`_eq`,a,i.getLocal(`c`)))}function Te(){let t=e.addFunction(n+`_pairing`);t.addParam(`p`,`i32`),t.addParam(`q`,`i32`),t.addParam(`r`,`i32`);let r=t.getCodeBuilder(),i=r.i32_const(e.alloc(u));t.addCode(r.call(n+`_prepareG1`,r.getLocal(`p`),r.i32_const(Se))),t.addCode(r.call(n+`_prepareG2`,r.getLocal(`q`),r.i32_const(Ce))),t.addCode(r.call(n+`_millerLoop`,r.i32_const(Se),r.i32_const(Ce),i)),t.addCode(r.call(n+`_finalExponentiation`,i,r.getLocal(`r`)))}ce(),le(),se(),de(),pe(),fe(),me();for(let t=0;t<10;t++)he(t),e.exportFunction(n+`__frobeniusMap`+t);xe(),be();for(let t=1;t<=5;t++)we(t),e.exportFunction(n+`_pairingEq`+t);Te(),e.exportFunction(n+`_pairing`),e.exportFunction(n+`_prepareG1`),e.exportFunction(n+`_prepareG2`),e.exportFunction(n+`_millerLoop`),e.exportFunction(n+`_finalExponentiation`),e.exportFunction(n+`_finalExponentiationOld`),e.exportFunction(n+`__mulBy024`),e.exportFunction(n+`__mulBy024Old`),e.exportFunction(n+`__cyclotomicSquare`),e.exportFunction(n+`__cyclotomicExp_w0`)};const B=_t,Hn=nn,Un=on,Wn=un,Gn=pn,Kn=yn,qn=wn,Jn=Tn,Yn=En,Xn=Dn,{bitLength:Zn,isOdd:Qn,isNegative:$n}=Et;var er=function(e,t){let n=t||`bls12381`;if(e.modules[n])return n;let r=4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787n,i=52435875175126190479447740508185965837690552500527637822603658699938581184513n,a=Math.floor((Zn(r-1n)-1)/64)+1,o=a*8,s=o,c=s*2,l=s*12,u=Math.floor((Zn(i-1n)-1)/64)+1,d=u*8,f=d,p=e.alloc(B.bigInt2BytesLE(i,f)),m=Hn(e,r,`f1m`,`intq`);Un(e,i,`fr`,`frm`,`intr`);let h=e.alloc(B.bigInt2BytesLE(x(4n),s)),g=Kn(e,`g1m`,`f1m`,h);qn(e,`frm`,`frm`,`frm`,`frm_mul`),Jn(e,`pol`,`frm`),Yn(e,`qap`,`frm`);let _=Wn(e,`f1m_neg`,`f2m`,`f1m`),v=e.alloc([...B.bigInt2BytesLE(x(4n),s),...B.bigInt2BytesLE(x(4n),s)]),y=Kn(e,`g2m`,`f2m`,v);function b(t,n){let r=e.addFunction(t);r.addParam(`pG`,`i32`),r.addParam(`pFr`,`i32`),r.addParam(`pr`,`i32`);let i=r.getCodeBuilder(),a=i.i32_const(e.alloc(d));r.addCode(i.call(`frm_fromMontgomery`,i.getLocal(`pFr`),a),i.call(n,i.getLocal(`pG`),a,i.i32_const(d),i.getLocal(`pr`))),e.exportFunction(t)}b(`g1m_timesFr`,`g1m_timesScalar`),qn(e,`g1m`,`g1m`,`frm`,`g1m_timesFr`),b(`g2m_timesFr`,`g2m_timesScalar`),qn(e,`g2m`,`g2m`,`frm`,`g2m_timesFr`),b(`g1m_timesFrAffine`,`g1m_timesScalarAffine`),b(`g2m_timesFrAffine`,`g2m_timesScalarAffine`),Xn(e,`frm_batchApplyKey`,`fmr`,`frm`,d,d,d,`frm_mul`),Xn(e,`g1m_batchApplyKey`,`g1m`,`frm`,o*3,o*3,d,`g1m_timesFr`),Xn(e,`g1m_batchApplyKeyMixed`,`g1m`,`frm`,o*2,o*3,d,`g1m_timesFrAffine`),Xn(e,`g2m_batchApplyKey`,`g2m`,`frm`,o*2*3,o*3*2,d,`g2m_timesFr`),Xn(e,`g2m_batchApplyKeyMixed`,`g2m`,`frm`,o*2*2,o*3*2,d,`g2m_timesFrAffine`);function x(e){return BigInt(e)*(1n<<BigInt(s*8))%r}let S=[3685416753713387016781088315183077757961620795782546409894578378688607592378376318836054947676345821548104185464507n,1339506544944476473020471379941921221584933875938349620426543736416511423956333506472724655353366534992391756441569n,1n],C=e.alloc([...B.bigInt2BytesLE(x(S[0]),s),...B.bigInt2BytesLE(x(S[1]),s),...B.bigInt2BytesLE(x(S[2]),s)]),w=[0n,1n,0n],T=e.alloc([...B.bigInt2BytesLE(x(w[0]),s),...B.bigInt2BytesLE(x(w[1]),s),...B.bigInt2BytesLE(x(w[2]),s)]),E=[[352701069587466618187139116011060144890029952792775240219908644239793785735715026873347600343865175952761926303160n,3059144344244213709971259814753781636986470325476647558659373206291635324768958432433509563104347017837885763365758n],[1985150602287291935568054521177171638300868978215655730859378665066344726373823718423869104263333984641494340347905n,927553665492332455747201965776037880757740193453592970025027978793976877002675564980949289727957565575433344219582n],[1n,0n]],D=e.alloc([...B.bigInt2BytesLE(x(E[0][0]),s),...B.bigInt2BytesLE(x(E[0][1]),s),...B.bigInt2BytesLE(x(E[1][0]),s),...B.bigInt2BytesLE(x(E[1][1]),s),...B.bigInt2BytesLE(x(E[2][0]),s),...B.bigInt2BytesLE(x(E[2][1]),s)]),O=[[0n,0n],[1n,0n],[0n,0n]],k=e.alloc([...B.bigInt2BytesLE(x(O[0][0]),s),...B.bigInt2BytesLE(x(O[0][1]),s),...B.bigInt2BytesLE(x(O[1][0]),s),...B.bigInt2BytesLE(x(O[1][1]),s),...B.bigInt2BytesLE(x(O[2][0]),s),...B.bigInt2BytesLE(x(O[2][1]),s)]),A=e.alloc([...B.bigInt2BytesLE(x(1n),s),...B.bigInt2BytesLE(x(0n),s),...B.bigInt2BytesLE(x(0n),s),...B.bigInt2BytesLE(x(0n),s),...B.bigInt2BytesLE(x(0n),s),...B.bigInt2BytesLE(x(0n),s),...B.bigInt2BytesLE(x(0n),s),...B.bigInt2BytesLE(x(0n),s),...B.bigInt2BytesLE(x(0n),s),...B.bigInt2BytesLE(x(0n),s),...B.bigInt2BytesLE(x(0n),s),...B.bigInt2BytesLE(x(0n),s)]),j=e.alloc([...B.bigInt2BytesLE(x(1n),s),...B.bigInt2BytesLE(x(1n),s)]);function ee(){let t=e.addFunction(_+`_mulNR`);t.addParam(`x`,`i32`),t.addParam(`pr`,`i32`);let n=t.getCodeBuilder(),r=n.i32_const(e.alloc(s)),i=n.getLocal(`x`),a=n.i32_add(n.getLocal(`x`),n.i32_const(s)),o=n.getLocal(`pr`),c=n.i32_add(n.getLocal(`pr`),n.i32_const(s));t.addCode(n.call(m+`_copy`,i,r),n.call(m+`_sub`,i,a,o),n.call(m+`_add`,r,a,c))}ee();let M=Gn(e,_+`_mulNR`,`f6m`,`f2m`);function N(){let t=e.addFunction(M+`_mulNR`);t.addParam(`x`,`i32`),t.addParam(`pr`,`i32`);let n=t.getCodeBuilder(),r=n.i32_const(e.alloc(s*2));t.addCode(n.call(_+`_copy`,n.getLocal(`x`),r),n.call(_+`_mulNR`,n.i32_add(n.getLocal(`x`),n.i32_const(o*4)),n.getLocal(`pr`)),n.call(_+`_copy`,n.i32_add(n.getLocal(`x`),n.i32_const(o*2)),n.i32_add(n.getLocal(`pr`),n.i32_const(o*4))),n.call(_+`_copy`,r,n.i32_add(n.getLocal(`pr`),n.i32_const(o*2))))}N();let P=Wn(e,M+`_mulNR`,`ftm`,M),F=oe(15132376222941642752n),te=e.alloc(F),I=3*c,L=F.length-1,ne=F.reduce((e,t)=>e+(t==0?0:1),0)+L+1,re=6*o,ie=3*o*2+ne*I,R=15132376222941642752n;e.modules[n]={n64q:a,n64r:u,n8q:o,n8r:d,pG1gen:C,pG1zero:T,pG1b:h,pG2gen:D,pG2zero:k,pG2b:v,pq:e.modules.f1m.pq,pr:p,pOneT:A,r:i,q:r,prePSize:re,preQSize:ie};function ae(e){let t=e,n=[];for(;t>0n;){if(Qn(t)){let e=2-Number(t%4n);n.push(e),t-=BigInt(e)}else n.push(0);t>>=1n}return n}function oe(e){let t=e,n=[];for(;t>0n;)Qn(t)?n.push(1):n.push(0),t>>=1n;return n}function se(){let t=e.addFunction(n+`_prepareG1`);t.addParam(`pP`,`i32`),t.addParam(`ppreP`,`i32`);let r=t.getCodeBuilder();t.addCode(r.call(g+`_normalize`,r.getLocal(`pP`),r.getLocal(`ppreP`)))}function ce(){let t=e.addFunction(n+`_prepDblStep`);t.addParam(`R`,`i32`),t.addParam(`r`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`R`),a=r.i32_add(r.getLocal(`R`),r.i32_const(2*o)),s=r.i32_add(r.getLocal(`R`),r.i32_const(4*o)),l=r.getLocal(`r`),u=r.i32_add(r.getLocal(`r`),r.i32_const(2*o)),d=r.i32_add(r.getLocal(`r`),r.i32_const(4*o)),f=r.i32_const(e.alloc(c)),p=r.i32_const(e.alloc(c)),m=r.i32_const(e.alloc(c)),h=r.i32_const(e.alloc(c)),g=r.i32_const(e.alloc(c));t.addCode(r.call(_+`_square`,i,l),r.call(_+`_square`,a,p),r.call(_+`_square`,p,m),r.call(_+`_add`,p,i,u),r.call(_+`_square`,u,u),r.call(_+`_sub`,u,l,u),r.call(_+`_sub`,u,m,u),r.call(_+`_add`,u,u,u),r.call(_+`_add`,l,l,h),r.call(_+`_add`,h,l,h),r.call(_+`_add`,i,h,d),r.call(_+`_square`,h,g),r.call(_+`_square`,s,f),r.call(_+`_sub`,g,u,i),r.call(_+`_sub`,i,u,i),r.call(_+`_add`,s,a,s),r.call(_+`_square`,s,s),r.call(_+`_sub`,s,p,s),r.call(_+`_sub`,s,f,s),r.call(_+`_sub`,u,i,a),r.call(_+`_mul`,a,h,a),r.call(_+`_add`,m,m,m),r.call(_+`_add`,m,m,m),r.call(_+`_add`,m,m,m),r.call(_+`_sub`,a,m,a),r.call(_+`_mul`,h,f,u),r.call(_+`_add`,u,u,u),r.call(_+`_neg`,u,u),r.call(_+`_square`,d,d),r.call(_+`_sub`,d,l,d),r.call(_+`_sub`,d,g,d),r.call(_+`_add`,p,p,p),r.call(_+`_add`,p,p,p),r.call(_+`_sub`,d,p,d),r.call(_+`_mul`,s,f,l),r.call(_+`_add`,l,l,l))}function le(){let t=e.addFunction(n+`_prepAddStep`);t.addParam(`R`,`i32`),t.addParam(`Q`,`i32`),t.addParam(`r`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`R`),a=r.i32_add(r.getLocal(`R`),r.i32_const(2*o)),s=r.i32_add(r.getLocal(`R`),r.i32_const(4*o)),l=r.getLocal(`Q`),u=r.i32_add(r.getLocal(`Q`),r.i32_const(2*o)),d=r.getLocal(`r`),f=r.i32_add(r.getLocal(`r`),r.i32_const(2*o)),p=r.i32_add(r.getLocal(`r`),r.i32_const(4*o)),m=r.i32_const(e.alloc(c)),h=r.i32_const(e.alloc(c)),g=r.i32_const(e.alloc(c)),v=r.i32_const(e.alloc(c)),y=r.i32_const(e.alloc(c)),b=r.i32_const(e.alloc(c)),x=r.i32_const(e.alloc(c)),S=r.i32_const(e.alloc(c)),C=r.i32_const(e.alloc(c)),w=r.i32_const(e.alloc(c)),T=r.i32_const(e.alloc(c));t.addCode(r.call(_+`_square`,s,m),r.call(_+`_square`,u,h),r.call(_+`_mul`,m,l,v),r.call(_+`_add`,u,s,f),r.call(_+`_square`,f,f),r.call(_+`_sub`,f,h,f),r.call(_+`_sub`,f,m,f),r.call(_+`_mul`,f,m,f),r.call(_+`_sub`,v,i,y),r.call(_+`_square`,y,b),r.call(_+`_add`,b,b,x),r.call(_+`_add`,x,x,x),r.call(_+`_mul`,x,y,S),r.call(_+`_sub`,f,a,C),r.call(_+`_sub`,C,a,C),r.call(_+`_mul`,C,l,p),r.call(_+`_mul`,x,i,w),r.call(_+`_square`,C,i),r.call(_+`_sub`,i,S,i),r.call(_+`_sub`,i,w,i),r.call(_+`_sub`,i,w,i),r.call(_+`_add`,s,y,s),r.call(_+`_square`,s,s),r.call(_+`_sub`,s,m,s),r.call(_+`_sub`,s,b,s),r.call(_+`_add`,u,s,d),r.call(_+`_sub`,w,i,T),r.call(_+`_mul`,T,C,T),r.call(_+`_mul`,a,S,v),r.call(_+`_add`,v,v,v),r.call(_+`_sub`,T,v,a),r.call(_+`_square`,d,d),r.call(_+`_sub`,d,h,d),r.call(_+`_square`,s,g),r.call(_+`_sub`,d,g,d),r.call(_+`_add`,p,p,p),r.call(_+`_sub`,p,d,p),r.call(_+`_add`,s,s,d),r.call(_+`_neg`,C,C),r.call(_+`_add`,C,C,f))}function ue(){let t=e.addFunction(n+`_prepareG2`);t.addParam(`pQ`,`i32`),t.addParam(`ppreQ`,`i32`),t.addLocal(`pCoef`,`i32`),t.addLocal(`i`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`pQ`),a=e.alloc(c*3),o=r.i32_const(a),s=r.getLocal(`ppreQ`);t.addCode(r.call(y+`_normalize`,i,s),r.if(r.call(y+`_isZero`,s),r.ret([])),r.call(y+`_copy`,s,o),r.setLocal(`pCoef`,r.i32_add(r.getLocal(`ppreQ`),r.i32_const(c*3)))),t.addCode(r.setLocal(`i`,r.i32_const(F.length-2)),r.block(r.loop(r.call(n+`_prepDblStep`,o,r.getLocal(`pCoef`)),r.setLocal(`pCoef`,r.i32_add(r.getLocal(`pCoef`),r.i32_const(I))),r.if(r.i32_load8_s(r.getLocal(`i`),te),[...r.call(n+`_prepAddStep`,o,s,r.getLocal(`pCoef`)),...r.setLocal(`pCoef`,r.i32_add(r.getLocal(`pCoef`),r.i32_const(I)))]),r.br_if(1,r.i32_eqz(r.getLocal(`i`))),r.setLocal(`i`,r.i32_sub(r.getLocal(`i`),r.i32_const(1))),r.br(0))))}function de(){let t=e.addFunction(M+`_mul1`);t.addParam(`pA`,`i32`),t.addParam(`pC1`,`i32`),t.addParam(`pR`,`i32`);let n=t.getCodeBuilder(),r=n.getLocal(`pA`),i=n.i32_add(n.getLocal(`pA`),n.i32_const(s*2)),a=n.i32_add(n.getLocal(`pA`),n.i32_const(s*4)),o=n.getLocal(`pC1`),c=n.getLocal(`pR`),l=n.i32_add(n.getLocal(`pR`),n.i32_const(s*2)),u=n.i32_add(n.getLocal(`pR`),n.i32_const(s*4)),d=n.i32_const(e.alloc(s*2)),f=n.i32_const(e.alloc(s*2));t.addCode(n.call(_+`_add`,r,i,d),n.call(_+`_add`,i,a,f),n.call(_+`_mul`,i,o,u),n.call(_+`_mul`,f,o,c),n.call(_+`_sub`,c,u,c),n.call(_+`_mulNR`,c,c),n.call(_+`_mul`,d,o,l),n.call(_+`_sub`,l,u,l))}de();function fe(){let t=e.addFunction(M+`_mul01`);t.addParam(`pA`,`i32`),t.addParam(`pC0`,`i32`),t.addParam(`pC1`,`i32`),t.addParam(`pR`,`i32`);let n=t.getCodeBuilder(),r=n.getLocal(`pA`),i=n.i32_add(n.getLocal(`pA`),n.i32_const(s*2)),a=n.i32_add(n.getLocal(`pA`),n.i32_const(s*4)),o=n.getLocal(`pC0`),c=n.getLocal(`pC1`),l=n.getLocal(`pR`),u=n.i32_add(n.getLocal(`pR`),n.i32_const(s*2)),d=n.i32_add(n.getLocal(`pR`),n.i32_const(s*4)),f=n.i32_const(e.alloc(s*2)),p=n.i32_const(e.alloc(s*2)),m=n.i32_const(e.alloc(s*2)),h=n.i32_const(e.alloc(s*2));t.addCode(n.call(_+`_mul`,r,o,f),n.call(_+`_mul`,i,c,p),n.call(_+`_add`,r,i,m),n.call(_+`_add`,r,a,h),n.call(_+`_add`,i,a,l),n.call(_+`_mul`,l,c,l),n.call(_+`_sub`,l,p,l),n.call(_+`_mulNR`,l,l),n.call(_+`_add`,l,f,l),n.call(_+`_add`,o,c,u),n.call(_+`_mul`,u,m,u),n.call(_+`_sub`,u,f,u),n.call(_+`_sub`,u,p,u),n.call(_+`_mul`,h,o,d),n.call(_+`_sub`,d,f,d),n.call(_+`_add`,d,p,d))}fe();function pe(){let t=e.addFunction(P+`_mul014`);t.addParam(`pA`,`i32`),t.addParam(`pC0`,`i32`),t.addParam(`pC1`,`i32`),t.addParam(`pC4`,`i32`),t.addParam(`pR`,`i32`);let n=t.getCodeBuilder(),r=n.getLocal(`pA`),i=n.i32_add(n.getLocal(`pA`),n.i32_const(s*6)),a=n.getLocal(`pC0`),o=n.getLocal(`pC1`),c=n.getLocal(`pC4`),l=n.i32_const(e.alloc(s*6)),u=n.i32_const(e.alloc(s*6)),d=n.i32_const(e.alloc(s*2)),f=n.getLocal(`pR`),p=n.i32_add(n.getLocal(`pR`),n.i32_const(s*6));t.addCode(n.call(M+`_mul01`,r,a,o,l),n.call(M+`_mul1`,i,c,u),n.call(_+`_add`,o,c,d),n.call(M+`_add`,i,r,p),n.call(M+`_mul01`,p,a,d,p),n.call(M+`_sub`,p,l,p),n.call(M+`_sub`,p,u,p),n.call(M+`_copy`,u,f),n.call(M+`_mulNR`,f,f),n.call(M+`_add`,f,l,f))}pe();function me(){let t=e.addFunction(n+`_ell`);t.addParam(`pP`,`i32`),t.addParam(`pCoefs`,`i32`),t.addParam(`pF`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`pP`),a=r.i32_add(r.getLocal(`pP`),r.i32_const(o)),c=r.getLocal(`pF`),l=r.getLocal(`pCoefs`),u=r.i32_add(r.getLocal(`pCoefs`),r.i32_const(s)),d=r.i32_add(r.getLocal(`pCoefs`),r.i32_const(s*2)),f=r.i32_add(r.getLocal(`pCoefs`),r.i32_const(s*3)),p=r.i32_add(r.getLocal(`pCoefs`),r.i32_const(s*4)),h=e.alloc(s*2),g=r.i32_const(h),_=r.i32_const(h),v=r.i32_const(h+s),y=e.alloc(s*2),b=r.i32_const(y),x=r.i32_const(y),S=r.i32_const(y+s);t.addCode(r.call(m+`_mul`,l,a,_),r.call(m+`_mul`,u,a,v),r.call(m+`_mul`,d,i,x),r.call(m+`_mul`,f,i,S),r.call(P+`_mul014`,c,p,b,g,c))}me();function he(){let t=e.addFunction(n+`_millerLoop`);t.addParam(`ppreP`,`i32`),t.addParam(`ppreQ`,`i32`),t.addParam(`r`,`i32`),t.addLocal(`pCoef`,`i32`),t.addLocal(`i`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`ppreP`),a=r.getLocal(`pCoef`),o=r.getLocal(`r`);t.addCode(r.call(P+`_one`,o),r.if(r.call(g+`_isZero`,i),r.ret([])),r.if(r.call(g+`_isZero`,r.getLocal(`ppreQ`)),r.ret([])),r.setLocal(`pCoef`,r.i32_add(r.getLocal(`ppreQ`),r.i32_const(c*3))),r.setLocal(`i`,r.i32_const(F.length-2)),r.block(r.loop(r.call(n+`_ell`,i,a,o),r.setLocal(`pCoef`,r.i32_add(r.getLocal(`pCoef`),r.i32_const(I))),r.if(r.i32_load8_s(r.getLocal(`i`),te),[...r.call(n+`_ell`,i,a,o),...r.setLocal(`pCoef`,r.i32_add(r.getLocal(`pCoef`),r.i32_const(I)))]),r.call(P+`_square`,o,o),r.br_if(1,r.i32_eq(r.getLocal(`i`),r.i32_const(1))),r.setLocal(`i`,r.i32_sub(r.getLocal(`i`),r.i32_const(1))),r.br(0))),r.call(n+`_ell`,i,a,o)),t.addCode(r.call(P+`_conjugate`,o,o))}function ge(t){let n=[[[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n]],[[1n,0n],[3850754370037169011952147076051364057158807420970682438676050522613628423219637725072182697113062777891589506424760n,151655185184498381465642749684540099398075398968325446656007613510403227271200139370504932015952886146304766135027n],[793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620351n,0n],[2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530n,1028732146235106349975324479215795277384839936929757896155643118032610843298655225875571310552543014690878354869257n],[793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350n,0n],[3125332594171059424908108096204648978570118281977575435832422631601824034463382777937621250592425535493320683825557n,877076961050607968509681729531255177986764537961432449499635504522207616027455086505066378536590128544573588734230n],[4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559786n,0n],[151655185184498381465642749684540099398075398968325446656007613510403227271200139370504932015952886146304766135027n,3850754370037169011952147076051364057158807420970682438676050522613628423219637725072182697113062777891589506424760n],[4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n,0n],[1028732146235106349975324479215795277384839936929757896155643118032610843298655225875571310552543014690878354869257n,2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530n],[4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939437n,0n],[877076961050607968509681729531255177986764537961432449499635504522207616027455086505066378536590128544573588734230n,3125332594171059424908108096204648978570118281977575435832422631601824034463382777937621250592425535493320683825557n]]],i=[[[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n],[1n,0n]],[[1n,0n],[0n,4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n],[793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350n,0n],[0n,1n],[4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n,0n],[0n,793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350n]],[[1n,0n],[4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939437n,0n],[4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n,0n],[4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559786n,0n],[793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350n,0n],[793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620351n,0n]]],a=e.addFunction(P+`_frobeniusMap`+t);a.addParam(`x`,`i32`),a.addParam(`r`,`i32`);let l=a.getCodeBuilder();for(let r=0;r<6;r++){let d=r==0?l.getLocal(`x`):l.i32_add(l.getLocal(`x`),l.i32_const(r*c)),f=d,p=l.i32_add(l.getLocal(`x`),l.i32_const(r*c+s)),h=r==0?l.getLocal(`r`):l.i32_add(l.getLocal(`r`),l.i32_const(r*c)),g=h,v=l.i32_add(l.getLocal(`r`),l.i32_const(r*c+s)),y=u(n[Math.floor(r/3)][t%12],i[r%3][t%6]),b=e.alloc([...B.bigInt2BytesLE(x(y[0]),o),...B.bigInt2BytesLE(x(y[1]),o)]);t%2==1?a.addCode(l.call(m+`_copy`,f,g),l.call(m+`_neg`,p,v),l.call(_+`_mul`,h,l.i32_const(b),h)):a.addCode(l.call(_+`_mul`,d,l.i32_const(b),h))}function u(e,t){let n=e[0],i=e[1],a=t[0],o=t[1],s=[(n*a-i*o)%r,(n*o+i*a)%r];return $n(s[0])&&(s[0]+=r),s}}function _e(){let t=e.addFunction(n+`__cyclotomicSquare`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`x`),a=r.i32_add(r.getLocal(`x`),r.i32_const(c)),o=r.i32_add(r.getLocal(`x`),r.i32_const(2*c)),s=r.i32_add(r.getLocal(`x`),r.i32_const(3*c)),l=r.i32_add(r.getLocal(`x`),r.i32_const(4*c)),u=r.i32_add(r.getLocal(`x`),r.i32_const(5*c)),d=r.getLocal(`r`),f=r.i32_add(r.getLocal(`r`),r.i32_const(c)),p=r.i32_add(r.getLocal(`r`),r.i32_const(2*c)),m=r.i32_add(r.getLocal(`r`),r.i32_const(3*c)),h=r.i32_add(r.getLocal(`r`),r.i32_const(4*c)),g=r.i32_add(r.getLocal(`r`),r.i32_const(5*c)),v=r.i32_const(e.alloc(c)),y=r.i32_const(e.alloc(c)),b=r.i32_const(e.alloc(c)),x=r.i32_const(e.alloc(c)),S=r.i32_const(e.alloc(c)),C=r.i32_const(e.alloc(c)),w=r.i32_const(e.alloc(c)),T=r.i32_const(e.alloc(c));t.addCode(r.call(_+`_mul`,i,l,w),r.call(_+`_mulNR`,l,v),r.call(_+`_add`,i,v,v),r.call(_+`_add`,i,l,T),r.call(_+`_mul`,T,v,v),r.call(_+`_mulNR`,w,T),r.call(_+`_add`,w,T,T),r.call(_+`_sub`,v,T,v),r.call(_+`_add`,w,w,y),r.call(_+`_mul`,s,o,w),r.call(_+`_mulNR`,o,b),r.call(_+`_add`,s,b,b),r.call(_+`_add`,s,o,T),r.call(_+`_mul`,T,b,b),r.call(_+`_mulNR`,w,T),r.call(_+`_add`,w,T,T),r.call(_+`_sub`,b,T,b),r.call(_+`_add`,w,w,x),r.call(_+`_mul`,a,u,w),r.call(_+`_mulNR`,u,S),r.call(_+`_add`,a,S,S),r.call(_+`_add`,a,u,T),r.call(_+`_mul`,T,S,S),r.call(_+`_mulNR`,w,T),r.call(_+`_add`,w,T,T),r.call(_+`_sub`,S,T,S),r.call(_+`_add`,w,w,C),r.call(_+`_sub`,v,i,d),r.call(_+`_add`,d,d,d),r.call(_+`_add`,v,d,d),r.call(_+`_add`,y,l,h),r.call(_+`_add`,h,h,h),r.call(_+`_add`,y,h,h),r.call(_+`_mul`,C,r.i32_const(j),T),r.call(_+`_add`,T,s,m),r.call(_+`_add`,m,m,m),r.call(_+`_add`,T,m,m),r.call(_+`_sub`,S,o,p),r.call(_+`_add`,p,p,p),r.call(_+`_add`,S,p,p),r.call(_+`_sub`,b,a,f),r.call(_+`_add`,f,f,f),r.call(_+`_add`,b,f,f),r.call(_+`_add`,x,u,g),r.call(_+`_add`,g,g,g),r.call(_+`_add`,x,g,g))}function ve(t,r,i){let a=ae(t).map(e=>e==-1?255:e),o=e.alloc(a),s=e.addFunction(n+`__cyclotomicExp_`+i);s.addParam(`x`,`i32`),s.addParam(`r`,`i32`),s.addLocal(`bit`,`i32`),s.addLocal(`i`,`i32`);let c=s.getCodeBuilder(),u=c.getLocal(`x`),d=c.getLocal(`r`),f=c.i32_const(e.alloc(l));s.addCode(c.call(P+`_conjugate`,u,f),c.call(P+`_one`,d),c.if(c.teeLocal(`bit`,c.i32_load8_s(c.i32_const(a.length-1),o)),c.if(c.i32_eq(c.getLocal(`bit`),c.i32_const(1)),c.call(P+`_mul`,d,u,d),c.call(P+`_mul`,d,f,d))),c.setLocal(`i`,c.i32_const(a.length-2)),c.block(c.loop(c.call(n+`__cyclotomicSquare`,d,d),c.if(c.teeLocal(`bit`,c.i32_load8_s(c.getLocal(`i`),o)),c.if(c.i32_eq(c.getLocal(`bit`),c.i32_const(1)),c.call(P+`_mul`,d,u,d),c.call(P+`_mul`,d,f,d))),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)))),r&&s.addCode(c.call(P+`_conjugate`,d,d))}function ye(){_e(),ve(R,!0,`w0`);let t=e.addFunction(n+`_finalExponentiation`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let r=t.getCodeBuilder(),i=r.getLocal(`x`),a=r.getLocal(`r`),o=r.i32_const(e.alloc(l)),s=r.i32_const(e.alloc(l)),c=r.i32_const(e.alloc(l)),u=r.i32_const(e.alloc(l)),d=r.i32_const(e.alloc(l)),f=r.i32_const(e.alloc(l)),p=r.i32_const(e.alloc(l));t.addCode(r.call(P+`_frobeniusMap6`,i,o),r.call(P+`_inverse`,i,s),r.call(P+`_mul`,o,s,c),r.call(P+`_copy`,c,s),r.call(P+`_frobeniusMap2`,c,c),r.call(P+`_mul`,c,s,c),r.call(n+`__cyclotomicSquare`,c,s),r.call(P+`_conjugate`,s,s),r.call(n+`__cyclotomicExp_w0`,c,u),r.call(n+`__cyclotomicSquare`,u,d),r.call(P+`_mul`,s,u,f),r.call(n+`__cyclotomicExp_w0`,f,s),r.call(n+`__cyclotomicExp_w0`,s,o),r.call(n+`__cyclotomicExp_w0`,o,p),r.call(P+`_mul`,p,d,p),r.call(n+`__cyclotomicExp_w0`,p,d),r.call(P+`_conjugate`,f,f),r.call(P+`_mul`,d,f,d),r.call(P+`_mul`,d,c,d),r.call(P+`_conjugate`,c,f),r.call(P+`_mul`,s,c,s),r.call(P+`_frobeniusMap3`,s,s),r.call(P+`_mul`,p,f,p),r.call(P+`_frobeniusMap1`,p,p),r.call(P+`_mul`,u,o,u),r.call(P+`_frobeniusMap2`,u,u),r.call(P+`_mul`,u,s,u),r.call(P+`_mul`,u,p,u),r.call(P+`_mul`,u,d,a))}function be(){let t=e.addFunction(n+`_finalExponentiationOld`);t.addParam(`x`,`i32`),t.addParam(`r`,`i32`);let r=e.alloc(B.bigInt2BytesLE(322277361516934140462891564586510139908379969514828494218366688025288661041104682794998680497580008899973249814104447692778988208376779573819485263026159588510513834876303014016798809919343532899164848730280942609956670917565618115867287399623286813270357901731510188149934363360381614501334086825442271920079363289954510565375378443704372994881406797882676971082200626541916413184642520269678897559532260949334760604962086348898118982248842634379637598665468817769075878555493752214492790122785850202957575200176084204422751485957336465472324810982833638490904279282696134323072515220044451592646885410572234451732790590013479358343841220074174848221722017083597872017638514103174122784843925578370430843522959600095676285723737049438346544753168912974976791528535276317256904336520179281145394686565050419250614107803233314658825463117900250701199181529205942363159325765991819433914303908860460720581408201373164047773794825411011922305820065611121544561808414055302212057471395719432072209245600258134364584636810093520285711072578721435517884103526483832733289802426157301542744476740008494780363354305116978805620671467071400711358839553375340724899735460480144599782014906586543813292157922220645089192130209334926661588737007768565838519456601560804957985667880395221049249803753582637708560n,544)),i=t.getCodeBuilder();t.addCode(i.call(P+`_exp`,i.getLocal(`x`),i.i32_const(r),i.i32_const(544),i.getLocal(`r`)))}let xe=e.alloc(re),Se=e.alloc(ie);function Ce(t){let r=e.addFunction(n+`_pairingEq`+t);for(let e=0;e<t;e++)r.addParam(`p_`+e,`i32`),r.addParam(`q_`+e,`i32`);r.addParam(`c`,`i32`),r.setReturnType(`i32`);let i=r.getCodeBuilder(),a=i.i32_const(e.alloc(l)),o=i.i32_const(e.alloc(l));r.addCode(i.call(P+`_one`,a));for(let e=0;e<t;e++)r.addCode(i.call(n+`_prepareG1`,i.getLocal(`p_`+e),i.i32_const(xe))),r.addCode(i.call(n+`_prepareG2`,i.getLocal(`q_`+e),i.i32_const(Se))),r.addCode(i.if(i.i32_eqz(i.call(g+`_inGroupAffine`,i.i32_const(xe))),i.ret(i.i32_const(0))),i.if(i.i32_eqz(i.call(y+`_inGroupAffine`,i.i32_const(Se))),i.ret(i.i32_const(0)))),r.addCode(i.call(n+`_millerLoop`,i.i32_const(xe),i.i32_const(Se),o)),r.addCode(i.call(P+`_mul`,a,o,a));r.addCode(i.call(n+`_finalExponentiation`,a,a)),r.addCode(i.call(P+`_eq`,a,i.getLocal(`c`)))}function we(){let t=e.addFunction(n+`_pairing`);t.addParam(`p`,`i32`),t.addParam(`q`,`i32`),t.addParam(`r`,`i32`);let r=t.getCodeBuilder(),i=r.i32_const(e.alloc(l));t.addCode(r.call(n+`_prepareG1`,r.getLocal(`p`),r.i32_const(xe))),t.addCode(r.call(n+`_prepareG2`,r.getLocal(`q`),r.i32_const(Se))),t.addCode(r.call(n+`_millerLoop`,r.i32_const(xe),r.i32_const(Se),i)),t.addCode(r.call(n+`_finalExponentiation`,i,r.getLocal(`r`)))}function Te(){let t=e.addFunction(y+`_inGroupAffine`);t.addParam(`p`,`i32`),t.setReturnType(`i32`);let n=t.getCodeBuilder(),r=[2001204777610833696708894912867952078278441409969503942666029068062015825245418932221343814564507832018947136279894n,2001204777610833696708894912867952078278441409969503942666029068062015825245418932221343814564507832018947136279893n],i=[2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530n,2973677408986561043442465346520108879172042883009249989176415018091420807192182638567116318576472649347015917690530n],a=n.i32_const(e.alloc([...B.bigInt2BytesLE(x(r[0]),o),...B.bigInt2BytesLE(x(r[1]),o)])),l=n.i32_const(e.alloc(B.bigInt2BytesLE(x(4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n),o))),u=n.i32_const(e.alloc([...B.bigInt2BytesLE(x(i[0]),o),...B.bigInt2BytesLE(x(i[1]),o)])),d=n.i32_const(e.alloc(B.bigInt2BytesLE(R,8))),f=n.getLocal(`p`),p=n.i32_add(n.getLocal(`p`),n.i32_const(c)),h=n.i32_const(e.alloc(s)),g=n.i32_const(e.alloc(c)),v=n.i32_const(e.alloc(c)),b=e.alloc(c*2),S=n.i32_const(b),C=n.i32_const(b),w=n.i32_const(b),T=n.i32_const(b+s),E=n.i32_const(b+c),D=n.i32_const(b+c),O=n.i32_const(b+c+s),k=e.alloc(c*3),A=n.i32_const(k),j=n.i32_const(k),ee=n.i32_const(k),M=n.i32_const(k+s),N=n.i32_const(k+c),P=n.i32_const(k+c),F=n.i32_const(k+c+s),te=n.i32_const(k+c*2);t.addCode(n.if(n.call(y+`_isZeroAffine`,n.getLocal(`p`)),n.ret(n.i32_const(1))),n.if(n.i32_eqz(n.call(y+`_inCurveAffine`,n.getLocal(`p`))),n.ret(n.i32_const(0))),n.call(_+`_mul`,f,a,g),n.call(_+`_mul`,p,a,v),n.call(_+`_mul1`,g,l,C),n.call(_+`_neg`,v,E),n.call(_+`_neg`,g,j),n.call(_+`_mul`,v,u,N),n.call(m+`_sub`,w,T,h),n.call(m+`_add`,w,T,T),n.call(m+`_copy`,h,w),n.call(m+`_sub`,D,O,h),n.call(m+`_add`,D,O,O),n.call(m+`_copy`,h,D),n.call(m+`_add`,ee,M,h),n.call(m+`_sub`,ee,M,M),n.call(m+`_copy`,h,ee),n.call(m+`_sub`,F,P,h),n.call(m+`_add`,P,F,F),n.call(m+`_copy`,h,P),n.call(_+`_one`,te),n.call(y+`_timesScalar`,A,d,n.i32_const(8),A),n.call(y+`_addMixed`,A,S,A),n.ret(n.call(y+`_eqMixed`,A,n.getLocal(`p`))));let I=e.addFunction(y+`_inGroup`);I.addParam(`pIn`,`i32`),I.setReturnType(`i32`);let L=I.getCodeBuilder(),ne=L.i32_const(e.alloc(c*2));I.addCode(L.call(y+`_toAffine`,L.getLocal(`pIn`),ne),L.ret(L.call(y+`_inGroupAffine`,ne)))}function Ee(){let t=e.addFunction(g+`_inGroupAffine`);t.addParam(`p`,`i32`),t.setReturnType(`i32`);let n=t.getCodeBuilder(),r=(R*R-1n)/3n,i=n.i32_const(e.alloc(B.bigInt2BytesLE(x(4002409555221667392624310435006688643935503118305586438271171395842971157480381377015405980053539358417135540939436n),o))),a=n.i32_const(e.alloc(B.bigInt2BytesLE(x(793479390729215512621379701633421447060886740281060493010456487427281649075476305620758731620350n),o))),c=n.i32_const(e.alloc(B.bigInt2BytesLE(r,16))),l=n.getLocal(`p`),u=n.i32_add(n.getLocal(`p`),n.i32_const(s)),d=e.alloc(s*3),f=n.i32_const(d),p=n.i32_const(d),h=n.i32_const(d+s),_=e.alloc(s*2),v=n.i32_const(_),y=n.i32_const(_),b=n.i32_const(_+s);t.addCode(n.if(n.call(g+`_isZeroAffine`,n.getLocal(`p`)),n.ret(n.i32_const(1))),n.if(n.i32_eqz(n.call(g+`_inCurveAffine`,n.getLocal(`p`))),n.ret(n.i32_const(0))),n.call(m+`_mul`,l,i,p),n.call(m+`_copy`,u,h),n.call(m+`_mul`,l,a,y),n.call(m+`_copy`,u,b),n.call(g+`_doubleAffine`,f,f),n.call(g+`_subMixed`,f,n.getLocal(`p`),f),n.call(g+`_subMixed`,f,v,f),n.call(g+`_timesScalar`,f,c,n.i32_const(16),f),n.ret(n.call(g+`_eqMixed`,f,v)));let S=e.addFunction(g+`_inGroup`);S.addParam(`pIn`,`i32`),S.setReturnType(`i32`);let C=S.getCodeBuilder(),w=C.i32_const(e.alloc(s*2));S.addCode(C.call(g+`_toAffine`,C.getLocal(`pIn`),w),C.ret(C.call(g+`_inGroupAffine`,w)))}for(let t=0;t<10;t++)ge(t),e.exportFunction(P+`_frobeniusMap`+t);Ee(),Te(),le(),ce(),se(),ue(),he(),be(),ye();for(let t=1;t<=5;t++)Ce(t),e.exportFunction(n+`_pairingEq`+t);we(),e.exportFunction(n+`_pairing`),e.exportFunction(n+`_prepareG1`),e.exportFunction(n+`_prepareG2`),e.exportFunction(n+`_millerLoop`),e.exportFunction(n+`_finalExponentiation`),e.exportFunction(n+`_finalExponentiationOld`),e.exportFunction(n+`__cyclotomicSquare`),e.exportFunction(n+`__cyclotomicExp_w0`),e.exportFunction(M+`_mul1`),e.exportFunction(M+`_mul01`),e.exportFunction(P+`_mul014`),e.exportFunction(g+`_inGroupAffine`),e.exportFunction(g+`_inGroup`),e.exportFunction(y+`_inGroupAffine`),e.exportFunction(y+`_inGroup`)},tr=Vn,nr=er;function rr(e){if(typeof e==`bigint`||e.eq!==void 0)return e.toString(10);if(e instanceof Uint8Array)return He(e,0);if(Array.isArray(e))return e.map(rr);if(typeof e==`object`){let t={};return Object.keys(e).forEach(n=>{t[n]=rr(e[n])}),t}else return e}function ir(e){if(typeof e==`string`&&/^[0-9]+$/.test(e)||typeof e==`string`&&/^0x[0-9a-fA-F]+$/.test(e))return BigInt(e);if(Array.isArray(e))return e.map(ir);if(typeof e==`object`){if(e===null)return null;let t={};return Object.keys(e).forEach(n=>{t[n]=ir(e[n])}),t}else return e}function ar(e){let t=BigInt(0),n=e.length,r=0,i=new DataView(e.buffer,e.byteOffset,e.byteLength);for(;n>0;)n>=4?(n-=4,t+=BigInt(i.getUint32(n))<<BigInt(r*8),r+=4):n>=2?(n-=2,t+=BigInt(i.getUint16(n))<<BigInt(r*8),r+=2):(--n,t+=BigInt(i.getUint8(n))<<BigInt(r*8),r+=1);return t}function or(e,t){let n=e,r=new Uint8Array(t),i=new DataView(r.buffer),a=t;for(;a>0;)a-4>=0?(a-=4,i.setUint32(a,Number(n&BigInt(4294967295))),n>>=BigInt(32)):a-2>=0?(a-=2,i.setUint16(a,Number(n&BigInt(65535))),n>>=BigInt(16)):(--a,i.setUint8(a,Number(n&BigInt(255))),n>>=BigInt(8));if(n)throw Error(`Number does not fit in this length`);return r}function sr(e){let t=BigInt(0),n=0,r=new DataView(e.buffer,e.byteOffset,e.byteLength);for(;n<e.length;)n+4<=e.length?(t+=BigInt(r.getUint32(n,!0))<<BigInt(n*8),n+=4):n+2<=e.length?(t+=BigInt(r.getUint16(n,!0))<<BigInt(n*8),n+=2):(t+=BigInt(r.getUint8(n,!0))<<BigInt(n*8),n+=1);return t}function cr(e,t){let n=e;t===void 0&&(t=Math.floor((oe(e)-1)/8)+1,t==0&&(t=1));let r=new Uint8Array(t),i=new DataView(r.buffer),a=0;for(;a<t;)a+4<=t?(i.setUint32(a,Number(n&BigInt(4294967295)),!0),a+=4,n>>=BigInt(32)):a+2<=t?(i.setUint16(a,Number(n&BigInt(65535)),!0),a+=2,n>>=BigInt(16)):(i.setUint8(a,Number(n&BigInt(255)),!0),a+=1,n>>=BigInt(8));if(n)throw Error(`Number does not fit in this length`);return r}function lr(e,t){if(typeof t==`bigint`||t.eq!==void 0)return t.toString(10);if(t instanceof Uint8Array)return e.toString(e.e(t));if(Array.isArray(t))return t.map(lr.bind(this,e));if(typeof t==`object`){let n={};return Object.keys(t).forEach(r=>{n[r]=lr(e,t[r])}),n}else return t}function ur(e,t){if(typeof t==`string`&&/^[0-9]+$/.test(t)||typeof t==`string`&&/^0x[0-9a-fA-F]+$/.test(t))return e.e(t);if(Array.isArray(t))return t.map(ur.bind(this,e));if(typeof t==`object`){if(t===null)return null;let n={};return Object.keys(t).forEach(r=>{n[r]=ur(e,t[r])}),n}else return t}const dr=[];for(let e=0;e<256;e++)dr[e]=fr(e,8);function fr(e,t){let n=0,r=e;for(let e=0;e<t;e++)n<<=1,n|=r&1,r>>=1;return n}function pr(e,t){return(dr[e>>>24]|dr[e>>>16&255]<<8|dr[e>>>8&255]<<16|dr[e&255]<<24)>>>32-t}function mr(e){return(e&4294901760?(e&=4294901760,16):0)|(e&4278255360?(e&=4278255360,8):0)|(e&4042322160?(e&=4042322160,4):0)|(e&3435973836?(e&=3435973836,2):0)|(e&2863311530)!=0}function hr(e,t){let n=e.byteLength/t,r=mr(n);if(n!=1<<r)throw Error(`Invalid number of pointers`);for(let i=0;i<n;i++){let n=pr(i,r);if(i>n){let r=e.slice(i*t,(i+1)*t);e.set(e.slice(n*t,(n+1)*t),i*t),e.set(r,n*t)}}}function gr(e,t){let n=new Uint8Array(t*e.length);for(let r=0;r<e.length;r++)n.set(e[r],r*t);return n}function _r(e,t){let n=e.byteLength/t,r=Array(n);for(let i=0;i<n;i++)r[i]=e.slice(i*t,i*t+t);return r}var vr=Object.freeze({__proto__:null,array2buffer:gr,beBuff2int:ar,beInt2Buff:or,bitReverse:pr,buffReverseBits:hr,buffer2array:_r,leBuff2int:sr,leInt2Buff:cr,log2:mr,stringifyBigInts:rr,stringifyFElements:lr,unstringifyBigInts:ir,unstringifyFElements:ur});const yr=1<<30;var V=class e{constructor(e){this.buffers=[],this.byteLength=e;for(let t=0;t<e;t+=yr){let n=Math.min(e-t,yr);this.buffers.push(new Uint8Array(n))}}slice(t,n){n===void 0&&(n=this.byteLength),t===void 0&&(t=0);let r=n-t,i=Math.floor(t/yr);if(i==Math.floor((t+r-1)/yr)||r==0)return this.buffers[i].slice(t%yr,t%yr+r);let a,o=i,s=t%yr,c=r;for(;c>0;){let t=s+c>yr?yr-s:c,n=new Uint8Array(this.buffers[o].buffer,this.buffers[o].byteOffset+s,t);if(t==r)return n.slice();a||=r<=yr?new Uint8Array(r):new e(r),a.set(n,r-c),c-=t,o++,s=0}return a}set(t,n){n===void 0&&(n=0);let r=t.byteLength;if(r==0)return;let i=Math.floor(n/yr);if(i==Math.floor((n+r-1)/yr))return t instanceof e&&t.buffers.length==1?this.buffers[i].set(t.buffers[0],n%yr):this.buffers[i].set(t,n%yr);let a=i,o=n%yr,s=r;for(;s>0;){let e=o+s>yr?yr-o:s,n=t.slice(r-s,r-s+e);new Uint8Array(this.buffers[a].buffer,this.buffers[a].byteOffset+o,e).set(n),s-=e,a++,o=0}}};function br(e,t,n,r){return async function(i){let a=Math.floor(i.byteLength/n);if(a*n!==i.byteLength)throw Error(`Invalid buffer size`);let o=Math.floor(a/e.concurrency),s=[];for(let c=0;c<e.concurrency;c++){let l;if(l=c<e.concurrency-1?o:a-c*o,l==0)continue;let u=[{cmd:`ALLOCSET`,var:0,buff:i.slice(c*o*n,c*o*n+l*n)},{cmd:`ALLOC`,var:1,len:r*l},{cmd:`CALL`,fnName:t,params:[{var:0},{val:l},{var:1}]},{cmd:`GET`,out:0,var:1,len:r*l}];s.push(e.queueAction(u))}let c=await Promise.all(s),l;l=i instanceof V?new V(a*r):new Uint8Array(a*r);let u=0;for(let e=0;e<c.length;e++)l.set(c[e][0],u),u+=c[e][0].byteLength;return l}}var xr=class{constructor(e,t,n,r){if(this.tm=e,this.prefix=t,this.p=r,this.n8=n,this.type=`F1`,this.m=1,this.half=ue(r,qe),this.bitLength=oe(r),this.mask=ye(le(qe,this.bitLength),qe),this.pOp1=e.alloc(n),this.pOp2=e.alloc(n),this.pOp3=e.alloc(n),this.tm.instance.exports[t+`_zero`](this.pOp1),this.zero=this.tm.getBuff(this.pOp1,this.n8),this.tm.instance.exports[t+`_one`](this.pOp1),this.one=this.tm.getBuff(this.pOp1,this.n8),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one),this.n64=Math.floor(n/8),this.n32=Math.floor(n/4),this.n64*8!=this.n8)throw Error(`n8 must be a multiple of 8`);this.half=ue(this.p,qe),this.nqr=this.two;let i=this.exp(this.nqr,this.half);for(;!this.eq(i,this.negone);)this.nqr=this.add(this.nqr,this.one),i=this.exp(this.nqr,this.half);this.shift=this.mul(this.nqr,this.nqr),this.shiftInv=this.inv(this.shift),this.s=0;let a=ye(this.p,qe);for(;!pe(a);)this.s+=1,a=ue(a,qe);this.w=[],this.w[this.s]=this.exp(this.nqr,a);for(let e=this.s-1;e>=0;e--)this.w[e]=this.square(this.w[e+1]);if(!this.eq(this.w[0],this.one))throw Error(`Error calculating roots of unity`);this.batchToMontgomery=br(e,t+`_batchToMontgomery`,this.n8,this.n8),this.batchFromMontgomery=br(e,t+`_batchFromMontgomery`,this.n8,this.n8)}op2(e,t,n){return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,n),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(e,t,n){return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,n),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2)}op1(e,t){return this.tm.setBuff(this.pOp1,t),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op1Bool(e,t){return this.tm.setBuff(this.pOp1,t),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3)}add(e,t){return this.op2(`_add`,e,t)}eq(e,t){return this.op2Bool(`_eq`,e,t)}isZero(e){return this.op1Bool(`_isZero`,e)}sub(e,t){return this.op2(`_sub`,e,t)}neg(e){return this.op1(`_neg`,e)}inv(e){return this.op1(`_inverse`,e)}toMontgomery(e){return this.op1(`_toMontgomery`,e)}fromMontgomery(e){return this.op1(`_fromMontgomery`,e)}mul(e,t){return this.op2(`_mul`,e,t)}div(e,t){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,t),this.tm.instance.exports[this.prefix+`_inverse`](this.pOp2,this.pOp2),this.tm.instance.exports[this.prefix+`_mul`](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}square(e){return this.op1(`_square`,e)}isSquare(e){return this.op1Bool(`_isSquare`,e)}sqrt(e){return this.op1(`_sqrt`,e)}exp(e,t){return t instanceof Uint8Array||(t=Ge(R(t))),this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,t),this.tm.instance.exports[this.prefix+`_exp`](this.pOp1,this.pOp2,t.byteLength,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}isNegative(e){return this.op1Bool(`_isNegative`,e)}e(e,t){if(e instanceof Uint8Array)return e;let n=R(e,t);se(n)?(n=be(n),je(n,this.p)&&(n=De(n,this.p)),n=ye(this.p,n)):je(n,this.p)&&(n=De(n,this.p));let r=cr(n,this.n8);return this.toMontgomery(r)}toString(e,t){return We(He(this.fromMontgomery(e),0),t)}fromRng(e){let t,n=new Uint8Array(this.n8);do{t=Ke;for(let n=0;n<this.n64;n++)t=ve(t,le(e.nextU64(),64*n));t=Pe(t,this.mask)}while(Ne(t,this.p));return Be(n,0,t,this.n8),n}random(){return this.fromRng(ft())}toObject(e){return He(this.fromMontgomery(e),0)}fromObject(e){let t=new Uint8Array(this.n8);return Be(t,0,e,this.n8),this.toMontgomery(t)}toRprLE(e,t,n){e.set(this.fromMontgomery(n),t)}toRprBE(e,t,n){let r=this.fromMontgomery(n);for(let e=0;e<this.n8/2;e++){let t=r[e];r[e]=r[this.n8-1-e],r[this.n8-1-e]=t}e.set(r,t)}fromRprLE(e,t){t||=0;let n=e.slice(t,t+this.n8);return this.toMontgomery(n)}async batchInverse(e){let t=!1,n=this.n8,r=this.n8;Array.isArray(e)?(e=gr(e,n),t=!0):e=e.slice(0,e.byteLength);let i=Math.floor(e.byteLength/n);if(i*n!==e.byteLength)throw Error(`Invalid buffer size`);let a=Math.floor(i/this.tm.concurrency),o=[];for(let t=0;t<this.tm.concurrency;t++){let s;if(s=t<this.tm.concurrency-1?a:i-t*a,s==0)continue;let c=[{cmd:`ALLOCSET`,var:0,buff:e.slice(t*a*n,t*a*n+s*n)},{cmd:`ALLOC`,var:1,len:r*s},{cmd:`CALL`,fnName:this.prefix+`_batchInverse`,params:[{var:0},{val:n},{val:s},{var:1},{val:r}]},{cmd:`GET`,out:0,var:1,len:r*s}];o.push(this.tm.queueAction(c))}let s=await Promise.all(o),c;c=e instanceof V?new V(i*r):new Uint8Array(i*r);let l=0;for(let e=0;e<s.length;e++)c.set(s[e][0],l),l+=s[e][0].byteLength;return t?_r(c,r):c}},Sr=class{constructor(e,t,n){this.tm=e,this.prefix=t,this.F=n,this.type=`F2`,this.m=n.m*2,this.n8=this.F.n8*2,this.n32=this.F.n32*2,this.n64=this.F.n64*2,this.pOp1=e.alloc(n.n8*2),this.pOp2=e.alloc(n.n8*2),this.pOp3=e.alloc(n.n8*2),this.tm.instance.exports[t+`_zero`](this.pOp1),this.zero=e.getBuff(this.pOp1,this.n8),this.tm.instance.exports[t+`_one`](this.pOp1),this.one=e.getBuff(this.pOp1,this.n8),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one)}op2(e,t,n){return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,n),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(e,t,n){return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,n),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2)}op1(e,t){return this.tm.setBuff(this.pOp1,t),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op1Bool(e,t){return this.tm.setBuff(this.pOp1,t),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3)}add(e,t){return this.op2(`_add`,e,t)}eq(e,t){return this.op2Bool(`_eq`,e,t)}isZero(e){return this.op1Bool(`_isZero`,e)}sub(e,t){return this.op2(`_sub`,e,t)}neg(e){return this.op1(`_neg`,e)}inv(e){return this.op1(`_inverse`,e)}isNegative(e){return this.op1Bool(`_isNegative`,e)}toMontgomery(e){return this.op1(`_toMontgomery`,e)}fromMontgomery(e){return this.op1(`_fromMontgomery`,e)}mul(e,t){return this.op2(`_mul`,e,t)}mul1(e,t){return this.op2(`_mul1`,e,t)}div(e,t){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,t),this.tm.instance.exports[this.prefix+`_inverse`](this.pOp2,this.pOp2),this.tm.instance.exports[this.prefix+`_mul`](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}square(e){return this.op1(`_square`,e)}isSquare(e){return this.op1Bool(`_isSquare`,e)}sqrt(e){return this.op1(`_sqrt`,e)}exp(e,t){return t instanceof Uint8Array||(t=Ge(R(t))),this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,t),this.tm.instance.exports[this.prefix+`_exp`](this.pOp1,this.pOp2,t.byteLength,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}e(e,t){if(e instanceof Uint8Array)return e;if(Array.isArray(e)&&e.length==2){let n=this.F.e(e[0],t),r=this.F.e(e[1],t),i=new Uint8Array(this.F.n8*2);return i.set(n),i.set(r,this.F.n8*2),i}else throw Error(`invalid F2`)}toString(e,t){return`[${this.F.toString(e.slice(0,this.F.n8),t)}, ${this.F.toString(e.slice(this.F.n8),t)}]`}fromRng(e){let t=this.F.fromRng(e),n=this.F.fromRng(e),r=new Uint8Array(this.F.n8*2);return r.set(t),r.set(n,this.F.n8),r}random(){return this.fromRng(ft())}toObject(e){return[this.F.toObject(e.slice(0,this.F.n8)),this.F.toObject(e.slice(this.F.n8,this.F.n8*2))]}fromObject(e){let t=new Uint8Array(this.F.n8*2),n=this.F.fromObject(e[0]),r=this.F.fromObject(e[1]);return t.set(n),t.set(r,this.F.n8),t}c1(e){return e.slice(0,this.F.n8)}c2(e){return e.slice(this.F.n8)}},Cr=class{constructor(e,t,n){this.tm=e,this.prefix=t,this.F=n,this.type=`F3`,this.m=n.m*3,this.n8=this.F.n8*3,this.n32=this.F.n32*3,this.n64=this.F.n64*3,this.pOp1=e.alloc(n.n8*3),this.pOp2=e.alloc(n.n8*3),this.pOp3=e.alloc(n.n8*3),this.tm.instance.exports[t+`_zero`](this.pOp1),this.zero=e.getBuff(this.pOp1,this.n8),this.tm.instance.exports[t+`_one`](this.pOp1),this.one=e.getBuff(this.pOp1,this.n8),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one)}op2(e,t,n){return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,n),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op2Bool(e,t,n){return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,n),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2)}op1(e,t){return this.tm.setBuff(this.pOp1,t),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}op1Bool(e,t){return this.tm.setBuff(this.pOp1,t),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3)}eq(e,t){return this.op2Bool(`_eq`,e,t)}isZero(e){return this.op1Bool(`_isZero`,e)}add(e,t){return this.op2(`_add`,e,t)}sub(e,t){return this.op2(`_sub`,e,t)}neg(e){return this.op1(`_neg`,e)}inv(e){return this.op1(`_inverse`,e)}isNegative(e){return this.op1Bool(`_isNegative`,e)}toMontgomery(e){return this.op1(`_toMontgomery`,e)}fromMontgomery(e){return this.op1(`_fromMontgomery`,e)}mul(e,t){return this.op2(`_mul`,e,t)}div(e,t){return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,t),this.tm.instance.exports[this.prefix+`_inverse`](this.pOp2,this.pOp2),this.tm.instance.exports[this.prefix+`_mul`](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.n8)}square(e){return this.op1(`_square`,e)}isSquare(e){return this.op1Bool(`_isSquare`,e)}sqrt(e){return this.op1(`_sqrt`,e)}exp(e,t){return t instanceof Uint8Array||(t=Ge(R(t))),this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,t),this.tm.instance.exports[this.prefix+`_exp`](this.pOp1,this.pOp2,t.byteLength,this.pOp3),this.getBuff(this.pOp3,this.n8)}e(e,t){if(e instanceof Uint8Array)return e;if(Array.isArray(e)&&e.length==3){let n=this.F.e(e[0],t),r=this.F.e(e[1],t),i=this.F.e(e[2],t),a=new Uint8Array(this.F.n8*3);return a.set(n),a.set(r,this.F.n8),a.set(i,this.F.n8*2),a}else throw Error(`invalid F3`)}toString(e,t){return`[${this.F.toString(e.slice(0,this.F.n8),t)}, ${this.F.toString(e.slice(this.F.n8,this.F.n8*2),t)}, ${this.F.toString(e.slice(this.F.n8*2),t)}]`}fromRng(e){let t=this.F.fromRng(e),n=this.F.fromRng(e),r=this.F.fromRng(e),i=new Uint8Array(this.F.n8*3);return i.set(t),i.set(n,this.F.n8),i.set(r,this.F.n8*2),i}random(){return this.fromRng(ft())}toObject(e){return[this.F.toObject(e.slice(0,this.F.n8)),this.F.toObject(e.slice(this.F.n8,this.F.n8*2)),this.F.toObject(e.slice(this.F.n8*2,this.F.n8*3))]}fromObject(e){let t=new Uint8Array(this.F.n8*3),n=this.F.fromObject(e[0]),r=this.F.fromObject(e[1]),i=this.F.fromObject(e[2]);return t.set(n),t.set(r,this.F.n8),t.set(i,this.F.n8*2),t}c1(e){return e.slice(0,this.F.n8)}c2(e){return e.slice(this.F.n8,this.F.n8*2)}c3(e){return e.slice(this.F.n8*2)}},wr=class{constructor(e,t,n,r,i,a){this.tm=e,this.prefix=t,this.F=n,this.pOp1=e.alloc(n.n8*3),this.pOp2=e.alloc(n.n8*3),this.pOp3=e.alloc(n.n8*3),this.tm.instance.exports[t+`_zero`](this.pOp1),this.zero=this.tm.getBuff(this.pOp1,n.n8*3),this.tm.instance.exports[t+`_zeroAffine`](this.pOp1),this.zeroAffine=this.tm.getBuff(this.pOp1,n.n8*2),this.one=this.tm.getBuff(r,n.n8*3),this.g=this.one,this.oneAffine=this.tm.getBuff(r,n.n8*2),this.gAffine=this.oneAffine,this.b=this.tm.getBuff(i,n.n8),a&&(this.cofactor=Ge(a)),this.negone=this.neg(this.one),this.two=this.add(this.one,this.one),this.batchLEMtoC=br(e,t+`_batchLEMtoC`,n.n8*2,n.n8),this.batchLEMtoU=br(e,t+`_batchLEMtoU`,n.n8*2,n.n8*2),this.batchCtoLEM=br(e,t+`_batchCtoLEM`,n.n8,n.n8*2),this.batchUtoLEM=br(e,t+`_batchUtoLEM`,n.n8*2,n.n8*2),this.batchToJacobian=br(e,t+`_batchToJacobian`,n.n8*2,n.n8*3),this.batchToAffine=br(e,t+`_batchToAffine`,n.n8*3,n.n8*2)}op2(e,t,n){return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,n),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}op2bool(e,t,n){return this.tm.setBuff(this.pOp1,t),this.tm.setBuff(this.pOp2,n),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp2,this.pOp3)}op1(e,t){return this.tm.setBuff(this.pOp1,t),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}op1Affine(e,t){return this.tm.setBuff(this.pOp1,t),this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*2)}op1Bool(e,t){return this.tm.setBuff(this.pOp1,t),!!this.tm.instance.exports[this.prefix+e](this.pOp1,this.pOp3)}add(e,t){if(e.byteLength==this.F.n8*3){if(t.byteLength==this.F.n8*3)return this.op2(`_add`,e,t);if(t.byteLength==this.F.n8*2)return this.op2(`_addMixed`,e,t);throw Error(`invalid point size`)}else if(e.byteLength==this.F.n8*2){if(t.byteLength==this.F.n8*3)return this.op2(`_addMixed`,t,e);if(t.byteLength==this.F.n8*2)return this.op2(`_addAffine`,e,t);throw Error(`invalid point size`)}else throw Error(`invalid point size`)}sub(e,t){if(e.byteLength==this.F.n8*3){if(t.byteLength==this.F.n8*3)return this.op2(`_sub`,e,t);if(t.byteLength==this.F.n8*2)return this.op2(`_subMixed`,e,t);throw Error(`invalid point size`)}else if(e.byteLength==this.F.n8*2){if(t.byteLength==this.F.n8*3)return this.op2(`_subMixed`,t,e);if(t.byteLength==this.F.n8*2)return this.op2(`_subAffine`,e,t);throw Error(`invalid point size`)}else throw Error(`invalid point size`)}neg(e){if(e.byteLength==this.F.n8*3)return this.op1(`_neg`,e);if(e.byteLength==this.F.n8*2)return this.op1Affine(`_negAffine`,e);throw Error(`invalid point size`)}double(e){if(e.byteLength==this.F.n8*3)return this.op1(`_double`,e);if(e.byteLength==this.F.n8*2)return this.op1(`_doubleAffine`,e);throw Error(`invalid point size`)}isZero(e){if(e.byteLength==this.F.n8*3)return this.op1Bool(`_isZero`,e);if(e.byteLength==this.F.n8*2)return this.op1Bool(`_isZeroAffine`,e);throw Error(`invalid point size`)}timesScalar(e,t){t instanceof Uint8Array||(t=Ge(R(t)));let n;if(e.byteLength==this.F.n8*3)n=this.prefix+`_timesScalar`;else if(e.byteLength==this.F.n8*2)n=this.prefix+`_timesScalarAffine`;else throw Error(`invalid point size`);return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,t),this.tm.instance.exports[n](this.pOp1,this.pOp2,t.byteLength,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}timesFr(e,t){let n;if(e.byteLength==this.F.n8*3)n=this.prefix+`_timesFr`;else if(e.byteLength==this.F.n8*2)n=this.prefix+`_timesFrAffine`;else throw Error(`invalid point size`);return this.tm.setBuff(this.pOp1,e),this.tm.setBuff(this.pOp2,t),this.tm.instance.exports[n](this.pOp1,this.pOp2,this.pOp3),this.tm.getBuff(this.pOp3,this.F.n8*3)}eq(e,t){if(e.byteLength==this.F.n8*3){if(t.byteLength==this.F.n8*3)return this.op2bool(`_eq`,e,t);if(t.byteLength==this.F.n8*2)return this.op2bool(`_eqMixed`,e,t);throw Error(`invalid point size`)}else if(e.byteLength==this.F.n8*2){if(t.byteLength==this.F.n8*3)return this.op2bool(`_eqMixed`,t,e);if(t.byteLength==this.F.n8*2)return this.op2bool(`_eqAffine`,e,t);throw Error(`invalid point size`)}else throw Error(`invalid point size`)}toAffine(e){if(e.byteLength==this.F.n8*3)return this.op1Affine(`_toAffine`,e);if(e.byteLength==this.F.n8*2)return e;throw Error(`invalid point size`)}toJacobian(e){if(e.byteLength==this.F.n8*3)return e;if(e.byteLength==this.F.n8*2)return this.op1(`_toJacobian`,e);throw Error(`invalid point size`)}toRprUncompressed(e,t,n){if(this.tm.setBuff(this.pOp1,n),n.byteLength==this.F.n8*3)this.tm.instance.exports[this.prefix+`_toAffine`](this.pOp1,this.pOp1);else if(n.byteLength!=this.F.n8*2)throw Error(`invalid point size`);this.tm.instance.exports[this.prefix+`_LEMtoU`](this.pOp1,this.pOp1);let r=this.tm.getBuff(this.pOp1,this.F.n8*2);e.set(r,t)}fromRprUncompressed(e,t){let n=e.slice(t,t+this.F.n8*2);return this.tm.setBuff(this.pOp1,n),this.tm.instance.exports[this.prefix+`_UtoLEM`](this.pOp1,this.pOp1),this.tm.getBuff(this.pOp1,this.F.n8*2)}toRprCompressed(e,t,n){if(this.tm.setBuff(this.pOp1,n),n.byteLength==this.F.n8*3)this.tm.instance.exports[this.prefix+`_toAffine`](this.pOp1,this.pOp1);else if(n.byteLength!=this.F.n8*2)throw Error(`invalid point size`);this.tm.instance.exports[this.prefix+`_LEMtoC`](this.pOp1,this.pOp1);let r=this.tm.getBuff(this.pOp1,this.F.n8);e.set(r,t)}fromRprCompressed(e,t){let n=e.slice(t,t+this.F.n8);return this.tm.setBuff(this.pOp1,n),this.tm.instance.exports[this.prefix+`_CtoLEM`](this.pOp1,this.pOp2),this.tm.getBuff(this.pOp2,this.F.n8*2)}toUncompressed(e){let t=new Uint8Array(this.F.n8*2);return this.toRprUncompressed(t,0,e),t}toRprLEM(e,t,n){if(n.byteLength==this.F.n8*2){e.set(n,t);return}else if(n.byteLength==this.F.n8*3){this.tm.setBuff(this.pOp1,n),this.tm.instance.exports[this.prefix+`_toAffine`](this.pOp1,this.pOp1);let r=this.tm.getBuff(this.pOp1,this.F.n8*2);e.set(r,t)}else throw Error(`invalid point size`)}fromRprLEM(e,t){return t||=0,e.slice(t,t+this.F.n8*2)}toString(e,t){if(e.byteLength==this.F.n8*3)return`[ ${this.F.toString(e.slice(0,this.F.n8),t)}, ${this.F.toString(e.slice(this.F.n8,this.F.n8*2),t)}, ${this.F.toString(e.slice(this.F.n8*2),t)} ]`;if(e.byteLength==this.F.n8*2)return`[ ${this.F.toString(e.slice(0,this.F.n8),t)}, ${this.F.toString(e.slice(this.F.n8),t)} ]`;throw Error(`invalid point size`)}isValid(e){if(this.isZero(e))return!0;let t=this.F,n=this.toAffine(e),r=n.slice(0,this.F.n8),i=n.slice(this.F.n8,this.F.n8*2),a=t.add(t.mul(t.square(r),r),this.b),o=t.square(i);return t.eq(a,o)}fromRng(e){let t=this.F,n=[],r,i;do n[0]=t.fromRng(e),r=e.nextBool(),i=t.add(t.mul(t.square(n[0]),n[0]),this.b);while(!t.isSquare(i));n[1]=t.sqrt(i);let a=t.isNegative(n[1]);r^a&&(n[1]=t.neg(n[1]));let o=new Uint8Array(this.F.n8*2);return o.set(n[0]),o.set(n[1],this.F.n8),this.cofactor&&(o=this.timesScalar(o,this.cofactor)),o}toObject(e){if(this.isZero(e))return[this.F.toObject(this.F.zero),this.F.toObject(this.F.one),this.F.toObject(this.F.zero)];let t=this.F.toObject(e.slice(0,this.F.n8)),n=this.F.toObject(e.slice(this.F.n8,this.F.n8*2)),r;return r=e.byteLength==this.F.n8*3?this.F.toObject(e.slice(this.F.n8*2,this.F.n8*3)):this.F.toObject(this.F.one),[t,n,r]}fromObject(e){let t=this.F.fromObject(e[0]),n=this.F.fromObject(e[1]),r;if(r=e.length==3?this.F.fromObject(e[2]):this.F.one,this.F.isZero(r,this.F.one))return this.zeroAffine;if(this.F.eq(r,this.F.one)){let e=new Uint8Array(this.F.n8*2);return e.set(t),e.set(n,this.F.n8),e}else{let e=new Uint8Array(this.F.n8*3);return e.set(t),e.set(n,this.F.n8),e.set(r,this.F.n8*2),e}}e(e){return e instanceof Uint8Array?e:this.fromObject(e)}x(e){return this.toAffine(e).slice(0,this.F.n8)}y(e){return this.toAffine(e).slice(this.F.n8)}};function Tr(e){let t=32767,n,r;e&&(e.onmessage=function(t){let n;if(n=t.data?t.data:t,n[0].cmd==`INIT`)i(n[0]).then(function(){e.postMessage(n.result)});else if(n[0].cmd==`TERMINATE`)e.close();else{let t=l(n);e.postMessage(t)}});async function i(e){let i=new Uint8Array(e.code),a=await WebAssembly.compile(i);r=new WebAssembly.Memory({initial:e.init,maximum:t}),n=await WebAssembly.instantiate(a,{env:{memory:r}})}function a(e){let n=new Uint32Array(r.buffer,0,1);for(;n[0]&3;)n[0]++;let i=n[0];if(n[0]+=e,n[0]+e>r.buffer.byteLength){let i=r.buffer.byteLength/65536,a=Math.floor((n[0]+e)/65536)+1;a>t&&(a=t),r.grow(a-i)}return i}function o(e){let t=a(e.byteLength);return c(t,e),t}function s(e,t){let n=new Uint8Array(r.buffer);return new Uint8Array(n.buffer,n.byteOffset+e,t)}function c(e,t){new Uint8Array(r.buffer).set(new Uint8Array(t),e)}function l(e){if(e[0].cmd==`INIT`)return i(e[0]);let t={vars:[],out:[]},l=new Uint32Array(r.buffer,0,1)[0];for(let r=0;r<e.length;r++)switch(e[r].cmd){case`ALLOCSET`:t.vars[e[r].var]=o(e[r].buff);break;case`ALLOC`:t.vars[e[r].var]=a(e[r].len);break;case`SET`:c(t.vars[e[r].var],e[r].buff);break;case`CALL`:{let i=[];for(let n=0;n<e[r].params.length;n++){let a=e[r].params[n];a.var===void 0?a.val!==void 0&&i.push(a.val):i.push(t.vars[a.var]+(a.offset||0))}n.exports[e[r].fnName](...i);break}case`GET`:t.out[e[r].out]=s(t.vars[e[r].var],e[r].len).slice();break;default:throw Error(`Invalid cmd`)}let u=new Uint32Array(r.buffer,0,1);return u[0]=l,t.out}return l}var Er=class{constructor(){this.promise=new Promise((e,t)=>{this.reject=t,this.resolve=e})}};function Dr(e){return new Promise(t=>setTimeout(t,e))}let Or;const kr=`(function thread(self) {
|
|
4
|
+
const MAXMEM = 32767;
|
|
5
|
+
let instance;
|
|
6
|
+
let memory;
|
|
7
|
+
|
|
8
|
+
if (self) {
|
|
9
|
+
self.onmessage = function(e) {
|
|
10
|
+
let data;
|
|
11
|
+
if (e.data) {
|
|
12
|
+
data = e.data;
|
|
13
|
+
} else {
|
|
14
|
+
data = e;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (data[0].cmd == "INIT") {
|
|
18
|
+
init(data[0]).then(function() {
|
|
19
|
+
self.postMessage(data.result);
|
|
20
|
+
});
|
|
21
|
+
} else if (data[0].cmd == "TERMINATE") {
|
|
22
|
+
self.close();
|
|
23
|
+
} else {
|
|
24
|
+
const res = runTask(data);
|
|
25
|
+
self.postMessage(res);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function init(data) {
|
|
31
|
+
const code = new Uint8Array(data.code);
|
|
32
|
+
const wasmModule = await WebAssembly.compile(code);
|
|
33
|
+
memory = new WebAssembly.Memory({initial:data.init, maximum: MAXMEM});
|
|
34
|
+
|
|
35
|
+
instance = await WebAssembly.instantiate(wasmModule, {
|
|
36
|
+
env: {
|
|
37
|
+
"memory": memory
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
function alloc(length) {
|
|
45
|
+
const u32 = new Uint32Array(memory.buffer, 0, 1);
|
|
46
|
+
while (u32[0] & 3) u32[0]++; // Return always aligned pointers
|
|
47
|
+
const res = u32[0];
|
|
48
|
+
u32[0] += length;
|
|
49
|
+
if (u32[0] + length > memory.buffer.byteLength) {
|
|
50
|
+
const currentPages = memory.buffer.byteLength / 0x10000;
|
|
51
|
+
let requiredPages = Math.floor((u32[0] + length) / 0x10000)+1;
|
|
52
|
+
if (requiredPages>MAXMEM) requiredPages=MAXMEM;
|
|
53
|
+
memory.grow(requiredPages-currentPages);
|
|
54
|
+
}
|
|
55
|
+
return res;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function allocBuffer(buffer) {
|
|
59
|
+
const p = alloc(buffer.byteLength);
|
|
60
|
+
setBuffer(p, buffer);
|
|
61
|
+
return p;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getBuffer(pointer, length) {
|
|
65
|
+
const u8 = new Uint8Array(memory.buffer);
|
|
66
|
+
return new Uint8Array(u8.buffer, u8.byteOffset + pointer, length);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function setBuffer(pointer, buffer) {
|
|
70
|
+
const u8 = new Uint8Array(memory.buffer);
|
|
71
|
+
u8.set(new Uint8Array(buffer), pointer);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function runTask(task) {
|
|
75
|
+
if (task[0].cmd == "INIT") {
|
|
76
|
+
return init(task[0]);
|
|
77
|
+
}
|
|
78
|
+
const ctx = {
|
|
79
|
+
vars: [],
|
|
80
|
+
out: []
|
|
81
|
+
};
|
|
82
|
+
const u32a = new Uint32Array(memory.buffer, 0, 1);
|
|
83
|
+
const oldAlloc = u32a[0];
|
|
84
|
+
for (let i=0; i<task.length; i++) {
|
|
85
|
+
switch (task[i].cmd) {
|
|
86
|
+
case "ALLOCSET":
|
|
87
|
+
ctx.vars[task[i].var] = allocBuffer(task[i].buff);
|
|
88
|
+
break;
|
|
89
|
+
case "ALLOC":
|
|
90
|
+
ctx.vars[task[i].var] = alloc(task[i].len);
|
|
91
|
+
break;
|
|
92
|
+
case "SET":
|
|
93
|
+
setBuffer(ctx.vars[task[i].var], task[i].buff);
|
|
94
|
+
break;
|
|
95
|
+
case "CALL": {
|
|
96
|
+
const params = [];
|
|
97
|
+
for (let j=0; j<task[i].params.length; j++) {
|
|
98
|
+
const p = task[i].params[j];
|
|
99
|
+
if (typeof p.var !== "undefined") {
|
|
100
|
+
params.push(ctx.vars[p.var] + (p.offset || 0));
|
|
101
|
+
} else if (typeof p.val != "undefined") {
|
|
102
|
+
params.push(p.val);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
instance.exports[task[i].fnName](...params);
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case "GET":
|
|
109
|
+
ctx.out[task[i].out] = getBuffer(ctx.vars[task[i].var], task[i].len).slice();
|
|
110
|
+
break;
|
|
111
|
+
default:
|
|
112
|
+
throw new Error("Invalid cmd");
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const u32b = new Uint32Array(memory.buffer, 0, 1);
|
|
116
|
+
u32b[0] = oldAlloc;
|
|
117
|
+
return ctx.out;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
return runTask;
|
|
122
|
+
})(self)`;if(globalThis?.Blob){let e=new TextEncoder().encode(kr),t=new Blob([e],{type:`application/javascript`});Or=URL.createObjectURL(t)}else Or=`data:application/javascript;base64,`+globalThis.btoa(kr);async function Ar(e,t){let n=new jr;n.memory=new WebAssembly.Memory({initial:25}),n.u8=new Uint8Array(n.memory.buffer),n.u32=new Uint32Array(n.memory.buffer);let r=await WebAssembly.compile(e.code);if(n.instance=await WebAssembly.instantiate(r,{env:{memory:n.memory}}),globalThis?.Worker||(t=!0),n.singleThread=t,n.initalPFree=n.u32[0],n.pq=e.pq,n.pr=e.pr,n.pG1gen=e.pG1gen,n.pG1zero=e.pG1zero,n.pG2gen=e.pG2gen,n.pG2zero=e.pG2zero,n.pOneT=e.pOneT,t)n.code=e.code,n.taskManager=Tr(),await n.taskManager([{cmd:`INIT`,init:25,code:n.code.slice()}]),n.concurrency=1;else{n.workers=[],n.pendingDeferreds=[],n.working=[];let t=2;typeof navigator==`object`&&navigator.hardwareConcurrency&&(t=navigator.hardwareConcurrency),t==0&&(t=2),t>64&&(t=64),n.concurrency=t;for(let e=0;e<t;e++)n.workers[e]=new Worker(Or),n.workers[e].addEventListener(`message`,i(e)),n.working[e]=!1;let r=[];for(let t=0;t<n.workers.length;t++){let i=e.code.slice();r.push(n.postAction(t,[{cmd:`INIT`,init:25,code:i}],[i.buffer]))}await Promise.all(r)}return n;function i(e){return function(t){let r;r=t&&t.data?t.data:t,n.working[e]=!1,n.pendingDeferreds[e].resolve(r),n.processWorks()}}}var jr=class{constructor(){this.actionQueue=[],this.oldPFree=0}startSyncOp(){if(this.oldPFree!=0)throw Error(`Sync operation in progress`);this.oldPFree=this.u32[0]}endSyncOp(){if(this.oldPFree==0)throw Error(`No sync operation in progress`);this.u32[0]=this.oldPFree,this.oldPFree=0}postAction(e,t,n,r){if(this.working[e])throw Error(`Posting a job t a working worker`);return this.working[e]=!0,this.pendingDeferreds[e]=r||new Er,this.workers[e].postMessage(t,n),this.pendingDeferreds[e].promise}processWorks(){for(let e=0;e<this.workers.length&&this.actionQueue.length>0;e++)if(this.working[e]==0){let t=this.actionQueue.shift();this.postAction(e,t.data,t.transfers,t.deferred)}}queueAction(e,t){let n=new Er;if(this.singleThread){let t=this.taskManager(e);n.resolve(t)}else this.actionQueue.push({data:e,transfers:t,deferred:n}),this.processWorks();return n.promise}resetMemory(){this.u32[0]=this.initalPFree}allocBuff(e){let t=this.alloc(e.byteLength);return this.setBuff(t,e),t}getBuff(e,t){return this.u8.slice(e,e+t)}setBuff(e,t){this.u8.set(new Uint8Array(t),e)}alloc(e){for(;this.u32[0]&3;)this.u32[0]++;let t=this.u32[0];return this.u32[0]+=e,t}async terminate(){for(let e=0;e<this.workers.length;e++)this.workers[e].postMessage([{cmd:`TERMINATE`}]);await Dr(200)}};function Mr(e,t){let n=e[t],r=e.Fr,i=e.tm;e[t].batchApplyKey=async function(e,a,o,s,c){s||=`affine`,c||=`affine`;let l,u,d,f,p;if(t==`G1`)s==`jacobian`?(d=n.F.n8*3,l=`g1m_batchApplyKey`):(d=n.F.n8*2,l=`g1m_batchApplyKeyMixed`),f=n.F.n8*3,c==`jacobian`?p=n.F.n8*3:(u=`g1m_batchToAffine`,p=n.F.n8*2);else if(t==`G2`)s==`jacobian`?(d=n.F.n8*3,l=`g2m_batchApplyKey`):(d=n.F.n8*2,l=`g2m_batchApplyKeyMixed`),f=n.F.n8*3,c==`jacobian`?p=n.F.n8*3:(u=`g2m_batchToAffine`,p=n.F.n8*2);else if(t==`Fr`)l=`frm_batchApplyKey`,d=n.n8,f=n.n8,p=n.n8;else throw Error(`Invalid group: `+t);let m=Math.floor(e.byteLength/d),h=Math.floor(m/i.concurrency),g=[];o=r.e(o);let _=r.e(a);for(let t=0;t<i.concurrency;t++){let n;if(n=t<i.concurrency-1?h:m-t*h,n==0)continue;let a=[];a.push({cmd:`ALLOCSET`,var:0,buff:e.slice(t*h*d,t*h*d+n*d)}),a.push({cmd:`ALLOCSET`,var:1,buff:_}),a.push({cmd:`ALLOCSET`,var:2,buff:o}),a.push({cmd:`ALLOC`,var:3,len:n*Math.max(f,p)}),a.push({cmd:`CALL`,fnName:l,params:[{var:0},{val:n},{var:1},{var:2},{var:3}]}),u&&a.push({cmd:`CALL`,fnName:u,params:[{var:3},{val:n},{var:3}]}),a.push({cmd:`GET`,out:0,var:3,len:n*p}),g.push(i.queueAction(a)),_=r.mul(_,r.exp(o,n))}let v=await Promise.all(g),y;y=e instanceof V?new V(m*p):new Uint8Array(m*p);let b=0;for(let e=0;e<v.length;e++)y.set(v[e][0],b),b+=v[e][0].byteLength;return y}}function Nr(e){let t=e.tm;e.pairing=function(n,r){t.startSyncOp();let i=t.allocBuff(e.G1.toJacobian(n)),a=t.allocBuff(e.G2.toJacobian(r)),o=t.alloc(e.Gt.n8);t.instance.exports[e.name+`_pairing`](i,a,o);let s=t.getBuff(o,e.Gt.n8);return t.endSyncOp(),s},e.pairingEq=async function(){let n,r;arguments.length%2==1?(n=arguments[arguments.length-1],r=(arguments.length-1)/2):(n=e.Gt.one,r=arguments.length/2);let i=[];for(let n=0;n<r;n++){let r=[],a=e.G1.toJacobian(arguments[n*2]);r.push({cmd:`ALLOCSET`,var:0,buff:a}),r.push({cmd:`ALLOC`,var:1,len:e.prePSize});let o=e.G2.toJacobian(arguments[n*2+1]);r.push({cmd:`ALLOCSET`,var:2,buff:o}),r.push({cmd:`ALLOC`,var:3,len:e.preQSize}),r.push({cmd:`ALLOC`,var:4,len:e.Gt.n8}),r.push({cmd:`CALL`,fnName:e.name+`_prepareG1`,params:[{var:0},{var:1}]}),r.push({cmd:`CALL`,fnName:e.name+`_prepareG2`,params:[{var:2},{var:3}]}),r.push({cmd:`CALL`,fnName:e.name+`_millerLoop`,params:[{var:1},{var:3},{var:4}]}),r.push({cmd:`GET`,out:0,var:4,len:e.Gt.n8}),i.push(t.queueAction(r))}let a=await Promise.all(i);t.startSyncOp();let o=t.alloc(e.Gt.n8);t.instance.exports.ftm_one(o);for(let e=0;e<a.length;e++){let n=t.allocBuff(a[e][0]);t.instance.exports.ftm_mul(o,n,o)}t.instance.exports[e.name+`_finalExponentiation`](o,o);let s=t.allocBuff(n),c=!!t.instance.exports.ftm_eq(o,s);return t.endSyncOp(),c},e.prepareG1=function(e){this.tm.startSyncOp();let t=this.tm.allocBuff(e),n=this.tm.alloc(this.prePSize);this.tm.instance.exports[this.name+`_prepareG1`](t,n);let r=this.tm.getBuff(n,this.prePSize);return this.tm.endSyncOp(),r},e.prepareG2=function(e){this.tm.startSyncOp();let t=this.tm.allocBuff(e),n=this.tm.alloc(this.preQSize);this.tm.instance.exports[this.name+`_prepareG2`](t,n);let r=this.tm.getBuff(n,this.preQSize);return this.tm.endSyncOp(),r},e.millerLoop=function(e,t){this.tm.startSyncOp();let n=this.tm.allocBuff(e),r=this.tm.allocBuff(t),i=this.tm.alloc(this.Gt.n8);this.tm.instance.exports[this.name+`_millerLoop`](n,r,i);let a=this.tm.getBuff(i,this.Gt.n8);return this.tm.endSyncOp(),a},e.finalExponentiation=function(e){this.tm.startSyncOp();let t=this.tm.allocBuff(e),n=this.tm.alloc(this.Gt.n8);this.tm.instance.exports[this.name+`_finalExponentiation`](t,n);let r=this.tm.getBuff(n,this.Gt.n8);return this.tm.endSyncOp(),r}}const Pr=[1,1,1,1,2,3,4,5,6,7,7,8,9,10,11,12,13,13,14,15,16,16,17,17,17,17,17,17,17,17,17,17];function Fr(e,t){let n=e[t],r=n.tm;async function i(e,r,i,a,o){if(!(e instanceof Uint8Array))throw a&&a.error(`${o} _multiExpChunk buffBases is not Uint8Array`),Error(`${o} _multiExpChunk buffBases is not Uint8Array`);if(!(r instanceof Uint8Array))throw a&&a.error(`${o} _multiExpChunk buffScalars is not Uint8Array`),Error(`${o} _multiExpChunk buffScalars is not Uint8Array`);i||=`affine`;let s,c;if(t==`G1`)i==`affine`?(c=`g1m_multiexpAffine_chunk`,s=n.F.n8*2):(c=`g1m_multiexp_chunk`,s=n.F.n8*3);else if(t==`G2`)i==`affine`?(c=`g2m_multiexpAffine_chunk`,s=n.F.n8*2):(c=`g2m_multiexp_chunk`,s=n.F.n8*3);else throw Error(`Invalid group`);let l=Math.floor(e.byteLength/s);if(l==0)return n.zero;let u=Math.floor(r.byteLength/l);if(u*l!=r.byteLength)throw Error(`Scalar size does not match`);let d=Pr[mr(l)],f=Math.floor((u*8-1)/d)+1,p=[];for(let t=0;t<f;t++){let i=[{cmd:`ALLOCSET`,var:0,buff:e},{cmd:`ALLOCSET`,var:1,buff:r},{cmd:`ALLOC`,var:2,len:n.F.n8*3},{cmd:`CALL`,fnName:c,params:[{var:0},{var:1},{val:u},{val:l},{val:t*d},{val:Math.min(u*8-t*d,d)},{var:2}]},{cmd:`GET`,out:0,var:2,len:n.F.n8*3}];p.push(n.tm.queueAction(i))}let m=await Promise.all(p),h=n.zero;for(let e=m.length-1;e>=0;e--){if(!n.isZero(h))for(let e=0;e<d;e++)h=n.double(h);h=n.add(h,m[e][0])}return h}async function a(e,a,o,s,c){let l=1<<22,u=1024,d;if(t==`G1`)d=o==`affine`?n.F.n8*2:n.F.n8*3;else if(t==`G2`)d=o==`affine`?n.F.n8*2:n.F.n8*3;else throw Error(`Invalid group`);let f=Math.floor(e.byteLength/d);if(f==0)return n.zero;let p=Math.floor(a.byteLength/f);if(p*f!=a.byteLength)throw Error(`Scalar size does not match`);let m=Pr[mr(f)],h=Math.floor((p*8-1)/m)+1,g;g=Math.floor(f/(r.concurrency/h)),g>l&&(g=l),g<u&&(g=u);let _=[];for(let t=0;t<f;t+=g){s&&s.debug(`Multiexp start: ${c}: ${t}/${f}`);let n=Math.min(f-t,g),r=e.slice(t*d,(t+n)*d),l=a.slice(t*p,(t+n)*p);_.push(i(r,l,o,s,c).then(e=>(s&&s.debug(`Multiexp end: ${c}: ${t}/${f}`),e)))}let v=await Promise.all(_),y=n.zero;for(let e=v.length-1;e>=0;e--)y=n.add(y,v[e]);return y}n.multiExp=async function(e,t,n,r){return await a(e,t,`jacobian`,n,r)},n.multiExpAffine=async function(e,t,n,r){return await a(e,t,`affine`,n,r)}}function Ir(e,t){let n=e[t],r=e.Fr,i=n.tm;async function a(e,a,c,l,u,d){c||=`affine`,l||=`affine`;let f,p,m,h,g,_,v,y;t==`G1`?(c==`affine`?(f=n.F.n8*2,h=`g1m_batchToJacobian`):f=n.F.n8*3,p=n.F.n8*3,a&&(y=`g1m_fftFinal`),v=`g1m_fftJoin`,_=`g1m_fftMix`,l==`affine`?(m=n.F.n8*2,g=`g1m_batchToAffine`):m=n.F.n8*3):t==`G2`?(c==`affine`?(f=n.F.n8*2,h=`g2m_batchToJacobian`):f=n.F.n8*3,p=n.F.n8*3,a&&(y=`g2m_fftFinal`),v=`g2m_fftJoin`,_=`g2m_fftMix`,l==`affine`?(m=n.F.n8*2,g=`g2m_batchToAffine`):m=n.F.n8*3):t==`Fr`&&(f=n.n8,p=n.n8,m=n.n8,a&&(y=`frm_fftFinal`),_=`frm_fftMix`,v=`frm_fftJoin`);let b=!1;Array.isArray(e)?(e=gr(e,f),b=!0):e=e.slice(0,e.byteLength);let x=e.byteLength/f,S=mr(x);if(1<<S!=x)throw Error(`fft must be multiple of 2`);if(S==r.s+1){let t;return t=a?await s(e,c,l,u,d):await o(e,c,l,u,d),b?_r(t,m):t}let C;a&&(C=r.inv(r.e(x)));let w;hr(e,f);let T,E=Math.min(16384,x),D=x/E;for(;D<i.concurrency&&E>=16;)D*=2,E/=2;let O=mr(E),k=[];for(let t=0;t<D;t++){u&&u.debug(`${d}: fft ${S} mix start: ${t}/${D}`);let n=[];n.push({cmd:`ALLOC`,var:0,len:p*E});let r=e.slice(E*t*f,E*(t+1)*f);n.push({cmd:`SET`,var:0,buff:r}),h&&n.push({cmd:`CALL`,fnName:h,params:[{var:0},{val:E},{var:0}]});for(let e=1;e<=O;e++)n.push({cmd:`CALL`,fnName:_,params:[{var:0},{val:E},{val:e}]});O==S?(y&&(n.push({cmd:`ALLOCSET`,var:1,buff:C}),n.push({cmd:`CALL`,fnName:y,params:[{var:0},{val:E},{var:1}]})),g&&n.push({cmd:`CALL`,fnName:g,params:[{var:0},{val:E},{var:0}]}),n.push({cmd:`GET`,out:0,var:0,len:E*m})):n.push({cmd:`GET`,out:0,var:0,len:p*E}),k.push(i.queueAction(n).then(e=>(u&&u.debug(`${d}: fft ${S} mix end: ${t}/${D}`),e)))}T=await Promise.all(k);for(let e=0;e<D;e++)T[e]=T[e][0];for(let e=O+1;e<=S;e++){u&&u.debug(`${d}: fft ${S} join: ${e}/${S}`);let t=1<<S-e,n=D/t,a=[];for(let o=0;o<t;o++)for(let s=0;s<n/2;s++){let c=r.exp(r.w[e],s*E),l=r.w[e],f=o*n+s,h=o*n+s+n/2,_=[];_.push({cmd:`ALLOCSET`,var:0,buff:T[f]}),_.push({cmd:`ALLOCSET`,var:1,buff:T[h]}),_.push({cmd:`ALLOCSET`,var:2,buff:c}),_.push({cmd:`ALLOCSET`,var:3,buff:l}),_.push({cmd:`CALL`,fnName:v,params:[{var:0},{var:1},{val:E},{var:2},{var:3}]}),e==S?(y&&(_.push({cmd:`ALLOCSET`,var:4,buff:C}),_.push({cmd:`CALL`,fnName:y,params:[{var:0},{val:E},{var:4}]}),_.push({cmd:`CALL`,fnName:y,params:[{var:1},{val:E},{var:4}]})),g&&(_.push({cmd:`CALL`,fnName:g,params:[{var:0},{val:E},{var:0}]}),_.push({cmd:`CALL`,fnName:g,params:[{var:1},{val:E},{var:1}]})),_.push({cmd:`GET`,out:0,var:0,len:E*m}),_.push({cmd:`GET`,out:1,var:1,len:E*m})):(_.push({cmd:`GET`,out:0,var:0,len:E*p}),_.push({cmd:`GET`,out:1,var:1,len:E*p})),a.push(i.queueAction(_).then(r=>(u&&u.debug(`${d}: fft ${S} join ${e}/${S} ${o+1}/${t} ${s}/${n/2}`),r)))}let o=await Promise.all(a);for(let e=0;e<t;e++)for(let t=0;t<n/2;t++){let r=e*n+t,i=e*n+t+n/2,a=o.shift();T[r]=a[0],T[i]=a[1]}}if(w=e instanceof V?new V(x*m):new Uint8Array(x*m),a){w.set(T[0].slice((E-1)*m));let e=m;for(let t=D-1;t>0;t--)w.set(T[t],e),e+=E*m,delete T[t];w.set(T[0].slice(0,(E-1)*m),e),delete T[0]}else for(let e=0;e<D;e++)w.set(T[e],E*m*e),delete T[e];return b?_r(w,m):w}async function o(e,t,n,i,o){let s,l;s=e.slice(0,e.byteLength/2),l=e.slice(e.byteLength/2,e.byteLength);let u=[];[s,l]=await c(s,l,`fftJoinExt`,r.one,r.shift,t,`jacobian`,i,o),u.push(a(s,!1,`jacobian`,n,i,o)),u.push(a(l,!1,`jacobian`,n,i,o));let d=await Promise.all(u),f;return f=d[0].byteLength>1<<28?new V(d[0].byteLength*2):new Uint8Array(d[0].byteLength*2),f.set(d[0]),f.set(d[1],d[0].byteLength),f}async function s(e,t,n,i,o){let s,l;s=e.slice(0,e.byteLength/2),l=e.slice(e.byteLength/2,e.byteLength);let u=[];u.push(a(s,!0,t,`jacobian`,i,o)),u.push(a(l,!0,t,`jacobian`,i,o)),[s,l]=await Promise.all(u);let d=await c(s,l,`fftJoinExtInv`,r.one,r.shiftInv,`jacobian`,n,i,o),f;return f=d[0].byteLength>1<<28?new V(d[0].byteLength*2):new Uint8Array(d[0].byteLength*2),f.set(d[0]),f.set(d[1],d[0].byteLength),f}async function c(e,a,o,s,c,l,u,d,f){let p=65536,m,h,g,_,v,y;if(t==`G1`)l==`affine`?(v=n.F.n8*2,h=`g1m_batchToJacobian`):v=n.F.n8*3,y=n.F.n8*3,m=`g1m_`+o,u==`affine`?(g=`g1m_batchToAffine`,_=n.F.n8*2):_=n.F.n8*3;else if(t==`G2`)l==`affine`?(v=n.F.n8*2,h=`g2m_batchToJacobian`):v=n.F.n8*3,m=`g2m_`+o,y=n.F.n8*3,u==`affine`?(g=`g2m_batchToAffine`,_=n.F.n8*2):_=n.F.n8*3;else if(t==`Fr`)v=r.n8,_=r.n8,y=r.n8,m=`frm_`+o;else throw Error(`Invalid group`);if(e.byteLength!=a.byteLength)throw Error(`Invalid buffer size`);let b=Math.floor(e.byteLength/v);if(b!=1<<mr(b))throw Error(`Invalid number of points`);let x=Math.floor(b/i.concurrency);x<16&&(x=16),x>p&&(x=p);let S=[];for(let t=0;t<b;t+=x){d&&d.debug(`${f}: fftJoinExt Start: ${t}/${b}`);let n=Math.min(b-t,x),o=r.mul(s,r.exp(c,t)),l=[],u=e.slice(t*v,(t+n)*v),p=a.slice(t*v,(t+n)*v);l.push({cmd:`ALLOC`,var:0,len:y*n}),l.push({cmd:`SET`,var:0,buff:u}),l.push({cmd:`ALLOC`,var:1,len:y*n}),l.push({cmd:`SET`,var:1,buff:p}),l.push({cmd:`ALLOCSET`,var:2,buff:o}),l.push({cmd:`ALLOCSET`,var:3,buff:c}),h&&(l.push({cmd:`CALL`,fnName:h,params:[{var:0},{val:n},{var:0}]}),l.push({cmd:`CALL`,fnName:h,params:[{var:1},{val:n},{var:1}]})),l.push({cmd:`CALL`,fnName:m,params:[{var:0},{var:1},{val:n},{var:2},{var:3},{val:r.s}]}),g&&(l.push({cmd:`CALL`,fnName:g,params:[{var:0},{val:n},{var:0}]}),l.push({cmd:`CALL`,fnName:g,params:[{var:1},{val:n},{var:1}]})),l.push({cmd:`GET`,out:0,var:0,len:n*_}),l.push({cmd:`GET`,out:1,var:1,len:n*_}),S.push(i.queueAction(l).then(e=>(d&&d.debug(`${f}: fftJoinExt End: ${t}/${b}`),e)))}let C=await Promise.all(S),w,T;b*_>1<<28?(w=new V(b*_),T=new V(b*_)):(w=new Uint8Array(b*_),T=new Uint8Array(b*_));let E=0;for(let e=0;e<C.length;e++)w.set(C[e][0],E),T.set(C[e][1],E),E+=C[e][0].byteLength;return[w,T]}n.fft=async function(e,t,n,r,i){return await a(e,!1,t,n,r,i)},n.ifft=async function(e,t,n,r,i){return await a(e,!0,t,n,r,i)},n.lagrangeEvaluations=async function(e,i,o,s,l){i||=`affine`,o||=`affine`;let u;if(t==`G1`)u=i==`affine`?n.F.n8*2:n.F.n8*3;else if(t==`G2`)u=i==`affine`?n.F.n8*2:n.F.n8*3;else if(t==`Fr`)u=r.n8;else throw Error(`Invalid group`);let d=e.byteLength/u,f=mr(d);if(2**f*u!=e.byteLength)throw s&&s.error(`lagrangeEvaluations iinvalid input size`),Error(`lagrangeEvaluations invalid Input size`);if(f<=r.s)return await n.ifft(e,i,o,s,l);if(f>r.s+1)throw s&&s.error(`lagrangeEvaluations input too big`),Error(`lagrangeEvaluations input too big`);let p=e.slice(0,e.byteLength/2),m=e.slice(e.byteLength/2,e.byteLength),h=r.exp(r.shift,d/2),g=r.inv(r.sub(r.one,h));[p,m]=await c(p,m,`prepareLagrangeEvaluation`,g,r.shiftInv,i,`jacobian`,s,l+` prep`);let _=[];_.push(a(p,!0,`jacobian`,o,s,l+` t0`)),_.push(a(m,!0,`jacobian`,o,s,l+` t1`)),[p,m]=await Promise.all(_);let v;return v=p.byteLength>1<<28?new V(p.byteLength*2):new Uint8Array(p.byteLength*2),v.set(p),v.set(m,p.byteLength),v},n.fftMix=async function(e){let a=n.F.n8*3,o,s;if(t==`G1`)o=`g1m_fftMix`,s=`g1m_fftJoin`;else if(t==`G2`)o=`g2m_fftMix`,s=`g2m_fftJoin`;else if(t==`Fr`)o=`frm_fftMix`,s=`frm_fftJoin`;else throw Error(`Invalid group`);let c=Math.floor(e.byteLength/a),l=mr(c),u=1<<mr(i.concurrency);c<=u*2&&(u=1);let d=c/u,f=mr(d),p=[];for(let t=0;t<u;t++){let n=[],r=e.slice(t*d*a,(t+1)*d*a);n.push({cmd:`ALLOCSET`,var:0,buff:r});for(let e=1;e<=f;e++)n.push({cmd:`CALL`,fnName:o,params:[{var:0},{val:d},{val:e}]});n.push({cmd:`GET`,out:0,var:0,len:d*a}),p.push(i.queueAction(n))}let m=await Promise.all(p),h=[];for(let e=0;e<m.length;e++)h[e]=m[e][0];for(let e=f+1;e<=l;e++){let t=1<<l-e,n=u/t,o=[];for(let c=0;c<t;c++)for(let t=0;t<n/2;t++){let l=r.exp(r.w[e],t*d),u=r.w[e],f=c*n+t,p=c*n+t+n/2,m=[];m.push({cmd:`ALLOCSET`,var:0,buff:h[f]}),m.push({cmd:`ALLOCSET`,var:1,buff:h[p]}),m.push({cmd:`ALLOCSET`,var:2,buff:l}),m.push({cmd:`ALLOCSET`,var:3,buff:u}),m.push({cmd:`CALL`,fnName:s,params:[{var:0},{var:1},{val:d},{var:2},{var:3}]}),m.push({cmd:`GET`,out:0,var:0,len:d*a}),m.push({cmd:`GET`,out:1,var:1,len:d*a}),o.push(i.queueAction(m))}let c=await Promise.all(o);for(let e=0;e<t;e++)for(let t=0;t<n/2;t++){let r=e*n+t,i=e*n+t+n/2,a=c.shift();h[r]=a[0],h[i]=a[1]}}let g;g=e instanceof V?new V(c*a):new Uint8Array(c*a);let _=0;for(let e=0;e<u;e++)g.set(h[e],_),_+=h[e].byteLength;return g},n.fftJoin=async function(e,a,o,s){let c=n.F.n8*3,l;if(t==`G1`)l=`g1m_fftJoin`;else if(t==`G2`)l=`g2m_fftJoin`;else if(t==`Fr`)l=`frm_fftJoin`;else throw Error(`Invalid group`);if(e.byteLength!=a.byteLength)throw Error(`Invalid buffer size`);let u=Math.floor(e.byteLength/c);if(u!=1<<mr(u))throw Error(`Invalid number of points`);let d=1<<mr(i.concurrency);u<=d*2&&(d=1);let f=u/d,p=[];for(let t=0;t<d;t++){let n=[],u=r.mul(o,r.exp(s,t*f)),d=e.slice(t*f*c,(t+1)*f*c),m=a.slice(t*f*c,(t+1)*f*c);n.push({cmd:`ALLOCSET`,var:0,buff:d}),n.push({cmd:`ALLOCSET`,var:1,buff:m}),n.push({cmd:`ALLOCSET`,var:2,buff:u}),n.push({cmd:`ALLOCSET`,var:3,buff:s}),n.push({cmd:`CALL`,fnName:l,params:[{var:0},{var:1},{val:f},{var:2},{var:3}]}),n.push({cmd:`GET`,out:0,var:0,len:f*c}),n.push({cmd:`GET`,out:1,var:1,len:f*c}),p.push(i.queueAction(n))}let m=await Promise.all(p),h,g;e instanceof V?(h=new V(u*c),g=new V(u*c)):(h=new Uint8Array(u*c),g=new Uint8Array(u*c));let _=0;for(let e=0;e<m.length;e++)h.set(m[e][0],_),g.set(m[e][1],_),_+=m[e][0].byteLength;return[h,g]},n.fftFinal=async function(e,r){let a=n.F.n8*3,o=n.F.n8*2,s,c;if(t==`G1`)s=`g1m_fftFinal`,c=`g1m_batchToAffine`;else if(t==`G2`)s=`g2m_fftFinal`,c=`g2m_batchToAffine`;else throw Error(`Invalid group`);let l=Math.floor(e.byteLength/a);if(l!=1<<mr(l))throw Error(`Invalid number of points`);let u=Math.floor(l/i.concurrency),d=[];for(let t=0;t<i.concurrency;t++){let n;if(n=t<i.concurrency-1?u:l-t*u,n==0)continue;let f=[],p=e.slice(t*u*a,(t*u+n)*a);f.push({cmd:`ALLOCSET`,var:0,buff:p}),f.push({cmd:`ALLOCSET`,var:1,buff:r}),f.push({cmd:`CALL`,fnName:s,params:[{var:0},{val:n},{var:1}]}),f.push({cmd:`CALL`,fnName:c,params:[{var:0},{val:n},{var:0}]}),f.push({cmd:`GET`,out:0,var:0,len:n*o}),d.push(i.queueAction(f))}let f=await Promise.all(d),p;p=e instanceof V?new V(l*o):new Uint8Array(l*o);let m=0;for(let e=f.length-1;e>=0;e--)p.set(f[e][0],m),m+=f[e][0].byteLength;return p}}async function Lr(e){let t=await Ar(e.wasm,e.singleThread),n={};return n.q=R(e.wasm.q.toString()),n.r=R(e.wasm.r.toString()),n.name=e.name,n.tm=t,n.prePSize=e.wasm.prePSize,n.preQSize=e.wasm.preQSize,n.Fr=new xr(t,`frm`,e.n8r,e.r),n.F1=new xr(t,`f1m`,e.n8q,e.q),n.F2=new Sr(t,`f2m`,n.F1),n.G1=new wr(t,`g1m`,n.F1,e.wasm.pG1gen,e.wasm.pG1b,e.cofactorG1),n.G2=new wr(t,`g2m`,n.F2,e.wasm.pG2gen,e.wasm.pG2b,e.cofactorG2),n.F6=new Cr(t,`f6m`,n.F2),n.F12=new Sr(t,`ftm`,n.F6),n.Gt=n.F12,Mr(n,`G1`),Mr(n,`G2`),Mr(n,`Fr`),Fr(n,`G1`),Fr(n,`G2`),Ir(n,`G1`),Ir(n,`G2`),Ir(n,`Fr`),Nr(n),n.array2buffer=function(e,t){let n=new Uint8Array(t*e.length);for(let r=0;r<e.length;r++)n.set(e[r],r*t);return n},n.buffer2array=function(e,t){let n=e.byteLength/t,r=Array(n);for(let i=0;i<n;i++)r[i]=e.slice(i*t,i*t+t);return r},n}function Rr(e){return BigInt(e)}function zr(e){return e<0n}function Br(e){return e===0n}function Vr(e){return zr(e)?e.toString(2).length-1:e.toString(2).length}function Hr(e){let t=[],n=Rr(e);return t.push(Number(n&255n)),t.push(Number(n>>8n&255n)),t.push(Number(n>>16n&255n)),t.push(Number(n>>24n&255n)),t}function Ur(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t.push(r):r<2048?t.push(192|r>>6,128|r&63):r<55296||r>=57344?t.push(224|r>>12,128|r>>6&63,128|r&63):(n++,r=65536+((r&1023)<<10|e.charCodeAt(n)&1023),t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63))}return t}function Wr(e){let t=Ur(e);return[...H(t.length),...t]}function Gr(e){let t=[],n=Rr(e);if(zr(n))throw Error(`Number cannot be negative`);for(;!Br(n);)t.push(Number(n&127n)),n>>=7n;t.length==0&&t.push(0);for(let e=0;e<t.length-1;e++)t[e]=t[e]|128;return t}function Kr(e){let t,n,r=Vr(e);e<0?(n=!0,t=(1n<<BigInt(r))+e):(n=!1,t=Rr(e));let i=7-r%7,a=(1n<<BigInt(i))-1n<<BigInt(r),o=(1<<7-i)-1|128,s=Gr(t+a);return n||(s[s.length-1]=s[s.length-1]&o),s}function qr(e){let t=Rr(e);if(t>4294967295n)throw Error(`Number too big`);if(t>2147483647n&&(t-=4294967296n),t<-2147483648n)throw Error(`Number too small`);return Kr(t)}function Jr(e){let t=Rr(e);if(t>18446744073709551615n)throw Error(`Number too big`);if(t>9223372036854775807n&&(t-=18446744073709551616n),t<-9223372036854775808n)throw Error(`Number too small`);return Kr(t)}function H(e){let t=Rr(e);if(t>4294967295n)throw Error(`Number too big`);return Gr(t)}function Yr(e){return Array.from(e,function(e){return(`0`+(e&255).toString(16)).slice(-2)}).join(``)}var Xr=class{constructor(e){this.func=e,this.functionName=e.functionName,this.module=e.module}setLocal(e,t){let n=this.func.localIdxByName[e];if(n===void 0)throw Error(`Local Variable not defined: Function: ${this.functionName} local: ${e} `);return[...t,33,...H(n)]}teeLocal(e,t){let n=this.func.localIdxByName[e];if(n===void 0)throw Error(`Local Variable not defined: Function: ${this.functionName} local: ${e} `);return[...t,34,...H(n)]}getLocal(e){let t=this.func.localIdxByName[e];if(t===void 0)throw Error(`Local Variable not defined: Function: ${this.functionName} local: ${e} `);return[32,...H(t)]}i64_load8_s(e,t,n){let r=t||0,i=n===void 0?0:n;return[...e,48,i,...H(r)]}i64_load8_u(e,t,n){let r=t||0,i=n===void 0?0:n;return[...e,49,i,...H(r)]}i64_load16_s(e,t,n){let r=t||0,i=n===void 0?1:n;return[...e,50,i,...H(r)]}i64_load16_u(e,t,n){let r=t||0,i=n===void 0?1:n;return[...e,51,i,...H(r)]}i64_load32_s(e,t,n){let r=t||0,i=n===void 0?2:n;return[...e,52,i,...H(r)]}i64_load32_u(e,t,n){let r=t||0,i=n===void 0?2:n;return[...e,53,i,...H(r)]}i64_load(e,t,n){let r=t||0,i=n===void 0?3:n;return[...e,41,i,...H(r)]}i64_store(e,t,n,r){let i,a,o;return Array.isArray(t)?(i=0,a=3,o=t):Array.isArray(n)?(i=t,a=3,o=n):Array.isArray(r)&&(i=t,a=n,o=r),[...e,...o,55,a,...H(i)]}i64_store32(e,t,n,r){let i,a,o;return Array.isArray(t)?(i=0,a=2,o=t):Array.isArray(n)?(i=t,a=2,o=n):Array.isArray(r)&&(i=t,a=n,o=r),[...e,...o,62,a,...H(i)]}i64_store16(e,t,n,r){let i,a,o;return Array.isArray(t)?(i=0,a=1,o=t):Array.isArray(n)?(i=t,a=1,o=n):Array.isArray(r)&&(i=t,a=n,o=r),[...e,...o,61,a,...H(i)]}i64_store8(e,t,n,r){let i,a,o;return Array.isArray(t)?(i=0,a=0,o=t):Array.isArray(n)?(i=t,a=0,o=n):Array.isArray(r)&&(i=t,a=n,o=r),[...e,...o,60,a,...H(i)]}i32_load8_s(e,t,n){let r=t||0,i=n===void 0?0:n;return[...e,44,i,...H(r)]}i32_load8_u(e,t,n){let r=t||0,i=n===void 0?0:n;return[...e,45,i,...H(r)]}i32_load16_s(e,t,n){let r=t||0,i=n===void 0?1:n;return[...e,46,i,...H(r)]}i32_load16_u(e,t,n){let r=t||0,i=n===void 0?1:n;return[...e,47,i,...H(r)]}i32_load(e,t,n){let r=t||0,i=n===void 0?2:n;return[...e,40,i,...H(r)]}i32_store(e,t,n,r){let i,a,o;return Array.isArray(t)?(i=0,a=2,o=t):Array.isArray(n)?(i=t,a=2,o=n):Array.isArray(r)&&(i=t,a=n,o=r),[...e,...o,54,a,...H(i)]}i32_store16(e,t,n,r){let i,a,o;return Array.isArray(t)?(i=0,a=1,o=t):Array.isArray(n)?(i=t,a=1,o=n):Array.isArray(r)&&(i=t,a=n,o=r),[...e,...o,59,a,...H(i)]}i32_store8(e,t,n,r){let i,a,o;return Array.isArray(t)?(i=0,a=0,o=t):Array.isArray(n)?(i=t,a=0,o=n):Array.isArray(r)&&(i=t,a=n,o=r),[...e,...o,58,a,...H(i)]}call(e,...t){let n=this.module.functionIdxByName[e];if(n===void 0)throw Error(`Function not defined: Function: ${e}`);return[...[].concat(...t),16,...H(n)]}call_indirect(e,...t){return[...[].concat(...t),...e,17,0,0]}if(e,t,n){return n?[...e,4,64,...t,5,...n,11]:[...e,4,64,...t,11]}block(e){return[2,64,...e,11]}loop(...e){return[3,64,...[].concat(...e),11]}br_if(e,t){return[...t,13,...H(e)]}br(e){return[12,...H(e)]}ret(e){return[...e,15]}drop(e){return[...e,26]}i64_const(e){return[66,...Jr(e)]}i32_const(e){return[65,...qr(e)]}i64_eqz(e){return[...e,80]}i64_eq(e,t){return[...e,...t,81]}i64_ne(e,t){return[...e,...t,82]}i64_lt_s(e,t){return[...e,...t,83]}i64_lt_u(e,t){return[...e,...t,84]}i64_gt_s(e,t){return[...e,...t,85]}i64_gt_u(e,t){return[...e,...t,86]}i64_le_s(e,t){return[...e,...t,87]}i64_le_u(e,t){return[...e,...t,88]}i64_ge_s(e,t){return[...e,...t,89]}i64_ge_u(e,t){return[...e,...t,90]}i64_add(e,t){return[...e,...t,124]}i64_sub(e,t){return[...e,...t,125]}i64_mul(e,t){return[...e,...t,126]}i64_div_s(e,t){return[...e,...t,127]}i64_div_u(e,t){return[...e,...t,128]}i64_rem_s(e,t){return[...e,...t,129]}i64_rem_u(e,t){return[...e,...t,130]}i64_and(e,t){return[...e,...t,131]}i64_or(e,t){return[...e,...t,132]}i64_xor(e,t){return[...e,...t,133]}i64_shl(e,t){return[...e,...t,134]}i64_shr_s(e,t){return[...e,...t,135]}i64_shr_u(e,t){return[...e,...t,136]}i64_extend_i32_s(e){return[...e,172]}i64_extend_i32_u(e){return[...e,173]}i64_clz(e){return[...e,121]}i64_ctz(e){return[...e,122]}i32_eqz(e){return[...e,69]}i32_eq(e,t){return[...e,...t,70]}i32_ne(e,t){return[...e,...t,71]}i32_lt_s(e,t){return[...e,...t,72]}i32_lt_u(e,t){return[...e,...t,73]}i32_gt_s(e,t){return[...e,...t,74]}i32_gt_u(e,t){return[...e,...t,75]}i32_le_s(e,t){return[...e,...t,76]}i32_le_u(e,t){return[...e,...t,77]}i32_ge_s(e,t){return[...e,...t,78]}i32_ge_u(e,t){return[...e,...t,79]}i32_add(e,t){return[...e,...t,106]}i32_sub(e,t){return[...e,...t,107]}i32_mul(e,t){return[...e,...t,108]}i32_div_s(e,t){return[...e,...t,109]}i32_div_u(e,t){return[...e,...t,110]}i32_rem_s(e,t){return[...e,...t,111]}i32_rem_u(e,t){return[...e,...t,112]}i32_and(e,t){return[...e,...t,113]}i32_or(e,t){return[...e,...t,114]}i32_xor(e,t){return[...e,...t,115]}i32_shl(e,t){return[...e,...t,116]}i32_shr_s(e,t){return[...e,...t,117]}i32_shr_u(e,t){return[...e,...t,118]}i32_rotl(e,t){return[...e,...t,119]}i32_rotr(e,t){return[...e,...t,120]}i32_wrap_i64(e){return[...e,167]}i32_clz(e){return[...e,103]}i32_ctz(e){return[...e,104]}unreachable(){return[0]}current_memory(){return[63,0]}comment(){return[]}};const Zr={i32:127,i64:126,f32:125,f64:124,anyfunc:112,func:96,emptyblock:64};var Qr=class{constructor(e,t,n,r,i){if(n==`import`)this.fnType=`import`,this.moduleName=r,this.fieldName=i;else if(n==`internal`)this.fnType=`internal`;else throw Error(`Invalid function fnType: `+n);this.module=e,this.fnName=t,this.params=[],this.locals=[],this.localIdxByName={},this.code=[],this.returnType=null,this.nextLocal=0}addParam(e,t){if(this.localIdxByName[e])throw Error(`param already exists. Function: ${this.fnName}, Param: ${e} `);let n=this.nextLocal++;this.localIdxByName[e]=n,this.params.push({type:t})}addLocal(e,t,n){let r=n||1;if(this.localIdxByName[e])throw Error(`local already exists. Function: ${this.fnName}, Param: ${e} `);let i=this.nextLocal++;this.localIdxByName[e]=i,this.locals.push({type:t,length:r})}setReturnType(e){if(this.returnType)throw Error(`returnType already defined. Function: ${this.fnName}`);this.returnType=e}getSignature(){let e=[...H(this.params.length),...this.params.map(e=>Zr[e.type])],t=this.returnType?[1,Zr[this.returnType]]:[0];return[96,...e,...t]}getBody(){let e=this.locals.map(e=>[...H(e.length),Zr[e.type]]),t=[...H(this.locals.length),...[].concat(...e),...this.code,11];return[...H(t.length),...t]}addCode(...e){this.code.push(...[].concat(...e))}getCodeBuilder(){return new Xr(this)}},$r=class{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(){return this._setSignatures(),new Uint8Array([...Hr(1836278016),...Hr(1),...this._buildType(),...this._buildImport(),...this._buildFunctionDeclarations(),...this._buildFunctionsTable(),...this._buildExports(),...this._buildElements(),...this._buildCode(),...this._buildData()])}addFunction(e){if(this.functionIdxByName[e]!==void 0)throw Error(`Function already defined: ${e}`);let t=this.functions.length;return this.functionIdxByName[e]=t,this.functions.push(new Qr(this,e,`internal`)),this.nInternalFunctions++,this.functions[t]}addIimportFunction(e,t,n){if(this.functionIdxByName[e]!==void 0)throw Error(`Function already defined: ${e}`);if(this.functions.length>0&&this.functions[this.functions.length-1].type==`internal`)throw Error(`Import functions must be declared before internal: ${e}`);let r=n||e,i=this.functions.length;return this.functionIdxByName[e]=i,this.functions.push(new Qr(this,e,`import`,t,r)),this.nImportFunctions++,this.functions[i]}setMemory(e,t,n){this.memory={pagesSize:e,moduleName:t||`env`,fieldName:n||`memory`}}exportFunction(e,t){let n=t||e;if(this.functionIdxByName[e]===void 0)throw Error(`Function not defined: ${e}`);let r=this.functionIdxByName[e];n!=e&&(this.functionIdxByName[n]=r),this.exports.push({exportName:n,idx:r})}addFunctionToTable(e){let t=this.functionIdxByName[e];this.functionsTable.push(t)}addData(e,t){this.datas.push({offset:e,bytes:t})}alloc(e,t){let n,r;(Array.isArray(e)||ArrayBuffer.isView(e))&&t===void 0?(n=e.length,r=e):(n=e,r=t),n=(n-1>>3)+1<<3;let i=this.free;return this.free+=n,r&&this.addData(i,r),i}allocString(e){let t=new globalThis.TextEncoder().encode(e);return this.alloc([...t,0])}_setSignatures(){this.signatures=[];let e={};if(this.functionsTable.length>0){let t=this.functions[this.functionsTable[0]].getSignature(),n=`s_`+Yr(t);e[n]=0,this.signatures.push(t)}for(let t=0;t<this.functions.length;t++){let n=this.functions[t].getSignature(),r=`s_`+Yr(n);e[r]===void 0&&(e[r]=this.signatures.length,this.signatures.push(n)),this.functions[t].signatureIdx=e[r]}}_buildSection(e,t){return[e,...H(t.length),...t]}_buildType(){return this._buildSection(1,[...H(this.signatures.length),...[].concat(...this.signatures)])}_buildImport(){let e=[];e.push([...Wr(this.memory.moduleName),...Wr(this.memory.fieldName),2,0,...H(this.memory.pagesSize)]);for(let t=0;t<this.nImportFunctions;t++)e.push([...Wr(this.functions[t].moduleName),...Wr(this.functions[t].fieldName),0,...H(this.functions[t].signatureIdx)]);return this._buildSection(2,H(e.length).concat(...e))}_buildFunctionDeclarations(){let e=[];for(let t=this.nImportFunctions;t<this.nImportFunctions+this.nInternalFunctions;t++)e.push(...H(this.functions[t].signatureIdx));return this._buildSection(3,[...H(e.length),...[...e]])}_buildFunctionsTable(){return this.functionsTable.length==0?[]:this._buildSection(4,[...H(1),112,0,...H(this.functionsTable.length)])}_buildElements(){if(this.functionsTable.length==0)return[];let e=[];for(let t=0;t<this.functionsTable.length;t++)e.push(...H(this.functionsTable[t]));return this._buildSection(9,[...H(1),...H(0),65,...qr(0),11,...H(this.functionsTable.length),...[...e]])}_buildExports(){let e=[];for(let t=0;t<this.exports.length;t++)e.push([...Wr(this.exports[t].exportName),0,...H(this.exports[t].idx)]);return this._buildSection(7,H(e.length).concat(...e))}_buildCode(){let e=[];for(let t=this.nImportFunctions;t<this.nImportFunctions+this.nInternalFunctions;t++)e.push(this.functions[t].getBody());return this._buildSection(10,H(e.length).concat(...e))}_buildData(){let e=[];e.push([0,65,0,11,4,...Hr(this.free)]);for(let t=0;t<this.datas.length;t++)e.push([0,65,...qr(this.datas[t].offset),11,...H(this.datas[t].bytes.length),...this.datas[t].bytes]);return this._buildSection(11,H(e.length).concat(...e))}};globalThis.curve_bn128=null;async function ei(e,t){if(!e&&globalThis.curve_bn128)return globalThis.curve_bn128;let n=new $r;n.setMemory(25),tr(n),t&&t(n);let r={};r.code=n.build(),r.pq=n.modules.f1m.pq,r.pr=n.modules.frm.pq,r.pG1gen=n.modules.bn128.pG1gen,r.pG1zero=n.modules.bn128.pG1zero,r.pG1b=n.modules.bn128.pG1b,r.pG2gen=n.modules.bn128.pG2gen,r.pG2zero=n.modules.bn128.pG2zero,r.pG2b=n.modules.bn128.pG2b,r.pOneT=n.modules.bn128.pOneT,r.prePSize=n.modules.bn128.prePSize,r.preQSize=n.modules.bn128.preQSize,r.n8q=32,r.n8r=32,r.q=n.modules.bn128.q,r.r=n.modules.bn128.r;let i={name:`bn128`,wasm:r,q:R(`21888242871839275222246405745257275088696311157297823662689037894645226208583`),r:R(`21888242871839275222246405745257275088548364400416034343698204186575808495617`),n8q:32,n8r:32,cofactorG2:R(`30644e72e131a029b85045b68181585e06ceecda572a2489345f2299c0f9fa8d`,16),singleThread:!!e},a=await Lr(i);return a.terminate=async function(){i.singleThread||(globalThis.curve_bn128=null,await this.tm.terminate())},e||(globalThis.curve_bn128=a),a}globalThis.curve_bls12381=null;async function ti(e,t){if(!e&&globalThis.curve_bls12381)return globalThis.curve_bls12381;let n=new $r;n.setMemory(25),nr(n),t&&t(n);let r={};r.code=n.build(),r.pq=n.modules.f1m.pq,r.pr=n.modules.frm.pq,r.pG1gen=n.modules.bls12381.pG1gen,r.pG1zero=n.modules.bls12381.pG1zero,r.pG1b=n.modules.bls12381.pG1b,r.pG2gen=n.modules.bls12381.pG2gen,r.pG2zero=n.modules.bls12381.pG2zero,r.pG2b=n.modules.bls12381.pG2b,r.pOneT=n.modules.bls12381.pOneT,r.prePSize=n.modules.bls12381.prePSize,r.preQSize=n.modules.bls12381.preQSize,r.n8q=48,r.n8r=32,r.q=n.modules.bls12381.q,r.r=n.modules.bls12381.r;let i={name:`bls12381`,wasm:r,q:R(`1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab`,16),r:R(`73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001`,16),n8q:48,n8r:32,cofactorG1:R(`0x396c8c005555e1568c00aaab0000aaab`,16),cofactorG2:R(`0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5`,16),singleThread:!!e},a=await Lr(i);return a.terminate=async function(){i.singleThread||(globalThis.curve_bls12381=null,await this.tm.terminate())},e||(globalThis.curve_bls12381=a),a}R(`73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001`,16),R(`21888242871839275222246405745257275088548364400416034343698204186575808495617`),R(`1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab`,16),R(`21888242871839275222246405745257275088696311157297823662689037894645226208583`);const U=Je,ni=vr;var ri={};async function ii(e,t,n,r){if(n||=4096*64,typeof t!=`number`&&[`w+`,`wx+`,`r`,`ax+`,`a+`].indexOf(t)<0)throw Error(`Invalid open option`);let i=await ri.promises.open(e,t);return new ai(i,await i.stat(),n,r,e)}var ai=class{constructor(e,t,n,r,i){for(this.fileName=i,this.fd=e,this.pos=0,this.pageSize=r||256;this.pageSize<t.blksize;)this.pageSize*=2;this.totalSize=t.size,this.totalPages=Math.floor((t.size-1)/this.pageSize)+1,this.maxPagesLoaded=Math.floor(n/this.pageSize)+1,this.pages={},this.pendingLoads=[],this.writing=!1,this.reading=!1,this.avBuffs=[],this.history={}}_loadPage(e){let t=this,n=new Promise((n,r)=>{t.pendingLoads.push({page:e,resolve:n,reject:r})});return t.__statusPage(`After Load request: `,e),n}__statusPage(e,t){let n=[],r=this;if(!r.logHistory)return;n.push(`==`+e+` `+t);let i=``;for(let e=0;e<r.pendingLoads.length;e++)r.pendingLoads[e].page==t&&(i=i+` `+e);if(i&&n.push(`Pending loads:`+i),r.pages[t]!==void 0){let e=r.pages[t];n.push(`Loaded`),n.push(`pendingOps: `+e.pendingOps),e.loading&&n.push(`loading: `+e.loading),e.writing&&n.push(`writing`),e.dirty&&n.push(`dirty`)}n.push(`==`),r.history[t]||(r.history[t]=[]),r.history[t].push(n)}__printHistory(e){let t=this;t.history[e]||console.log(`Empty History `,e),console.log(`History `+e);for(let n=0;n<t.history[e].length;n++)for(let r=0;r<t.history[e][n].length;r++)console.log(`-> `+t.history[e][n][r])}_triggerLoad(){let e=this;if(e.reading||e.pendingLoads.length==0)return;let t=Object.keys(e.pages),n=[];for(let r=0;r<t.length;r++){let i=e.pages[parseInt(t[r])];i.dirty==0&&i.pendingOps==0&&!i.writing&&!i.loading&&n.push(parseInt(t[r]))}let r=e.maxPagesLoaded-t.length,i=[];for(;e.pendingLoads.length>0&&(e.pages[e.pendingLoads[0].page]!==void 0||r>0||n.length>0);){let t=e.pendingLoads.shift();if(e.pages[t.page]!==void 0){e.pages[t.page].pendingOps++;let r=n.indexOf(t.page);r>=0&&n.splice(r,1),e.pages[t.page].loading?e.pages[t.page].loading.push(t):t.resolve(),e.__statusPage(`After Load (cached): `,t.page)}else{if(r)r--;else{let t=n.shift();e.__statusPage(`Before Unload: `,t),e.avBuffs.unshift(e.pages[t]),delete e.pages[t],e.__statusPage(`After Unload: `,t)}t.page>=e.totalPages?(e.pages[t.page]=a(),t.resolve(),e.__statusPage(`After Load (new): `,t.page)):(e.reading=!0,e.pages[t.page]=a(),e.pages[t.page].loading=[t],i.push(e.fd.read(e.pages[t.page].buff,0,e.pageSize,t.page*e.pageSize).then(n=>{e.pages[t.page].size=n.bytesRead;let r=e.pages[t.page].loading;delete e.pages[t.page].loading;for(let e=0;e<r.length;e++)r[e].resolve();return e.__statusPage(`After Load (loaded): `,t.page),n},e=>{t.reject(e)})),e.__statusPage(`After Load (loading): `,t.page))}}Promise.all(i).then(()=>{e.reading=!1,e.pendingLoads.length>0&&setImmediate(e._triggerLoad.bind(e)),e._tryClose()});function a(){if(e.avBuffs.length>0){let t=e.avBuffs.shift();return t.dirty=!1,t.pendingOps=1,t.size=0,t}else return{dirty:!1,buff:new Uint8Array(e.pageSize),pendingOps:1,size:0}}}_triggerWrite(){let e=this;if(e.writing)return;let t=Object.keys(e.pages),n=[];for(let r=0;r<t.length;r++){let i=e.pages[parseInt(t[r])];i.dirty&&(i.dirty=!1,i.writing=!0,e.writing=!0,n.push(e.fd.write(i.buff,0,i.size,parseInt(t[r])*e.pageSize).then(()=>{i.writing=!1},t=>{console.log(`ERROR Writing: `+t),e.error=t,e._tryClose()})))}e.writing&&Promise.all(n).then(()=>{e.writing=!1,setImmediate(e._triggerWrite.bind(e)),e._tryClose(),e.pendingLoads.length>0&&setImmediate(e._triggerLoad.bind(e))})}_getDirtyPage(){for(let e in this.pages)if(this.pages[e].dirty)return e;return-1}async write(e,t){if(e.byteLength==0)return;let n=this;if(t===void 0&&(t=n.pos),n.pos=t+e.byteLength,n.totalSize<t+e.byteLength&&(n.totalSize=t+e.byteLength),n.pendingClose)throw Error(`Writing a closing file`);let r=Math.floor(t/n.pageSize),i=Math.floor((t+e.byteLength-1)/n.pageSize),a=[];for(let e=r;e<=i;e++)a.push(n._loadPage(e));n._triggerLoad();let o=r,s=t%n.pageSize,c=e.byteLength;for(;c>0;){await a[o-r];let t=s+c>n.pageSize?n.pageSize-s:c,i=e.slice(e.byteLength-c,e.byteLength-c+t);new Uint8Array(n.pages[o].buff.buffer,s,t).set(i),n.pages[o].dirty=!0,n.pages[o].pendingOps--,n.pages[o].size=Math.max(s+t,n.pages[o].size),o>=n.totalPages&&(n.totalPages=o+1),c-=t,o++,s=0,n.writing||setImmediate(n._triggerWrite.bind(n))}}async read(e,t){let n=this,r=new Uint8Array(e);return await n.readToBuffer(r,0,e,t),r}async readToBuffer(e,t,n,r){if(n==0)return;let i=this;if(n>i.pageSize*i.maxPagesLoaded*.8){let e=Math.floor(n*1.1);this.maxPagesLoaded=Math.floor(e/i.pageSize)+1}if(r===void 0&&(r=i.pos),i.pos=r+n,i.pendingClose)throw Error(`Reading a closing file`);let a=Math.floor(r/i.pageSize),o=Math.floor((r+n-1)/i.pageSize),s=[];for(let e=a;e<=o;e++)s.push(i._loadPage(e));i._triggerLoad();let c=a,l=r%i.pageSize,u=r+n>i.totalSize?n-(r+n-i.totalSize):n;for(;u>0;){await s[c-a],i.__statusPage(`After Await (read): `,c);let r=l+u>i.pageSize?i.pageSize-l:u,o=new Uint8Array(i.pages[c].buff.buffer,i.pages[c].buff.byteOffset+l,r);e.set(o,t+n-u),i.pages[c].pendingOps--,i.__statusPage(`After Op done: `,c),u-=r,c++,l=0,i.pendingLoads.length>0&&setImmediate(i._triggerLoad.bind(i))}this.pos=r+n}_tryClose(){let e=this;e.pendingClose&&(e.error&&e.pendingCloseReject(e.error),!(e._getDirtyPage()>=0||e.writing||e.reading||e.pendingLoads.length>0)&&e.pendingClose())}close(){let e=this;if(e.pendingClose)throw Error(`Closing the file twice`);return new Promise((t,n)=>{e.pendingClose=t,e.pendingCloseReject=n,e._tryClose()}).then(()=>{e.fd.close()},t=>{throw e.fd.close(),t})}async discard(){await this.close(),await ri.promises.unlink(this.fileName)}async writeULE32(e,t){let n=this,r=new Uint8Array(4);new DataView(r.buffer).setUint32(0,e,!0),await n.write(r,t)}async writeUBE32(e,t){let n=this,r=new Uint8Array(4);new DataView(r.buffer).setUint32(0,e,!1),await n.write(r,t)}async writeULE64(e,t){let n=this,r=new Uint8Array(8),i=new DataView(r.buffer);i.setUint32(0,e&4294967295,!0),i.setUint32(4,Math.floor(e/4294967296),!0),await n.write(r,t)}async readULE32(e){let t=await this.read(4,e);return new Uint32Array(t.buffer)[0]}async readUBE32(e){let t=await this.read(4,e);return new DataView(t.buffer).getUint32(0,!1)}async readULE64(e){let t=await this.read(8,e),n=new Uint32Array(t.buffer);return n[1]*4294967296+n[0]}async readString(e){let t=this;if(t.pendingClose)throw Error(`Reading a closing file`);let n=e===void 0?t.pos:e,r=Math.floor(n/t.pageSize),i=!1,a=``;for(;!i;){let e=t._loadPage(r);t._triggerLoad(),await e,t.__statusPage(`After Await (read): `,r);let o=n%t.pageSize,s=new Uint8Array(t.pages[r].buff.buffer,t.pages[r].buff.byteOffset+o,t.pageSize-o),c=s.findIndex(e=>e===0);i=c!==-1,i?(a+=new TextDecoder().decode(s.slice(0,c)),t.pos=r*this.pageSize+o+c+1):(a+=new TextDecoder().decode(s),t.pos=r*this.pageSize+o+s.length),t.pages[r].pendingOps--,t.__statusPage(`After Op done: `,r),n=t.pos,r++,t.pendingLoads.length>0&&setImmediate(t._triggerLoad.bind(t))}return a}};function oi(e){let t=e.initialSize||1<<20,n=new fi;return n.o=e,n.o.data=new Uint8Array(t),n.allocSize=t,n.totalSize=0,n.readOnly=!1,n.pos=0,n}function si(e){let t=new fi;return t.o=e,t.allocSize=e.data.byteLength,t.totalSize=e.data.byteLength,t.readOnly=!0,t.pos=0,t}const ci=new Uint8Array(4),li=new DataView(ci.buffer),ui=new Uint8Array(8),di=new DataView(ui.buffer);var fi=class{constructor(){this.pageSize=16384}_resizeIfNeeded(e){if(e>this.allocSize){let t=Math.max(this.allocSize+(1<<20),Math.floor(this.allocSize*1.1),e),n=new Uint8Array(t);n.set(this.o.data),this.o.data=n,this.allocSize=t}}async write(e,t){let n=this;if(t===void 0&&(t=n.pos),this.readOnly)throw Error(`Writing a read only file`);this._resizeIfNeeded(t+e.byteLength),this.o.data.set(e.slice(),t),t+e.byteLength>this.totalSize&&(this.totalSize=t+e.byteLength),this.pos=t+e.byteLength}async readToBuffer(e,t,n,r){let i=this;if(r===void 0&&(r=i.pos),this.readOnly&&r+n>this.totalSize)throw Error(`Reading out of bounds`);this._resizeIfNeeded(r+n);let a=new Uint8Array(this.o.data.buffer,this.o.data.byteOffset+r,n);e.set(a,t),this.pos=r+n}async read(e,t){let n=this,r=new Uint8Array(e);return await n.readToBuffer(r,0,e,t),r}close(){this.o.data.byteLength!=this.totalSize&&(this.o.data=this.o.data.slice(0,this.totalSize))}async discard(){}async writeULE32(e,t){let n=this;li.setUint32(0,e,!0),await n.write(ci,t)}async writeUBE32(e,t){let n=this;li.setUint32(0,e,!1),await n.write(ci,t)}async writeULE64(e,t){let n=this;di.setUint32(0,e&4294967295,!0),di.setUint32(4,Math.floor(e/4294967296),!0),await n.write(ui,t)}async readULE32(e){let t=await this.read(4,e);return new Uint32Array(t.buffer)[0]}async readUBE32(e){let t=await this.read(4,e);return new DataView(t.buffer).getUint32(0,!1)}async readULE64(e){let t=await this.read(8,e),n=new Uint32Array(t.buffer);return n[1]*4294967296+n[0]}async readString(e){let t=this,n=e===void 0?t.pos:e;if(n>this.totalSize){if(this.readOnly)throw Error(`Reading out of bounds`);this._resizeIfNeeded(e)}let r=new Uint8Array(t.o.data.buffer,n,this.totalSize-n),i=r.findIndex(e=>e===0),a=i!==-1,o=``;return a?(o=new TextDecoder().decode(r.slice(0,i)),t.pos=n+i+1):t.pos=n,o}};const pi=1<<22;function mi(e){let t=e.initialSize||0,n=new bi;n.o=e;let r=t?Math.floor((t-1)/pi)+1:0;n.o.data=[];for(let e=0;e<r-1;e++)n.o.data.push(new Uint8Array(pi));return r&&n.o.data.push(new Uint8Array(t-pi*(r-1))),n.totalSize=0,n.readOnly=!1,n.pos=0,n}function hi(e){let t=new bi;return t.o=e,t.totalSize=(e.data.length-1)*pi+e.data[e.data.length-1].byteLength,t.readOnly=!0,t.pos=0,t}const gi=new Uint8Array(4),_i=new DataView(gi.buffer),vi=new Uint8Array(8),yi=new DataView(vi.buffer);var bi=class{constructor(){this.pageSize=16384}_resizeIfNeeded(e){if(e<=this.totalSize)return;if(this.readOnly)throw Error(`Reading out of file bounds`);let t=Math.floor((e-1)/pi)+1;for(let n=Math.max(this.o.data.length-1,0);n<t;n++){let r=n<t-1?pi:e-(t-1)*pi,i=new Uint8Array(r);n==this.o.data.length-1&&i.set(this.o.data[n]),this.o.data[n]=i}this.totalSize=e}async write(e,t){let n=this;if(t===void 0&&(t=n.pos),this.readOnly)throw Error(`Writing a read only file`);this._resizeIfNeeded(t+e.byteLength);let r=Math.floor(t/pi),i=t%pi,a=e.byteLength;for(;a>0;){let t=i+a>pi?pi-i:a,o=e.slice(e.byteLength-a,e.byteLength-a+t);new Uint8Array(n.o.data[r].buffer,i,t).set(o),a-=t,r++,i=0}this.pos=t+e.byteLength}async readToBuffer(e,t,n,r){let i=this;if(r===void 0&&(r=i.pos),this.readOnly&&r+n>this.totalSize)throw Error(`Reading out of bounds`);this._resizeIfNeeded(r+n);let a=Math.floor(r/pi),o=r%pi,s=n;for(;s>0;){let r=o+s>pi?pi-o:s,c=new Uint8Array(i.o.data[a].buffer,o,r);e.set(c,t+n-s),s-=r,a++,o=0}this.pos=r+n}async read(e,t){let n=this,r=new Uint8Array(e);return await n.readToBuffer(r,0,e,t),r}close(){}async discard(){}async writeULE32(e,t){let n=this;_i.setUint32(0,e,!0),await n.write(gi,t)}async writeUBE32(e,t){let n=this;_i.setUint32(0,e,!1),await n.write(gi,t)}async writeULE64(e,t){let n=this;yi.setUint32(0,e&4294967295,!0),yi.setUint32(4,Math.floor(e/4294967296),!0),await n.write(vi,t)}async readULE32(e){let t=await this.read(4,e);return new Uint32Array(t.buffer)[0]}async readUBE32(e){let t=await this.read(4,e);return new DataView(t.buffer).getUint32(0,!1)}async readULE64(e){let t=await this.read(8,e),n=new Uint32Array(t.buffer);return n[1]*4294967296+n[0]}async readString(e){let t=this,n=e===void 0?t.pos:e;if(n>this.totalSize){if(this.readOnly)throw Error(`Reading out of bounds`);this._resizeIfNeeded(e)}let r=!1,i=``;for(;!r;){let e=Math.floor(n/pi),a=n%pi;if(t.o.data[e]===void 0)throw Error(`ERROR`);let o=Math.min(2048,t.o.data[e].length-a),s=new Uint8Array(t.o.data[e].buffer,a,o),c=s.findIndex(e=>e===0);r=c!==-1,r?(i+=new TextDecoder().decode(s.slice(0,c)),t.pos=e*pi+a+c+1):(i+=new TextDecoder().decode(s),t.pos=e*pi+a+s.length),n=t.pos}return i}};async function xi(e,t,n){if(typeof e==`string`&&(e={type:`file`,fileName:e,cacheSize:t||65536,pageSize:n||8192}),e.type==`file`)return await ii(e.fileName,1538,e.cacheSize,e.pageSize);if(e.type==`mem`)return oi(e);if(e.type==`bigMem`)return mi(e);throw Error(`Invalid FastFile type: `+e.type)}async function Si(e,t,n){if(e instanceof Uint8Array&&(e={type:`mem`,data:e}),typeof e==`string`&&(e={type:`mem`,data:await fetch(e).then(function(e){return e.arrayBuffer()}).then(function(e){return new Uint8Array(e)})}),e.type==`file`)return await ii(e.fileName,0,e.cacheSize,e.pageSize);if(e.type==`mem`)return await si(e);if(e.type==`bigMem`)return await hi(e);throw Error(`Invalid FastFile type: `+e.type)}async function Ci(e,t,n,r,i){let a=await Si(e),o=await a.read(4),s=``;for(let e=0;e<4;e++)s+=String.fromCharCode(o[e]);if(s!=t)throw Error(e+`: Invalid File format`);if(await a.readULE32()>n)throw Error(`Version not supported`);let c=await a.readULE32(),l=[];for(let e=0;e<c;e++){let e=await a.readULE32(),t=await a.readULE64();l[e]===void 0&&(l[e]=[]),l[e].push({p:a.pos,size:t}),a.pos+=t}return{fd:a,sections:l}}async function wi(e,t,n,r,i,a){let o=await xi(e,i,a),s=new Uint8Array(4);for(let e=0;e<4;e++)s[e]=t.charCodeAt(e);return await o.write(s,0),await o.writeULE32(n),await o.writeULE32(r),o}async function Ti(e,t){if(e.writingSection!==void 0)throw Error(`Already writing a section`);await e.writeULE32(t),e.writingSection={pSectionSize:e.pos},await e.writeULE64(0)}async function Ei(e){if(e.writingSection===void 0)throw Error(`Not writing a section`);let t=e.pos-e.writingSection.pSectionSize-8,n=e.pos;e.pos=e.writingSection.pSectionSize,await e.writeULE64(t),e.pos=n,delete e.writingSection}async function Di(e,t,n){if(e.readingSection!==void 0)throw Error(`Already reading a section`);if(!t[n])throw Error(e.fileName+`: Missing section `+n);if(t[n].length>1)throw Error(e.fileName+`: Section Duplicated `+n);e.pos=t[n][0].p,e.readingSection=t[n][0]}async function Oi(e,t){if(e.readingSection===void 0)throw Error(`Not reading a section`);if(!t&&e.pos-e.readingSection.p!=e.readingSection.size)throw Error(`Invalid section size reading`);delete e.readingSection}async function ki(e,t,n,r){let i=new Uint8Array(n);U.toRprLE(i,0,t,n),await e.write(i,r)}async function Ai(e,t,n){let r=await e.read(t,n);return U.fromRprLE(r,0,t)}async function ji(e,t,n,r,i){if(r=r===void 0?0:r,i=i===void 0?t[n][0].size-r:i,r+i>t[n][0].size)throw Error(`Reading out of the range of the section`);let a;return a=i<1<<30?new Uint8Array(i):new V(i),await e.readToBuffer(a,0,i,t[n][0].p+r),a}U.e(`73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001`,16),U.e(`21888242871839275222246405745257275088548364400416034343698204186575808495617`);const Mi=U.e(`1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab`,16),Ni=U.e(`21888242871839275222246405745257275088696311157297823662689037894645226208583`);async function Pi(e,t){let n,r=t&&t.singleThread;if(U.eq(e,Ni))n=await ei(r);else if(U.eq(e,Mi))n=await ti(r);else throw Error(`Curve not supported: ${U.toString(e)}`);return n}async function Fi(e,t){let n,r=t&&t.singleThread,i=a(e);if([`BN128`,`BN254`,`ALTBN128`].indexOf(i)>=0)n=await ei(r);else if([`BLS12381`].indexOf(i)>=0)n=await ti(r);else throw Error(`Curve not supported: ${e}`);return n;function a(e){return e.toUpperCase().match(/[A-Za-z0-9]+/g).join(``)}}new Uint8Array(new Uint32Array([287454020]).buffer)[0];function Ii(e){return(e&4294901760?(e&=4294901760,16):0)|(e&4278255360?(e&=4278255360,8):0)|(e&4042322160?(e&=4042322160,4):0)|(e&3435973836?(e&=3435973836,2):0)|(e&2863311530)!=0}async function Li(e,t,n){let r=await e.read(t.G1.F.n8*2),i=t.G1.fromRprLEM(r,0);return n?t.G1.toObject(i):i}async function Ri(e,t,n){let r=await e.read(t.G2.F.n8*2),i=t.G2.fromRprLEM(r,0);return n?t.G2.toObject(i):i}async function zi(e,t,n,r){await Di(e,t,1);let i=await e.readULE32();if(await Oi(e),i===1)return await Bi(e,t,n,r);if(i===2)return await Vi(e,t,n,r);if(i===10)return await Hi(e,t,n,r);throw Error(`Protocol not supported: `)}async function Bi(e,t,n,r){let i={};i.protocol=`groth16`,await Di(e,t,2);let a=await e.readULE32();i.n8q=a,i.q=await Ai(e,a);let o=await e.readULE32();return i.n8r=o,i.r=await Ai(e,o),i.curve=await Pi(i.q,r),i.nVars=await e.readULE32(),i.nPublic=await e.readULE32(),i.domainSize=await e.readULE32(),i.power=Ii(i.domainSize),i.vk_alpha_1=await Li(e,i.curve,n),i.vk_beta_1=await Li(e,i.curve,n),i.vk_beta_2=await Ri(e,i.curve,n),i.vk_gamma_2=await Ri(e,i.curve,n),i.vk_delta_1=await Li(e,i.curve,n),i.vk_delta_2=await Ri(e,i.curve,n),await Oi(e),i}async function Vi(e,t,n,r){let i={};i.protocol=`plonk`,await Di(e,t,2);let a=await e.readULE32();i.n8q=a,i.q=await Ai(e,a);let o=await e.readULE32();return i.n8r=o,i.r=await Ai(e,o),i.curve=await Pi(i.q,r),i.nVars=await e.readULE32(),i.nPublic=await e.readULE32(),i.domainSize=await e.readULE32(),i.power=Ii(i.domainSize),i.nAdditions=await e.readULE32(),i.nConstraints=await e.readULE32(),i.k1=await e.read(o),i.k2=await e.read(o),i.Qm=await Li(e,i.curve,n),i.Ql=await Li(e,i.curve,n),i.Qr=await Li(e,i.curve,n),i.Qo=await Li(e,i.curve,n),i.Qc=await Li(e,i.curve,n),i.S1=await Li(e,i.curve,n),i.S2=await Li(e,i.curve,n),i.S3=await Li(e,i.curve,n),i.X_2=await Ri(e,i.curve,n),await Oi(e),i}async function Hi(e,t,n,r){let i={};i.protocol=`fflonk`,i.protocolId=10,await Di(e,t,2);let a=await e.readULE32();i.n8q=a,i.q=await Ai(e,a),i.curve=await Pi(i.q,r);let o=await e.readULE32();return i.n8r=o,i.r=await Ai(e,o),i.nVars=await e.readULE32(),i.nPublic=await e.readULE32(),i.domainSize=await e.readULE32(),i.power=Ii(i.domainSize),i.nAdditions=await e.readULE32(),i.nConstraints=await e.readULE32(),i.k1=await e.read(o),i.k2=await e.read(o),i.w3=await e.read(o),i.w4=await e.read(o),i.w8=await e.read(o),i.wr=await e.read(o),i.X_2=await Ri(e,i.curve,n),i.C0=await Li(e,i.curve,n),await Oi(e),i}async function Ui(e,t,n){await Ti(e,1);let r=(Math.floor((U.bitLength(n)-1)/64)+1)*8;if(await e.writeULE32(r),await ki(e,n,r),t.byteLength%r!=0)throw Error(`Invalid witness length`);await e.writeULE32(t.byteLength/r),await Ei(e),await Ti(e,2),await e.write(t),await Ei(e)}async function Wi(e,t){await Di(e,t,1);let n=await e.readULE32(),r=await Ai(e,n),i=await e.readULE32();return await Oi(e),{n8:n,q:r,nWitness:i}}const{stringifyBigInts:Gi}=ni;async function Ki(e,t,n,r){let{fd:i,sections:a}=await Ci(t,`wtns`,2),o=await Wi(i,a),{fd:s,sections:c}=await Ci(e,`zkey`,2),l=await zi(s,c,void 0,r);if(l.protocol!=`groth16`)throw Error(`zkey file is not groth16`);if(!U.eq(l.r,o.q))throw Error(`Curve of the witness does not match the curve of the proving key`);if(o.nWitness!=l.nVars)throw Error(`Invalid witness length. Circuit: ${l.nVars}, witness: ${o.nWitness}`);let u=l.curve,d=u.Fr,f=u.G1,p=u.G2,m=Ii(l.domainSize);n&&n.debug(`Reading Wtns`);let h=await ji(i,a,2);n&&n.debug(`Reading Coeffs`);let g=await ji(s,c,4);n&&n.debug(`Building ABC`);let[_,v,y]=await qi(u,l,h,g,n),b=m==d.s?u.Fr.shift:u.Fr.w[m+1],x=await d.ifft(_,``,``,n,`IFFT_A`),S=await d.batchApplyKey(x,d.e(1),b),C=await d.fft(S,``,``,n,`FFT_A`),w=await d.ifft(v,``,``,n,`IFFT_B`),T=await d.batchApplyKey(w,d.e(1),b),E=await d.fft(T,``,``,n,`FFT_B`),D=await d.ifft(y,``,``,n,`IFFT_C`),O=await d.batchApplyKey(D,d.e(1),b),k=await d.fft(O,``,``,n,`FFT_C`);n&&n.debug(`Join ABC`);let A=await Ji(u,l,C,E,k,n),j={};n&&n.debug(`Reading A Points`);let ee=await ji(s,c,5);j.pi_a=await u.G1.multiExpAffine(ee,h,n,`multiexp A`),n&&n.debug(`Reading B1 Points`);let M=await ji(s,c,6),N=await u.G1.multiExpAffine(M,h,n,`multiexp B1`);n&&n.debug(`Reading B2 Points`);let P=await ji(s,c,7);j.pi_b=await u.G2.multiExpAffine(P,h,n,`multiexp B2`),n&&n.debug(`Reading C Points`);let F=await ji(s,c,8);j.pi_c=await u.G1.multiExpAffine(F,h.slice((l.nPublic+1)*u.Fr.n8),n,`multiexp C`),n&&n.debug(`Reading H Points`);let te=await ji(s,c,9),I=await u.G1.multiExpAffine(te,A,n,`multiexp H`),L=u.Fr.random(),ne=u.Fr.random();j.pi_a=f.add(j.pi_a,l.vk_alpha_1),j.pi_a=f.add(j.pi_a,f.timesFr(l.vk_delta_1,L)),j.pi_b=p.add(j.pi_b,l.vk_beta_2),j.pi_b=p.add(j.pi_b,p.timesFr(l.vk_delta_2,ne)),N=f.add(N,l.vk_beta_1),N=f.add(N,f.timesFr(l.vk_delta_1,ne)),j.pi_c=f.add(j.pi_c,I),j.pi_c=f.add(j.pi_c,f.timesFr(j.pi_a,ne)),j.pi_c=f.add(j.pi_c,f.timesFr(N,L)),j.pi_c=f.add(j.pi_c,f.timesFr(l.vk_delta_1,d.neg(d.mul(L,ne))));let re=[];for(let e=1;e<=l.nPublic;e++){let t=h.slice(e*d.n8,e*d.n8+d.n8);re.push(U.fromRprLE(t))}return j.pi_a=f.toObject(f.toAffine(j.pi_a)),j.pi_b=p.toObject(p.toAffine(j.pi_b)),j.pi_c=f.toObject(f.toAffine(j.pi_c)),j.protocol=`groth16`,j.curve=u.name,await s.close(),await i.close(),j=Gi(j),re=Gi(re),{proof:j,publicSignals:re}}async function qi(e,t,n,r,i){let a=e.Fr.n8,o=12+t.n8r,s=(r.byteLength-4)/o,c=new V(t.domainSize*a),l=new V(t.domainSize*a),u=new V(t.domainSize*a),d=[c,l];for(let t=0;t<s;t++){i&&t%1e6==0&&i.debug(`QAP AB: ${t}/${s}`);let c=r.slice(4+t*o,4+t*o+o),l=new DataView(c.buffer),u=l.getUint32(0,!0),f=l.getUint32(4,!0),p=l.getUint32(8,!0),m=c.slice(12,12+a);d[u].set(e.Fr.add(d[u].slice(f*a,f*a+a),e.Fr.mul(m,n.slice(p*a,p*a+a))),f*a)}for(let n=0;n<t.domainSize;n++)i&&n%1e6==0&&i.debug(`QAP C: ${n}/${t.domainSize}`),u.set(e.Fr.mul(c.slice(n*a,n*a+a),l.slice(n*a,n*a+a)),n*a);return[c,l,u]}async function Ji(e,t,n,r,i,a){let o=1<<22,s=e.Fr.n8,c=Math.floor(n.byteLength/e.Fr.n8),l=[];for(let t=0;t<c;t+=o){a&&a.debug(`JoinABC: ${t}/${c}`);let u=Math.min(c-t,o),d=[],f=n.slice(t*s,(t+u)*s),p=r.slice(t*s,(t+u)*s),m=i.slice(t*s,(t+u)*s);d.push({cmd:`ALLOCSET`,var:0,buff:f}),d.push({cmd:`ALLOCSET`,var:1,buff:p}),d.push({cmd:`ALLOCSET`,var:2,buff:m}),d.push({cmd:`ALLOC`,var:3,len:u*s}),d.push({cmd:`CALL`,fnName:`qap_joinABC`,params:[{var:0},{var:1},{var:2},{val:u},{var:3}]}),d.push({cmd:`CALL`,fnName:`frm_batchFromMontgomery`,params:[{var:3},{val:u},{var:3}]}),d.push({cmd:`GET`,out:0,var:3,len:u*s}),l.push(e.tm.queueAction(d))}let u=await Promise.all(l),d;d=n instanceof V?new V(n.byteLength):new Uint8Array(n.byteLength);let f=0;for(let e=0;e<u.length;e++)d.set(u[e][0],f),f+=u[e][0].byteLength;return d}function Yi(e){let t=[];return n(t,e),t;function n(e,t){if(Array.isArray(t))for(let r=0;r<t.length;r++)n(e,t[r]);else e.push(t)}}function Xi(e,t){let n=BigInt(e)%t;return n<0&&(n+=t),n}function Zi(e){let t=BigInt(2)**BigInt(64),n=BigInt(`0xCBF29CE484222325`);for(let r=0;r<e.length;r++)n^=BigInt(e[r].charCodeAt(0)),n*=BigInt(1099511628211),n%=t;let r=n.toString(16),i=16-r.length;return r=`0`.repeat(i).concat(r),r}function Qi(e,t){let n=[],r=BigInt(e),i=BigInt(4294967296);for(;r;)n.unshift(Number(r%i)),r/=i;if(t){let e=t-n.length;for(;e>0;)n.unshift(0),e--}return n}async function $i(e,t){let n,r,i;t||={};let a=1,o=0,s=0,c=!1;if(e instanceof WebAssembly.Instance)n=e,c=!0;else{let c=32767;if(t.memorySize&&(c=parseInt(t.memorySize),c<0))throw Error(`Invalid memory size`);let l=!1;for(;!l;)try{i=new WebAssembly.Memory({initial:c}),l=!0}catch(e){if(c<=1)throw e;console.warn(`Could not allocate `+c*1024*64+` bytes. This may cause severe instability. Trying with `+c*1024*64/2+` bytes`),c=Math.floor(c/2)}let f=await WebAssembly.compile(e),p=``,m=``;n=await WebAssembly.instantiate(f,{env:{memory:i},runtime:{printDebug:function(e){console.log(`printDebug:`,e)},exceptionHandler:function(e){let t;throw t=e===1?`Signal not found. `:e===2?`Too many signals set. `:e===3?`Signal already set. `:e===4?`Assert Failed. `:e===5?`Not enough memory. `:e===6?`Input signal array access exceeds the size. `:`Unknown error. `,console.error(`ERROR: `,e,p),Error(t+p)},printErrorMessage:function(){p+=u()+`
|
|
123
|
+
`},writeBufferMessage:function(){let e=u();e===`
|
|
124
|
+
`?(console.log(m),m=``):(m!==``&&(m+=` `),m+=e)},showSharedRWMemory:function(){let e=n.exports.getFieldNumLen32(),t=new Uint32Array(e);for(let r=0;r<e;r++)t[e-1-r]=n.exports.readSharedRWMemory(r);if(a>=2&&(o>=1||s>=7)){m!==``&&(m+=` `);let e=U.fromArray(t,4294967296).toString();m+=e}else console.log(U.fromArray(t,4294967296))},error:function(e,n,i,a,o,s){let c;throw c=e===7?d(n)+` `+r.getFr(a).toString()+` != `+r.getFr(o).toString()+` `+d(s):e===9?d(n)+` `+r.getFr(a).toString()+` `+d(o):e===5&&t.sym?d(n)+` `+t.sym.labelIdx2Name[o]:d(n)+` `+i+` `+a+` `+o+` `+s,console.log(`ERROR: `,e,c),Error(c)},log:function(e){console.log(r.getFr(e).toString())},logGetSignal:function(e,n){t.logGetSignal&&t.logGetSignal(e,r.getFr(n))},logSetSignal:function(e,n){t.logSetSignal&&t.logSetSignal(e,r.getFr(n))},logStartComponent:function(e){t.logStartComponent&&t.logStartComponent(e)},logFinishComponent:function(e){t.logFinishComponent&&t.logFinishComponent(e)}}})}typeof n.exports.getVersion==`function`&&(a=n.exports.getVersion()),typeof n.exports.getMinorVersion==`function`&&(o=n.exports.getMinorVersion()),typeof n.exports.getPatchVersion==`function`&&(s=n.exports.getPatchVersion());let l=t&&(t.sanityCheck||t.logGetSignal||t.logSetSignal||t.logStartComponent||t.logFinishComponent);if(a===2)r=new ta(n,l);else if(a===1){if(c)throw Error(`Loading code from WebAssembly instance is not supported for circom version 1`);r=new ea(i,n,l)}else throw Error(`Unsupported circom version: ${a}`);return r;function u(){let e=``,t=n.exports.getMessageChar();for(;t!==0;)e+=String.fromCharCode(t),t=n.exports.getMessageChar();return e}function d(e){let t=new Uint8Array(i.buffer),n=[];for(let r=0;t[e+r]>0;r++)n.push(t[e+r]);return String.fromCharCode.apply(null,n)}}var ea=class{constructor(e,t,n){this.memory=e,this.i32=new Uint32Array(e.buffer),this.instance=t,this.n32=(this.instance.exports.getFrLen()>>2)-2;let r=this.instance.exports.getPRawPrime(),i=Array(this.n32);for(let e=0;e<this.n32;e++)i[this.n32-1-e]=this.i32[(r>>2)+e];this.prime=U.fromArray(i,4294967296),this.Fr=new gt(this.prime),this.mask32=U.fromString(`FFFFFFFF`,16),this.NVars=this.instance.exports.getNVars(),this.n64=Math.floor((this.Fr.bitLength-1)/64)+1,this.R=this.Fr.e(U.shiftLeft(1,this.n64*64)),this.RInv=this.Fr.inv(this.R),this.sanityCheck=n}circom_version(){return 1}async _doCalculateWitness(e,t){this.instance.exports.init(this.sanityCheck||t?1:0);let n=this.allocInt(),r=this.allocFr();Object.keys(e).forEach(t=>{let i=Zi(t),a=parseInt(i.slice(0,8),16),o=parseInt(i.slice(8,16),16);try{this.instance.exports.getSignalOffset32(n,0,a,o)}catch{throw Error(`Signal ${t} is not an input of the circuit.`)}let s=this.getInt(n),c=Yi(e[t]);for(let e=0;e<c.length;e++)this.setFr(r,c[e]),this.instance.exports.setSignal(0,0,s+e,r)})}async calculateWitness(e,t){let n=this,r=n.i32[0],i=[];await n._doCalculateWitness(e,t);for(let e=0;e<n.NVars;e++){let t=n.instance.exports.getPWitness(e);i.push(n.getFr(t))}return n.i32[0]=r,i}async calculateBinWitness(e,t){let n=this,r=n.i32[0];await n._doCalculateWitness(e,t);let i=n.instance.exports.getWitnessBuffer();n.i32[0]=r;let a=n.memory.buffer.slice(i,i+n.NVars*n.n64*8);return new Uint8Array(a)}allocInt(){let e=this.i32[0];return this.i32[0]=e+8,e}allocFr(){let e=this.i32[0];return this.i32[0]=e+this.n32*4+8,e}getInt(e){return this.i32[e>>2]}setInt(e,t){this.i32[e>>2]=t}getFr(e){let t=this,n=e>>2;if(t.i32[n+1]&2147483648){let e=Array(t.n32);for(let r=0;r<t.n32;r++)e[t.n32-1-r]=t.i32[n+2+r];let i=t.Fr.e(U.fromArray(e,4294967296));return t.i32[n+1]&1073741824?r(i):i}else if(t.i32[n]&2147483648)return t.Fr.e(t.i32[n]-4294967296);else return t.Fr.e(t.i32[n]);function r(e){return t.Fr.mul(t.RInv,e)}}setFr(e,t){let n=this;t=n.Fr.e(t);let r=n.Fr.neg(n.Fr.e(`80000000`,16)),i=n.Fr.e(`7FFFFFFF`,16);if(n.Fr.geq(t,r)&&n.Fr.leq(t,i)){let i;n.Fr.geq(t,n.Fr.zero)?i=U.toNumber(t):(i=U.toNumber(n.Fr.sub(t,r)),i-=2147483648,i=4294967296+i),n.i32[e>>2]=i,n.i32[(e>>2)+1]=0;return}n.i32[e>>2]=0,n.i32[(e>>2)+1]=2147483648;let a=U.toArray(t,4294967296);for(let t=0;t<n.n32;t++){let r=a.length-1-t;r>=0?n.i32[(e>>2)+2+t]=a[r]:n.i32[(e>>2)+2+t]=0}}},ta=class{constructor(e,t){this.instance=e,this.version=this.instance.exports.getVersion(),this.n32=this.instance.exports.getFieldNumLen32(),this.instance.exports.getRawPrime();let n=new Uint32Array(this.n32);for(let e=0;e<this.n32;e++)n[this.n32-1-e]=this.instance.exports.readSharedRWMemory(e);this.prime=U.fromArray(n,4294967296),this.witnessSize=this.instance.exports.getWitnessSize(),this.sanityCheck=t}circom_version(){return this.instance.exports.getVersion()}async _doCalculateWitness(e,t){this.instance.exports.init(this.sanityCheck||t?1:0);let n=Object.keys(e),r=0;if(n.forEach(t=>{let n=Zi(t),i=parseInt(n.slice(0,8),16),a=parseInt(n.slice(8,16),16),o=Yi(e[t]);if(typeof this.instance.exports.getInputSignalSize==`function`){let e=this.instance.exports.getInputSignalSize(i,a);if(e<0)throw Error(`Signal ${t} not found\n`);if(o.length<e)throw Error(`Not enough values for input signal ${t}\n`);if(o.length>e)throw Error(`Too many values for input signal ${t}\n`)}for(let e=0;e<o.length;e++){let t=Qi(Xi(o[e],this.prime),this.n32);for(let e=0;e<this.n32;e++)this.instance.exports.writeSharedRWMemory(e,t[this.n32-1-e]);try{this.instance.exports.setInputSignal(i,a,e),r++}catch(e){throw Error(e)}}}),r<this.instance.exports.getInputSize())throw Error(`Not all inputs have been set. Only ${r} out of ${this.instance.exports.getInputSize()}`)}async calculateWitness(e,t){let n=[];await this._doCalculateWitness(e,t);for(let e=0;e<this.witnessSize;e++){this.instance.exports.getWitness(e);let t=new Uint32Array(this.n32);for(let e=0;e<this.n32;e++)t[this.n32-1-e]=this.instance.exports.readSharedRWMemory(e);n.push(U.fromArray(t,4294967296))}return n}async calculateWTNSBin(e,t){let n=new Uint32Array(this.witnessSize*this.n32+this.n32+11),r=new Uint8Array(n.buffer);await this._doCalculateWitness(e,t),r[0]=119,r[1]=116,r[2]=110,r[3]=115,n[1]=2,n[2]=2,n[3]=1;let i=this.n32*4,a=(8+i).toString(16);n[4]=parseInt(a.slice(0,8),16),n[5]=parseInt(a.slice(8,16),16),n[6]=i,this.instance.exports.getRawPrime();let o=7;for(let e=0;e<this.n32;e++)n[o+e]=this.instance.exports.readSharedRWMemory(e);o+=this.n32,n[o]=this.witnessSize,o++,n[o]=2,o++;let s=(i*this.witnessSize).toString(16);n[o]=parseInt(s.slice(0,8),16),n[o+1]=parseInt(s.slice(8,16),16),o+=2;for(let e=0;e<this.witnessSize;e++){this.instance.exports.getWitness(e);for(let e=0;e<this.n32;e++)n[o+e]=this.instance.exports.readSharedRWMemory(e);o+=this.n32}return r}};const{unstringifyBigInts:na}=ni;async function ra(e,t,n,r){let i=na(e),a=await Si(t),o=await a.read(a.totalSize);await a.close();let s=await $i(o,r);if(s.circom_version()===1){let e=await s.calculateBinWitness(i),t=await wi(n,`wtns`,2,2);await Ui(t,e,s.prime),await t.close()}else{let e=await xi(n),t=await s.calculateWTNSBin(i);await e.write(t),await e.close()}}const{unstringifyBigInts:ia}=ni;async function aa(e,t,n,r,i,a){let o=ia(e),s={type:`mem`};return await ra(o,t,s,i),await Ki(n,s,r,a)}const{unstringifyBigInts:oa}=ni;async function sa(e,t,n,r){let i=oa(e),a=oa(n),o=oa(t),s=await Fi(i.curve),c=s.G1.fromObject(i.IC[0]),l=new Uint8Array(s.G1.F.n8*2*o.length),u=new Uint8Array(s.Fr.n8*o.length);if(!ua(s,o))return r&&r.error(`Public inputs are not valid.`),!1;for(let e=0;e<o.length;e++){let t=s.G1.fromObject(i.IC[e+1]);l.set(t,e*s.G1.F.n8*2),U.toRprLE(u,s.Fr.n8*e,o[e],s.Fr.n8)}let d=await s.G1.multiExpAffine(l,u);d=s.G1.add(d,c);let f=s.G1.fromObject(a.pi_a),p=s.G2.fromObject(a.pi_b),m=s.G1.fromObject(a.pi_c);if(!ca(s,{pi_a:f,pi_b:p,pi_c:m}))return r&&r.error(`Proof commitments are not valid.`),!1;let h=s.G2.fromObject(i.vk_gamma_2),g=s.G2.fromObject(i.vk_delta_2),_=s.G1.fromObject(i.vk_alpha_1),v=s.G2.fromObject(i.vk_beta_2);return await s.pairingEq(s.G1.neg(f),p,d,h,m,g,_,v)?(r&&r.info(`OK!`),!0):(r&&r.error(`Invalid proof`),!1)}function ca(e,t){let n=e.G1,r=e.G2;return n.isValid(t.pi_a)&&r.isValid(t.pi_b)&&n.isValid(t.pi_c)}function la(e,t){return U.geq(t,0)&&U.lt(t,e.r)}function ua(e,t){for(let n=0;n<t.length;n++)if(!la(e,t[n]))return!1;return!0}const{unstringifyBigInts:da}=ni;function fa(e){let t=e.toString(16);for(;t.length<64;)t=`0`+t;return t=`"0x${t}"`,t}async function pa(e,t){let n=da(e),r=da(t),i=``;for(let e=0;e<r.length;e++)i!=``&&(i+=`,`),i+=fa(r[e]);let a;return a=`[${fa(n.pi_a[0])}, ${fa(n.pi_a[1])}],[[${fa(n.pi_b[0][1])}, ${fa(n.pi_b[0][0])}],[${fa(n.pi_b[1][1])}, ${fa(n.pi_b[1][0])}]],[${fa(n.pi_c[0])}, ${fa(n.pi_c[1])}],[${i}]`,a}var ma=Object.freeze({__proto__:null,fullProve:aa,prove:Ki,verify:sa,exportSolidityCallData:pa});U.e(`73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001`,16),U.e(`21888242871839275222246405745257275088548364400416034343698204186575808495617`);const{unstringifyBigInts:ha}=ni,{stringifyBigInts:ga}=ni,{unstringifyBigInts:_a,stringifyBigInts:va}=ni,ya=[],ba=[],xa=[],Sa=BigInt(0),Ca=BigInt(1),wa=BigInt(2),Ta=BigInt(7),Ea=BigInt(256),Da=BigInt(113);for(let e=0,t=Ca,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],ya.push(2*(5*r+n)),ba.push((e+1)*(e+2)/2%64);let i=Sa;for(let e=0;e<7;e++)t=(t<<Ca^(t>>Ta)*Da)%Ea,t&wa&&(i^=Ca<<(Ca<<BigInt(e))-Ca);xa.push(i)}const{stringifyBigInts:Oa}=ni,{unstringifyBigInts:ka}=ni,{unstringifyBigInts:Aa}=ni,{unstringifyBigInts:ja}=ni,{stringifyBigInts:Ma}=ni,{unstringifyBigInts:Na}=ni,{unstringifyBigInts:Pa}=ni,{unstringifyBigInts:Fa}=ni;function Ia(e,t){return function(){return e.apply(t,arguments)}}const{toString:La}=Object.prototype,{getPrototypeOf:Ra}=Object,{iterator:za,toStringTag:Ba}=Symbol,Va=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Ha=(e,t)=>{let n=e,r=[];for(;n!=null&&n!==Object.prototype;){if(r.indexOf(n)!==-1)return!1;if(r.push(n),Va(n,t))return!0;n=Ra(n)}return!1},Ua=(e,t)=>e!=null&&Ha(e,t)?e[t]:void 0,Wa=(e=>t=>{let n=La.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ga=e=>(e=e.toLowerCase(),t=>Wa(t)===e),Ka=e=>t=>typeof t===e,{isArray:qa}=Array,Ja=Ka(`undefined`);function Ya(e){return e!==null&&!Ja(e)&&e.constructor!==null&&!Ja(e.constructor)&&$a(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Xa=Ga(`ArrayBuffer`);function Za(e){let t;return t=typeof ArrayBuffer<`u`&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Xa(e.buffer),t}const Qa=Ka(`string`),$a=Ka(`function`),eo=Ka(`number`),to=e=>typeof e==`object`&&!!e,no=e=>e===!0||e===!1,ro=e=>{if(!to(e))return!1;let t=Ra(e);return(t===null||t===Object.prototype||Ra(t)===null)&&!Ha(e,Ba)&&!Ha(e,za)},io=e=>{if(!to(e)||Ya(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},ao=Ga(`Date`),oo=Ga(`File`),so=e=>!!(e&&e.uri!==void 0),co=e=>e&&e.getParts!==void 0,lo=Ga(`Blob`),uo=Ga(`FileList`),fo=Ga(`Set`),po=e=>to(e)&&$a(e.pipe);function mo(){return typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{}}const ho=mo(),go=ho.FormData===void 0?void 0:ho.FormData,_o=e=>{if(!e)return!1;if(go&&e instanceof go)return!0;let t=Ra(e);if(!t||t===Object.prototype||!$a(e.append))return!1;let n=Wa(e);return n===`formdata`||n===`object`&&$a(e.toString)&&e.toString()===`[object FormData]`},vo=Ga(`URLSearchParams`),[yo,bo,xo,So]=[`ReadableStream`,`Request`,`Response`,`Headers`].map(Ga),Co=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,``);function wo(e,t,{allOwnKeys:n=!1}={}){if(e==null)return;let r,i;if(typeof e!=`object`&&(e=[e]),qa(e))for(r=0,i=e.length;r<i;r++)t.call(null,e[r],r,e);else{if(Ya(e))return;let i=n?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length,o;for(r=0;r<a;r++)o=i[r],t.call(null,e[o],o,e)}}function To(e,t){if(Ya(e))return null;t=t.toLowerCase();let n=Object.keys(e),r=n.length,i;for(;r-- >0;)if(i=n[r],t===i.toLowerCase())return i;return null}const Eo=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:global,Do=e=>!Ja(e)&&e!==Eo;function Oo(...e){let{caseless:t,skipUndefined:n}=Do(this)&&this||{},r={},i=(e,i)=>{if(i===`__proto__`||i===`constructor`||i===`prototype`)return;let a=t&&typeof i==`string`&&To(r,i)||i,o=Va(r,a)?r[a]:void 0;ro(o)&&ro(e)?r[a]=Oo(o,e):ro(e)?r[a]=Oo({},e):qa(e)?r[a]=e.slice():(!n||!Ja(e))&&(r[a]=e)};for(let t=0,n=e.length;t<n;t++){let n=e[t];if(!n||Ya(n)||(wo(n,i),typeof n!=`object`||qa(n)))continue;let r=Object.getOwnPropertySymbols(n);for(let e=0;e<r.length;e++){let t=r[e];Bo.call(n,t)&&i(n[t],t)}}return r}const ko=(e,t,n,{allOwnKeys:r}={})=>(wo(t,(t,r)=>{n&&$a(t)?Object.defineProperty(e,r,{__proto__:null,value:Ia(t,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,r,{__proto__:null,value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),Ao=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),jo=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,`constructor`,{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,`super`,{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},Mo=(e,t,n,r)=>{let i,a,o,s={};if(t||={},e==null)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)o=i[a],(!r||r(o,e,t))&&!s[o]&&(t[o]=e[o],s[o]=!0);e=n!==!1&&Ra(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},No=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},Po=e=>{if(!e)return null;if(qa(e))return e;let t=e.length;if(!eo(t))return null;let n=Array(t);for(;t-- >0;)n[t]=e[t];return n},Fo=(e=>t=>e&&t instanceof e)(typeof Uint8Array<`u`&&Ra(Uint8Array)),Io=(e,t)=>{let n=(e&&e[za]).call(e),r;for(;(r=n.next())&&!r.done;){let n=r.value;t.call(e,n[0],n[1])}},Lo=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Ro=Ga(`HTMLFormElement`),zo=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),{propertyIsEnumerable:Bo}=Object.prototype,Vo=Ga(`RegExp`),Ho=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};wo(n,(n,i)=>{let a;(a=t(n,i,e))!==!1&&(r[i]=a||n)}),Object.defineProperties(e,r)},Uo=e=>{Ho(e,(t,n)=>{if($a(e)&&[`arguments`,`caller`,`callee`].includes(n))return!1;let r=e[n];if($a(r)){if(t.enumerable=!1,`writable`in t){t.writable=!1;return}t.set||=()=>{throw Error(`Can not rewrite read-only method '`+n+`'`)}}})},Wo=(e,t)=>{let n={},r=e=>{e.forEach(e=>{n[e]=!0})};return qa(e)?r(e):r(String(e).split(t)),n},Go=()=>{},Ko=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function qo(e){return!!(e&&$a(e.append)&&e[Ba]===`FormData`&&e[za])}const Jo=e=>{let t=new WeakSet,n=e=>{if(to(e)){if(t.has(e))return;if(Ya(e))return e;if(!(`toJSON`in e)){t.add(e);let r;if(fo(e)){r=[];for(let t of e){let e=n(t);!Ja(e)&&r.push(e)}}else r=qa(e)?[]:{},wo(e,(e,t)=>{let i=n(e);!Ja(i)&&(r[t]=i)});return t.delete(e),r}}return e};return n(e)},Yo=Ga(`AsyncFunction`),Xo=e=>e&&(to(e)||$a(e))&&$a(e.then)&&$a(e.catch),Zo=((e,t)=>e?setImmediate:t?((e,t)=>(Eo.addEventListener(`message`,({source:n,data:r})=>{n===Eo&&r===e&&t.length&&t.shift()()},!1),n=>{t.push(n),Eo.postMessage(e,`*`)}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate==`function`,$a(Eo.postMessage)),Qo=typeof queueMicrotask<`u`?queueMicrotask.bind(Eo):typeof process<`u`&&process.nextTick||Zo,$o=e=>e!=null&&$a(e[za]);var W={isArray:qa,isArrayBuffer:Xa,isBuffer:Ya,isFormData:_o,isArrayBufferView:Za,isString:Qa,isNumber:eo,isBoolean:no,isObject:to,isPlainObject:ro,isEmptyObject:io,isReadableStream:yo,isRequest:bo,isResponse:xo,isHeaders:So,isUndefined:Ja,isDate:ao,isFile:oo,isReactNativeBlob:so,isReactNative:co,isBlob:lo,isRegExp:Vo,isFunction:$a,isStream:po,isURLSearchParams:vo,isTypedArray:Fo,isFileList:uo,forEach:wo,merge:Oo,extend:ko,trim:Co,stripBOM:Ao,inherits:jo,toFlatObject:Mo,kindOf:Wa,kindOfTest:Ga,endsWith:No,toArray:Po,forEachEntry:Io,matchAll:Lo,isHTMLForm:Ro,hasOwnProperty:Va,hasOwnProp:Va,hasOwnInPrototypeChain:Ha,getSafeProp:Ua,reduceDescriptors:Ho,freezeMethods:Uo,toObjectSet:Wo,toCamelCase:zo,noop:Go,toFiniteNumber:Ko,findKey:To,global:Eo,isContextDefined:Do,isSpecCompliantForm:qo,toJSONObject:Jo,isAsyncFn:Yo,isThenable:Xo,setImmediate:Zo,asap:Qo,isIterable:$o,isSafeIterable:e=>e!=null&&Ha(e,za)&&$o(e)};const es=W.toObjectSet([`age`,`authorization`,`content-length`,`content-type`,`etag`,`expires`,`from`,`host`,`if-modified-since`,`if-unmodified-since`,`last-modified`,`location`,`max-forwards`,`proxy-authorization`,`referer`,`retry-after`,`user-agent`]);var ts=e=>{let t={},n,r,i;return e&&e.split(`
|
|
125
|
+
`).forEach(function(e){i=e.indexOf(`:`),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim();let a=W.hasOwnProp(t,n);!n||a&&W.hasOwnProp(es,n)||(n===`set-cookie`?a?t[n].push(r):t[n]=[r]:t[n]=a?t[n]+`, `+r:r)}),t};function ns(e){let t=0,n=e.length;for(;t<n;){let n=e.charCodeAt(t);if(n!==9&&n!==32)break;t+=1}for(;n>t;){let t=e.charCodeAt(n-1);if(t!==9&&t!==32)break;--n}return t===0&&n===e.length?e:e.slice(t,n)}const rs=RegExp(`[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+`,`g`),is=RegExp(`[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+`,`g`);function as(e,t){return W.isArray(e)?e.map(e=>as(e,t)):ns(String(e).replace(t,``))}const os=e=>as(e,rs),ss=e=>as(e,is);function cs(e){let t=Object.create(null);return W.forEach(e.toJSON(),(e,n)=>{t[n]=ss(e)}),t}const ls=Symbol(`internals`);function us(e){return e&&String(e).trim().toLowerCase()}function ds(e){return e===!1||e==null?e:W.isArray(e)?e.map(ds):os(String(e))}function fs(e){let t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const ps=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function ms(e){let t=0,n=e.length;for(;t<n;){let n=e.charCodeAt(t);if(n!==9&&n!==32)break;t+=1}for(;n>t;){let t=e.charCodeAt(n-1);if(t!==9&&t!==32)break;--n}return t===0&&n===e.length?e:e.slice(t,n)}function hs(e){let t=e.length-1;if(t<1||e.charCodeAt(0)!==34||e.charCodeAt(t)!==34)return e;let n=``;for(let r=1;r<t;r++){let i=e.charCodeAt(r);if(i===34||i===92&&(r+=1,r>=t))return e;n+=e[r]}return n}function gs(e){let t=Object.create(null),n=String(e),r=0,i=!1,a=!1;function o(e){let i=ms(n.slice(r,e)),a=i.indexOf(`=`);if(a<1)return;let o=ms(i.slice(0,a));if(!ps.test(o))return;let s=o.toLowerCase();s===`__proto__`||s===`constructor`||s===`prototype`||(t[s]=hs(ms(i.slice(a+1))))}for(let e=0;e<n.length;e++){let t=n.charCodeAt(e);i?a?a=!1:t===92?a=!0:t===34&&(i=!1):t===34?i=!0:(t===44||t===59)&&(o(e),r=e+1)}return o(n.length),t}const _s=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function vs(e,t,n,r,i){if(W.isFunction(r))return r.call(this,t,n);if(i&&(t=n),W.isString(t)){if(W.isString(r))return t.indexOf(r)!==-1;if(W.isRegExp(r))return r.test(t)}}function ys(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function bs(e,t){let n=W.toCamelCase(` `+t);[`get`,`set`,`has`].forEach(r=>{Object.defineProperty(e,r+n,{__proto__:null,value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}var xs=class{constructor(e){e&&this.set(e)}set(e,t,n){let r=this;function i(e,t,n){let i=us(t);if(!i)return;let a=W.findKey(r,i);(!a||r[a]===void 0||n===!0||n===void 0&&r[a]!==!1)&&(r[a||t]=ds(e))}let a=(e,t)=>W.forEach(e,(e,n)=>i(e,n,t));if(W.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(W.isString(e)&&(e=e.trim())&&!_s(e))a(ts(e),t);else if(W.isObject(e)&&W.isSafeIterable(e)){let n=Object.create(null),r,i;for(let t of e){if(!W.isArray(t))throw TypeError(`Object iterator must return a key-value pair`);i=t[0],W.hasOwnProp(n,i)?(r=n[i],n[i]=W.isArray(r)?[...r,t[1]]:[r,t[1]]):n[i]=t[1]}a(n,t)}else e!=null&&i(t,e,n);return this}get(e,t){if(e=us(e),e){let n=W.findKey(this,e);if(n){let e=this[n];if(!t)return e;if(t===!0)return fs(e);if(W.isFunction(t))return t.call(this,e,n);if(W.isRegExp(t))return t.exec(e);throw TypeError(`parser must be boolean|regexp|function`)}}}has(e,t){if(e=us(e),e){let n=W.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||vs(this,this[n],n,t)))}return!1}delete(e,t){let n=this,r=!1;function i(e){if(e=us(e),e){let i=W.findKey(n,e);i&&(!t||vs(n,n[i],i,t))&&(delete n[i],r=!0)}}return W.isArray(e)?e.forEach(i):i(e),r}clear(e){let t=Object.keys(this),n=t.length,r=!1;for(;n--;){let i=t[n];(!e||vs(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){let t=this,n={};return W.forEach(this,(r,i)=>{let a=W.findKey(n,i);if(a){t[a]=ds(r),delete t[i];return}let o=e?ys(i):String(i).trim();o!==i&&delete t[i],t[o]=ds(r),n[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return W.forEach(this,(n,r)=>{n!=null&&n!==!1&&(t[r]=e&&W.isArray(n)?n.join(`, `):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+`: `+t).join(`
|
|
126
|
+
`)}getSetCookie(){let e=this.get(`set-cookie`);return W.isArray(e)?e:e==null||e===!1?[]:[e]}get[Symbol.toStringTag](){return`AxiosHeaders`}static from(e){return e instanceof this?e:new this(e)}static parseParameters(e){return gs(e)}static concat(e,...t){let n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){let t=(this[ls]=this[ls]={accessors:{}}).accessors,n=this.prototype;function r(e){let r=us(e);t[r]||(bs(n,e),t[r]=!0)}return W.isArray(e)?e.forEach(r):r(e),this}};xs.accessor([`Content-Type`,`Content-Length`,`Accept`,`Accept-Encoding`,`User-Agent`,`Authorization`]),W.reduceDescriptors(xs.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),W.freezeMethods(xs);const Ss=`[REDACTED ****]`;function Cs(e){if(W.hasOwnProp(e,`toJSON`))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(W.hasOwnProp(t,`toJSON`))return!0;t=Object.getPrototypeOf(t)}return!1}function ws(e,t){let n=new Set(t.map(e=>String(e).toLowerCase())),r=[],i=e=>{if(typeof e!=`object`||!e||W.isBuffer(e))return e;if(r.indexOf(e)!==-1)return;e instanceof xs&&(e=e.toJSON()),r.push(e);let t;if(W.isArray(e))t=[],e.forEach((e,n)=>{let r=i(e);W.isUndefined(r)||(t[n]=r)});else{if(!W.isPlainObject(e)&&Cs(e))return r.pop(),e;t=Object.create(null);for(let[r,a]of Object.entries(e)){let e=n.has(r.toLowerCase())?Ss:i(a);W.isUndefined(e)||(t[r]=e)}}return r.pop(),t};return i(e)}function Ts(e){try{return String(e)}catch{return``}}function Es(e){return e.errors.map(e=>{try{return e&&e.message?Ts(e.message):Ts(e)}catch{return``}}).filter(Boolean).join(`; `)||e.name||`AggregateError`}var G=class e extends Error{static from(t,n,r,i,a,o){let s=t.message;!s&&W.isArray(t.errors)&&t.errors.length&&(s=Es(t));let c=new e(s,n||t.code,r,i,a);return Object.defineProperty(c,`cause`,{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),c.name=t.name,t.status!=null&&c.status==null&&(c.status=t.status),o&&Object.assign(c,o),c}constructor(e,t,n,r,i){super(e),Object.defineProperty(this,`message`,{__proto__:null,value:e,enumerable:!0,writable:!0,configurable:!0}),this.name=`AxiosError`,this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){let e=this.config,t=e&&W.hasOwnProp(e,`redact`)?e.redact:void 0,n=W.isArray(t)&&t.length>0?ws(e,t):W.toJSONObject(e);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:n,code:this.code,status:this.status}}};G.ERR_BAD_OPTION_VALUE=`ERR_BAD_OPTION_VALUE`,G.ERR_BAD_OPTION=`ERR_BAD_OPTION`,G.ECONNABORTED=`ECONNABORTED`,G.ETIMEDOUT=`ETIMEDOUT`,G.ECONNREFUSED=`ECONNREFUSED`,G.ERR_NETWORK=`ERR_NETWORK`,G.ERR_FR_TOO_MANY_REDIRECTS=`ERR_FR_TOO_MANY_REDIRECTS`,G.ERR_DEPRECATED=`ERR_DEPRECATED`,G.ERR_BAD_RESPONSE=`ERR_BAD_RESPONSE`,G.ERR_BAD_REQUEST=`ERR_BAD_REQUEST`,G.ERR_CANCELED=`ERR_CANCELED`,G.ERR_NOT_SUPPORT=`ERR_NOT_SUPPORT`,G.ERR_INVALID_URL=`ERR_INVALID_URL`,G.ERR_FORM_DATA_DEPTH_EXCEEDED=`ERR_FORM_DATA_DEPTH_EXCEEDED`;function Ds(e){return W.isPlainObject(e)||W.isArray(e)}function Os(e){return W.endsWith(e,`[]`)?e.slice(0,-2):e}function ks(e,t,n){return e?e.concat(t).map(function(e,t){return e=Os(e),!n&&t?`[`+e+`]`:e}).join(n?`.`:``):t}function As(e){return W.isArray(e)&&!e.some(Ds)}const js=W.toFlatObject(W,{},null,function(e){return/^is[A-Z]/.test(e)});function Ms(e,t,n){if(!W.isObject(e))throw TypeError(`target must be an object`);t||=new FormData,n=W.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!W.isUndefined(t[e])});let r=n.metaTokens,i=n.visitor||m,a=n.dots,o=n.indexes,s=n.Blob||typeof Blob<`u`&&Blob,c=n.maxDepth===void 0?100:n.maxDepth,l=s&&W.isSpecCompliantForm(t),u=[];if(!W.isFunction(i))throw TypeError(`visitor must be a function`);function d(e){if(e===null)return``;if(W.isDate(e))return e.toISOString();if(W.isBoolean(e))return e.toString();if(!l&&W.isBlob(e))throw new G(`Blob is not supported. Use a Buffer instead.`);if(W.isArrayBuffer(e)||W.isTypedArray(e)){if(l&&typeof s==`function`)return new s([e]);throw new G(`Blob is not supported. Use a Buffer instead.`,G.ERR_NOT_SUPPORT)}return e}function f(e){if(e>c)throw new G(`Object is too deeply nested (`+e+` levels). Max depth: `+c,G.ERR_FORM_DATA_DEPTH_EXCEEDED)}function p(e,t){if(c===1/0)return JSON.stringify(e);let n=[];return JSON.stringify(e,function(e,r){if(!W.isObject(r))return r;for(;n.length&&n[n.length-1]!==this;)n.pop();return n.push(r),f(t+n.length-1),r})}function m(e,n,i){let s=e;if(W.isReactNative(t)&&W.isReactNativeBlob(e))return t.append(ks(i,n,a),d(e)),!1;if(e&&!i&&typeof e==`object`){if(W.endsWith(n,`{}`))n=r?n:n.slice(0,-2),e=p(e,1);else if(W.isArray(e)&&As(e)||(W.isFileList(e)||W.endsWith(n,`[]`))&&(s=W.toArray(e)))return n=Os(n),s.forEach(function(e,r){!(W.isUndefined(e)||e===null)&&t.append(o===!0?ks([n],r,a):o===null?n:n+`[]`,d(e))}),!1}return Ds(e)?!0:(t.append(ks(i,n,a),d(e)),!1)}let h=Object.assign(js,{defaultVisitor:m,convertValue:d,isVisitable:Ds});function g(e,n,r=0){if(!W.isUndefined(e)){if(f(r),u.indexOf(e)!==-1)throw Error(`Circular reference detected in `+n.join(`.`));u.push(e),W.forEach(e,function(e,a){(!(W.isUndefined(e)||e===null)&&i.call(t,e,W.isString(a)?a.trim():a,n,h))===!0&&g(e,n?n.concat(a):[a],r+1)}),u.pop()}}if(!W.isObject(e))throw TypeError(`data must be an object`);return g(e),t}function Ns(e){let t={"!":`%21`,"'":`%27`,"(":`%28`,")":`%29`,"~":`%7E`,"%20":`+`};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(e){return t[e]})}function Ps(e,t){this._pairs=[],e&&Ms(e,this,t)}const Fs=Ps.prototype;Fs.append=function(e,t){this._pairs.push([e,t])},Fs.toString=function(e){let t=e?t=>e.call(this,t,Ns):Ns;return this._pairs.map(function(e){return t(e[0])+`=`+t(e[1])},``).join(`&`)};function Is(e){return encodeURIComponent(e).replace(/%3A/gi,`:`).replace(/%24/g,`$`).replace(/%2C/gi,`,`).replace(/%20/g,`+`)}function Ls(e,t,n){if(!t)return e;e||=``;let r=W.isFunction(n)?{serialize:n}:n,i=W.getSafeProp(r,`encode`)||Is,a=W.getSafeProp(r,`serialize`),o;if(o=a?a(t,r):W.isURLSearchParams(t)?t.toString():new Ps(t,r).toString(i),o){let t=e.indexOf(`#`);t!==-1&&(e=e.slice(0,t)),e+=(e.indexOf(`?`)===-1?`?`:`&`)+o}return e}var Rs=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&=[]}forEach(e){W.forEach(this.handlers,function(t){t!==null&&e(t)})}},zs={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0},Bs={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<`u`?URLSearchParams:Ps,FormData:typeof FormData<`u`?FormData:null,Blob:typeof Blob<`u`?Blob:null},protocols:[`http`,`https`,`file`,`blob`,`url`,`data`]},Vs=n({hasBrowserEnv:()=>Hs,hasStandardBrowserEnv:()=>Ws,hasStandardBrowserWebWorkerEnv:()=>Gs,navigator:()=>Us,origin:()=>Ks});const Hs=typeof window<`u`&&typeof document<`u`,Us=typeof navigator==`object`&&navigator||void 0,Ws=Hs&&(!Us||[`ReactNative`,`NativeScript`,`NS`].indexOf(Us.product)<0),Gs=typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope&&typeof self.importScripts==`function`,Ks=Hs&&window.location.href||`http://localhost`;var qs={...Vs,...Bs};function Js(e,t){return Ms(e,new qs.classes.URLSearchParams,{visitor:function(e,t,n,r){return qs.isNode&&W.isBuffer(e)?(this.append(t,e.toString(`base64`)),!1):r.defaultVisitor.apply(this,arguments)},...t})}function Ys(e){if(e>100)throw new G(`FormData field is too deeply nested (`+e+` levels). Max depth: 100`,G.ERR_FORM_DATA_DEPTH_EXCEEDED)}function Xs(e){let t=[],n=/[^.[\]]+|\[([^.[\]]*)]/g,r;for(;(r=n.exec(e))!==null;)Ys(t.length),t.push(r[0]===`[]`?``:r[1]||r[0]);return t}function Zs(e){let t={},n=Object.keys(e),r,i=n.length,a;for(r=0;r<i;r++)a=n[r],t[a]=e[a];return t}function Qs(e){function t(e,n,r,i){Ys(i);let a=e[i++];if(a===`__proto__`)return!0;let o=Number.isFinite(+a),s=i>=e.length;return a=!a&&W.isArray(r)?r.length:a,s?(W.hasOwnProp(r,a)?r[a]=W.isArray(r[a])?r[a].concat(n):[r[a],n]:r[a]=n,!o):((!W.hasOwnProp(r,a)||!W.isObject(r[a]))&&(r[a]=[]),t(e,n,r[a],i)&&W.isArray(r[a])&&(r[a]=Zs(r[a])),!o)}if(W.isFormData(e)&&W.isFunction(e.entries)){let n={};return W.forEachEntry(e,(e,r)=>{t(Xs(e),r,n,0)}),n}return null}const $s=(e,t)=>e!=null&&W.hasOwnProp(e,t)?e[t]:void 0;function ec(e,t,n){if(W.isString(e))try{return(t||JSON.parse)(e),W.trim(e)}catch(e){if(e.name!==`SyntaxError`)throw e}return(n||JSON.stringify)(e)}const tc={transitional:zs,adapter:[`xhr`,`http`,`fetch`],transformRequest:[function(e,t){let n=t.getContentType()||``,r=n.indexOf(`application/json`)>-1,i=W.isObject(e);if(i&&W.isHTMLForm(e)&&(e=new FormData(e)),W.isFormData(e))return r?JSON.stringify(Qs(e)):e;if(W.isArrayBuffer(e)||W.isBuffer(e)||W.isStream(e)||W.isFile(e)||W.isBlob(e)||W.isReadableStream(e))return e;if(W.isArrayBufferView(e))return e.buffer;if(W.isURLSearchParams(e))return t.setContentType(`application/x-www-form-urlencoded;charset=utf-8`,!1),e.toString();let a;if(i){let t=$s(this,`formSerializer`);if(n.indexOf(`application/x-www-form-urlencoded`)>-1)return Js(e,t).toString();if((a=W.isFileList(e))||n.indexOf(`multipart/form-data`)>-1){let n=$s(this,`env`),r=n&&n.FormData;return Ms(a?{"files[]":e}:e,r&&new r,t)}}return i||r?(t.setContentType(`application/json`,!1),ec(e)):e}],transformResponse:[function(e){let t=$s(this,`transitional`)||tc.transitional,n=t&&t.forcedJSONParsing,r=$s(this,`responseType`),i=r===`json`;if(W.isResponse(e)||W.isReadableStream(e))return e;if(e&&W.isString(e)&&(n&&!r||i)){let n=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,$s(this,`parseReviver`))}catch(e){if(n)throw e.name===`SyntaxError`?G.from(e,G.ERR_BAD_RESPONSE,this,null,$s(this,`response`)):e}}return e}],timeout:0,xsrfCookieName:`XSRF-TOKEN`,xsrfHeaderName:`X-XSRF-TOKEN`,maxContentLength:-1,maxBodyLength:-1,env:{FormData:qs.classes.FormData,Blob:qs.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:`application/json, text/plain, */*`,"Content-Type":void 0}}};W.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`query`],e=>{tc.headers[e]={}});function nc(e,t){let n=this||tc,r=t||n,i=xs.from(r.headers),a=r.data;return W.forEach(e,function(e){a=e.call(n,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function rc(e){return!!(e&&e.__CANCEL__)}var ic=class extends G{constructor(e,t,n){super(e??`canceled`,G.ERR_CANCELED,t,n),this.name=`CanceledError`,this.__CANCEL__=!0}};function ac(e,t,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new G(`Request failed with status code `+n.status,n.status>=400&&n.status<500?G.ERR_BAD_REQUEST:G.ERR_BAD_RESPONSE,n.config,n.request,n))}function oc(e){let t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||``}function sc(e,t){e||=10;let n=Array(e),r=Array(e),i=0,a=0,o;return t=t===void 0?1e3:t,function(s){let c=Date.now(),l=r[a];o||=c,n[i]=s,r[i]=c;let u=a,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-o<t)return;let f=l&&c-l;return f?Math.round(d*1e3/f):void 0}}function cc(e,t){let n=0,r=1e3/t,i,a,o=(t,r=Date.now())=>{n=r,i=null,a&&=(clearTimeout(a),null),e(...t)};return[(...e)=>{let t=Date.now(),s=t-n;s>=r?o(e,t):(i=e,a||=setTimeout(()=>{a=null,o(i)},r-s))},()=>i&&o(i)]}const lc=(e,t,n=3)=>{let r=0,i=sc(50,250);return cc(n=>{if(!n||typeof n.loaded!=`number`)return;let a=n.loaded,o=n.lengthComputable?n.total:void 0,s=Math.max(0,o==null?a:Math.min(a,o)),c=Math.max(0,s-r),l=i(c);r=Math.max(r,s),e({loaded:s,total:o,progress:o?s/o:void 0,bytes:c,rate:l||void 0,estimated:l&&o?(o-s)/l:void 0,event:n,lengthComputable:o!=null,[t?`download`:`upload`]:!0})},n)},uc=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},dc=(e,t=W.asap)=>(...n)=>t(()=>e(...n));var fc=qs.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,qs.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(qs.origin),qs.navigator&&/(msie|trident)/i.test(qs.navigator.userAgent)):()=>!0,pc=qs.hasStandardBrowserEnv?{write(e,t,n,r,i,a,o){if(typeof document>`u`)return;let s=[`${e}=${encodeURIComponent(t)}`];W.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),W.isString(r)&&s.push(`path=${r}`),W.isString(i)&&s.push(`domain=${i}`),a===!0&&s.push(`secure`),W.isString(o)&&s.push(`SameSite=${o}`),document.cookie=s.join(`; `)},read(e){if(typeof document>`u`)return null;let t=document.cookie.split(`;`);for(let n=0;n<t.length;n++){let r=t[n].replace(/^\s+/,``),i=r.indexOf(`=`);if(i!==-1&&r.slice(0,i)===e)try{return decodeURIComponent(r.slice(i+1))}catch{return r.slice(i+1)}}return null},remove(e){this.write(e,``,Date.now()-864e5,`/`)}}:{write(){},read(){return null},remove(){}};function mc(e){return typeof e==`string`?/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e):!1}function hc(e,t){if(!t)return e;let n=e.length;for(;n>0&&e.charCodeAt(n-1)===47;)n--;return e.slice(0,n)+`/`+t.replace(/^\/+/,``)}const gc=/^https?:(?!\/\/)/i,_c=/[\t\n\r]/g;function vc(e){let t=0;for(;t<e.length&&e.charCodeAt(t)<=32;)t++;return e.slice(t)}function yc(e){return vc(e).replace(_c,``)}function bc(e){return e&&e.replace(/(^|&)([^=&]*=)?[^&]+/g,(e,t,n=``)=>`${t}${n}${Ss}`)}function xc(e){let t=e.replace(/^(https?:\/{0,2})[^/?#]*@/i,`$1${Ss}@`),n=t.indexOf(`#`),r=(n===-1?t:t.slice(0,n)).replace(/([?&][^=&#]*=)[^&#]*/g,`$1${Ss}`);return n===-1?r:`${r}#${bc(t.slice(n+1))}`}function Sc(e,t){if(typeof e==`string`){let n=yc(e);if(gc.test(n))throw new G(`Invalid URL ${JSON.stringify(xc(n))}: missing "//" after protocol`,G.ERR_INVALID_URL,t)}}function Cc(e,t,n,r){Sc(t,r);let i=!mc(t);return e&&(i||n===!1)?(Sc(e,r),hc(e,t)):t}const wc=e=>e instanceof xs?{...e}:e,Tc=e=>Object.getOwnPropertySymbols&&Object.getOwnPropertyDescriptor?Object.keys(e).concat(Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)):Object.keys(e);function Ec(e,t){e||={},t||={};let n=Object.create(null);Object.defineProperty(n,`hasOwnProperty`,{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(e,t,n,r){return W.isPlainObject(e)&&W.isPlainObject(t)?W.merge.call({caseless:r},e,t):W.isPlainObject(t)?W.merge({},t):W.isArray(t)?t.slice():t}function i(e,t,n,i){if(!W.isUndefined(t))return r(e,t,n,i);if(!W.isUndefined(e))return r(void 0,e,n,i)}function a(e,t){if(!W.isUndefined(t))return r(void 0,t)}function o(e,t){if(!W.isUndefined(t))return r(void 0,t);if(!W.isUndefined(e))return r(void 0,e)}function s(n){let r=W.hasOwnProp(t,`transitional`)?t.transitional:void 0;if(!W.isUndefined(r))if(W.isPlainObject(r)){if(W.hasOwnProp(r,n))return r[n]}else return;let i=W.hasOwnProp(e,`transitional`)?e.transitional:void 0;if(W.isPlainObject(i)&&W.hasOwnProp(i,n))return i[n]}function c(n,i,a){if(W.hasOwnProp(t,a))return r(n,i);if(W.hasOwnProp(e,a))return r(void 0,n)}let l={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,allowedSocketPaths:o,responseEncoding:o,validateStatus:c,headers:(e,t,n)=>i(wc(e),wc(t),n,!0)};return W.forEach(Tc({...e,...t}),function(r){if(r===`__proto__`||r===`constructor`||r===`prototype`)return;let a=W.hasOwnProp(l,r)?l[r]:i,o=a(W.hasOwnProp(e,r)?e[r]:void 0,W.hasOwnProp(t,r)?t[r]:void 0,r);W.isUndefined(o)&&a!==c||(n[r]=o)}),W.hasOwnProp(t,`validateStatus`)&&W.isUndefined(t.validateStatus)&&s(`validateStatusUndefinedResolves`)===!1&&(W.hasOwnProp(e,`validateStatus`)?n.validateStatus=r(void 0,e.validateStatus):delete n.validateStatus),n}const Dc=[`content-type`,`content-length`];function Oc(e,t,n){if(n!==`content-only`){e.set(t);return}Object.entries(t||{}).forEach(([t,n])=>{Dc.includes(t.toLowerCase())&&e.set(t,n)})}const kc=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16)));function Ac(e){let t=Ec({},e),n=e=>W.hasOwnProp(t,e)?t[e]:void 0,r=n(`data`),i=n(`withXSRFToken`),a=n(`xsrfHeaderName`),o=n(`xsrfCookieName`),s=n(`headers`),c=n(`auth`),l=n(`baseURL`),u=n(`allowAbsoluteUrls`),d=n(`url`);if(t.headers=s=xs.from(s),t.url=Ls(Cc(l,d,u,t),n(`params`),n(`paramsSerializer`)),c){let t=W.getSafeProp(c,`username`)||``,n=W.getSafeProp(c,`password`)||``;try{s.set(`Authorization`,`Basic `+btoa(t+`:`+(n?kc(n):``)))}catch(t){throw G.from(t,G.ERR_BAD_OPTION_VALUE,e)}}if(W.isFormData(r)&&(qs.hasStandardBrowserEnv||qs.hasStandardBrowserWebWorkerEnv||W.isReactNative(r)?s.setContentType(void 0):W.isFunction(r.getHeaders)&&Oc(s,r.getHeaders(),n(`formDataHeaderPolicy`))),qs.hasStandardBrowserEnv&&(W.isFunction(i)&&(i=i(t)),i===!0||i==null&&fc(t.url))){let e=a&&o&&pc.read(o);e&&s.set(a,e)}return t}var jc=typeof XMLHttpRequest<`u`&&function(e){return new Promise(function(t,n){let r=Ac(e),i=r.data,a=xs.from(r.headers).normalize(),{responseType:o,onUploadProgress:s,onDownloadProgress:c}=r,l,u,d,f,p;function m(){f&&f(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(l),r.signal&&r.signal.removeEventListener(`abort`,l)}let h=new XMLHttpRequest;h.open(r.method.toUpperCase(),r.url,!0),h.timeout=r.timeout;function g(){if(!h)return;let r=xs.from(`getAllResponseHeaders`in h&&h.getAllResponseHeaders());ac(function(e){t(e),m()},function(e){n(e),m()},{data:!o||o===`text`||o===`json`?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:r,config:e,request:h}),h=null}`onloadend`in h?h.onloadend=g:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.startsWith(`file:`))||setTimeout(g)},h.onabort=function(){h&&=(n(new G(`Request aborted`,G.ECONNABORTED,e,h)),m(),null)},h.onerror=function(t){let r=new G(t&&t.message?t.message:`Network Error`,G.ERR_NETWORK,e,h);r.event=t||null,n(r),m(),h=null},h.ontimeout=function(){let t=r.timeout?`timeout of `+r.timeout+`ms exceeded`:`timeout exceeded`,i=r.transitional||zs;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new G(t,i.clarifyTimeoutError?G.ETIMEDOUT:G.ECONNABORTED,e,h)),m(),h=null},i===void 0&&a.setContentType(null),`setRequestHeader`in h&&W.forEach(cs(a),function(e,t){h.setRequestHeader(t,e)}),W.isUndefined(r.withCredentials)||(h.withCredentials=!!r.withCredentials),o&&o!==`json`&&(h.responseType=r.responseType),c&&([d,p]=lc(c,!0),h.addEventListener(`progress`,d)),s&&h.upload&&([u,f]=lc(s),h.upload.addEventListener(`progress`,u),h.upload.addEventListener(`loadend`,f)),(r.cancelToken||r.signal)&&(l=t=>{h&&=(n(!t||t.type?new ic(null,e,h):t),h.abort(),m(),null)},r.cancelToken&&r.cancelToken.subscribe(l),r.signal&&(r.signal.aborted?l():r.signal.addEventListener(`abort`,l)));let _=oc(r.url);if(_&&!qs.protocols.includes(_)){n(new G(`Unsupported protocol `+_+`:`,G.ERR_BAD_REQUEST,e)),m();return}h.send(i||null)})};const Mc=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;let n=new AbortController,r=!1,i=function(e){if(!r){r=!0,o();let t=e instanceof Error?e:this.reason;n.abort(t instanceof G?t:new ic(t instanceof Error?t.message:t))}},a=t&&setTimeout(()=>{a=null,i(new G(`timeout of ${t}ms exceeded`,G.ETIMEDOUT))},t),o=()=>{e&&=(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener(`abort`,i)}),null)};e.forEach(e=>{if(!r){if(e.aborted){i.call(e);return}e.addEventListener(`abort`,i,{once:!0})}});let{signal:s}=n;return s.unsubscribe=()=>W.asap(o),s},Nc=function*(e,t){let n=e.byteLength;if(!t||n<t){yield e;return}let r=0,i;for(;r<n;)i=r+t,yield e.slice(r,i),r=i},Pc=async function*(e,t){for await(let n of Fc(e))yield*Nc(n,t)},Fc=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}let t=e.getReader();try{for(;;){let{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},Ic=(e,t,n,r)=>{let i=Pc(e,t),a=0,o,s=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{let{done:t,value:r}=await i.next();if(t){s(),e.close();return}let o=r.byteLength;n&&n(a+=o),e.enqueue(new Uint8Array(r))}catch(e){throw s(e),e}},cancel(e){return s(e),i.return()}},{highWaterMark:2})},Lc=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,Rc=(e,t,n)=>t+2<n&&Lc(e.charCodeAt(t+1))&&Lc(e.charCodeAt(t+2)),zc=e=>e<=57?e-48:(e&223)-55,Bc=e=>e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===43||e===47||e===45||e===95,Vc=e=>e===9||e===10||e===12||e===13||e===32,Hc=e=>{let t=Math.floor(e/4),n=e%4;return t*3+(n===2?1:n===3?2:0)},Uc=e=>{let t=e.length,n=0;return t>0&&e.charCodeAt(t-1)===61&&(n++,t>1&&e.charCodeAt(t-2)===61&&n++),Math.floor((t-n)*3/4)},Wc=e=>{let t=e.length,n=0,r=0,i=!1;for(let a=0;a<t;a++){let o=e.charCodeAt(a);if(o===37&&Rc(e,a,t)&&(o=zc(e.charCodeAt(a+1))*16+zc(e.charCodeAt(a+2)),a+=2),!Vc(o)){if(o===61){r++;continue}if(!Bc(o)||r>0){i=!0;continue}n++}}return i||r>2||r>0&&(n+r)%4!=0||n%4==1?Uc(e):Hc(n)},Gc=(e,t)=>{if(!e||typeof e!=`string`||!e.startsWith(`data:`))return 0;let n=e.indexOf(`,`);if(n<0)return 0;let r=e.slice(5,n),i=e.slice(n+1);if(/;base64/i.test(r))return t(i);let a=0;for(let e=0,t=i.length;e<t;e++){let n=i.charCodeAt(e);if(n===37&&Rc(i,e,t))a+=1,e+=2;else if(n<128)a+=1;else if(n<2048)a+=2;else if(n>=55296&&n<=56319&&e+1<t){let t=i.charCodeAt(e+1);t>=56320&&t<=57343?(a+=4,e++):a+=3}else a+=3}return a};function Kc(e){let t=typeof e==`string`?e.indexOf(`#`):-1;return Gc(t===-1?e:e.slice(0,t),Wc)}const qc=`1.19.0`,Jc=64*1024,{isFunction:Yc}=W,Xc=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16))),Zc=e=>{if(!W.isString(e))return e;try{return decodeURIComponent(e)}catch{return e}},Qc=(e,...t)=>{try{return!!e(...t)}catch{return!1}},$c=e=>{let t=e.indexOf(`://`),n=e;return t!==-1&&(n=n.slice(t+3)),n.includes(`@`)||n.includes(`:`)},el=e=>{let t=W.global!==void 0&&W.global!==null?W.global:globalThis,{ReadableStream:n,TextEncoder:r}=t;e=W.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);let{fetch:i,Request:a,Response:o}=e,s=i?Yc(i):typeof fetch==`function`,c=Yc(a),l=Yc(o);if(!s)return!1;let u=s&&Yc(n),d=s&&(typeof r==`function`?(e=>t=>e.encode(t))(new r):async e=>new Uint8Array(await new a(e).arrayBuffer())),f=c&&u&&Qc(()=>{let e=!1,t=new a(qs.origin,{body:new n,method:`POST`,get duplex(){return e=!0,`half`}}),r=t.headers.has(`Content-Type`);return t.body!=null&&t.body.cancel(),e&&!r}),p=l&&u&&Qc(()=>W.isReadableStream(new o(``).body)),m={stream:p&&(e=>e.body)};s&&[`text`,`arrayBuffer`,`blob`,`formData`,`stream`].forEach(e=>{!m[e]&&(m[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new G(`Response type '${e}' is not supported`,G.ERR_NOT_SUPPORT,n)})});let h=async e=>{if(e==null)return 0;if(W.isBlob(e))return e.size;if(W.isSpecCompliantForm(e))return(await new a(qs.origin,{method:`POST`,body:e}).arrayBuffer()).byteLength;if(W.isArrayBufferView(e)||W.isArrayBuffer(e))return e.byteLength;if(W.isURLSearchParams(e)&&(e+=``),W.isString(e))return(await d(e)).byteLength},g=async(e,t)=>W.toFiniteNumber(e.getContentLength())??h(t);return async e=>{let{url:t,method:n,data:s,signal:l,cancelToken:d,timeout:_,onDownloadProgress:v,onUploadProgress:y,responseType:b,headers:x,withCredentials:S=`same-origin`,fetchOptions:C,maxContentLength:w,maxBodyLength:T}=Ac(e),E=W.isNumber(w)&&w>-1,D=W.isNumber(T)&&T>-1,O=t=>W.hasOwnProp(e,t)?e[t]:void 0,k=i||fetch;b=b?(b+``).toLowerCase():`text`;let A=Mc([l,d&&d.toAbortSignal()],_),j=null,ee=A&&A.unsubscribe&&(()=>{A.unsubscribe()}),M,N=null,P=()=>new G(`Request body larger than maxBodyLength limit`,G.ERR_BAD_REQUEST,e,j);try{let i,l=O(`auth`);if(l&&(i={username:W.getSafeProp(l,`username`)||``,password:W.getSafeProp(l,`password`)||``}),$c(t)){let e=new URL(t,qs.origin);!i&&(e.username||e.password)&&(i={username:Zc(e.username),password:Zc(e.password)}),(e.username||e.password)&&(e.username=``,e.password=``,t=e.href)}if(i&&(x.delete(`authorization`),x.set(`Authorization`,`Basic `+btoa(Xc((i.username||``)+`:`+(i.password||``))))),E&&typeof t==`string`&&t.startsWith(`data:`)&&Kc(t)>w)throw new G(`maxContentLength size of `+w+` exceeded`,G.ERR_BAD_RESPONSE,e,j);if(D&&n!==`get`&&n!==`head`){let e=await h(s);if(typeof e==`number`&&isFinite(e)&&(M=e,e>T))throw P()}let d=D&&(W.isReadableStream(s)||W.isStream(s)),_=(e,t,n)=>Ic(e,Jc,e=>{if(D&&e>T)throw N=P();t&&t(e)},n);if(f&&n!==`get`&&n!==`head`&&(y||d)){if(M??=await g(x,s),M!==0||d){let e=new a(t,{method:`POST`,body:s,duplex:`half`}),n;if(W.isFormData(s)&&(n=e.headers.get(`content-type`))&&x.setContentType(n),e.body){let[t,n]=y&&uc(M,lc(dc(y)))||[];s=_(e.body,t,n)}}}else if(d&&!c&&u&&n!==`get`&&n!==`head`)s=_(s);else if(d&&c&&!f&&n!==`get`&&n!==`head`)throw new G(`Stream request bodies are not supported by the current fetch implementation`,G.ERR_NOT_SUPPORT,e,j);W.isString(S)||(S=S?`include`:`omit`);let F=c&&`credentials`in a.prototype;if(W.isFormData(s)){let e=x.getContentType();e&&/^multipart\/form-data/i.test(e)&&!/boundary=/i.test(e)&&x.delete(`content-type`)}x.set(`User-Agent`,`axios/`+qc,!1);let te={...C,signal:A,method:n.toUpperCase(),headers:cs(x.normalize()),body:s,duplex:`half`,credentials:F?S:void 0};j=c&&new a(t,te);let I=await(c?k(j,C):k(t,te)),L=xs.from(I.headers);if(E){let t=W.toFiniteNumber(L.getContentLength());if(t!=null&&t>w)throw new G(`maxContentLength size of `+w+` exceeded`,G.ERR_BAD_RESPONSE,e,j)}let ne=p&&(b===`stream`||b===`response`);if(p&&I.body&&(v||E||ne&&ee)){let t={};[`status`,`statusText`,`headers`].forEach(e=>{t[e]=I[e]});let n=W.toFiniteNumber(L.getContentLength()),[r,i]=v&&uc(n,lc(dc(v),!0))||[],a=0;I=new o(Ic(I.body,Jc,t=>{if(E&&(a=t,a>w))throw new G(`maxContentLength size of `+w+` exceeded`,G.ERR_BAD_RESPONSE,e,j);r&&r(t)},()=>{i&&i(),ee&&ee()}),t)}b||=`text`;let re=await m[W.findKey(m,b)||`text`](I,e);if(E&&!p&&!ne){let t;if(re!=null&&(typeof re.byteLength==`number`?t=re.byteLength:typeof re.size==`number`?t=re.size:typeof re==`string`&&(t=typeof r==`function`?new r().encode(re).byteLength:re.length)),typeof t==`number`&&t>w)throw new G(`maxContentLength size of `+w+` exceeded`,G.ERR_BAD_RESPONSE,e,j)}return!ne&&ee&&ee(),await new Promise((t,n)=>{ac(t,n,{data:re,headers:xs.from(I.headers),status:I.status,statusText:I.statusText,config:e,request:j})})}catch(t){if(ee&&ee(),A&&A.aborted&&A.reason instanceof G){let n=A.reason;throw n.config=e,j&&(n.request=j),t!==n&&Object.defineProperty(n,`cause`,{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),n}if(N)throw j&&!N.request&&(N.request=j),N;if(t instanceof G)throw j&&!t.request&&(t.request=j),t;if(t&&t.name===`TypeError`&&/Load failed|fetch/i.test(t.message)){let n=new G(`Network Error`,G.ERR_NETWORK,e,j,t&&t.response);throw Object.defineProperty(n,`cause`,{__proto__:null,value:t.cause||t,writable:!0,enumerable:!1,configurable:!0}),n}throw G.from(t,t&&t.code,e,j,t&&t.response)}}},tl=new Map,nl=e=>{let t=e&&e.env||{},{fetch:n,Request:r,Response:i}=t,a=[r,i,n],o=a.length,s,c,l=tl;for(;o--;)s=a[o],c=l.get(s),c===void 0&&l.set(s,c=o?new Map:el(t)),l=c;return c};nl();const rl={http:null,xhr:jc,fetch:{get:nl}};W.forEach(rl,(e,t)=>{if(e){try{Object.defineProperty(e,`name`,{__proto__:null,value:t})}catch{}Object.defineProperty(e,`adapterName`,{__proto__:null,value:t})}});const il=e=>`- ${e}`,al=e=>W.isFunction(e)||e===null||e===!1;function ol(e,t){e=W.isArray(e)?e:[e];let{length:n}=e,r,i,a={};for(let o=0;o<n;o++){r=e[o];let n;if(i=r,!al(r)&&(i=rl[(n=String(r)).toLowerCase()],i===void 0))throw new G(`Unknown adapter '${n}'`);if(i&&(W.isFunction(i)||(i=i.get(t))))break;a[n||`#`+o]=i}if(!i){let e=Object.entries(a).map(([e,t])=>`adapter ${e} `+(t===!1?`is not supported by the environment`:`is not available in the build`));throw new G(`There is no suitable adapter to dispatch the request `+(n?e.length>1?`since :
|
|
127
|
+
`+e.map(il).join(`
|
|
128
|
+
`):` `+il(e[0]):`as no adapter specified`),G.ERR_NOT_SUPPORT)}return i}var sl={getAdapter:ol,adapters:rl};function cl(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ic(null,e)}function ll(e){return cl(e),e.headers=xs.from(e.headers),e.data=nc.call(e,e.transformRequest),[`post`,`put`,`patch`].indexOf(e.method)!==-1&&e.headers.setContentType(`application/x-www-form-urlencoded`,!1),sl.getAdapter(e.adapter||tc.adapter,e)(e).then(function(t){cl(e),e.response=t;try{t.data=nc.call(e,e.transformResponse,t)}finally{delete e.response}return t.headers=xs.from(t.headers),t},function(t){if(!rc(t)&&(cl(e),t&&t.response)){e.response=t.response;try{t.response.data=nc.call(e,e.transformResponse,t.response)}finally{delete e.response}t.response.headers=xs.from(t.response.headers)}return Promise.reject(t)})}const ul={};[`object`,`boolean`,`number`,`function`,`string`,`symbol`].forEach((e,t)=>{ul[e]=function(n){return typeof n===e||`a`+(t<1?`n `:` `)+e}});const dl={};ul.transitional=function(e,t,n){function r(e,t){return`[Axios v`+qc+`] Transitional option '`+e+`'`+t+(n?`. `+n:``)}return(n,i,a)=>{if(e===!1)throw new G(r(i,` has been removed`+(t?` in `+t:``)),G.ERR_DEPRECATED);return t&&!dl[i]&&(dl[i]=!0,console.warn(r(i,` has been deprecated since v`+t+` and will be removed in the near future`))),e?e(n,i,a):!0}},ul.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function fl(e,t,n){if(typeof e!=`object`||!e)throw new G(`options must be an object`,G.ERR_BAD_OPTION_VALUE);let r=Object.keys(e),i=r.length;for(;i-- >0;){let a=r[i],o=Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0;if(o){let t=e[a],n=t===void 0||o(t,a,e);if(n!==!0)throw new G(`option `+a+` must be `+n,G.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new G(`Unknown option `+a,G.ERR_BAD_OPTION)}}var pl={assertOptions:fl,validators:ul};const ml=pl.validators;var hl=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Rs,response:new Rs}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=Error();let n=(()=>{if(!t.stack)return``;let e=t.stack.indexOf(`
|
|
129
|
+
`);return e===-1?``:t.stack.slice(e+1)})();try{if(!e.stack)e.stack=n;else if(n){let t=n.indexOf(`
|
|
130
|
+
`),r=t===-1?-1:n.indexOf(`
|
|
131
|
+
`,t+1),i=r===-1?``:n.slice(r+1);String(e.stack).endsWith(i)||(e.stack+=`
|
|
132
|
+
`+n)}}catch{}}throw e}}_request(e,t){typeof e==`string`?(t||={},t.url=e):t=e||{},t=Ec(this.defaults,t);let{transitional:n,paramsSerializer:r,headers:i}=t;n!==void 0&&pl.assertOptions(n,{silentJSONParsing:ml.transitional(ml.boolean),forcedJSONParsing:ml.transitional(ml.boolean),clarifyTimeoutError:ml.transitional(ml.boolean),legacyInterceptorReqResOrdering:ml.transitional(ml.boolean),advertiseZstdAcceptEncoding:ml.transitional(ml.boolean),validateStatusUndefinedResolves:ml.transitional(ml.boolean)},!1),r!=null&&(W.isFunction(r)?t.paramsSerializer={serialize:r}:pl.assertOptions(r,{encode:ml.function,serialize:ml.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls===void 0?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),pl.assertOptions(t,{baseUrl:ml.spelling(`baseURL`),withXsrfToken:ml.spelling(`withXSRFToken`)},!0),t.method=(t.method||this.defaults.method||`get`).toLowerCase();let a=i&&W.merge(i.common,i[t.method]);i&&W.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`query`,`common`],e=>{delete i[e]}),t.headers=xs.concat(a,i);let o=[],s=!0;this.interceptors.request.forEach(function(e){if(typeof e.runWhen==`function`&&e.runWhen(t)===!1)return;s&&=e.synchronous;let n=t.transitional||zs;n&&n.legacyInterceptorReqResOrdering?o.unshift(e.fulfilled,e.rejected):o.push(e.fulfilled,e.rejected)});let c=[];this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,u=0,d;if(!s){let e=[ll.bind(this),void 0];for(e.unshift(...o),e.push(...c),d=e.length,l=Promise.resolve(t);u<d;)l=l.then(e[u++],e[u++]);return l}d=o.length;let f=t;for(;u<d;){let e=o[u++],t=o[u++];try{f=e?e(f):f}catch(e){if(!t){l=Promise.reject(e);break}try{let n=t.call(this,e);W.isThenable(n)&&(l=Promise.resolve(n).then(()=>ll.call(this,f)))}catch(e){l=Promise.reject(e)}break}}if(!l)try{l=ll.call(this,f)}catch(e){l=Promise.reject(e)}for(u=0,d=c.length;u<d;)l=l.then(c[u++],c[u++]);return l}getUri(e){return e=Ec(this.defaults,e),Ls(Cc(e.baseURL,e.url,e.allowAbsoluteUrls,e),e.params,e.paramsSerializer)}};W.forEach([`delete`,`get`,`head`,`options`],function(e){hl.prototype[e]=function(t,n){return this.request(Ec(n||{},{method:e,url:t,data:n&&W.hasOwnProp(n,`data`)?n.data:void 0}))}}),W.forEach([`post`,`put`,`patch`,`query`],function(e){function t(t){return function(n,r,i){return this.request(Ec(i||{},{method:e,headers:t?{"Content-Type":`multipart/form-data`}:{},url:n,data:r}))}}hl.prototype[e]=t(),e!==`query`&&(hl.prototype[e+`Form`]=t(!0))});var gl=class e{constructor(e){if(typeof e!=`function`)throw TypeError(`executor must be a function.`);let t;this.promise=new Promise(function(e){t=e});let n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t,r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new ic(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}};function _l(e){return function(t){return e.apply(null,t)}}function vl(e){return W.isObject(e)&&e.isAxiosError===!0}const yl={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerReturnsAnUnknownError:520,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(yl).forEach(([e,t])=>{yl[t]=e});function bl(e){let t=new hl(e),n=Ia(hl.prototype.request,t);return W.extend(n,hl.prototype,t,{allOwnKeys:!0}),W.extend(n,t,null,{allOwnKeys:!0}),n.create=function(t){return bl(Ec(e,t))},n}const xl=bl(tc);xl.Axios=hl,xl.CanceledError=ic,xl.CancelToken=gl,xl.isCancel=rc,xl.VERSION=qc,xl.toFormData=Ms,xl.AxiosError=G,xl.Cancel=xl.CanceledError,xl.all=function(e){return Promise.all(e)},xl.spread=_l,xl.isAxiosError=vl,xl.mergeConfig=Ec,xl.AxiosHeaders=xs,xl.formToJSON=e=>Qs(W.isHTMLForm(e)?new FormData(e):e),xl.getAdapter=sl.getAdapter,xl.HttpStatusCode=yl,xl.default=xl;let Sl=new class{axiosInstance;constructor(){this.axiosInstance=xl.create()}async get(e,t){return(await this.axiosInstance.get(e,t)).data}async post(e,t,n){return(await this.axiosInstance.post(e,t,n)).data}async put(e,t,n){return(await this.axiosInstance.put(e,t,n)).data}async patch(e,t,n){return(await this.axiosInstance.patch(e,t,n)).data}async delete(e,t){return(await this.axiosInstance.delete(e,t)).data}};const Cl={setHttpClient:e=>{Sl=e},get:(e,t)=>Sl.get(e,t),post:(e,t,n)=>Sl.post(e,t,n),put:(e,t,n)=>Sl.put(e,t,n),patch:(e,t,n)=>Sl.patch(e,t,n),delete:(e,t)=>Sl.delete(e,t)};let wl=function(e){return e.Wallet=`wallet`,e.Pay=`pay`,e.Dashboard=`dashboard`,e.Bridge=`bridge`,e}({}),Tl=function(e){return e.Mainnet=`Mainnet`,e.Testnet=`Testnet`,e.Local=`Local`,e}({});var El={hinkalAddress:`0x7cb60446d7635C68EDf1c568cac74A1f98c1Cfa4`,hinkalHelperAddress:`0x74F3D85bf47E354BDede5759522f278eD48C48fD`,hinkalWrapperAddress:`0x2AE2C150c7CFE6662d13Ba9d8f8C1E9b271fEEc1`,emporiumAddress:`0x3f868DA5A511C36473A8B4e0851b1aA36d9a19D0`,hinkalWalletAddress:`0x4a2b15BCAb735c097758cc41522BbCd41897175A`,lifiExternalActionInstanceAddress:`0x8e151d0Cc6400038c932C00c382ba3814A5a1F96`},Dl={hinkalAddress:`0x7cb60446d7635C68EDf1c568cac74A1f98c1Cfa4`,hinkalHelperAddress:`0x2B02B49878A23b90F7a823994626eCdcc11fef6C`,hinkalWrapperAddress:`0x0fAb8C78cC588D2dc2B96971685747FC980c08fb`,emporiumAddress:`0x0AEcD18E04FB5263155476059fDcAA41a8efF0F9`,hinkalWalletAddress:`0xb34e79F356aBd059DF1B1ef0A136Db65f6659e49`,lifiExternalActionInstanceAddress:`0xb032AACD69641a71c052e58d29dE6900A32dfAec`},Ol={hinkalAddress:`0x7cb60446d7635C68EDf1c568cac74A1f98c1Cfa4`,hinkalHelperAddress:`0x62Af1392aF5376c76d4437598C3E925E66fB03F5`,hinkalWrapperAddress:`0x6998fE93f3a3AbDb31df1922EB91BC282F42aa1d`,emporiumAddress:`0x795884e56c58D4fF1B26Eb1494F39FcfB38917a1`,hinkalWalletAddress:`0xB24043ebDC72ddC1923ec749cFBDFbEfF3FC82f6`,lifiExternalActionInstanceAddress:`0x834528321Ffa675a865d260776f09f21BB7D64C6`},kl={hinkalAddress:`0xfc6f822A982F987AfC1DE65d0b9BAaC68888024a`,hinkalHelperAddress:`0x91a065E81e28dBf62FCBD7020D2bFaC07FB0b47d`,hinkalWrapperAddress:`0x4EEC778F7aA8cfEE40aB438D3B847DF59D0621BE`,emporiumAddress:`0xD7eF077523B61C9704Bf3361A39b0eEfd3Ea2d56`,hinkalWalletAddress:`0xd1D8D4Eec685DF5A9595E7A9Ec8073945CCDC57a`,lifiExternalActionInstanceAddress:`0x6A58F4e36C885fA1e3EA4Eb0B5BE81f7a06c6457`},Al={hinkalAddress:`0x5395d371491b87F656280Ca29b584185Bdc83580`,hinkalHelperAddress:`0xb66469a26C737aCA04128AfEb2AA9be2034f5E76`,hinkalWrapperAddress:`0x4360b2416c77e3a02a0d28Bc1Eed341CB6885f73`,emporiumAddress:`0x9B234163a3b6d315d402e48262Fb411316d7a1F7`,hinkalWalletAddress:`0xFd40a90A71Af2ad674AC38a605c3A8e87582fdC9`},jl={hinkalAddress:`0x7cb60446d7635C68EDf1c568cac74A1f98c1Cfa4`,hinkalHelperAddress:`0x4C877A7d7CED0181d70c6c3C759981F3ea51f5f6`,hinkalWrapperAddress:`0xeA179De69AcFcDD1Da5437E70339450bB96Ea5FE`,emporiumAddress:`0x658a7a12A45f59F9c2bB7a5d5A3bb733d9155d24`,hinkalWalletAddress:`0x95Da9777f9fb8d8500592E351676Aa9B560E5956`,lifiExternalActionInstanceAddress:`0xE96E04Cb3C1601dc170eb3374d3B9088019A41A4`},Ml={hinkalAddress:`0x7cb60446d7635C68EDf1c568cac74A1f98c1Cfa4`,hinkalHelperAddress:`0xf629A958edB2bEb2F32DDC3DFDef80364FEe49a9`,hinkalWrapperAddress:`0xEa1765Cc8d3aEB2A3bf5365a7Fa8451597CA9153`,emporiumAddress:`0xf66D101962E20cb49c4934F9fbb43eb7ef75F4cC`,hinkalWalletAddress:`0x2Be66fdF3F0F1A93dce0450074ecb77c44CdC42B`,lifiExternalActionInstanceAddress:`0x4e384B3e7Ae050580F148Dedfa80C2cb4Ac01217`},Nl={hinkalAddress:`0x13b65FA5375af51A12762499602bE7B92afB8CD6`,hinkalHelperAddress:`0x6D5DFa6Ec97bF1Da5396033F305dFA8575c1f5a7`,emporiumAddress:`0x23A64eF68de98C6Cf01e3A5202d47a3bcee6f920`,hinkalWalletFactoryAddress:`0xD0b3FF7e99dcD6058362c7B0894DBB34723D1bfA`,hinkalWalletBeaconAddress:`0x85f525996478fe87e265dfdb99e6C3ebE2D6E876`},Pl={hinkalAddress:`0x7cb60446d7635C68EDf1c568cac74A1f98c1Cfa4`,hinkalHelperAddress:`0x9F8C8D60d5093523c702FFBc7035DCb9537271dC`,hinkalWrapperAddress:`0xC39A087096430Dd12d288227d7dA749D8Db8c669`,emporiumAddress:`0x70F48817aaE2Bb9dD042D4Ea46ECfe1C168ed3e0`,hinkalWalletAddress:`0x987F7979617361e002E91071978be99D10abeB80`,lifiExternalActionInstanceAddress:`0x93113974Dd1A8F5C1a7974C9d5E753b0bD0b9261`},Fl={hinkalAddress:`0x1858c7E127877430EbEc27D112F319C7091add33`,hinkalHelperAddress:`0x83927CF3049DEA065dB50e6B08aA5A136b70C95b`,depositOnChainUtxosExternalActionAddress:`0xFA3164c6beA5c21d86E14348854d51B08032da2A`,hinkalWrapperAddress:`0x74aFF37065ae1044158A3535248402Ff8FcF90e9`},Il={hinkalAddress:`8LLNFE62Lr9rJLvmPsTsFttrcmwYrEykZwvpyYDW4Nc2`,originalDeployer:`8xzyYDbvfpqYEGekNsm6KDyNXJybTLJhBWBQwabsZN49`},Ll={hinkalAddress:`0x9046b44155bbf6aa991e86cc30451c4c1c73eb74`,hinkalHelperAddress:`0x4ca5f085914836d11f591769e71a018128759d92`},Rl={hinkalAddress:`0x2bf3af0ffb6f0b8cdc649d11c91953f700733b17`,hinkalHelperAddress:`0xef3b0c95e5a235ac8d5d4545eee02cf41b572459`},zl={hinkalAddress:`0x7cb60446d7635C68EDf1c568cac74A1f98c1Cfa4`,hinkalHelperAddress:`0x4d1D5E41ae21E30444F277750518c8a8b942A893`,hinkalWrapperAddress:`0x0B790C436B7A277f24A7f43D74c44db1a56f2A36`,emporiumAddress:`0x94bF69507085a33028Aa111046B85cA1b6846aA3`,hinkalWalletAddress:`0xd05B85a7C2fA4d99C48145eF25e87C2a68826B70`,lifiExternalActionInstanceAddress:`0x4031137A209130b4cf0D161D0BFC1c39049d49B3`};function Bl(e,t,n){let r=t.split(`|`).map(e=>e.trim());for(let n=0;n<r.length;n++)switch(t){case`any`:return;case`bigint`:case`boolean`:case`number`:case`string`:if(typeof e===t)return}let i=Error(`invalid value for type ${t}`);throw i.code=`INVALID_ARGUMENT`,i.argument=`value.${n}`,i.value=e,i}function K(e,t,n){for(let r in t){let i=t[r],a=n?n[r]:null;a&&Bl(i,a,r),Object.defineProperty(e,r,{enumerable:!0,value:i,writable:!1})}}function Vl(e,t){if(e==null)return`null`;if(t??=new Set,typeof e==`object`){if(t.has(e))return`[Circular]`;t.add(e)}if(Array.isArray(e))return`[ `+e.map(e=>Vl(e,t)).join(`, `)+` ]`;if(e instanceof Uint8Array){let t=`0123456789abcdef`,n=`0x`;for(let r=0;r<e.length;r++)n+=t[e[r]>>4],n+=t[e[r]&15];return n}if(typeof e==`object`&&typeof e.toJSON==`function`)return Vl(e.toJSON(),t);switch(typeof e){case`boolean`:case`number`:case`symbol`:return e.toString();case`bigint`:return BigInt(e).toString();case`string`:return JSON.stringify(e);case`object`:{let n=Object.keys(e);return n.sort(),`{ `+n.map(n=>`${Vl(n,t)}: ${Vl(e[n],t)}`).join(`, `)+` }`}}return`[ COULD NOT SERIALIZE ]`}function Hl(e,t){return e&&e.code===t}function Ul(e,t,n){let r=e;{let r=[];if(n){if(`message`in n||`code`in n||`name`in n)throw Error(`value will overwrite populated values: ${Vl(n)}`);for(let e in n){if(e===`shortMessage`)continue;let t=n[e];r.push(e+`=`+Vl(t))}}r.push(`code=${t}`),r.push(`version=6.17.0`),r.length&&(e+=` (`+r.join(`, `)+`)`)}let i;switch(t){case`INVALID_ARGUMENT`:i=TypeError(e);break;case`NUMERIC_FAULT`:case`BUFFER_OVERRUN`:i=RangeError(e);break;default:i=Error(e)}return K(i,{code:t}),n&&Object.assign(i,n),i.shortMessage??K(i,{shortMessage:r}),i}function q(e,t,n,r){if(!e)throw Ul(t,n,r)}function J(e,t,n,r){q(e,t,`INVALID_ARGUMENT`,{argument:n,value:r})}function Wl(e,t,n){n??=``,n&&=`: `+n,q(e>=t,`missing argument`+n,`MISSING_ARGUMENT`,{count:e,expectedCount:t}),q(e<=t,`too many arguments`+n,`UNEXPECTED_ARGUMENT`,{count:e,expectedCount:t})}const Gl=[`NFD`,`NFC`,`NFKD`,`NFKC`].reduce((e,t)=>{try{if(`test`.normalize(t)!==`test`)throw Error(`bad`);if(t===`NFD`&&`é`.normalize(`NFD`)!==`é`)throw Error(`broken`);e.push(t)}catch{}return e},[]);function Kl(e){q(Gl.indexOf(e)>=0,`platform missing String.prototype.normalize`,`UNSUPPORTED_OPERATION`,{operation:`String.prototype.normalize`,info:{form:e}})}function ql(e,t,n){if(n??=``,e!==t){let e=n,t=`new`;n&&(e+=`.`,t+=` `+n),q(!1,`private constructor; use ${e}from* methods`,`UNSUPPORTED_OPERATION`,{operation:t})}}function Jl(e,t,n){if(e instanceof Uint8Array)return n?new Uint8Array(e):e;if(typeof e==`string`&&e.length%2==0&&e.match(/^0x[0-9a-f]*$/i)){let t=new Uint8Array((e.length-2)/2),n=2;for(let r=0;r<t.length;r++)t[r]=parseInt(e.substring(n,n+2),16),n+=2;return t}J(!1,`invalid BytesLike value`,t||`value`,e)}function Yl(e,t){return Jl(e,t,!1)}function Xl(e,t){return Jl(e,t,!0)}function Zl(e,t){return!(typeof e!=`string`||!e.match(/^0x[0-9A-Fa-f]*$/)||typeof t==`number`&&e.length!==2+2*t||t===!0&&e.length%2!=0)}const Ql=`0123456789abcdef`;function $l(e){let t=Yl(e),n=`0x`;for(let e=0;e<t.length;e++){let r=t[e];n+=Ql[(r&240)>>4]+Ql[r&15]}return n}function eu(e){return`0x`+e.map(e=>$l(e).substring(2)).join(``)}function tu(e,t,n){let r=Yl(e);return n!=null&&n>r.length&&q(!1,`cannot slice beyond data bounds`,`BUFFER_OVERRUN`,{buffer:r,length:r.length,offset:n}),$l(r.slice(t??0,n??r.length))}function nu(e,t,n){let r=Yl(e);q(t>=r.length,`padding exceeds data length`,`BUFFER_OVERRUN`,{buffer:new Uint8Array(r),length:t,offset:t+1});let i=new Uint8Array(t);return i.fill(0),n?i.set(r,t-r.length):i.set(r,0),$l(i)}function ru(e,t){return nu(e,t,!0)}function iu(e,t){return nu(e,t,!1)}const au=BigInt(0),ou=BigInt(1),su=9007199254740991;function cu(e,t){let n=fu(e,`value`),r=BigInt(hu(t,`width`));if(q(n>>r===au,`overflow`,`NUMERIC_FAULT`,{operation:`fromTwos`,fault:`overflow`,value:e}),n>>r-ou){let e=(ou<<r)-ou;return-((~n&e)+ou)}return n}function lu(e,t){let n=du(e,`value`),r=BigInt(hu(t,`width`)),i=ou<<r-ou;if(n<au){n=-n,q(n<=i,`too low`,`NUMERIC_FAULT`,{operation:`toTwos`,fault:`overflow`,value:e});let t=(ou<<r)-ou;return(~n&t)+ou}else q(n<i,`too high`,`NUMERIC_FAULT`,{operation:`toTwos`,fault:`overflow`,value:e});return n}function uu(e,t){return fu(e,`value`)&(ou<<BigInt(hu(t,`bits`)))-ou}function du(e,t){switch(typeof e){case`bigint`:return e;case`number`:return J(Number.isInteger(e),`underflow`,t||`value`,e),J(e>=-su&&e<=su,`overflow`,t||`value`,e),BigInt(e);case`string`:try{if(e===``)throw Error(`empty string`);return e[0]===`-`&&e[1]!==`-`?-BigInt(e.substring(1)):BigInt(e)}catch(n){J(!1,`invalid BigNumberish string: ${n.message}`,t||`value`,e)}}J(!1,`invalid BigNumberish value`,t||`value`,e)}function fu(e,t){let n=du(e,t);return q(n>=au,`unsigned value cannot be negative`,`NUMERIC_FAULT`,{fault:`overflow`,operation:`getUint`,value:e}),n}const pu=`0123456789abcdef`;function mu(e){if(e instanceof Uint8Array){let t=`0x0`;for(let n of e)t+=pu[n>>4],t+=pu[n&15];return BigInt(t)}return du(e)}function hu(e,t){switch(typeof e){case`bigint`:return J(e>=-su&&e<=su,`overflow`,t||`value`,e),Number(e);case`number`:return J(Number.isInteger(e),`underflow`,t||`value`,e),J(e>=-su&&e<=su,`overflow`,t||`value`,e),e;case`string`:try{if(e===``)throw Error(`empty string`);return hu(BigInt(e),t)}catch(n){J(!1,`invalid numeric string: ${n.message}`,t||`value`,e)}}J(!1,`invalid numeric value`,t||`value`,e)}function gu(e){return hu(mu(e))}function _u(e,t){let n=fu(e,`value`),r=n.toString(16);if(t==null)r.length%2&&(r=`0`+r);else{let i=hu(t,`width`);if(i===0&&n===au)return`0x`;for(q(i*2>=r.length,`value exceeds width (${i} bytes)`,`NUMERIC_FAULT`,{operation:`toBeHex`,fault:`overflow`,value:e});r.length<i*2;)r=`0`+r}return`0x`+r}function vu(e,t){let n=fu(e,`value`);if(n===au){let e=t==null?0:hu(t,`width`);return new Uint8Array(e)}let r=n.toString(16);if(r.length%2&&(r=`0`+r),t!=null){let n=hu(t,`width`);for(;r.length<n*2;)r=`00`+r;q(n*2===r.length,`value exceeds width (${n} bytes)`,`NUMERIC_FAULT`,{operation:`toBeArray`,fault:`overflow`,value:e})}let i=new Uint8Array(r.length/2);for(let e=0;e<i.length;e++){let t=e*2;i[e]=parseInt(r.substring(t,t+2),16)}return i}function yu(e,t,n,r,i){J(!1,`invalid codepoint at offset ${t}; ${e}`,`bytes`,n)}function bu(e,t,n,r,i){if(e===`BAD_PREFIX`||e===`UNEXPECTED_CONTINUE`){let e=0;for(let r=t+1;r<n.length&&n[r]>>6==2;r++)e++;return e}return e===`OVERRUN`?n.length-t-1:0}function xu(e,t,n,r,i){return e===`OVERLONG`?(J(typeof i==`number`,`invalid bad code point for replacement`,`badCodepoint`,i),r.push(i),0):(r.push(65533),bu(e,t,n,r,i))}const Su=Object.freeze({error:yu,ignore:bu,replace:xu});function Cu(e,t){t??=Su.error;let n=Yl(e,`bytes`),r=[],i=0;for(;i<n.length;){let e=n[i++];if(!(e>>7)){r.push(e);continue}let a=null,o=null;if((e&224)==192)a=1,o=127;else if((e&240)==224)a=2,o=2047;else if((e&248)==240)a=3,o=65535;else{(e&192)==128?i+=t(`UNEXPECTED_CONTINUE`,i-1,n,r):i+=t(`BAD_PREFIX`,i-1,n,r);continue}if(i-1+a>=n.length){i+=t(`OVERRUN`,i-1,n,r);continue}let s=e&(1<<8-a-1)-1;for(let e=0;e<a;e++){let e=n[i];if((e&192)!=128){i+=t(`MISSING_CONTINUE`,i,n,r),s=null;break}s=s<<6|e&63,i++}if(s!==null){if(s>1114111){i+=t(`OUT_OF_RANGE`,i-1-a,n,r,s);continue}if(s>=55296&&s<=57343){i+=t(`UTF16_SURROGATE`,i-1-a,n,r,s);continue}if(s<=o){i+=t(`OVERLONG`,i-1-a,n,r,s);continue}r.push(s)}}return r}function wu(e,t){J(typeof e==`string`,`invalid string value`,`str`,e),t!=null&&(Kl(t),e=e.normalize(t));let n=[];for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);if(r<128)n.push(r);else if(r<2048)n.push(r>>6|192),n.push(r&63|128);else if((r&64512)==55296){t++;let i=e.charCodeAt(t);J(t<e.length&&(i&64512)==56320,`invalid surrogate pair`,`str`,e);let a=65536+((r&1023)<<10)+(i&1023);n.push(a>>18|240),n.push(a>>12&63|128),n.push(a>>6&63|128),n.push(a&63|128)}else n.push(r>>12|224),n.push(r>>6&63|128),n.push(r&63|128)}return new Uint8Array(n)}function Tu(e){return e.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join(``)}function Eu(e,t){return Tu(Cu(e,t))}const Du=new Uint8Array(32),Ou=[`then`],ku={},Au=new WeakMap;function ju(e){return Au.get(e)}function Mu(e,t){Au.set(e,t)}function Nu(e,t){let n=Error(`deferred error during ABI decoding triggered accessing ${e}`);throw n.error=t,n}function Pu(e,t,n){return e.indexOf(null)>=0?t.map((e,t)=>e instanceof Fu?Pu(ju(e),e,n):e):e.reduce((e,r,i)=>{let a=t.getValue(r);return r in e||(n&&a instanceof Fu&&(a=Pu(ju(a),a,n)),e[r]=a),e},{})}var Fu=class e extends Array{#e;constructor(...e){let t=e[0],n=e[1],r=(e[2]||[]).slice(),i=!0;t!==ku&&(n=e,r=[],i=!1),super(n.length),n.forEach((e,t)=>{this[t]=e});let a=r.reduce((e,t)=>(typeof t==`string`&&e.set(t,(e.get(t)||0)+1),e),new Map);if(Mu(this,Object.freeze(n.map((e,t)=>{let n=r[t];return n!=null&&a.get(n)===1?n:null}))),this.#e=[],this.#e??this.#e,!i)return;Object.freeze(this);let o=new Proxy(this,{get:(e,t,n)=>{if(typeof t==`string`){if(t.match(/^[0-9]+$/)){let n=hu(t,`%index`);if(n<0||n>=this.length)throw RangeError(`out of result range`);let r=e[n];return r instanceof Error&&Nu(`index ${n}`,r),r}if(Ou.indexOf(t)>=0)return Reflect.get(e,t,n);let r=e[t];if(r instanceof Function)return function(...t){return r.apply(this===n?e:this,t)};if(!(t in e))return e.getValue.apply(this===n?e:this,[t])}return Reflect.get(e,t,n)}});return Mu(o,ju(this)),o}toArray(t){let n=[];return this.forEach((r,i)=>{r instanceof Error&&Nu(`index ${i}`,r),t&&r instanceof e&&(r=r.toArray(t)),n.push(r)}),n}toObject(e){let t=ju(this);return t.reduce((n,r,i)=>(q(r!=null,`value at index ${i} unnamed`,`UNSUPPORTED_OPERATION`,{operation:`toObject()`}),Pu(t,this,e)),{})}slice(t,n){t??=0,t<0&&(t+=this.length,t<0&&(t=0)),n??=this.length,n<0&&(n+=this.length,n<0&&(n=0)),n>this.length&&(n=this.length);let r=ju(this),i=[],a=[];for(let e=t;e<n;e++)i.push(this[e]),a.push(r[e]);return new e(ku,i,a)}filter(t,n){let r=ju(this),i=[],a=[];for(let e=0;e<this.length;e++){let o=this[e];o instanceof Error&&Nu(`index ${e}`,o),t.call(n,o,e,this)&&(i.push(o),a.push(r[e]))}return new e(ku,i,a)}map(e,t){let n=[];for(let r=0;r<this.length;r++){let i=this[r];i instanceof Error&&Nu(`index ${r}`,i),n.push(e.call(t,i,r,this))}return n}getValue(e){let t=ju(this).indexOf(e);if(t===-1)return;let n=this[t];return n instanceof Error&&Nu(`property ${JSON.stringify(e)}`,n.error),n}static fromItems(t,n){return new e(ku,t,n)}};function Iu(e){let t=vu(e);return q(t.length<=32,`value out-of-bounds`,`BUFFER_OVERRUN`,{buffer:t,length:32,offset:t.length}),t.length!==32&&(t=Xl(eu([Du.slice(t.length%32),t]))),t}var Lu=class{name;type;localName;dynamic;constructor(e,t,n,r){K(this,{name:e,type:t,localName:n,dynamic:r},{name:`string`,type:`string`,localName:`string`,dynamic:`boolean`})}_throwError(e,t){J(!1,e,this.localName,t)}},Ru=class{#e;#t;constructor(){this.#e=[],this.#t=0}get data(){return eu(this.#e)}get length(){return this.#t}#n(e){return this.#e.push(e),this.#t+=e.length,e.length}appendWriter(e){return this.#n(Xl(e.data))}writeBytes(e){let t=Xl(e),n=t.length%32;return n&&(t=Xl(eu([t,Du.slice(n)]))),this.#n(t)}writeValue(e){return this.#n(Iu(e))}writeUpdatableValue(){let e=this.#e.length;return this.#e.push(Du),this.#t+=32,t=>{this.#e[e]=Iu(t)}}},zu=class e{allowLoose;#e;#t;#n;#r;#i;constructor(e,t,n){K(this,{allowLoose:!!t}),this.#e=Xl(e),this.#n=0,this.#r=null,this.#i=n??1024,this.#t=0}get data(){return $l(this.#e)}get dataLength(){return this.#e.length}get consumed(){return this.#t}get bytes(){return new Uint8Array(this.#e)}#a(e){if(this.#r)return this.#r.#a(e);this.#n+=e,q(this.#i<1||this.#n<=this.#i*this.dataLength,`compressed ABI data exceeds inflation ratio of ${this.#i} ( see: https:/\/github.com/ethers-io/ethers.js/issues/4537 )`,`BUFFER_OVERRUN`,{buffer:Xl(this.#e),offset:this.#t,length:e,info:{bytesRead:this.#n,dataLength:this.dataLength}})}#o(e,t,n){let r=Math.ceil(t/32)*32;return this.#t+r>this.#e.length&&(this.allowLoose&&n&&this.#t+t<=this.#e.length?r=t:q(!1,`data out-of-bounds`,`BUFFER_OVERRUN`,{buffer:Xl(this.#e),length:this.#e.length,offset:this.#t+r})),this.#e.slice(this.#t,this.#t+r)}subReader(t){let n=new e(this.#e.slice(this.#t+t),this.allowLoose,this.#i);return n.#r=this,n}readBytes(e,t){let n=this.#o(0,e,!!t);return this.#a(e),this.#t+=n.length,n.slice(0,e)}readValue(){return mu(this.readBytes(32))}readIndex(){return gu(this.readBytes(32))}};function Bu(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`Wrong positive integer: ${e}`)}function Vu(e,...t){if(!(e instanceof Uint8Array))throw Error(`Expected Uint8Array`);if(t.length>0&&!t.includes(e.length))throw Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Hu(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function Uu(e,t){Vu(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least ${n}`)}const Wu=e=>e instanceof Uint8Array,Gu=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(new Uint8Array(new Uint32Array([287454020]).buffer)[0]!==68)throw Error(`Non little-endian hardware is not supported`);function Ku(e){if(typeof e!=`string`)throw Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function qu(e){if(typeof e==`string`&&(e=Ku(e)),!Wu(e))throw Error(`expected Uint8Array, got ${typeof e}`);return e}var Ju=class{clone(){return this._cloneInto()}};({}).toString;function Yu(e){let t=t=>e().update(qu(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const Xu=BigInt(2**32-1),Zu=BigInt(32);function Qu(e,t=!1){return t?{h:Number(e&Xu),l:Number(e>>Zu&Xu)}:{h:Number(e>>Zu&Xu)|0,l:Number(e&Xu)|0}}function $u(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){let{h:a,l:o}=Qu(e[i],t);[n[i],r[i]]=[a,o]}return[n,r]}const ed=(e,t,n)=>e<<n|t>>>32-n,td=(e,t,n)=>t<<n|e>>>32-n,nd=(e,t,n)=>t<<n-32|e>>>64-n,rd=(e,t,n)=>e<<n-32|t>>>64-n,[id,ad,od]=[[],[],[]],sd=BigInt(0),cd=BigInt(1),ld=BigInt(2),ud=BigInt(7),dd=BigInt(256),fd=BigInt(113);for(let e=0,t=cd,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],id.push(2*(5*r+n)),ad.push((e+1)*(e+2)/2%64);let i=sd;for(let e=0;e<7;e++)t=(t<<cd^(t>>ud)*fd)%dd,t&ld&&(i^=cd<<(cd<<BigInt(e))-cd);od.push(i)}const[pd,md]=$u(od,!0),hd=(e,t,n)=>n>32?nd(e,t,n):ed(e,t,n),gd=(e,t,n)=>n>32?rd(e,t,n):td(e,t,n);function _d(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=hd(a,o,1)^n[r],c=gd(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=ad[n],a=hd(t,i,r),o=gd(t,i,r),s=id[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=pd[r],e[1]^=md[r]}n.fill(0)}var vd=class e extends Ju{constructor(e,t,n,r=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Bu(n),0>=this.blockLen||this.blockLen>=200)throw Error(`Sha3 supports only keccak-f1600 function`);this.state=new Uint8Array(200),this.state32=Gu(this.state)}keccak(){_d(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Hu(this);let{blockLen:t,state:n}=this;e=qu(e);let r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Hu(this,!1),Vu(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return Bu(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Uu(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}};const yd=((e,t,n)=>Yu(()=>new vd(t,e,n)))(1,136,256/8);let bd=!1;const xd=function(e){return yd(e)};let Sd=xd;function Cd(e){let t=Yl(e,`data`);return $l(Sd(t))}Cd._=xd,Cd.lock=function(){bd=!0},Cd.register=function(e){if(bd)throw TypeError(`keccak256 is locked`);Sd=e},Object.freeze(Cd);const wd=BigInt(0),Td=BigInt(36);function Ed(e){e=e.toLowerCase();let t=e.substring(2).split(``),n=new Uint8Array(40);for(let e=0;e<40;e++)n[e]=t[e].charCodeAt(0);let r=Yl(Cd(n));for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&(t[e]=t[e].toUpperCase()),(r[e>>1]&15)>=8&&(t[e+1]=t[e+1].toUpperCase());return`0x`+t.join(``)}const Dd={};for(let e=0;e<10;e++)Dd[String(e)]=String(e);for(let e=0;e<26;e++)Dd[String.fromCharCode(65+e)]=String(10+e);function Od(e){e=e.toUpperCase(),e=e.substring(4)+e.substring(0,2)+`00`;let t=e.split(``).map(e=>Dd[e]).join(``);for(;t.length>=15;){let e=t.substring(0,15);t=parseInt(e,10)%97+t.substring(e.length)}let n=String(98-parseInt(t,10)%97);for(;n.length<2;)n=`0`+n;return n}const kd=(function(){let e={};for(let t=0;t<36;t++){let n=`0123456789abcdefghijklmnopqrstuvwxyz`[t];e[n]=BigInt(t)}return e})();function Ad(e){e=e.toLowerCase();let t=wd;for(let n=0;n<e.length;n++)t=t*Td+kd[e[n]];return t}function jd(e){if(J(typeof e==`string`,`invalid address`,`address`,e),e.match(/^(0x)?[0-9a-fA-F]{40}$/)){e.startsWith(`0x`)||(e=`0x`+e);let t=Ed(e);return J(!e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||t===e,`bad address checksum`,`address`,e),t}if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){J(e.substring(2,4)===Od(e),`bad icap checksum`,`address`,e);let t=Ad(e.substring(4)).toString(16);for(;t.length<40;)t=`0`+t;return Ed(`0x`+t)}J(!1,`invalid address`,`address`,e)}const Md={};function Y(e,t){let n=!1;return t<0&&(n=!0,t*=-1),new Pd(Md,`${n?``:`u`}int${t}`,e,{signed:n,width:t})}function X(e,t){return new Pd(Md,`bytes${t||``}`,e,{size:t})}const Nd=Symbol.for(`_ethers_typed`);var Pd=class e{type;value;#e;_typedSymbol;constructor(e,t,n,r){r??=null,ql(Md,e,`Typed`),K(this,{_typedSymbol:Nd,type:t,value:n}),this.#e=r,this.format()}format(){if(this.type===`array`||this.type===`dynamicArray`)throw Error(``);return this.type===`tuple`?`tuple(${this.value.map(e=>e.format()).join(`,`)})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith(`bytes`)}isString(){return this.type===`string`}get tupleName(){if(this.type!==`tuple`)throw TypeError(`not a tuple`);return this.#e}get arrayLength(){if(this.type!==`array`)throw TypeError(`not an array`);return this.#e===!0?-1:this.#e===!1?this.value.length:null}static from(t,n){return new e(Md,t,n)}static uint8(e){return Y(e,8)}static uint16(e){return Y(e,16)}static uint24(e){return Y(e,24)}static uint32(e){return Y(e,32)}static uint40(e){return Y(e,40)}static uint48(e){return Y(e,48)}static uint56(e){return Y(e,56)}static uint64(e){return Y(e,64)}static uint72(e){return Y(e,72)}static uint80(e){return Y(e,80)}static uint88(e){return Y(e,88)}static uint96(e){return Y(e,96)}static uint104(e){return Y(e,104)}static uint112(e){return Y(e,112)}static uint120(e){return Y(e,120)}static uint128(e){return Y(e,128)}static uint136(e){return Y(e,136)}static uint144(e){return Y(e,144)}static uint152(e){return Y(e,152)}static uint160(e){return Y(e,160)}static uint168(e){return Y(e,168)}static uint176(e){return Y(e,176)}static uint184(e){return Y(e,184)}static uint192(e){return Y(e,192)}static uint200(e){return Y(e,200)}static uint208(e){return Y(e,208)}static uint216(e){return Y(e,216)}static uint224(e){return Y(e,224)}static uint232(e){return Y(e,232)}static uint240(e){return Y(e,240)}static uint248(e){return Y(e,248)}static uint256(e){return Y(e,256)}static uint(e){return Y(e,256)}static int8(e){return Y(e,-8)}static int16(e){return Y(e,-16)}static int24(e){return Y(e,-24)}static int32(e){return Y(e,-32)}static int40(e){return Y(e,-40)}static int48(e){return Y(e,-48)}static int56(e){return Y(e,-56)}static int64(e){return Y(e,-64)}static int72(e){return Y(e,-72)}static int80(e){return Y(e,-80)}static int88(e){return Y(e,-88)}static int96(e){return Y(e,-96)}static int104(e){return Y(e,-104)}static int112(e){return Y(e,-112)}static int120(e){return Y(e,-120)}static int128(e){return Y(e,-128)}static int136(e){return Y(e,-136)}static int144(e){return Y(e,-144)}static int152(e){return Y(e,-152)}static int160(e){return Y(e,-160)}static int168(e){return Y(e,-168)}static int176(e){return Y(e,-176)}static int184(e){return Y(e,-184)}static int192(e){return Y(e,-192)}static int200(e){return Y(e,-200)}static int208(e){return Y(e,-208)}static int216(e){return Y(e,-216)}static int224(e){return Y(e,-224)}static int232(e){return Y(e,-232)}static int240(e){return Y(e,-240)}static int248(e){return Y(e,-248)}static int256(e){return Y(e,-256)}static int(e){return Y(e,-256)}static bytes1(e){return X(e,1)}static bytes2(e){return X(e,2)}static bytes3(e){return X(e,3)}static bytes4(e){return X(e,4)}static bytes5(e){return X(e,5)}static bytes6(e){return X(e,6)}static bytes7(e){return X(e,7)}static bytes8(e){return X(e,8)}static bytes9(e){return X(e,9)}static bytes10(e){return X(e,10)}static bytes11(e){return X(e,11)}static bytes12(e){return X(e,12)}static bytes13(e){return X(e,13)}static bytes14(e){return X(e,14)}static bytes15(e){return X(e,15)}static bytes16(e){return X(e,16)}static bytes17(e){return X(e,17)}static bytes18(e){return X(e,18)}static bytes19(e){return X(e,19)}static bytes20(e){return X(e,20)}static bytes21(e){return X(e,21)}static bytes22(e){return X(e,22)}static bytes23(e){return X(e,23)}static bytes24(e){return X(e,24)}static bytes25(e){return X(e,25)}static bytes26(e){return X(e,26)}static bytes27(e){return X(e,27)}static bytes28(e){return X(e,28)}static bytes29(e){return X(e,29)}static bytes30(e){return X(e,30)}static bytes31(e){return X(e,31)}static bytes32(e){return X(e,32)}static address(t){return new e(Md,`address`,t)}static bool(t){return new e(Md,`bool`,!!t)}static bytes(t){return new e(Md,`bytes`,t)}static string(t){return new e(Md,`string`,t)}static array(e,t){throw Error(`not implemented yet`)}static tuple(e,t){throw Error(`not implemented yet`)}static overrides(t){return new e(Md,`overrides`,Object.assign({},t))}static isTyped(e){return e&&typeof e==`object`&&`_typedSymbol`in e&&e._typedSymbol===Nd}static dereference(t,n){if(e.isTyped(t)){if(t.type!==n)throw Error(`invalid type: expecetd ${n}, got ${t.type}`);return t.value}return t}},Fd=class extends Lu{constructor(e){super(`address`,`address`,e,!1)}defaultValue(){return`0x0000000000000000000000000000000000000000`}encode(e,t){let n=Pd.dereference(t,`string`);try{n=jd(n)}catch(e){return this._throwError(e.message,t)}return e.writeValue(n)}decode(e){return jd(_u(e.readValue(),20))}},Id=class extends Lu{coder;constructor(e){super(e.name,e.type,`_`,e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}};function Ld(e,t,n){let r=[];if(Array.isArray(n))r=n;else if(n&&typeof n==`object`){let e={};r=t.map(t=>{let r=t.localName;return q(r,`cannot encode object for signature with missing names`,`INVALID_ARGUMENT`,{argument:`values`,info:{coder:t},value:n}),q(!e[r],`cannot encode object for signature with duplicate names`,`INVALID_ARGUMENT`,{argument:`values`,info:{coder:t},value:n}),e[r]=!0,n[r]})}else J(!1,`invalid tuple value`,`tuple`,n);J(t.length===r.length,`types/value length mismatch`,`tuple`,n);let i=new Ru,a=new Ru,o=[];t.forEach((e,t)=>{let n=r[t];if(e.dynamic){let t=a.length;e.encode(a,n);let r=i.writeUpdatableValue();o.push(e=>{r(e+t)})}else e.encode(i,n)}),o.forEach(e=>{e(i.length)});let s=e.appendWriter(i);return s+=e.appendWriter(a),s}function Rd(e,t){let n=[],r=[],i=e.subReader(0);return t.forEach(t=>{let a=null;if(t.dynamic){let n=e.readIndex(),r=i.subReader(n);try{a=t.decode(r)}catch(e){if(Hl(e,`BUFFER_OVERRUN`))throw e;a=e,a.baseType=t.name,a.name=t.localName,a.type=t.type}}else try{a=t.decode(e)}catch(e){if(Hl(e,`BUFFER_OVERRUN`))throw e;a=e,a.baseType=t.name,a.name=t.localName,a.type=t.type}if(a==null)throw Error(`investigate`);n.push(a),r.push(t.localName||null)}),Fu.fromItems(n,r)}var zd=class extends Lu{coder;length;constructor(e,t,n){let r=e.type+`[`+(t>=0?t:``)+`]`,i=t===-1||e.dynamic;super(`array`,r,n,i),K(this,{coder:e,length:t})}defaultValue(){let e=this.coder.defaultValue(),t=[];for(let n=0;n<this.length;n++)t.push(e);return t}encode(e,t){let n=Pd.dereference(t,`array`);Array.isArray(n)||this._throwError(`expected array value`,n);let r=this.length;r===-1&&(r=n.length,e.writeValue(n.length)),Wl(n.length,r,`coder array`+(this.localName?` `+this.localName:``));let i=[];for(let e=0;e<n.length;e++)i.push(this.coder);return Ld(e,i,n)}decode(e){let t=this.length;t===-1&&(t=e.readIndex(),q(t*32<=e.dataLength,`insufficient data length`,`BUFFER_OVERRUN`,{buffer:e.bytes,offset:t*32,length:e.dataLength}));let n=[];for(let e=0;e<t;e++)n.push(new Id(this.coder));return Rd(e,n)}},Bd=class extends Lu{constructor(e){super(`bool`,`bool`,e,!1)}defaultValue(){return!1}encode(e,t){let n=Pd.dereference(t,`bool`);return e.writeValue(+!!n)}decode(e){return!!e.readValue()}},Vd=class extends Lu{constructor(e,t){super(e,e,t,!0)}defaultValue(){return`0x`}encode(e,t){t=Xl(t);let n=e.writeValue(t.length);return n+=e.writeBytes(t),n}decode(e){return e.readBytes(e.readIndex(),!0)}},Hd=class extends Vd{constructor(e){super(`bytes`,e)}decode(e){return $l(super.decode(e))}},Ud=class extends Lu{size;constructor(e,t){let n=`bytes`+String(e);super(n,n,t,!1),K(this,{size:e},{size:`number`})}defaultValue(){return`0x0000000000000000000000000000000000000000000000000000000000000000`.substring(0,2+this.size*2)}encode(e,t){let n=Xl(Pd.dereference(t,this.type));return n.length!==this.size&&this._throwError(`incorrect data length`,t),e.writeBytes(n)}decode(e){return $l(e.readBytes(this.size))}};const Wd=new Uint8Array([]);var Gd=class extends Lu{constructor(e){super(`null`,``,e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError(`not null`,t),e.writeBytes(Wd)}decode(e){return e.readBytes(0),null}};const Kd=BigInt(0),qd=BigInt(1),Jd=BigInt(`0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff`);var Yd=class extends Lu{size;signed;constructor(e,t,n){let r=(t?`int`:`uint`)+e*8;super(r,r,n,!1),K(this,{size:e,signed:t},{size:`number`,signed:`boolean`})}defaultValue(){return 0}encode(e,t){let n=du(Pd.dereference(t,this.type)),r=uu(Jd,256);if(this.signed){let e=uu(r,this.size*8-1);(n>e||n<-(e+qd))&&this._throwError(`value out-of-bounds`,t),n=lu(n,256)}else (n<Kd||n>uu(r,this.size*8))&&this._throwError(`value out-of-bounds`,t);return e.writeValue(n)}decode(e){let t=uu(e.readValue(),this.size*8);return this.signed&&(t=cu(t,this.size*8)),t}},Xd=class extends Vd{constructor(e){super(`string`,e)}defaultValue(){return``}encode(e,t){return super.encode(e,wu(Pd.dereference(t,`string`)))}decode(e){return Eu(super.decode(e))}},Zd=class extends Lu{coders;constructor(e,t){let n=!1,r=[];e.forEach(e=>{e.dynamic&&(n=!0),r.push(e.type)});let i=`tuple(`+r.join(`,`)+`)`;super(`tuple`,i,t,n),K(this,{coders:Object.freeze(e.slice())})}defaultValue(){let e=[];this.coders.forEach(t=>{e.push(t.defaultValue())});let t=this.coders.reduce((e,t)=>{let n=t.localName;return n&&(e[n]||(e[n]=0),e[n]++),e},{});return this.coders.forEach((n,r)=>{let i=n.localName;!i||t[i]!==1||(i===`length`&&(i=`_length`),e[i]??(e[i]=e[r]))}),Object.freeze(e)}encode(e,t){let n=Pd.dereference(t,`tuple`);return Ld(e,this.coders,n)}decode(e){return Rd(e,this.coders)}};function Qd(e){return Cd(wu(e))}function $d(e){let t=new Set;return e.forEach(e=>t.add(e)),Object.freeze(t)}const ef=$d(`external public payable override`.split(` `)),tf=`constant external internal payable private public pure view override`,nf=$d(tf.split(` `)),rf=`constructor error event fallback function receive struct`,af=$d(rf.split(` `)),of=`calldata memory storage payable indexed`,sf=$d(of.split(` `)),cf=$d([rf,of,`tuple returns`,tf].join(` `).split(` `)),lf={"(":`OPEN_PAREN`,")":`CLOSE_PAREN`,"[":`OPEN_BRACKET`,"]":`CLOSE_BRACKET`,",":`COMMA`,"@":`AT`},uf=RegExp(`^(\\s*)`),df=RegExp(`^([0-9]+)`),ff=RegExp(`^([a-zA-Z$_][a-zA-Z0-9$_]*)`),pf=RegExp(`^([a-zA-Z$_][a-zA-Z0-9$_]*)$`),mf=RegExp(`^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$`);var hf=class e{#e;#t;get offset(){return this.#e}get length(){return this.#t.length-this.#e}constructor(e){this.#e=0,this.#t=e.slice()}clone(){return new e(this.#t)}reset(){this.#e=0}#n(t=0,n=0){return new e(this.#t.slice(t,n).map(e=>Object.freeze(Object.assign({},e,{match:e.match-t,linkBack:e.linkBack-t,linkNext:e.linkNext-t}))))}popKeyword(e){let t=this.peek();if(t.type!==`KEYWORD`||!e.has(t.text))throw Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){let t=this.peek();throw Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){let e=this.peek();if(e.type!==`OPEN_PAREN`)throw Error(`bad start`);let t=this.#n(this.#e+1,e.match+1);return this.#e=e.match+1,t}popParams(){let e=this.peek();if(e.type!==`OPEN_PAREN`)throw Error(`bad start`);let t=[];for(;this.#e<e.match-1;){let e=this.peek().linkNext;t.push(this.#n(this.#e+1,e)),this.#e=e}return this.#e=e.match+1,t}peek(){if(this.#e>=this.#t.length)throw Error(`out-of-bounds`);return this.#t[this.#e]}peekKeyword(e){let t=this.peekType(`KEYWORD`);return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;let t=this.peek();return t.type===e?t.text:null}pop(){let e=this.peek();return this.#e++,e}toString(){let e=[];for(let t=this.#e;t<this.#t.length;t++){let n=this.#t[t];e.push(`${n.type}:${n.text}`)}return`<TokenString ${e.join(` `)}>`}};function gf(e){let t=[],n=t=>{let n=a<e.length?JSON.stringify(e[a]):`$EOI`;throw Error(`invalid token ${n} at ${a}: ${t}`)},r=[],i=[],a=0;for(;a<e.length;){let o=e.substring(a),s=o.match(uf);s&&(a+=s[1].length,o=e.substring(a));let c={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:``,text:``,offset:a,value:-1};t.push(c);let l=lf[o[0]]||``;if(l){if(c.type=l,c.text=o[0],a++,l===`OPEN_PAREN`)r.push(t.length-1),i.push(t.length-1);else if(l==`CLOSE_PAREN`)r.length===0&&n(`no matching open bracket`),c.match=r.pop(),t[c.match].match=t.length-1,c.depth--,c.linkBack=i.pop(),t[c.linkBack].linkNext=t.length-1;else if(l===`COMMA`)c.linkBack=i.pop(),t[c.linkBack].linkNext=t.length-1,i.push(t.length-1);else if(l===`OPEN_BRACKET`)c.type=`BRACKET`;else if(l===`CLOSE_BRACKET`){let e=t.pop().text;if(t.length>0&&t[t.length-1].type===`NUMBER`){let n=t.pop().text;e=n+e,t[t.length-1].value=hu(n)}if(t.length===0||t[t.length-1].type!==`BRACKET`)throw Error(`missing opening bracket`);t[t.length-1].text+=e}continue}if(s=o.match(ff),s){if(c.text=s[1],a+=c.text.length,cf.has(c.text)){c.type=`KEYWORD`;continue}if(c.text.match(mf)){c.type=`TYPE`;continue}c.type=`ID`;continue}if(s=o.match(df),s){c.text=s[1],c.type=`NUMBER`,a+=c.text.length;continue}throw Error(`unexpected token ${JSON.stringify(o[0])} at position ${a}`)}return new hf(t.map(e=>Object.freeze(e)))}function _f(e,t){let n=[];for(let r in t.keys())e.has(r)&&n.push(r);if(n.length>1)throw Error(`conflicting types: ${n.join(`, `)}`)}function vf(e,t){if(t.peekKeyword(af)){let n=t.pop().text;if(n!==e)throw Error(`expected ${e}, got ${n}`)}return t.popType(`ID`)}function yf(e,t){let n=new Set;for(;;){let r=e.peekType(`KEYWORD`);if(r==null||t&&!t.has(r))break;if(e.pop(),n.has(r))throw Error(`duplicate keywords: ${JSON.stringify(r)}`);n.add(r)}return Object.freeze(n)}function bf(e){let t=yf(e,nf);return _f(t,$d(`constant payable nonpayable`.split(` `))),_f(t,$d(`pure view payable nonpayable`.split(` `))),t.has(`view`)?`view`:t.has(`pure`)?`pure`:t.has(`payable`)?`payable`:t.has(`nonpayable`)?`nonpayable`:t.has(`constant`)?`view`:`nonpayable`}function xf(e,t){return e.popParams().map(e=>Pf.from(e,t))}function Sf(e){if(e.peekType(`AT`)){if(e.pop(),e.peekType(`NUMBER`))return du(e.pop().text);throw Error(`invalid gas`)}return null}function Cf(e){if(e.length)throw Error(`unexpected tokens at offset ${e.offset}: ${e.toString()}`)}const wf=new RegExp(/^(.*)\[([0-9]*)\]$/);function Tf(e){let t=e.match(mf);if(J(t,`invalid type`,`type`,e),e===`uint`)return`uint256`;if(e===`int`)return`int256`;if(t[2]){let n=parseInt(t[2]);J(n!==0&&n<=32,`invalid bytes length`,`type`,e)}else if(t[3]){let n=parseInt(t[3]);J(n!==0&&n<=256&&n%8==0,`invalid numeric width`,`type`,e)}return e}const Z={},Ef=Symbol.for(`_ethers_internal`),Df=`_ParamTypeInternal`,Of=`_ErrorInternal`,kf=`_EventInternal`,Af=`_ConstructorInternal`,jf=`_FallbackInternal`,Mf=`_FunctionInternal`,Nf=`_StructInternal`;var Pf=class e{name;type;baseType;indexed;components;arrayLength;arrayChildren;constructor(e,t,n,r,i,a,o,s){if(ql(e,Z,`ParamType`),Object.defineProperty(this,Ef,{value:Df}),a&&=Object.freeze(a.slice()),r===`array`){if(o==null||s==null)throw Error(``)}else if(o!=null||s!=null)throw Error(``);if(r===`tuple`){if(a==null)throw Error(``)}else if(a!=null)throw Error(``);K(this,{name:t,type:n,baseType:r,indexed:i,components:a,arrayLength:o,arrayChildren:s})}format(e){if(e??=`sighash`,e===`json`){let t=this.name||``;if(this.isArray()){let e=JSON.parse(this.arrayChildren.format(`json`));return e.name=t,e.type+=`[${this.arrayLength<0?``:String(this.arrayLength)}]`,JSON.stringify(e)}let n={type:this.baseType===`tuple`?`tuple`:this.type,name:t};return typeof this.indexed==`boolean`&&(n.indexed=this.indexed),this.isTuple()&&(n.components=this.components.map(t=>JSON.parse(t.format(e)))),JSON.stringify(n)}let t=``;return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?``:String(this.arrayLength)}]`):this.isTuple()?t+=`(`+this.components.map(t=>t.format(e)).join(e===`full`?`, `:`,`)+`)`:t+=this.type,e!==`sighash`&&(this.indexed===!0&&(t+=` indexed`),e===`full`&&this.name&&(t+=` `+this.name)),t}isArray(){return this.baseType===`array`}isTuple(){return this.baseType===`tuple`}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw Error(`invalid array value`);if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw Error(`array is wrong length`);let n=this;return e.map(e=>n.arrayChildren.walk(e,t))}if(this.isTuple()){if(!Array.isArray(e))throw Error(`invalid tuple value`);if(e.length!==this.components.length)throw Error(`array is wrong length`);let n=this;return e.map((e,r)=>n.components[r].walk(e,t))}return t(this.type,e)}#e(e,t,n,r){if(this.isArray()){if(!Array.isArray(t))throw Error(`invalid array value`);if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw Error(`array is wrong length`);let i=this.arrayChildren,a=t.slice();a.forEach((t,r)=>{i.#e(e,t,n,e=>{a[r]=e})}),r(a);return}if(this.isTuple()){let i=this.components,a;if(Array.isArray(t))a=t.slice();else{if(typeof t!=`object`||!t)throw Error(`invalid tuple value`);a=i.map(e=>{if(!e.name)throw Error(`cannot use object value with unnamed components`);if(!(e.name in t))throw Error(`missing value for component ${e.name}`);return t[e.name]})}if(a.length!==this.components.length)throw Error(`array is wrong length`);a.forEach((t,r)=>{i[r].#e(e,t,n,e=>{a[r]=e})}),r(a);return}let i=n(this.type,t);i.then?e.push((async function(){r(await i)})()):r(i)}async walkAsync(e,t){let n=[],r=[e];return this.#e(n,e,t,e=>{r[0]=e}),n.length&&await Promise.all(n),r[0]}static from(t,n){if(e.isParamType(t))return t;if(typeof t==`string`)try{return e.from(gf(t),n)}catch{J(!1,`invalid param type`,`obj`,t)}else if(t instanceof hf){let r=``,i=``,a=null;yf(t,$d([`tuple`])).has(`tuple`)||t.peekType(`OPEN_PAREN`)?(i=`tuple`,a=t.popParams().map(t=>e.from(t)),r=`tuple(${a.map(e=>e.format()).join(`,`)})`):(r=Tf(t.popType(`TYPE`)),i=r);let o=null,s=null;for(;t.length&&t.peekType(`BRACKET`);){let n=t.pop();o=new e(Z,``,r,i,null,a,s,o),s=n.value,r+=n.text,i=`array`,a=null}let c=null;if(yf(t,sf).has(`indexed`)){if(!n)throw Error(``);c=!0}let l=t.peekType(`ID`)?t.pop().text:``;if(t.length)throw Error(`leftover tokens`);return new e(Z,l,r,i,c,a,s,o)}let r=t.name;J(!r||typeof r==`string`&&r.match(pf),`invalid name`,`obj.name`,r);let i=t.indexed;i!=null&&(J(n,`parameter cannot be indexed`,`obj.indexed`,t.indexed),i=!!i);let a=t.type,o=a.match(wf);if(o){let n=parseInt(o[2]||`-1`),s=e.from({type:o[1],components:t.components});return new e(Z,r||``,a,`array`,i,null,n,s)}if(a===`tuple`||a.startsWith(`tuple(`)||a.startsWith(`(`)){let n=t.components==null?null:t.components.map(t=>e.from(t));return new e(Z,r||``,a,`tuple`,i,n,null,null)}return a=Tf(t.type),new e(Z,r||``,a,a,i,null,null,null)}static isParamType(e){return e&&e[Ef]===Df}},Ff=class e{type;inputs;constructor(e,t,n){ql(e,Z,`Fragment`),n=Object.freeze(n.slice()),K(this,{type:t,inputs:n})}static from(t){if(typeof t==`string`){try{e.from(JSON.parse(t))}catch{}return e.from(gf(t))}if(t instanceof hf)switch(t.peekKeyword(af)){case`constructor`:return Bf.from(t);case`error`:return Rf.from(t);case`event`:return zf.from(t);case`fallback`:case`receive`:return Vf.from(t);case`function`:return Hf.from(t);case`struct`:return Uf.from(t)}else if(typeof t==`object`){switch(t.type){case`constructor`:return Bf.from(t);case`error`:return Rf.from(t);case`event`:return zf.from(t);case`fallback`:case`receive`:return Vf.from(t);case`function`:return Hf.from(t);case`struct`:return Uf.from(t)}q(!1,`unsupported type: ${t.type}`,`UNSUPPORTED_OPERATION`,{operation:`Fragment.from`})}J(!1,`unsupported frgament object`,`obj`,t)}static isConstructor(e){return Bf.isFragment(e)}static isError(e){return Rf.isFragment(e)}static isEvent(e){return zf.isFragment(e)}static isFunction(e){return Hf.isFragment(e)}static isStruct(e){return Uf.isFragment(e)}},If=class extends Ff{name;constructor(e,t,n,r){super(e,t,r),J(typeof n==`string`&&n.match(pf),`invalid identifier`,`name`,n),r=Object.freeze(r.slice()),K(this,{name:n})}};function Lf(e,t){return`(`+t.map(t=>t.format(e)).join(e===`full`?`, `:`,`)+`)`}var Rf=class e extends If{constructor(e,t,n){super(e,`error`,t,n),Object.defineProperty(this,Ef,{value:Of})}get selector(){return Qd(this.format(`sighash`)).substring(0,10)}format(e){if(e??=`sighash`,e===`json`)return JSON.stringify({type:`error`,name:this.name,inputs:this.inputs.map(t=>JSON.parse(t.format(e)))});let t=[];return e!==`sighash`&&t.push(`error`),t.push(this.name+Lf(e,this.inputs)),t.join(` `)}static from(t){if(e.isFragment(t))return t;if(typeof t==`string`)return e.from(gf(t));if(t instanceof hf){let n=vf(`error`,t),r=xf(t);return Cf(t),new e(Z,n,r)}return new e(Z,t.name,t.inputs?t.inputs.map(Pf.from):[])}static isFragment(e){return e&&e[Ef]===Of}},zf=class e extends If{anonymous;constructor(e,t,n,r){super(e,`event`,t,n),Object.defineProperty(this,Ef,{value:kf}),K(this,{anonymous:r})}get topicHash(){return Qd(this.format(`sighash`))}format(e){if(e??=`sighash`,e===`json`)return JSON.stringify({type:`event`,anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(t=>JSON.parse(t.format(e)))});let t=[];return e!==`sighash`&&t.push(`event`),t.push(this.name+Lf(e,this.inputs)),e!==`sighash`&&this.anonymous&&t.push(`anonymous`),t.join(` `)}static getTopicHash(t,n){return n=(n||[]).map(e=>Pf.from(e)),new e(Z,t,n,!1).topicHash}static from(t){if(e.isFragment(t))return t;if(typeof t==`string`)try{return e.from(gf(t))}catch{J(!1,`invalid event fragment`,`obj`,t)}else if(t instanceof hf){let n=vf(`event`,t),r=xf(t,!0),i=!!yf(t,$d([`anonymous`])).has(`anonymous`);return Cf(t),new e(Z,n,r,i)}return new e(Z,t.name,t.inputs?t.inputs.map(e=>Pf.from(e,!0)):[],!!t.anonymous)}static isFragment(e){return e&&e[Ef]===kf}},Bf=class e extends Ff{payable;gas;constructor(e,t,n,r,i){super(e,t,n),Object.defineProperty(this,Ef,{value:Af}),K(this,{payable:r,gas:i})}format(e){if(q(e!=null&&e!==`sighash`,`cannot format a constructor for sighash`,`UNSUPPORTED_OPERATION`,{operation:`format(sighash)`}),e===`json`)return JSON.stringify({type:`constructor`,stateMutability:this.payable?`payable`:`undefined`,payable:this.payable,gas:this.gas==null?void 0:this.gas,inputs:this.inputs.map(t=>JSON.parse(t.format(e)))});let t=[`constructor${Lf(e,this.inputs)}`];return this.payable&&t.push(`payable`),this.gas!=null&&t.push(`@${this.gas.toString()}`),t.join(` `)}static from(t){if(e.isFragment(t))return t;if(typeof t==`string`)try{return e.from(gf(t))}catch{J(!1,`invalid constuctor fragment`,`obj`,t)}else if(t instanceof hf){yf(t,$d([`constructor`]));let n=xf(t),r=!!yf(t,ef).has(`payable`),i=Sf(t);return Cf(t),new e(Z,`constructor`,n,r,i)}return new e(Z,`constructor`,t.inputs?t.inputs.map(Pf.from):[],!!t.payable,t.gas==null?null:t.gas)}static isFragment(e){return e&&e[Ef]===Af}},Vf=class e extends Ff{payable;constructor(e,t,n){super(e,`fallback`,t),Object.defineProperty(this,Ef,{value:jf}),K(this,{payable:n})}format(e){let t=this.inputs.length===0?`receive`:`fallback`;if(e===`json`){let e=this.payable?`payable`:`nonpayable`;return JSON.stringify({type:t,stateMutability:e})}return`${t}()${this.payable?` payable`:``}`}static from(t){if(e.isFragment(t))return t;if(typeof t==`string`)try{return e.from(gf(t))}catch{J(!1,`invalid fallback fragment`,`obj`,t)}else if(t instanceof hf){let n=t.toString();if(J(t.peekKeyword($d([`fallback`,`receive`])),`type must be fallback or receive`,`obj`,n),t.popKeyword($d([`fallback`,`receive`]))===`receive`){let n=xf(t);return J(n.length===0,`receive cannot have arguments`,`obj.inputs`,n),yf(t,$d([`payable`])),Cf(t),new e(Z,[],!0)}let r=xf(t);r.length?J(r.length===1&&r[0].type===`bytes`,`invalid fallback inputs`,`obj.inputs`,r.map(e=>e.format(`minimal`)).join(`, `)):r=[Pf.from(`bytes`)];let i=bf(t);if(J(i===`nonpayable`||i===`payable`,`fallback cannot be constants`,`obj.stateMutability`,i),yf(t,$d([`returns`])).has(`returns`)){let e=xf(t);J(e.length===1&&e[0].type===`bytes`,`invalid fallback outputs`,`obj.outputs`,e.map(e=>e.format(`minimal`)).join(`, `))}return Cf(t),new e(Z,r,i===`payable`)}if(t.type===`receive`)return new e(Z,[],!0);if(t.type===`fallback`)return new e(Z,[Pf.from(`bytes`)],t.stateMutability===`payable`);J(!1,`invalid fallback description`,`obj`,t)}static isFragment(e){return e&&e[Ef]===jf}},Hf=class e extends If{constant;outputs;stateMutability;payable;gas;constructor(e,t,n,r,i,a){super(e,`function`,t,r),Object.defineProperty(this,Ef,{value:Mf}),i=Object.freeze(i.slice());let o=n===`view`||n===`pure`,s=n===`payable`;K(this,{constant:o,gas:a,outputs:i,payable:s,stateMutability:n})}get selector(){return Qd(this.format(`sighash`)).substring(0,10)}format(e){if(e??=`sighash`,e===`json`)return JSON.stringify({type:`function`,name:this.name,constant:this.constant,stateMutability:this.stateMutability===`nonpayable`?void 0:this.stateMutability,payable:this.payable,gas:this.gas==null?void 0:this.gas,inputs:this.inputs.map(t=>JSON.parse(t.format(e))),outputs:this.outputs.map(t=>JSON.parse(t.format(e)))});let t=[];return e!==`sighash`&&t.push(`function`),t.push(this.name+Lf(e,this.inputs)),e!==`sighash`&&(this.stateMutability!==`nonpayable`&&t.push(this.stateMutability),this.outputs&&this.outputs.length&&(t.push(`returns`),t.push(Lf(e,this.outputs))),this.gas!=null&&t.push(`@${this.gas.toString()}`)),t.join(` `)}static getSelector(t,n){return n=(n||[]).map(e=>Pf.from(e)),new e(Z,t,`view`,n,[],null).selector}static from(t){if(e.isFragment(t))return t;if(typeof t==`string`)try{return e.from(gf(t))}catch{J(!1,`invalid function fragment`,`obj`,t)}else if(t instanceof hf){let n=vf(`function`,t),r=xf(t),i=bf(t),a=[];yf(t,$d([`returns`])).has(`returns`)&&(a=xf(t));let o=Sf(t);return Cf(t),new e(Z,n,i,r,a,o)}let n=t.stateMutability;return n??(n=`payable`,typeof t.constant==`boolean`?(n=`view`,t.constant||(n=`payable`,typeof t.payable==`boolean`&&!t.payable&&(n=`nonpayable`))):typeof t.payable==`boolean`&&!t.payable&&(n=`nonpayable`)),new e(Z,t.name,n,t.inputs?t.inputs.map(Pf.from):[],t.outputs?t.outputs.map(Pf.from):[],t.gas==null?null:t.gas)}static isFragment(e){return e&&e[Ef]===Mf}},Uf=class e extends If{constructor(e,t,n){super(e,`struct`,t,n),Object.defineProperty(this,Ef,{value:Nf})}format(){throw Error(`@TODO`)}static from(t){if(typeof t==`string`)try{return e.from(gf(t))}catch{J(!1,`invalid struct fragment`,`obj`,t)}else if(t instanceof hf){let n=vf(`struct`,t),r=xf(t);return Cf(t),new e(Z,n,r)}return new e(Z,t.name,t.inputs?t.inputs.map(Pf.from):[])}static isFragment(e){return e&&e[Ef]===Nf}};const Wf=new Map;Wf.set(0,`GENERIC_PANIC`),Wf.set(1,`ASSERT_FALSE`),Wf.set(17,`OVERFLOW`),Wf.set(18,`DIVIDE_BY_ZERO`),Wf.set(33,`ENUM_RANGE_ERROR`),Wf.set(34,`BAD_STORAGE_DATA`),Wf.set(49,`STACK_UNDERFLOW`),Wf.set(50,`ARRAY_RANGE_ERROR`),Wf.set(65,`OUT_OF_MEMORY`),Wf.set(81,`UNINITIALIZED_FUNCTION_CALL`);const Gf=new RegExp(/^bytes([0-9]*)$/),Kf=new RegExp(/^(u?int)([0-9]*)$/);let qf=null,Jf=1024;function Yf(e,t,n,r){let i=`missing revert data`,a=null,o=null;if(n){i=`execution reverted`;let e=Yl(n);if(n=$l(n),e.length===0)i+=` (no data present; likely require(false) occurred`,a=`require(false)`;else if(e.length%32!=4)i+=` (could not decode reason; invalid data length)`;else if($l(e.slice(0,4))===`0x08c379a0`)try{a=r.decode([`string`],e.slice(4))[0],o={signature:`Error(string)`,name:`Error`,args:[a]},i+=`: ${JSON.stringify(a)}`}catch{i+=` (could not decode reason; invalid string data)`}else if($l(e.slice(0,4))===`0x4e487b71`)try{let t=Number(r.decode([`uint256`],e.slice(4))[0]);o={signature:`Panic(uint256)`,name:`Panic`,args:[t]},a=`Panic due to ${Wf.get(t)||`UNKNOWN`}(${t})`,i+=`: ${a}`}catch{i+=` (could not decode panic code)`}else i+=` (unknown custom error)`}let s={to:t.to?jd(t.to):null,data:t.data||`0x`};return t.from&&(s.from=jd(t.from)),Ul(i,`CALL_EXCEPTION`,{action:e,data:n,reason:a,transaction:s,invocation:null,revert:o})}var Xf=class e{#e(e){if(e.isArray())return new zd(this.#e(e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new Zd(e.components.map(e=>this.#e(e)),e.name);switch(e.baseType){case`address`:return new Fd(e.name);case`bool`:return new Bd(e.name);case`string`:return new Xd(e.name);case`bytes`:return new Hd(e.name);case``:return new Gd(e.name)}let t=e.type.match(Kf);if(t){let n=parseInt(t[2]||`256`);return J(n!==0&&n<=256&&n%8==0,`invalid `+t[1]+` bit length`,`param`,e),new Yd(n/8,t[1]===`int`,e.name)}if(t=e.type.match(Gf),t){let n=parseInt(t[1]);return J(n!==0&&n<=32,`invalid bytes length`,`param`,e),new Ud(n,e.name)}J(!1,`invalid type`,`type`,e.type)}getDefaultValue(e){return new Zd(e.map(e=>this.#e(Pf.from(e))),`_`).defaultValue()}encode(e,t){Wl(t.length,e.length,`types/values length mismatch`);let n=new Zd(e.map(e=>this.#e(Pf.from(e))),`_`),r=new Ru;return n.encode(r,t),r.data}decode(e,t,n){return new Zd(e.map(e=>this.#e(Pf.from(e))),`_`).decode(new zu(t,n,Jf))}static _setDefaultMaxInflation(e){J(typeof e==`number`&&Number.isInteger(e),`invalid defaultMaxInflation factor`,`value`,e),Jf=e}static defaultAbiCoder(){return qf??=new e,qf}static getBuiltinCallException(t,n,r){return Yf(t,n,r,e.defaultAbiCoder())}},Zf=class{fragment;name;signature;topic;args;constructor(e,t,n){let r=e.name,i=e.format();K(this,{fragment:e,name:r,signature:i,topic:t,args:n})}},Qf=class{fragment;name;args;signature;selector;value;constructor(e,t,n,r){let i=e.name,a=e.format();K(this,{fragment:e,name:i,args:n,signature:a,selector:t,value:r})}},$f=class{fragment;name;args;signature;selector;constructor(e,t,n){let r=e.name,i=e.format();K(this,{fragment:e,name:r,args:n,signature:i,selector:t})}},ep=class{hash;_isIndexed;static isIndexed(e){return!!(e&&e._isIndexed)}constructor(e){K(this,{hash:e,_isIndexed:!0})}};const tp={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`},np={"0x08c379a0":{signature:`Error(string)`,name:`Error`,inputs:[`string`],reason:e=>`reverted with reason string ${JSON.stringify(e)}`},"0x4e487b71":{signature:`Panic(uint256)`,name:`Panic`,inputs:[`uint256`],reason:e=>{let t=`unknown panic code`;return e>=0&&e<=255&&tp[e.toString()]&&(t=tp[e.toString()]),`reverted with panic code 0x${e.toString(16)} (${t})`}}};var rp=class e{fragments;deploy;fallback;receive;#e;#t;#n;#r;constructor(e){let t=[];t=typeof e==`string`?JSON.parse(e):e,this.#n=new Map,this.#e=new Map,this.#t=new Map;let n=[];for(let e of t)try{n.push(Ff.from(e))}catch(t){console.log(`[Warning] Invalid Fragment ${JSON.stringify(e)}:`,t.message)}K(this,{fragments:Object.freeze(n)});let r=null,i=!1;this.#r=this.getAbiCoder(),this.fragments.forEach((e,t)=>{let n;switch(e.type){case`constructor`:if(this.deploy){console.log(`duplicate definition - constructor`);return}K(this,{deploy:e});return;case`fallback`:e.inputs.length===0?i=!0:(J(!r||e.payable!==r.payable,`conflicting fallback fragments`,`fragments[${t}]`,e),r=e,i=r.payable);return;case`function`:n=this.#n;break;case`event`:n=this.#t;break;case`error`:n=this.#e;break;default:return}let a=e.format();n.has(a)||n.set(a,e)}),this.deploy||K(this,{deploy:Bf.from(`constructor()`)}),K(this,{fallback:r,receive:i})}format(e){let t=e?`minimal`:`full`;return this.fragments.map(e=>e.format(t))}formatJson(){let e=this.fragments.map(e=>e.format(`json`));return JSON.stringify(e.map(e=>JSON.parse(e)))}getAbiCoder(){return Xf.defaultAbiCoder()}#i(e,t,n){if(Zl(e)){let t=e.toLowerCase();for(let e of this.#n.values())if(t===e.selector)return e;return null}if(e.indexOf(`(`)===-1){let r=[];for(let[t,n]of this.#n)t.split(`(`)[0]===e&&r.push(n);if(t){let e=t.length>0?t[t.length-1]:null,n=t.length,i=!0;Pd.isTyped(e)&&e.type===`overrides`&&(i=!1,n--);for(let e=r.length-1;e>=0;e--){let t=r[e].inputs.length;t!==n&&(!i||t!==n-1)&&r.splice(e,1)}for(let e=r.length-1;e>=0;e--){let n=r[e].inputs;for(let i=0;i<t.length;i++)if(Pd.isTyped(t[i])){if(i>=n.length){if(t[i].type===`overrides`)continue;r.splice(e,1);break}if(t[i].type!==n[i].baseType){r.splice(e,1);break}}}}if(r.length===1&&t&&t.length!==r[0].inputs.length){let e=t[t.length-1];(e==null||Array.isArray(e)||typeof e!=`object`)&&r.splice(0,1)}return r.length===0?null:(r.length>1&&n&&J(!1,`ambiguous function description (i.e. matches ${r.map(e=>JSON.stringify(e.format())).join(`, `)})`,`key`,e),r[0])}return this.#n.get(Hf.from(e).format())||null}getFunctionName(e){let t=this.#i(e,null,!1);return J(t,`no matching function`,`key`,e),t.name}hasFunction(e){return!!this.#i(e,null,!1)}getFunction(e,t){return this.#i(e,t||null,!0)}forEachFunction(e){let t=Array.from(this.#n.keys());t.sort((e,t)=>e.localeCompare(t));for(let n=0;n<t.length;n++){let r=t[n];e(this.#n.get(r),n)}}#a(e,t,n){if(Zl(e)){let t=e.toLowerCase();for(let e of this.#t.values())if(t===e.topicHash)return e;return null}if(e.indexOf(`(`)===-1){let r=[];for(let[t,n]of this.#t)t.split(`(`)[0]===e&&r.push(n);if(t){for(let e=r.length-1;e>=0;e--)r[e].inputs.length<t.length&&r.splice(e,1);for(let e=r.length-1;e>=0;e--){let n=r[e].inputs;for(let i=0;i<t.length;i++)if(Pd.isTyped(t[i])&&t[i].type!==n[i].baseType){r.splice(e,1);break}}}return r.length===0?null:(r.length>1&&n&&J(!1,`ambiguous event description (i.e. matches ${r.map(e=>JSON.stringify(e.format())).join(`, `)})`,`key`,e),r[0])}return this.#t.get(zf.from(e).format())||null}getEventName(e){let t=this.#a(e,null,!1);return J(t,`no matching event`,`key`,e),t.name}hasEvent(e){return!!this.#a(e,null,!1)}getEvent(e,t){return this.#a(e,t||null,!0)}forEachEvent(e){let t=Array.from(this.#t.keys());t.sort((e,t)=>e.localeCompare(t));for(let n=0;n<t.length;n++){let r=t[n];e(this.#t.get(r),n)}}getError(e,t){if(Zl(e)){let t=e.toLowerCase();if(np[t])return Rf.from(np[t].signature);for(let e of this.#e.values())if(t===e.selector)return e;return null}if(e.indexOf(`(`)===-1){let t=[];for(let[n,r]of this.#e)n.split(`(`)[0]===e&&t.push(r);return t.length===0?e===`Error`?Rf.from(`error Error(string)`):e===`Panic`?Rf.from(`error Panic(uint256)`):null:(t.length>1&&J(!1,`ambiguous error description (i.e. ${t.map(e=>JSON.stringify(e.format())).join(`, `)})`,`name`,e),t[0])}return e=Rf.from(e).format(),e===`Error(string)`?Rf.from(`error Error(string)`):e===`Panic(uint256)`?Rf.from(`error Panic(uint256)`):this.#e.get(e)||null}forEachError(e){let t=Array.from(this.#e.keys());t.sort((e,t)=>e.localeCompare(t));for(let n=0;n<t.length;n++){let r=t[n];e(this.#e.get(r),n)}}_decodeParams(e,t){return this.#r.decode(e,t)}_encodeParams(e,t){return this.#r.encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e==`string`){let t=this.getError(e);J(t,`unknown error`,`fragment`,e),e=t}return J(tu(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,`data`,t),this._decodeParams(e.inputs,tu(t,4))}encodeErrorResult(e,t){if(typeof e==`string`){let t=this.getError(e);J(t,`unknown error`,`fragment`,e),e=t}return eu([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e==`string`){let t=this.getFunction(e);J(t,`unknown function`,`fragment`,e),e=t}return J(tu(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,`data`,t),this._decodeParams(e.inputs,tu(t,4))}encodeFunctionData(e,t){if(typeof e==`string`){let t=this.getFunction(e);J(t,`unknown function`,`fragment`,e),e=t}return eu([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e==`string`){let t=this.getFunction(e);J(t,`unknown function`,`fragment`,e),e=t}let n=`invalid length for result data`,r=Xl(t);if(r.length%32==0)try{return this.#r.decode(e.outputs,r)}catch{n=`could not decode result data`}q(!1,n,`BAD_DATA`,{value:$l(r),info:{method:e.name,signature:e.format()}})}makeError(e,t){let n=Yl(e,`data`),r=Xf.getBuiltinCallException(`call`,t,n);if(r.message.startsWith(`execution reverted (unknown custom error)`)){let e=$l(n.slice(0,4)),t=this.getError(e);if(t)try{let e=this.#r.decode(t.inputs,n.slice(4));r.revert={name:t.name,signature:t.format(),args:e},r.reason=r.revert.signature,r.message=`execution reverted: ${r.reason}`}catch{r.message=`execution reverted (coult not decode custom error)`}}let i=this.parseTransaction(t);return i&&(r.invocation={method:i.name,signature:i.signature,args:i.args}),r}encodeFunctionResult(e,t){if(typeof e==`string`){let t=this.getFunction(e);J(t,`unknown function`,`fragment`,e),e=t}return $l(this.#r.encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e==`string`){let t=this.getEvent(e);J(t,`unknown event`,`eventFragment`,e),e=t}q(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,`UNEXPECTED_ARGUMENT`,{count:t.length,expectedCount:e.inputs.length});let n=[];e.anonymous||n.push(e.topicHash);let r=(e,t)=>e.type===`string`?Qd(t):e.type===`bytes`?Cd($l(t)):(e.type===`bool`&&typeof t==`boolean`?t=t?`0x01`:`0x00`:e.type.match(/^u?int/)?t=_u(t):e.type.match(/^bytes/)?t=iu(t,32):e.type===`address`&&this.#r.encode([`address`],[t]),ru($l(t),32));for(t.forEach((t,i)=>{let a=e.inputs[i];if(!a.indexed){J(t==null,`cannot filter non-indexed parameters; must be null`,`contract.`+a.name,t);return}t==null?n.push(null):a.baseType===`array`||a.baseType===`tuple`?J(!1,`filtering with tuples or arrays not supported`,`contract.`+a.name,t):Array.isArray(t)?n.push(t.map(e=>r(a,e))):n.push(r(a,t))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(e,t){if(typeof e==`string`){let t=this.getEvent(e);J(t,`unknown event`,`eventFragment`,e),e=t}let n=[],r=[],i=[];return e.anonymous||n.push(e.topicHash),J(t.length===e.inputs.length,`event arguments/values mismatch`,`values`,t),e.inputs.forEach((e,a)=>{let o=t[a];if(e.indexed)if(e.type===`string`)n.push(Qd(o));else if(e.type===`bytes`)n.push(Cd(o));else if(e.baseType===`tuple`||e.baseType===`array`)throw Error(`not implemented`);else n.push(this.#r.encode([e.type],[o]));else r.push(e),i.push(o)}),{data:this.#r.encode(r,i),topics:n}}decodeEventLog(e,t,n){if(typeof e==`string`){let t=this.getEvent(e);J(t,`unknown event`,`eventFragment`,e),e=t}if(n!=null&&!e.anonymous){let t=e.topicHash;J(Zl(n[0],32)&&n[0].toLowerCase()===t,`fragment/topic mismatch`,`topics[0]`,n[0]),n=n.slice(1)}let r=[],i=[],a=[];e.inputs.forEach((e,t)=>{e.indexed?e.type===`string`||e.type===`bytes`||e.baseType===`tuple`||e.baseType===`array`?(r.push(Pf.from({type:`bytes32`,name:e.name})),a.push(!0)):(r.push(e),a.push(!1)):(i.push(e),a.push(!1))});let o=n==null?null:this.#r.decode(r,eu(n)),s=this.#r.decode(i,t,!0),c=[],l=[],u=0,d=0;return e.inputs.forEach((e,t)=>{let n=null;if(e.indexed)if(o==null)n=new ep(null);else if(a[t])n=new ep(o[d++]);else try{n=o[d++]}catch(e){n=e}else try{n=s[u++]}catch(e){n=e}c.push(n),l.push(e.name||null)}),Fu.fromItems(c,l)}parseTransaction(e){let t=Yl(e.data,`tx.data`),n=du(e.value==null?0:e.value,`tx.value`),r=this.getFunction($l(t.slice(0,4)));if(!r)return null;let i=this.#r.decode(r.inputs,t.slice(4));return new Qf(r,r.selector,i,n)}parseCallResult(e){throw Error(`@TODO`)}parseLog(e){let t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new Zf(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){let t=$l(e),n=this.getError(tu(t,0,4));if(!n)return null;let r=this.#r.decode(n.inputs,tu(t,4));return new $f(n,n.selector,r)}static from(t){return t instanceof e?t:typeof t==`string`?new e(JSON.parse(t)):typeof t.formatJson==`function`?new e(t.formatJson()):typeof t.format==`function`?new e(t.format(`json`)):new e(t)}};const ip=e=>JSON.parse(new rp(e).formatJson()),ap=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,ip(t)]));var op={hinkalABI:`constructor(tuple(uint128 levels, address poseidon2, address poseidon4) constructorArgs, address _hinkalHelper, address _hinkalHelperManager).event BlockedUtxosCreated().event BufferReleased(address approvalTarget, address tokenAddress, uint256 inHinkalAddress).event ExternalActionRegistered(address externalActionAddress).event NewBufferEntry(address approvalTarget, address tokenAddress, uint256 amount, uint256 inHinkalAddress).event NewCommitment(uint256 commitment, int256 index, bytes encryptedOutput).event NewTransaction(address sender, uint256 timestamp, address erc20TokenAddress, int256 publicAmount).event NewUtxo(uint256 amount, address erc20Address, uint256 randomization, uint256 stealthAddress, uint256 timeStamp).event Nullified(uint256 nullifier).event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner).event OwnershipTransferred(address indexed previousOwner, address indexed newOwner).event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole).event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender).event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender).event VerifierRegistered(uint256 verifierId, address verifierAddress).event VerifierRemoved(uint256 verifierId).function DEFAULT_ADMIN_ROLE() view returns (bytes32).function HINKAL_HELPER_MANAGER() view returns (bytes32).function acceptOwnership().function buildVerifierId(tuple(uint16 tokenNumber, uint16 nullifierAmount, uint16 outputAmount) dimensions, uint256 externalActionId) pure returns (uint256).function externalActionMap(uint256) view returns (address).function getRoleAdmin(bytes32 role) view returns (bytes32).function getRootHash() view returns (uint256).function grantRole(bytes32 role, address account).function hasRole(bytes32 role, address account) view returns (bool).function hash2(uint256 a, uint256 b) view returns (uint256 poseidonHash).function hash4(uint256 a0, uint256 a1, uint256 a2, uint256 a3) view returns (uint256 poseidonHash).function hinkalHelper() view returns (address).function logarithm2(uint256 x) pure returns (uint256 y).function m_index() view returns (uint256).function nullifiers(uint256) view returns (bool).function onERC1155BatchReceived(address, address, uint256[], uint256[], bytes) pure returns (bytes4).function onERC1155Received(address, address, uint256, uint256, bytes) pure returns (bytes4).function onERC721Received(address, address, uint256, bytes) pure returns (bytes4).function owner() view returns (address).function pendingOwner() view returns (address).function poseidon2() view returns (address).function poseidon4() view returns (address).function prooflessDeposit(address[] erc20Addresses, uint256[] amounts, tuple(uint256 H0x, uint256 H0y, uint256 H1x, uint256 H1y, uint256 stealthAddress)[] stealthAddressStructures, bytes[] onChainEncryptedOutputs, bool createBlockedUtxos, string orderId) payable.function registerExternalAction(uint256 externalActionId, address externalActionAddress).function registerVerifiers(uint256[] verifierIds, address[] verifierAddresses).function removeVerifier(uint256 verifierId).function renounceOwnership() view.function renounceRole(bytes32 role, address account).function revokeRole(bytes32 role, address account).function rootHashExists(uint256 _root, uint256 _rootIndex) view returns (bool).function roots(uint256) view returns (uint256).function setHinkalHelper(address _hinkalHelper).function supportsInterface(bytes4 interfaceId) view returns (bool).function transact(uint256[2] a, uint256[2][2] b, uint256[2] c, tuple(uint16 tokenNumber, uint16 nullifierAmount, uint16 outputAmount) dimensions, tuple(uint256 rootHashHinkal, uint256 rootHashHinkalIndex, address[] erc20TokenAddresses, int256[] amountChanges, uint256[][] inputNullifiers, uint256[][] outCommitments, bytes[][] encryptedOutputs, bytes onChainEncryptedOutput, bool[] onChainCreation, int256[] slippageValues, tuple(address feeToken, uint256 flatFee, uint256 variableRate) feeStructure, tuple(uint256 H0x, uint256 H0y, uint256 H1x, uint256 H1y, uint256 stealthAddress) stealthAddressStructure, uint256 timeStamp, uint256 calldataHash, uint256 emporiumMessage, uint16 publicSignalCount, address relay, tuple(address externalAddress, uint256 externalActionId, bytes externalActionMetadata) externalActionData, tuple(address preHookContract, address postHookContract, bytes preHookMetadata, bytes postHookMetadata) hookData, address originalSender, bytes extraData) circomData) payable.function transferOwnership(address newOwner).function tree(uint256) view returns (uint256).function verifierMap(uint256) view returns (address)`.split(`.`),hinkalHelperABI:[`constructor(address[] _initialRelays)`,`event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)`,`event RelayAdded(address relayAddress)`,`event RelayRemoved(address relayAddress)`,`function MAX_AMOUNT() view returns (int256)`,`function addRelay(address _relayAddress)`,`function calculateRelayFee(uint256 balance, uint256 flatFee, uint256 variableRate) pure returns (uint256 relayFee)`,`function getRelayStore() view returns (address[])`,`function hinkalAddress() view returns (address)`,`function isRelayInList(address relayAddress) view returns (bool)`,`function owner() view returns (address)`,`function performHinkalChecks(tuple(uint256 rootHashHinkal, uint256 rootHashHinkalIndex, address[] erc20TokenAddresses, int256[] amountChanges, uint256[][] inputNullifiers, uint256[][] outCommitments, bytes[][] encryptedOutputs, bytes onChainEncryptedOutput, bool[] onChainCreation, int256[] slippageValues, tuple(address feeToken, uint256 flatFee, uint256 variableRate) feeStructure, tuple(uint256 H0x, uint256 H0y, uint256 H1x, uint256 H1y, uint256 stealthAddress) stealthAddressStructure, uint256 timeStamp, uint256 calldataHash, uint256 emporiumMessage, uint16 publicSignalCount, address relay, tuple(address externalAddress, uint256 externalActionId, bytes externalActionMetadata) externalActionData, tuple(address preHookContract, address postHookContract, bytes preHookMetadata, bytes postHookMetadata) hookData, address originalSender, bytes extraData) circomData, tuple(uint16 tokenNumber, uint16 nullifierAmount, uint16 outputAmount) dimensions, address sender) view returns (uint256[])`,`function performProoflessDepositChecks(address[] erc20Addresses, uint256[] amounts, tuple(uint256 H0x, uint256 H0y, uint256 H1x, uint256 H1y, uint256 stealthAddress)[] stealthAddressStructures, bytes[] onChainEncryptedOutputs) view`,`function performSideEffects(tuple(uint256 rootHashHinkal, uint256 rootHashHinkalIndex, address[] erc20TokenAddresses, int256[] amountChanges, uint256[][] inputNullifiers, uint256[][] outCommitments, bytes[][] encryptedOutputs, bytes onChainEncryptedOutput, bool[] onChainCreation, int256[] slippageValues, tuple(address feeToken, uint256 flatFee, uint256 variableRate) feeStructure, tuple(uint256 H0x, uint256 H0y, uint256 H1x, uint256 H1y, uint256 stealthAddress) stealthAddressStructure, uint256 timeStamp, uint256 calldataHash, uint256 emporiumMessage, uint16 publicSignalCount, address relay, tuple(address externalAddress, uint256 externalActionId, bytes externalActionMetadata) externalActionData, tuple(address preHookContract, address postHookContract, bytes preHookMetadata, bytes postHookMetadata) hookData, address originalSender, bytes extraData))`,`function relayList(address) view returns (bool)`,`function relayStore(uint256) view returns (address)`,`function removeRelay(address _relayAddress)`,`function renounceOwnership()`,`function setHinkalAddress(address _hinkalAddress)`,`function transferOwnership(address newOwner)`],hinkalWrapperABI:[`constructor(address _hinkal)`,`event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner)`,`event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)`,`function acceptOwnership()`,`function onERC1155BatchReceived(address, address, uint256[], uint256[], bytes) pure returns (bytes4)`,`function onERC1155Received(address, address, uint256, uint256, bytes) pure returns (bytes4)`,`function onERC721Received(address, address, uint256, bytes) pure returns (bytes4)`,`function owner() view returns (address)`,`function pendingOwner() view returns (address)`,`function prooflessDeposit(address[] erc20Addresses, uint256[] amounts, tuple(uint256 H0x, uint256 H0y, uint256 H1x, uint256 H1y, uint256 stealthAddress)[] stealthAddressStructures, bytes[] onChainEncryptedOutputs, bool createBlockedUtxos, tuple(address feeRecipient, address feeToken, uint256 feeAmount) feeStructure, string orderId) payable`,`function renounceOwnership() view`,`function setHinkalAddress(address _hinkal)`,`function supportsInterface(bytes4 _interfaceId) view returns (bool)`,`function transferOwnership(address newOwner)`]},sp={hinkalIdl:JSON.parse(`{"address":"8LLNFE62Lr9rJLvmPsTsFttrcmwYrEykZwvpyYDW4Nc2","metadata":{"name":"hinkal","version":"0.1.0","spec":"0.1.0","description":"Created with Anchor"},"instructions":[{"name":"accept_ownership","discriminator":[172,23,43,13,238,213,85,150],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"original_deployer"},{"name":"storage_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108]},{"kind":"account","path":"original_deployer"}]}}],"args":[]},{"name":"close_nullifier","discriminator":[162,69,214,3,121,155,58,219],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"original_deployer"},{"name":"nullifier_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,110,117,108,108,105,102,105,101,114]},{"kind":"account","path":"original_deployer"},{"kind":"arg","path":"nullifier"}]}},{"name":"storage_account","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108]},{"kind":"account","path":"original_deployer"}]}},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"nullifier","type":{"array":["u8",32]}}]},{"name":"init_nullifier","discriminator":[187,124,88,139,111,232,162,236],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"original_deployer"},{"name":"nullifier_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,110,117,108,108,105,102,105,101,114]},{"kind":"account","path":"original_deployer"},{"kind":"arg","path":"nullifier"}]}},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"nullifier","type":{"array":["u8",32]}}]},{"name":"initialize","discriminator":[175,175,109,31,13,152,155,237],"accounts":[{"name":"original_deployer","writable":true,"signer":true},{"name":"storage_vault","docs":["zero-length PDA owned by the system program that only stores lamports"],"writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,118,97,117,108,116]},{"kind":"account","path":"original_deployer"}]}},{"name":"merkle_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,109,101,114,107,108,101]},{"kind":"account","path":"original_deployer"}]}},{"name":"storage_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108]},{"kind":"account","path":"original_deployer"}]}},{"name":"rent","address":"SysvarRent111111111111111111111111111111111"},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[]},{"name":"multi_payment_deposit","discriminator":[70,64,60,132,3,67,69,74],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"original_deployer"},{"name":"storage_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108]},{"kind":"account","path":"original_deployer"}]}},{"name":"storage_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,118,97,117,108,116]},{"kind":"account","path":"original_deployer"}]}},{"name":"mint","optional":true},{"name":"signer_ata","writable":true,"optional":true,"pda":{"seeds":[{"kind":"account","path":"signer"},{"kind":"const","value":[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{"kind":"account","path":"mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"storage_vault_ata","writable":true,"optional":true,"pda":{"seeds":[{"kind":"account","path":"storage_vault"},{"kind":"const","value":[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{"kind":"account","path":"mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"merkle_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,109,101,114,107,108,101]},{"kind":"account","path":"original_deployer"}]}},{"name":"root_bucket_current","writable":true},{"name":"root_bucket_next","writable":true,"optional":true},{"name":"token_program","address":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"amounts","type":{"vec":"u64"}},{"name":"stealth_address_structure","type":{"vec":{"defined":{"name":"StealthAddressStructure"}}}},{"name":"encrypted_blobs","type":{"vec":"bytes"}},{"name":"create_blocked_utxos","type":"bool"}]},{"name":"proofless_deposit","discriminator":[238,63,30,216,109,36,109,123],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"original_deployer"},{"name":"storage_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108]},{"kind":"account","path":"original_deployer"}]}},{"name":"storage_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,118,97,117,108,116]},{"kind":"account","path":"original_deployer"}]}},{"name":"mint","optional":true},{"name":"signer_ata","writable":true,"optional":true,"pda":{"seeds":[{"kind":"account","path":"signer"},{"kind":"const","value":[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{"kind":"account","path":"mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"storage_vault_ata","writable":true,"optional":true,"pda":{"seeds":[{"kind":"account","path":"storage_vault"},{"kind":"const","value":[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{"kind":"account","path":"mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"merkle_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,109,101,114,107,108,101]},{"kind":"account","path":"original_deployer"}]}},{"name":"root_bucket_current","writable":true},{"name":"root_bucket_next","writable":true,"optional":true},{"name":"token_program","address":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"amount","type":"u64"},{"name":"stealth_address_structure","type":{"defined":{"name":"StealthAddressStructure"}}},{"name":"encrypted_blob","type":"bytes"},{"name":"create_blocked_utxos","type":"bool"}]},{"name":"store_encrypted_outputs","discriminator":[119,158,243,225,12,25,29,85],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"original_deployer"},{"name":"encrypted_outputs_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,101,110,99,114,121,112,116,101,100,95,111,117,116,112,117,116,115]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"id","type":"u32"},{"name":"encrypted_output","type":"bytes"},{"name":"on_chain_encrypted_output","type":"bytes"},{"name":"output_index","type":"u8"},{"name":"output_count","type":"u8"}]},{"name":"store_instructions","discriminator":[74,235,173,153,203,64,250,122],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"original_deployer"},{"name":"instructions_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,105,110,115,116,114,117,99,116,105,111,110,115]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"id","type":"u32"},{"name":"instructions","type":{"vec":{"defined":{"name":"SolanaInstructionData"}}}}]},{"name":"store_proof_part1","discriminator":[174,144,197,114,7,196,154,191],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"original_deployer"},{"name":"proof_account_part1","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,112,114,111,111,102,95,112,97,114,116,49]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"id","type":"u32"},{"name":"proof_a_arr","type":{"array":["u8",64]}},{"name":"proof_b_arr","type":{"array":["u8",128]}},{"name":"proof_c_arr","type":{"array":["u8",64]}},{"name":"public_signals_part1","type":{"vec":{"array":["u8",32]}}}]},{"name":"store_proof_part2","discriminator":[32,225,73,0,60,163,213,158],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"original_deployer"},{"name":"proof_account_part2","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,112,114,111,111,102,95,112,97,114,116,50]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"id","type":"u32"},{"name":"public_signals_part2","type":{"vec":{"array":["u8",32]}}}]},{"name":"swap2","discriminator":[65,75,63,76,235,91,91,136],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"swapper_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,115,119,97,112,112,101,114]},{"kind":"account","path":"original_deployer"},{"kind":"arg","path":"swapper_account_additional_seed"}]}},{"name":"original_deployer"},{"name":"storage_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108]},{"kind":"account","path":"original_deployer"}]}},{"name":"storage_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,118,97,117,108,116]},{"kind":"account","path":"original_deployer"}]}},{"name":"mint_from","optional":true},{"name":"mint_to","optional":true},{"name":"signer_to_ata","writable":true,"optional":true},{"name":"storage_vault_from_ata","writable":true,"optional":true},{"name":"storage_vault_to_ata","writable":true,"optional":true},{"name":"swapper_account_from_ata","writable":true,"optional":true},{"name":"swapper_account_to_ata","writable":true,"optional":true},{"name":"merkle_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,109,101,114,107,108,101]},{"kind":"account","path":"original_deployer"}]}},{"name":"root_bucket_verify","writable":true},{"name":"root_bucket_current","writable":true},{"name":"root_bucket_next","writable":true,"optional":true},{"name":"first_nullifier","writable":true,"optional":true},{"name":"second_nullifier","writable":true,"optional":true},{"name":"third_nullifier","writable":true,"optional":true},{"name":"fourth_nullifier","writable":true,"optional":true},{"name":"encrypted_outputs_account","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,101,110,99,114,121,112,116,101,100,95,111,117,116,112,117,116,115]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"proof_account_part1","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,112,114,111,111,102,95,112,97,114,116,49]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"proof_account_part2","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,112,114,111,111,102,95,112,97,114,116,50]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"instructions_account","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,105,110,115,116,114,117,99,116,105,111,110,115]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"token_program","address":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"event_authority","pda":{"seeds":[{"kind":"const","value":[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{"name":"program"}],"args":[{"name":"id","type":"u32"},{"name":"swapper_account_additional_seed","type":{"array":["u8",32]}},{"name":"in_nullifiers","type":{"vec":{"array":["u8",32]}}},{"name":"relayer_fee","type":"u64"},{"name":"variable_rate","type":"u64"},{"name":"dimensions","type":{"defined":{"name":"Dimensions"}}},{"name":"root_hash_index","type":{"array":["u8",32]}}]},{"name":"swap6","discriminator":[99,72,77,24,113,171,250,215],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"swapper_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,115,119,97,112,112,101,114]},{"kind":"account","path":"original_deployer"},{"kind":"arg","path":"swapper_account_additional_seed"}]}},{"name":"original_deployer"},{"name":"storage_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108]},{"kind":"account","path":"original_deployer"}]}},{"name":"storage_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,118,97,117,108,116]},{"kind":"account","path":"original_deployer"}]}},{"name":"mint_from","optional":true},{"name":"mint_to","optional":true},{"name":"signer_to_ata","writable":true,"optional":true},{"name":"storage_vault_from_ata","writable":true,"optional":true},{"name":"storage_vault_to_ata","writable":true,"optional":true},{"name":"swapper_account_from_ata","writable":true,"optional":true},{"name":"swapper_account_to_ata","writable":true,"optional":true},{"name":"merkle_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,109,101,114,107,108,101]},{"kind":"account","path":"original_deployer"}]}},{"name":"root_bucket_verify","writable":true},{"name":"root_bucket_current","writable":true},{"name":"root_bucket_next","writable":true,"optional":true},{"name":"first_nullifier","writable":true,"optional":true},{"name":"second_nullifier","writable":true,"optional":true},{"name":"third_nullifier","writable":true,"optional":true},{"name":"fourth_nullifier","writable":true,"optional":true},{"name":"fifth_nullifier","writable":true,"optional":true},{"name":"sixth_nullifier","writable":true,"optional":true},{"name":"seventh_nullifier","writable":true,"optional":true},{"name":"eighth_nullifier","writable":true,"optional":true},{"name":"nineth_nullifier","writable":true,"optional":true},{"name":"tenth_nullifier","writable":true,"optional":true},{"name":"eleventh_nullifier","writable":true,"optional":true},{"name":"twelveth_nullifier","writable":true,"optional":true},{"name":"encrypted_outputs_account","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,101,110,99,114,121,112,116,101,100,95,111,117,116,112,117,116,115]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"proof_account_part1","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,112,114,111,111,102,95,112,97,114,116,49]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"proof_account_part2","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,112,114,111,111,102,95,112,97,114,116,50]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"instructions_account","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,105,110,115,116,114,117,99,116,105,111,110,115]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"token_program","address":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{"name":"system_program","address":"11111111111111111111111111111111"},{"name":"event_authority","pda":{"seeds":[{"kind":"const","value":[95,95,101,118,101,110,116,95,97,117,116,104,111,114,105,116,121]}]}},{"name":"program"}],"args":[{"name":"id","type":"u32"},{"name":"swapper_account_additional_seed","type":{"array":["u8",32]}},{"name":"in_nullifiers","type":{"vec":{"array":["u8",32]}}},{"name":"relayer_fee","type":"u64"},{"name":"variable_rate","type":"u64"},{"name":"dimensions","type":{"defined":{"name":"Dimensions"}}},{"name":"root_hash_index","type":{"array":["u8",32]}}]},{"name":"transact2","discriminator":[147,170,237,9,83,181,181,81],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"recipient","writable":true},{"name":"original_deployer"},{"name":"storage_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108]},{"kind":"account","path":"original_deployer"}]}},{"name":"storage_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,118,97,117,108,116]},{"kind":"account","path":"original_deployer"}]}},{"name":"mint","optional":true},{"name":"signer_ata","writable":true,"optional":true,"pda":{"seeds":[{"kind":"account","path":"signer"},{"kind":"const","value":[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{"kind":"account","path":"mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"storage_vault_ata","writable":true,"optional":true,"pda":{"seeds":[{"kind":"account","path":"storage_vault"},{"kind":"const","value":[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{"kind":"account","path":"mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"recipient_ata","writable":true,"optional":true,"pda":{"seeds":[{"kind":"account","path":"recipient"},{"kind":"const","value":[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{"kind":"account","path":"mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"merkle_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,109,101,114,107,108,101]},{"kind":"account","path":"original_deployer"}]}},{"name":"root_bucket_verify","writable":true},{"name":"root_bucket_current","writable":true},{"name":"root_bucket_next","writable":true,"optional":true},{"name":"first_nullifier","writable":true,"optional":true},{"name":"second_nullifier","writable":true,"optional":true},{"name":"encrypted_outputs_account","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,101,110,99,114,121,112,116,101,100,95,111,117,116,112,117,116,115]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"proof_account_part1","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,112,114,111,111,102,95,112,97,114,116,49]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"proof_account_part2","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,112,114,111,111,102,95,112,97,114,116,50]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"token_program","address":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"id","type":"u32"},{"name":"forbid_deposit","type":"bool"},{"name":"in_nullifiers","type":{"vec":{"array":["u8",32]}}},{"name":"relayer_fee","type":"u64"},{"name":"dimensions","type":{"defined":{"name":"Dimensions"}}},{"name":"root_hash_index","type":{"array":["u8",32]}}]},{"name":"transact6","discriminator":[141,202,39,130,160,18,56,118],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"recipient","writable":true},{"name":"original_deployer"},{"name":"storage_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108]},{"kind":"account","path":"original_deployer"}]}},{"name":"storage_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,118,97,117,108,116]},{"kind":"account","path":"original_deployer"}]}},{"name":"mint","optional":true},{"name":"signer_ata","writable":true,"optional":true,"pda":{"seeds":[{"kind":"account","path":"signer"},{"kind":"const","value":[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{"kind":"account","path":"mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"storage_vault_ata","writable":true,"optional":true,"pda":{"seeds":[{"kind":"account","path":"storage_vault"},{"kind":"const","value":[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{"kind":"account","path":"mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"recipient_ata","writable":true,"optional":true,"pda":{"seeds":[{"kind":"account","path":"recipient"},{"kind":"const","value":[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{"kind":"account","path":"mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"merkle_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,109,101,114,107,108,101]},{"kind":"account","path":"original_deployer"}]}},{"name":"root_bucket_verify","writable":true},{"name":"root_bucket_current","writable":true},{"name":"root_bucket_next","writable":true,"optional":true},{"name":"first_nullifier","writable":true,"optional":true},{"name":"second_nullifier","writable":true,"optional":true},{"name":"third_nullifier","writable":true,"optional":true},{"name":"fourth_nullifier","writable":true,"optional":true},{"name":"fifth_nullifier","writable":true,"optional":true},{"name":"sixth_nullifier","writable":true,"optional":true},{"name":"encrypted_outputs_account","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,101,110,99,114,121,112,116,101,100,95,111,117,116,112,117,116,115]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"proof_account_part1","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,112,114,111,111,102,95,112,97,114,116,49]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"proof_account_part2","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,112,114,111,111,102,95,112,97,114,116,50]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"token_program","address":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"id","type":"u32"},{"name":"forbid_deposit","type":"bool"},{"name":"in_nullifiers","type":{"vec":{"array":["u8",32]}}},{"name":"relayer_fee","type":"u64"},{"name":"dimensions","type":{"defined":{"name":"Dimensions"}}},{"name":"root_hash_index","type":{"array":["u8",32]}}]},{"name":"transfer2","discriminator":[27,140,248,82,105,169,171,143],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"original_deployer"},{"name":"storage_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108]},{"kind":"account","path":"original_deployer"}]}},{"name":"storage_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,118,97,117,108,116]},{"kind":"account","path":"original_deployer"}]}},{"name":"mint","optional":true},{"name":"signer_ata","writable":true,"optional":true,"pda":{"seeds":[{"kind":"account","path":"signer"},{"kind":"const","value":[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{"kind":"account","path":"mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"storage_vault_ata","writable":true,"optional":true,"pda":{"seeds":[{"kind":"account","path":"storage_vault"},{"kind":"const","value":[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{"kind":"account","path":"mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"merkle_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,109,101,114,107,108,101]},{"kind":"account","path":"original_deployer"}]}},{"name":"root_bucket_verify","writable":true},{"name":"root_bucket_current","writable":true},{"name":"root_bucket_next","writable":true,"optional":true},{"name":"first_nullifier","writable":true,"optional":true},{"name":"second_nullifier","writable":true,"optional":true},{"name":"encrypted_outputs_account","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,101,110,99,114,121,112,116,101,100,95,111,117,116,112,117,116,115]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"proof_account_part1","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,112,114,111,111,102,95,112,97,114,116,49]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"proof_account_part2","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,112,114,111,111,102,95,112,97,114,116,50]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"token_program","address":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"id","type":"u32"},{"name":"in_nullifiers","type":{"vec":{"array":["u8",32]}}},{"name":"relayer_fee","type":"u64"},{"name":"dimensions","type":{"defined":{"name":"Dimensions"}}},{"name":"root_hash_index","type":{"array":["u8",32]}}]},{"name":"transfer6","discriminator":[181,146,34,243,187,199,220,67],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"original_deployer"},{"name":"storage_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108]},{"kind":"account","path":"original_deployer"}]}},{"name":"storage_vault","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,118,97,117,108,116]},{"kind":"account","path":"original_deployer"}]}},{"name":"mint","optional":true},{"name":"signer_ata","writable":true,"optional":true,"pda":{"seeds":[{"kind":"account","path":"signer"},{"kind":"const","value":[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{"kind":"account","path":"mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"storage_vault_ata","writable":true,"optional":true,"pda":{"seeds":[{"kind":"account","path":"storage_vault"},{"kind":"const","value":[6,221,246,225,215,101,161,147,217,203,225,70,206,235,121,172,28,180,133,237,95,91,55,145,58,140,245,133,126,255,0,169]},{"kind":"account","path":"mint"}],"program":{"kind":"const","value":[140,151,37,143,78,36,137,241,187,61,16,41,20,142,13,131,11,90,19,153,218,255,16,132,4,142,123,216,219,233,248,89]}}},{"name":"merkle_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,109,101,114,107,108,101]},{"kind":"account","path":"original_deployer"}]}},{"name":"root_bucket_verify","writable":true},{"name":"root_bucket_current","writable":true},{"name":"root_bucket_next","writable":true,"optional":true},{"name":"first_nullifier","writable":true,"optional":true},{"name":"second_nullifier","writable":true,"optional":true},{"name":"third_nullifier","writable":true,"optional":true},{"name":"fourth_nullifier","writable":true,"optional":true},{"name":"fifth_nullifier","writable":true,"optional":true},{"name":"sixth_nullifier","writable":true,"optional":true},{"name":"encrypted_outputs_account","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,101,110,99,114,121,112,116,101,100,95,111,117,116,112,117,116,115]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"proof_account_part1","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,112,114,111,111,102,95,112,97,114,116,49]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"proof_account_part2","pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108,95,112,114,111,111,102,95,112,97,114,116,50]},{"kind":"account","path":"original_deployer"},{"kind":"account","path":"signer"},{"kind":"arg","path":"id"}]}},{"name":"token_program","address":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{"name":"associated_token_program","address":"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"id","type":"u32"},{"name":"in_nullifiers","type":{"vec":{"array":["u8",32]}}},{"name":"relayer_fee","type":"u64"},{"name":"dimensions","type":{"defined":{"name":"Dimensions"}}},{"name":"root_hash_index","type":{"array":["u8",32]}}]},{"name":"transfer_ownership","discriminator":[65,177,215,73,53,45,99,47],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"original_deployer"},{"name":"storage_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108]},{"kind":"account","path":"original_deployer"}]}}],"args":[{"name":"new_owner","type":"pubkey"}]},{"name":"update_relayer_status","discriminator":[247,180,15,221,102,66,142,253],"accounts":[{"name":"signer","writable":true,"signer":true},{"name":"original_deployer"},{"name":"storage_account","writable":true,"pda":{"seeds":[{"kind":"const","value":[104,105,110,107,97,108]},{"kind":"account","path":"original_deployer"}]}},{"name":"relayer"},{"name":"system_program","address":"11111111111111111111111111111111"}],"args":[{"name":"status","type":"bool"}]}],"accounts":[{"name":"EncryptedOutputsAccount","discriminator":[38,153,140,49,115,38,136,21]},{"name":"InstructionsAccount","discriminator":[158,246,131,222,29,159,202,65]},{"name":"Merkle","discriminator":[55,52,102,252,195,69,204,210]},{"name":"NullifierAccount","discriminator":[250,31,238,177,213,98,48,172]},{"name":"ProofAccountPart1","discriminator":[227,231,205,87,22,154,112,114]},{"name":"ProofAccountPart2","discriminator":[84,185,22,128,59,14,111,158]},{"name":"StorageAccount","discriminator":[41,48,231,194,22,77,205,235]}],"events":[{"name":"BlockedUtxosCreated","discriminator":[64,214,216,215,75,156,106,107]},{"name":"NewCommitment","discriminator":[78,21,75,243,5,132,204,67]},{"name":"Nullified","discriminator":[124,69,200,64,75,203,121,17]},{"name":"OwnershipAccepted","discriminator":[60,223,46,198,226,73,39,18]},{"name":"OwnershipTransferred","discriminator":[172,61,205,183,250,50,38,98]},{"name":"RelayerStatusUpdated","discriminator":[47,132,241,182,171,89,127,242]}],"errors":[{"code":6000,"name":"InvalidMintConfiguration","msg":"Invalid combination of mint accounts supplied for swap."},{"code":6001,"name":"MissingMintFrom","msg":"Missing mint account for source leg."},{"code":6002,"name":"MissingMintTo","msg":"Missing mint account for destination leg."},{"code":6003,"name":"IdenticalTokenMints","msg":"Source and destination token mints cannot be identical."},{"code":6004,"name":"MissingStorageSourceAta","msg":"Missing storage vault source token ATA."},{"code":6005,"name":"MissingStorageDestinationAta","msg":"Missing storage vault destination token ATA."},{"code":6006,"name":"MissingSwapperSourceAta","msg":"Missing swapper account source token ATA."},{"code":6007,"name":"MissingSwapperDestinationAta","msg":"Missing swapper account destination token ATA."},{"code":6008,"name":"ReceivedAmountLowerThanExpected","msg":"Received amount lower than expected"},{"code":6009,"name":"ExpectedNegativeInputAmount","msg":"Expected negative input amount"},{"code":6010,"name":"ExpectedPositiveOutputAmount","msg":"Expected positive output amount"},{"code":6011,"name":"UnexpectedOnchainCreation","msg":"Unexpected onchain creation values specified"},{"code":6012,"name":"UnexpectedDimensions","msg":"Unexpected dimensions"},{"code":6013,"name":"ValueLargerThanCircomP","msg":"Value larger than circom P"},{"code":6014,"name":"UnsafeArithmetic","msg":"Unsafe arithmetic"},{"code":6015,"name":"FeeCalculationOverflow","msg":"Fee calculation overflow"},{"code":6016,"name":"InvalidPublicSignalsSize","msg":"Invalid public signals size for proof verification"},{"code":6017,"name":"UnsupportedDimensions","msg":"Unsupported dimensions for proof verification"},{"code":6018,"name":"NullifierAlreadyUsed","msg":"Cannot close a nullifier account that has already been used"},{"code":6019,"name":"Unauthorized","msg":"Unauthorized"},{"code":6020,"name":"CalldataHashMismatch","msg":"Calldata hash mismatch"},{"code":6021,"name":"SignedMessageHashMismatch","msg":"Signed message hash mismatch"},{"code":6022,"name":"RootHashDoesNotExist","msg":"Root hash doesn't exist"},{"code":6023,"name":"InvalidAmountChange","msg":"Invalid amount change"},{"code":6024,"name":"RelayerNotWhitelisted","msg":"Relayer account not whitelisted"},{"code":6025,"name":"ExpectedMintAddressZero","msg":"Expected mint address to be zero"},{"code":6026,"name":"ExpectedMintAddressNotZero","msg":"Expected mint address not to be zero"},{"code":6027,"name":"UnsupportedDimensionsError","msg":"Unsupported dimensions"},{"code":6028,"name":"InNullifiersLengthMismatch","msg":"In nullifiers length mismatch"},{"code":6029,"name":"InNullifierMismatch","msg":"In nullifier mismatch"},{"code":6030,"name":"PoseidonHashFailed","msg":"Poseidon hash failed"},{"code":6031,"name":"NullifierUsed","msg":"Nullifier used"},{"code":6032,"name":"NullifierNotZeroButAccountNotSpecified","msg":"Nullifier not zero, but account not specified"},{"code":6033,"name":"NullifierAccountsListLengthMustBeEven","msg":"Nullifier accounts list length must be even"},{"code":6034,"name":"OnChainCreationLengthMismatch","msg":"On chain creation length mismatch"},{"code":6035,"name":"EncryptedOutputsLengthMismatch","msg":"Encrypted outputs length mismatch"},{"code":6036,"name":"MissingOnChainEncryptedOutput","msg":"Missing encrypted output for on-chain commitment"},{"code":6037,"name":"EncryptedOutputTooLarge","msg":"Encrypted output byte length exceeds on-chain limit"},{"code":6038,"name":"EncryptedOutputsCountTooLarge","msg":"Too many encrypted outputs for on-chain account"},{"code":6039,"name":"EncryptedOutputIndexOutOfBounds","msg":"Encrypted output index out of bounds"},{"code":6040,"name":"ProofVerificationFailed","msg":"Proof verification failed"},{"code":6041,"name":"UnexpectedValue","msg":"Unexpected value"},{"code":6042,"name":"ATAValidationFailed","msg":"Associate token account validation failed"},{"code":6043,"name":"BalanceDiffMismatch","msg":"Balance Diff Should be equal to sum of onchain and offchain created commitments"},{"code":6044,"name":"ZeroRandomizationForbidden","msg":"Randomization cannot be zero"},{"code":6045,"name":"RemainingAccountSignerForbidden","msg":"Ramaining account signer forbidden"},{"code":6046,"name":"DepositForbidden","msg":"Deposit forbidden"},{"code":6047,"name":"SwapperAccountAdditionalSeedMismatch","msg":"Swapper account additional seed mismatch"},{"code":6048,"name":"InvalidVersion","msg":"Invalid Version"},{"code":6049,"name":"SelfCPIForbidden","msg":"Self-CPI forbidden"},{"code":6050,"name":"InvalidNullifierPDA","msg":"Invalid nullifier pda"},{"code":6051,"name":"DuplicateNullifier","msg":"Duplicate nullifier in proof"}],"types":[{"name":"BlockedUtxosCreated","type":{"kind":"struct","fields":[]}},{"name":"Dimensions","type":{"kind":"struct","fields":[{"name":"token_number","type":"u8"},{"name":"nullifier_amount","type":"u8"},{"name":"output_amount","type":"u8"}]}},{"name":"EncryptedOutputsAccount","type":{"kind":"struct","fields":[{"name":"version","type":"u8"},{"name":"encrypted_outputs","type":{"vec":"bytes"}},{"name":"on_chain_encrypted_output","type":"bytes"}]}},{"name":"InstructionsAccount","type":{"kind":"struct","fields":[{"name":"version","type":"u8"},{"name":"instructions","type":{"vec":{"defined":{"name":"SolanaInstructionData"}}}}]}},{"name":"Merkle","serialization":"bytemuck","repr":{"kind":"c"},"type":{"kind":"struct","fields":[{"name":"version","type":"u8"},{"name":"tree_levels","type":{"array":[{"array":["u8",32]},200]}},{"name":"m_index","type":{"array":["u8",32]}},{"name":"levels","type":{"array":["u8",16]}},{"name":"minimum_index","type":{"array":["u8",32]}}]}},{"name":"NewCommitment","type":{"kind":"struct","fields":[{"name":"commitment","type":{"array":["u8",32]}},{"name":"index","type":{"array":["u8",32]}},{"name":"encrypted_output","type":"bytes"},{"name":"on_chain_data","type":{"array":[{"array":["u8",32]},9]}}]}},{"name":"Nullified","type":{"kind":"struct","fields":[{"name":"nullifier","type":{"array":["u8",32]}}]}},{"name":"NullifierAccount","type":{"kind":"struct","fields":[{"name":"version","type":"u8"},{"name":"is_used","type":"bool"}]}},{"name":"OwnershipAccepted","type":{"kind":"struct","fields":[{"name":"previous_owner","type":"pubkey"},{"name":"new_owner","type":"pubkey"}]}},{"name":"OwnershipTransferred","type":{"kind":"struct","fields":[{"name":"previous_owner","type":"pubkey"},{"name":"new_pending_owner","type":"pubkey"}]}},{"name":"ProofAccountPart1","type":{"kind":"struct","fields":[{"name":"version","type":"u8"},{"name":"proof_a_arr","type":{"array":["u8",64]}},{"name":"proof_b_arr","type":{"array":["u8",128]}},{"name":"proof_c_arr","type":{"array":["u8",64]}},{"name":"public_signals_part1","type":{"vec":{"array":["u8",32]}}}]}},{"name":"ProofAccountPart2","type":{"kind":"struct","fields":[{"name":"version","type":"u8"},{"name":"public_signals_part2","type":{"vec":{"array":["u8",32]}}}]}},{"name":"RelayerStatusUpdated","type":{"kind":"struct","fields":[{"name":"relayer","type":"pubkey"},{"name":"status","type":"bool"}]}},{"name":"SolanaInstructionData","type":{"kind":"struct","fields":[{"name":"account_indexes","type":"bytes"},{"name":"data","type":"bytes"},{"name":"program_index","type":"u8"}]}},{"name":"StealthAddressStructure","type":{"kind":"struct","fields":[{"name":"h0_x","type":{"array":["u8",32]}},{"name":"h0_y","type":{"array":["u8",32]}},{"name":"h1_x","type":{"array":["u8",32]}},{"name":"h1_y","type":{"array":["u8",32]}},{"name":"stealth_address","type":{"array":["u8",32]}}]}},{"name":"StorageAccount","type":{"kind":"struct","fields":[{"name":"version","type":"u8"},{"name":"whitelisted_relayers","type":{"vec":"pubkey"}},{"name":"owner","type":"pubkey"},{"name":"pending_owner","type":"pubkey"}]}}]}`)},cp={hinkalABI:`constructor(tuple(uint128 levels) constructorArgs, address _hinkalHelper, address _hinkalHelperManager).event BlockedUtxosCreated().event ExternalActionRegistered(address externalActionAddress).event NewCommitment(uint256 commitment, int256 index, bytes encryptedOutput).event Nullified(uint256 nullifier).event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner).event OwnershipTransferred(address indexed previousOwner, address indexed newOwner).event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole).event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender).event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender).event VerifierRegistered(address verifierAddress).event VerifierRemoved(address verifierAddress).function DEFAULT_ADMIN_ROLE() view returns (bytes32).function HINKAL_HELPER_MANAGER() view returns (bytes32).function acceptOwnership().function buildVerifierId(tuple(uint16 tokenNumber, uint16 nullifierAmount, uint16 outputAmount) dimensions, uint256 externalActionId) pure returns (uint256).function externalActionMap(uint256) view returns (address).function getRoleAdmin(bytes32 role) view returns (bytes32).function getRootHash() view returns (uint256).function grantRole(bytes32 role, address account).function hasRole(bytes32 role, address account) view returns (bool).function hinkalHelper() view returns (address).function m_index() view returns (uint256).function nullifiers(uint256) view returns (bool).function owner() view returns (address).function pendingOwner() view returns (address).function registerExternalAction(uint256 externalActionId, address externalActionAddress).function registerVerifiers(address[] verifierAddresses).function removeVerifier(address verifier).function renounceOwnership() view.function renounceRole(bytes32 role, address account).function revokeRole(bytes32 role, address account).function rootHashExists(uint256 _root, uint256 _rootIndex) view returns (bool).function roots(uint256) view returns (uint256).function setHinkalHelper(address _hinkalHelper).function supportsInterface(bytes4 interfaceId) view returns (bool).function transact(tuple(uint8 v, bytes32 r, bytes32 s) proofSignature, uint256[2] a, uint256[2][2] b, uint256[2] c, tuple(uint16 tokenNumber, uint16 nullifierAmount, uint16 outputAmount) dimensions, tuple(uint256 rootHashHinkal, uint256 rootHashHinkalIndex, address[] erc20TokenAddresses, int256[] amountChanges, uint256 newRootHash, uint256[][] inputNullifiers, uint256[][] outCommitments, bytes[][] encryptedOutputs, int256[] slippageValues, tuple(address feeToken, uint256 flatFee, uint256 variableRate) feeStructure, uint256 timeStamp, uint256 calldataHash, uint256 emporiumMessage, uint16 publicSignalCount, address relay, tuple(address externalAddress, uint256 externalActionId, bytes externalActionMetadata) externalActionData, tuple(address preHookContract, address postHookContract, bytes preHookMetadata, bytes postHookMetadata) hookData, address originalSender, bytes extraData, uint256 insertedLeafIndex, bool createBlockedUtxos) circomData) payable.function transferOwnership(address newOwner).function verifierMap(address) view returns (bool)`.split(`.`),hinkalHelperABI:[`constructor(address[] _initialRelays)`,`event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)`,`event RelayAdded(address relayAddress)`,`event RelayRemoved(address relayAddress)`,`function MAX_AMOUNT() view returns (int256)`,`function addRelay(address _relayAddress)`,`function calculateRelayFee(uint256 balance, uint256 flatFee, uint256 variableRate) pure returns (uint256 relayFee)`,`function getRelayStore() view returns (address[])`,`function hinkalAddress() view returns (address)`,`function isRelayInList(address relayAddress) view returns (bool)`,`function owner() view returns (address)`,`function performHinkalChecks(tuple(uint256 rootHashHinkal, uint256 rootHashHinkalIndex, address[] erc20TokenAddresses, int256[] amountChanges, uint256 newRootHash, uint256[][] inputNullifiers, uint256[][] outCommitments, bytes[][] encryptedOutputs, int256[] slippageValues, tuple(address feeToken, uint256 flatFee, uint256 variableRate) feeStructure, uint256 timeStamp, uint256 calldataHash, uint256 emporiumMessage, uint16 publicSignalCount, address relay, tuple(address externalAddress, uint256 externalActionId, bytes externalActionMetadata) externalActionData, tuple(address preHookContract, address postHookContract, bytes preHookMetadata, bytes postHookMetadata) hookData, address originalSender, bytes extraData, uint256 insertedLeafIndex, bool createBlockedUtxos) circomData, tuple(uint16 tokenNumber, uint16 nullifierAmount, uint16 outputAmount) dimensions, address sender) view returns (uint256[])`,`function relayList(address) view returns (bool)`,`function relayStore(uint256) view returns (address)`,`function removeRelay(address _relayAddress)`,`function renounceOwnership()`,`function setHinkalAddress(address _hinkalAddress)`,`function transferOwnership(address newOwner)`]};const lp=e=>({...op,...e}),up=e=>({...ap(cp),...e}),dp=e=>({...sp,...e}),fp=lp(El),pp=lp(Dl),mp=lp(Ol),hp=lp(kl),gp=lp(Al),_p=lp(jl),vp=lp(Ml),yp=lp(Nl),bp=lp(Pl),xp=lp(Fl),Sp=lp(zl),Cp=up(Ll),wp=up(Rl),Tp=dp(Il),Q={polygon:137,arbMainnet:42161,ethMainnet:1,optimism:10,optimismTest:1010,base:8453,localhost:31337,arcTestnet:5042002,sepoliaTestnet:11155111,solanaMainnet:501,solanaLocalnet:102,tronNile:3448148188,tronLocalnet:103,tronMainnet:728126428,tempo:4217,bnbMainnet:56,avalanche:43114,cronos:25,monad:143,plasma:9745,ink:57073,hyperEvm:999};Q.ethMainnet;const $=ne?`X4IiEZsSzGOrJq8tzq7Y3`:`XzUgeU8YiIIzkD7j2GWnTsFUck7wGgK9`,Ep={[Q.ethMainnet]:{name:`Ethereum`,chainId:Q.ethMainnet,rpcUrl:`https://rpc.ankr.com/eth`,fetchRpcUrl:`https://eth-mainnet.g.alchemy.com/v2/${$}`,wsRpcUrl:`wss://eth-mainnet.g.alchemy.com/v2/${$}`,supported:!0,contractData:mp,priority:1,maxPageSize:9e5},[Q.arbMainnet]:{name:`Arbitrum`,chainId:Q.arbMainnet,rpcUrl:`https://endpoints.omniatech.io/v1/arbitrum/one/public`,fetchRpcUrl:`https://arb-mainnet.g.alchemy.com/v2/${$}`,wsRpcUrl:`wss://arb-mainnet.g.alchemy.com/v2/${$}`,supported:!0,contractData:fp,priority:2,maxPageSize:5e5},[Q.optimism]:{name:`Optimism`,chainId:Q.optimism,rpcUrl:`https://optimism-mainnet.infura.io/v3/c26b99456bb6464bb498926ff5162903`,fetchRpcUrl:`https://opt-mainnet.g.alchemy.com/v2/${$}`,wsRpcUrl:`wss://opt-mainnet.g.alchemy.com/v2/${$}`,supported:!0,contractData:hp,priority:3,maxPageSize:9e5},[Q.optimismTest]:{name:`Optimism Test`,chainId:Q.optimismTest,rpcUrl:`https://optimism-mainnet.infura.io/v3/c26b99456bb6464bb498926ff5162903`,fetchRpcUrl:`https://opt-mainnet.g.alchemy.com/v2/${$}`,wsRpcUrl:`wss://opt-mainnet.g.alchemy.com/v2/${$}`,supported:!0,contractData:gp,priority:3,maxPageSize:9e5},[Q.polygon]:{name:`Polygon`,chainId:Q.polygon,rpcUrl:`https://polygon-rpc.com`,fetchRpcUrl:`https://polygon-mainnet.g.alchemy.com/v2/${$}`,wsRpcUrl:`wss://polygon-mainnet.g.alchemy.com/v2/${$}`,supported:!0,contractData:_p,priority:4,maxPageSize:9e5},[Q.base]:{name:`Base`,chainId:Q.base,rpcUrl:`https://mainnet.base.org/`,fetchRpcUrl:`https://base-mainnet.g.alchemy.com/v2/${$}`,wsRpcUrl:`wss://base-mainnet.g.alchemy.com/v2/${$}`,supported:!0,contractData:vp,priority:7,maxPageSize:5e5},[Q.arcTestnet]:{name:`Arc Testnet`,chainId:Q.arcTestnet,rpcUrl:`https://arc-testnet.g.alchemy.com/v2/${$}`,fetchRpcUrl:`https://arc-testnet.g.alchemy.com/v2/${$}`,wsRpcUrl:`wss://arc-testnet.g.alchemy.com/v2/${$}`,supported:!0,contractData:bp,priority:8,maxPageSize:9999},[Q.solanaMainnet]:{name:`Solana`,chainId:Q.solanaMainnet,rpcUrl:`https://api.mainnet-beta.solana.com`,fetchRpcUrl:`https://mainnet.helius-rpc.com/?api-key=54ad9ec9-dad6-41de-b961-e3e8ea7a7188`,supported:!0,contractData:Tp,priority:8},[Q.solanaLocalnet]:{name:`Solana Localnet`,chainId:Q.solanaLocalnet,rpcUrl:`http://127.0.0.1:8899`,fetchRpcUrl:`http://127.0.0.1:8899`,supported:!0,contractData:Tp,priority:9},[Q.tronNile]:{name:`Tron Nile`,chainId:Q.tronNile,rpcUrl:`https://tron-testnet.g.alchemy.com/v2/${$}`,fetchRpcUrl:`https://tron-testnet.g.alchemy.com/v2/${$}`,supported:!0,contractData:Cp,priority:9,maxPageSize:5e5},[Q.tronMainnet]:{name:`Tron`,chainId:Q.tronMainnet,rpcUrl:`https://tron-mainnet.g.alchemy.com/v2/${$}`,fetchRpcUrl:`https://tron-mainnet.g.alchemy.com/v2/${$}`,supported:!0,priority:10,contractData:wp,maxPageSize:5e5},[Q.sepoliaTestnet]:{name:`Sepolia Testnet`,chainId:Q.sepoliaTestnet,rpcUrl:`https://eth-sepolia.g.alchemy.com/v2/${$}`,fetchRpcUrl:`https://eth-sepolia.g.alchemy.com/v2/${$}`,supported:!0,priority:11,contractData:xp,maxPageSize:9e5},[Q.tempo]:{name:`Tempo`,chainId:Q.tempo,rpcUrl:`https://rpc.tempo.xyz`,fetchRpcUrl:`https://rpc.tempo.xyz`,supported:!0,priority:12,contractData:Sp,maxPageSize:9999},[Q.bnbMainnet]:{name:`BNB Chain`,chainId:Q.bnbMainnet,rpcUrl:`https://bnb-mainnet.g.alchemy.com/v2/${$}`,fetchRpcUrl:`https://bnb-mainnet.g.alchemy.com/v2/${$}`,wsRpcUrl:`wss://bnb-mainnet.g.alchemy.com/v2/${$}`,supported:!0,contractData:pp,priority:13,maxPageSize:9e5},[Q.avalanche]:{name:`Avalanche`,chainId:Q.avalanche,rpcUrl:`https://api.avax.network/ext/bc/C/rpc`,fetchRpcUrl:`https://api.avax.network/ext/bc/C/rpc`,supported:!1,contractData:{},priority:14},[Q.cronos]:{name:`Cronos`,chainId:Q.cronos,rpcUrl:`https://evm.cronos.org`,fetchRpcUrl:`https://evm.cronos.org`,supported:!1,contractData:{},priority:15},[Q.monad]:{name:`Monad`,chainId:Q.monad,rpcUrl:`https://rpc.monad.xyz`,fetchRpcUrl:`https://rpc.monad.xyz`,supported:!1,contractData:{},priority:16},[Q.plasma]:{name:`Plasma`,chainId:Q.plasma,rpcUrl:`https://rpc.plasma.to`,fetchRpcUrl:`https://rpc.plasma.to`,supported:!1,contractData:{},priority:17},[Q.ink]:{name:`Ink`,chainId:Q.ink,rpcUrl:`https://rpc-gel.inkonchain.com`,fetchRpcUrl:`https://rpc-gel.inkonchain.com`,supported:!1,contractData:{},priority:18},[Q.hyperEvm]:{name:`HyperEVM`,chainId:Q.hyperEvm,rpcUrl:`https://rpc.hyperliquid.xyz/evm`,fetchRpcUrl:`https://rpc.hyperliquid.xyz/evm`,supported:!1,contractData:{},priority:19}},Dp={name:`Localhost`,chainId:Q.localhost,rpcUrl:`http://127.0.0.1:8545`,fetchRpcUrl:`http://127.0.0.1:8545`,supported:!0,contractData:yp,priority:7};I&&(Ep[Q.localhost]=Dp),Tl.Mainnet,Q.polygon,Q.arbMainnet,Q.ethMainnet,Q.bnbMainnet,Q.optimism,Q.base,Q.tronMainnet,Q.tempo,Q.solanaMainnet,Q.avalanche,Q.cronos,Q.monad,Q.plasma,Q.ink,Q.hyperEvm,Tl.Testnet,ne?(Q.arcTestnet,Q.tronNile,Q.sepoliaTestnet,Q.optimismTest):(Q.arcTestnet,Q.sepoliaTestnet),Tl.Local,Q.localhost,Q.solanaLocalnet,Q.tronLocalnet;const Op=[Q.tronNile,Q.tronMainnet,Q.tronLocalnet],kp=[Q.solanaMainnet,Q.solanaLocalnet],Ap=e=>kp.includes(e),jp=e=>Op.includes(e),Mp=e=>e===Q.sepoliaTestnet,Np=e=>e===Q.tempo,Pp=e=>e===Q.arcTestnet;let Fp=ne?Q.tronNile:Q.tronMainnet;const Ip=Q.solanaMainnet,Lp=[Q.ethMainnet,Q.base,Q.polygon,Q.arbMainnet,Q.bnbMainnet,Q.arcTestnet,Ip,Q.tronMainnet,Q.tronNile,Q.tempo],Rp=[...Lp.filter(e=>!jp(e)),Fp];Lp.filter(e=>!jp(e)&&!Mp(e)&&!Np(e)&&!Pp(e));const zp=[Q.sepoliaTestnet];Rp.filter(e=>!zp.includes(e));const Bp=Lp.filter(e=>e!==Q.arcTestnet&&!Mp(e)&&!(jp(e)&&e!==Q.tronMainnet)),Vp=[Q.avalanche,Q.cronos,Q.monad,Q.plasma,Q.ink,Q.hyperEvm];[...Bp,...Vp],Lp.filter(e=>!Ap(e)&&!jp(e)),Bp.filter(e=>!Ap(e)&&!jp(e)),wl.Wallet,wl.Pay,wl.Bridge,wl.Dashboard,Q.arcTestnet,Q.arcTestnet,Q.sepoliaTestnet;const Hp=new o,Up=async e=>new Uint8Array(await Cl.get(e,{responseType:`arraybuffer`})),Wp=async e=>{try{let{input:t,wasmFilePath:n,zKeyFilePath:r,chainId:i}=e.payload.data,{hostLocation:{origin:o},constants:{isDevelopment:s,chains:{chainIds:c}}}=e.metadata,l=n,u=r,d,f,p=l.startsWith(`https://`);if(M&&!p){N?(l=`libs/hardhat/test/circuits/${n}`,u=`libs/hardhat/test/circuits/${r}`):!N&&s&&(i===Q.solanaLocalnet?(l=`tests/circuits/${n}`,u=`tests/circuits/${r}`):(l=`test/circuits/${n}`,u=`test/circuits/${r}`));let e=a();l=e.resolve(l),u=e.resolve(u);let t=a();d=await t.promises.readFile(l),f=await t.promises.readFile(u)}M&&p?(d=await Up(l),f=await Up(u)):(i===c.localhost||i===Q.solanaLocalnet||i===c.tronLocalnet)&&!M&&(l=`${o}/${n}`,u=`${o}/${r}`);let{proof:m,publicSignals:h}=await ma.fullProve(t,d??l,f??u,void 0,void 0,M?{singleThread:!0}:void 0),g=await ma.exportSolidityCallData(m,h),_=JSON.parse(`[${g}]`);Hp.postMessageToMainThread({zkCallData:_,proof:m,publicSignals:h})}catch(e){console.error(e),Hp.postErrorToMainThread(e)}};export{Wp as onWorkerMessage};
|