"use strict";var Dt=Object.create;var O=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Tt=Object.getPrototypeOf,Ft=Object.prototype.hasOwnProperty;var Mt=(a,t)=>{for(var e in t)O(a,e,{get:t[e],enumerable:!0})},lt=(a,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of It(t))!Ft.call(a,s)&&s!==e&&O(a,s,{get:()=>t[s],enumerable:!(n=Et(t,s))||n.enumerable});return a};var ft=(a,t,e)=>(e=a!=null?Dt(Tt(a)):{},lt(t||!a||!a.__esModule?O(e,"default",{value:a,enumerable:!0}):e,a)),Gt=a=>lt(O({},"__esModule",{value:!0}),a);var Vt={};Mt(Vt,{Sdk:()=>Xt,getAssetsBalances:()=>U,getBalance:()=>C,getContractFee:()=>ht,getDecimals:()=>A,getExtrinsicFee:()=>Ct,getFee:()=>yt,getFeeBalance:()=>H,getMax:()=>At,getMin:()=>F,getParachainBalances:()=>_t,getSourceData:()=>J,validateSovereignAccountBalances:()=>j});module.exports=Gt(Vt);var gt=require("@moonbeam-network/xcm-builder"),M=require("@moonbeam-network/xcm-types"),y=require("@moonbeam-network/xcm-utils"),L=ft(require("big.js"),1);var dt=require("ethers"),w=require("viem");function I(a){return"provider"in a}function P(a){return!("abi"in a)}var S=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}];var q=class{address;#t;#e;constructor(t,e){if(!t.address)throw new Error("Contract address is required");this.address=t.address,this.#t=t,this.#e=I(e)?new dt.Contract(this.address,S,e):(0,w.getContract)({abi:S,address:this.address,client:{public:(0,w.createPublicClient)({chain:e.chain,transport:(0,w.http)()}),wallet:e}})}async getBalance(){return P(this.#e)?(await this.#e.balanceOf(...this.#t.args)).toBigInt():this.#e.read.balanceOf(this.#t.args)}async getDecimals(){return P(this.#e)?await this.#e.decimals():this.#e.read.decimals()}};var pt=require("ethers"),h=require("viem");var z=[{inputs:[{internalType:"address",name:"currencyAddress",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{components:[{internalType:"uint8",name:"parents",type:"uint8"},{internalType:"bytes[]",name:"interior",type:"bytes[]"}],internalType:"struct Xtokens.Multilocation",name:"destination",type:"tuple"},{internalType:"uint64",name:"weight",type:"uint64"}],name:"transfer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"currencyAddress",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],internalType:"struct Xtokens.Currency[]",name:"currencies",type:"tuple[]"},{internalType:"uint32",name:"feeItem",type:"uint32"},{components:[{internalType:"uint8",name:"parents",type:"uint8"},{internalType:"bytes[]",name:"interior",type:"bytes[]"}],internalType:"struct Xtokens.Multilocation",name:"destination",type:"tuple"},{internalType:"uint64",name:"weight",type:"uint64"}],name:"transferMultiCurrencies",outputs:[],stateMutability:"nonpayable",type:"function"}];var T=class{defaultMoonChainAddress="0x0000000000000000000000000000000000000804";address;#t;#e;#a;constructor(t,e,n){this.#t=t,this.#a=e,this.address=n??this.defaultMoonChainAddress,this.#e=I(e)?new pt.Contract(this.address,z,e):(0,h.getContract)({abi:z,address:this.address,client:{public:(0,h.createPublicClient)({chain:e.chain,transport:(0,h.http)()}),wallet:e}})}async transfer(){return P(this.#e)?this.#e[this.#t.func](...this.#t.args):this.#e.write[this.#t.func](this.#t.args)}async getEthersContractEstimatedGas(t){return t[this.#t.func].estimateGas(...this.#t.args)}async getViemContractEstimatedGas(t){return t?t.estimateGas[this.#t.func](this.#t.args):0n}async getFee(t){if(t===0n)return 0n;try{let e=P(this.#e)?await this.getEthersContractEstimatedGas(this.#e):await this.getViemContractEstimatedGas(this.#e),n=await this.getGasPrice();return e*n}catch(e){throw console.error(e),new Error("Can't get a fee. Make sure that you have enough balance!")}}async getGasPrice(){if(I(this.#a)){if(!this.#a.provider)return 0n;let{gasPrice:e,maxPriorityFeePerGas:n}=await this.#a.provider.getFeeData();return(e||0n)+(n||0n)}return(0,h.createPublicClient)({chain:this.#a.chain,transport:(0,h.http)()}).getGasPrice()}};var N=require("viem");var $=class{address;#t;#e;constructor(t,e){if(!t.address)throw new Error("Contract address is required");this.address=t.address,this.#t=t,this.#e=(0,N.createPublicClient)({chain:e,transport:(0,N.http)()})}async getBalance(){return await this.#e.readContract({abi:S,address:this.#t.address,args:this.#t.args,functionName:"balanceOf"})}async getDecimals(){return await this.#e.readContract({abi:S,address:this.#t.address,functionName:"decimals"})}};function Rt(a,t,e){var n;if(a.module==="Erc20")return new q(a,t);if(a.module==="Xtokens"){if(e&&"contracts"in e){let s=(n=e==null?void 0:e.contracts)==null?void 0:n.Xtokens;return new T(a,t,s)}return new T(a,t)}throw new Error(`Contract ${a.module} not found`)}function v(a,t){if(a.module==="Erc20")return new $(a,t.getViemChain());throw new Error(`Public Contract ${a.module} not found`)}function Q(a,t,e){return t?Rt(a,t,e):v(a,e)}var K=require("@moonbeam-network/xcm-builder"),X=require("@moonbeam-network/xcm-utils");async function C({address:a,chain:t,balanceBuilder:e,asset:n,decimals:s,polkadot:o}){let i=e.build({address:a,asset:o.chain.getBalanceAssetId(n)});if(i.type===K.CallType.Substrate){let r=await o.query(i);return t.usesChainDecimals?(0,X.convertDecimals)(r,o.decimals,s):r}return await v(i,t).getBalance()}async function A({address:a,asset:t,config:e,polkadot:n,chain:s,assetBuiltConfig:o}){let i=o||e.balance.build({address:a,asset:n.chain.getBalanceAssetId(t||e.asset)});return i.type===K.CallType.Substrate?n.getAssetDecimals(t||e.asset):v(i,s).getDecimals()}async function F(a,t){if(a.min)return t.query(a.min.build({asset:t.chain.getMinAssetId(a.asset)}));let e=t.chain.getAssetMin(a.asset);if(e){let n=await t.getAssetDecimals(a.asset);return(0,X.toBigInt)(e,n)}return 0n}function j({amount:a,source:t,destination:e}){if(!e.chain.checkSovereignAccountBalances||!e.sovereignAccountBalances)return;let{feeAssetBalance:n,transferAssetBalance:s}=e.sovereignAccountBalances;if(a>s)throw new Error(`${t.chain.name} Sovereign account in ${e.chain.name} does not have enough balance for this transaction`);if(n&&t.destinationFee.amount>n)throw new Error(`${t.chain.name} Sovereign account in ${e.chain.name} does not have enough balance to pay for fees for this transaction`)}async function J({transferConfig:a,destinationAddress:t,destinationFee:e,polkadot:n,sourceAddress:s,evmSigner:o}){var st,rt,it,ot,ct,mt,ut;let{asset:i,destination:m,source:{chain:c,config:r}}=a,u=M.AssetAmount.fromAsset(i,{amount:0n,decimals:await A({address:t,chain:c,config:r,polkadot:n})}),f=n.chain.getBalanceAssetId(((st=r==null?void 0:r.fee)==null?void 0:st.asset)||r.asset),p=(rt=r.fee)==null?void 0:rt.balance.build({address:t,asset:f}),d=(it=r.fee)!=null&&it.asset?await A({address:t,asset:r.fee.asset,assetBuiltConfig:p,chain:c,config:r,polkadot:n}):void 0,l=(ot=r.fee)!=null&&ot.asset?M.AssetAmount.fromAsset(r.fee.asset,{amount:0n,decimals:d||0}):u,D=(ct=r.destinationFee)!=null&&ct.asset?M.AssetAmount.fromAsset(r.destinationFee.asset,{amount:0n,decimals:await A({address:t,asset:r.destinationFee.asset,chain:c,config:r,polkadot:n})}):u,g=await C({address:s,asset:r.asset,balanceBuilder:r.balance,chain:c,decimals:u.decimals,polkadot:n}),k=await H({address:s,balance:g,chain:c,decimals:l.decimals,feeConfig:r.fee,polkadot:n}),W=r.asset.isEqual(r.destinationFee.asset)?g:await H({address:s,balance:g,chain:c,decimals:D.decimals,feeConfig:r.destinationFee,polkadot:n}),R=await F(r,n),E=(mt=r.extrinsic)==null?void 0:mt.build({address:t,amount:g,asset:c.getAssetId(i),destination:m.chain,fee:e.amount,feeAsset:c.getAssetId(e),palletInstance:c.getAssetPalletInstance(i),source:c}),wt=(ut=r.contract)==null?void 0:ut.build({address:t,amount:g,asset:c.getAssetId(i),destination:m.chain,fee:e.amount,feeAsset:c.getAssetId(e)}),Z=D.copyWith({amount:W}),vt=await yt({balance:g,chain:c,contract:wt,decimals:l.decimals,destinationFeeBalanceAmount:Z,destinationFeeConfig:r.destinationFee,evmSigner:o,extrinsic:E,feeConfig:r.fee,polkadot:n,sourceAddress:s}),tt=u.copyWith({amount:g}),{existentialDeposit:et}=n,at=l.copyWith({amount:vt}),Bt=l.copyWith({amount:k}),nt=u.copyWith({amount:R}),xt=At({balanceAmount:tt,existentialDeposit:et,feeAmount:at,minAmount:nt});return{balance:tt,chain:c,destinationFee:e,destinationFeeBalance:Z,existentialDeposit:et,fee:at,feeBalance:Bt,max:xt,min:nt}}async function H({address:a,balance:t,chain:e,decimals:n,feeConfig:s,polkadot:o}){if(!s)return t;let i=s.balance.build({address:a,asset:o.chain.getBalanceAssetId(s.asset)});if(i.type===gt.CallType.Evm){let c=v(i,e),r=await c.getDecimals(),u=await c.getBalance();return e.usesChainDecimals?(0,y.convertDecimals)(u,o.decimals,r):u}let m=await o.query(i);return e.usesChainDecimals?(0,y.convertDecimals)(m,o.decimals,n):m}async function yt({balance:a,chain:t,contract:e,decimals:n,destinationFeeConfig:s,destinationFeeBalanceAmount:o,evmSigner:i,extrinsic:m,feeConfig:c,polkadot:r,sourceAddress:u}){if(e){if(!i)throw new Error("EVM Signer must be provided");if(s&&o&&typeof s.amount=="number"){let f=Number((0,y.toDecimal)(o.amount,o.decimals));if(f&&s.amount>f)throw new Error(`Can't get a fee, make sure you have ${s==null?void 0:s.amount} ${s==null?void 0:s.asset.originSymbol} in your source balance, needed for destination fees`)}return ht({balance:a,chain:t,config:e,decimals:n,evmSigner:i})}if(m){let f=await Ct(a,m,r,u),p=Ot(n,c),d=f+p;return t.usesChainDecimals?(0,y.convertDecimals)(d,r.decimals,n):d}throw new Error("Either contract or extrinsic must be provided")}async function ht({balance:a,config:t,decimals:e,evmSigner:n,chain:s}){let i=await Q(t,n,s).getFee(a);return(0,y.convertDecimals)(i,18,e)}async function Ct(a,t,e,n){try{return await e.getFee(n,t)}catch(s){if(a)throw s;return 0n}}function Ot(a,t){return t!=null&&t.xcmDeliveryFeeAmount?(0,y.toBigInt)(t.xcmDeliveryFeeAmount,a):0n}function At({balanceAmount:a,existentialDeposit:t,feeAmount:e,minAmount:n}){let s=a.toBig().minus(n.toBig()).minus(a.isSame(t)?t.toBig():(0,L.default)(0)).minus(a.isSame(e)?e.toBig():(0,L.default)(0));return a.copyWith({amount:s.lt(0)?0n:BigInt(s.toFixed())})}async function U({address:a,chain:t,assets:e,polkadot:n}){let s=e.reduce((i,m)=>i.some(c=>c.asset.isEqual(m.asset))?i:[m,...i],[]);return await Promise.all(s.map(async i=>{let m=await A({address:a,asset:i.asset,chain:t,config:i,polkadot:n}),c=await C({address:a,asset:i.asset,balanceBuilder:i.balance,chain:t,decimals:m,polkadot:n});return M.AssetAmount.fromAsset(i.asset,{amount:c,decimals:m})}))}var x=require("@moonbeam-network/xcm-config");var G=require("@moonbeam-network/xcm-utils"),b=ft(require("big.js"),1);var _e=require("@polkadot/api-augment"),bt=require("@moonbeam-network/xcm-types"),Pt=require("@moonbeam-network/xcm-utils"),B=class a{api;chain;configService;constructor(t,e,n){this.api=t,this.chain=e,this.configService=n}static async create(t,e){return new a(await(0,Pt.getPolkadotApi)(t.ws),t,e)}static async createMulti(t,e){return Promise.all(t.map(n=>a.create(n,e)))}get decimals(){return this.api.registry.chainDecimals.at(0)||12}get asset(){let t=this.api.registry.chainTokens.at(0),e=t==null?void 0:t.toString().toLowerCase();if(!e)throw new Error("No native symbol key found");let n=this.configService.getAsset(e);if(!n)throw new Error(`No asset found for key "${e}" and symbol "${t}"`);return n}get existentialDeposit(){var s,o;let t=(s=this.api.consts.balances)==null?void 0:s.existentialDeposit,e=(o=this.api.consts.eqBalances)==null?void 0:o.existentialDeposit,n=(t==null?void 0:t.toBigInt())||(e==null?void 0:e.toBigInt())||0n;return bt.AssetAmount.fromAsset(this.asset,{amount:n,decimals:this.decimals})}async getAssetMeta(t){var i,m,c,r,u,f;let e=((i=this.api.query.assets)==null?void 0:i.metadata)||((m=this.api.query.assetRegistry)==null?void 0:m.assets)||((c=this.api.query.assetRegistry)==null?void 0:c.metadata)||((r=this.api.query.assetRegistry)==null?void 0:r.currencyMetadatas)||((u=this.api.query.assetRegistry)==null?void 0:u.assetMetadatas)||((f=this.api.query.assetRegistry)==null?void 0:f.assetMetadataMap);if(!e)return;let n=await e(t),s="unwrapOrDefault"in n?n.unwrapOrDefault():n;return{decimals:("unwrapOrDefault"in s.decimals?s.decimals.unwrapOrDefault():s.decimals).toNumber(),symbol:s.symbol.toString()}}async getAssetDecimalsFromQuery(t){var s;let e=(s=this.api.query.assetsRegistry)==null?void 0:s.assetDecimals;return e?(await e(t)).unwrapOrDefault().toNumber():void 0}async getAssetDecimals(t){var s;let e=this.chain.getMetadataAssetId(t),n=this.chain.getAssetDecimals(t)||await this.getAssetDecimalsFromQuery(e)||((s=await this.getAssetMeta(e))==null?void 0:s.decimals)||this.decimals;if(!n)throw new Error(`No decimals found for asset ${t.originSymbol}`);return n}async query(t){let e=await this.api.query[t.module][t.func](...t.args);return t.transform(e)}async getFee(t,e){let n=this.api.tx[e.module][e.func],s=e.getArgs(n);return(await n(...s).paymentInfo(t,{nonce:-1})).partialFee.toBigInt()}async transfer(t,e,n){let s=this.api.tx[e.module][e.func],o=e.getArgs(s);return(await s(...o).signAndSend(this.#t(n)?t:n,{nonce:-1,signer:this.#t(n)?n:void 0,withSignedTransaction:!0})).toString()}#t(t){return"signPayload"in t}};var Y=require("@moonbeam-network/xcm-types"),_=require("@moonbeam-network/xcm-utils");async function St({transferConfig:a,destinationAddress:t,polkadot:e}){let{asset:n,destination:{chain:s,config:o}}=a,i=Y.AssetAmount.fromAsset(n,{amount:0n,decimals:await A({address:t,chain:s,config:o,polkadot:e})}),m=await C({address:t,asset:o.asset,balanceBuilder:o.balance,chain:s,decimals:i.decimals,polkadot:e}),c=await F(o,e),r=i.copyWith({amount:m}),{existentialDeposit:u}=e,f=await qt({address:t,config:a,polkadot:e}),p=i.copyWith({amount:c});return{balance:r,chain:s,existentialDeposit:u,fee:f,min:p,sovereignAccountBalances:s.checkSovereignAccountBalances?await $t({decimals:i.decimals,polkadot:e,transferConfig:a}):void 0}}async function qt({address:a,config:t,polkadot:e}){let{amount:n,asset:s}=t.source.config.destinationFee,o=await e.getAssetDecimals(s),i=Y.AssetAmount.fromAsset(s,{amount:0n,decimals:o});if(Number.isFinite(n))return i.copyWith({amount:(0,_.toBigInt)(n,o)});let m=n.build({address:a,api:e.api,chain:e.chain,feeAsset:e.chain.getRegisteredAssetIdOrAddress(s),transferAsset:e.chain.getRegisteredAssetIdOrAddress(t.asset)});return i.copyWith({amount:await m.call()})}async function $t({transferConfig:a,decimals:t,polkadot:e}){var f;let{destination:{chain:n,config:s},source:{config:o}}=a,i=(0,_.getSovereignAccountAddresses)(a.source.chain.parachainId),m=(f=o.destinationFee)==null?void 0:f.destinationBalance,c=n.isRelay?i.relay:i.generic,r=await C({address:c,asset:s.asset,balanceBuilder:s.balance,chain:n,decimals:t,polkadot:e});return{feeAssetBalance:m?await C({address:c,asset:o.destinationFee.asset,balanceBuilder:m,chain:n,decimals:t,polkadot:e}):void 0,transferAssetBalance:r}}async function V({configService:a,destinationAddress:t,evmSigner:e,polkadotSigner:n,sourceAddress:s,transferConfig:o}){let[i,m]=await B.createMulti([o.destination.chain,o.source.chain],a),c=await St({destinationAddress:t,polkadot:i,transferConfig:o}),r=await Qt(m,c.fee),u=await J({destinationAddress:t,destinationFee:r,evmSigner:e,polkadot:m,sourceAddress:s,transferConfig:o});return{destination:c,getEstimate(f){let d=(0,b.default)((0,G.toBigInt)(f,u.balance.decimals).toString()).minus(u.balance.isSame(r)?r.toBig():(0,b.default)(0));return u.balance.copyWith({amount:d.lt(0)?0n:BigInt(d.toFixed())})},isSwapPossible:!0,max:u.max,min:Nt(c),source:u,async swap(){return V({configService:a,destinationAddress:s,evmSigner:e,polkadotSigner:n,sourceAddress:t,transferConfig:{...o,destination:o.source,source:o.destination}})},async transfer(f){var W,R;let p=(0,G.toBigInt)(f,u.balance.decimals);j({amount:p,destination:c,source:u});let{asset:d,source:{chain:l,config:D}}=o,g=(W=D.contract)==null?void 0:W.build({address:t,amount:p,asset:l.getAssetId(d),destination:c.chain,fee:r.amount,feeAsset:l.getAssetId(r)}),k=(R=D.extrinsic)==null?void 0:R.build({address:t,amount:p,asset:l.getAssetId(d),destination:c.chain,fee:r.amount,feeAsset:l.getAssetId(r),palletInstance:l.getAssetPalletInstance(d),source:l});if(g){if(!e)throw new Error("EVM Signer must be provided");return Q(g,e,l).transfer().then(E=>typeof E=="object"?E.hash:E)}if(k){if(!n)throw new Error("Polkadot signer must be provided");return m.transfer(s,k,n)}throw new Error("Either contract or extrinsic must be provided")}}}function Nt({balance:a,existentialDeposit:t,fee:e,min:n}){let s=(0,b.default)(0).plus(a.isSame(e)?e.toBig():(0,b.default)(0)).plus(a.isSame(t)&&a.toBig().lt(t.toBig())?t.toBig():(0,b.default)(0)).plus(a.toBig().lt(n.toBig())?n.toBig():(0,b.default)(0));return a.copyWith({amount:BigInt(s.toFixed())})}async function Qt(a,t){let e=await a.getAssetDecimals(t);return t.decimals===e?t:t.copyWith({amount:(0,G.convertDecimals)(t.amount,t.decimals,e),decimals:e})}function Xt(a){let t=(a==null?void 0:a.configService)??new x.ConfigService;return{assets(e){let{assets:n,asset:s}=(0,x.ConfigBuilder)(t).assets(e);return{assets:n,asset(o){let{sourceChains:i,source:m}=s(o);return{sourceChains:i,source(c){let{destinationChains:r,destination:u}=m(c);return{destinationChains:r,destination(f){return{async accounts(p,d,l){return V({...a,configService:t,destinationAddress:d,evmSigner:(l==null?void 0:l.evmSigner)??(l==null?void 0:l.ethersSigner),sourceAddress:p,transferConfig:u(f).build(),polkadotSigner:l==null?void 0:l.polkadotSigner})}}}}}}}}},async getTransferData({destinationAddress:e,destinationKeyOrChain:n,ethersSigner:s,evmSigner:o,keyOrAsset:i,polkadotSigner:m,sourceAddress:c,sourceKeyOrChain:r}){return V({configService:t,destinationAddress:e,evmSigner:o??s,polkadotSigner:m,sourceAddress:c,transferConfig:(0,x.ConfigBuilder)(t).assets().asset(i).source(r).destination(n).build()})}}}async function _t(a,t){let e=new x.ConfigService,s=e.getChainConfig(a).getAssetsConfigs(),o=await B.create(a,e);return await U({chain:a,assets:s,address:t,polkadot:o})}0&&(module.exports={Sdk,getAssetsBalances,getBalance,getContractFee,getDecimals,getExtrinsicFee,getFee,getFeeBalance,getMax,getMin,getParachainBalances,getSourceData,validateSovereignAccountBalances}); //# sourceMappingURL=index.cjs.map