@sentio/sdk 2.57.11 → 2.57.12-rc.aaa
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/lib/aptos/ext/token.d.ts.map +1 -1
- package/lib/aptos/ext/token.js +4 -6
- package/lib/aptos/ext/token.js.map +1 -1
- package/lib/chunk-24EEMT46.js +3 -0
- package/lib/chunk-24EEMT46.js.map +1 -0
- package/lib/chunk-2R7O6UGY.js +3 -0
- package/lib/chunk-2R7O6UGY.js.map +1 -0
- package/lib/chunk-4JXRK4YH.js +29 -0
- package/lib/chunk-4JXRK4YH.js.map +1 -0
- package/lib/chunk-7QZC3R57.js +3 -0
- package/lib/chunk-7QZC3R57.js.map +1 -0
- package/lib/chunk-AK5E6DKD.js +6 -0
- package/lib/chunk-AK5E6DKD.js.map +1 -0
- package/lib/chunk-ATZBHPQN.js +3 -0
- package/lib/chunk-ATZBHPQN.js.map +1 -0
- package/lib/chunk-B6U7F4GY.js +29 -0
- package/lib/chunk-B6U7F4GY.js.map +1 -0
- package/lib/chunk-DGKULIPW.js +3 -0
- package/lib/chunk-DGKULIPW.js.map +1 -0
- package/lib/chunk-DS2LOABN.js +3 -0
- package/lib/chunk-DS2LOABN.js.map +1 -0
- package/lib/chunk-FMBGZMT4.js +6 -0
- package/lib/chunk-FMBGZMT4.js.map +1 -0
- package/lib/chunk-FMZDKD72.js +8 -0
- package/lib/chunk-FMZDKD72.js.map +1 -0
- package/lib/chunk-G5BIPHMS.js +3 -0
- package/lib/chunk-G5BIPHMS.js.map +1 -0
- package/lib/chunk-G6XPDWDE.js +3 -0
- package/lib/chunk-G6XPDWDE.js.map +1 -0
- package/lib/chunk-GJX3DL4J.js +499 -0
- package/lib/chunk-GJX3DL4J.js.map +1 -0
- package/lib/chunk-GTITFWMU.js +259 -0
- package/lib/chunk-GTITFWMU.js.map +1 -0
- package/lib/chunk-J7Z2TKQE.js +33 -0
- package/lib/chunk-J7Z2TKQE.js.map +1 -0
- package/lib/chunk-JQ4LTUIX.js +995 -0
- package/lib/chunk-JQ4LTUIX.js.map +1 -0
- package/lib/chunk-LG2TF5WR.js +8 -0
- package/lib/chunk-LG2TF5WR.js.map +1 -0
- package/lib/chunk-LVWOFGF2.js +3 -0
- package/lib/chunk-LVWOFGF2.js.map +1 -0
- package/lib/chunk-O564J2U6.js +11 -0
- package/lib/chunk-O564J2U6.js.map +1 -0
- package/lib/chunk-QGIFUSFI.js +84 -0
- package/lib/chunk-QGIFUSFI.js.map +1 -0
- package/lib/chunk-QGPJOTWP.js +3 -0
- package/lib/chunk-QGPJOTWP.js.map +1 -0
- package/lib/chunk-RA75ESSD.js +3 -0
- package/lib/chunk-RA75ESSD.js.map +1 -0
- package/lib/chunk-RVAYZJ7X.js +5 -0
- package/lib/chunk-RVAYZJ7X.js.map +1 -0
- package/lib/chunk-SPY3PKUB.js +3 -0
- package/lib/chunk-SPY3PKUB.js.map +1 -0
- package/lib/chunk-SUCYR7EB.js +3 -0
- package/lib/chunk-SUCYR7EB.js.map +1 -0
- package/lib/chunk-TGIXVAHB.js +7 -0
- package/lib/chunk-TGIXVAHB.js.map +1 -0
- package/lib/chunk-TSEQGMTN.js +5 -0
- package/lib/chunk-TSEQGMTN.js.map +1 -0
- package/lib/chunk-ZHI6ULD5.js +3 -0
- package/lib/chunk-ZHI6ULD5.js.map +1 -0
- package/lib/multipart-parser-J6QPYJHT.js +4 -0
- package/lib/multipart-parser-J6QPYJHT.js.map +1 -0
- package/package.json +4 -4
- package/src/aptos/builtin/0x1.d.ts +6451 -0
- package/src/aptos/builtin/0x1.d.ts.map +1 -0
- package/src/aptos/builtin/0x1.js +7138 -0
- package/src/aptos/builtin/0x1.js.map +1 -0
- package/src/aptos/builtin/0x3.d.ts +1122 -0
- package/src/aptos/builtin/0x3.d.ts.map +1 -0
- package/src/aptos/builtin/0x3.js +937 -0
- package/src/aptos/builtin/0x3.js.map +1 -0
- package/src/aptos/builtin/0x4.d.ts +551 -0
- package/src/aptos/builtin/0x4.d.ts.map +1 -0
- package/src/aptos/builtin/0x4.js +529 -0
- package/src/aptos/builtin/0x4.js.map +1 -0
- package/src/aptos/builtin/index.d.ts +4 -0
- package/src/aptos/builtin/index.d.ts.map +1 -0
- package/src/aptos/builtin/index.js +7 -0
- package/src/aptos/builtin/index.js.map +1 -0
- package/src/aptos/ext/token.ts +4 -6
- package/src/eth/builtin/eacaggregatorproxy.d.ts +5 -0
- package/src/eth/builtin/eacaggregatorproxy.d.ts.map +1 -0
- package/src/eth/builtin/eacaggregatorproxy.js +8 -0
- package/src/eth/builtin/eacaggregatorproxy.js.map +1 -0
- package/src/eth/builtin/erc1155.d.ts +5 -0
- package/src/eth/builtin/erc1155.d.ts.map +1 -0
- package/src/eth/builtin/erc1155.js +8 -0
- package/src/eth/builtin/erc1155.js.map +1 -0
- package/src/eth/builtin/erc20.d.ts +5 -0
- package/src/eth/builtin/erc20.d.ts.map +1 -0
- package/src/eth/builtin/erc20.js +8 -0
- package/src/eth/builtin/erc20.js.map +1 -0
- package/src/eth/builtin/erc20bytes.d.ts +5 -0
- package/src/eth/builtin/erc20bytes.d.ts.map +1 -0
- package/src/eth/builtin/erc20bytes.js +8 -0
- package/src/eth/builtin/erc20bytes.js.map +1 -0
- package/src/eth/builtin/erc721.d.ts +5 -0
- package/src/eth/builtin/erc721.d.ts.map +1 -0
- package/src/eth/builtin/erc721.js +8 -0
- package/src/eth/builtin/erc721.js.map +1 -0
- package/src/eth/builtin/index.d.ts +13 -0
- package/src/eth/builtin/index.d.ts.map +1 -0
- package/src/eth/builtin/index.js +16 -0
- package/src/eth/builtin/index.js.map +1 -0
- package/src/eth/builtin/internal/EACAggregatorProxy.d.ts +50 -0
- package/src/eth/builtin/internal/EACAggregatorProxy.d.ts.map +1 -0
- package/src/eth/builtin/internal/EACAggregatorProxy.js +2 -0
- package/src/eth/builtin/internal/EACAggregatorProxy.js.map +1 -0
- package/src/eth/builtin/internal/ERC1155.d.ts +57 -0
- package/src/eth/builtin/internal/ERC1155.d.ts.map +1 -0
- package/src/eth/builtin/internal/ERC1155.js +2 -0
- package/src/eth/builtin/internal/ERC1155.js.map +1 -0
- package/src/eth/builtin/internal/ERC20.d.ts +41 -0
- package/src/eth/builtin/internal/ERC20.d.ts.map +1 -0
- package/src/eth/builtin/internal/ERC20.js +2 -0
- package/src/eth/builtin/internal/ERC20.js.map +1 -0
- package/src/eth/builtin/internal/ERC20Bytes.d.ts +32 -0
- package/src/eth/builtin/internal/ERC20Bytes.d.ts.map +1 -0
- package/src/eth/builtin/internal/ERC20Bytes.js +2 -0
- package/src/eth/builtin/internal/ERC20Bytes.js.map +1 -0
- package/src/eth/builtin/internal/ERC721.d.ts +43 -0
- package/src/eth/builtin/internal/ERC721.d.ts.map +1 -0
- package/src/eth/builtin/internal/ERC721.js +2 -0
- package/src/eth/builtin/internal/ERC721.js.map +1 -0
- package/src/eth/builtin/internal/WETH9.d.ts +47 -0
- package/src/eth/builtin/internal/WETH9.d.ts.map +1 -0
- package/src/eth/builtin/internal/WETH9.js +2 -0
- package/src/eth/builtin/internal/WETH9.js.map +1 -0
- package/src/eth/builtin/internal/common.d.ts +3 -0
- package/src/eth/builtin/internal/common.d.ts.map +1 -0
- package/src/eth/builtin/internal/common.js +8 -0
- package/src/eth/builtin/internal/common.js.map +1 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +373 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.js +1355 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-test-utils.d.ts +7 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-test-utils.d.ts.map +1 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-test-utils.js +55 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-test-utils.js.map +1 -0
- package/src/eth/builtin/internal/erc1155-processor.d.ts +173 -0
- package/src/eth/builtin/internal/erc1155-processor.d.ts.map +1 -0
- package/src/eth/builtin/internal/erc1155-processor.js +596 -0
- package/src/eth/builtin/internal/erc1155-processor.js.map +1 -0
- package/src/eth/builtin/internal/erc1155-test-utils.d.ts +7 -0
- package/src/eth/builtin/internal/erc1155-test-utils.d.ts.map +1 -0
- package/src/eth/builtin/internal/erc1155-test-utils.js +55 -0
- package/src/eth/builtin/internal/erc1155-test-utils.js.map +1 -0
- package/src/eth/builtin/internal/erc20-processor.d.ts +244 -0
- package/src/eth/builtin/internal/erc20-processor.d.ts.map +1 -0
- package/src/eth/builtin/internal/erc20-processor.js +1109 -0
- package/src/eth/builtin/internal/erc20-processor.js.map +1 -0
- package/src/eth/builtin/internal/erc20-test-utils.d.ts +6 -0
- package/src/eth/builtin/internal/erc20-test-utils.d.ts.map +1 -0
- package/src/eth/builtin/internal/erc20-test-utils.js +44 -0
- package/src/eth/builtin/internal/erc20-test-utils.js.map +1 -0
- package/src/eth/builtin/internal/erc20bytes-processor.d.ts +144 -0
- package/src/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -0
- package/src/eth/builtin/internal/erc20bytes-processor.js +594 -0
- package/src/eth/builtin/internal/erc20bytes-processor.js.map +1 -0
- package/src/eth/builtin/internal/erc20bytes-test-utils.d.ts +5 -0
- package/src/eth/builtin/internal/erc20bytes-test-utils.d.ts.map +1 -0
- package/src/eth/builtin/internal/erc20bytes-test-utils.js +33 -0
- package/src/eth/builtin/internal/erc20bytes-test-utils.js.map +1 -0
- package/src/eth/builtin/internal/erc721-processor.d.ts +215 -0
- package/src/eth/builtin/internal/erc721-processor.d.ts.map +1 -0
- package/src/eth/builtin/internal/erc721-processor.js +895 -0
- package/src/eth/builtin/internal/erc721-processor.js.map +1 -0
- package/src/eth/builtin/internal/erc721-test-utils.d.ts +6 -0
- package/src/eth/builtin/internal/erc721-test-utils.d.ts.map +1 -0
- package/src/eth/builtin/internal/erc721-test-utils.js +44 -0
- package/src/eth/builtin/internal/erc721-test-utils.js.map +1 -0
- package/src/eth/builtin/internal/factories/EACAggregatorProxy__factory.d.ts +400 -0
- package/src/eth/builtin/internal/factories/EACAggregatorProxy__factory.d.ts.map +1 -0
- package/src/eth/builtin/internal/factories/EACAggregatorProxy__factory.js +524 -0
- package/src/eth/builtin/internal/factories/EACAggregatorProxy__factory.js.map +1 -0
- package/src/eth/builtin/internal/factories/ERC1155__factory.d.ts +251 -0
- package/src/eth/builtin/internal/factories/ERC1155__factory.d.ts.map +1 -0
- package/src/eth/builtin/internal/factories/ERC1155__factory.js +329 -0
- package/src/eth/builtin/internal/factories/ERC1155__factory.js.map +1 -0
- package/src/eth/builtin/internal/factories/ERC20Bytes__factory.d.ts +185 -0
- package/src/eth/builtin/internal/factories/ERC20Bytes__factory.d.ts.map +1 -0
- package/src/eth/builtin/internal/factories/ERC20Bytes__factory.js +251 -0
- package/src/eth/builtin/internal/factories/ERC20Bytes__factory.js.map +1 -0
- package/src/eth/builtin/internal/factories/ERC20__factory.d.ts +303 -0
- package/src/eth/builtin/internal/factories/ERC20__factory.d.ts.map +1 -0
- package/src/eth/builtin/internal/factories/ERC20__factory.js +401 -0
- package/src/eth/builtin/internal/factories/ERC20__factory.js.map +1 -0
- package/src/eth/builtin/internal/factories/ERC721__factory.d.ts +273 -0
- package/src/eth/builtin/internal/factories/ERC721__factory.d.ts.map +1 -0
- package/src/eth/builtin/internal/factories/ERC721__factory.js +361 -0
- package/src/eth/builtin/internal/factories/ERC721__factory.js.map +1 -0
- package/src/eth/builtin/internal/factories/WETH9__factory.d.ts +220 -0
- package/src/eth/builtin/internal/factories/WETH9__factory.d.ts.map +1 -0
- package/src/eth/builtin/internal/factories/WETH9__factory.js +294 -0
- package/src/eth/builtin/internal/factories/WETH9__factory.js.map +1 -0
- package/src/eth/builtin/internal/factories/index.d.ts +7 -0
- package/src/eth/builtin/internal/factories/index.d.ts.map +1 -0
- package/src/eth/builtin/internal/factories/index.js +10 -0
- package/src/eth/builtin/internal/factories/index.js.map +1 -0
- package/src/eth/builtin/internal/index.d.ts +14 -0
- package/src/eth/builtin/internal/index.d.ts.map +1 -0
- package/src/eth/builtin/internal/index.js +8 -0
- package/src/eth/builtin/internal/index.js.map +1 -0
- package/src/eth/builtin/internal/weth9-processor.d.ts +172 -0
- package/src/eth/builtin/internal/weth9-processor.d.ts.map +1 -0
- package/src/eth/builtin/internal/weth9-processor.js +729 -0
- package/src/eth/builtin/internal/weth9-processor.js.map +1 -0
- package/src/eth/builtin/internal/weth9-test-utils.d.ts +7 -0
- package/src/eth/builtin/internal/weth9-test-utils.d.ts.map +1 -0
- package/src/eth/builtin/internal/weth9-test-utils.js +55 -0
- package/src/eth/builtin/internal/weth9-test-utils.js.map +1 -0
- package/src/eth/builtin/weth9.d.ts +5 -0
- package/src/eth/builtin/weth9.d.ts.map +1 -0
- package/src/eth/builtin/weth9.js +8 -0
- package/src/eth/builtin/weth9.js.map +1 -0
- package/src/solana/builtin/index.d.ts +2 -0
- package/src/solana/builtin/index.d.ts.map +1 -0
- package/src/solana/builtin/index.js +2 -0
- package/src/solana/builtin/index.js.map +1 -0
- package/src/solana/builtin/spl-token-processor.d.ts +40 -0
- package/src/solana/builtin/spl-token-processor.d.ts.map +1 -0
- package/src/solana/builtin/spl-token-processor.js +254 -0
- package/src/solana/builtin/spl-token-processor.js.map +1 -0
- package/src/solana/builtin/types.d.ts +428 -0
- package/src/solana/builtin/types.d.ts.map +1 -0
- package/src/solana/builtin/types.js +201 -0
- package/src/solana/builtin/types.js.map +1 -0
- package/src/sui/builtin/0x1.d.ts +114 -0
- package/src/sui/builtin/0x1.d.ts.map +1 -0
- package/src/sui/builtin/0x1.js +159 -0
- package/src/sui/builtin/0x1.js.map +1 -0
- package/src/sui/builtin/0x2.d.ts +1250 -0
- package/src/sui/builtin/0x2.d.ts.map +1 -0
- package/src/sui/builtin/0x2.js +1511 -0
- package/src/sui/builtin/0x2.js.map +1 -0
- package/src/sui/builtin/0x3.d.ts +774 -0
- package/src/sui/builtin/0x3.d.ts.map +1 -0
- package/src/sui/builtin/0x3.js +720 -0
- package/src/sui/builtin/0x3.js.map +1 -0
- package/src/sui/builtin/index.d.ts +4 -0
- package/src/sui/builtin/index.d.ts.map +1 -0
- package/src/sui/builtin/index.js +7 -0
- package/src/sui/builtin/index.js.map +1 -0
@@ -0,0 +1,6 @@
|
|
1
|
+
import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
|
2
|
+
import{c as Se}from"./chunk-QGPJOTWP.js";import{e as be}from"./chunk-ATZBHPQN.js";import{$ as ye,V as we,g as ge}from"./chunk-B6U7F4GY.js";import{l as re}from"./chunk-LG2TF5WR.js";import{Jd as Q,de as _e}from"./chunk-JQ4LTUIX.js";import{a,e as je}from"./chunk-G5BIPHMS.js";async function j(n,e){let t=await n.getBlock(e);if(!t)throw new Error(`Block ${e} not found.`);return t}a(j,"getBlockSafely");async function Lt(n,e,t){let i=Math.floor(e.getTime()/1e3),r=await j(n,"latest"),c=(await j(n,t!==void 0?t:0)).number,l=r.number;for(;c<=l;){let h=Math.floor((c+l)/2),u=await j(n,h);if(u.timestamp===i)return u.number;u.timestamp<i?c=h+1:l=h-1}return(await j(n,l)).number}a(Lt,"estimateBlockNumberAtDate");import("node:process").then(n=>n.stdout.write(""));function kt(n){let e=BigInt(0);for(let t=0;t<n.length;t++)e=e*BigInt(256)+BigInt(n[t]);return e}a(kt,"bytesToBigInt");import("node:process").then(n=>n.stdout.write(""));var Ae={};je(Ae,{NATIVE_ETH:()=>Ye,getER20NormalizedAmount:()=>Ze,getERC20TokenInfo:()=>Ne});var z=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ie=new Set,se=typeof process=="object"&&process?process:{},Ce=a((n,e,t,i)=>{typeof se.emitWarning=="function"?se.emitWarning(n,e,t,i):console.error(`[${t}] ${e}: ${n}`)},"emitWarning"),K=globalThis.AbortController,Oe=globalThis.AbortSignal;if(typeof K>"u"){Oe=class{static{a(this,"AbortSignal")}onabort;_onabort=[];reason;aborted=!1;addEventListener(i,r){this._onabort.push(r)}},K=class{static{a(this,"AbortController")}constructor(){e()}signal=new Oe;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=!0;for(let r of this.signal._onabort)r(i);this.signal.onabort?.(i)}}};let n=se.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=a(()=>{n&&(n=!1,Ce("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))},"warnACPolyfill")}var Ke=a(n=>!Ie.has(n),"shouldWarn"),Vt=Symbol("type"),D=a(n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),"isPosInt"),Pe=a(n=>D(n)?n<=Math.pow(2,8)?Uint8Array:n<=Math.pow(2,16)?Uint16Array:n<=Math.pow(2,32)?Uint32Array:n<=Number.MAX_SAFE_INTEGER?M:null:null,"getUintArray"),M=class extends Array{static{a(this,"ZeroArray")}constructor(e){super(e),this.fill(0)}},oe=class n{static{a(this,"Stack")}heap;length;static#c=!1;static create(e){let t=Pe(e);if(!t)return[];n.#c=!0;let i=new n(e,t);return n.#c=!1,i}constructor(e,t){if(!n.#c)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},$=class n{static{a(this,"LRUCache")}#c;#u;#p;#_;#x;#R;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#r;#g;#n;#i;#e;#l;#h;#a;#s;#w;#o;#y;#S;#d;#b;#E;#f;static unsafeExposeInternals(e){return{starts:e.#S,ttls:e.#d,sizes:e.#y,keyMap:e.#n,keyList:e.#i,valList:e.#e,next:e.#l,prev:e.#h,get head(){return e.#a},get tail(){return e.#s},free:e.#w,isBackgroundFetch:a(t=>e.#t(t),"isBackgroundFetch"),backgroundFetch:a((t,i,r,s)=>e.#L(t,i,r,s),"backgroundFetch"),moveToTail:a(t=>e.#T(t),"moveToTail"),indexes:a(t=>e.#O(t),"indexes"),rindexes:a(t=>e.#I(t),"rindexes"),isStale:a(t=>e.#m(t),"isStale")}}get max(){return this.#c}get maxSize(){return this.#u}get calculatedSize(){return this.#g}get size(){return this.#r}get fetchMethod(){return this.#x}get memoMethod(){return this.#R}get dispose(){return this.#p}get disposeAfter(){return this.#_}constructor(e){let{max:t=0,ttl:i,ttlResolution:r=1,ttlAutopurge:s,updateAgeOnGet:o,updateAgeOnHas:c,allowStale:l,dispose:f,disposeAfter:h,noDisposeOnSet:u,noUpdateTTL:w,maxSize:O=0,maxEntrySize:N=0,sizeCalculation:g,fetchMethod:C,memoMethod:d,noDeleteOnFetchRejection:p,noDeleteOnStaleGet:_,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:I,ignoreFetchAbort:T}=e;if(t!==0&&!D(t))throw new TypeError("max option must be a nonnegative integer");let A=t?Pe(t):Array;if(!A)throw new Error("invalid max value: "+t);if(this.#c=t,this.#u=O,this.maxEntrySize=N||this.#u,this.sizeCalculation=g,this.sizeCalculation){if(!this.#u&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(d!==void 0&&typeof d!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#R=d,C!==void 0&&typeof C!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#x=C,this.#E=!!C,this.#n=new Map,this.#i=new Array(t).fill(void 0),this.#e=new Array(t).fill(void 0),this.#l=new A(t),this.#h=new A(t),this.#a=0,this.#s=0,this.#w=oe.create(t),this.#r=0,this.#g=0,typeof f=="function"&&(this.#p=f),typeof h=="function"?(this.#_=h,this.#o=[]):(this.#_=void 0,this.#o=void 0),this.#b=!!this.#p,this.#f=!!this.#_,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!w,this.noDeleteOnFetchRejection=!!p,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!I,this.ignoreFetchAbort=!!T,this.maxEntrySize!==0){if(this.#u!==0&&!D(this.#u))throw new TypeError("maxSize must be a positive integer if specified");if(!D(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#$()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!_,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!c,this.ttlResolution=D(r)||r===0?r:1,this.ttlAutopurge=!!s,this.ttl=i||0,this.ttl){if(!D(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#F()}if(this.#c===0&&this.ttl===0&&this.#u===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#c&&!this.#u){let x="LRU_CACHE_UNBOUNDED";Ke(x)&&(Ie.add(x),Ce("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",x,n))}}getRemainingTTL(e){return this.#n.has(e)?1/0:0}#F(){let e=new M(this.#c),t=new M(this.#c);this.#d=e,this.#S=t,this.#B=(s,o,c=z.now())=>{if(t[s]=o!==0?c:0,e[s]=o,o!==0&&this.ttlAutopurge){let l=setTimeout(()=>{this.#m(s)&&this.#C(this.#i[s],"expire")},o+1);l.unref&&l.unref()}},this.#N=s=>{t[s]=e[s]!==0?z.now():0},this.#P=(s,o)=>{if(e[o]){let c=e[o],l=t[o];if(!c||!l)return;s.ttl=c,s.start=l,s.now=i||r();let f=s.now-l;s.remainingTTL=c-f}};let i=0,r=a(()=>{let s=z.now();if(this.ttlResolution>0){i=s;let o=setTimeout(()=>i=0,this.ttlResolution);o.unref&&o.unref()}return s},"getNow");this.getRemainingTTL=s=>{let o=this.#n.get(s);if(o===void 0)return 0;let c=e[o],l=t[o];if(!c||!l)return 1/0;let f=(i||r())-l;return c-f},this.#m=s=>{let o=t[s],c=e[s];return!!c&&!!o&&(i||r())-o>c}}#N=a(()=>{},"#updateItemAge");#P=a(()=>{},"#statusTTL");#B=a(()=>{},"#setItemTTL");#m=a(()=>!1,"#isStale");#$(){let e=new M(this.#c);this.#g=0,this.#y=e,this.#A=t=>{this.#g-=e[t],e[t]=0},this.#k=(t,i,r,s)=>{if(this.#t(i))return 0;if(!D(r))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(r=s(i,t),!D(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r},this.#v=(t,i,r)=>{if(e[t]=i,this.#u){let s=this.#u-e[t];for(;this.#g>s;)this.#D(!0)}this.#g+=e[t],r&&(r.entrySize=i,r.totalCalculatedSize=this.#g)}}#A=a(e=>{},"#removeItemSize");#v=a((e,t,i)=>{},"#addItemSize");#k=a((e,t,i,r)=>{if(i||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0},"#requireSize");*#O({allowStale:e=this.allowStale}={}){if(this.#r)for(let t=this.#s;!(!this.#J(t)||((e||!this.#m(t))&&(yield t),t===this.#a));)t=this.#h[t]}*#I({allowStale:e=this.allowStale}={}){if(this.#r)for(let t=this.#a;!(!this.#J(t)||((e||!this.#m(t))&&(yield t),t===this.#s));)t=this.#l[t]}#J(e){return e!==void 0&&this.#n.get(this.#i[e])===e}*entries(){for(let e of this.#O())this.#e[e]!==void 0&&this.#i[e]!==void 0&&!this.#t(this.#e[e])&&(yield[this.#i[e],this.#e[e]])}*rentries(){for(let e of this.#I())this.#e[e]!==void 0&&this.#i[e]!==void 0&&!this.#t(this.#e[e])&&(yield[this.#i[e],this.#e[e]])}*keys(){for(let e of this.#O()){let t=this.#i[e];t!==void 0&&!this.#t(this.#e[e])&&(yield t)}}*rkeys(){for(let e of this.#I()){let t=this.#i[e];t!==void 0&&!this.#t(this.#e[e])&&(yield t)}}*values(){for(let e of this.#O())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e])}*rvalues(){for(let e of this.#I())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let i of this.#O()){let r=this.#e[i],s=this.#t(r)?r.__staleWhileFetching:r;if(s!==void 0&&e(s,this.#i[i],this))return this.get(this.#i[i],t)}}forEach(e,t=this){for(let i of this.#O()){let r=this.#e[i],s=this.#t(r)?r.__staleWhileFetching:r;s!==void 0&&e.call(t,s,this.#i[i],this)}}rforEach(e,t=this){for(let i of this.#I()){let r=this.#e[i],s=this.#t(r)?r.__staleWhileFetching:r;s!==void 0&&e.call(t,s,this.#i[i],this)}}purgeStale(){let e=!1;for(let t of this.#I({allowStale:!0}))this.#m(t)&&(this.#C(this.#i[t],"expire"),e=!0);return e}info(e){let t=this.#n.get(e);if(t===void 0)return;let i=this.#e[t],r=this.#t(i)?i.__staleWhileFetching:i;if(r===void 0)return;let s={value:r};if(this.#d&&this.#S){let o=this.#d[t],c=this.#S[t];if(o&&c){let l=o-(z.now()-c);s.ttl=l,s.start=Date.now()}}return this.#y&&(s.size=this.#y[t]),s}dump(){let e=[];for(let t of this.#O({allowStale:!0})){let i=this.#i[t],r=this.#e[t],s=this.#t(r)?r.__staleWhileFetching:r;if(s===void 0||i===void 0)continue;let o={value:s};if(this.#d&&this.#S){o.ttl=this.#d[t];let c=z.now()-this.#S[t];o.start=Math.floor(Date.now()-c)}this.#y&&(o.size=this.#y[t]),e.unshift([i,o])}return e}load(e){this.clear();for(let[t,i]of e){if(i.start){let r=Date.now()-i.start;i.start=z.now()-r}this.set(t,i.value,i)}}set(e,t,i={}){if(t===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:s,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:c=this.sizeCalculation,status:l}=i,{noUpdateTTL:f=this.noUpdateTTL}=i,h=this.#k(e,t,i.size||0,c);if(this.maxEntrySize&&h>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.#C(e,"set"),this;let u=this.#r===0?void 0:this.#n.get(e);if(u===void 0)u=this.#r===0?this.#s:this.#w.length!==0?this.#w.pop():this.#r===this.#c?this.#D(!1):this.#r,this.#i[u]=e,this.#e[u]=t,this.#n.set(e,u),this.#l[this.#s]=u,this.#h[u]=this.#s,this.#s=u,this.#r++,this.#v(u,h,l),l&&(l.set="add"),f=!1;else{this.#T(u);let w=this.#e[u];if(t!==w){if(this.#E&&this.#t(w)){w.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:O}=w;O!==void 0&&!o&&(this.#b&&this.#p?.(O,e,"set"),this.#f&&this.#o?.push([O,e,"set"]))}else o||(this.#b&&this.#p?.(w,e,"set"),this.#f&&this.#o?.push([w,e,"set"]));if(this.#A(u),this.#v(u,h,l),this.#e[u]=t,l){l.set="replace";let O=w&&this.#t(w)?w.__staleWhileFetching:w;O!==void 0&&(l.oldValue=O)}}else l&&(l.set="update")}if(r!==0&&!this.#d&&this.#F(),this.#d&&(f||this.#B(u,r,s),l&&this.#P(l,u)),!o&&this.#f&&this.#o){let w=this.#o,O;for(;O=w?.shift();)this.#_?.(...O)}return this}pop(){try{for(;this.#r;){let e=this.#e[this.#a];if(this.#D(!0),this.#t(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#f&&this.#o){let e=this.#o,t;for(;t=e?.shift();)this.#_?.(...t)}}}#D(e){let t=this.#a,i=this.#i[t],r=this.#e[t];return this.#E&&this.#t(r)?r.__abortController.abort(new Error("evicted")):(this.#b||this.#f)&&(this.#b&&this.#p?.(r,i,"evict"),this.#f&&this.#o?.push([r,i,"evict"])),this.#A(t),e&&(this.#i[t]=void 0,this.#e[t]=void 0,this.#w.push(t)),this.#r===1?(this.#a=this.#s=0,this.#w.length=0):this.#a=this.#l[t],this.#n.delete(i),this.#r--,t}has(e,t={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:r}=t,s=this.#n.get(e);if(s!==void 0){let o=this.#e[s];if(this.#t(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#m(s))r&&(r.has="stale",this.#P(r,s));else return i&&this.#N(s),r&&(r.has="hit",this.#P(r,s)),!0}else r&&(r.has="miss");return!1}peek(e,t={}){let{allowStale:i=this.allowStale}=t,r=this.#n.get(e);if(r===void 0||!i&&this.#m(r))return;let s=this.#e[r];return this.#t(s)?s.__staleWhileFetching:s}#L(e,t,i,r){let s=t===void 0?void 0:this.#e[t];if(this.#t(s))return s;let o=new K,{signal:c}=i;c?.addEventListener("abort",()=>o.abort(c.reason),{signal:o.signal});let l={signal:o.signal,options:i,context:r},f=a((g,C=!1)=>{let{aborted:d}=o.signal,p=i.ignoreFetchAbort&&g!==void 0;if(i.status&&(d&&!C?(i.status.fetchAborted=!0,i.status.fetchError=o.signal.reason,p&&(i.status.fetchAbortIgnored=!0)):i.status.fetchResolved=!0),d&&!p&&!C)return u(o.signal.reason);let _=O;return this.#e[t]===O&&(g===void 0?_.__staleWhileFetching?this.#e[t]=_.__staleWhileFetching:this.#C(e,"fetch"):(i.status&&(i.status.fetchUpdated=!0),this.set(e,g,l.options))),g},"cb"),h=a(g=>(i.status&&(i.status.fetchRejected=!0,i.status.fetchError=g),u(g)),"eb"),u=a(g=>{let{aborted:C}=o.signal,d=C&&i.allowStaleOnFetchAbort,p=d||i.allowStaleOnFetchRejection,_=p||i.noDeleteOnFetchRejection,S=O;if(this.#e[t]===O&&(!_||S.__staleWhileFetching===void 0?this.#C(e,"fetch"):d||(this.#e[t]=S.__staleWhileFetching)),p)return i.status&&S.__staleWhileFetching!==void 0&&(i.status.returnedStale=!0),S.__staleWhileFetching;if(S.__returned===S)throw g},"fetchFail"),w=a((g,C)=>{let d=this.#x?.(e,s,l);d&&d instanceof Promise&&d.then(p=>g(p===void 0?void 0:p),C),o.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(g(void 0),i.allowStaleOnFetchAbort&&(g=a(p=>f(p,!0),"res")))})},"pcall");i.status&&(i.status.fetchDispatched=!0);let O=new Promise(w).then(f,h),N=Object.assign(O,{__abortController:o,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.set(e,N,{...l.options,status:void 0}),t=this.#n.get(e)):this.#e[t]=N,N}#t(e){if(!this.#E)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof K}async fetch(e,t={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:l=0,sizeCalculation:f=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:w=this.allowStaleOnFetchRejection,ignoreFetchAbort:O=this.ignoreFetchAbort,allowStaleOnFetchAbort:N=this.allowStaleOnFetchAbort,context:g,forceRefresh:C=!1,status:d,signal:p}=t;if(!this.#E)return d&&(d.fetch="get"),this.get(e,{allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:s,status:d});let _={allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:s,ttl:o,noDisposeOnSet:c,size:l,sizeCalculation:f,noUpdateTTL:h,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:N,ignoreFetchAbort:O,status:d,signal:p},S=this.#n.get(e);if(S===void 0){d&&(d.fetch="miss");let I=this.#L(e,S,_,g);return I.__returned=I}else{let I=this.#e[S];if(this.#t(I)){let W=i&&I.__staleWhileFetching!==void 0;return d&&(d.fetch="inflight",W&&(d.returnedStale=!0)),W?I.__staleWhileFetching:I.__returned=I}let T=this.#m(S);if(!C&&!T)return d&&(d.fetch="hit"),this.#T(S),r&&this.#N(S),d&&this.#P(d,S),I;let A=this.#L(e,S,_,g),U=A.__staleWhileFetching!==void 0&&i;return d&&(d.fetch=T?"stale":"refresh",U&&T&&(d.returnedStale=!0)),U?A.__staleWhileFetching:A.__returned=A}}async forceFetch(e,t={}){let i=await this.fetch(e,t);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(e,t={}){let i=this.#R;if(!i)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:s,...o}=t,c=this.get(e,o);if(!s&&c!==void 0)return c;let l=i(e,c,{options:o,context:r});return this.set(e,l,o),l}get(e,t={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:o}=t,c=this.#n.get(e);if(c!==void 0){let l=this.#e[c],f=this.#t(l);return o&&this.#P(o,c),this.#m(c)?(o&&(o.get="stale"),f?(o&&i&&l.__staleWhileFetching!==void 0&&(o.returnedStale=!0),i?l.__staleWhileFetching:void 0):(s||this.#C(e,"expire"),o&&i&&(o.returnedStale=!0),i?l:void 0)):(o&&(o.get="hit"),f?l.__staleWhileFetching:(this.#T(c),r&&this.#N(c),l))}else o&&(o.get="miss")}#z(e,t){this.#h[t]=e,this.#l[e]=t}#T(e){e!==this.#s&&(e===this.#a?this.#a=this.#l[e]:this.#z(this.#h[e],this.#l[e]),this.#z(this.#s,e),this.#s=e)}delete(e){return this.#C(e,"delete")}#C(e,t){let i=!1;if(this.#r!==0){let r=this.#n.get(e);if(r!==void 0)if(i=!0,this.#r===1)this.#M(t);else{this.#A(r);let s=this.#e[r];if(this.#t(s)?s.__abortController.abort(new Error("deleted")):(this.#b||this.#f)&&(this.#b&&this.#p?.(s,e,t),this.#f&&this.#o?.push([s,e,t])),this.#n.delete(e),this.#i[r]=void 0,this.#e[r]=void 0,r===this.#s)this.#s=this.#h[r];else if(r===this.#a)this.#a=this.#l[r];else{let o=this.#h[r];this.#l[o]=this.#l[r];let c=this.#l[r];this.#h[c]=this.#h[r]}this.#r--,this.#w.push(r)}}if(this.#f&&this.#o?.length){let r=this.#o,s;for(;s=r?.shift();)this.#_?.(...s)}return i}clear(){return this.#M("delete")}#M(e){for(let t of this.#I({allowStale:!0})){let i=this.#e[t];if(this.#t(i))i.__abortController.abort(new Error("deleted"));else{let r=this.#i[t];this.#b&&this.#p?.(i,r,e),this.#f&&this.#o?.push([i,r,e])}}if(this.#n.clear(),this.#e.fill(void 0),this.#i.fill(void 0),this.#d&&this.#S&&(this.#d.fill(0),this.#S.fill(0)),this.#y&&this.#y.fill(0),this.#a=0,this.#s=0,this.#w.length=0,this.#g=0,this.#r=0,this.#f&&this.#o){let t=this.#o,i;for(;i=t?.shift();)this.#_?.(...i)}}};var Ye={symbol:"ETH",decimal:18,name:"Native ETH"},Ee=new $({max:1e4,ttl:1e3*60*60});async function Xe(n,e,t){return{symbol:await n,name:await e,decimal:Number(await t)}}a(Xe,"getTokenInfoPromise");async function Ne(n,e){let t;n instanceof _e?t=n.getChainId():t=n||we.ETHEREUM;let i=t+e,r=Ee.get(i);if(r)return r;let s=ye(t,e),o=Se(t,e),c="";try{c=await s.name()}catch{c=re(await o.name())}let l="";try{l=await s.symbol()}catch{l=re(await o.symbol())}let f=await s.decimals(),h=Xe(l,c,f);return Ee.set(i,h),h}a(Ne,"getERC20TokenInfo");async function Ze(n,e,t){let i=await Ne(n,e);return Q(t,i.decimal)}a(Ze,"getER20NormalizedAmount");import("node:process").then(n=>n.stdout.write(""));import Fe from"fs";var y=class n extends Error{static{a(this,"CsvError")}constructor(e,t,i,...r){Array.isArray(t)&&(t=t.join(" ").trim()),super(t),Error.captureStackTrace!==void 0&&Error.captureStackTrace(this,n),this.code=e;for(let s of r)for(let o in s){let c=s[o];this[o]=Buffer.isBuffer(c)?c.toString(i.encoding):c==null?c:JSON.parse(JSON.stringify(c))}}};var Te=a(function(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)},"is_object");var Y=a(function(n){let e=[];for(let t=0,i=n.length;t<i;t++){let r=n[t];if(r==null||r===!1)e[t]={disabled:!0};else if(typeof r=="string")e[t]={name:r};else if(Te(r)){if(typeof r.name!="string")throw new y("CSV_OPTION_COLUMNS_MISSING_NAME",["Option columns missing name:",`property "name" is required at position ${t}`,"when column is an object literal"]);e[t]=r}else throw new y("CSV_INVALID_COLUMN_DEFINITION",["Invalid column definition:","expect a string or a literal object,",`got ${JSON.stringify(r)} at position ${t}`])}return e},"normalize_columns_array");var ae=class{static{a(this,"ResizeableBuffer")}constructor(e=100){this.size=e,this.length=0,this.buf=Buffer.allocUnsafe(e)}prepend(e){if(Buffer.isBuffer(e)){let t=this.length+e.length;if(t>=this.size&&(this.resize(),t>=this.size))throw Error("INVALID_BUFFER_STATE");let i=this.buf;this.buf=Buffer.allocUnsafe(this.size),e.copy(this.buf,0),i.copy(this.buf,e.length),this.length+=e.length}else{let t=this.length++;t===this.size&&this.resize();let i=this.clone();this.buf[0]=e,i.copy(this.buf,1,0,t)}}append(e){let t=this.length++;t===this.size&&this.resize(),this.buf[t]=e}clone(){return Buffer.from(this.buf.slice(0,this.length))}resize(){let e=this.length;this.size=this.size*2;let t=Buffer.allocUnsafe(this.size);this.buf.copy(t,0,0,e),this.buf=t}toString(e){return e?this.buf.slice(0,this.length).toString(e):Uint8Array.prototype.slice.call(this.buf.slice(0,this.length))}toJSON(){return this.toString("utf8")}reset(){this.length=0}},ce=ae;var et=12,tt=13,it=10,nt=32,rt=9,xe=a(function(n){return{bomSkipped:!1,bufBytesStart:0,castField:n.cast_function,commenting:!1,error:void 0,enabled:n.from_line===1,escaping:!1,escapeIsQuote:Buffer.isBuffer(n.escape)&&Buffer.isBuffer(n.quote)&&Buffer.compare(n.escape,n.quote)===0,expectedRecordLength:Array.isArray(n.columns)?n.columns.length:void 0,field:new ce(20),firstLineToHeaders:n.cast_first_line_to_header,needMoreDataSize:Math.max(n.comment!==null?n.comment.length:0,...n.delimiter.map(e=>e.length),n.quote!==null?n.quote.length:0),previousBuf:void 0,quoting:!1,stop:!1,rawBuffer:new ce(100),record:[],recordHasError:!1,record_length:0,recordDelimiterMaxLength:n.record_delimiter.length===0?0:Math.max(...n.record_delimiter.map(e=>e.length)),trimChars:[Buffer.from(" ",n.encoding)[0],Buffer.from(" ",n.encoding)[0]],wasQuoting:!1,wasRowDelimiter:!1,timchars:[Buffer.from(Buffer.from([tt],"utf8").toString(),n.encoding),Buffer.from(Buffer.from([it],"utf8").toString(),n.encoding),Buffer.from(Buffer.from([et],"utf8").toString(),n.encoding),Buffer.from(Buffer.from([nt],"utf8").toString(),n.encoding),Buffer.from(Buffer.from([rt],"utf8").toString(),n.encoding)]}},"init_state");var Re=a(function(n){return n.replace(/([A-Z])/g,function(e,t){return"_"+t.toLowerCase()})},"underscore");var le=a(function(n){let e={};for(let i in n)e[Re(i)]=n[i];if(e.encoding===void 0||e.encoding===!0)e.encoding="utf8";else if(e.encoding===null||e.encoding===!1)e.encoding=null;else if(typeof e.encoding!="string"&&e.encoding!==null)throw new y("CSV_INVALID_OPTION_ENCODING",["Invalid option encoding:","encoding must be a string or null to return a buffer,",`got ${JSON.stringify(e.encoding)}`],e);if(e.bom===void 0||e.bom===null||e.bom===!1)e.bom=!1;else if(e.bom!==!0)throw new y("CSV_INVALID_OPTION_BOM",["Invalid option bom:","bom must be true,",`got ${JSON.stringify(e.bom)}`],e);if(e.cast_function=null,e.cast===void 0||e.cast===null||e.cast===!1||e.cast==="")e.cast=void 0;else if(typeof e.cast=="function")e.cast_function=e.cast,e.cast=!0;else if(e.cast!==!0)throw new y("CSV_INVALID_OPTION_CAST",["Invalid option cast:","cast must be true or a function,",`got ${JSON.stringify(e.cast)}`],e);if(e.cast_date===void 0||e.cast_date===null||e.cast_date===!1||e.cast_date==="")e.cast_date=!1;else if(e.cast_date===!0)e.cast_date=function(i){let r=Date.parse(i);return isNaN(r)?i:new Date(r)};else if(typeof e.cast_date!="function")throw new y("CSV_INVALID_OPTION_CAST_DATE",["Invalid option cast_date:","cast_date must be true or a function,",`got ${JSON.stringify(e.cast_date)}`],e);if(e.cast_first_line_to_header=null,e.columns===!0)e.cast_first_line_to_header=void 0;else if(typeof e.columns=="function")e.cast_first_line_to_header=e.columns,e.columns=!0;else if(Array.isArray(e.columns))e.columns=Y(e.columns);else if(e.columns===void 0||e.columns===null||e.columns===!1)e.columns=!1;else throw new y("CSV_INVALID_OPTION_COLUMNS",["Invalid option columns:","expect an array, a function or true,",`got ${JSON.stringify(e.columns)}`],e);if(e.group_columns_by_name===void 0||e.group_columns_by_name===null||e.group_columns_by_name===!1)e.group_columns_by_name=!1;else{if(e.group_columns_by_name!==!0)throw new y("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","expect an boolean,",`got ${JSON.stringify(e.group_columns_by_name)}`],e);if(e.columns===!1)throw new y("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","the `columns` mode must be activated."],e)}if(e.comment===void 0||e.comment===null||e.comment===!1||e.comment==="")e.comment=null;else if(typeof e.comment=="string"&&(e.comment=Buffer.from(e.comment,e.encoding)),!Buffer.isBuffer(e.comment))throw new y("CSV_INVALID_OPTION_COMMENT",["Invalid option comment:","comment must be a buffer or a string,",`got ${JSON.stringify(e.comment)}`],e);if(e.comment_no_infix===void 0||e.comment_no_infix===null||e.comment_no_infix===!1)e.comment_no_infix=!1;else if(e.comment_no_infix!==!0)throw new y("CSV_INVALID_OPTION_COMMENT",["Invalid option comment_no_infix:","value must be a boolean,",`got ${JSON.stringify(e.comment_no_infix)}`],e);let t=JSON.stringify(e.delimiter);if(Array.isArray(e.delimiter)||(e.delimiter=[e.delimiter]),e.delimiter.length===0)throw new y("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${t}`],e);if(e.delimiter=e.delimiter.map(function(i){if(i==null||i===!1)return Buffer.from(",",e.encoding);if(typeof i=="string"&&(i=Buffer.from(i,e.encoding)),!Buffer.isBuffer(i)||i.length===0)throw new y("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${t}`],e);return i}),e.escape===void 0||e.escape===!0?e.escape=Buffer.from('"',e.encoding):typeof e.escape=="string"?e.escape=Buffer.from(e.escape,e.encoding):(e.escape===null||e.escape===!1)&&(e.escape=null),e.escape!==null&&!Buffer.isBuffer(e.escape))throw new Error(`Invalid Option: escape must be a buffer, a string or a boolean, got ${JSON.stringify(e.escape)}`);if(e.from===void 0||e.from===null)e.from=1;else if(typeof e.from=="string"&&/\d+/.test(e.from)&&(e.from=parseInt(e.from)),Number.isInteger(e.from)){if(e.from<0)throw new Error(`Invalid Option: from must be a positive integer, got ${JSON.stringify(n.from)}`)}else throw new Error(`Invalid Option: from must be an integer, got ${JSON.stringify(e.from)}`);if(e.from_line===void 0||e.from_line===null)e.from_line=1;else if(typeof e.from_line=="string"&&/\d+/.test(e.from_line)&&(e.from_line=parseInt(e.from_line)),Number.isInteger(e.from_line)){if(e.from_line<=0)throw new Error(`Invalid Option: from_line must be a positive integer greater than 0, got ${JSON.stringify(n.from_line)}`)}else throw new Error(`Invalid Option: from_line must be an integer, got ${JSON.stringify(n.from_line)}`);if(e.ignore_last_delimiters===void 0||e.ignore_last_delimiters===null)e.ignore_last_delimiters=!1;else if(typeof e.ignore_last_delimiters=="number")e.ignore_last_delimiters=Math.floor(e.ignore_last_delimiters),e.ignore_last_delimiters===0&&(e.ignore_last_delimiters=!1);else if(typeof e.ignore_last_delimiters!="boolean")throw new y("CSV_INVALID_OPTION_IGNORE_LAST_DELIMITERS",["Invalid option `ignore_last_delimiters`:","the value must be a boolean value or an integer,",`got ${JSON.stringify(e.ignore_last_delimiters)}`],e);if(e.ignore_last_delimiters===!0&&e.columns===!1)throw new y("CSV_IGNORE_LAST_DELIMITERS_REQUIRES_COLUMNS",["The option `ignore_last_delimiters`","requires the activation of the `columns` option"],e);if(e.info===void 0||e.info===null||e.info===!1)e.info=!1;else if(e.info!==!0)throw new Error(`Invalid Option: info must be true, got ${JSON.stringify(e.info)}`);if(e.max_record_size===void 0||e.max_record_size===null||e.max_record_size===!1)e.max_record_size=0;else if(!(Number.isInteger(e.max_record_size)&&e.max_record_size>=0))if(typeof e.max_record_size=="string"&&/\d+/.test(e.max_record_size))e.max_record_size=parseInt(e.max_record_size);else throw new Error(`Invalid Option: max_record_size must be a positive integer, got ${JSON.stringify(e.max_record_size)}`);if(e.objname===void 0||e.objname===null||e.objname===!1)e.objname=void 0;else if(Buffer.isBuffer(e.objname)){if(e.objname.length===0)throw new Error("Invalid Option: objname must be a non empty buffer");e.encoding===null||(e.objname=e.objname.toString(e.encoding))}else if(typeof e.objname=="string"){if(e.objname.length===0)throw new Error("Invalid Option: objname must be a non empty string")}else if(typeof e.objname!="number")throw new Error(`Invalid Option: objname must be a string or a buffer, got ${e.objname}`);if(e.objname!==void 0){if(typeof e.objname=="number"){if(e.columns!==!1)throw Error("Invalid Option: objname index cannot be combined with columns or be defined as a field")}else if(e.columns===!1)throw Error("Invalid Option: objname field must be combined with columns or be defined as an index")}if(e.on_record===void 0||e.on_record===null)e.on_record=void 0;else if(typeof e.on_record!="function")throw new y("CSV_INVALID_OPTION_ON_RECORD",["Invalid option `on_record`:","expect a function,",`got ${JSON.stringify(e.on_record)}`],e);if(e.on_skip!==void 0&&e.on_skip!==null&&typeof e.on_skip!="function")throw new Error(`Invalid Option: on_skip must be a function, got ${JSON.stringify(e.on_skip)}`);if(e.quote===null||e.quote===!1||e.quote==="")e.quote=null;else if(e.quote===void 0||e.quote===!0?e.quote=Buffer.from('"',e.encoding):typeof e.quote=="string"&&(e.quote=Buffer.from(e.quote,e.encoding)),!Buffer.isBuffer(e.quote))throw new Error(`Invalid Option: quote must be a buffer or a string, got ${JSON.stringify(e.quote)}`);if(e.raw===void 0||e.raw===null||e.raw===!1)e.raw=!1;else if(e.raw!==!0)throw new Error(`Invalid Option: raw must be true, got ${JSON.stringify(e.raw)}`);if(e.record_delimiter===void 0)e.record_delimiter=[];else if(typeof e.record_delimiter=="string"||Buffer.isBuffer(e.record_delimiter)){if(e.record_delimiter.length===0)throw new y("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer,",`got ${JSON.stringify(e.record_delimiter)}`],e);e.record_delimiter=[e.record_delimiter]}else if(!Array.isArray(e.record_delimiter))throw new y("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer,",`got ${JSON.stringify(e.record_delimiter)}`],e);if(e.record_delimiter=e.record_delimiter.map(function(i,r){if(typeof i!="string"&&!Buffer.isBuffer(i))throw new y("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer",`at index ${r},`,`got ${JSON.stringify(i)}`],e);if(i.length===0)throw new y("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer",`at index ${r},`,`got ${JSON.stringify(i)}`],e);return typeof i=="string"&&(i=Buffer.from(i,e.encoding)),i}),typeof e.relax_column_count!="boolean")if(e.relax_column_count===void 0||e.relax_column_count===null)e.relax_column_count=!1;else throw new Error(`Invalid Option: relax_column_count must be a boolean, got ${JSON.stringify(e.relax_column_count)}`);if(typeof e.relax_column_count_less!="boolean")if(e.relax_column_count_less===void 0||e.relax_column_count_less===null)e.relax_column_count_less=!1;else throw new Error(`Invalid Option: relax_column_count_less must be a boolean, got ${JSON.stringify(e.relax_column_count_less)}`);if(typeof e.relax_column_count_more!="boolean")if(e.relax_column_count_more===void 0||e.relax_column_count_more===null)e.relax_column_count_more=!1;else throw new Error(`Invalid Option: relax_column_count_more must be a boolean, got ${JSON.stringify(e.relax_column_count_more)}`);if(typeof e.relax_quotes!="boolean")if(e.relax_quotes===void 0||e.relax_quotes===null)e.relax_quotes=!1;else throw new Error(`Invalid Option: relax_quotes must be a boolean, got ${JSON.stringify(e.relax_quotes)}`);if(typeof e.skip_empty_lines!="boolean")if(e.skip_empty_lines===void 0||e.skip_empty_lines===null)e.skip_empty_lines=!1;else throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(e.skip_empty_lines)}`);if(typeof e.skip_records_with_empty_values!="boolean")if(e.skip_records_with_empty_values===void 0||e.skip_records_with_empty_values===null)e.skip_records_with_empty_values=!1;else throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(e.skip_records_with_empty_values)}`);if(typeof e.skip_records_with_error!="boolean")if(e.skip_records_with_error===void 0||e.skip_records_with_error===null)e.skip_records_with_error=!1;else throw new Error(`Invalid Option: skip_records_with_error must be a boolean, got ${JSON.stringify(e.skip_records_with_error)}`);if(e.rtrim===void 0||e.rtrim===null||e.rtrim===!1)e.rtrim=!1;else if(e.rtrim!==!0)throw new Error(`Invalid Option: rtrim must be a boolean, got ${JSON.stringify(e.rtrim)}`);if(e.ltrim===void 0||e.ltrim===null||e.ltrim===!1)e.ltrim=!1;else if(e.ltrim!==!0)throw new Error(`Invalid Option: ltrim must be a boolean, got ${JSON.stringify(e.ltrim)}`);if(e.trim===void 0||e.trim===null||e.trim===!1)e.trim=!1;else if(e.trim!==!0)throw new Error(`Invalid Option: trim must be a boolean, got ${JSON.stringify(e.trim)}`);if(e.trim===!0&&n.ltrim!==!1?e.ltrim=!0:e.ltrim!==!0&&(e.ltrim=!1),e.trim===!0&&n.rtrim!==!1?e.rtrim=!0:e.rtrim!==!0&&(e.rtrim=!1),e.to===void 0||e.to===null)e.to=-1;else if(typeof e.to=="string"&&/\d+/.test(e.to)&&(e.to=parseInt(e.to)),Number.isInteger(e.to)){if(e.to<=0)throw new Error(`Invalid Option: to must be a positive integer greater than 0, got ${JSON.stringify(n.to)}`)}else throw new Error(`Invalid Option: to must be an integer, got ${JSON.stringify(n.to)}`);if(e.to_line===void 0||e.to_line===null)e.to_line=-1;else if(typeof e.to_line=="string"&&/\d+/.test(e.to_line)&&(e.to_line=parseInt(e.to_line)),Number.isInteger(e.to_line)){if(e.to_line<=0)throw new Error(`Invalid Option: to_line must be a positive integer greater than 0, got ${JSON.stringify(n.to_line)}`)}else throw new Error(`Invalid Option: to_line must be an integer, got ${JSON.stringify(n.to_line)}`);return e},"normalize_options");var ve=a(function(n){return n.every(e=>e==null||e.toString&&e.toString().trim()==="")},"isRecordEmpty"),st=13,ot=10,V={utf8:Buffer.from([239,187,191]),utf16le:Buffer.from([255,254])},De=a(function(n={}){let e={bytes:0,comment_lines:0,empty_lines:0,invalid_field_length:0,lines:1,records:0},t=le(n);return{info:e,original_options:n,options:t,state:xe(t),__needMoreData:a(function(i,r,s){if(s)return!1;let{encoding:o,escape:c,quote:l}=this.options,{quoting:f,needMoreDataSize:h,recordDelimiterMaxLength:u}=this.state,w=r-i-1,O=Math.max(h,u===0?Buffer.from(`\r
|
3
|
+
`,o).length:u,f?(c===null?0:c.length)+l.length:0,f?l.length+u:0);return w<O},"__needMoreData"),parse:a(function(i,r,s,o){let{bom:c,comment_no_infix:l,encoding:f,from_line:h,ltrim:u,max_record_size:w,raw:O,relax_quotes:N,rtrim:g,skip_empty_lines:C,to:d,to_line:p}=this.options,{comment:_,escape:S,quote:I,record_delimiter:T}=this.options,{bomSkipped:A,previousBuf:x,rawBuffer:U,escapeIsQuote:W}=this.state,b;if(x===void 0)if(i===void 0){o();return}else b=i;else x!==void 0&&i===void 0?b=x:b=Buffer.concat([x,i]);if(A===!1)if(c===!1)this.state.bomSkipped=!0;else if(b.length<3){if(r===!1){this.state.previousBuf=b;return}}else{for(let P in V)if(V[P].compare(b,0,V[P].length)===0){let v=V[P].length;this.state.bufBytesStart+=v,b=b.slice(v),this.options=le({...this.original_options,encoding:P}),{comment:_,escape:S,quote:I}=this.options;break}this.state.bomSkipped=!0}let ne=b.length,m;for(m=0;m<ne&&!this.__needMoreData(m,ne,r);m++){if(this.state.wasRowDelimiter===!0&&(this.info.lines++,this.state.wasRowDelimiter=!1),p!==-1&&this.info.lines>p){this.state.stop=!0,o();return}this.state.quoting===!1&&T.length===0&&this.__autoDiscoverRecordDelimiter(b,m)&&(T=this.options.record_delimiter);let P=b[m];if(O===!0&&U.append(P),(P===st||P===ot)&&this.state.wasRowDelimiter===!1&&(this.state.wasRowDelimiter=!0),this.state.escaping===!0)this.state.escaping=!1;else{if(S!==null&&this.state.quoting===!0&&this.__isEscape(b,m,P)&&m+S.length<ne)if(W){if(this.__isQuote(b,m+S.length)){this.state.escaping=!0,m+=S.length-1;continue}}else{this.state.escaping=!0,m+=S.length-1;continue}if(this.state.commenting===!1&&this.__isQuote(b,m))if(this.state.quoting===!0){let E=b[m+I.length],L=g&&this.__isCharTrimable(b,m+I.length),R=_!==null&&this.__compareBytes(_,b,m+I.length,E),F=this.__isDelimiter(b,m+I.length,E),H=T.length===0?this.__autoDiscoverRecordDelimiter(b,m+I.length):this.__isRecordDelimiter(E,b,m+I.length);if(S!==null&&this.__isEscape(b,m,P)&&this.__isQuote(b,m+S.length))m+=S.length-1;else if(!E||F||H||R||L){this.state.quoting=!1,this.state.wasQuoting=!0,m+=I.length-1;continue}else if(N===!1){let pe=this.__error(new y("CSV_INVALID_CLOSING_QUOTE",["Invalid Closing Quote:",`got "${String.fromCharCode(E)}"`,`at line ${this.info.lines}`,"instead of delimiter, record delimiter, trimable character","(if activated) or comment"],this.options,this.__infoField()));if(pe!==void 0)return pe}else this.state.quoting=!1,this.state.wasQuoting=!0,this.state.field.prepend(I),m+=I.length-1}else if(this.state.field.length!==0){if(N===!1){let E=this.__infoField(),L=Object.keys(V).map(F=>V[F].equals(this.state.field.toString())?F:!1).filter(Boolean)[0],R=this.__error(new y("INVALID_OPENING_QUOTE",["Invalid Opening Quote:",`a quote is found on field ${JSON.stringify(E.column)} at line ${E.lines}, value is ${JSON.stringify(this.state.field.toString(f))}`,L?`(${L} bom)`:void 0],this.options,E,{field:this.state.field}));if(R!==void 0)return R}}else{this.state.quoting=!0,m+=I.length-1;continue}if(this.state.quoting===!1){let E=this.__isRecordDelimiter(P,b,m);if(E!==0){if(this.state.commenting&&this.state.wasQuoting===!1&&this.state.record.length===0&&this.state.field.length===0)this.info.comment_lines++;else{if(this.state.enabled===!1&&this.info.lines+(this.state.wasRowDelimiter===!0?1:0)>=h){this.state.enabled=!0,this.__resetField(),this.__resetRecord(),m+=E-1;continue}if(C===!0&&this.state.wasQuoting===!1&&this.state.record.length===0&&this.state.field.length===0){this.info.empty_lines++,m+=E-1;continue}this.info.bytes=this.state.bufBytesStart+m;let F=this.__onField();if(F!==void 0)return F;this.info.bytes=this.state.bufBytesStart+m+E;let H=this.__onRecord(s);if(H!==void 0)return H;if(d!==-1&&this.info.records>=d){this.state.stop=!0,o();return}}this.state.commenting=!1,m+=E-1;continue}if(this.state.commenting)continue;if(_!==null&&(l===!1||this.state.record.length===0&&this.state.field.length===0)&&this.__compareBytes(_,b,m,P)!==0){this.state.commenting=!0;continue}let L=this.__isDelimiter(b,m,P);if(L!==0){this.info.bytes=this.state.bufBytesStart+m;let R=this.__onField();if(R!==void 0)return R;m+=L-1;continue}}}if(this.state.commenting===!1&&w!==0&&this.state.record_length+this.state.field.length>w)return this.__error(new y("CSV_MAX_RECORD_SIZE",["Max Record Size:","record exceed the maximum number of tolerated bytes",`of ${w}`,`at line ${this.info.lines}`],this.options,this.__infoField()));let v=u===!1||this.state.quoting===!0||this.state.field.length!==0||!this.__isCharTrimable(b,m),Qe=g===!1||this.state.wasQuoting===!1;if(v===!0&&Qe===!0)this.state.field.append(P);else{if(g===!0&&!this.__isCharTrimable(b,m))return this.__error(new y("CSV_NON_TRIMABLE_CHAR_AFTER_CLOSING_QUOTE",["Invalid Closing Quote:","found non trimable byte after quote",`at line ${this.info.lines}`],this.options,this.__infoField()));v===!1&&(m+=this.__isCharTrimable(b,m)-1);continue}}if(r===!0)if(this.state.quoting===!0){let P=this.__error(new y("CSV_QUOTE_NOT_CLOSED",["Quote Not Closed:",`the parsing is finished with an opening quote at line ${this.info.lines}`],this.options,this.__infoField()));if(P!==void 0)return P}else if(this.state.wasQuoting===!0||this.state.record.length!==0||this.state.field.length!==0){this.info.bytes=this.state.bufBytesStart+m;let P=this.__onField();if(P!==void 0)return P;let v=this.__onRecord(s);if(v!==void 0)return v}else this.state.wasRowDelimiter===!0?this.info.empty_lines++:this.state.commenting===!0&&this.info.comment_lines++;else this.state.bufBytesStart+=m,this.state.previousBuf=b.slice(m);this.state.wasRowDelimiter===!0&&(this.info.lines++,this.state.wasRowDelimiter=!1)},"parse"),__onRecord:a(function(i){let{columns:r,group_columns_by_name:s,encoding:o,info:c,from:l,relax_column_count:f,relax_column_count_less:h,relax_column_count_more:u,raw:w,skip_records_with_empty_values:O}=this.options,{enabled:N,record:g}=this.state;if(N===!1)return this.__resetRecord();let C=g.length;if(r===!0){if(O===!0&&ve(g)){this.__resetRecord();return}return this.__firstLineToColumns(g)}if(r===!1&&this.info.records===0&&(this.state.expectedRecordLength=C),C!==this.state.expectedRecordLength){let d=r===!1?new y("CSV_RECORD_INCONSISTENT_FIELDS_LENGTH",["Invalid Record Length:",`expect ${this.state.expectedRecordLength},`,`got ${C} on line ${this.info.lines}`],this.options,this.__infoField(),{record:g}):new y("CSV_RECORD_INCONSISTENT_COLUMNS",["Invalid Record Length:",`columns length is ${r.length},`,`got ${C} on line ${this.info.lines}`],this.options,this.__infoField(),{record:g});if(f===!0||h===!0&&C<this.state.expectedRecordLength||u===!0&&C>this.state.expectedRecordLength)this.info.invalid_field_length++,this.state.error=d;else{let p=this.__error(d);if(p)return p}}if(O===!0&&ve(g)){this.__resetRecord();return}if(this.state.recordHasError===!0){this.__resetRecord(),this.state.recordHasError=!1;return}if(this.info.records++,l===1||this.info.records>=l){let{objname:d}=this.options;if(r!==!1){let p={};for(let _=0,S=g.length;_<S;_++)r[_]===void 0||r[_].disabled||(s===!0&&p[r[_].name]!==void 0?Array.isArray(p[r[_].name])?p[r[_].name]=p[r[_].name].concat(g[_]):p[r[_].name]=[p[r[_].name],g[_]]:p[r[_].name]=g[_]);if(w===!0||c===!0){let _=Object.assign({record:p},w===!0?{raw:this.state.rawBuffer.toString(o)}:{},c===!0?{info:this.__infoRecord()}:{}),S=this.__push(d===void 0?_:[p[d],_],i);if(S)return S}else{let _=this.__push(d===void 0?p:[p[d],p],i);if(_)return _}}else if(w===!0||c===!0){let p=Object.assign({record:g},w===!0?{raw:this.state.rawBuffer.toString(o)}:{},c===!0?{info:this.__infoRecord()}:{}),_=this.__push(d===void 0?p:[g[d],p],i);if(_)return _}else{let p=this.__push(d===void 0?g:[g[d],g],i);if(p)return p}}this.__resetRecord()},"__onRecord"),__firstLineToColumns:a(function(i){let{firstLineToHeaders:r}=this.state;try{let s=r===void 0?i:r.call(null,i);if(!Array.isArray(s))return this.__error(new y("CSV_INVALID_COLUMN_MAPPING",["Invalid Column Mapping:","expect an array from column function,",`got ${JSON.stringify(s)}`],this.options,this.__infoField(),{headers:s}));let o=Y(s);this.state.expectedRecordLength=o.length,this.options.columns=o,this.__resetRecord();return}catch(s){return s}},"__firstLineToColumns"),__resetRecord:a(function(){this.options.raw===!0&&this.state.rawBuffer.reset(),this.state.error=void 0,this.state.record=[],this.state.record_length=0},"__resetRecord"),__onField:a(function(){let{cast:i,encoding:r,rtrim:s,max_record_size:o}=this.options,{enabled:c,wasQuoting:l}=this.state;if(c===!1)return this.__resetField();let f=this.state.field.toString(r);if(s===!0&&l===!1&&(f=f.trimRight()),i===!0){let[h,u]=this.__cast(f);if(h!==void 0)return h;f=u}this.state.record.push(f),o!==0&&typeof f=="string"&&(this.state.record_length+=f.length),this.__resetField()},"__onField"),__resetField:a(function(){this.state.field.reset(),this.state.wasQuoting=!1},"__resetField"),__push:a(function(i,r){let{on_record:s}=this.options;if(s!==void 0){let o=this.__infoRecord();try{i=s.call(null,i,o)}catch(c){return c}if(i==null)return}r(i)},"__push"),__cast:a(function(i){let{columns:r,relax_column_count:s}=this.options;if(Array.isArray(r)===!0&&s&&this.options.columns.length<=this.state.record.length)return[void 0,void 0];if(this.state.castField!==null)try{let c=this.__infoField();return[void 0,this.state.castField.call(null,i,c)]}catch(c){return[c]}if(this.__isFloat(i))return[void 0,parseFloat(i)];if(this.options.cast_date!==!1){let c=this.__infoField();return[void 0,this.options.cast_date.call(null,i,c)]}return[void 0,i]},"__cast"),__isCharTrimable:a(function(i,r){return a((o,c)=>{let{timchars:l}=this.state;e:for(let f=0;f<l.length;f++){let h=l[f];for(let u=0;u<h.length;u++)if(h[u]!==o[c+u])continue e;return h.length}return 0},"isTrim")(i,r)},"__isCharTrimable"),__isFloat:a(function(i){return i-parseFloat(i)+1>=0},"__isFloat"),__compareBytes:a(function(i,r,s,o){if(i[0]!==o)return 0;let c=i.length;for(let l=1;l<c;l++)if(i[l]!==r[s+l])return 0;return c},"__compareBytes"),__isDelimiter:a(function(i,r,s){let{delimiter:o,ignore_last_delimiters:c}=this.options;if(c===!0&&this.state.record.length===this.options.columns.length-1)return 0;if(c!==!1&&typeof c=="number"&&this.state.record.length===c-1)return 0;e:for(let l=0;l<o.length;l++){let f=o[l];if(f[0]===s){for(let h=1;h<f.length;h++)if(f[h]!==i[r+h])continue e;return f.length}}return 0},"__isDelimiter"),__isRecordDelimiter:a(function(i,r,s){let{record_delimiter:o}=this.options,c=o.length;e:for(let l=0;l<c;l++){let f=o[l],h=f.length;if(f[0]===i){for(let u=1;u<h;u++)if(f[u]!==r[s+u])continue e;return f.length}}return 0},"__isRecordDelimiter"),__isEscape:a(function(i,r,s){let{escape:o}=this.options;if(o===null)return!1;let c=o.length;if(o[0]===s){for(let l=0;l<c;l++)if(o[l]!==i[r+l])return!1;return!0}return!1},"__isEscape"),__isQuote:a(function(i,r){let{quote:s}=this.options;if(s===null)return!1;let o=s.length;for(let c=0;c<o;c++)if(s[c]!==i[r+c])return!1;return!0},"__isQuote"),__autoDiscoverRecordDelimiter:a(function(i,r){let{encoding:s}=this.options,o=[Buffer.from(`\r
|
4
|
+
`,s),Buffer.from(`
|
5
|
+
`,s),Buffer.from("\r",s)];e:for(let c=0;c<o.length;c++){let l=o[c].length;for(let f=0;f<l;f++)if(o[c][f]!==i[r+f])continue e;return this.options.record_delimiter.push(o[c]),this.state.recordDelimiterMaxLength=o[c].length,o[c].length}return 0},"__autoDiscoverRecordDelimiter"),__error:a(function(i){let{encoding:r,raw:s,skip_records_with_error:o}=this.options,c=typeof i=="string"?new Error(i):i;if(o){this.state.recordHasError=!0,this.options.on_skip!==void 0&&this.options.on_skip(c,s?this.state.rawBuffer.toString(r):void 0);return}else return c},"__error"),__infoDataSet:a(function(){return{...this.info,columns:this.options.columns}},"__infoDataSet"),__infoRecord:a(function(){let{columns:i,raw:r,encoding:s}=this.options;return{...this.__infoDataSet(),error:this.state.error,header:i===!0,index:this.state.record.length,raw:r?this.state.rawBuffer.toString(s):void 0}},"__infoRecord"),__infoField:a(function(){let{columns:i}=this.options,r=Array.isArray(i);return{...this.__infoRecord(),column:r===!0?i.length>this.state.record.length?i[this.state.record.length].name:null:this.state.record.length,quoting:this.state.wasQuoting}},"__infoField")}},"transform");var Le=a(function(n,e={}){typeof n=="string"&&(n=Buffer.from(n));let t=e&&e.objname?{}:[],i=De(e),r=a(l=>{i.options.objname===void 0?t.push(l):t[l[0]]=l[1]},"push"),s=a(()=>{},"close"),o=i.parse(n,!1,r,s);if(o!==void 0)throw o;let c=i.parse(void 0,!0,r,s);if(c!==void 0)throw c;return t},"parse");import{EthChainId as Be}from"@sentio/chain";import{createRequire as at}from"module";import X from"path";var ct=(i=>(i[i.USD=0]="USD",i[i.ETH=1]="ETH",i[i.BTC=2]="BTC",i))(ct||{});function lt(n){let t=at(import.meta.url).resolve(n),i=X.dirname(t);for(;!Fe.existsSync(X.join(i,"package.json"));)i=X.dirname(i);return i}a(lt,"getPackageRoot");var Z=class{static{a(this,"DexPrice")}USD_ORACLE_MAP=new Map;ETH_ORACLE_MAP=new Map;BTC_ORACLE_MAP=new Map;ASSETS_INFOS=new Map;chainId;constructor(e,t){this.chainId=t;let i=lt("@sentio/sdk"),r=X.join(i,"assets",e),s=Fe.readFileSync(r,{encoding:"utf-8"}),c=Le(s,{delimiter:",",columns:["Pair","Asset","Type","Address"],skip_empty_lines:!0});for(let l of c){let f=l.Pair.split("/"),h=f[0].trim().toLowerCase(),u=f[1].trim().toLowerCase(),w=l.Address.toLowerCase();u==="usd"?this.USD_ORACLE_MAP.set(h,w):u==="eth"?this.ETH_ORACLE_MAP.set(h,w):u=="btc"?this.BTC_ORACLE_MAP.set(h,w):console.error("wrong asset record:"+JSON.stringify(l))}}async getPrice(e,t="latest",i=0){let r=this.USD_ORACLE_MAP;switch(i){case 1:r=this.ETH_ORACLE_MAP;break;case 2:r=this.BTC_ORACLE_MAP;break;default:}e=e.trim().toLowerCase();let s=r.get(e);if(!s)return{error:"No price feed found for asset"};let o=be(this.chainId,s);try{let c=await o.latestAnswer({blockTag:t}),l=this.ASSETS_INFOS.get(e);return l||(l=Number(await o.decimals()),this.ASSETS_INFOS.set(e,l)),{price:Q(c,l).toNumber()}}catch(c){return{error:"Price query error for "+e+" failed at "+s+" at chain "+this.chainId+". Details: "+c.toString()}}}},ki=new Z("chainlink-oracles.csv",Be.ETHEREUM),Ji=new Z("chainlink-oracles-sepolia.csv",Be.SEPOLIA);import("node:process").then(n=>n.stdout.write(""));import{Endpoints as Ct,processMetrics as Pt}from"@sentio/runtime";var ft="https://app.sentio.xyz".replace(/\/+$/,""),q=class{static{a(this,"Configuration")}configuration;constructor(e={}){this.configuration=e}set config(e){this.configuration=e}get basePath(){return this.configuration.basePath!=null?this.configuration.basePath:ft}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||ke}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){let e=this.configuration.apiKey;if(e)return typeof e=="function"?e:()=>e}get accessToken(){let e=this.configuration.accessToken;if(e)return typeof e=="function"?e:async()=>e}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}},ut=new q,ee=class n{static{a(this,"BaseAPI")}configuration;static jsonRegex=new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$","i");middleware;constructor(e=ut){this.configuration=e,this.middleware=e.middleware}withMiddleware(...e){let t=this.clone();return t.middleware=t.middleware.concat(...e),t}withPreMiddleware(...e){let t=e.map(i=>({pre:i}));return this.withMiddleware(...t)}withPostMiddleware(...e){let t=e.map(i=>({post:i}));return this.withMiddleware(...t)}isJsonMime(e){return e?n.jsonRegex.test(e):!1}async request(e,t){let{url:i,init:r}=await this.createFetchParams(e,t),s=await this.fetchApi(i,r);if(s&&s.status>=200&&s.status<300)return s;throw new fe(s,"Response returned an error code")}async createFetchParams(e,t){let i=this.configuration.basePath+e.path;e.query!==void 0&&Object.keys(e.query).length!==0&&(i+="?"+this.configuration.queryParamsStringify(e.query));let r=Object.assign({},this.configuration.headers,e.headers);Object.keys(r).forEach(h=>r[h]===void 0?delete r[h]:{});let s=typeof t=="function"?t:async()=>t,o={method:e.method,headers:r,body:e.body,credentials:this.configuration.credentials},c={...o,...await s({init:o,context:e})},l;dt(c.body)||c.body instanceof URLSearchParams||ht(c.body)?l=c.body:this.isJsonMime(r["Content-Type"])?l=JSON.stringify(c.body):l=c.body;let f={...c,body:l};return{url:i,init:f}}fetchApi=a(async(e,t)=>{let i={url:e,init:t};for(let s of this.middleware)s.pre&&(i=await s.pre({fetch:this.fetchApi,...i})||i);let r;try{r=await(this.configuration.fetchApi||fetch)(i.url,i.init)}catch(s){for(let o of this.middleware)o.onError&&(r=await o.onError({fetch:this.fetchApi,url:i.url,init:i.init,error:s,response:r?r.clone():void 0})||r);if(r===void 0)throw s instanceof Error?new ue(s,"The request failed and the interceptors did not return an alternative response"):s}for(let s of this.middleware)s.post&&(r=await s.post({fetch:this.fetchApi,url:i.url,init:i.init,response:r.clone()})||r);return r},"fetchApi");clone(){let e=this.constructor,t=new e(this.configuration);return t.middleware=this.middleware.slice(),t}};function ht(n){return typeof Blob<"u"&&n instanceof Blob}a(ht,"isBlob");function dt(n){return typeof FormData<"u"&&n instanceof FormData}a(dt,"isFormData");var fe=class extends Error{static{a(this,"ResponseError")}response;name="ResponseError";constructor(e,t){super(t),this.response=e}},ue=class extends Error{static{a(this,"FetchError")}cause;name="FetchError";constructor(e,t){super(t),this.cause=e}};function ke(n,e=""){return Object.keys(n).map(t=>Je(t,n[t],e)).filter(t=>t.length>0).join("&")}a(ke,"querystring");function Je(n,e,t=""){let i=t+(t.length?`[${n}]`:n);if(e instanceof Array){let r=e.map(s=>encodeURIComponent(String(s))).join(`&${encodeURIComponent(i)}=`);return`${encodeURIComponent(i)}=${r}`}if(e instanceof Set){let r=Array.from(e);return Je(n,r,t)}return e instanceof Date?`${encodeURIComponent(i)}=${encodeURIComponent(e.toISOString())}`:e instanceof Object?ke(e,i):`${encodeURIComponent(i)}=${encodeURIComponent(String(e))}`}a(Je,"querystringSingleKey");function ze(n,e){return Object.keys(n).reduce((t,i)=>({...t,[i]:e(n[i])}),{})}a(ze,"mapValues");var B=class{static{a(this,"JSONApiResponse")}raw;transformer;constructor(e,t=i=>i){this.raw=e,this.transformer=t}async value(){return this.transformer(await this.raw.json())}};function te(n){return pt(n,!1)}a(te,"PriceServiceGetPriceResponseFromJSON");function pt(n,e){return n==null?n:{price:n.price==null?void 0:n.price,timestamp:n.timestamp==null?void 0:new Date(n.timestamp)}}a(pt,"PriceServiceGetPriceResponseFromJSONTyped");function Me(n){return _t(n,!1)}a(Me,"PriceServiceBatchGetPricesResponseCoinPricePriceFromJSON");function _t(n,e){return n==null?n:{results:n.results==null?void 0:n.results.map(te)}}a(_t,"PriceServiceBatchGetPricesResponseCoinPricePriceFromJSONTyped");function $e(n){return gt(n,!1)}a($e,"PriceServiceCoinIDAddressIdentifierFromJSON");function gt(n,e){return n==null?n:{address:n.address==null?void 0:n.address,chain:n.chain==null?void 0:n.chain}}a(gt,"PriceServiceCoinIDAddressIdentifierFromJSONTyped");function k(n){return wt(n,!1)}a(k,"PriceServiceCoinIDFromJSON");function wt(n,e){return n==null?n:{symbol:n.symbol==null?void 0:n.symbol,address:n.address==null?void 0:$e(n.address)}}a(wt,"PriceServiceCoinIDFromJSONTyped");function Ge(n){return yt(n,!1)}a(Ge,"PriceServiceBatchGetPricesResponseCoinPriceFromJSON");function yt(n,e){return n==null?n:{coinId:n.coinId==null?void 0:k(n.coinId),price:n.price==null?void 0:Me(n.price),error:n.error==null?void 0:n.error}}a(yt,"PriceServiceBatchGetPricesResponseCoinPriceFromJSONTyped");function Ue(n){return St(n,!1)}a(Ue,"PriceServiceBatchGetPricesResponseFromJSON");function St(n,e){return n==null?n:{prices:n.prices==null?void 0:n.prices.map(Ge)}}a(St,"PriceServiceBatchGetPricesResponseFromJSONTyped");function he(n){return bt(n,!1)}a(he,"PriceServiceCheckLatestPriceResponseCoinPriceFromJSON");function bt(n,e){return n==null?n:{coinId:n.coinId==null?void 0:k(n.coinId),price:n.price==null?void 0:n.price,timestamp:n.timestamp==null?void 0:new Date(n.timestamp)}}a(bt,"PriceServiceCheckLatestPriceResponseCoinPriceFromJSONTyped");function qe(n){return Ot(n,!1)}a(qe,"PriceServiceCheckLatestPriceResponseFromJSON");function Ot(n,e){return n==null?n:{prices:n.prices==null?void 0:n.prices.map(he),latestPrice:n.latestPrice==null?void 0:he(n.latestPrice)}}a(Ot,"PriceServiceCheckLatestPriceResponseFromJSONTyped");function We(n){return It(n,!1)}a(We,"PriceServiceListCoinsResponseFromJSON");function It(n,e){return n==null?n:{coins:n.coins==null?void 0:n.coins.map(k),coinAddressesInChain:n.coinAddressesInChain==null?void 0:ze(n.coinAddressesInChain,k)}}a(It,"PriceServiceListCoinsResponseFromJSONTyped");var ie=class extends ee{static{a(this,"PriceApi")}async batchGetPricesRaw(e,t){let i={};e.timestamps!=null&&(i.timestamps=e.timestamps);let r={};this.configuration&&this.configuration.apiKey&&(r["api-key"]=await this.configuration.apiKey("api-key"));let s=await this.request({path:"/api/v1/prices/batch",method:"GET",headers:r,query:i},t);return new B(s,o=>Ue(o))}async batchGetPrices(e={},t){return await(await this.batchGetPricesRaw(e,t)).value()}async checkLatestPriceRaw(e){let t={},i={};this.configuration&&this.configuration.apiKey&&(i["api-key"]=await this.configuration.apiKey("api-key"));let r=await this.request({path:"/api/v1/prices/check_latest",method:"GET",headers:i,query:t},e);return new B(r,s=>qe(s))}async checkLatestPrice(e){return await(await this.checkLatestPriceRaw(e)).value()}async getPriceRaw(e,t){let i={};e.timestamp!=null&&(i.timestamp=e.timestamp.toISOString()),e.coinIdSymbol!=null&&(i["coinId.symbol"]=e.coinIdSymbol),e.coinIdAddressAddress!=null&&(i["coinId.address.address"]=e.coinIdAddressAddress),e.coinIdAddressChain!=null&&(i["coinId.address.chain"]=e.coinIdAddressChain),e.source!=null&&(i.source=e.source);let r={};this.configuration&&this.configuration.apiKey&&(r["api-key"]=await this.configuration.apiKey("api-key"));let s=await this.request({path:"/api/v1/prices",method:"GET",headers:r,query:i},t);return new B(s,o=>te(o))}async getPrice(e={},t){return await(await this.getPriceRaw(e,t)).value()}async priceListCoinsRaw(e,t){let i={};e.limit!=null&&(i.limit=e.limit),e.offset!=null&&(i.offset=e.offset),e.searchQuery!=null&&(i.searchQuery=e.searchQuery),e.chain!=null&&(i.chain=e.chain);let r={};this.configuration&&this.configuration.apiKey&&(r["api-key"]=await this.configuration.apiKey("api-key"));let s=await this.request({path:"/api/v1/prices/coins",method:"GET",headers:r,query:i},t);return new B(s,o=>We(o))}async priceListCoins(e={},t){return await(await this.priceListCoinsRaw(e,t)).value()}};import Et from"path";import Nt from"fs";import At from"os";function Tt(){try{let n=Nt.readFileSync(Et.join(At.homedir(),".sentio","config.json"),"utf8");return JSON.parse(n)["https://app.sentio.xyz"]?.api_keys}catch{}}a(Tt,"getApiKey");function me(n=Ct.INSTANCE.priceFeedAPI){n.startsWith("http")||(n="http://"+n),n.endsWith("/")&&(n=n.slice(0,-1));let e=new q({basePath:n,apiKey:Tt()});return new ie(e)}a(me,"getPriceClient");var J=new $({max:1e5,ttl:1e3*60*5}),G;async function He(n,e,t){return G||(G=me()),xt(G,n,e,t)}a(He,"getPriceByTypeOrSymbol");async function xt(n,e,t,i){let r=de(e),s=de(new Date),o;t.symbol?o=`${t.symbol}-${r}`:o=`${t.address?.address}-${t.address?.chain}-${r}`;let c=J.get(o);return c||(Pt.process_pricecall_count.add(1),c=n.getPrice({timestamp:e,coinIdSymbol:t.symbol,coinIdAddressAddress:t.address?.address,coinIdAddressChain:t.address?.chain}).then(f=>{if(f.timestamp)if(de(f.timestamp)===s)J.delete(o);else{let w=Math.abs(f.timestamp.getTime()-e.getTime())/(1e3*60*60*24),O=i?.toleranceInDays||2;if(w>O){J.delete(o);return}}else J.delete(o);return f.price}).catch(f=>{if(setTimeout(()=>{J.delete(o)},1e3),f.response?.status===404){console.error("price not found for ",JSON.stringify(t)," at ",r);return}throw J.delete(o),f}),J.set(o,c),c)}a(xt,"getPriceByTypeOrSymbolInternal");async function Rt(n,e,t,i){return He(t,{address:{chain:n,address:e}},i)}a(Rt,"getPriceByType");async function vt(n,e,t){return He(e,{symbol:n},t)}a(vt,"getPriceBySymbol");function de(n){return[n.getHours(),n.getUTCDate(),n.getUTCMonth()+1,n.getUTCFullYear()].join("-")}a(de,"dateString");async function Dt(n){G||(G=me());let e=await G.priceListCoins({chain:n,limit:1e3});return e.coinAddressesInChain?Object.entries(e.coinAddressesInChain).map(([t,i])=>(i.symbol=t,i)):[]}a(Dt,"getCoinsThatHasPrice");import("node:process").then(n=>n.stdout.write(""));async function Dn(n,e=!1){try{return await n}catch(t){if(t instanceof ge||t.code==="CALL_EXCEPTION"||t.code==="BAD_DATA"){e&&console.error("eth call exception, return undefined",t);return}throw t}}a(Dn,"ignoreEthCallException");import("node:process").then(n=>n.stdout.write(""));import("node:process").then(n=>n.stdout.write(""));export{Lt as a,kt as b,Ae as c,ct as d,lt as e,ki as f,Ji as g,me as h,Rt as i,vt as j,Dt as k,Dn as l};
|
6
|
+
//# sourceMappingURL=chunk-AK5E6DKD.js.map
|