@vleap/warps 2.3.0-alpha.0 → 2.3.0-alpha.2
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/dist/index.js +27 -4
- package/dist/index.mjs +27 -4
- package/package.json +12 -11
package/dist/index.js
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
|
-
"use strict";var At=Object.create;var rt=Object.defineProperty;var xt=Object.getOwnPropertyDescriptor;var Bt=Object.getOwnPropertyNames;var St=Object.getPrototypeOf,Et=Object.prototype.hasOwnProperty;var Pt=(a,t)=>{for(var e in t)rt(a,e,{get:t[e],enumerable:!0})},mt=(a,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Bt(t))!Et.call(a,n)&&n!==e&&rt(a,n,{get:()=>t[n],enumerable:!(r=xt(t,n))||r.enumerable});return a};var st=(a,t,e)=>(e=a!=null?At(St(a)):{},mt(t||!a||!a.__esModule?rt(e,"default",{value:a,enumerable:!0}):e,a)),Rt=a=>mt(rt({},"__esModule",{value:!0}),a);var re={};Pt(re,{BrandBuilder:()=>pt,CacheKey:()=>P,CacheTtl:()=>ct,Config:()=>v,WarpAbiBuilder:()=>tt,WarpActionExecutor:()=>dt,WarpArgSerializer:()=>_,WarpBuilder:()=>Y,WarpCache:()=>V,WarpConstants:()=>f,WarpContractLoader:()=>et,WarpIndex:()=>gt,WarpInterpolator:()=>U,WarpLink:()=>Z,WarpProtocolVersions:()=>F,WarpRegistry:()=>$,WarpUtils:()=>y,WarpValidator:()=>X,address:()=>Gt,biguint:()=>jt,boolean:()=>Qt,codemeta:()=>Xt,composite:()=>Lt,esdt:()=>Jt,getChainExplorerUrl:()=>Vt,getLatestProtocolIdentifier:()=>O,getMainChainInfo:()=>I,getWarpActionByIndex:()=>M,hex:()=>Kt,list:()=>kt,nothing:()=>Yt,option:()=>Ft,optional:()=>Ot,replacePlaceholders:()=>z,shiftBigintBy:()=>G,string:()=>_t,toPreviewText:()=>ot,toTypedChainInfo:()=>nt,token:()=>zt,u16:()=>Mt,u32:()=>Ht,u64:()=>Dt,u8:()=>qt,variadic:()=>$t});module.exports=Rt(re);var L=require("@multiversx/sdk-core"),Tt=st(require("ajv"));var f={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierType:{Alias:"alias",Hash:"hash"},Source:{UserWallet:"user:wallet"},Globals:{UserWallet:{Placeholder:"USER_WALLET",Accessor:a=>a.config.user?.wallet},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:a=>a.chain.apiUrl},ChainExplorerUrl:{Placeholder:"CHAIN_EXPLORER",Accessor:a=>a.chain.explorerUrl}},Vars:{Query:"query",Env:"env"},ArgParamsSeparator:":",ArgCompositeSeparator:"|",Transform:{Prefix:"transform:"},Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}};var F={Warp:"2.0.1",Brand:"0.1.0",Abi:"0.1.0"},v={LatestWarpSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/v${F.Warp}.schema.json`,LatestBrandSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/brand/v${F.Brand}.schema.json`,DefaultClientUrl:a=>a==="devnet"?"https://devnet.usewarp.to":a==="testnet"?"https://testnet.usewarp.to":"https://usewarp.to",SuperClientUrls:["https://usewarp.to","https://testnet.usewarp.to","https://devnet.usewarp.to"],MainChain:{Name:"multiversx",DisplayName:"MultiversX",ApiUrl:a=>a==="devnet"?"https://devnet-api.multiversx.com":a==="testnet"?"https://testnet-api.multiversx.com":"https://api.multiversx.com",ExplorerUrl:a=>a==="devnet"?"https://devnet-explorer.multiversx.com":a==="testnet"?"https://testnet-explorer.multiversx.com":"https://explorer.multiversx.com",BlockTime:a=>6e3,AddressHrp:"erd",ChainId:a=>a==="devnet"?"D":a==="testnet"?"T":"1"},Registry:{Contract:a=>a==="devnet"?"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36":a==="testnet"?"####":"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"},AvailableActionInputSources:["field","query",f.Source.UserWallet],AvailableActionInputTypes:["string","uint8","uint16","uint32","uint64","biguint","boolean","address"],AvailableActionInputPositions:["receiver","value","transfer","arg:1","arg:2","arg:3","arg:4","arg:5","arg:6","arg:7","arg:8","arg:9","arg:10","data","ignore"]};var I=a=>({name:v.MainChain.Name,displayName:v.MainChain.DisplayName,chainId:v.MainChain.ChainId(a.env),blockTime:v.MainChain.BlockTime(a.env),addressHrp:v.MainChain.AddressHrp,apiUrl:v.MainChain.ApiUrl(a.env),explorerUrl:v.MainChain.ExplorerUrl(a.env)}),Vt=(a,t)=>a.explorerUrl+(t?"/"+t:""),O=a=>{if(a==="warp")return`warp:${F.Warp}`;if(a==="brand")return`brand:${F.Brand}`;if(a==="abi")return`abi:${F.Abi}`;throw new Error(`getLatestProtocolIdentifier: Invalid protocol name: ${a}`)},M=(a,t)=>a?.actions[t-1],nt=a=>({name:a.name.toString(),displayName:a.display_name.toString(),chainId:a.chain_id.toString(),blockTime:a.block_time.toNumber(),addressHrp:a.address_hrp.toString(),apiUrl:a.api_url.toString(),explorerUrl:a.explorer_url.toString()}),G=(a,t)=>{let e=a.toString(),[r,n=""]=e.split("."),i=Math.abs(t);if(t>0)return BigInt(r+n.padEnd(i,"0"));if(t<0){let s=r+n;if(i>=s.length)return 0n;let c=s.slice(0,-i)||"0";return BigInt(c)}else return e.includes(".")?BigInt(e.split(".")[0]):BigInt(e)},ot=(a,t=100)=>{if(!a)return"";let e=a.replace(/<\/?(h[1-6])[^>]*>/gi," - ").replace(/<\/?(p|div|ul|ol|li|br|hr)[^>]*>/gi," ").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();return e=e.startsWith("- ")?e.slice(2):e,e=e.length>t?e.substring(0,e.lastIndexOf(" ",t))+"...":e,e},z=(a,t)=>a.replace(/\{\{([^}]+)\}\}/g,(e,r)=>t[r]||"");var D=require("@multiversx/sdk-core");var K=class{constructor(t="warp-cache"){this.prefix=t}getKey(t){return`${this.prefix}:${t}`}get(t){try{let e=localStorage.getItem(this.getKey(t));if(!e)return null;let r=JSON.parse(e);return Date.now()>r.expiresAt?(localStorage.removeItem(this.getKey(t)),null):r.value}catch{return null}}set(t,e,r){let n={value:e,expiresAt:Date.now()+r*1e3};localStorage.setItem(this.getKey(t),JSON.stringify(n))}forget(t){localStorage.removeItem(this.getKey(t))}clear(){for(let t=0;t<localStorage.length;t++){let e=localStorage.key(t);e?.startsWith(this.prefix)&&localStorage.removeItem(e)}}};var N=class N{get(t){let e=N.cache.get(t);return e?Date.now()>e.expiresAt?(N.cache.delete(t),null):e.value:null}set(t,e,r){let n=Date.now()+r*1e3;N.cache.set(t,{value:e,expiresAt:n})}forget(t){N.cache.delete(t)}clear(){N.cache.clear()}};N.cache=new Map;var J=N;var ct={OneMinute:60,OneHour:60*60,OneDay:60*60*24,OneWeek:60*60*24*7,OneMonth:60*60*24*30,OneYear:60*60*24*365},P={Warp:a=>`warp:${a}`,WarpAbi:a=>`warp-abi:${a}`,RegistryInfo:a=>`registry-info:${a}`,Brand:a=>`brand:${a}`,ChainInfo:a=>`chain:${a}`,ChainInfos:()=>"chains"},V=class{constructor(t){this.strategy=this.selectStrategy(t)}selectStrategy(t){return t==="localStorage"?new K:t==="memory"?new J:typeof window<"u"&&window.localStorage?new K:new J}set(t,e,r){this.strategy.set(t,e,r)}get(t){return this.strategy.get(t)}forget(t){this.strategy.forget(t)}clear(){this.strategy.clear()}};var wt=st(require("qr-code-styling"));var k=require("@multiversx/sdk-core");var H=class H{static info(...t){H.isTestEnv||console.info(...t)}static warn(...t){H.isTestEnv||console.warn(...t)}static error(...t){H.isTestEnv||console.error(...t)}};H.isTestEnv=typeof process<"u"&&process.env.JEST_WORKER_ID!==void 0;var S=H;var ht=st(require("ajv"));var X=class{constructor(t){this.config=t;this.config=t}async validate(t){let e=[];return e.push(...this.validateMaxOneValuePosition(t)),e.push(...this.validateVariableNamesAndResultNamesUppercase(t)),e.push(...this.validateAbiIsSetIfApplicable(t)),e.push(...await this.validateSchema(t)),{valid:e.length===0,errors:e}}validateMaxOneValuePosition(t){return t.actions.filter(r=>r.inputs?r.inputs.some(n=>n.position==="value"):!1).length>1?["Only one value position action is allowed"]:[]}validateVariableNamesAndResultNamesUppercase(t){let e=[],r=(n,i)=>{n&&Object.keys(n).forEach(s=>{s!==s.toUpperCase()&&e.push(`${i} name '${s}' must be uppercase`)})};return r(t.vars,"Variable"),r(t.results,"Result"),e}validateAbiIsSetIfApplicable(t){let e=t.actions.some(i=>i.type==="contract"),r=t.actions.some(i=>i.type==="query");if(!e&&!r)return[];let n=t.actions.some(i=>i.abi);return t.results&&!n?["ABI is required when results are present for contract or query actions"]:[]}async validateSchema(t){try{let e=this.config.schema?.warp||v.LatestWarpSchemaUrl,n=await(await fetch(e)).json(),i=new ht.default,s=i.compile(n);return s(t)?[]:[`Schema validation failed: ${i.errorsText(s.errors)}`]}catch(e){return[`Schema validation failed: ${e instanceof Error?e.message:String(e)}`]}}};var Y=class{constructor(t){this.pendingWarp={protocol:O("warp"),name:"",title:"",description:null,preview:"",actions:[]};this.config=t,this.cache=new V(t.cache?.type)}createInscriptionTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpBuilder: user address not set");let e=I(this.config),r=new k.TransactionsFactoryConfig({chainID:e.chainId}),n=new k.TransferTransactionsFactory({config:r}),i=k.Address.newFromBech32(this.config.user.wallet),s=JSON.stringify(t),c=n.createTransactionForTransfer(i,{receiver:k.Address.newFromBech32(this.config.user.wallet),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(s))});return c.gasLimit=c.gasLimit+BigInt(2e6),c}async createFromRaw(t,e=!0){let r=JSON.parse(t);return e&&await this.validate(r),r}async createFromTransaction(t,e=!1){let r=await this.createFromRaw(t.data.toString(),e);return r.meta={hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},r}async createFromTransactionHash(t,e){let r=P.Warp(t);if(e){let c=this.cache.get(r);if(c)return S.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),c}let n=I(this.config),s=y.getChainEntrypoint(n,this.config.env).createNetworkProvider();try{let c=await s.getTransaction(t),u=await this.createFromTransaction(c);return e&&e.ttl&&u&&this.cache.set(r,u,e.ttl),u}catch(c){return console.error("WarpBuilder: Error creating from transaction hash",c),null}}setName(t){return this.pendingWarp.name=t,this}setTitle(t){return this.pendingWarp.title=t,this}setDescription(t){return this.pendingWarp.description=t,this}setPreview(t){return this.pendingWarp.preview=t,this}setActions(t){return this.pendingWarp.actions=t,this}addAction(t){return this.pendingWarp.actions.push(t),this}async build(){return this.ensure(this.pendingWarp.protocol,"protocol is required"),this.ensure(this.pendingWarp.name,"name is required"),this.ensure(this.pendingWarp.title,"title is required"),this.ensure(this.pendingWarp.actions.length>0,"actions are required"),await this.validate(this.pendingWarp),this.pendingWarp}getDescriptionPreview(t,e=100){return ot(t,e)}ensure(t,e){if(!t)throw new Error(e)}async validate(t){let r=await new X(this.config).validate(t);if(!r.valid)throw new Error(r.errors.join(`
|
|
2
|
-
`))}};var U=class{static async apply(t,e){let r=this.applyVars(t,e);return await this.applyGlobals(t,r)}static async applyGlobals(t,e){let r={...e};return r.actions=await Promise.all(r.actions.map(async n=>await this.applyActionGlobals(t,n))),r=await this.applyRootGlobals(r,t),r}static applyVars(t,e){if(!e?.vars)return e;let r=JSON.stringify(e),n=(i,s)=>{r=r.replace(new RegExp(`{{${i.toUpperCase()}}}`,"g"),s.toString())};return Object.entries(e.vars).forEach(([i,s])=>{if(typeof s!="string")n(i,s);else if(s.startsWith(`${f.Vars.Query}:`)){if(!t.currentUrl)throw new Error("WarpUtils: currentUrl config is required to prepare vars");let c=s.split(`${f.Vars.Query}:`)[1],u=new URLSearchParams(t.currentUrl.split("?")[1]).get(c);u&&n(i,u)}else if(s.startsWith(`${f.Vars.Env}:`)){let c=s.split(`${f.Vars.Env}:`)[1],u=t.vars?.[c];u&&n(i,u)}else s===f.Source.UserWallet&&t.user?.wallet?n(i,t.user.wallet):n(i,s)}),JSON.parse(r)}static async applyRootGlobals(t,e){let r=JSON.stringify(t),n={config:e,chain:I(e)};return Object.values(f.Globals).forEach(i=>{let s=i.Accessor(n);s!=null&&(r=r.replace(new RegExp(`{{${i.Placeholder}}}`,"g"),s.toString()))}),JSON.parse(r)}static async applyActionGlobals(t,e){let r=await y.getChainInfoForAction(t,e),n=JSON.stringify(e),i={config:t,chain:r};return Object.values(f.Globals).forEach(s=>{let c=s.Accessor(i);c!=null&&(n=n.replace(new RegExp(`{{${s.Placeholder}}}`,"g"),c.toString()))}),JSON.parse(n)}};var m=require("@multiversx/sdk-core/out");var ut={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"}],outputs:[]},{name:"setWarpAlias",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias",type:"bytes"}],outputs:[]},{name:"forceRemoveAlias",mutability:"mutable",inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"verifyWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"transferOwnership",mutability:"mutable",inputs:[{name:"warp",type:"bytes"},{name:"new_owner",type:"Address"}],outputs:[]},{name:"getUserWarps",mutability:"readonly",inputs:[{name:"address",type:"Address"}],outputs:[{type:"variadic<InfoView>",multi_result:!0}]},{name:"getInfoByAlias",mutability:"readonly",inputs:[{name:"alias",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"getInfoByHash",mutability:"readonly",inputs:[{name:"hash",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"setVault",onlyOwner:!0,mutability:"mutable",inputs:[{name:"vault",type:"Address"}],outputs:[]},{name:"setUnitPrice",onlyOwner:!0,mutability:"mutable",inputs:[{name:"amount",type:"BigUint"}],outputs:[]},{name:"addAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"removeAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"ConfigView"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]},{name:"setChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"}],outputs:[]},{name:"removeChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"}],outputs:[]},{name:"getChain",mutability:"readonly",inputs:[{name:"name",type:"bytes"}],outputs:[{type:"ChainView"}]},{name:"getChains",mutability:"readonly",inputs:[],outputs:[{type:"variadic<ChainView>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpUnregistered",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"warpUpgraded",inputs:[{name:"alias",type:"bytes",indexed:!0},{name:"new_warp",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{identifier:"ownershipTransferred",inputs:[{name:"warp",type:"bytes",indexed:!0},{name:"old_owner",type:"Address",indexed:!0},{name:"new_owner",type:"Address",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{ChainView:{type:"struct",fields:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"}]},ConfigView:{type:"struct",fields:[{name:"unit_price",type:"BigUint"},{name:"admins",type:"List<Address>"}]},InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"owner",type:"Address"},{name:"created_at",type:"u64"},{name:"upgraded_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var it=a=>({hash:a.hash.toString("hex"),alias:a.alias?.toString()||null,trust:a.trust.toString(),owner:a.owner.toString(),createdAt:a.created_at.toNumber(),upgradedAt:a.upgraded_at?.toNumber(),brand:a.brand?.toString("hex")||null,upgrade:a.upgrade?.toString("hex")||null}),yt=a=>({unitPrice:BigInt(a.unit_price.toString()),admins:a.admins.map(t=>t.toBech32())});var $=class{constructor(t){this.config=t,this.cache=new V(t.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]}}async init(){await this.loadRegistryConfigs()}createWarpRegisterTransaction(t,e,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let n=m.Address.newFromBech32(this.config.user.wallet),i=()=>this.isCurrentUserAdmin()?BigInt(0):e&&r?this.registryConfig.unitPrice*BigInt(3):e?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,s=()=>e&&r?[m.BytesValue.fromHex(t),m.BytesValue.fromUTF8(e),m.BytesValue.fromHex(r)]:e?[m.BytesValue.fromHex(t),m.BytesValue.fromUTF8(e)]:[m.BytesValue.fromHex(t)];return this.getFactory().createTransactionForExecute(n,{contract:this.getRegistryContractAddress(),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:i(),arguments:s()})}createWarpUnregisterTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=m.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(t)]})}createWarpUpgradeTransaction(t,e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromUTF8(t),m.BytesValue.fromHex(e)]})}createWarpAliasSetTransaction(t,e){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(t),m.BytesValue.fromUTF8(e)]})}createWarpVerifyTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=m.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(t)]})}createWarpTransferOwnershipTransaction(t,e){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[m.BytesValue.fromHex(t),new m.AddressValue(new m.Address(e))]})}createBrandRegisterTransaction(t){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=m.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(t)]})}createWarpBrandingTransaction(t,e){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=m.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[m.BytesValue.fromHex(t),m.BytesValue.fromHex(e)]})}async getInfoByAlias(t,e){try{let r=P.RegistryInfo(t),n=e?this.cache.get(r):null;if(n)return S.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${t}`),n;let i=this.getRegistryContractAddress(),s=this.getController(),c=s.createQuery({contract:i,function:"getInfoByAlias",arguments:[m.BytesValue.fromUTF8(t)]}),u=await s.runQuery(c),[p]=s.parseQueryResponse(u),d=p?it(p):null,g=d?.brand?await this.fetchBrand(d.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:d,brand:g},e.ttl),{registryInfo:d,brand:g}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(t,e){try{let r=P.RegistryInfo(t);if(e){let g=this.cache.get(r);if(g)return S.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${t}`),g}let n=this.getRegistryContractAddress(),i=this.getController(),s=i.createQuery({contract:n,function:"getInfoByHash",arguments:[m.BytesValue.fromHex(t)]}),c=await i.runQuery(s),[u]=i.parseQueryResponse(c),p=u?it(u):null,d=p?.brand?await this.fetchBrand(p.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:p,brand:d},e.ttl),{registryInfo:p,brand:d}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(t){try{let e=t||this.config.user?.wallet;if(!e)throw new Error("WarpRegistry: user address not set");let r=this.getRegistryContractAddress(),n=this.getController(),i=n.createQuery({contract:r,function:"getUserWarps",arguments:[new m.AddressValue(new m.Address(e))]}),s=await n.runQuery(i),[c]=n.parseQueryResponse(s);return c.map(it)}catch{return[]}}async getUserBrands(t){try{let e=t||this.config.user?.wallet;if(!e)throw new Error("WarpRegistry: user address not set");let r=this.getRegistryContractAddress(),n=this.getController(),i=n.createQuery({contract:r,function:"getUserBrands",arguments:[new m.AddressValue(new m.Address(e))]}),s=await n.runQuery(i),[c]=n.parseQueryResponse(s),u=c.map(g=>g.toString("hex")),p={ttl:365*24*60*60};return(await Promise.all(u.map(g=>this.fetchBrand(g,p)))).filter(g=>g!==null)}catch{return[]}}async getChainInfos(t){let e=P.ChainInfos();if(t&&t.ttl){let p=this.cache.get(e);if(p)return S.info("WarpRegistry (getChainInfos): ChainInfos found in cache"),p}let r=this.getRegistryContractAddress(),n=this.getController(),i=n.createQuery({contract:r,function:"getChains",arguments:[]}),s=await n.runQuery(i),[c]=n.parseQueryResponse(s),u=c.map(nt);if(t&&t.ttl){for(let p of u)this.cache.set(P.ChainInfo(p.chain),p,t.ttl);this.cache.set(e,u,t.ttl)}return u}async getChainInfo(t,e){try{let r=P.ChainInfo(t),n=e?this.cache.get(r):null;if(n)return S.info(`WarpRegistry (getChainInfo): ChainInfo found in cache: ${t}`),n;let i=this.getRegistryContractAddress(),s=this.getController(),c=s.createQuery({contract:i,function:"getChain",arguments:[m.BytesValue.fromUTF8(t)]}),u=await s.runQuery(c),[p]=s.parseQueryResponse(u),d=p?nt(p):null;return e&&e.ttl&&d&&this.cache.set(r,d,e.ttl),d}catch{return null}}async fetchBrand(t,e){let r=P.Brand(t),n=e?this.cache.get(r):null;if(n)return S.info(`WarpRegistry (fetchBrand): Brand found in cache: ${t}`),n;let i=I(this.config),c=y.getChainEntrypoint(i,this.config.env).createNetworkProvider();try{let u=await c.getTransaction(t),p=JSON.parse(u.data.toString());return p.meta={hash:u.hash,creator:u.sender.bech32(),createdAt:new Date(u.timestamp*1e3).toISOString()},e&&e.ttl&&this.cache.set(r,p,e.ttl),p}catch{return null}}getRegistryContractAddress(){return m.Address.newFromBech32(this.config.registry?.contract||v.Registry.Contract(this.config.env))}async loadRegistryConfigs(){let t=this.getRegistryContractAddress(),e=this.getController(),[r]=await e.query({contract:t,function:"getConfig",arguments:[]}),n=r?yt(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let t=I(this.config),e=new m.TransactionsFactoryConfig({chainID:t.chainId}),r=m.AbiRegistry.create(ut);return new m.SmartContractTransactionsFactory({config:e,abi:r})}getController(){let t=I(this.config),e=y.getChainEntrypoint(t,this.config.env),r=m.AbiRegistry.create(ut);return e.createSmartContractController(r)}isCurrentUserAdmin(){return!!this.config.user?.wallet&&this.registryConfig.admins.includes(this.config.user.wallet)}};var Z=class{constructor(t){this.config=t;this.config=t}isValid(t){return t.startsWith(f.HttpProtocolPrefix)?!!this.extractIdentifierInfoFromUrl(t):!1}async detectFromHtml(t){if(!t.length)return{match:!1,results:[]};let n=[...t.matchAll(/https?:\/\/[^\s"'<>]+/gi)].map(p=>p[0]).filter(p=>this.isValid(p)).map(p=>this.detect(p)),s=(await Promise.all(n)).filter(p=>p.match),c=s.length>0,u=s.map(p=>({url:p.url,warp:p.warp}));return{match:c,results:u}}async detect(t,e){let r={match:!1,url:t,warp:null,registryInfo:null,brand:null},n=t.startsWith(f.HttpProtocolPrefix)?this.extractIdentifierInfoFromUrl(t):y.getInfoFromPrefixedIdentifier(t);if(!n)return r;try{let{type:i,identifierBase:s}=n,c=new Y(this.config),u=new $(this.config),p=null,d=null,g=null;if(i==="hash"){p=await c.createFromTransactionHash(s,e);let W=await u.getInfoByHash(s,e);d=W.registryInfo,g=W.brand}else if(i==="alias"){let W=await u.getInfoByAlias(s,e);d=W.registryInfo,g=W.brand,W.registryInfo&&(p=await c.createFromTransactionHash(W.registryInfo.hash,e))}let T=p?await U.apply(this.config,p):null;return T?{match:!0,url:t,warp:T,registryInfo:d,brand:g}:r}catch(i){return S.error("Error detecting warp link",i),r}}build(t,e){let r=this.config.clientUrl||v.DefaultClientUrl(this.config.env),n=t===f.IdentifierType.Alias?encodeURIComponent(e):encodeURIComponent(t+f.IdentifierParamSeparator+e);return v.SuperClientUrls.includes(r)?`${r}/${n}`:`${r}?${f.IdentifierParamName}=${n}`}buildFromPrefixedIdentifier(t){let e=y.getInfoFromPrefixedIdentifier(t);return e?this.build(e.type,e.identifierBase):""}generateQrCode(t,e,r=512,n="white",i="black",s="#23F7DD"){let c=this.build(t,e);return new wt.default({type:"svg",width:r,height:r,data:String(c),margin:16,qrOptions:{typeNumber:0,mode:"Byte",errorCorrectionLevel:"Q"},backgroundOptions:{color:n},dotsOptions:{type:"extra-rounded",color:i},cornersSquareOptions:{type:"extra-rounded",color:i},cornersDotOptions:{type:"square",color:i},imageOptions:{hideBackgroundDots:!0,imageSize:.4,margin:8},image:`data:image/svg+xml;utf8,<svg width="16" height="16" viewBox="0 0 100 100" fill="${encodeURIComponent(s)}" xmlns="http://www.w3.org/2000/svg"><path d="M54.8383 50.0242L95 28.8232L88.2456 16L51.4717 30.6974C50.5241 31.0764 49.4759 31.0764 48.5283 30.6974L11.7544 16L5 28.8232L45.1616 50.0242L5 71.2255L11.7544 84.0488L48.5283 69.351C49.4759 68.9724 50.5241 68.9724 51.4717 69.351L88.2456 84.0488L95 71.2255L54.8383 50.0242Z"/></svg>`})}extractIdentifierInfoFromUrl(t){let e=new URL(t),r=v.SuperClientUrls.includes(e.origin),n=e.searchParams.get(f.IdentifierParamName),i=r&&!n?e.pathname.split("/")[1]:n;if(!i)return null;let s=decodeURIComponent(i);return y.getInfoFromPrefixedIdentifier(s)}};var Nt="https://",y=class{static getInfoFromPrefixedIdentifier(t){let e=decodeURIComponent(t),r=e.includes(f.IdentifierParamSeparator)?e:`${f.IdentifierType.Alias}${f.IdentifierParamSeparator}${e}`,[n,i]=r.split(f.IdentifierParamSeparator),s=i.split("?")[0];return{type:n,identifier:i,identifierBase:s}}static getNextInfo(t,e,r,n){let i=e.actions?.[r]?.next||e.next||null;if(!i)return null;if(i.startsWith(Nt))return[{identifier:null,url:i}];let[s,c]=i.split("?");if(!c)return[{identifier:s,url:this.buildNextUrl(s,t)}];let u=c.match(/{{([^}]+)\[\](\.[^}]+)?}}/g)||[];if(u.length===0){let h=z(c,{...e.vars,...n}),w=h?`${s}?${h}`:s;return[{identifier:w,url:this.buildNextUrl(w,t)}]}let p=u[0];if(!p)return[];let d=p.match(/{{([^[]+)\[\]/),g=d?d[1]:null;if(!g||n[g]===void 0)return[];let T=Array.isArray(n[g])?n[g]:[n[g]];if(T.length===0)return[];let W=u.filter(h=>h.includes(`{{${g}[]`)).map(h=>{let w=h.match(/\[\](\.[^}]+)?}}/),b=w&&w[1]||"";return{placeholder:h,field:b?b.slice(1):"",regex:new RegExp(h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g")}});return T.map(h=>{let w=c;for(let{regex:A,field:R}of W){let E=R?this.getNestedValue(h,R):h;if(E==null)return null;w=w.replace(A,E)}if(w.includes("{{")||w.includes("}}"))return null;let b=w?`${s}?${w}`:s;return{identifier:b,url:this.buildNextUrl(b,t)}}).filter(h=>h!==null)}static buildNextUrl(t,e){let[r,n]=t.split("?"),i=this.getInfoFromPrefixedIdentifier(r)||{type:"alias",identifier:r,identifierBase:r},c=new Z(e).build(i.type,i.identifierBase);if(!n)return c;let u=new URL(c);return new URLSearchParams(n).forEach((p,d)=>u.searchParams.set(d,p)),u.toString().replace(/\/\?/,"?")}static getNestedValue(t,e){return e.split(".").reduce((r,n)=>r?.[n],t)}static async getChainInfoForAction(t,e){if(!e.chain)return I(t);let r=await new $(t).getChainInfo(e.chain,{ttl:ct.OneWeek});if(!r)throw new Error(`WarpActionExecutor: Chain info not found for ${e.chain}`);return r}static getChainEntrypoint(t,e){let r="warp-sdk",n="api";return e==="devnet"?new D.DevnetEntrypoint(t.apiUrl,n,r):e==="testnet"?new D.TestnetEntrypoint(t.apiUrl,n,r):new D.MainnetEntrypoint(t.apiUrl,n,r)}};var pt=class{constructor(t){this.pendingBrand={protocol:O("brand"),name:"",description:"",logo:""};this.config=t}createInscriptionTransaction(t){if(!this.config.user?.wallet)throw new Error("BrandBuilder: user address not set");let e=I(this.config),r=new L.TransactionsFactoryConfig({chainID:e.chainId}),n=new L.TransferTransactionsFactory({config:r}),i=L.Address.newFromBech32(this.config.user.wallet),s=JSON.stringify(t);return n.createTransactionForNativeTokenTransfer(i,{receiver:L.Address.newFromBech32(this.config.user.wallet),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(s))})}async createFromRaw(t,e=!0){let r=JSON.parse(t);return e&&await this.ensureValidSchema(r),r}async createFromTransaction(t,e=!1){return await this.createFromRaw(t.data.toString(),e)}async createFromTransactionHash(t){let e=I(this.config),n=y.getChainEntrypoint(e,this.config.env).createNetworkProvider();try{let i=await n.getTransaction(t);return this.createFromTransaction(i)}catch(i){return console.error("BrandBuilder: Error creating from transaction hash",i),null}}setName(t){return this.pendingBrand.name=t,this}setDescription(t){return this.pendingBrand.description=t,this}setLogo(t){return this.pendingBrand.logo=t,this}setUrls(t){return this.pendingBrand.urls=t,this}setColors(t){return this.pendingBrand.colors=t,this}setCta(t){return this.pendingBrand.cta=t,this}async build(){return this.ensure(this.pendingBrand.name,"name is required"),this.ensure(this.pendingBrand.description,"description is required"),this.ensure(this.pendingBrand.logo,"logo is required"),await this.ensureValidSchema(this.pendingBrand),this.pendingBrand}ensure(t,e){if(!t)throw new Error(`Warp: ${e}`)}async ensureValidSchema(t){let e=this.config.schema?.brand||v.LatestBrandSchemaUrl,n=await(await fetch(e)).json(),i=new Tt.default,s=i.compile(n);if(!s(t))throw new Error(`BrandBuilder: schema validation failed: ${i.errorsText(s.errors)}`)}};var l=require("@multiversx/sdk-core/out"),Ft=(a,t)=>a?l.OptionValue.newProvided(a):t?l.OptionValue.newMissingTyped(t):l.OptionValue.newMissing(),Ot=(a,t)=>a?new l.OptionalValue(a.getType(),a):t?new l.OptionalValue(t):l.OptionalValue.newMissing(),kt=a=>{if(a.length===0)throw new Error("Cannot create a list from an empty array");let t=a[0].getType();return new l.List(t,a)},$t=a=>l.VariadicValue.fromItems(...a),Lt=a=>{let t=a.map(e=>e.getType());return new l.CompositeValue(new l.CompositeType(...t),a)},_t=a=>l.StringValue.fromUTF8(a),qt=a=>new l.U8Value(a),Mt=a=>new l.U16Value(a),Ht=a=>new l.U32Value(a),Dt=a=>new l.U64Value(a),jt=a=>new l.BigUIntValue(BigInt(a)),Qt=a=>new l.BooleanValue(a),Gt=a=>new l.AddressValue(l.Address.newFromBech32(a)),zt=a=>new l.TokenIdentifierValue(a),Kt=a=>l.BytesValue.fromHex(a),Jt=a=>new l.Struct(new l.StructType("EsdtTokenPayment",[new l.FieldDefinition("token_identifier","",new l.TokenIdentifierType),new l.FieldDefinition("token_nonce","",new l.U64Type),new l.FieldDefinition("amount","",new l.BigUIntType)]),[new l.Field(new l.TokenIdentifierValue(a.token.identifier),"token_identifier"),new l.Field(new l.U64Value(BigInt(a.token.nonce)),"token_nonce"),new l.Field(new l.BigUIntValue(BigInt(a.amount)),"amount")]),Xt=a=>new l.CodeMetadataValue(l.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(a,"hex")))),Yt=()=>new l.NothingValue;var j=require("@multiversx/sdk-core");var tt=class{constructor(t){this.cache=new V;this.config=t}createInscriptionTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpBuilder: user address not set");let e=I(this.config),r=new j.TransactionsFactoryConfig({chainID:e.chainId}),n=new j.TransferTransactionsFactory({config:r}),i={protocol:O("abi"),content:t},s=j.Address.newFromBech32(this.config.user.wallet),c=JSON.stringify(i),u=n.createTransactionForTransfer(s,{receiver:s,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(c))});return u.gasLimit=u.gasLimit+BigInt(2e6),u}async createFromRaw(t){return JSON.parse(t)}async createFromTransaction(t){let e=await this.createFromRaw(t.data.toString());return e.meta={hash:t.hash,creator:t.sender.bech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},e}async createFromTransactionHash(t,e){let r=P.WarpAbi(t);if(e){let c=this.cache.get(r);if(c)return S.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${t}`),c}let n=I(this.config),s=y.getChainEntrypoint(n,this.config.env).createNetworkProvider();try{let c=await s.getTransaction(t),u=await this.createFromTransaction(c);return e&&e.ttl&&u&&this.cache.set(r,u,e.ttl),u}catch(c){return console.error("WarpAbiBuilder: Error creating from transaction hash",c),null}}};var C=require("@multiversx/sdk-core");var Q=require("@multiversx/sdk-core/out");var o=require("@multiversx/sdk-core/out");var Ct=new RegExp(`${f.ArgParamsSeparator}(.*)`),_=class{nativeToString(t,e){return t==="esdt"&&e instanceof o.TokenTransfer?`esdt:${e.token.identifier}|${e.token.nonce.toString()}|${e.amount.toString()}`:`${t}:${e?.toString()??""}`}typedToString(t){if(t.hasClassOrSuperclass(o.OptionValue.ClassName))return t.isSet()?`option:${this.typedToString(t.getTypedValue())}`:"option:null";if(t.hasClassOrSuperclass(o.OptionalValue.ClassName))return t.isSet()?`optional:${this.typedToString(t.getTypedValue())}`:"optional:null";if(t.hasClassOrSuperclass(o.List.ClassName)){let e=t.getItems(),n=e.map(s=>this.typedToString(s).split(f.ArgParamsSeparator)[0])[0],i=e.map(s=>this.typedToString(s).split(f.ArgParamsSeparator)[1]);return`list:${n}:${i.join(",")}`}if(t.hasClassOrSuperclass(o.VariadicValue.ClassName)){let e=t.getItems(),n=e.map(s=>this.typedToString(s).split(f.ArgParamsSeparator)[0])[0],i=e.map(s=>this.typedToString(s).split(f.ArgParamsSeparator)[1]);return`variadic:${n}:${i.join(",")}`}if(t.hasClassOrSuperclass(o.CompositeValue.ClassName)){let e=t.getItems(),r=e.map(c=>this.typedToString(c).split(f.ArgParamsSeparator)[0]),n=e.map(c=>this.typedToString(c).split(f.ArgParamsSeparator)[1]),i=r.join(f.ArgCompositeSeparator),s=n.join(f.ArgCompositeSeparator);return`composite(${i}):${s}`}if(t.hasClassOrSuperclass(o.BigUIntValue.ClassName)||t.getType().getName()==="BigUint")return`biguint:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(o.U8Value.ClassName))return`uint8:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(o.U16Value.ClassName))return`uint16:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(o.U32Value.ClassName))return`uint32:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(o.U64Value.ClassName))return`uint64:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(o.StringValue.ClassName))return`string:${t.valueOf()}`;if(t.hasClassOrSuperclass(o.BooleanValue.ClassName))return`bool:${t.valueOf()}`;if(t.hasClassOrSuperclass(o.AddressValue.ClassName))return`address:${t.valueOf().bech32()}`;if(t.hasClassOrSuperclass(o.TokenIdentifierValue.ClassName))return`token:${t.valueOf()}`;if(t.hasClassOrSuperclass(o.BytesValue.ClassName))return`hex:${t.valueOf().toString("hex")}`;if(t.hasClassOrSuperclass(o.CodeMetadataValue.ClassName))return`codemeta:${t.valueOf().toBuffer().toString("hex")}`;if(t.getType().getName()==="EsdtTokenPayment"){let e=t.getFieldValue("token_identifier").valueOf(),r=t.getFieldValue("token_nonce").valueOf(),n=t.getFieldValue("amount").valueOf();return`esdt:${e}|${r}|${n}`}throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${t.getClassName()}`)}typedToNative(t){let e=this.typedToString(t);return this.stringToNative(e)}nativeToTyped(t,e){let r=this.nativeToString(t,e);return this.stringToTyped(r)}nativeToType(t){if(t.startsWith("composite")){let e=t.match(/\(([^)]+)\)/)?.[1];return new o.CompositeType(...e.split(f.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(t==="string")return new o.StringType;if(t==="uint8")return new o.U8Type;if(t==="uint16")return new o.U16Type;if(t==="uint32")return new o.U32Type;if(t==="uint64")return new o.U64Type;if(t==="biguint")return new o.BigUIntType;if(t==="bool")return new o.BooleanType;if(t==="address")return new o.AddressType;if(t==="token")return new o.TokenIdentifierType;if(t==="hex")return new o.BytesType;if(t==="codemeta")return new o.CodeMetadataType;if(t==="esdt"||t==="nft")return new o.StructType("EsdtTokenPayment",[new o.FieldDefinition("token_identifier","",new o.TokenIdentifierType),new o.FieldDefinition("token_nonce","",new o.U64Type),new o.FieldDefinition("amount","",new o.BigUIntType)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${t}`)}stringToNative(t){let e=t.split(f.ArgParamsSeparator),r=e[0],n=e.slice(1).join(f.ArgParamsSeparator);if(r==="null")return[r,null];if(r==="option"){let[i,s]=n.split(f.ArgParamsSeparator);return[`option:${i}`,s||null]}else if(r==="optional"){let[i,s]=n.split(f.ArgParamsSeparator);return[`optional:${i}`,s||null]}else if(r==="list"){let i=n.split(f.ArgParamsSeparator),s=i.slice(0,-1).join(f.ArgParamsSeparator),c=i[i.length-1],p=(c?c.split(","):[]).map(d=>this.stringToNative(`${s}:${d}`)[1]);return[`list:${s}`,p]}else if(r==="variadic"){let i=n.split(f.ArgParamsSeparator),s=i.slice(0,-1).join(f.ArgParamsSeparator),c=i[i.length-1],p=(c?c.split(","):[]).map(d=>this.stringToNative(`${s}:${d}`)[1]);return[`variadic:${s}`,p]}else if(r.startsWith("composite")){let i=r.match(/\(([^)]+)\)/)?.[1]?.split(f.ArgCompositeSeparator),c=n.split(f.ArgCompositeSeparator).map((u,p)=>this.stringToNative(`${i[p]}:${u}`)[1]);return[r,c]}else{if(r==="string")return[r,n];if(r==="uint8"||r==="uint16"||r==="uint32")return[r,Number(n)];if(r==="uint64"||r==="biguint")return[r,BigInt(n||0)];if(r==="bool")return[r,n==="true"];if(r==="address")return[r,n];if(r==="token")return[r,n];if(r==="hex")return[r,n];if(r==="codemeta")return[r,n];if(r==="esdt"){let[i,s,c]=n.split(f.ArgCompositeSeparator);return[r,new o.TokenTransfer({token:new o.Token({identifier:i,nonce:BigInt(s)}),amount:BigInt(c)})]}}throw new Error(`WarpArgSerializer (stringToNative): Unsupported input type: ${r}`)}stringToTyped(t){let[e,r]=t.split(/:(.*)/,2);if(e==="null"||e===null)return new o.NothingValue;if(e==="option"){let n=this.stringToTyped(r);return n instanceof o.NothingValue?o.OptionValue.newMissingTyped(n.getType()):o.OptionValue.newProvided(n)}if(e==="optional"){let n=this.stringToTyped(r);return n instanceof o.NothingValue?o.OptionalValue.newMissing():new o.OptionalValue(n.getType(),n)}if(e==="list"){let[n,i]=r.split(Ct,2),c=i.split(",").map(u=>this.stringToTyped(`${n}:${u}`));return new o.List(this.nativeToType(n),c)}if(e==="variadic"){let[n,i]=r.split(Ct,2),c=i.split(",").map(u=>this.stringToTyped(`${n}:${u}`));return new o.VariadicValue(new o.VariadicType(this.nativeToType(n)),c)}if(e.startsWith("composite")){let n=e.match(/\(([^)]+)\)/)?.[1],i=r.split(f.ArgCompositeSeparator),s=n.split(f.ArgCompositeSeparator),c=i.map((p,d)=>this.stringToTyped(`${s[d]}:${p}`)),u=c.map(p=>p.getType());return new o.CompositeValue(new o.CompositeType(...u),c)}if(e==="string")return r?o.StringValue.fromUTF8(r):new o.NothingValue;if(e==="uint8")return r?new o.U8Value(Number(r)):new o.NothingValue;if(e==="uint16")return r?new o.U16Value(Number(r)):new o.NothingValue;if(e==="uint32")return r?new o.U32Value(Number(r)):new o.NothingValue;if(e==="uint64")return r?new o.U64Value(BigInt(r)):new o.NothingValue;if(e==="biguint")return r?new o.BigUIntValue(BigInt(r)):new o.NothingValue;if(e==="bool")return r?new o.BooleanValue(typeof r=="boolean"?r:r==="true"):new o.NothingValue;if(e==="address")return r?new o.AddressValue(o.Address.newFromBech32(r)):new o.NothingValue;if(e==="token")return r?new o.TokenIdentifierValue(r):new o.NothingValue;if(e==="hex")return r?o.BytesValue.fromHex(r):new o.NothingValue;if(e==="codemeta")return new o.CodeMetadataValue(o.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(e==="esdt"){let n=r.split(f.ArgCompositeSeparator);return new o.Struct(this.nativeToType("esdt"),[new o.Field(new o.TokenIdentifierValue(n[0]),"token_identifier"),new o.Field(new o.U64Value(BigInt(n[1])),"token_nonce"),new o.Field(new o.BigUIntValue(BigInt(n[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${e}`)}typeToString(t){if(t instanceof o.OptionType)return"option:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof o.OptionalType)return"optional:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof o.ListType)return"list:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof o.VariadicType)return"variadic:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof o.StringType)return"string";if(t instanceof o.U8Type)return"uint8";if(t instanceof o.U16Type)return"uint16";if(t instanceof o.U32Type)return"uint32";if(t instanceof o.U64Type)return"uint64";if(t instanceof o.BigUIntType)return"biguint";if(t instanceof o.BooleanType)return"bool";if(t instanceof o.AddressType)return"address";if(t instanceof o.TokenIdentifierType)return"token";if(t instanceof o.BytesType)return"hex";if(t instanceof o.CodeMetadataType)return"codemeta";if(t instanceof o.StructType&&t.getClassName()==="EsdtTokenPayment")return"esdt";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${t.getClassName()}`)}};var Zt=async(a,t)=>{if(typeof window>"u"){let{VM:e}=require("vm2"),r=new e({timeout:1e3,sandbox:{input:t},eval:!1,wasm:!1});return a.trim().startsWith("(")&&a.includes("=>")?r.run(`(${a})(input)`):null}return new Promise((e,r)=>{try{let n=new Blob([`
|
|
1
|
+
"use strict";var ds=Object.create;var zt=Object.defineProperty;var ms=Object.getOwnPropertyDescriptor;var gs=Object.getOwnPropertyNames;var ys=Object.getPrototypeOf,xs=Object.prototype.hasOwnProperty;var de=(c,t)=>()=>(t||c((t={exports:{}}).exports,t),t.exports),vs=(c,t)=>{for(var i in t)zt(c,i,{get:t[i],enumerable:!0})},$i=(c,t,i,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of gs(t))!xs.call(c,u)&&u!==i&&zt(c,u,{get:()=>t[u],enumerable:!(s=ms(t,u))||s.enumerable});return c};var br=(c,t,i)=>(i=c!=null?ds(ys(c)):{},$i(t||!c||!c.__esModule?zt(i,"default",{value:c,enumerable:!0}):i,c)),bs=c=>$i(zt({},"__esModule",{value:!0}),c);var Ye=de(ir=>{"use strict";var Yt=["Number","String","Boolean","Date","RegExp","Map","WeakMap","Set","WeakSet","Promise","Function"],Zt=["RangeError","ReferenceError","SyntaxError","TypeError","EvalError","URIError","Error"],js="Operation not allowed on contextified object.",Fe={__proto__:null,Object:Object.prototype,Array:Array.prototype};for(let c=0;c<Yt.length;c++){let t=Yt[c],i=global[t];i&&(Fe[t]=i.prototype)}for(let c=0;c<Zt.length;c++){let t=Zt[c],i=global[t];i&&(Fe[t]=i.prototype)}var{getPrototypeOf:Xe,setPrototypeOf:rr,defineProperty:Ue,deleteProperty:qs,getOwnPropertyDescriptor:$s,isExtensible:Er,preventExtensions:Ji,apply:oe,construct:Gs,set:Hs,get:zs,has:Ks,ownKeys:Qs,enumerate:Js}=Reflect,Xs=Object,{freeze:Rr,prototype:Pr}=Xs,Ar=Pr.hasOwnProperty,er=Proxy,Yi=WeakMap,{get:Ir,set:Jt}=Yi.prototype,tr=Map,Xt=tr.prototype.get,pt=tr.prototype.set,Ys=Function,Zs=Ys.prototype.bind,ea=Array.isArray,ta=Error.captureStackTrace,ra=Symbol.prototype.toString,Tr=Symbol.toStringTag,ia=Symbol.iterator,na=Symbol.for("nodejs.util.inspect.custom"),he=class extends Error{constructor(t,i){super(t),this.name="VMError",this.code=i,ta(this,this.constructor)}};Fe.VMError=he.prototype;function ke(){return new he("Unexpected")}if(!rr(ir,null))throw ke();function kr(c,t){let i=$s(c,t);if(!i)return i;if(!rr(i,null))throw ke();return i}function Zi(c){"use strict";return Zi[c],ke()}function Xi(c,t){return t}var sa=Rr({__proto__:null,get(c,t,i){throw typeof t=="symbol"&&(t=oe(ra,t,[])),new he(`Unexpected access to key '${t}'`)}}),en=Rr({__proto__:null}),tn=new er(en,sa);function rn(){}if(!Ue(rn,"prototype",{__proto__:null,value:tn}))throw ke();function aa(){}var oa=Rr({__proto__:tn,construct(){return this}});function ua(c){let t=new er(c,oa);try{return new t,!0}catch{return!1}}function ca(c,t){let i;if(typeof c=="function")ua(c)?i=oe(Zs,aa,[null]):i=()=>{};else if(ea(c))i=[];else return{__proto__:t};if(!rr(i,t))throw ke();return i}function la(c,t){let i=new Yi,s=new tr,u=new tr;function l(M,k,E){oe(pt,s,[M,Xi]),oe(pt,s,[k,(P,B)=>ve(P,B,M)]),E&&oe(pt,u,[M,E])}function p(M,k,E){let P;oe(pt,s,[k,(B,L)=>(P||(P=M(),oe(pt,s,[P,Xi]),E&&oe(pt,u,[P,E])),ve(B,L,P))])}let f={__proto__:null,globalPrototypes:Fe,safeGetOwnPropertyDescriptor:kr,fromArguments:$e,from:Re,fromWithFactory:rt,ensureThis:Lt,mapping:i,connect:Le,reflectSet:Hs,reflectGet:zs,reflectDefineProperty:Ue,reflectDeleteProperty:qs,reflectApply:oe,reflectConstruct:Gs,reflectHas:Ks,reflectOwnKeys:Qs,reflectEnumerate:Js,reflectGetPrototypeOf:Xe,reflectIsExtensible:Er,reflectPreventExtensions:Ji,objectHasOwnProperty:Ar,weakMapSet:Jt,addProtoMapping:l,addProtoMappingFactory:p,defaultFactory:Ae,protectedFactory:xe,readonlyFactory:Pe,VMError:he},b=typeof c!="object";b&&(c=c(f,t)),f.other=c;let{globalPrototypes:x,safeGetOwnPropertyDescriptor:S,fromArguments:T,from:N,mapping:O,reflectSet:W,reflectGet:y,reflectDefineProperty:m,reflectDeleteProperty:d,reflectApply:g,reflectConstruct:_,reflectHas:a,reflectOwnKeys:A,reflectEnumerate:V,reflectGetPrototypeOf:I,reflectIsExtensible:J,reflectPreventExtensions:K,objectHasOwnProperty:X,weakMapSet:fe}=c;function tt(M,k){try{return g(X,M,[k])===!0}catch(E){throw ae(E)}}function Ft(M,k,E,P){let B;if(P.get||P.set){let L=P.get;if(!L)return;try{B=g(L,k,[E])}catch($){throw ae($)}}else B=P.value;return M.fromOtherWithContext(B)}function ge(M,k,E){if(!oe(Ar,k,[E]))return!1;try{M[E]=N(k[E])}catch(P){throw ae(P)}return!0}class Ee extends rn{constructor(k){super(),this.objectWrapper=()=>k}getObject(){return this.objectWrapper()}getFactory(){return Ae}fromOtherWithContext(k){return rt(this.getFactory(),k)}doPreventExtensions(k,E,P){let B;try{B=A(E)}catch(L){throw ae(L)}for(let L=0;L<B.length;L++){let $=B[L],Y;try{Y=S(E,$)}catch(ye){throw ae(ye)}if(Y){if(Y.configurable)Y.get||Y.set?Y={__proto__:null,configurable:!0,enumerable:Y.enumerable,writable:!0,value:null}:Y.value=null;else{let ye=kr(k,$);if(ye&&!ye.configurable)continue;Y.get||Y.set?(Y.get=this.fromOtherWithContext(Y.get),Y.set=this.fromOtherWithContext(Y.set)):typeof E=="function"&&($==="caller"||$==="callee"||$==="arguments")?Y.value=null:Y.value=this.fromOtherWithContext(Y.value)}if(!Ue(k,$,Y))throw ke()}}if(!Ji(k))throw ke()}get(k,E,P){let B=this.getObject();switch(E){case"constructor":{let $=S(B,E);if($)return Ft(this,B,E,$);let Y=Xe(k);return Y===null?void 0:Y.constructor}case"__proto__":{let $=S(B,E);return $?Ft(this,B,E,$):Xe(k)}case Tr:if(!tt(B,Tr)){let $=Xe(k),Y=oe(Xt,u,[$]);if(Y)return Y}break;case"arguments":case"caller":case"callee":if(typeof B=="function"&&tt(B,E))throw Zi(E);break}let L;try{L=y(B,E)}catch($){throw ae($)}return this.fromOtherWithContext(L)}set(k,E,P,B){let L=this.getObject();if(E==="__proto__"&&!tt(L,E))return this.setPrototypeOf(k,P);try{return P=N(P),W(L,E,P)===!0}catch($){throw ae($)}}getPrototypeOf(k){return Xe(k)}setPrototypeOf(k,E){throw new he(js)}apply(k,E,P){let B=this.getObject(),L;try{E=N(E),P=T(P),L=g(B,E,P)}catch($){throw ae($)}return Re(L)}construct(k,E,P){let B=this.getObject(),L;try{E=T(E),L=_(B,E)}catch($){throw ae($)}return rt(this.getFactory(),L,Re(B))}getOwnPropertyDescriptorDesc(k,E,P){let B=this.getObject();return P&&typeof B=="function"&&(E==="arguments"||E==="caller"||E==="callee")&&(P.value=null),P}getOwnPropertyDescriptor(k,E){let P=this.getObject(),B;try{B=S(P,E)}catch($){throw ae($)}if(B=this.getOwnPropertyDescriptorDesc(k,E,B),!B)return;let L;if(B.get||B.set?L={__proto__:null,get:this.fromOtherWithContext(B.get),set:this.fromOtherWithContext(B.set),enumerable:B.enumerable===!0,configurable:B.configurable===!0}:L={__proto__:null,value:this.fromOtherWithContext(B.value),writable:B.writable===!0,enumerable:B.enumerable===!0,configurable:B.configurable===!0},!L.configurable){let $=kr(k,E);if((!$||$.configurable||$.writable!==L.writable)&&!Ue(k,E,L))throw ke()}return L}definePropertyDesc(k,E,P){return P}defineProperty(k,E,P){let B=this.getObject();if(!rr(P,null))throw ke();if(P=this.definePropertyDesc(k,E,P),!P)return!1;let L={__proto__:null},$=!0,Y=!0,ye=!0;$&=ge(L,P,"get"),$&=ge(L,P,"set"),Y&=ge(L,P,"value"),Y&=ge(L,P,"writable"),ye&=ge(L,P,"enumerable"),ye&=ge(L,P,"configurable");try{if(!m(B,E,L))return!1;L.configurable!==!0&&(!ye||!($||Y))&&(L=S(B,E))}catch(Ne){throw ae(Ne)}if(!L.configurable){let Ne;if(L.get||L.set?Ne={__proto__:null,get:this.fromOtherWithContext(L.get),set:this.fromOtherWithContext(L.set),enumerable:L.enumerable,configurable:L.configurable}:Ne={__proto__:null,value:this.fromOtherWithContext(L.value),writable:L.writable,enumerable:L.enumerable,configurable:L.configurable},!Ue(k,E,Ne))throw ke()}return!0}deleteProperty(k,E){let P=this.getObject();try{return d(P,E)===!0}catch(B){throw ae(B)}}has(k,E){let P=this.getObject();try{return a(P,E)===!0}catch(B){throw ae(B)}}isExtensible(k){let E=this.getObject();try{if(J(E))return!0}catch(P){throw ae(P)}return Er(k)&&this.doPreventExtensions(k,E,this),!1}ownKeys(k){let E=this.getObject(),P;try{P=A(E)}catch(B){throw ae(B)}return Re(P)}preventExtensions(k){let E=this.getObject();try{if(!K(E))return!1}catch(P){throw ae(P)}return Er(k)&&this.doPreventExtensions(k,E,this),!0}enumerate(k){let E=this.getObject(),P;try{P=V(E)}catch(B){throw ae(B)}return this.fromOtherWithContext(P)}}Ee.prototype[na]=void 0,Ee.prototype[Tr]="VM2 Wrapper",Ee.prototype[ia]=void 0;function Ae(M){return new Ee(M)}class Se extends Ee{getFactory(){return xe}set(k,E,P,B){return typeof P=="function"?Ue(B,E,{__proto__:null,value:P,writable:!0,enumerable:!0,configurable:!0})===!0:super.set(k,E,P,B)}definePropertyDesc(k,E,P){if(!(P&&(P.set||P.get||typeof P.value=="function")))return P}}function xe(M){return new Se(M)}class vt extends Ee{getFactory(){return Pe}set(k,E,P,B){return Ue(B,E,{__proto__:null,value:P,writable:!0,enumerable:!0,configurable:!0})}setPrototypeOf(k,E){return!1}defineProperty(k,E,P){return!1}deleteProperty(k,E){return!1}isExtensible(k){return!1}preventExtensions(k){return!1}}function Pe(M){return new vt(M)}class qe extends vt{constructor(k,E){super(k),this.mock=E}get(k,E,P){let B=this.getObject(),L=this.mock;return oe(Ar,L,E)&&!tt(B,E)?L[E]:super.get(k,E,P)}}function Re(M){return rt(Ae,M)}function ve(M,k,E){let P=ca(k,E),B=M(k),L=new er(P,B);try{g(fe,O,[L,k]),t(L,B)}catch{throw new he("Unexpected error")}if(!b)return oe(Jt,i,[k,L]),L;let $=new er(L,en);try{g(fe,O,[$,k]),t($,B)}catch{throw new he("Unexpected error")}return oe(Jt,i,[k,$]),$}function Lt(M){let k=typeof M;switch(k){case"object":if(M===null)return null;case"function":let E=Xe(M);if(!E)return M;for(;E;){let P=oe(Xt,s,[E]);if(P){let B=oe(Ir,i,[M]);return B||P(Ae,M)}E=Xe(E)}return M;case"undefined":case"string":case"number":case"boolean":case"symbol":case"bigint":return M;default:throw new he(`Unknown type '${k}'`)}}function ae(M){for(let k=0;k<10;k++){let E=typeof M;switch(E){case"object":if(M===null)return null;case"function":let P=oe(Ir,i,[M]);if(P)return P;let B;try{B=I(M)}catch(L){M=L;break}if(!B)return ve(Ae,M,null);for(;;){let L=oe(Xt,s,[B]);if(L)return L(Ae,M);try{B=I(B)}catch($){M=$;break}if(!B)return ve(Ae,M,Pr)}break;case"undefined":case"string":case"number":case"boolean":case"symbol":case"bigint":return M;default:throw new he(`Unknown type '${E}'`)}}throw new he("Exception recursion depth")}function rt(M,k,E){let P=typeof k;switch(P){case"object":if(k===null)return null;case"function":let B=oe(Ir,i,[k]);if(B)return B;if(E)return ve(M,k,E);try{E=I(k)}catch(L){throw ae(L)}if(!E)return ve(M,k,null);do{let L=oe(Xt,s,[E]);if(L)return L(M,k);try{E=I(E)}catch($){throw ae($)}}while(E);return ve(M,k,Pr);case"undefined":case"string":case"number":case"boolean":case"symbol":case"bigint":return k;default:throw new he(`Unknown type '${P}'`)}}function $e(M){let k=[];for(let E=0;E<M.length;E++){let P=Re(M[E]);Ue(k,E,{__proto__:null,value:P,writable:!0,enumerable:!0,configurable:!0})}return k}function Le(M,k){try{g(fe,O,[M,k])}catch{throw new he("Unexpected error")}oe(Jt,i,[k,M])}l(Fe.Object,x.Object),l(Fe.Array,x.Array);for(let M=0;M<Yt.length;M++){let k=Yt[M],E=Fe[k],P=x[k];E&&P&&l(E,P,k)}for(let M=0;M<Zt.length;M++){let k=Zt[M],E=Fe[k],P=x[k];E&&P&&l(E,P,"Error")}return l(Fe.VMError,x.VMError,"Error"),f.BaseHandler=Ee,f.ProtectedHandler=Se,f.ReadOnlyHandler=vt,f.ReadOnlyMockHandler=qe,f}ir.createBridge=la;ir.VMError=he});var Nt=de(Vr=>{"use strict";var{VMError:nn}=Ye(),Nr;function pa(){if(!Nr)try{let c=require("coffee-script");Nr=(t,i)=>c.compile(t,{header:!1,bare:!0})}catch{throw new nn("Coffee-Script compiler is not installed.")}return Nr}function sn(c){return c.startsWith("#!")?"//"+c.substring(2):c}function ha(c,t){return sn(c)}function fa(c){if(typeof c=="function")return c;switch(c){case"coffeescript":case"coffee-script":case"cs":case"text/coffeescript":return pa();case"javascript":case"java-script":case"js":case"text/javascript":return ha;default:throw new nn(`Unsupported compiler '${c}'.`)}}Vr.removeShebang=sn;Vr.lookupCompiler=fa});var on=de((nr,an)=>{"use strict";(function(c,t){typeof nr=="object"&&typeof an<"u"?t(nr):typeof define=="function"&&define.amd?define(["exports"],t):(c=typeof globalThis<"u"?globalThis:c||self,t(c.acorn={}))})(nr,function(c){"use strict";var t=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],i=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],s="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",u="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",l={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},p="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",f={5:p,"5module":p+" export import",6:p+" const class extends export import super"},b=/^in(stanceof)?$/,x=new RegExp("["+u+"]"),S=new RegExp("["+u+s+"]");function T(e,r){for(var n=65536,o=0;o<r.length;o+=2){if(n+=r[o],n>e)return!1;if(n+=r[o+1],n>=e)return!0}return!1}function N(e,r){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&x.test(String.fromCharCode(e)):r===!1?!1:T(e,i)}function O(e,r){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&S.test(String.fromCharCode(e)):r===!1?!1:T(e,i)||T(e,t)}var W=function(r,n){n===void 0&&(n={}),this.label=r,this.keyword=n.keyword,this.beforeExpr=!!n.beforeExpr,this.startsExpr=!!n.startsExpr,this.isLoop=!!n.isLoop,this.isAssign=!!n.isAssign,this.prefix=!!n.prefix,this.postfix=!!n.postfix,this.binop=n.binop||null,this.updateContext=null};function y(e,r){return new W(e,{beforeExpr:!0,binop:r})}var m={beforeExpr:!0},d={startsExpr:!0},g={};function _(e,r){return r===void 0&&(r={}),r.keyword=e,g[e]=new W(e,r)}var a={num:new W("num",d),regexp:new W("regexp",d),string:new W("string",d),name:new W("name",d),privateId:new W("privateId",d),eof:new W("eof"),bracketL:new W("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new W("]"),braceL:new W("{",{beforeExpr:!0,startsExpr:!0}),braceR:new W("}"),parenL:new W("(",{beforeExpr:!0,startsExpr:!0}),parenR:new W(")"),comma:new W(",",m),semi:new W(";",m),colon:new W(":",m),dot:new W("."),question:new W("?",m),questionDot:new W("?."),arrow:new W("=>",m),template:new W("template"),invalidTemplate:new W("invalidTemplate"),ellipsis:new W("...",m),backQuote:new W("`",d),dollarBraceL:new W("${",{beforeExpr:!0,startsExpr:!0}),eq:new W("=",{beforeExpr:!0,isAssign:!0}),assign:new W("_=",{beforeExpr:!0,isAssign:!0}),incDec:new W("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new W("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:y("||",1),logicalAND:y("&&",2),bitwiseOR:y("|",3),bitwiseXOR:y("^",4),bitwiseAND:y("&",5),equality:y("==/!=/===/!==",6),relational:y("</>/<=/>=",7),bitShift:y("<</>>/>>>",8),plusMin:new W("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:y("%",10),star:y("*",10),slash:y("/",10),starstar:new W("**",{beforeExpr:!0}),coalesce:y("??",1),_break:_("break"),_case:_("case",m),_catch:_("catch"),_continue:_("continue"),_debugger:_("debugger"),_default:_("default",m),_do:_("do",{isLoop:!0,beforeExpr:!0}),_else:_("else",m),_finally:_("finally"),_for:_("for",{isLoop:!0}),_function:_("function",d),_if:_("if"),_return:_("return",m),_switch:_("switch"),_throw:_("throw",m),_try:_("try"),_var:_("var"),_const:_("const"),_while:_("while",{isLoop:!0}),_with:_("with"),_new:_("new",{beforeExpr:!0,startsExpr:!0}),_this:_("this",d),_super:_("super",d),_class:_("class",d),_extends:_("extends",m),_export:_("export"),_import:_("import",d),_null:_("null",d),_true:_("true",d),_false:_("false",d),_in:_("in",{beforeExpr:!0,binop:7}),_instanceof:_("instanceof",{beforeExpr:!0,binop:7}),_typeof:_("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:_("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:_("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},A=/\r\n?|\n|\u2028|\u2029/,V=new RegExp(A.source,"g");function I(e){return e===10||e===13||e===8232||e===8233}function J(e,r,n){n===void 0&&(n=e.length);for(var o=r;o<n;o++){var h=e.charCodeAt(o);if(I(h))return o<n-1&&h===13&&e.charCodeAt(o+1)===10?o+2:o+1}return-1}var K=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,X=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,fe=Object.prototype,tt=fe.hasOwnProperty,Ft=fe.toString,ge=Object.hasOwn||function(e,r){return tt.call(e,r)},Ee=Array.isArray||function(e){return Ft.call(e)==="[object Array]"},Ae=Object.create(null);function Se(e){return Ae[e]||(Ae[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function xe(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var vt=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Pe=function(r,n){this.line=r,this.column=n};Pe.prototype.offset=function(r){return new Pe(this.line,this.column+r)};var qe=function(r,n,o){this.start=n,this.end=o,r.sourceFile!==null&&(this.source=r.sourceFile)};function Re(e,r){for(var n=1,o=0;;){var h=J(e,o,r);if(h<0)return new Pe(n,r-o);++n,o=h}}var ve={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},Lt=!1;function ae(e){var r={};for(var n in ve)r[n]=e&&ge(e,n)?e[n]:ve[n];if(r.ecmaVersion==="latest"?r.ecmaVersion=1e8:r.ecmaVersion==null?(!Lt&&typeof console=="object"&&console.warn&&(Lt=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
2
|
+
Defaulting to 2020, but this will stop working in the future.`)),r.ecmaVersion=11):r.ecmaVersion>=2015&&(r.ecmaVersion-=2009),r.allowReserved==null&&(r.allowReserved=r.ecmaVersion<5),(!e||e.allowHashBang==null)&&(r.allowHashBang=r.ecmaVersion>=14),Ee(r.onToken)){var o=r.onToken;r.onToken=function(h){return o.push(h)}}return Ee(r.onComment)&&(r.onComment=rt(r,r.onComment)),r}function rt(e,r){return function(n,o,h,v,w,R){var F={type:n?"Block":"Line",value:o,start:h,end:v};e.locations&&(F.loc=new qe(this,w,R)),e.ranges&&(F.range=[h,v]),r.push(F)}}var $e=1,Le=2,M=4,k=8,E=16,P=32,B=64,L=128,$=256,Y=512,ye=$e|Le|$;function Ne(e,r){return Le|(e?M:0)|(r?k:0)}var Mt=0,mr=1,Ve=2,mi=3,gi=4,yi=5,se=function(r,n,o){this.options=r=ae(r),this.sourceFile=r.sourceFile,this.keywords=Se(f[r.ecmaVersion>=6?6:r.sourceType==="module"?"5module":5]);var h="";r.allowReserved!==!0&&(h=l[r.ecmaVersion>=6?6:r.ecmaVersion===5?5:3],r.sourceType==="module"&&(h+=" await")),this.reservedWords=Se(h);var v=(h?h+" ":"")+l.strict;this.reservedWordsStrict=Se(v),this.reservedWordsStrictBind=Se(v+" "+l.strictBind),this.input=String(n),this.containsEsc=!1,o?(this.pos=o,this.lineStart=this.input.lastIndexOf(`
|
|
3
|
+
`,o-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(A).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=a.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=r.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&r.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope($e),this.regexpState=null,this.privateNameStack=[]},Ie={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};se.prototype.parse=function(){var r=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(r)},Ie.inFunction.get=function(){return(this.currentVarScope().flags&Le)>0},Ie.inGenerator.get=function(){return(this.currentVarScope().flags&k)>0},Ie.inAsync.get=function(){return(this.currentVarScope().flags&M)>0},Ie.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var r=this.scopeStack[e],n=r.flags;if(n&($|Y))return!1;if(n&Le)return(n&M)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},Ie.allowSuper.get=function(){var e=this.currentThisScope(),r=e.flags;return(r&B)>0||this.options.allowSuperOutsideMethod},Ie.allowDirectSuper.get=function(){return(this.currentThisScope().flags&L)>0},Ie.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},Ie.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var r=this.scopeStack[e],n=r.flags;if(n&($|Y)||n&Le&&!(n&E))return!0}return!1},Ie.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&$)>0},se.extend=function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];for(var o=this,h=0;h<r.length;h++)o=r[h](o);return o},se.parse=function(r,n){return new this(n,r).parse()},se.parseExpressionAt=function(r,n,o){var h=new this(o,r,n);return h.nextToken(),h.parseExpression()},se.tokenizer=function(r,n){return new this(n,r)},Object.defineProperties(se.prototype,Ie);var pe=se.prototype,Mn=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;pe.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){X.lastIndex=e,e+=X.exec(this.input)[0].length;var r=Mn.exec(this.input.slice(e));if(!r)return!1;if((r[1]||r[2])==="use strict"){X.lastIndex=e+r[0].length;var n=X.exec(this.input),o=n.index+n[0].length,h=this.input.charAt(o);return h===";"||h==="}"||A.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(h)||h==="!"&&this.input.charAt(o+1)==="=")}e+=r[0].length,X.lastIndex=e,e+=X.exec(this.input)[0].length,this.input[e]===";"&&e++}},pe.eat=function(e){return this.type===e?(this.next(),!0):!1},pe.isContextual=function(e){return this.type===a.name&&this.value===e&&!this.containsEsc},pe.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1},pe.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},pe.canInsertSemicolon=function(){return this.type===a.eof||this.type===a.braceR||A.test(this.input.slice(this.lastTokEnd,this.start))},pe.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},pe.semicolon=function(){!this.eat(a.semi)&&!this.insertSemicolon()&&this.unexpected()},pe.afterTrailingComma=function(e,r){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),r||this.next(),!0},pe.expect=function(e){this.eat(e)||this.unexpected()},pe.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var Dt=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};pe.checkPatternErrors=function(e,r){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var n=r?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,r?"Assigning to rvalue":"Parenthesized pattern")}},pe.checkExpressionErrors=function(e,r){if(!e)return!1;var n=e.shorthandAssign,o=e.doubleProto;if(!r)return n>=0||o>=0;n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),o>=0&&this.raiseRecoverable(o,"Redefinition of __proto__ property")},pe.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")},pe.isSimpleAssignTarget=function(e){return e.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(e.expression):e.type==="Identifier"||e.type==="MemberExpression"};var j=se.prototype;j.parseTopLevel=function(e){var r=Object.create(null);for(e.body||(e.body=[]);this.type!==a.eof;){var n=this.parseStatement(null,!0,r);e.body.push(n)}if(this.inModule)for(var o=0,h=Object.keys(this.undefinedExports);o<h.length;o+=1){var v=h[o];this.raiseRecoverable(this.undefinedExports[v].start,"Export '"+v+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,"Program")};var gr={kind:"loop"},Dn={kind:"switch"};j.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;X.lastIndex=this.pos;var r=X.exec(this.input),n=this.pos+r[0].length,o=this.input.charCodeAt(n);if(o===91||o===92)return!0;if(e)return!1;if(o===123||o>55295&&o<56320)return!0;if(N(o,!0)){for(var h=n+1;O(o=this.input.charCodeAt(h),!0);)++h;if(o===92||o>55295&&o<56320)return!0;var v=this.input.slice(n,h);if(!b.test(v))return!0}return!1},j.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;X.lastIndex=this.pos;var e=X.exec(this.input),r=this.pos+e[0].length,n;return!A.test(this.input.slice(this.pos,r))&&this.input.slice(r,r+8)==="function"&&(r+8===this.input.length||!(O(n=this.input.charCodeAt(r+8))||n>55295&&n<56320))},j.isUsingKeyword=function(e,r){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;X.lastIndex=this.pos;var n=X.exec(this.input),o=this.pos+n[0].length;if(A.test(this.input.slice(this.pos,o)))return!1;if(e){var h=o+5,v;if(this.input.slice(o,h)!=="using"||h===this.input.length||O(v=this.input.charCodeAt(h))||v>55295&&v<56320)return!1;X.lastIndex=h;var w=X.exec(this.input);if(w&&A.test(this.input.slice(h,h+w[0].length)))return!1}if(r){var R=o+2,F;if(this.input.slice(o,R)==="of"&&(R===this.input.length||!O(F=this.input.charCodeAt(R))&&!(F>55295&&F<56320)))return!1}var G=this.input.charCodeAt(o);return N(G,!0)||G===92},j.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},j.isUsing=function(e){return this.isUsingKeyword(!1,e)},j.parseStatement=function(e,r,n){var o=this.type,h=this.startNode(),v;switch(this.isLet(e)&&(o=a._var,v="let"),o){case a._break:case a._continue:return this.parseBreakContinueStatement(h,o.keyword);case a._debugger:return this.parseDebuggerStatement(h);case a._do:return this.parseDoStatement(h);case a._for:return this.parseForStatement(h);case a._function:return e&&(this.strict||e!=="if"&&e!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(h,!1,!e);case a._class:return e&&this.unexpected(),this.parseClass(h,!0);case a._if:return this.parseIfStatement(h);case a._return:return this.parseReturnStatement(h);case a._switch:return this.parseSwitchStatement(h);case a._throw:return this.parseThrowStatement(h);case a._try:return this.parseTryStatement(h);case a._const:case a._var:return v=v||this.value,e&&v!=="var"&&this.unexpected(),this.parseVarStatement(h,v);case a._while:return this.parseWhileStatement(h);case a._with:return this.parseWithStatement(h);case a.braceL:return this.parseBlock(!0,h);case a.semi:return this.parseEmptyStatement(h);case a._export:case a._import:if(this.options.ecmaVersion>10&&o===a._import){X.lastIndex=this.pos;var w=X.exec(this.input),R=this.pos+w[0].length,F=this.input.charCodeAt(R);if(F===40||F===46)return this.parseExpressionStatement(h,this.parseExpression())}return this.options.allowImportExportEverywhere||(r||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),o===a._import?this.parseImport(h):this.parseExport(h,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(h,!0,!e);var G=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(G)return r&&this.options.sourceType==="script"&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),G==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(h,!1,G),this.semicolon(),this.finishNode(h,"VariableDeclaration");var Q=this.value,ie=this.parseExpression();return o===a.name&&ie.type==="Identifier"&&this.eat(a.colon)?this.parseLabeledStatement(h,Q,ie,e):this.parseExpressionStatement(h,ie)}},j.parseBreakContinueStatement=function(e,r){var n=r==="break";this.next(),this.eat(a.semi)||this.insertSemicolon()?e.label=null:this.type!==a.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var o=0;o<this.labels.length;++o){var h=this.labels[o];if((e.label==null||h.name===e.label.name)&&(h.kind!=null&&(n||h.kind==="loop")||e.label&&n))break}return o===this.labels.length&&this.raise(e.start,"Unsyntactic "+r),this.finishNode(e,n?"BreakStatement":"ContinueStatement")},j.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")},j.parseDoStatement=function(e){return this.next(),this.labels.push(gr),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(a._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(a.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")},j.parseForStatement=function(e){this.next();var r=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(gr),this.enterScope(0),this.expect(a.parenL),this.type===a.semi)return r>-1&&this.unexpected(r),this.parseFor(e,null);var n=this.isLet();if(this.type===a._var||this.type===a._const||n){var o=this.startNode(),h=n?"let":this.value;return this.next(),this.parseVar(o,!0,h),this.finishNode(o,"VariableDeclaration"),this.parseForAfterInit(e,o,r)}var v=this.isContextual("let"),w=!1,R=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(R){var F=this.startNode();return this.next(),R==="await using"&&this.next(),this.parseVar(F,!0,R),this.finishNode(F,"VariableDeclaration"),this.parseForAfterInit(e,F,r)}var G=this.containsEsc,Q=new Dt,ie=this.start,le=r>-1?this.parseExprSubscripts(Q,"await"):this.parseExpression(!0,Q);return this.type===a._in||(w=this.options.ecmaVersion>=6&&this.isContextual("of"))?(r>-1?(this.type===a._in&&this.unexpected(r),e.await=!0):w&&this.options.ecmaVersion>=8&&(le.start===ie&&!G&&le.type==="Identifier"&&le.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),v&&w&&this.raise(le.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(le,!1,Q),this.checkLValPattern(le),this.parseForIn(e,le)):(this.checkExpressionErrors(Q,!0),r>-1&&this.unexpected(r),this.parseFor(e,le))},j.parseForAfterInit=function(e,r,n){return(this.type===a._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&r.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===a._in?n>-1&&this.unexpected(n):e.await=n>-1),this.parseForIn(e,r)):(n>-1&&this.unexpected(n),this.parseFor(e,r))},j.parseFunctionStatement=function(e,r,n){return this.next(),this.parseFunction(e,bt|(n?0:yr),!1,r)},j.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(a._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")},j.parseReturnStatement=function(e){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(a.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")},j.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(a.braceL),this.labels.push(Dn),this.enterScope(0);for(var r,n=!1;this.type!==a.braceR;)if(this.type===a._case||this.type===a._default){var o=this.type===a._case;r&&this.finishNode(r,"SwitchCase"),e.cases.push(r=this.startNode()),r.consequent=[],this.next(),o?r.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),n=!0,r.test=null),this.expect(a.colon)}else r||this.unexpected(),r.consequent.push(this.parseStatement(null));return this.exitScope(),r&&this.finishNode(r,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")},j.parseThrowStatement=function(e){return this.next(),A.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var Un=[];j.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),r=e.type==="Identifier";return this.enterScope(r?P:0),this.checkLValPattern(e,r?gi:Ve),this.expect(a.parenR),e},j.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===a._catch){var r=this.startNode();this.next(),this.eat(a.parenL)?r.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),r.param=null,this.enterScope(0)),r.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(r,"CatchClause")}return e.finalizer=this.eat(a._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")},j.parseVarStatement=function(e,r,n){return this.next(),this.parseVar(e,!1,r,n),this.semicolon(),this.finishNode(e,"VariableDeclaration")},j.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(gr),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")},j.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")},j.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")},j.parseLabeledStatement=function(e,r,n,o){for(var h=0,v=this.labels;h<v.length;h+=1){var w=v[h];w.name===r&&this.raise(n.start,"Label '"+r+"' is already declared")}for(var R=this.type.isLoop?"loop":this.type===a._switch?"switch":null,F=this.labels.length-1;F>=0;F--){var G=this.labels[F];if(G.statementStart===e.start)G.statementStart=this.start,G.kind=R;else break}return this.labels.push({name:r,kind:R,statementStart:this.start}),e.body=this.parseStatement(o?o.indexOf("label")===-1?o+"label":o:"label"),this.labels.pop(),e.label=n,this.finishNode(e,"LabeledStatement")},j.parseExpressionStatement=function(e,r){return e.expression=r,this.semicolon(),this.finishNode(e,"ExpressionStatement")},j.parseBlock=function(e,r,n){for(e===void 0&&(e=!0),r===void 0&&(r=this.startNode()),r.body=[],this.expect(a.braceL),e&&this.enterScope(0);this.type!==a.braceR;){var o=this.parseStatement(null);r.body.push(o)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(r,"BlockStatement")},j.parseFor=function(e,r){return e.init=r,this.expect(a.semi),e.test=this.type===a.semi?null:this.parseExpression(),this.expect(a.semi),e.update=this.type===a.parenR?null:this.parseExpression(),this.expect(a.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")},j.parseForIn=function(e,r){var n=this.type===a._in;return this.next(),r.type==="VariableDeclaration"&&r.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||r.kind!=="var"||r.declarations[0].id.type!=="Identifier")&&this.raise(r.start,(n?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=r,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(a.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,n?"ForInStatement":"ForOfStatement")},j.parseVar=function(e,r,n,o){for(e.declarations=[],e.kind=n;;){var h=this.startNode();if(this.parseVarId(h,n),this.eat(a.eq)?h.init=this.parseMaybeAssign(r):!o&&n==="const"&&!(this.type===a._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!o&&(n==="using"||n==="await using")&&this.options.ecmaVersion>=17&&this.type!==a._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+n+" declaration"):!o&&h.id.type!=="Identifier"&&!(r&&(this.type===a._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):h.init=null,e.declarations.push(this.finishNode(h,"VariableDeclarator")),!this.eat(a.comma))break}return e},j.parseVarId=function(e,r){e.id=r==="using"||r==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,r==="var"?mr:Ve,!1)};var bt=1,yr=2,xi=4;j.parseFunction=function(e,r,n,o,h){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!o)&&(this.type===a.star&&r&yr&&this.unexpected(),e.generator=this.eat(a.star)),this.options.ecmaVersion>=8&&(e.async=!!o),r&bt&&(e.id=r&xi&&this.type!==a.name?null:this.parseIdent(),e.id&&!(r&yr)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?mr:Ve:mi));var v=this.yieldPos,w=this.awaitPos,R=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ne(e.async,e.generator)),r&bt||(e.id=this.type===a.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,h),this.yieldPos=v,this.awaitPos=w,this.awaitIdentPos=R,this.finishNode(e,r&bt?"FunctionDeclaration":"FunctionExpression")},j.parseFunctionParams=function(e){this.expect(a.parenL),e.params=this.parseBindingList(a.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},j.parseClass=function(e,r){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,r),this.parseClassSuper(e);var o=this.enterClassBody(),h=this.startNode(),v=!1;for(h.body=[],this.expect(a.braceL);this.type!==a.braceR;){var w=this.parseClassElement(e.superClass!==null);w&&(h.body.push(w),w.type==="MethodDefinition"&&w.kind==="constructor"?(v&&this.raiseRecoverable(w.start,"Duplicate constructor in the same class"),v=!0):w.key&&w.key.type==="PrivateIdentifier"&&jn(o,w)&&this.raiseRecoverable(w.key.start,"Identifier '#"+w.key.name+"' has already been declared"))}return this.strict=n,this.next(),e.body=this.finishNode(h,"ClassBody"),this.exitClassBody(),this.finishNode(e,r?"ClassDeclaration":"ClassExpression")},j.parseClassElement=function(e){if(this.eat(a.semi))return null;var r=this.options.ecmaVersion,n=this.startNode(),o="",h=!1,v=!1,w="method",R=!1;if(this.eatContextual("static")){if(r>=13&&this.eat(a.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===a.star?R=!0:o="static"}if(n.static=R,!o&&r>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===a.star)&&!this.canInsertSemicolon()?v=!0:o="async"),!o&&(r>=9||!v)&&this.eat(a.star)&&(h=!0),!o&&!v&&!h){var F=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?w=F:o=F)}if(o?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=o,this.finishNode(n.key,"Identifier")):this.parseClassElementName(n),r<13||this.type===a.parenL||w!=="method"||h||v){var G=!n.static&&Ut(n,"constructor"),Q=G&&e;G&&w!=="method"&&this.raise(n.key.start,"Constructor can't have get/set modifier"),n.kind=G?"constructor":w,this.parseClassMethod(n,h,v,Q)}else this.parseClassField(n);return n},j.isClassElementNameStart=function(){return this.type===a.name||this.type===a.privateId||this.type===a.num||this.type===a.string||this.type===a.bracketL||this.type.keyword},j.parseClassElementName=function(e){this.type===a.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},j.parseClassMethod=function(e,r,n,o){var h=e.key;e.kind==="constructor"?(r&&this.raise(h.start,"Constructor can't be a generator"),n&&this.raise(h.start,"Constructor can't be an async method")):e.static&&Ut(e,"prototype")&&this.raise(h.start,"Classes may not have a static property named prototype");var v=e.value=this.parseMethod(r,n,o);return e.kind==="get"&&v.params.length!==0&&this.raiseRecoverable(v.start,"getter should have no params"),e.kind==="set"&&v.params.length!==1&&this.raiseRecoverable(v.start,"setter should have exactly one param"),e.kind==="set"&&v.params[0].type==="RestElement"&&this.raiseRecoverable(v.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")},j.parseClassField=function(e){return Ut(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&Ut(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(a.eq)?(this.enterScope(Y|B),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")},j.parseClassStaticBlock=function(e){e.body=[];var r=this.labels;for(this.labels=[],this.enterScope($|B);this.type!==a.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=r,this.finishNode(e,"StaticBlock")},j.parseClassId=function(e,r){this.type===a.name?(e.id=this.parseIdent(),r&&this.checkLValSimple(e.id,Ve,!1)):(r===!0&&this.unexpected(),e.id=null)},j.parseClassSuper=function(e){e.superClass=this.eat(a._extends)?this.parseExprSubscripts(null,!1):null},j.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},j.exitClassBody=function(){var e=this.privateNameStack.pop(),r=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var o=this.privateNameStack.length,h=o===0?null:this.privateNameStack[o-1],v=0;v<n.length;++v){var w=n[v];ge(r,w.name)||(h?h.used.push(w):this.raiseRecoverable(w.start,"Private field '#"+w.name+"' must be declared in an enclosing class"))}};function jn(e,r){var n=r.key.name,o=e[n],h="true";return r.type==="MethodDefinition"&&(r.kind==="get"||r.kind==="set")&&(h=(r.static?"s":"i")+r.kind),o==="iget"&&h==="iset"||o==="iset"&&h==="iget"||o==="sget"&&h==="sset"||o==="sset"&&h==="sget"?(e[n]="true",!1):o?!0:(e[n]=h,!1)}function Ut(e,r){var n=e.computed,o=e.key;return!n&&(o.type==="Identifier"&&o.name===r||o.type==="Literal"&&o.value===r)}j.parseExportAllDeclaration=function(e,r){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(r,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==a.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")},j.parseExport=function(e,r){if(this.next(),this.eat(a.star))return this.parseExportAllDeclaration(e,r);if(this.eat(a._default))return this.checkExport(r,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type==="VariableDeclaration"?this.checkVariableExport(r,e.declaration.declarations):this.checkExport(r,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(r),this.eatContextual("from"))this.type!==a.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,o=e.specifiers;n<o.length;n+=1){var h=o[n];this.checkUnreserved(h.local),this.checkLocalExport(h.local),h.local.type==="Literal"&&this.raise(h.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")},j.parseExportDeclaration=function(e){return this.parseStatement(null)},j.parseExportDefaultDeclaration=function(){var e;if(this.type===a._function||(e=this.isAsyncFunction())){var r=this.startNode();return this.next(),e&&this.next(),this.parseFunction(r,bt|xi,!1,e)}else if(this.type===a._class){var n=this.startNode();return this.parseClass(n,"nullableID")}else{var o=this.parseMaybeAssign();return this.semicolon(),o}},j.checkExport=function(e,r,n){e&&(typeof r!="string"&&(r=r.type==="Identifier"?r.name:r.value),ge(e,r)&&this.raiseRecoverable(n,"Duplicate export '"+r+"'"),e[r]=!0)},j.checkPatternExport=function(e,r){var n=r.type;if(n==="Identifier")this.checkExport(e,r,r.start);else if(n==="ObjectPattern")for(var o=0,h=r.properties;o<h.length;o+=1){var v=h[o];this.checkPatternExport(e,v)}else if(n==="ArrayPattern")for(var w=0,R=r.elements;w<R.length;w+=1){var F=R[w];F&&this.checkPatternExport(e,F)}else n==="Property"?this.checkPatternExport(e,r.value):n==="AssignmentPattern"?this.checkPatternExport(e,r.left):n==="RestElement"&&this.checkPatternExport(e,r.argument)},j.checkVariableExport=function(e,r){if(e)for(var n=0,o=r;n<o.length;n+=1){var h=o[n];this.checkPatternExport(e,h.id)}},j.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()},j.parseExportSpecifier=function(e){var r=this.startNode();return r.local=this.parseModuleExportName(),r.exported=this.eatContextual("as")?this.parseModuleExportName():r.local,this.checkExport(e,r.exported,r.exported.start),this.finishNode(r,"ExportSpecifier")},j.parseExportSpecifiers=function(e){var r=[],n=!0;for(this.expect(a.braceL);!this.eat(a.braceR);){if(n)n=!1;else if(this.expect(a.comma),this.afterTrailingComma(a.braceR))break;r.push(this.parseExportSpecifier(e))}return r},j.parseImport=function(e){return this.next(),this.type===a.string?(e.specifiers=Un,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===a.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")},j.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,Ve),this.finishNode(e,"ImportSpecifier")},j.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,Ve),this.finishNode(e,"ImportDefaultSpecifier")},j.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,Ve),this.finishNode(e,"ImportNamespaceSpecifier")},j.parseImportSpecifiers=function(){var e=[],r=!0;if(this.type===a.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(a.comma)))return e;if(this.type===a.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(a.braceL);!this.eat(a.braceR);){if(r)r=!1;else if(this.expect(a.comma),this.afterTrailingComma(a.braceR))break;e.push(this.parseImportSpecifier())}return e},j.parseWithClause=function(){var e=[];if(!this.eat(a._with))return e;this.expect(a.braceL);for(var r={},n=!0;!this.eat(a.braceR);){if(n)n=!1;else if(this.expect(a.comma),this.afterTrailingComma(a.braceR))break;var o=this.parseImportAttribute(),h=o.key.type==="Identifier"?o.key.name:o.key.value;ge(r,h)&&this.raiseRecoverable(o.key.start,"Duplicate attribute key '"+h+"'"),r[h]=!0,e.push(o)}return e},j.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===a.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(a.colon),this.type!==a.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")},j.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===a.string){var e=this.parseLiteral(this.value);return vt.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)},j.adaptDirectivePrologue=function(e){for(var r=0;r<e.length&&this.isDirectiveCandidate(e[r]);++r)e[r].directive=e[r].expression.raw.slice(1,-1)},j.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type==="ExpressionStatement"&&e.expression.type==="Literal"&&typeof e.expression.value=="string"&&(this.input[e.start]==='"'||this.input[e.start]==="'")};var be=se.prototype;be.toAssignable=function(e,r,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&e.name==="await"&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var o=0,h=e.properties;o<h.length;o+=1){var v=h[o];this.toAssignable(v,r),v.type==="RestElement"&&(v.argument.type==="ArrayPattern"||v.argument.type==="ObjectPattern")&&this.raise(v.argument.start,"Unexpected token")}break;case"Property":e.kind!=="init"&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,r);break;case"ArrayExpression":e.type="ArrayPattern",n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,r);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,r),e.argument.type==="AssignmentPattern"&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":e.operator!=="="&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,r);break;case"ParenthesizedExpression":this.toAssignable(e.expression,r,n);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!r)break;default:this.raise(e.start,"Assigning to rvalue")}else n&&this.checkPatternErrors(n,!0);return e},be.toAssignableList=function(e,r){for(var n=e.length,o=0;o<n;o++){var h=e[o];h&&this.toAssignable(h,r)}if(n){var v=e[n-1];this.options.ecmaVersion===6&&r&&v&&v.type==="RestElement"&&v.argument.type!=="Identifier"&&this.unexpected(v.argument.start)}return e},be.parseSpread=function(e){var r=this.startNode();return this.next(),r.argument=this.parseMaybeAssign(!1,e),this.finishNode(r,"SpreadElement")},be.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==a.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")},be.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case a.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(a.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case a.braceL:return this.parseObj(!0)}return this.parseIdent()},be.parseBindingList=function(e,r,n,o){for(var h=[],v=!0;!this.eat(e);)if(v?v=!1:this.expect(a.comma),r&&this.type===a.comma)h.push(null);else{if(n&&this.afterTrailingComma(e))break;if(this.type===a.ellipsis){var w=this.parseRestBinding();this.parseBindingListItem(w),h.push(w),this.type===a.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}else h.push(this.parseAssignableListItem(o))}return h},be.parseAssignableListItem=function(e){var r=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(r),r},be.parseBindingListItem=function(e){return e},be.parseMaybeDefault=function(e,r,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(a.eq))return n;var o=this.startNodeAt(e,r);return o.left=n,o.right=this.parseMaybeAssign(),this.finishNode(o,"AssignmentPattern")},be.checkLValSimple=function(e,r,n){r===void 0&&(r=Mt);var o=r!==Mt;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(o?"Binding ":"Assigning to ")+e.name+" in strict mode"),o&&(r===Ve&&e.name==="let"&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),n&&(ge(n,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),n[e.name]=!0),r!==yi&&this.declareName(e.name,r,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":o&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return o&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,r,n);default:this.raise(e.start,(o?"Binding":"Assigning to")+" rvalue")}},be.checkLValPattern=function(e,r,n){switch(r===void 0&&(r=Mt),e.type){case"ObjectPattern":for(var o=0,h=e.properties;o<h.length;o+=1){var v=h[o];this.checkLValInnerPattern(v,r,n)}break;case"ArrayPattern":for(var w=0,R=e.elements;w<R.length;w+=1){var F=R[w];F&&this.checkLValInnerPattern(F,r,n)}break;default:this.checkLValSimple(e,r,n)}},be.checkLValInnerPattern=function(e,r,n){switch(r===void 0&&(r=Mt),e.type){case"Property":this.checkLValInnerPattern(e.value,r,n);break;case"AssignmentPattern":this.checkLValPattern(e.left,r,n);break;case"RestElement":this.checkLValPattern(e.argument,r,n);break;default:this.checkLValPattern(e,r,n)}};var we=function(r,n,o,h,v){this.token=r,this.isExpr=!!n,this.preserveSpace=!!o,this.override=h,this.generator=!!v},re={b_stat:new we("{",!1),b_expr:new we("{",!0),b_tmpl:new we("${",!1),p_stat:new we("(",!1),p_expr:new we("(",!0),q_tmpl:new we("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new we("function",!1),f_expr:new we("function",!0),f_expr_gen:new we("function",!0,!1,null,!0),f_gen:new we("function",!1,!1,null,!0)},it=se.prototype;it.initialContext=function(){return[re.b_stat]},it.curContext=function(){return this.context[this.context.length-1]},it.braceIsBlock=function(e){var r=this.curContext();return r===re.f_expr||r===re.f_stat?!0:e===a.colon&&(r===re.b_stat||r===re.b_expr)?!r.isExpr:e===a._return||e===a.name&&this.exprAllowed?A.test(this.input.slice(this.lastTokEnd,this.start)):e===a._else||e===a.semi||e===a.eof||e===a.parenR||e===a.arrow?!0:e===a.braceL?r===re.b_stat:e===a._var||e===a._const||e===a.name?!1:!this.exprAllowed},it.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var r=this.context[e];if(r.token==="function")return r.generator}return!1},it.updateContext=function(e){var r,n=this.type;n.keyword&&e===a.dot?this.exprAllowed=!1:(r=n.updateContext)?r.call(this,e):this.exprAllowed=n.beforeExpr},it.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},a.parenR.updateContext=a.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===re.b_stat&&this.curContext().token==="function"&&(e=this.context.pop()),this.exprAllowed=!e.isExpr},a.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?re.b_stat:re.b_expr),this.exprAllowed=!0},a.dollarBraceL.updateContext=function(){this.context.push(re.b_tmpl),this.exprAllowed=!0},a.parenL.updateContext=function(e){var r=e===a._if||e===a._for||e===a._with||e===a._while;this.context.push(r?re.p_stat:re.p_expr),this.exprAllowed=!0},a.incDec.updateContext=function(){},a._function.updateContext=a._class.updateContext=function(e){e.beforeExpr&&e!==a._else&&!(e===a.semi&&this.curContext()!==re.p_stat)&&!(e===a._return&&A.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===a.colon||e===a.braceL)&&this.curContext()===re.b_stat)?this.context.push(re.f_expr):this.context.push(re.f_stat),this.exprAllowed=!1},a.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0},a.backQuote.updateContext=function(){this.curContext()===re.q_tmpl?this.context.pop():this.context.push(re.q_tmpl),this.exprAllowed=!1},a.star.updateContext=function(e){if(e===a._function){var r=this.context.length-1;this.context[r]===re.f_expr?this.context[r]=re.f_expr_gen:this.context[r]=re.f_gen}this.exprAllowed=!0},a.name.updateContext=function(e){var r=!1;this.options.ecmaVersion>=6&&e!==a.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(r=!0),this.exprAllowed=r};var H=se.prototype;H.checkPropClash=function(e,r,n){if(!(this.options.ecmaVersion>=9&&e.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var o=e.key,h;switch(o.type){case"Identifier":h=o.name;break;case"Literal":h=String(o.value);break;default:return}var v=e.kind;if(this.options.ecmaVersion>=6){h==="__proto__"&&v==="init"&&(r.proto&&(n?n.doubleProto<0&&(n.doubleProto=o.start):this.raiseRecoverable(o.start,"Redefinition of __proto__ property")),r.proto=!0);return}h="$"+h;var w=r[h];if(w){var R;v==="init"?R=this.strict&&w.init||w.get||w.set:R=w.init||w[v],R&&this.raiseRecoverable(o.start,"Redefinition of property")}else w=r[h]={init:!1,get:!1,set:!1};w[v]=!0}},H.parseExpression=function(e,r){var n=this.start,o=this.startLoc,h=this.parseMaybeAssign(e,r);if(this.type===a.comma){var v=this.startNodeAt(n,o);for(v.expressions=[h];this.eat(a.comma);)v.expressions.push(this.parseMaybeAssign(e,r));return this.finishNode(v,"SequenceExpression")}return h},H.parseMaybeAssign=function(e,r,n){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var o=!1,h=-1,v=-1,w=-1;r?(h=r.parenthesizedAssign,v=r.trailingComma,w=r.doubleProto,r.parenthesizedAssign=r.trailingComma=-1):(r=new Dt,o=!0);var R=this.start,F=this.startLoc;(this.type===a.parenL||this.type===a.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e==="await");var G=this.parseMaybeConditional(e,r);if(n&&(G=n.call(this,G,R,F)),this.type.isAssign){var Q=this.startNodeAt(R,F);return Q.operator=this.value,this.type===a.eq&&(G=this.toAssignable(G,!1,r)),o||(r.parenthesizedAssign=r.trailingComma=r.doubleProto=-1),r.shorthandAssign>=G.start&&(r.shorthandAssign=-1),this.type===a.eq?this.checkLValPattern(G):this.checkLValSimple(G),Q.left=G,this.next(),Q.right=this.parseMaybeAssign(e),w>-1&&(r.doubleProto=w),this.finishNode(Q,"AssignmentExpression")}else o&&this.checkExpressionErrors(r,!0);return h>-1&&(r.parenthesizedAssign=h),v>-1&&(r.trailingComma=v),G},H.parseMaybeConditional=function(e,r){var n=this.start,o=this.startLoc,h=this.parseExprOps(e,r);if(this.checkExpressionErrors(r))return h;if(this.eat(a.question)){var v=this.startNodeAt(n,o);return v.test=h,v.consequent=this.parseMaybeAssign(),this.expect(a.colon),v.alternate=this.parseMaybeAssign(e),this.finishNode(v,"ConditionalExpression")}return h},H.parseExprOps=function(e,r){var n=this.start,o=this.startLoc,h=this.parseMaybeUnary(r,!1,!1,e);return this.checkExpressionErrors(r)||h.start===n&&h.type==="ArrowFunctionExpression"?h:this.parseExprOp(h,n,o,-1,e)},H.parseExprOp=function(e,r,n,o,h){var v=this.type.binop;if(v!=null&&(!h||this.type!==a._in)&&v>o){var w=this.type===a.logicalOR||this.type===a.logicalAND,R=this.type===a.coalesce;R&&(v=a.logicalAND.binop);var F=this.value;this.next();var G=this.start,Q=this.startLoc,ie=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,h),G,Q,v,h),le=this.buildBinary(r,n,e,ie,F,w||R);return(w&&this.type===a.coalesce||R&&(this.type===a.logicalOR||this.type===a.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(le,r,n,o,h)}return e},H.buildBinary=function(e,r,n,o,h,v){o.type==="PrivateIdentifier"&&this.raise(o.start,"Private identifier can only be left side of binary expression");var w=this.startNodeAt(e,r);return w.left=n,w.operator=h,w.right=o,this.finishNode(w,v?"LogicalExpression":"BinaryExpression")},H.parseMaybeUnary=function(e,r,n,o){var h=this.start,v=this.startLoc,w;if(this.isContextual("await")&&this.canAwait)w=this.parseAwait(o),r=!0;else if(this.type.prefix){var R=this.startNode(),F=this.type===a.incDec;R.operator=this.value,R.prefix=!0,this.next(),R.argument=this.parseMaybeUnary(null,!0,F,o),this.checkExpressionErrors(e,!0),F?this.checkLValSimple(R.argument):this.strict&&R.operator==="delete"&&vi(R.argument)?this.raiseRecoverable(R.start,"Deleting local variable in strict mode"):R.operator==="delete"&&xr(R.argument)?this.raiseRecoverable(R.start,"Private fields can not be deleted"):r=!0,w=this.finishNode(R,F?"UpdateExpression":"UnaryExpression")}else if(!r&&this.type===a.privateId)(o||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),w=this.parsePrivateIdent(),this.type!==a._in&&this.unexpected();else{if(w=this.parseExprSubscripts(e,o),this.checkExpressionErrors(e))return w;for(;this.type.postfix&&!this.canInsertSemicolon();){var G=this.startNodeAt(h,v);G.operator=this.value,G.prefix=!1,G.argument=w,this.checkLValSimple(w),this.next(),w=this.finishNode(G,"UpdateExpression")}}if(!n&&this.eat(a.starstar))if(r)this.unexpected(this.lastTokStart);else return this.buildBinary(h,v,w,this.parseMaybeUnary(null,!1,!1,o),"**",!1);else return w};function vi(e){return e.type==="Identifier"||e.type==="ParenthesizedExpression"&&vi(e.expression)}function xr(e){return e.type==="MemberExpression"&&e.property.type==="PrivateIdentifier"||e.type==="ChainExpression"&&xr(e.expression)||e.type==="ParenthesizedExpression"&&xr(e.expression)}H.parseExprSubscripts=function(e,r){var n=this.start,o=this.startLoc,h=this.parseExprAtom(e,r);if(h.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return h;var v=this.parseSubscripts(h,n,o,!1,r);return e&&v.type==="MemberExpression"&&(e.parenthesizedAssign>=v.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=v.start&&(e.parenthesizedBind=-1),e.trailingComma>=v.start&&(e.trailingComma=-1)),v},H.parseSubscripts=function(e,r,n,o,h){for(var v=this.options.ecmaVersion>=8&&e.type==="Identifier"&&e.name==="async"&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,w=!1;;){var R=this.parseSubscript(e,r,n,o,v,w,h);if(R.optional&&(w=!0),R===e||R.type==="ArrowFunctionExpression"){if(w){var F=this.startNodeAt(r,n);F.expression=R,R=this.finishNode(F,"ChainExpression")}return R}e=R}},H.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(a.arrow)},H.parseSubscriptAsyncArrow=function(e,r,n,o){return this.parseArrowExpression(this.startNodeAt(e,r),n,!0,o)},H.parseSubscript=function(e,r,n,o,h,v,w){var R=this.options.ecmaVersion>=11,F=R&&this.eat(a.questionDot);o&&F&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var G=this.eat(a.bracketL);if(G||F&&this.type!==a.parenL&&this.type!==a.backQuote||this.eat(a.dot)){var Q=this.startNodeAt(r,n);Q.object=e,G?(Q.property=this.parseExpression(),this.expect(a.bracketR)):this.type===a.privateId&&e.type!=="Super"?Q.property=this.parsePrivateIdent():Q.property=this.parseIdent(this.options.allowReserved!=="never"),Q.computed=!!G,R&&(Q.optional=F),e=this.finishNode(Q,"MemberExpression")}else if(!o&&this.eat(a.parenL)){var ie=new Dt,le=this.yieldPos,Ct=this.awaitPos,nt=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var Ht=this.parseExprList(a.parenR,this.options.ecmaVersion>=8,!1,ie);if(h&&!F&&this.shouldParseAsyncArrow())return this.checkPatternErrors(ie,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=le,this.awaitPos=Ct,this.awaitIdentPos=nt,this.parseSubscriptAsyncArrow(r,n,Ht,w);this.checkExpressionErrors(ie,!0),this.yieldPos=le||this.yieldPos,this.awaitPos=Ct||this.awaitPos,this.awaitIdentPos=nt||this.awaitIdentPos;var st=this.startNodeAt(r,n);st.callee=e,st.arguments=Ht,R&&(st.optional=F),e=this.finishNode(st,"CallExpression")}else if(this.type===a.backQuote){(F||v)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var at=this.startNodeAt(r,n);at.tag=e,at.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(at,"TaggedTemplateExpression")}return e},H.parseExprAtom=function(e,r,n){this.type===a.slash&&this.readRegexp();var o,h=this.potentialArrowAt===this.start;switch(this.type){case a._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),o=this.startNode(),this.next(),this.type===a.parenL&&!this.allowDirectSuper&&this.raise(o.start,"super() call outside constructor of a subclass"),this.type!==a.dot&&this.type!==a.bracketL&&this.type!==a.parenL&&this.unexpected(),this.finishNode(o,"Super");case a._this:return o=this.startNode(),this.next(),this.finishNode(o,"ThisExpression");case a.name:var v=this.start,w=this.startLoc,R=this.containsEsc,F=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!R&&F.name==="async"&&!this.canInsertSemicolon()&&this.eat(a._function))return this.overrideContext(re.f_expr),this.parseFunction(this.startNodeAt(v,w),0,!1,!0,r);if(h&&!this.canInsertSemicolon()){if(this.eat(a.arrow))return this.parseArrowExpression(this.startNodeAt(v,w),[F],!1,r);if(this.options.ecmaVersion>=8&&F.name==="async"&&this.type===a.name&&!R&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return F=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(a.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(v,w),[F],!0,r)}return F;case a.regexp:var G=this.value;return o=this.parseLiteral(G.value),o.regex={pattern:G.pattern,flags:G.flags},o;case a.num:case a.string:return this.parseLiteral(this.value);case a._null:case a._true:case a._false:return o=this.startNode(),o.value=this.type===a._null?null:this.type===a._true,o.raw=this.type.keyword,this.next(),this.finishNode(o,"Literal");case a.parenL:var Q=this.start,ie=this.parseParenAndDistinguishExpression(h,r);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(ie)&&(e.parenthesizedAssign=Q),e.parenthesizedBind<0&&(e.parenthesizedBind=Q)),ie;case a.bracketL:return o=this.startNode(),this.next(),o.elements=this.parseExprList(a.bracketR,!0,!0,e),this.finishNode(o,"ArrayExpression");case a.braceL:return this.overrideContext(re.b_expr),this.parseObj(!1,e);case a._function:return o=this.startNode(),this.next(),this.parseFunction(o,0);case a._class:return this.parseClass(this.startNode(),!1);case a._new:return this.parseNew();case a.backQuote:return this.parseTemplate();case a._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},H.parseExprAtomDefault=function(){this.unexpected()},H.parseExprImport=function(e){var r=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===a.parenL&&!e)return this.parseDynamicImport(r);if(this.type===a.dot){var n=this.startNodeAt(r.start,r.loc&&r.loc.start);return n.name="import",r.meta=this.finishNode(n,"Identifier"),this.parseImportMeta(r)}else this.unexpected()},H.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(a.parenR)?e.options=null:(this.expect(a.comma),this.afterTrailingComma(a.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(a.parenR)||(this.expect(a.comma),this.afterTrailingComma(a.parenR)||this.unexpected())));else if(!this.eat(a.parenR)){var r=this.start;this.eat(a.comma)&&this.eat(a.parenR)?this.raiseRecoverable(r,"Trailing comma is not allowed in import()"):this.unexpected(r)}return this.finishNode(e,"ImportExpression")},H.parseImportMeta=function(e){this.next();var r=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="meta"&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),r&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")},H.parseLiteral=function(e){var r=this.startNode();return r.value=e,r.raw=this.input.slice(this.start,this.end),r.raw.charCodeAt(r.raw.length-1)===110&&(r.bigint=r.value!=null?r.value.toString():r.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(r,"Literal")},H.parseParenExpression=function(){this.expect(a.parenL);var e=this.parseExpression();return this.expect(a.parenR),e},H.shouldParseArrow=function(e){return!this.canInsertSemicolon()},H.parseParenAndDistinguishExpression=function(e,r){var n=this.start,o=this.startLoc,h,v=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var w=this.start,R=this.startLoc,F=[],G=!0,Q=!1,ie=new Dt,le=this.yieldPos,Ct=this.awaitPos,nt;for(this.yieldPos=0,this.awaitPos=0;this.type!==a.parenR;)if(G?G=!1:this.expect(a.comma),v&&this.afterTrailingComma(a.parenR,!0)){Q=!0;break}else if(this.type===a.ellipsis){nt=this.start,F.push(this.parseParenItem(this.parseRestBinding())),this.type===a.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else F.push(this.parseMaybeAssign(!1,ie,this.parseParenItem));var Ht=this.lastTokEnd,st=this.lastTokEndLoc;if(this.expect(a.parenR),e&&this.shouldParseArrow(F)&&this.eat(a.arrow))return this.checkPatternErrors(ie,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=le,this.awaitPos=Ct,this.parseParenArrowList(n,o,F,r);(!F.length||Q)&&this.unexpected(this.lastTokStart),nt&&this.unexpected(nt),this.checkExpressionErrors(ie,!0),this.yieldPos=le||this.yieldPos,this.awaitPos=Ct||this.awaitPos,F.length>1?(h=this.startNodeAt(w,R),h.expressions=F,this.finishNodeAt(h,"SequenceExpression",Ht,st)):h=F[0]}else h=this.parseParenExpression();if(this.options.preserveParens){var at=this.startNodeAt(n,o);return at.expression=h,this.finishNode(at,"ParenthesizedExpression")}else return h},H.parseParenItem=function(e){return e},H.parseParenArrowList=function(e,r,n,o){return this.parseArrowExpression(this.startNodeAt(e,r),n,!1,o)};var qn=[];H.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===a.dot){var r=this.startNodeAt(e.start,e.loc&&e.loc.start);r.name="new",e.meta=this.finishNode(r,"Identifier"),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="target"&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),n&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var o=this.start,h=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),o,h,!0,!1),this.eat(a.parenL)?e.arguments=this.parseExprList(a.parenR,this.options.ecmaVersion>=8,!1):e.arguments=qn,this.finishNode(e,"NewExpression")},H.parseTemplateElement=function(e){var r=e.isTagged,n=this.startNode();return this.type===a.invalidTemplate?(r||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value.replace(/\r\n?/g,`
|
|
4
|
+
`),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
|
5
|
+
`),cooked:this.value},this.next(),n.tail=this.type===a.backQuote,this.finishNode(n,"TemplateElement")},H.parseTemplate=function(e){e===void 0&&(e={});var r=e.isTagged;r===void 0&&(r=!1);var n=this.startNode();this.next(),n.expressions=[];var o=this.parseTemplateElement({isTagged:r});for(n.quasis=[o];!o.tail;)this.type===a.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(a.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(a.braceR),n.quasis.push(o=this.parseTemplateElement({isTagged:r}));return this.next(),this.finishNode(n,"TemplateLiteral")},H.isAsyncProp=function(e){return!e.computed&&e.key.type==="Identifier"&&e.key.name==="async"&&(this.type===a.name||this.type===a.num||this.type===a.string||this.type===a.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===a.star)&&!A.test(this.input.slice(this.lastTokEnd,this.start))},H.parseObj=function(e,r){var n=this.startNode(),o=!0,h={};for(n.properties=[],this.next();!this.eat(a.braceR);){if(o)o=!1;else if(this.expect(a.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(a.braceR))break;var v=this.parseProperty(e,r);e||this.checkPropClash(v,h,r),n.properties.push(v)}return this.finishNode(n,e?"ObjectPattern":"ObjectExpression")},H.parseProperty=function(e,r){var n=this.startNode(),o,h,v,w;if(this.options.ecmaVersion>=9&&this.eat(a.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===a.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(n,"RestElement")):(n.argument=this.parseMaybeAssign(!1,r),this.type===a.comma&&r&&r.trailingComma<0&&(r.trailingComma=this.start),this.finishNode(n,"SpreadElement"));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||r)&&(v=this.start,w=this.startLoc),e||(o=this.eat(a.star)));var R=this.containsEsc;return this.parsePropertyName(n),!e&&!R&&this.options.ecmaVersion>=8&&!o&&this.isAsyncProp(n)?(h=!0,o=this.options.ecmaVersion>=9&&this.eat(a.star),this.parsePropertyName(n)):h=!1,this.parsePropertyValue(n,e,o,h,v,w,r,R),this.finishNode(n,"Property")},H.parseGetterSetter=function(e){var r=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=r;var n=e.kind==="get"?0:1;if(e.value.params.length!==n){var o=e.value.start;e.kind==="get"?this.raiseRecoverable(o,"getter should have no params"):this.raiseRecoverable(o,"setter should have exactly one param")}else e.kind==="set"&&e.value.params[0].type==="RestElement"&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")},H.parsePropertyValue=function(e,r,n,o,h,v,w,R){(n||o)&&this.type===a.colon&&this.unexpected(),this.eat(a.colon)?(e.value=r?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,w),e.kind="init"):this.options.ecmaVersion>=6&&this.type===a.parenL?(r&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,o),e.kind="init"):!r&&!R&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type==="Identifier"&&(e.key.name==="get"||e.key.name==="set")&&this.type!==a.comma&&this.type!==a.braceR&&this.type!==a.eq?((n||o)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type==="Identifier"?((n||o)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=h),r?e.value=this.parseMaybeDefault(h,v,this.copyNode(e.key)):this.type===a.eq&&w?(w.shorthandAssign<0&&(w.shorthandAssign=this.start),e.value=this.parseMaybeDefault(h,v,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected()},H.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(a.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(a.bracketR),e.key;e.computed=!1}return e.key=this.type===a.num||this.type===a.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")},H.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},H.parseMethod=function(e,r,n){var o=this.startNode(),h=this.yieldPos,v=this.awaitPos,w=this.awaitIdentPos;return this.initFunction(o),this.options.ecmaVersion>=6&&(o.generator=e),this.options.ecmaVersion>=8&&(o.async=!!r),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ne(r,o.generator)|B|(n?L:0)),this.expect(a.parenL),o.params=this.parseBindingList(a.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(o,!1,!0,!1),this.yieldPos=h,this.awaitPos=v,this.awaitIdentPos=w,this.finishNode(o,"FunctionExpression")},H.parseArrowExpression=function(e,r,n,o){var h=this.yieldPos,v=this.awaitPos,w=this.awaitIdentPos;return this.enterScope(Ne(n,!1)|E),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(r,!0),this.parseFunctionBody(e,!0,!1,o),this.yieldPos=h,this.awaitPos=v,this.awaitIdentPos=w,this.finishNode(e,"ArrowFunctionExpression")},H.parseFunctionBody=function(e,r,n,o){var h=r&&this.type!==a.braceL,v=this.strict,w=!1;if(h)e.body=this.parseMaybeAssign(o),e.expression=!0,this.checkParams(e,!1);else{var R=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!v||R)&&(w=this.strictDirective(this.end),w&&R&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var F=this.labels;this.labels=[],w&&(this.strict=!0),this.checkParams(e,!v&&!w&&!r&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,yi),e.body=this.parseBlock(!1,void 0,w&&!v),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=F}this.exitScope()},H.isSimpleParamList=function(e){for(var r=0,n=e;r<n.length;r+=1){var o=n[r];if(o.type!=="Identifier")return!1}return!0},H.checkParams=function(e,r){for(var n=Object.create(null),o=0,h=e.params;o<h.length;o+=1){var v=h[o];this.checkLValInnerPattern(v,mr,r?null:n)}},H.parseExprList=function(e,r,n,o){for(var h=[],v=!0;!this.eat(e);){if(v)v=!1;else if(this.expect(a.comma),r&&this.afterTrailingComma(e))break;var w=void 0;n&&this.type===a.comma?w=null:this.type===a.ellipsis?(w=this.parseSpread(o),o&&this.type===a.comma&&o.trailingComma<0&&(o.trailingComma=this.start)):w=this.parseMaybeAssign(!1,o),h.push(w)}return h},H.checkUnreserved=function(e){var r=e.start,n=e.end,o=e.name;if(this.inGenerator&&o==="yield"&&this.raiseRecoverable(r,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&o==="await"&&this.raiseRecoverable(r,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&ye)&&o==="arguments"&&this.raiseRecoverable(r,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(o==="arguments"||o==="await")&&this.raise(r,"Cannot use "+o+" in class static initialization block"),this.keywords.test(o)&&this.raise(r,"Unexpected keyword '"+o+"'"),!(this.options.ecmaVersion<6&&this.input.slice(r,n).indexOf("\\")!==-1)){var h=this.strict?this.reservedWordsStrict:this.reservedWords;h.test(o)&&(!this.inAsync&&o==="await"&&this.raiseRecoverable(r,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(r,"The keyword '"+o+"' is reserved"))}},H.parseIdent=function(e){var r=this.parseIdentNode();return this.next(!!e),this.finishNode(r,"Identifier"),e||(this.checkUnreserved(r),r.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=r.start)),r},H.parseIdentNode=function(){var e=this.startNode();return this.type===a.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name==="class"||e.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=a.name):this.unexpected(),e},H.parsePrivateIdent=function(){var e=this.startNode();return this.type===a.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},H.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var r=this.startNode();return this.next(),this.type===a.semi||this.canInsertSemicolon()||this.type!==a.star&&!this.type.startsExpr?(r.delegate=!1,r.argument=null):(r.delegate=this.eat(a.star),r.argument=this.parseMaybeAssign(e)),this.finishNode(r,"YieldExpression")},H.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var r=this.startNode();return this.next(),r.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(r,"AwaitExpression")};var jt=se.prototype;jt.raise=function(e,r){var n=Re(this.input,e);r+=" ("+n.line+":"+n.column+")",this.sourceFile&&(r+=" in "+this.sourceFile);var o=new SyntaxError(r);throw o.pos=e,o.loc=n,o.raisedAt=this.pos,o},jt.raiseRecoverable=jt.raise,jt.curPosition=function(){if(this.options.locations)return new Pe(this.curLine,this.pos-this.lineStart)};var Me=se.prototype,$n=function(r){this.flags=r,this.var=[],this.lexical=[],this.functions=[]};Me.enterScope=function(e){this.scopeStack.push(new $n(e))},Me.exitScope=function(){this.scopeStack.pop()},Me.treatFunctionsAsVarInScope=function(e){return e.flags&Le||!this.inModule&&e.flags&$e},Me.declareName=function(e,r,n){var o=!1;if(r===Ve){var h=this.currentScope();o=h.lexical.indexOf(e)>-1||h.functions.indexOf(e)>-1||h.var.indexOf(e)>-1,h.lexical.push(e),this.inModule&&h.flags&$e&&delete this.undefinedExports[e]}else if(r===gi){var v=this.currentScope();v.lexical.push(e)}else if(r===mi){var w=this.currentScope();this.treatFunctionsAsVar?o=w.lexical.indexOf(e)>-1:o=w.lexical.indexOf(e)>-1||w.var.indexOf(e)>-1,w.functions.push(e)}else for(var R=this.scopeStack.length-1;R>=0;--R){var F=this.scopeStack[R];if(F.lexical.indexOf(e)>-1&&!(F.flags&P&&F.lexical[0]===e)||!this.treatFunctionsAsVarInScope(F)&&F.functions.indexOf(e)>-1){o=!0;break}if(F.var.push(e),this.inModule&&F.flags&$e&&delete this.undefinedExports[e],F.flags&ye)break}o&&this.raiseRecoverable(n,"Identifier '"+e+"' has already been declared")},Me.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},Me.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},Me.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var r=this.scopeStack[e];if(r.flags&(ye|Y|$))return r}},Me.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var r=this.scopeStack[e];if(r.flags&(ye|Y|$)&&!(r.flags&E))return r}};var wt=function(r,n,o){this.type="",this.start=n,this.end=0,r.options.locations&&(this.loc=new qe(r,o)),r.options.directSourceFile&&(this.sourceFile=r.options.directSourceFile),r.options.ranges&&(this.range=[n,0])},_t=se.prototype;_t.startNode=function(){return new wt(this,this.start,this.startLoc)},_t.startNodeAt=function(e,r){return new wt(this,e,r)};function bi(e,r,n,o){return e.type=r,e.end=n,this.options.locations&&(e.loc.end=o),this.options.ranges&&(e.range[1]=n),e}_t.finishNode=function(e,r){return bi.call(this,e,r,this.lastTokEnd,this.lastTokEndLoc)},_t.finishNodeAt=function(e,r,n,o){return bi.call(this,e,r,n,o)},_t.copyNode=function(e){var r=new wt(this,e.start,this.startLoc);for(var n in e)r[n]=e[n];return r};var Gn="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",wi="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",_i=wi+" Extended_Pictographic",Ci=_i,Si=Ci+" EBase EComp EMod EPres ExtPict",Ei=Si,Hn=Ei,zn={9:wi,10:_i,11:Ci,12:Si,13:Ei,14:Hn},Kn="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",Qn={9:"",10:"",11:"",12:"",13:"",14:Kn},Ai="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",Ii="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",Ti=Ii+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",ki=Ti+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Pi=ki+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Ri=Pi+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Jn=Ri+" "+Gn,Xn={9:Ii,10:Ti,11:ki,12:Pi,13:Ri,14:Jn},Ni={};function Yn(e){var r=Ni[e]={binary:Se(zn[e]+" "+Ai),binaryOfStrings:Se(Qn[e]),nonBinary:{General_Category:Se(Ai),Script:Se(Xn[e])}};r.nonBinary.Script_Extensions=r.nonBinary.Script,r.nonBinary.gc=r.nonBinary.General_Category,r.nonBinary.sc=r.nonBinary.Script,r.nonBinary.scx=r.nonBinary.Script_Extensions}for(var vr=0,Vi=[9,10,11,12,13,14];vr<Vi.length;vr+=1){var Zn=Vi[vr];Yn(Zn)}var U=se.prototype,qt=function(r,n){this.parent=r,this.base=n||this};qt.prototype.separatedFrom=function(r){for(var n=this;n;n=n.parent)for(var o=r;o;o=o.parent)if(n.base===o.base&&n!==o)return!0;return!1},qt.prototype.sibling=function(){return new qt(this.parent,this.base)};var Te=function(r){this.parser=r,this.validFlags="gim"+(r.options.ecmaVersion>=6?"uy":"")+(r.options.ecmaVersion>=9?"s":"")+(r.options.ecmaVersion>=13?"d":"")+(r.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Ni[r.options.ecmaVersion>=14?14:r.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};Te.prototype.reset=function(r,n,o){var h=o.indexOf("v")!==-1,v=o.indexOf("u")!==-1;this.start=r|0,this.source=n+"",this.flags=o,h&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=v&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=v&&this.parser.options.ecmaVersion>=9)},Te.prototype.raise=function(r){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+r)},Te.prototype.at=function(r,n){n===void 0&&(n=!1);var o=this.source,h=o.length;if(r>=h)return-1;var v=o.charCodeAt(r);if(!(n||this.switchU)||v<=55295||v>=57344||r+1>=h)return v;var w=o.charCodeAt(r+1);return w>=56320&&w<=57343?(v<<10)+w-56613888:v},Te.prototype.nextIndex=function(r,n){n===void 0&&(n=!1);var o=this.source,h=o.length;if(r>=h)return h;var v=o.charCodeAt(r),w;return!(n||this.switchU)||v<=55295||v>=57344||r+1>=h||(w=o.charCodeAt(r+1))<56320||w>57343?r+1:r+2},Te.prototype.current=function(r){return r===void 0&&(r=!1),this.at(this.pos,r)},Te.prototype.lookahead=function(r){return r===void 0&&(r=!1),this.at(this.nextIndex(this.pos,r),r)},Te.prototype.advance=function(r){r===void 0&&(r=!1),this.pos=this.nextIndex(this.pos,r)},Te.prototype.eat=function(r,n){return n===void 0&&(n=!1),this.current(n)===r?(this.advance(n),!0):!1},Te.prototype.eatChars=function(r,n){n===void 0&&(n=!1);for(var o=this.pos,h=0,v=r;h<v.length;h+=1){var w=v[h],R=this.at(o,n);if(R===-1||R!==w)return!1;o=this.nextIndex(o,n)}return this.pos=o,!0},U.validateRegExpFlags=function(e){for(var r=e.validFlags,n=e.flags,o=!1,h=!1,v=0;v<n.length;v++){var w=n.charAt(v);r.indexOf(w)===-1&&this.raise(e.start,"Invalid regular expression flag"),n.indexOf(w,v+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),w==="u"&&(o=!0),w==="v"&&(h=!0)}this.options.ecmaVersion>=15&&o&&h&&this.raise(e.start,"Invalid regular expression flag")};function es(e){for(var r in e)return!0;return!1}U.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&es(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},U.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var r=0,n=e.backReferenceNames;r<n.length;r+=1){var o=n[r];e.groupNames[o]||e.raise("Invalid named capture referenced")}},U.regexp_disjunction=function(e){var r=this.options.ecmaVersion>=16;for(r&&(e.branchID=new qt(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)r&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);r&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")},U.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},U.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1},U.regexp_eatAssertion=function(e){var r=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=r}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=r,!1},U.regexp_eatQuantifier=function(e,r){return r===void 0&&(r=!1),this.regexp_eatQuantifierPrefix(e,r)?(e.eat(63),!0):!1},U.regexp_eatQuantifierPrefix=function(e,r){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,r)},U.regexp_eatBracedQuantifier=function(e,r){var n=e.pos;if(e.eat(123)){var o=0,h=-1;if(this.regexp_eatDecimalDigits(e)&&(o=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(h=e.lastIntValue),e.eat(125)))return h!==-1&&h<o&&!r&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!r&&e.raise("Incomplete quantifier"),e.pos=n}return!1},U.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)},U.regexp_eatReverseSolidusAtomEscape=function(e){var r=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=r}return!1},U.regexp_eatUncapturingGroup=function(e){var r=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),o=e.eat(45);if(n||o){for(var h=0;h<n.length;h++){var v=n.charAt(h);n.indexOf(v,h+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(o){var w=this.regexp_eatModifiers(e);!n&&!w&&e.current()===58&&e.raise("Invalid regular expression modifiers");for(var R=0;R<w.length;R++){var F=w.charAt(R);(w.indexOf(F,R+1)>-1||n.indexOf(F)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=r}return!1},U.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1},U.regexp_eatModifiers=function(e){for(var r="",n=0;(n=e.current())!==-1&&ts(n);)r+=xe(n),e.advance();return r};function ts(e){return e===105||e===109||e===115}U.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},U.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1},U.regexp_eatSyntaxCharacter=function(e){var r=e.current();return Oi(r)?(e.lastIntValue=r,e.advance(),!0):!1};function Oi(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}U.regexp_eatPatternCharacters=function(e){for(var r=e.pos,n=0;(n=e.current())!==-1&&!Oi(n);)e.advance();return e.pos!==r},U.regexp_eatExtendedPatternCharacter=function(e){var r=e.current();return r!==-1&&r!==36&&!(r>=40&&r<=43)&&r!==46&&r!==63&&r!==91&&r!==94&&r!==124?(e.advance(),!0):!1},U.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var r=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(r)for(var o=0,h=n;o<h.length;o+=1){var v=h[o];v.separatedFrom(e.branchID)||e.raise("Duplicate capture group name")}else e.raise("Duplicate capture group name");r?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},U.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1},U.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=xe(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=xe(e.lastIntValue);return!0}return!1},U.regexp_eatRegExpIdentifierStart=function(e){var r=e.pos,n=this.options.ecmaVersion>=11,o=e.current(n);return e.advance(n),o===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(o=e.lastIntValue),rs(o)?(e.lastIntValue=o,!0):(e.pos=r,!1)};function rs(e){return N(e,!0)||e===36||e===95}U.regexp_eatRegExpIdentifierPart=function(e){var r=e.pos,n=this.options.ecmaVersion>=11,o=e.current(n);return e.advance(n),o===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(o=e.lastIntValue),is(o)?(e.lastIntValue=o,!0):(e.pos=r,!1)};function is(e){return O(e,!0)||e===36||e===95||e===8204||e===8205}U.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)},U.regexp_eatBackReference=function(e){var r=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=r}return!1},U.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1},U.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},U.regexp_eatCControlLetter=function(e){var r=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=r}return!1},U.regexp_eatZero=function(e){return e.current()===48&&!$t(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1},U.regexp_eatControlEscape=function(e){var r=e.current();return r===116?(e.lastIntValue=9,e.advance(),!0):r===110?(e.lastIntValue=10,e.advance(),!0):r===118?(e.lastIntValue=11,e.advance(),!0):r===102?(e.lastIntValue=12,e.advance(),!0):r===114?(e.lastIntValue=13,e.advance(),!0):!1},U.regexp_eatControlLetter=function(e){var r=e.current();return Wi(r)?(e.lastIntValue=r%32,e.advance(),!0):!1};function Wi(e){return e>=65&&e<=90||e>=97&&e<=122}U.regexp_eatRegExpUnicodeEscapeSequence=function(e,r){r===void 0&&(r=!1);var n=e.pos,o=r||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var h=e.lastIntValue;if(o&&h>=55296&&h<=56319){var v=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var w=e.lastIntValue;if(w>=56320&&w<=57343)return e.lastIntValue=(h-55296)*1024+(w-56320)+65536,!0}e.pos=v,e.lastIntValue=h}return!0}if(o&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&ns(e.lastIntValue))return!0;o&&e.raise("Invalid unicode escape"),e.pos=n}return!1};function ns(e){return e>=0&&e<=1114111}U.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var r=e.current();return r!==99&&(!e.switchN||r!==107)?(e.lastIntValue=r,e.advance(),!0):!1},U.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var r=e.current();if(r>=49&&r<=57){do e.lastIntValue=10*e.lastIntValue+(r-48),e.advance();while((r=e.current())>=48&&r<=57);return!0}return!1};var Bi=0,Oe=1,_e=2;U.regexp_eatCharacterClassEscape=function(e){var r=e.current();if(ss(r))return e.lastIntValue=-1,e.advance(),Oe;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=r===80)||r===112)){e.lastIntValue=-1,e.advance();var o;if(e.eat(123)&&(o=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&o===_e&&e.raise("Invalid property name"),o;e.raise("Invalid property name")}return Bi};function ss(e){return e===100||e===68||e===115||e===83||e===119||e===87}U.regexp_eatUnicodePropertyValueExpression=function(e){var r=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var o=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,o),Oe}}if(e.pos=r,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var h=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,h)}return Bi},U.regexp_validateUnicodePropertyNameAndValue=function(e,r,n){ge(e.unicodeProperties.nonBinary,r)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[r].test(n)||e.raise("Invalid property value")},U.regexp_validateUnicodePropertyNameOrValue=function(e,r){if(e.unicodeProperties.binary.test(r))return Oe;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(r))return _e;e.raise("Invalid property name")},U.regexp_eatUnicodePropertyName=function(e){var r=0;for(e.lastStringValue="";Fi(r=e.current());)e.lastStringValue+=xe(r),e.advance();return e.lastStringValue!==""};function Fi(e){return Wi(e)||e===95}U.regexp_eatUnicodePropertyValue=function(e){var r=0;for(e.lastStringValue="";as(r=e.current());)e.lastStringValue+=xe(r),e.advance();return e.lastStringValue!==""};function as(e){return Fi(e)||$t(e)}U.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},U.regexp_eatCharacterClass=function(e){if(e.eat(91)){var r=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),r&&n===_e&&e.raise("Negated character class may contain strings"),!0}return!1},U.regexp_classContents=function(e){return e.current()===93?Oe:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),Oe)},U.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var r=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(r===-1||n===-1)&&e.raise("Invalid character class"),r!==-1&&n!==-1&&r>n&&e.raise("Range out of order in character class")}}},U.regexp_eatClassAtom=function(e){var r=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||Di(n))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=r}var o=e.current();return o!==93?(e.lastIntValue=o,e.advance(),!0):!1},U.regexp_eatClassEscape=function(e){var r=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=r}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},U.regexp_classSetExpression=function(e){var r=Oe,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===_e&&(r=_e);for(var o=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==_e&&(r=Oe);continue}e.raise("Invalid character in character class")}if(o!==e.pos)return r;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(o!==e.pos)return r}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e),!n)return r;n===_e&&(r=_e)}},U.regexp_eatClassSetRange=function(e){var r=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var o=e.lastIntValue;return n!==-1&&o!==-1&&n>o&&e.raise("Range out of order in character class"),!0}e.pos=r}return!1},U.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?Oe:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},U.regexp_eatNestedClass=function(e){var r=e.pos;if(e.eat(91)){var n=e.eat(94),o=this.regexp_classContents(e);if(e.eat(93))return n&&o===_e&&e.raise("Negated character class may contain strings"),o;e.pos=r}if(e.eat(92)){var h=this.regexp_eatCharacterClassEscape(e);if(h)return h;e.pos=r}return null},U.regexp_eatClassStringDisjunction=function(e){var r=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise("Invalid escape");e.pos=r}return null},U.regexp_classStringDisjunctionContents=function(e){for(var r=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===_e&&(r=_e);return r},U.regexp_classString=function(e){for(var r=0;this.regexp_eatClassSetCharacter(e);)r++;return r===1?Oe:_e},U.regexp_eatClassSetCharacter=function(e){var r=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=r,!1);var n=e.current();return n<0||n===e.lookahead()&&os(n)||us(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function os(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function us(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}U.regexp_eatClassSetReservedPunctuator=function(e){var r=e.current();return cs(r)?(e.lastIntValue=r,e.advance(),!0):!1};function cs(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}U.regexp_eatClassControlLetter=function(e){var r=e.current();return $t(r)||r===95?(e.lastIntValue=r%32,e.advance(),!0):!1},U.regexp_eatHexEscapeSequence=function(e){var r=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=r}return!1},U.regexp_eatDecimalDigits=function(e){var r=e.pos,n=0;for(e.lastIntValue=0;$t(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==r};function $t(e){return e>=48&&e<=57}U.regexp_eatHexDigits=function(e){var r=e.pos,n=0;for(e.lastIntValue=0;Li(n=e.current());)e.lastIntValue=16*e.lastIntValue+Mi(n),e.advance();return e.pos!==r};function Li(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Mi(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}U.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var r=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;r<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=r*64+n*8+e.lastIntValue:e.lastIntValue=r*8+n}else e.lastIntValue=r;return!0}return!1},U.regexp_eatOctalDigit=function(e){var r=e.current();return Di(r)?(e.lastIntValue=r-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Di(e){return e>=48&&e<=55}U.regexp_eatFixedHexDigits=function(e,r){var n=e.pos;e.lastIntValue=0;for(var o=0;o<r;++o){var h=e.current();if(!Li(h))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+Mi(h),e.advance()}return!0};var Gt=function(r){this.type=r.type,this.value=r.value,this.start=r.start,this.end=r.end,r.options.locations&&(this.loc=new qe(r,r.startLoc,r.endLoc)),r.options.ranges&&(this.range=[r.start,r.end])},Z=se.prototype;Z.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Gt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},Z.getToken=function(){return this.next(),new Gt(this)},typeof Symbol<"u"&&(Z[Symbol.iterator]=function(){var e=this;return{next:function(){var r=e.getToken();return{done:r.type===a.eof,value:r}}}}),Z.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(a.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())},Z.readToken=function(e){return N(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)},Z.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var r=this.input.charCodeAt(this.pos+1);return r<=56319||r>=57344?e:(e<<10)+r-56613888},Z.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),r=this.pos,n=this.input.indexOf("*/",this.pos+=2);if(n===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=n+2,this.options.locations)for(var o=void 0,h=r;(o=J(this.input,h,this.pos))>-1;)++this.curLine,h=this.lineStart=o;this.options.onComment&&this.options.onComment(!0,this.input.slice(r+2,n),r,this.pos,e,this.curPosition())},Z.skipLineComment=function(e){for(var r=this.pos,n=this.options.onComment&&this.curPosition(),o=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!I(o);)o=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(r+e,this.pos),r,this.pos,n,this.curPosition())},Z.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(e>8&&e<14||e>=5760&&K.test(String.fromCharCode(e)))++this.pos;else break e}}},Z.finishToken=function(e,r){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=r,this.updateContext(n)},Z.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var r=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&r===46?(this.pos+=3,this.finishToken(a.ellipsis)):(++this.pos,this.finishToken(a.dot))},Z.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(a.assign,2):this.finishOp(a.slash,1)},Z.readToken_mult_modulo_exp=function(e){var r=this.input.charCodeAt(this.pos+1),n=1,o=e===42?a.star:a.modulo;return this.options.ecmaVersion>=7&&e===42&&r===42&&(++n,o=a.starstar,r=this.input.charCodeAt(this.pos+2)),r===61?this.finishOp(a.assign,n+1):this.finishOp(o,n)},Z.readToken_pipe_amp=function(e){var r=this.input.charCodeAt(this.pos+1);if(r===e){if(this.options.ecmaVersion>=12){var n=this.input.charCodeAt(this.pos+2);if(n===61)return this.finishOp(a.assign,3)}return this.finishOp(e===124?a.logicalOR:a.logicalAND,2)}return r===61?this.finishOp(a.assign,2):this.finishOp(e===124?a.bitwiseOR:a.bitwiseAND,1)},Z.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(a.assign,2):this.finishOp(a.bitwiseXOR,1)},Z.readToken_plus_min=function(e){var r=this.input.charCodeAt(this.pos+1);return r===e?r===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||A.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(a.incDec,2):r===61?this.finishOp(a.assign,2):this.finishOp(a.plusMin,1)},Z.readToken_lt_gt=function(e){var r=this.input.charCodeAt(this.pos+1),n=1;return r===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(a.assign,n+1):this.finishOp(a.bitShift,n)):r===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(r===61&&(n=2),this.finishOp(a.relational,n))},Z.readToken_eq_excl=function(e){var r=this.input.charCodeAt(this.pos+1);return r===61?this.finishOp(a.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&r===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(a.arrow)):this.finishOp(e===61?a.eq:a.prefix,1)},Z.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var r=this.input.charCodeAt(this.pos+1);if(r===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(a.questionDot,2)}if(r===63){if(e>=12){var o=this.input.charCodeAt(this.pos+2);if(o===61)return this.finishOp(a.assign,3)}return this.finishOp(a.coalesce,2)}}return this.finishOp(a.question,1)},Z.readToken_numberSign=function(){var e=this.options.ecmaVersion,r=35;if(e>=13&&(++this.pos,r=this.fullCharCodeAtPos(),N(r,!0)||r===92))return this.finishToken(a.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+xe(r)+"'")},Z.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(a.parenL);case 41:return++this.pos,this.finishToken(a.parenR);case 59:return++this.pos,this.finishToken(a.semi);case 44:return++this.pos,this.finishToken(a.comma);case 91:return++this.pos,this.finishToken(a.bracketL);case 93:return++this.pos,this.finishToken(a.bracketR);case 123:return++this.pos,this.finishToken(a.braceL);case 125:return++this.pos,this.finishToken(a.braceR);case 58:return++this.pos,this.finishToken(a.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(a.backQuote);case 48:var r=this.input.charCodeAt(this.pos+1);if(r===120||r===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(r===111||r===79)return this.readRadixNumber(8);if(r===98||r===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(a.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+xe(e)+"'")},Z.finishOp=function(e,r){var n=this.input.slice(this.pos,this.pos+r);return this.pos+=r,this.finishToken(e,n)},Z.readRegexp=function(){for(var e,r,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,"Unterminated regular expression");var o=this.input.charAt(this.pos);if(A.test(o)&&this.raise(n,"Unterminated regular expression"),e)e=!1;else{if(o==="[")r=!0;else if(o==="]"&&r)r=!1;else if(o==="/"&&!r)break;e=o==="\\"}++this.pos}var h=this.input.slice(n,this.pos);++this.pos;var v=this.pos,w=this.readWord1();this.containsEsc&&this.unexpected(v);var R=this.regexpState||(this.regexpState=new Te(this));R.reset(n,h,w),this.validateRegExpFlags(R),this.validateRegExpPattern(R);var F=null;try{F=new RegExp(h,w)}catch{}return this.finishToken(a.regexp,{pattern:h,flags:w,value:F})},Z.readInt=function(e,r,n){for(var o=this.options.ecmaVersion>=12&&r===void 0,h=n&&this.input.charCodeAt(this.pos)===48,v=this.pos,w=0,R=0,F=0,G=r??1/0;F<G;++F,++this.pos){var Q=this.input.charCodeAt(this.pos),ie=void 0;if(o&&Q===95){h&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),R===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),F===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),R=Q;continue}if(Q>=97?ie=Q-97+10:Q>=65?ie=Q-65+10:Q>=48&&Q<=57?ie=Q-48:ie=1/0,ie>=e)break;R=Q,w=w*e+ie}return o&&R===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===v||r!=null&&this.pos-v!==r?null:w};function ls(e,r){return r?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function Ui(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}Z.readRadixNumber=function(e){var r=this.pos;this.pos+=2;var n=this.readInt(e);return n==null&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=Ui(this.input.slice(r,this.pos)),++this.pos):N(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(a.num,n)},Z.readNumber=function(e){var r=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(r,"Invalid number");var n=this.pos-r>=2&&this.input.charCodeAt(r)===48;n&&this.strict&&this.raise(r,"Invalid number");var o=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&o===110){var h=Ui(this.input.slice(r,this.pos));return++this.pos,N(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(a.num,h)}n&&/[89]/.test(this.input.slice(r,this.pos))&&(n=!1),o===46&&!n&&(++this.pos,this.readInt(10),o=this.input.charCodeAt(this.pos)),(o===69||o===101)&&!n&&(o=this.input.charCodeAt(++this.pos),(o===43||o===45)&&++this.pos,this.readInt(10)===null&&this.raise(r,"Invalid number")),N(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var v=ls(this.input.slice(r,this.pos),n);return this.finishToken(a.num,v)},Z.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),r;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;r=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,r>1114111&&this.invalidStringToken(n,"Code point out of bounds")}else r=this.readHexChar(4);return r},Z.readString=function(e){for(var r="",n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var o=this.input.charCodeAt(this.pos);if(o===e)break;o===92?(r+=this.input.slice(n,this.pos),r+=this.readEscapedChar(!1),n=this.pos):o===8232||o===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(I(o)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return r+=this.input.slice(n,this.pos++),this.finishToken(a.string,r)};var ji={};Z.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===ji)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1},Z.invalidStringToken=function(e,r){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw ji;this.raise(e,r)},Z.readTmplToken=function(){for(var e="",r=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===a.template||this.type===a.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(a.dollarBraceL)):(++this.pos,this.finishToken(a.backQuote)):(e+=this.input.slice(r,this.pos),this.finishToken(a.template,e));if(n===92)e+=this.input.slice(r,this.pos),e+=this.readEscapedChar(!0),r=this.pos;else if(I(n)){switch(e+=this.input.slice(r,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
|
|
6
|
+
`;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),r=this.pos}else++this.pos}},Z.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(a.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
|
|
7
|
+
`&&++this.pos;case`
|
|
8
|
+
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")},Z.readEscapedChar=function(e){var r=this.input.charCodeAt(++this.pos);switch(++this.pos,r){case 110:return`
|
|
9
|
+
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return xe(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(r>=48&&r<=55){var o=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],h=parseInt(o,8);return h>255&&(o=o.slice(0,-1),h=parseInt(o,8)),this.pos+=o.length-1,r=this.input.charCodeAt(this.pos),(o!=="0"||r===56||r===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-o.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(h)}return I(r)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(r)}},Z.readHexChar=function(e){var r=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(r,"Bad character escape sequence"),n},Z.readWord1=function(){this.containsEsc=!1;for(var e="",r=!0,n=this.pos,o=this.options.ecmaVersion>=6;this.pos<this.input.length;){var h=this.fullCharCodeAtPos();if(O(h,o))this.pos+=h<=65535?1:2;else if(h===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var v=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var w=this.readCodePoint();(r?N:O)(w,o)||this.invalidStringToken(v,"Invalid Unicode escape"),e+=xe(w),n=this.pos}else break;r=!1}return e+this.input.slice(n,this.pos)},Z.readWord=function(){var e=this.readWord1(),r=a.name;return this.keywords.test(e)&&(r=g[e]),this.finishToken(r,e)};var qi="8.15.0";se.acorn={Parser:se,version:qi,defaultOptions:ve,Position:Pe,SourceLocation:qe,getLineInfo:Re,Node:wt,TokenType:W,tokTypes:a,keywordTypes:g,TokContext:we,tokContexts:re,isIdentifierChar:O,isIdentifierStart:N,Token:Gt,isNewLine:I,lineBreak:A,lineBreakG:V,nonASCIIwhitespace:K};function ps(e,r){return se.parse(e,r)}function hs(e,r,n){return se.parseExpressionAt(e,r,n)}function fs(e,r){return se.tokenizer(e,r)}c.Node=wt,c.Parser=se,c.Position=Pe,c.SourceLocation=qe,c.TokContext=we,c.Token=Gt,c.TokenType=W,c.defaultOptions=ve,c.getLineInfo=Re,c.isIdentifierChar=O,c.isIdentifierStart=N,c.isNewLine=I,c.keywordTypes=g,c.lineBreak=A,c.lineBreakG=V,c.nonASCIIwhitespace=K,c.parse=ps,c.parseExpressionAt=hs,c.tokContexts=re,c.tokTypes=a,c.tokenizer=fs,c.version=qi})});var cn=de((sr,un)=>{"use strict";(function(c,t){typeof sr=="object"&&typeof un<"u"?t(sr):typeof define=="function"&&define.amd?define(["exports"],t):(c=typeof globalThis<"u"?globalThis:c||self,t((c.acorn=c.acorn||{},c.acorn.walk={})))})(sr,function(c){"use strict";function t(m,d,g,_,a){g||(g=y),function A(V,I,J){var K=J||V.type;g[K](V,I,A),d[K]&&d[K](V,I)}(m,_,a)}function i(m,d,g,_,a){var A=[];g||(g=y),function V(I,J,K){var X=K||I.type,fe=I!==A[A.length-1];fe&&A.push(I),g[X](I,J,V),d[X]&&d[X](I,J||A,A),fe&&A.pop()}(m,_,a)}function s(m,d,g,_,a){var A=g?N(g,_||void 0):_;(function V(I,J,K){A[K||I.type](I,J,V)})(m,d,a)}function u(m){return typeof m=="string"?function(d){return d===m}:m||function(){return!0}}var l=function(d,g){this.node=d,this.state=g};function p(m,d,g,_,a){g||(g=y);var A;(function V(I,J,K){var X=K||I.type;g[X](I,J,V),A!==I&&(d(I,J,X),A=I)})(m,_,a)}function f(m,d,g,_){g||(g=y);var a=[],A;(function V(I,J,K){var X=K||I.type,fe=I!==a[a.length-1];fe&&a.push(I),g[X](I,J,V),A!==I&&(d(I,J||a,a,X),A=I),fe&&a.pop()})(m,_)}function b(m,d,g,_,a,A){a||(a=y),_=u(_);try{(function V(I,J,K){var X=K||I.type;if((d==null||I.start<=d)&&(g==null||I.end>=g)&&a[X](I,J,V),(d==null||I.start===d)&&(g==null||I.end===g)&&_(X,I))throw new l(I,J)})(m,A)}catch(V){if(V instanceof l)return V;throw V}}function x(m,d,g,_,a){g=u(g),_||(_=y);try{(function A(V,I,J){var K=J||V.type;if(!(V.start>d||V.end<d)&&(_[K](V,I,A),g(K,V)))throw new l(V,I)})(m,a)}catch(A){if(A instanceof l)return A;throw A}}function S(m,d,g,_,a){g=u(g),_||(_=y);try{(function A(V,I,J){if(!(V.end<d)){var K=J||V.type;if(V.start>=d&&g(K,V))throw new l(V,I);_[K](V,I,A)}})(m,a)}catch(A){if(A instanceof l)return A;throw A}}function T(m,d,g,_,a){g=u(g),_||(_=y);var A;return function V(I,J,K){if(!(I.start>d)){var X=K||I.type;I.end<=d&&(!A||A.node.end<I.end)&&g(X,I)&&(A=new l(I,J)),_[X](I,J,V)}}(m,a),A}function N(m,d){var g=Object.create(d||y);for(var _ in m)g[_]=m[_];return g}function O(m,d,g){g(m,d)}function W(m,d,g){}var y={};y.Program=y.BlockStatement=y.StaticBlock=function(m,d,g){for(var _=0,a=m.body;_<a.length;_+=1){var A=a[_];g(A,d,"Statement")}},y.Statement=O,y.EmptyStatement=W,y.ExpressionStatement=y.ParenthesizedExpression=y.ChainExpression=function(m,d,g){return g(m.expression,d,"Expression")},y.IfStatement=function(m,d,g){g(m.test,d,"Expression"),g(m.consequent,d,"Statement"),m.alternate&&g(m.alternate,d,"Statement")},y.LabeledStatement=function(m,d,g){return g(m.body,d,"Statement")},y.BreakStatement=y.ContinueStatement=W,y.WithStatement=function(m,d,g){g(m.object,d,"Expression"),g(m.body,d,"Statement")},y.SwitchStatement=function(m,d,g){g(m.discriminant,d,"Expression");for(var _=0,a=m.cases;_<a.length;_+=1){var A=a[_];g(A,d)}},y.SwitchCase=function(m,d,g){m.test&&g(m.test,d,"Expression");for(var _=0,a=m.consequent;_<a.length;_+=1){var A=a[_];g(A,d,"Statement")}},y.ReturnStatement=y.YieldExpression=y.AwaitExpression=function(m,d,g){m.argument&&g(m.argument,d,"Expression")},y.ThrowStatement=y.SpreadElement=function(m,d,g){return g(m.argument,d,"Expression")},y.TryStatement=function(m,d,g){g(m.block,d,"Statement"),m.handler&&g(m.handler,d),m.finalizer&&g(m.finalizer,d,"Statement")},y.CatchClause=function(m,d,g){m.param&&g(m.param,d,"Pattern"),g(m.body,d,"Statement")},y.WhileStatement=y.DoWhileStatement=function(m,d,g){g(m.test,d,"Expression"),g(m.body,d,"Statement")},y.ForStatement=function(m,d,g){m.init&&g(m.init,d,"ForInit"),m.test&&g(m.test,d,"Expression"),m.update&&g(m.update,d,"Expression"),g(m.body,d,"Statement")},y.ForInStatement=y.ForOfStatement=function(m,d,g){g(m.left,d,"ForInit"),g(m.right,d,"Expression"),g(m.body,d,"Statement")},y.ForInit=function(m,d,g){m.type==="VariableDeclaration"?g(m,d):g(m,d,"Expression")},y.DebuggerStatement=W,y.FunctionDeclaration=function(m,d,g){return g(m,d,"Function")},y.VariableDeclaration=function(m,d,g){for(var _=0,a=m.declarations;_<a.length;_+=1){var A=a[_];g(A,d)}},y.VariableDeclarator=function(m,d,g){g(m.id,d,"Pattern"),m.init&&g(m.init,d,"Expression")},y.Function=function(m,d,g){m.id&&g(m.id,d,"Pattern");for(var _=0,a=m.params;_<a.length;_+=1){var A=a[_];g(A,d,"Pattern")}g(m.body,d,m.expression?"Expression":"Statement")},y.Pattern=function(m,d,g){m.type==="Identifier"?g(m,d,"VariablePattern"):m.type==="MemberExpression"?g(m,d,"MemberPattern"):g(m,d)},y.VariablePattern=W,y.MemberPattern=O,y.RestElement=function(m,d,g){return g(m.argument,d,"Pattern")},y.ArrayPattern=function(m,d,g){for(var _=0,a=m.elements;_<a.length;_+=1){var A=a[_];A&&g(A,d,"Pattern")}},y.ObjectPattern=function(m,d,g){for(var _=0,a=m.properties;_<a.length;_+=1){var A=a[_];A.type==="Property"?(A.computed&&g(A.key,d,"Expression"),g(A.value,d,"Pattern")):A.type==="RestElement"&&g(A.argument,d,"Pattern")}},y.Expression=O,y.ThisExpression=y.Super=y.MetaProperty=W,y.ArrayExpression=function(m,d,g){for(var _=0,a=m.elements;_<a.length;_+=1){var A=a[_];A&&g(A,d,"Expression")}},y.ObjectExpression=function(m,d,g){for(var _=0,a=m.properties;_<a.length;_+=1){var A=a[_];g(A,d)}},y.FunctionExpression=y.ArrowFunctionExpression=y.FunctionDeclaration,y.SequenceExpression=function(m,d,g){for(var _=0,a=m.expressions;_<a.length;_+=1){var A=a[_];g(A,d,"Expression")}},y.TemplateLiteral=function(m,d,g){for(var _=0,a=m.quasis;_<a.length;_+=1){var A=a[_];g(A,d)}for(var V=0,I=m.expressions;V<I.length;V+=1){var J=I[V];g(J,d,"Expression")}},y.TemplateElement=W,y.UnaryExpression=y.UpdateExpression=function(m,d,g){g(m.argument,d,"Expression")},y.BinaryExpression=y.LogicalExpression=function(m,d,g){g(m.left,d,"Expression"),g(m.right,d,"Expression")},y.AssignmentExpression=y.AssignmentPattern=function(m,d,g){g(m.left,d,"Pattern"),g(m.right,d,"Expression")},y.ConditionalExpression=function(m,d,g){g(m.test,d,"Expression"),g(m.consequent,d,"Expression"),g(m.alternate,d,"Expression")},y.NewExpression=y.CallExpression=function(m,d,g){if(g(m.callee,d,"Expression"),m.arguments)for(var _=0,a=m.arguments;_<a.length;_+=1){var A=a[_];g(A,d,"Expression")}},y.MemberExpression=function(m,d,g){g(m.object,d,"Expression"),m.computed&&g(m.property,d,"Expression")},y.ExportNamedDeclaration=y.ExportDefaultDeclaration=function(m,d,g){m.declaration&&g(m.declaration,d,m.type==="ExportNamedDeclaration"||m.declaration.id?"Statement":"Expression"),m.source&&g(m.source,d,"Expression")},y.ExportAllDeclaration=function(m,d,g){m.exported&&g(m.exported,d),g(m.source,d,"Expression")},y.ImportDeclaration=function(m,d,g){for(var _=0,a=m.specifiers;_<a.length;_+=1){var A=a[_];g(A,d)}g(m.source,d,"Expression")},y.ImportExpression=function(m,d,g){g(m.source,d,"Expression")},y.ImportSpecifier=y.ImportDefaultSpecifier=y.ImportNamespaceSpecifier=y.Identifier=y.PrivateIdentifier=y.Literal=W,y.TaggedTemplateExpression=function(m,d,g){g(m.tag,d,"Expression"),g(m.quasi,d,"Expression")},y.ClassDeclaration=y.ClassExpression=function(m,d,g){return g(m,d,"Class")},y.Class=function(m,d,g){m.id&&g(m.id,d,"Pattern"),m.superClass&&g(m.superClass,d,"Expression"),g(m.body,d)},y.ClassBody=function(m,d,g){for(var _=0,a=m.body;_<a.length;_+=1){var A=a[_];g(A,d)}},y.MethodDefinition=y.PropertyDefinition=y.Property=function(m,d,g){m.computed&&g(m.key,d,"Expression"),m.value&&g(m.value,d,"Expression")},c.ancestor=i,c.base=y,c.findNodeAfter=S,c.findNodeAround=x,c.findNodeAt=b,c.findNodeBefore=T,c.full=p,c.fullAncestor=f,c.make=N,c.recursive=s,c.simple=t})});var ar=de(Wr=>{"use strict";var{Parser:da,isNewLine:ma,getLineInfo:ga}=on(),{full:ya}=cn(),ht="VM2_INTERNAL_STATE_DO_NOT_USE_OR_PROGRAM_WILL_FAIL";function Or(c,t){if(!c)throw new Error(`None existent node expected '${t}'`);if(c.type!==t)throw new Error(`Invalid node type '${c.type}' expected '${t}'`);return c}function ln(c,t,i,s,u){let l=ga(t,s),p=s;for(;p<t.length&&!ma(t.charCodeAt(p));)p++;let f=u.start===s?u.end:s+1;(!f||f>p)&&(f=p);let b=f-s;if(b<=0&&(b=1),c==="Unexpected token"){let N=u.type;N.label==="name"||N.label==="privateId"?c="Unexpected identifier":N.label==="eof"?c="Unexpected end of input":N.label==="num"?c="Unexpected number":N.label==="string"?c="Unexpected string":N.label==="regexp"?(c="Unexpected token '/'",b=1):c=`Unexpected token '${u.value||N.label}'`}let x=new SyntaxError(c);if(!i)return x;let S=t.slice(s-l.column,p),T=S.slice(0,l.column).replace(/\S/g," ")+"^".repeat(b);return x.stack=`${i}:${l.line}
|
|
10
|
+
${S}
|
|
11
|
+
${T}
|
|
12
|
+
|
|
13
|
+
${x.stack}`,x}function xa(c,t,i,s,u){let l,p;if(c===null){if(l=t,!/\b(?:catch|import|async)\b/.test(l))return{__proto__:null,code:l,hasAsync:!1}}else l=i?"(async function":"(function",s&&(l+="*"),l+=" anonymous(",l+=c,p=l.length,l+=`
|
|
14
|
+
) {
|
|
15
|
+
`,l+=t,l+=`
|
|
16
|
+
})`;let f=new da({__proto__:null,ecmaVersion:2022,allowAwaitOutsideFunction:c===null&&i,allowReturnOutsideFunction:c===null},l),b;try{b=f.parse()}catch(d){if(d instanceof SyntaxError&&d.pos!==void 0){let g=d.message,_=g.match(/^(.*) \(\d+:\d+\)$/);_&&(g=_[1]),d=ln(g,l,u,d.pos,f)}throw d}if(c!==null){let d=Or(b,"Program").body;if(d.length!==1)throw new SyntaxError("Single function literal required");let g=d[0];if(g.type!=="ExpressionStatement")throw new SyntaxError("Single function literal required");let _=g.expression;if(_.type!=="FunctionExpression")throw new SyntaxError("Single function literal required");if(_.body.start!==p+3)throw new SyntaxError("Unexpected end of arg string")}let x=[],S=!1,T=-100,N=100,O,W="VM2_INTERNAL_TMPNAME";if(ya(b,(d,g,_)=>{_==="Function"&&d.async&&(S=!0);let a=d.type;if(a==="CatchClause"){let A=d.param;if(A)if(A.type==="Identifier"){let V=Or(A,"Identifier").name,I=Or(d.body,"BlockStatement");I.body.length>0&&x.push({__proto__:null,pos:I.body[0].start,order:T,coder:()=>`${V}=${ht}.handleException(${V});`})}else x.push({__proto__:null,pos:d.start,order:N,coder:()=>`catch(${W}){${W}=${ht}.handleException(${W});try{throw ${W};}`}),x.push({__proto__:null,pos:d.body.end,order:T,coder:()=>"}"})}else a==="WithStatement"?(x.push({__proto__:null,pos:d.object.start,order:T,coder:()=>ht+".wrapWith("}),x.push({__proto__:null,pos:d.object.end,order:N,coder:()=>")"})):a==="Identifier"?d.name===ht?(O===void 0||O.start>d.start)&&(O=d):d.name.startsWith(W)&&(W=d.name+"_UNIQUE"):a==="ImportExpression"&&x.push({__proto__:null,pos:d.start,order:N,coder:()=>ht+"."})}),O)throw ln("Use of internal vm2 state variable",l,u,O.start,{__proto__:null,start:O.start,end:O.end});if(x.length===0)return{__proto__:null,code:l,hasAsync:S};x.sort((d,g)=>d.pos==g.pos?d.order-g.order:d.pos-g.pos);let y="",m=0;for(let d=0;d<x.length;d++){let g=x[d];y+=l.substring(m,g.pos)+g.coder(),m=g.pos}return y+=l.substring(m),{__proto__:null,code:y,hasAsync:S}}Wr.INTERNAL_STATE_NAME=ht;Wr.transformer=xa});var ft=de(Vt=>{"use strict";var{Script:va}=require("vm"),{lookupCompiler:ba,removeShebang:wa}=Nt(),{transformer:_a}=ar(),Ca=Object.defineProperties,Lr="(function (exports, require, module, __filename, __dirname) { ",pn=Lr+'"use strict"; ',Br=`
|
|
17
|
+
});`,Fr=class{constructor(t,i){let s=`${t}`,u,l;arguments.length===2?typeof i=="object"?(l=i||{__proto__:null},u=l.filename):(l={__proto__:null},u=i):arguments.length>2?(l=arguments[2]||{__proto__:null},u=i||l.filename):l={__proto__:null};let{compiler:p="javascript",lineOffset:f=0,columnOffset:b=0}=l,x=ba(p);Ca(this,{__proto__:null,code:{__proto__:null,get(){return this._prefix+this._code+this._suffix},set(S){let T=String(S);T===this._code&&this._prefix===""&&this._suffix===""||(this._code=T,this._prefix="",this._suffix="",this._compiledVM=null,this._compiledNodeVM=null,this._compiledCode=null)},enumerable:!0},filename:{__proto__:null,value:u||"vm.js",enumerable:!0},lineOffset:{__proto__:null,value:f,enumerable:!0},columnOffset:{__proto__:null,value:b,enumerable:!0},compiler:{__proto__:null,value:p,enumerable:!0},_code:{__proto__:null,value:s,writable:!0},_prefix:{__proto__:null,value:"",writable:!0},_suffix:{__proto__:null,value:"",writable:!0},_compiledVM:{__proto__:null,value:null,writable:!0},_compiledNodeVM:{__proto__:null,value:null,writable:!0},_compiledNodeVMStrict:{__proto__:null,value:null,writable:!0},_compiledCode:{__proto__:null,value:null,writable:!0},_hasAsync:{__proto__:null,value:!1,writable:!0},_compiler:{__proto__:null,value:x}})}wrap(t,i){let s=`${t}`,u=`${i}`;return this._prefix===s&&this._suffix===u?this:(this._prefix=s,this._suffix=u,this._compiledVM=null,this._compiledNodeVM=null,this._compiledNodeVMStrict=null,this)}compile(){return this._compileVM(),this}getCompiledCode(){if(!this._compiledCode){let t=this._compiler(this._prefix+wa(this._code)+this._suffix,this.filename),i=_a(null,t,!1,!1,this.filename);this._compiledCode=i.code,this._hasAsync=i.hasAsync}return this._compiledCode}_compile(t,i){return new va(t+this.getCompiledCode()+i,{__proto__:null,filename:this.filename,displayErrors:!1,lineOffset:this.lineOffset,columnOffset:this.columnOffset})}_compileVM(){let t=this._compiledVM;return t||(this._compiledVM=t=this._compile("","")),t}_compileNodeVM(){let t=this._compiledNodeVM;return t||(this._compiledNodeVM=t=this._compile(Lr,Br)),t}_compileNodeVMStrict(){let t=this._compiledNodeVMStrict;return t||(this._compiledNodeVMStrict=t=this._compile(pn,Br)),t}};Vt.MODULE_PREFIX=Lr;Vt.STRICT_MODULE_PREFIX=pn;Vt.MODULE_SUFFIX=Br;Vt.VMScript=Fr});var ur=de(mn=>{"use strict";var Wt=require("fs"),Sa=require("path"),{Script:$r,createContext:fn}=require("vm"),{EventEmitter:Ea}=require("events"),{INSPECT_MAX_BYTES:Aa}=require("buffer"),{createBridge:Ia,VMError:or}=Ye(),{transformer:dn,INTERNAL_STATE_NAME:Ta}=ar(),{lookupCompiler:ka}=Nt(),{VMScript:Pa}=ft(),{inspect:Ra}=require("util"),Na=Object.defineProperties,Va=Object.freeze({Buffer,Function,Object,transformAndCheck:Oa,INSPECT_MAX_BYTES:Aa,INTERNAL_STATE_NAME:Ta});function dt(c,t){return new $r(t,{__proto__:null,filename:c,displayErrors:!1})}var Ze=Object.freeze({__proto__:null,displayErrors:!1});function Mr(c){if(!c)throw new or("Async not available")}function Oa(c,t,i,s,u){let l=dn(c,t,i,s,void 0);return Mr(u||!l.hasAsync),l.code}var Ot=null,hn=null;function Wa(c,t){Ot||(Ot=fn(),hn=new $r("fn()",{__proto__:null,filename:"timeout_bridge.js",displayErrors:!1})),Ot.fn=c;try{return hn.runInContext(Ot,{__proto__:null,displayErrors:!1,timeout:t})}finally{Ot.fn=null}}var Ba=dt(`${__dirname}/bridge.js`,`(function(global) {"use strict"; const exports = {};${Wt.readFileSync(`${__dirname}/bridge.js`,"utf8")}
|
|
18
|
+
return exports;})`),Fa=dt(`${__dirname}/setup-sandbox.js`,`(function(global, host, bridge, data, context) { ${Wt.readFileSync(`${__dirname}/setup-sandbox.js`,"utf8")}
|
|
19
|
+
})`),La=dt("get_global.js","this"),Dr=null,Ur=null,jr=null;try{Dr=dt("get_generator_function.js","(function*(){}).constructor")}catch{}try{Ur=dt("get_async_function.js","(async function(){}).constructor")}catch{}try{jr=dt("get_async_generator_function.js","(async function*(){}).constructor")}catch{}var qr=class extends Ea{constructor(t={}){super();let{timeout:i,sandbox:s,compiler:u="javascript",allowAsync:l=!0}=t,p=t.eval!==!1,f=t.wasm!==!1,b=l&&!t.fixAsync;if(s&&typeof s!="object")throw new or("Sandbox must be object.");let x=ka(u),S=fn(void 0,{__proto__:null,codeGeneration:{__proto__:null,strings:p,wasm:f}}),T=La.runInContext(S,Ze),{createBridge:N}=Ba.runInContext(S,Ze)(T),O=Ia(N,()=>{}),W={__proto__:null,allowAsync:b};Dr&&(W.GeneratorFunction=Dr.runInContext(S,Ze)),Ur&&(W.AsyncFunction=Ur.runInContext(S,Ze)),jr&&(W.AsyncGeneratorFunction=jr.runInContext(S,Ze));let y=Fa.runInContext(S,Ze)(T,Va,O.other,W,S),m=A=>{let V;try{V=A.runInContext(S,Ze)}catch(I){throw O.from(I)}return O.from(V)},d=(A,V)=>{try{y.readonly(A,V)}catch(I){throw O.from(I)}return A},g=A=>{let V=O.other;try{V.fromWithFactory(V.protectedFactory,A)}catch(I){throw O.from(I)}return A},_=(A,V)=>{let I=O.other,J;try{J=I.from(V),I.addProtoMapping(J,A)}catch(K){throw O.from(K)}O.addProtoMapping(A,J)},a=(A,V)=>{let I=O.other,J=()=>{let K=V(this);return O.addProtoMapping(A,K),K};try{let K=I.from(J);I.addProtoMappingFactory(K,A)}catch(K){throw O.from(K)}};Na(this,{__proto__:null,timeout:{__proto__:null,value:i,writable:!0,enumerable:!0},compiler:{__proto__:null,value:u,enumerable:!0},sandbox:{__proto__:null,value:O.from(T),enumerable:!0},_runScript:{__proto__:null,value:m},_makeReadonly:{__proto__:null,value:d},_makeProtected:{__proto__:null,value:g},_addProtoMapping:{__proto__:null,value:_},_addProtoMappingFactory:{__proto__:null,value:a},_compiler:{__proto__:null,value:x},_allowAsync:{__proto__:null,value:b}}),this.readonly(Ra),s&&this.setGlobals(s)}setGlobals(t){for(let i in t)Object.prototype.hasOwnProperty.call(t,i)&&(this.sandbox[i]=t[i]);return this}setGlobal(t,i){return this.sandbox[t]=i,this}getGlobal(t){return this.sandbox[t]}freeze(t,i){return this.readonly(t),i&&(this.sandbox[i]=t),t}readonly(t,i){return this._makeReadonly(t,i)}protect(t,i){return this._makeProtected(t),i&&(this.sandbox[i]=t),t}run(t,i){let s,u;if(typeof i=="object"?u=i.filename:u=i,t instanceof Pa)s=t._compileVM(),Mr(this._allowAsync||!t._hasAsync);else{let l=u||"vm.js",p=this._compiler(t,l),f=dn(null,p,!1,!1,l);p=f.code,Mr(this._allowAsync||!f.hasAsync),s=new $r(p,{__proto__:null,filename:l,displayErrors:!1})}return this.timeout?Wa(()=>this._runScript(s),this.timeout):this._runScript(s)}runFile(t){let i=Sa.resolve(t);if(!Wt.existsSync(i))throw new or(`Script '${t}' not found.`);if(Wt.statSync(i).isDirectory())throw new or("Script must be file, got directory.");return this.run(Wt.readFileSync(i,"utf8"),i)}};mn.VM=qr});var lr=de(zr=>{"use strict";var{VMError:te}=Ye(),{VMScript:Ma}=ft(),{jsCopmiler:Da}=Nt(),Ua=/^((?:@[^/\\%]+\/)?[^/\\%]+)(\/.*)?$/;function ja(c){let t=+c;return`${t}`!==c?!1:t>=0&&t<4294967295}var cr=class{constructor(t,i,s){this.fs=t,this.globalPaths=i,this.builtins=s}init(t){}isPathAllowed(t){return!1}checkAccess(t,i){if(!this.isPathAllowed(i))throw new te(`Module '${i}' is not allowed to be required. The path is outside the border!`,"EDENIED")}pathIsRelative(t){if(t===""||t[0]!==".")return!1;if(t.length===1)return!0;let i=t[1]==="."?2:1;return t.length<=i?!1:this.fs.isSeparator(t[i])}pathIsAbsolute(t){return t!==""&&(this.fs.isSeparator(t[0])||this.fs.isAbsolute(t))}lookupPaths(t,i){return this.pathIsRelative(i)?[t.path||"."]:[...t.paths,...this.globalPaths]}getBuiltinModulesList(t){if(this.builtins===void 0)return[];let i=[];return this.builtins.forEach((s,u)=>{typeof s=="object"&&s.init(t),i.push(u)}),i}loadBuiltinModule(t,i){if(this.builtins===void 0)return;let s=this.builtins.get(i);if(s)return typeof s=="function"?s(t):s.load(t)}makeExtensionHandler(t,i){return(s,u)=>{u=this.fs.resolve(u),this.checkAccess(s,u),this[i](t,s,u)}}getExtensions(t){return{__proto__:null,".js":this.makeExtensionHandler(t,"loadJS"),".json":this.makeExtensionHandler(t,"loadJSON")," .node":this.makeExtensionHandler(t,"loadNode")}}loadJS(t,i,s){throw new te(`Access denied to require '${s}'`,"EDENIED")}loadJSON(t,i,s){throw new te(`Access denied to require '${s}'`,"EDENIED")}loadNode(t,i,s){throw new te(`Access denied to require '${s}'`,"EDENIED")}registerModule(t,i,s,u,l){}resolve(t,i,s,u,l){return i.startsWith("node:")||this.builtins.has(i)?i:this.resolveFull(t,i,s,u,l)}resolveFull(t,i,s,u,l){throw new te(`Cannot find module '${i}'`,"ENOTFOUND")}genLookupPaths(t){let i=[];for(;;){this.fs.basename(t)!=="node_modules"&&i.push(this.fs.join(t,"node_modules"));let u=this.fs.dirname(t);if(u==t)break;t=u}return i}};function qa(c,t){try{let i=c.statSync(t,{__proto__:null,throwIfNoEntry:!1});return i&&i.isDirectory()}catch{return!1}}function gn(c,t){try{let i=c.statSync(t,{__proto__:null,throwIfNoEntry:!1});return i&&i.isFile()}catch{return!1}}function Gr(c,t){return c.readFileSync(t,{encoding:"utf8"})}function $a(c,t){return gn(c,t)?Gr(c,t):void 0}var Hr=class extends cr{constructor(t,i,s){super(t,i,s),this.packageCache=new Map,this.scriptCache=new Map}getCompiler(t){return Da}isStrict(t){return!0}readScript(t){let i=this.scriptCache.get(t);return i||(i=new Ma(Gr(this.fs,t),{filename:t,compiler:this.getCompiler(t)}),this.scriptCache.set(t,i)),i}loadJS(t,i,s){let u=this.readScript(s);t.run(u,{filename:s,strict:this.isStrict(s),module:i,wrapper:"none",dirname:i.path})}loadJSON(t,i,s){let u=Gr(this.fs,s);i.exports=t._jsonParse(u)}loadNode(t,i,s){throw new te("Native modules can be required only with context set to 'host'.")}customResolve(t,i,s){}resolveFull(t,i,s,u,l){let p=t.path||".",f=this.loadPackageSelf(i,p,u);if(f||i[0]==="#"&&(f=this.loadPackageImports(i,p,u),f))return f;if(this.pathIsAbsolute(i)){if(f=this.loadAsFileOrDirectory(i,u),f)return f;throw new te(`Cannot find module '${i}'`,"ENOTFOUND")}else if(this.pathIsRelative(i)){if(typeof s=="object"&&s!==null){let x=s.paths;if(Array.isArray(x)){for(let S=0;S<x.length;S++)if(f=this.loadAsFileOrDirectory(this.fs.join(x[S],i),u),f)return f}else if(x===void 0){if(f=this.loadAsFileOrDirectory(this.fs.join(p,i),u),f)return f}else throw new te("Invalid options.paths option.")}else if(f=this.loadAsFileOrDirectory(this.fs.join(p,i),u),f)return f;throw new te(`Cannot find module '${i}'`,"ENOTFOUND")}let b;if(typeof s=="object"&&s!==null){let x=s.paths;if(Array.isArray(x)){b=[];for(let S=0;S<x.length;S++){let T=this.genLookupPaths(x[S]);for(let N=0;N<T.length;N++)b.includes(T[N])||b.push(T[N]);if(S===0){let N=this.globalPaths;for(let O=0;O<N.length;O++)b.includes(N[O])||b.push(N[O])}}}else if(x===void 0)b=[...t.paths,...this.globalPaths];else throw new te("Invalid options.paths option.")}else b=[...t.paths,...this.globalPaths];return f=this.loadNodeModules(i,b,u),f||(f=this.customResolve(i,p,u),f)?f:super.resolveFull(t,i,s,u,l)}loadAsFileOrDirectory(t,i){let s=this.loadAsFile(t,i);return s||this.loadAsDirectory(t,i)}tryFile(t){return t=this.fs.resolve(t),this.isPathAllowed(t)&&gn(this.fs,t)?t:void 0}tryWithExtension(t,i){for(let s=0;s<i.length;s++){let u=i[s];if(u!==this.fs.basename(u))continue;let l=this.tryFile(t+u);if(l)return l}}readPackage(t){let i=this.fs.resolve(this.fs.join(t,"package.json")),s=this.packageCache.get(i);if(s!==void 0)return s;if(!this.isPathAllowed(i))return;let u=$a(this.fs,i);if(!u)return this.packageCache.set(i,!1),!1;let l;try{l=JSON.parse(u)}catch(f){throw f.path=i,f.message="Error parsing "+i+": "+f.message,f}let p={name:l.name,main:l.main,exports:l.exports,imports:l.imports,type:l.type};return this.packageCache.set(i,p),p}readPackageScope(t){for(;;){let i=this.fs.dirname(t);if(i===t||this.fs.basename(i)==="node_modules")break;let u=this.readPackage(i);if(u)return{data:u,scope:i};t=i}return{data:void 0,scope:void 0}}loadAsFile(t,i){let s=this.tryFile(t);return s||this.tryWithExtension(t,i)}loadIndex(t,i){return this.tryWithExtension(this.fs.join(t,"index"),i)}loadAsPackage(t,i,s){if(i&&typeof i.main=="string"){let u=this.fs.join(t,i.main),l=this.loadAsFile(u,s);if(l||(l=this.loadIndex(u,s),l)||(l=this.loadIndex(t,s),l))return l;throw new te(`Cannot find module '${t}'`,"ENOTFOUND")}return this.loadIndex(t,s)}loadAsDirectory(t,i){let s=this.readPackage(t);return this.loadAsPackage(t,s,i)}loadNodeModules(t,i,s){for(let u=0;u<i.length;u++){let l=i[u],p=this.loadPackageExports(t,l,s);if(p||(p=this.loadAsFile(l+"/"+t,s),p)||(p=this.loadAsDirectory(l+"/"+t,s),p))return p}}loadPackageImports(t,i,s){let{data:u,scope:l}=this.readPackageScope(i);if(!u||typeof u.imports!="object"||u.imports===null||Array.isArray(u.imports))return;if(t==="#"||t.startsWith("#/"))throw new te(`Invalid module specifier '${t}'`,"ERR_INVALID_MODULE_SPECIFIER");let p=this.packageImportsExportsResolve(t,u.imports,l,!0,["node","require"],s);if(!p)throw new te(`Package import not defined for '${t}'`,"ERR_PACKAGE_IMPORT_NOT_DEFINED");return this.resolveEsmMatch(p,t,s)}loadPackageExports(t,i,s){let u=t.match(Ua);if(!u)return;let l=this.fs.join(i,u[1]),p=this.readPackage(l);if(!p||!p.exports)return;let f=this.packageExportsResolve(l,"."+(u[2]||""),p.exports,["node","require"],s);return this.resolveEsmMatch(f,t,s)}loadPackageSelf(t,i,s){let{data:u,scope:l}=this.readPackageScope(i);if(!u||!u.exports||t!==u.name&&!t.startsWith(u.name+"/"))return;let p=this.packageExportsResolve(l,"."+t.slice(u.name.length),u.exports,["node","require"],s);return this.resolveEsmMatch(p,t,s)}resolveEsmMatch(t,i,s){let u=t,l=!0,p=u,f;if(l?f=this.tryFile(p):f=this.loadAsFileOrDirectory(p,s),f)return f;throw new te(`Cannot find module '${i}'`,"ENOTFOUND")}packageExportsResolve(t,i,s,u,l){let p=!1;if(typeof s=="object"&&!Array.isArray(s)){let f=Object.getOwnPropertyNames(s);if(f.length>0){p=f[0][0]===".";for(let b=0;b<f.length;b++)if(p!==(f[b][0]==="."))throw new te("Invalid package configuration","ERR_INVALID_PACKAGE_CONFIGURATION")}}if(i==="."){let f;if(typeof s=="string"||Array.isArray(s)||!p?f=s:p&&(f=s["."]),f){let b=this.packageTargetResolve(t,f,"",!1,!1,u,l);if(b)return b}}else if(p){let f=this.packageImportsExportsResolve(i,s,t,!1,u,l);if(f)return f}throw new te(`Package path '${i}' is not exported`,"ERR_PACKAGE_PATH_NOT_EXPORTED")}packageImportsExportsResolve(t,i,s,u,l,p){let f=i[t];if(f&&t.indexOf("*")===-1)return this.packageTargetResolve(s,f,"",!1,u,l,p);let b=Object.getOwnPropertyNames(i),x="",S;for(let T=0;T<b.length;T++){let N=b[T];if(t.length<N.length)continue;let O=N.indexOf("*");if(O===-1)continue;let W=N.slice(0,O);if(t.startsWith(W)&&N.indexOf("*",O+1)===-1){let y=N.slice(O+1);t.endsWith(y)&&this.patternKeyCompare(x,N)===1&&(f=i[N],x=N,S=t.slice(W.length,t.length-y.length))}}return S?this.packageTargetResolve(s,f,S,!0,u,l,p):null}patternKeyCompare(t,i){let s=t.indexOf("*"),u=s===-1?t.length:s+1,l=i.indexOf("*"),p=l===-1?i.length:l+1;return u>p?-1:p>u||s===-1?1:l===-1||t.length>i.length?-1:i.length>t.length?1:0}packageTargetResolve(t,i,s,u,l,p,f){if(typeof i=="string"){if(!u&&s.length>0&&!i.endsWith("/"))throw new te(`Invalid package specifier '${s}'`,"ERR_INVALID_MODULE_SPECIFIER");if(!i.startsWith("./")){if(l&&!i.startsWith("../")&&!i.startsWith("/")){let x=!1;try{new URL(i),x=!0}catch{}if(!x)return u?this.packageResolve(i.replace(/\*/g,s),t,p,f):this.packageResolve(this.fs.join(i,s),t,p,f)}throw new te(`Invalid package target for '${s}'`,"ERR_INVALID_PACKAGE_TARGET")}if(i=decodeURI(i),i.split(/[/\\]/).slice(1).findIndex(x=>x==="."||x===".."||x.toLowerCase()==="node_modules")!==-1)throw new te(`Invalid package target for '${s}'`,"ERR_INVALID_PACKAGE_TARGET");let b=this.fs.join(t,i);if(s=decodeURI(s),s.split(/[/\\]/).findIndex(x=>x==="."||x===".."||x.toLowerCase()==="node_modules")!==-1)throw new te(`Invalid package specifier '${s}'`,"ERR_INVALID_MODULE_SPECIFIER");return u?b.replace(/\*/g,s):this.fs.join(b,s)}else if(Array.isArray(i)){if(i.length===0)return null;let b;for(let x=0;x<i.length;x++){let S=i[x],T;try{T=this.packageTargetResolve(t,S,s,u,l,p,f)}catch(N){if(N.code!=="ERR_INVALID_PACKAGE_TARGET")throw N;b=N;continue}if(T!==void 0)return T;T===null&&(b=null)}if(b==null)return b;throw b}else if(typeof i=="object"&&i!==null){let b=Object.getOwnPropertyNames(i);for(let x=0;x<b.length;x++){let S=b[x];if(ja(S))throw new te(`Invalid package configuration for '${s}'`,"ERR_INVALID_PACKAGE_CONFIGURATION")}for(let x=0;x<b.length;x++){let S=b[x];if(S==="default"||p.includes(S)){let T=i[S],N=this.packageTargetResolve(t,T,s,u,l,p,f);if(N!==void 0)return N}}return}else if(i==null)return null;throw new te(`Invalid package target for '${s}'`,"ERR_INVALID_PACKAGE_TARGET")}packageResolve(t,i,s,u){let l;if(t==="")throw new te(`Invalid package specifier '${t}'`,"ERR_INVALID_MODULE_SPECIFIER");if(this.builtins.has(t))return"node:"+t;let p=t.indexOf("/");if(t[0]==="@"){if(p===-1)throw new te(`Invalid package specifier '${t}'`,"ERR_INVALID_MODULE_SPECIFIER");p=t.indexOf("/",p+1)}if(l=p===-1?t:t.slice(0,p),p!==0&&(l[0]==="."||l.indexOf("\\")>=0||l.indexOf("%")>=0))throw new te(`Invalid package specifier '${t}'`,"ERR_INVALID_MODULE_SPECIFIER");let f="."+t.slice(l.length);if(f[f.length-1]==="/")throw new te(`Invalid package specifier '${t}'`,"ERR_INVALID_MODULE_SPECIFIER");let b=this.packageSelfResolve(l,f,i);if(b)return b;let x;for(;;){x=this.fs.resolve(this.fs.join(i,"node_modules",t));let T=this.fs.dirname(i);if(this.isPathAllowed(x)&&qa(this.fs,x))break;if(T===i)throw new te(`Cannot find module '${t}'`,"ENOTFOUND");i=T}let S=this.readPackage(x);return S&&S.exports?this.packageExportsResolve(x,f,S.exports,s,u):f==="."?this.loadAsPackage(f,S,u):this.fs.join(x,f)}};zr.Resolver=cr;zr.DefaultResolver=Hr});var Yr=de(Xr=>{"use strict";var et=require("path"),Kr=require("fs"),Qr=class{resolve(t){return et.resolve(t)}isSeparator(t){return t==="/"||t===et.sep}isAbsolute(t){return et.isAbsolute(t)}join(...t){return et.join(...t)}basename(t){return et.basename(t)}dirname(t){return et.dirname(t)}statSync(t,i){return Kr.statSync(t,i)}readFileSync(t,i){return Kr.readFileSync(t,i)}},Jr=class{constructor({fs:t=Kr,path:i=et}={}){this.fs=t,this.path=i}resolve(t){return this.path.resolve(t)}isSeparator(t){return t==="/"||t===this.path.sep}isAbsolute(t){return this.path.isAbsolute(t)}join(...t){return this.path.join(...t)}basename(t){return this.path.basename(t)}dirname(t){return this.path.dirname(t)}statSync(t,i){return this.fs.statSync(t,i)}readFileSync(t,i){return this.fs.readFileSync(t,i)}};Xr.DefaultFileSystem=Qr;Xr.VMFileSystem=Jr});var vn=de(ii=>{"use strict";var Ga=require("fs"),Ha=require("module"),{EventEmitter:gt}=require("events"),za=require("util"),{VMScript:ri}=ft(),{VM:Ka}=ur(),yn=new WeakMap;function Qa(c){return yn.get(c)}var Zr;function Ja(c){return Zr||(Zr=new ri("return buffer=>({Buffer: buffer});",{__proto__:null,filename:"buffer.js"})),c.run(Zr,{__proto__:null,strict:!0,wrapper:"none"})(Buffer)}var ei;function Xa(c){ei||(ei=new ri(`return function inherits(ctor, superCtor) {
|
|
20
|
+
ctor.super_ = superCtor;
|
|
21
|
+
Object.setPrototypeOf(ctor.prototype, superCtor.prototype);
|
|
22
|
+
}`,{__proto__:null,filename:"util.js"}));let t=c.run(ei,{__proto__:null,strict:!0,wrapper:"none"}),i=Object.assign({},za);return i.inherits=t,c.readonly(i)}var mt=(Ha.builtinModules||Object.getOwnPropertyNames(process.binding("natives"))).filter(c=>!c.startsWith("internal/")),xn=null;if(gt.EventEmitterAsyncResource){let{AsyncResource:c}=require("async_hooks"),t=Symbol("kEventEmitter");class i extends c{constructor(u,l,p){super(l,p),this[t]=u}get eventEmitter(){return this[t]}}xn=i}var ti,Ya={events:{init(c){if(!ti){let s=Ga.readFileSync(`${__dirname}/events.js`,"utf8");ti=new ri(`(function (fromhost) { const module = {}; module.exports={};{ ${s}
|
|
23
|
+
} return module.exports;})`,{filename:"events.js"})}let i=Ka.prototype.run.call(c,ti)(c.readonly({kErrorMonitor:gt.errorMonitor,once:gt.once,on:gt.on,getEventListeners:gt.getEventListeners,EventEmitterReferencingAsyncResource:xn}));yn.set(c,i),c._addProtoMapping(gt.prototype,i.EventEmitter.prototype)},load:Qa},buffer:Ja,util:Xa};function pr(c,t,i){if(c.has(t))return;let s=Ya[t];c.set(t,s||(u=>u.readonly(i(t))))}function Za(c,t,i,s){let u=new Map;if(i){let l=Object.getOwnPropertyNames(i);for(let p=0;p<l.length;p++){let f=l[p];u.set(f,b=>b.readonly(i[f]))}}if(s){let l=Object.getOwnPropertyNames(s);for(let p=0;p<l.length;p++){let f=l[p];u.set(f,s[f])}}if(Array.isArray(c))if(c.indexOf("*")>=0)for(let p=0;p<mt.length;p++){let f=mt[p];c.indexOf(`-${f}`)===-1&&pr(u,f,t)}else for(let p=0;p<mt.length;p++){let f=mt[p];c.indexOf(f)!==-1&&pr(u,f,t)}else if(c)for(let l=0;l<mt.length;l++){let p=mt[l];c[p]&&pr(u,p,t)}return u}function eo(c,t){let i=new Map;for(let s=0;s<c.length;s++){let u=c[s];pr(i,u,t)}return i}ii.makeBuiltinsFromLegacyOptions=Za;ii.makeBuiltins=eo});var ui=de(Cn=>{"use strict";var{Resolver:ni,DefaultResolver:to}=lr(),{VMError:ro}=Ye(),{DefaultFileSystem:io}=Yr(),{makeBuiltinsFromLegacyOptions:bn}=vn(),{jsCompiler:no}=Nt();function wn(c){return require(c)}function si(c){return c.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&")}function _n(c){return si(c).replace(/\\\\|\//g,"[\\\\/]").replace(/\\\*\\\*/g,".*").replace(/\\\*/g,"[^\\\\/]*").replace(/\\\?/g,"[^\\\\/]")}function so(c){let t=_n(c);return new RegExp(`[\\\\/]node_modules[\\\\/]${t}(?:[\\\\/](?!(?:.*[\\\\/])?node_modules[\\\\/]).*)?$`)}var hr=class extends to{constructor(t,i,s,u,l,p,f,b,x){super(t,i,s),this.rootPaths=u,this.pathContext=l,this.customResolver=p,this.hostRequire=f,this.compiler=b,this.strict=x}isPathAllowed(t){return this.rootPaths===void 0||this.rootPaths.some(i=>{if(!t.startsWith(i))return!1;let s=i.length;return t.length===s||s>0&&this.fs.isSeparator(i[s-1])?!0:this.fs.isSeparator(t[s])})}loadJS(t,i,s){if(this.pathContext(s,"js")!=="host")return super.loadJS(t,i,s);let u=this.hostRequire(s);i.exports=t.readonly(u)}loadNode(t,i,s){if(this.pathContext(s,"node")!=="host")return super.loadNode(t,i,s);let u=this.hostRequire(s);i.exports=t.readonly(u)}customResolve(t,i,s){if(this.customResolver===void 0)return;let u=this.customResolver(t,i);if(!u)return;if(typeof u=="string")return this.loadAsFileOrDirectory(u,s);let{module:l=t,path:p}=u;return this.loadNodeModules(l,[p],s)}getCompiler(t){return this.compiler}isStrict(t){return this.strict}},ai=class extends hr{constructor(t,i,s,u,l,p,f,b,x,S,T){super(t,i,s,u,l,p,f,b,x),this.externals=S.map(so),this.externalCache=S.map(N=>new RegExp(_n(N))),this.currMod=void 0,this.trustedMods=new WeakMap,this.allowTransitive=T}isPathAllowed(t){return this.isPathAllowedForModule(t,this.currMod)}isPathAllowedForModule(t,i){if(!super.isPathAllowed(t))return!1;if(i){if(i.allowTransitive)return!0;if(t.startsWith(i.path)){let s=t.slice(i.path.length);if(!/(?:^|[\\\\/])node_modules(?:$|[\\\\/])/.test(s))return!0}}return this.externals.some(s=>s.test(t))}registerModule(t,i,s,u,l){let p=this.trustedMods.get(u);this.trustedMods.set(t,{filename:i,path:s,paths:this.genLookupPaths(s),allowTransitive:this.allowTransitive&&(l&&p&&p.allowTransitive||this.externals.some(f=>f.test(i)))})}resolveFull(t,i,s,u,l){if(this.currMod=void 0,!l)return super.resolveFull(t,i,s,u,!1);let p=this.trustedMods.get(t);if(!p||t.path!==p.path)return super.resolveFull(t,i,s,u,!1);let f=[...t.paths];if(f.length!==p.paths.length)return super.resolveFull(t,i,s,u,!1);for(let b=0;b<f.length;b++)if(f[b]!==p.paths[b])return super.resolveFull(t,i,s,u,!1);try{return this.currMod=p,super.resolveFull(p,i,s,u,!0)}finally{this.currMod=void 0}}checkAccess(t,i){let s=this.trustedMods.get(t);if((!s||s.filename!==i)&&!this.isPathAllowedForModule(i,void 0))throw new ro(`Module '${i}' is not allowed to be required. The path is outside the border!`,"EDENIED")}loadJS(t,i,s){if(this.pathContext(s,"js")!=="host"){let u=this.trustedMods.get(i),l=this.readScript(s);t.run(l,{filename:s,strict:this.isStrict(s),module:i,wrapper:"none",dirname:u?u.path:i.path})}else{let u=this.hostRequire(s);i.exports=t.readonly(u)}}customResolve(t,i,s){if(this.customResolver===void 0||!(this.pathIsAbsolute(t)||this.pathIsRelative(t))&&!this.externalCache.some(f=>f.test(t)))return;let u=this.customResolver(t,i);if(!u)return;if(typeof u=="string")return this.externals.push(new RegExp("^"+si(u))),this.loadAsFileOrDirectory(u,s);let{module:l=t,path:p}=u;return this.externals.push(new RegExp("^"+si(p))),this.loadNodeModules(l,[p],s)}},oi=new io,ao=new ni(oi,[],new Map);function oo(c,t,i){if(!c){if(!t)return ao;let d=bn(void 0,wn,void 0,t);return new ni(oi,[],d)}let{builtin:s,mock:u,external:l,root:p,resolve:f,customRequire:b=wn,context:x="host",strict:S=!0,fs:T=oi}=c,N=bn(s,b,u,t);if(!l)return new ni(T,[],N);i||(i=no);let O=p?(Array.isArray(p)?p:[p]).map(d=>T.resolve(d)):void 0,W=typeof x=="function"?x:()=>x;if(typeof l!="object")return new hr(T,[],N,O,W,f,b,i,S);let y=!1,m;return Array.isArray(l)?m=l:(m=l.modules,y=x!=="host"&&l.transitive),new ai(T,[],N,O,W,f,b,i,S,m,y)}Cn.makeResolverFromLegacyOptions=oo});var Rn=de(Pn=>{"use strict";var fr=require("fs"),Sn=require("path"),{Script:In}=require("vm"),{VMError:yt}=Ye(),{VMScript:uo,MODULE_PREFIX:co,STRICT_MODULE_PREFIX:lo,MODULE_SUFFIX:po}=ft(),{transformer:ho}=ar(),{VM:Tn}=ur(),{makeResolverFromLegacyOptions:fo}=ui(),{Resolver:mo}=lr(),En=Object.defineProperty,go=Object.defineProperties,An=Object.freeze({__proto__:null,version:parseInt(process.versions.node.split(".")[0]),process,console,setTimeout,setInterval,setImmediate,clearTimeout,clearInterval,clearImmediate});function kn(c,t){return new In(t,{__proto__:null,filename:c,displayErrors:!1})}var ci=null,li=null,yo=Object.freeze({__proto__:null,vm2:wo});function xo(c,t,i){let s={__proto__:null},u=t.makeExtensionHandler(c,"loadJS");for(let l=0;l<i.length;l++)s["."+i[l]]=u;return s[".json"]||(s[".json"]=t.makeExtensionHandler(c,"loadJSON")),s[".node"]||(s[".node"]=t.makeExtensionHandler(c,"loadNode")),s}function vo(c){if(c===void 0)return;if(!Array.isArray(c))return!0;let t=[...c];return t.some(i=>typeof i!="string")?!0:t}function bo(c){return c===void 0||c==null||typeof c!="object"&&typeof c!="function"?c:{unsafeOptions:c,paths:vo(c.paths)}}var dr=class c extends Tn{constructor(t={}){let{compiler:i,eval:s,wasm:u,console:l="inherit",require:p=!1,nesting:f=!1,wrapper:b="commonjs",sourceExtensions:x=["js"],argv:S,env:T,strict:N=!1,sandbox:O}=t;if(O&&typeof O!="object")throw new yt("Sandbox must be an object.");super({__proto__:null,compiler:i,eval:s,wasm:u});let W=p instanceof mo,y=W?p:fo(p,f&&yo,this._compiler);En(this,"options",{__proto__:null,value:{console:l,require:p,nesting:f,wrapper:b,sourceExtensions:x,strict:N}}),En(this,"resolver",{__proto__:null,value:y,enumerable:!0}),ci||(ci=kn(`${__dirname}/setup-node-sandbox.js`,`(function (host, data) { ${fr.readFileSync(`${__dirname}/setup-node-sandbox.js`,"utf8")}
|
|
24
|
+
})`));let m=this._runScript(ci),d=xo(this,y,x);this.readonly(An);let{Module:g,jsonParse:_,createRequireForModule:a,requireImpl:A}=m(An,{__proto__:null,argv:S,env:T,console:l,extensions:d,emitArgs:(V,I)=>{if(typeof V!="string"&&typeof V!="symbol")throw new Error("Event is not a string");return this.emit(V,...I)},globalPaths:[...y.globalPaths],getLookupPathsFor:V=>typeof V!="string"?[]:[...y.genLookupPaths(V)],resolve:(V,I,J,K,X)=>{if(typeof I!="string")throw new Error("Id is not a string");let fe=Object.getOwnPropertyNames(K);return y.resolve(V,I,bo(J),fe,!!X)},lookupPaths:(V,I)=>{if(typeof I!="string")throw new Error("Id is not a string");return[...y.lookupPaths(V,I)]},loadBuiltinModule:V=>{if(typeof V!="string")throw new Error("Id is not a string");return y.loadBuiltinModule(this,V)},registerModule:(V,I,J,K,X)=>y.registerModule(V,I,J,K,X),builtinModules:[...y.getBuiltinModulesList(this)],dirname:V=>typeof V!="string"?V:y.fs.dirname(V),basename:V=>typeof V!="string"?V:y.fs.basename(V)});if(go(this,{__proto__:null,_Module:{__proto__:null,value:g},_jsonParse:{__proto__:null,value:_},_createRequireForModule:{__proto__:null,value:a},_requireImpl:{__proto__:null,value:A},_cacheRequireModule:{__proto__:null,value:null,writable:!0}}),y.init(this),O&&this.setGlobals(O),!W&&p&&p.import)if(Array.isArray(p.import))for(let V=0,I=p.import.length;V<I;V++)this.require(p.import[V]);else this.require(p.import)}get _resolver(){return this.resolver}call(t,...i){if(typeof t=="function")return t(...i);throw new yt("Unrecognized method type.")}require(t){let i=this.resolver.fs.resolve("."),s=this._cacheRequireModule;if(!s||s.path!==i){let u=this.resolver.fs.join(i,"/vm.js");s=new this._Module(u,i),this.resolver.registerModule(s,u,i,null,!1),this._cacheRequireModule=s}return this._requireImpl(s,t,!0)}run(t,i){let s,u;typeof i=="object"?u=i.filename:(u=i,i={__proto__:null});let{strict:l=this.options.strict,wrapper:p=this.options.wrapper,module:f,require:b,dirname:x=null}=i,S=f,T=x;if(t instanceof uo){if(s=l?t._compileNodeVMStrict():t._compileNodeVM(),!S){let y=this.resolver.fs.resolve(t.filename);T=this.resolver.fs.dirname(y),S=new this._Module(y,T),this.resolver.registerModule(S,y,T,null,!1)}}else{let y=u||"vm.js";if(!S)if(u){let g=this.resolver.fs.resolve(u);T=this.resolver.fs.dirname(g),S=new this._Module(g,T),this.resolver.registerModule(S,g,T,null,!1)}else S=new this._Module(null,null),S.id=y;let m=l?lo:co,d=this._compiler(t,y);d=ho(null,d,!1,!1,y).code,s=new In(m+d+po,{__proto__:null,filename:y,displayErrors:!1})}let N=this._runScript(s),O=b||this._createRequireForModule(S),W=Reflect.apply(N,this.sandbox,[S.exports,O,S,u,T]);return p==="commonjs"?S.exports:W}static code(t,i,s){let u;if(i!=null)if(typeof i=="object")s=i,u=s.filename;else if(typeof i=="string")u=i;else throw new yt("Invalid arguments.");else typeof s=="object"&&(u=s.filename);if(arguments.length>3)throw new yt("Invalid number of arguments.");let l=typeof u=="string"?Sn.resolve(u):void 0;return new c(s).run(t,l)}static file(t,i){let s=Sn.resolve(t);if(!fr.existsSync(s))throw new yt(`Script '${t}' not found.`);if(fr.statSync(s).isDirectory())throw new yt("Script must be file, got directory.");return new c(i).run(fr.readFileSync(s,"utf8"),s)}};function wo(c){return li||(li=kn("nesting.js","(vm, nodevm) => ({VM: vm, NodeVM: nodevm})")),c._runScript(li)(c.readonly(Tn),c.readonly(dr))}Pn.NodeVM=dr});var Nn=de(je=>{"use strict";var{VMError:_o}=Ye(),{VMScript:Co}=ft(),{VM:So}=ur(),{NodeVM:Eo}=Rn(),{VMFileSystem:Ao}=Yr(),{Resolver:Io}=lr(),{makeResolverFromLegacyOptions:To}=ui();je.VMError=_o;je.VMScript=Co;je.NodeVM=Eo;je.VM=So;je.VMFileSystem=Ao;je.Resolver=Io;je.makeResolverFromLegacyOptions=To});var On=de((yc,Vn)=>{"use strict";if(parseInt(process.versions.node.split(".")[0])<6)throw new Error("vm2 requires Node.js version 6 or newer.");Vn.exports=Nn()});var No={};vs(No,{BrandBuilder:()=>Sr,CacheKey:()=>Ce,CacheTtl:()=>_r,Config:()=>ce,WarpAbiBuilder:()=>Rt,WarpActionExecutor:()=>fi,WarpArgSerializer:()=>Je,WarpBuilder:()=>kt,WarpCache:()=>We,WarpConstants:()=>q,WarpContractLoader:()=>Bt,WarpIndex:()=>di,WarpInterpolator:()=>Be,WarpLink:()=>Pt,WarpProtocolVersions:()=>Ge,WarpRegistry:()=>Ke,WarpUtils:()=>ee,WarpValidator:()=>Tt,address:()=>Bs,biguint:()=>Os,boolean:()=>Ws,codemeta:()=>Ds,composite:()=>Ts,esdt:()=>Ms,getChainExplorerUrl:()=>ws,getLatestProtocolIdentifier:()=>He,getMainChainInfo:()=>ue,getWarpActionByIndex:()=>ot,hex:()=>Ls,list:()=>As,nothing:()=>Us,option:()=>Ss,optional:()=>Es,replacePlaceholders:()=>Et,shiftBigintBy:()=>St,string:()=>ks,toPreviewText:()=>wr,toTypedChainInfo:()=>Kt,token:()=>Fs,u16:()=>Rs,u32:()=>Ns,u64:()=>Vs,u8:()=>Ps,variadic:()=>Is});module.exports=bs(No);var Qe=require("@multiversx/sdk-core"),Ki=br(require("ajv"));var q={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierType:{Alias:"alias",Hash:"hash"},Source:{UserWallet:"user:wallet"},Globals:{UserWallet:{Placeholder:"USER_WALLET",Accessor:c=>c.config.user?.wallet},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:c=>c.chain.apiUrl},ChainExplorerUrl:{Placeholder:"CHAIN_EXPLORER",Accessor:c=>c.chain.explorerUrl}},Vars:{Query:"query",Env:"env"},ArgParamsSeparator:":",ArgCompositeSeparator:"|",Transform:{Prefix:"transform:"},Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}};var Ge={Warp:"2.0.1",Brand:"0.1.0",Abi:"0.1.0"},ce={LatestWarpSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/v${Ge.Warp}.schema.json`,LatestBrandSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/brand/v${Ge.Brand}.schema.json`,DefaultClientUrl:c=>c==="devnet"?"https://devnet.usewarp.to":c==="testnet"?"https://testnet.usewarp.to":"https://usewarp.to",SuperClientUrls:["https://usewarp.to","https://testnet.usewarp.to","https://devnet.usewarp.to"],MainChain:{Name:"multiversx",DisplayName:"MultiversX",ApiUrl:c=>c==="devnet"?"https://devnet-api.multiversx.com":c==="testnet"?"https://testnet-api.multiversx.com":"https://api.multiversx.com",ExplorerUrl:c=>c==="devnet"?"https://devnet-explorer.multiversx.com":c==="testnet"?"https://testnet-explorer.multiversx.com":"https://explorer.multiversx.com",BlockTime:c=>6e3,AddressHrp:"erd",ChainId:c=>c==="devnet"?"D":c==="testnet"?"T":"1"},Registry:{Contract:c=>c==="devnet"?"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36":c==="testnet"?"####":"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"},AvailableActionInputSources:["field","query",q.Source.UserWallet],AvailableActionInputTypes:["string","uint8","uint16","uint32","uint64","biguint","boolean","address"],AvailableActionInputPositions:["receiver","value","transfer","arg:1","arg:2","arg:3","arg:4","arg:5","arg:6","arg:7","arg:8","arg:9","arg:10","data","ignore"]};var ue=c=>({name:ce.MainChain.Name,displayName:ce.MainChain.DisplayName,chainId:ce.MainChain.ChainId(c.env),blockTime:ce.MainChain.BlockTime(c.env),addressHrp:ce.MainChain.AddressHrp,apiUrl:ce.MainChain.ApiUrl(c.env),explorerUrl:ce.MainChain.ExplorerUrl(c.env)}),ws=(c,t)=>c.explorerUrl+(t?"/"+t:""),He=c=>{if(c==="warp")return`warp:${Ge.Warp}`;if(c==="brand")return`brand:${Ge.Brand}`;if(c==="abi")return`abi:${Ge.Abi}`;throw new Error(`getLatestProtocolIdentifier: Invalid protocol name: ${c}`)},ot=(c,t)=>c?.actions[t-1],Kt=c=>({name:c.name.toString(),displayName:c.display_name.toString(),chainId:c.chain_id.toString(),blockTime:c.block_time.toNumber(),addressHrp:c.address_hrp.toString(),apiUrl:c.api_url.toString(),explorerUrl:c.explorer_url.toString()}),St=(c,t)=>{let i=c.toString(),[s,u=""]=i.split("."),l=Math.abs(t);if(t>0)return BigInt(s+u.padEnd(l,"0"));if(t<0){let p=s+u;if(l>=p.length)return 0n;let f=p.slice(0,-l)||"0";return BigInt(f)}else return i.includes(".")?BigInt(i.split(".")[0]):BigInt(i)},wr=(c,t=100)=>{if(!c)return"";let i=c.replace(/<\/?(h[1-6])[^>]*>/gi," - ").replace(/<\/?(p|div|ul|ol|li|br|hr)[^>]*>/gi," ").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();return i=i.startsWith("- ")?i.slice(2):i,i=i.length>t?i.substring(0,i.lastIndexOf(" ",t))+"...":i,i},Et=(c,t)=>c.replace(/\{\{([^}]+)\}\}/g,(i,s)=>t[s]||"");var ct=require("@multiversx/sdk-core");var At=class{constructor(t="warp-cache"){this.prefix=t}getKey(t){return`${this.prefix}:${t}`}get(t){try{let i=localStorage.getItem(this.getKey(t));if(!i)return null;let s=JSON.parse(i);return Date.now()>s.expiresAt?(localStorage.removeItem(this.getKey(t)),null):s.value}catch{return null}}set(t,i,s){let u={value:i,expiresAt:Date.now()+s*1e3};localStorage.setItem(this.getKey(t),JSON.stringify(u))}forget(t){localStorage.removeItem(this.getKey(t))}clear(){for(let t=0;t<localStorage.length;t++){let i=localStorage.key(t);i?.startsWith(this.prefix)&&localStorage.removeItem(i)}}};var De=class De{get(t){let i=De.cache.get(t);return i?Date.now()>i.expiresAt?(De.cache.delete(t),null):i.value:null}set(t,i,s){let u=Date.now()+s*1e3;De.cache.set(t,{value:i,expiresAt:u})}forget(t){De.cache.delete(t)}clear(){De.cache.clear()}};De.cache=new Map;var It=De;var _r={OneMinute:60,OneHour:60*60,OneDay:60*60*24,OneWeek:60*60*24*7,OneMonth:60*60*24*30,OneYear:60*60*24*365},Ce={Warp:c=>`warp:${c}`,WarpAbi:c=>`warp-abi:${c}`,RegistryInfo:c=>`registry-info:${c}`,Brand:c=>`brand:${c}`,ChainInfo:c=>`chain:${c}`,ChainInfos:()=>"chains"},We=class{constructor(t){this.strategy=this.selectStrategy(t)}selectStrategy(t){return t==="localStorage"?new At:t==="memory"?new It:typeof window<"u"&&window.localStorage?new At:new It}set(t,i,s){this.strategy.set(t,i,s)}get(t){return this.strategy.get(t)}forget(t){this.strategy.forget(t)}clear(){this.strategy.clear()}};var zi=br(require("qr-code-styling"));var ze=require("@multiversx/sdk-core");var ut=class ut{static info(...t){ut.isTestEnv||console.info(...t)}static warn(...t){ut.isTestEnv||console.warn(...t)}static error(...t){ut.isTestEnv||console.error(...t)}};ut.isTestEnv=typeof process<"u"&&process.env.JEST_WORKER_ID!==void 0;var me=ut;var Gi=br(require("ajv"));var Tt=class{constructor(t){this.config=t;this.config=t}async validate(t){let i=[];return i.push(...this.validateMaxOneValuePosition(t)),i.push(...this.validateVariableNamesAndResultNamesUppercase(t)),i.push(...this.validateAbiIsSetIfApplicable(t)),i.push(...await this.validateSchema(t)),{valid:i.length===0,errors:i}}validateMaxOneValuePosition(t){return t.actions.filter(s=>s.inputs?s.inputs.some(u=>u.position==="value"):!1).length>1?["Only one value position action is allowed"]:[]}validateVariableNamesAndResultNamesUppercase(t){let i=[],s=(u,l)=>{u&&Object.keys(u).forEach(p=>{p!==p.toUpperCase()&&i.push(`${l} name '${p}' must be uppercase`)})};return s(t.vars,"Variable"),s(t.results,"Result"),i}validateAbiIsSetIfApplicable(t){let i=t.actions.some(l=>l.type==="contract"),s=t.actions.some(l=>l.type==="query");if(!i&&!s)return[];let u=t.actions.some(l=>l.abi);return t.results&&!u?["ABI is required when results are present for contract or query actions"]:[]}async validateSchema(t){try{let i=this.config.schema?.warp||ce.LatestWarpSchemaUrl,u=await(await fetch(i)).json(),l=new Gi.default,p=l.compile(u);return p(t)?[]:[`Schema validation failed: ${l.errorsText(p.errors)}`]}catch(i){return[`Schema validation failed: ${i instanceof Error?i.message:String(i)}`]}}};var kt=class{constructor(t){this.pendingWarp={protocol:He("warp"),name:"",title:"",description:null,preview:"",actions:[]};this.config=t,this.cache=new We(t.cache?.type)}createInscriptionTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpBuilder: user address not set");let i=ue(this.config),s=new ze.TransactionsFactoryConfig({chainID:i.chainId}),u=new ze.TransferTransactionsFactory({config:s}),l=ze.Address.newFromBech32(this.config.user.wallet),p=JSON.stringify(t),f=u.createTransactionForTransfer(l,{receiver:ze.Address.newFromBech32(this.config.user.wallet),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(p))});return f.gasLimit=f.gasLimit+BigInt(2e6),f}async createFromRaw(t,i=!0){let s=JSON.parse(t);return i&&await this.validate(s),s}async createFromTransaction(t,i=!1){let s=await this.createFromRaw(t.data.toString(),i);return s.meta={hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},s}async createFromTransactionHash(t,i){let s=Ce.Warp(t);if(i){let f=this.cache.get(s);if(f)return me.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),f}let u=ue(this.config),p=ee.getChainEntrypoint(u,this.config.env).createNetworkProvider();try{let f=await p.getTransaction(t),b=await this.createFromTransaction(f);return i&&i.ttl&&b&&this.cache.set(s,b,i.ttl),b}catch(f){return console.error("WarpBuilder: Error creating from transaction hash",f),null}}setName(t){return this.pendingWarp.name=t,this}setTitle(t){return this.pendingWarp.title=t,this}setDescription(t){return this.pendingWarp.description=t,this}setPreview(t){return this.pendingWarp.preview=t,this}setActions(t){return this.pendingWarp.actions=t,this}addAction(t){return this.pendingWarp.actions.push(t),this}async build(){return this.ensure(this.pendingWarp.protocol,"protocol is required"),this.ensure(this.pendingWarp.name,"name is required"),this.ensure(this.pendingWarp.title,"title is required"),this.ensure(this.pendingWarp.actions.length>0,"actions are required"),await this.validate(this.pendingWarp),this.pendingWarp}getDescriptionPreview(t,i=100){return wr(t,i)}ensure(t,i){if(!t)throw new Error(i)}async validate(t){let s=await new Tt(this.config).validate(t);if(!s.valid)throw new Error(s.errors.join(`
|
|
25
|
+
`))}};var Be=class{static async apply(t,i){let s=this.applyVars(t,i);return await this.applyGlobals(t,s)}static async applyGlobals(t,i){let s={...i};return s.actions=await Promise.all(s.actions.map(async u=>await this.applyActionGlobals(t,u))),s=await this.applyRootGlobals(s,t),s}static applyVars(t,i){if(!i?.vars)return i;let s=JSON.stringify(i),u=(l,p)=>{s=s.replace(new RegExp(`{{${l.toUpperCase()}}}`,"g"),p.toString())};return Object.entries(i.vars).forEach(([l,p])=>{if(typeof p!="string")u(l,p);else if(p.startsWith(`${q.Vars.Query}:`)){if(!t.currentUrl)throw new Error("WarpUtils: currentUrl config is required to prepare vars");let f=p.split(`${q.Vars.Query}:`)[1],b=new URLSearchParams(t.currentUrl.split("?")[1]).get(f);b&&u(l,b)}else if(p.startsWith(`${q.Vars.Env}:`)){let f=p.split(`${q.Vars.Env}:`)[1],b=t.vars?.[f];b&&u(l,b)}else p===q.Source.UserWallet&&t.user?.wallet?u(l,t.user.wallet):u(l,p)}),JSON.parse(s)}static async applyRootGlobals(t,i){let s=JSON.stringify(t),u={config:i,chain:ue(i)};return Object.values(q.Globals).forEach(l=>{let p=l.Accessor(u);p!=null&&(s=s.replace(new RegExp(`{{${l.Placeholder}}}`,"g"),p.toString()))}),JSON.parse(s)}static async applyActionGlobals(t,i){let s=await ee.getChainInfoForAction(t,i),u=JSON.stringify(i),l={config:t,chain:s};return Object.values(q.Globals).forEach(p=>{let f=p.Accessor(l);f!=null&&(u=u.replace(new RegExp(`{{${p.Placeholder}}}`,"g"),f.toString()))}),JSON.parse(u)}};var z=require("@multiversx/sdk-core/out");var Cr={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"}],outputs:[]},{name:"setWarpAlias",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias",type:"bytes"}],outputs:[]},{name:"forceRemoveAlias",mutability:"mutable",inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"verifyWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"transferOwnership",mutability:"mutable",inputs:[{name:"warp",type:"bytes"},{name:"new_owner",type:"Address"}],outputs:[]},{name:"getUserWarps",mutability:"readonly",inputs:[{name:"address",type:"Address"}],outputs:[{type:"variadic<InfoView>",multi_result:!0}]},{name:"getInfoByAlias",mutability:"readonly",inputs:[{name:"alias",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"getInfoByHash",mutability:"readonly",inputs:[{name:"hash",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"setVault",onlyOwner:!0,mutability:"mutable",inputs:[{name:"vault",type:"Address"}],outputs:[]},{name:"setUnitPrice",onlyOwner:!0,mutability:"mutable",inputs:[{name:"amount",type:"BigUint"}],outputs:[]},{name:"addAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"removeAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"ConfigView"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]},{name:"setChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"}],outputs:[]},{name:"removeChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"}],outputs:[]},{name:"getChain",mutability:"readonly",inputs:[{name:"name",type:"bytes"}],outputs:[{type:"ChainView"}]},{name:"getChains",mutability:"readonly",inputs:[],outputs:[{type:"variadic<ChainView>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpUnregistered",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"warpUpgraded",inputs:[{name:"alias",type:"bytes",indexed:!0},{name:"new_warp",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{identifier:"ownershipTransferred",inputs:[{name:"warp",type:"bytes",indexed:!0},{name:"old_owner",type:"Address",indexed:!0},{name:"new_owner",type:"Address",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{ChainView:{type:"struct",fields:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"}]},ConfigView:{type:"struct",fields:[{name:"unit_price",type:"BigUint"},{name:"admins",type:"List<Address>"}]},InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"owner",type:"Address"},{name:"created_at",type:"u64"},{name:"upgraded_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var Qt=c=>({hash:c.hash.toString("hex"),alias:c.alias?.toString()||null,trust:c.trust.toString(),owner:c.owner.toString(),createdAt:c.created_at.toNumber(),upgradedAt:c.upgraded_at?.toNumber(),brand:c.brand?.toString("hex")||null,upgrade:c.upgrade?.toString("hex")||null}),Hi=c=>({unitPrice:BigInt(c.unit_price.toString()),admins:c.admins.map(t=>t.toBech32())});var Ke=class{constructor(t){this.config=t,this.cache=new We(t.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]}}async init(){await this.loadRegistryConfigs()}createWarpRegisterTransaction(t,i,s){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let u=z.Address.newFromBech32(this.config.user.wallet),l=()=>this.isCurrentUserAdmin()?BigInt(0):i&&s?this.registryConfig.unitPrice*BigInt(3):i?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,p=()=>i&&s?[z.BytesValue.fromHex(t),z.BytesValue.fromUTF8(i),z.BytesValue.fromHex(s)]:i?[z.BytesValue.fromHex(t),z.BytesValue.fromUTF8(i)]:[z.BytesValue.fromHex(t)];return this.getFactory().createTransactionForExecute(u,{contract:this.getRegistryContractAddress(),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:l(),arguments:p()})}createWarpUnregisterTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let i=z.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(i,{contract:this.getRegistryContractAddress(),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[z.BytesValue.fromHex(t)]})}createWarpUpgradeTransaction(t,i){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let s=z.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(s,{contract:this.getRegistryContractAddress(),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[z.BytesValue.fromUTF8(t),z.BytesValue.fromHex(i)]})}createWarpAliasSetTransaction(t,i){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let s=z.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(s,{contract:this.getRegistryContractAddress(),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[z.BytesValue.fromHex(t),z.BytesValue.fromUTF8(i)]})}createWarpVerifyTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let i=z.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(i,{contract:this.getRegistryContractAddress(),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[z.BytesValue.fromHex(t)]})}createWarpTransferOwnershipTransaction(t,i){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let s=z.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(s,{contract:this.getRegistryContractAddress(),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[z.BytesValue.fromHex(t),new z.AddressValue(new z.Address(i))]})}createBrandRegisterTransaction(t){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let i=z.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(i,{contract:this.getRegistryContractAddress(),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[z.BytesValue.fromHex(t)]})}createWarpBrandingTransaction(t,i){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let s=z.Address.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(s,{contract:this.getRegistryContractAddress(),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[z.BytesValue.fromHex(t),z.BytesValue.fromHex(i)]})}async getInfoByAlias(t,i){try{let s=Ce.RegistryInfo(t),u=i?this.cache.get(s):null;if(u)return me.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${t}`),u;let l=this.getRegistryContractAddress(),p=this.getController(),f=p.createQuery({contract:l,function:"getInfoByAlias",arguments:[z.BytesValue.fromUTF8(t)]}),b=await p.runQuery(f),[x]=p.parseQueryResponse(b),S=x?Qt(x):null,T=S?.brand?await this.fetchBrand(S.brand):null;return i&&i.ttl&&this.cache.set(s,{registryInfo:S,brand:T},i.ttl),{registryInfo:S,brand:T}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(t,i){try{let s=Ce.RegistryInfo(t);if(i){let T=this.cache.get(s);if(T)return me.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${t}`),T}let u=this.getRegistryContractAddress(),l=this.getController(),p=l.createQuery({contract:u,function:"getInfoByHash",arguments:[z.BytesValue.fromHex(t)]}),f=await l.runQuery(p),[b]=l.parseQueryResponse(f),x=b?Qt(b):null,S=x?.brand?await this.fetchBrand(x.brand):null;return i&&i.ttl&&this.cache.set(s,{registryInfo:x,brand:S},i.ttl),{registryInfo:x,brand:S}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(t){try{let i=t||this.config.user?.wallet;if(!i)throw new Error("WarpRegistry: user address not set");let s=this.getRegistryContractAddress(),u=this.getController(),l=u.createQuery({contract:s,function:"getUserWarps",arguments:[new z.AddressValue(new z.Address(i))]}),p=await u.runQuery(l),[f]=u.parseQueryResponse(p);return f.map(Qt)}catch{return[]}}async getUserBrands(t){try{let i=t||this.config.user?.wallet;if(!i)throw new Error("WarpRegistry: user address not set");let s=this.getRegistryContractAddress(),u=this.getController(),l=u.createQuery({contract:s,function:"getUserBrands",arguments:[new z.AddressValue(new z.Address(i))]}),p=await u.runQuery(l),[f]=u.parseQueryResponse(p),b=f.map(T=>T.toString("hex")),x={ttl:365*24*60*60};return(await Promise.all(b.map(T=>this.fetchBrand(T,x)))).filter(T=>T!==null)}catch{return[]}}async getChainInfos(t){let i=Ce.ChainInfos();if(t&&t.ttl){let x=this.cache.get(i);if(x)return me.info("WarpRegistry (getChainInfos): ChainInfos found in cache"),x}let s=this.getRegistryContractAddress(),u=this.getController(),l=u.createQuery({contract:s,function:"getChains",arguments:[]}),p=await u.runQuery(l),[f]=u.parseQueryResponse(p),b=f.map(Kt);if(t&&t.ttl){for(let x of b)this.cache.set(Ce.ChainInfo(x.chain),x,t.ttl);this.cache.set(i,b,t.ttl)}return b}async getChainInfo(t,i){try{let s=Ce.ChainInfo(t),u=i?this.cache.get(s):null;if(u)return me.info(`WarpRegistry (getChainInfo): ChainInfo found in cache: ${t}`),u;let l=this.getRegistryContractAddress(),p=this.getController(),f=p.createQuery({contract:l,function:"getChain",arguments:[z.BytesValue.fromUTF8(t)]}),b=await p.runQuery(f),[x]=p.parseQueryResponse(b),S=x?Kt(x):null;return i&&i.ttl&&S&&this.cache.set(s,S,i.ttl),S}catch{return null}}async fetchBrand(t,i){let s=Ce.Brand(t),u=i?this.cache.get(s):null;if(u)return me.info(`WarpRegistry (fetchBrand): Brand found in cache: ${t}`),u;let l=ue(this.config),f=ee.getChainEntrypoint(l,this.config.env).createNetworkProvider();try{let b=await f.getTransaction(t),x=JSON.parse(b.data.toString());return x.meta={hash:b.hash,creator:b.sender.bech32(),createdAt:new Date(b.timestamp*1e3).toISOString()},i&&i.ttl&&this.cache.set(s,x,i.ttl),x}catch{return null}}getRegistryContractAddress(){return z.Address.newFromBech32(this.config.registry?.contract||ce.Registry.Contract(this.config.env))}async loadRegistryConfigs(){let t=this.getRegistryContractAddress(),i=this.getController(),[s]=await i.query({contract:t,function:"getConfig",arguments:[]}),u=s?Hi(s):null;this.registryConfig=u||{unitPrice:BigInt(0),admins:[]}}getFactory(){let t=ue(this.config),i=new z.TransactionsFactoryConfig({chainID:t.chainId}),s=z.AbiRegistry.create(Cr);return new z.SmartContractTransactionsFactory({config:i,abi:s})}getController(){let t=ue(this.config),i=ee.getChainEntrypoint(t,this.config.env),s=z.AbiRegistry.create(Cr);return i.createSmartContractController(s)}isCurrentUserAdmin(){return!!this.config.user?.wallet&&this.registryConfig.admins.includes(this.config.user.wallet)}};var Pt=class{constructor(t){this.config=t;this.config=t}isValid(t){return t.startsWith(q.HttpProtocolPrefix)?!!this.extractIdentifierInfoFromUrl(t):!1}async detectFromHtml(t){if(!t.length)return{match:!1,results:[]};let u=[...t.matchAll(/https?:\/\/[^\s"'<>]+/gi)].map(x=>x[0]).filter(x=>this.isValid(x)).map(x=>this.detect(x)),p=(await Promise.all(u)).filter(x=>x.match),f=p.length>0,b=p.map(x=>({url:x.url,warp:x.warp}));return{match:f,results:b}}async detect(t,i){let s={match:!1,url:t,warp:null,registryInfo:null,brand:null},u=t.startsWith(q.HttpProtocolPrefix)?this.extractIdentifierInfoFromUrl(t):ee.getInfoFromPrefixedIdentifier(t);if(!u)return s;try{let{type:l,identifierBase:p}=u,f=new kt(this.config),b=new Ke(this.config),x=null,S=null,T=null;if(l==="hash"){x=await f.createFromTransactionHash(p,i);let O=await b.getInfoByHash(p,i);S=O.registryInfo,T=O.brand}else if(l==="alias"){let O=await b.getInfoByAlias(p,i);S=O.registryInfo,T=O.brand,O.registryInfo&&(x=await f.createFromTransactionHash(O.registryInfo.hash,i))}let N=x?await Be.apply(this.config,x):null;return N?{match:!0,url:t,warp:N,registryInfo:S,brand:T}:s}catch(l){return me.error("Error detecting warp link",l),s}}build(t,i){let s=this.config.clientUrl||ce.DefaultClientUrl(this.config.env),u=t===q.IdentifierType.Alias?encodeURIComponent(i):encodeURIComponent(t+q.IdentifierParamSeparator+i);return ce.SuperClientUrls.includes(s)?`${s}/${u}`:`${s}?${q.IdentifierParamName}=${u}`}buildFromPrefixedIdentifier(t){let i=ee.getInfoFromPrefixedIdentifier(t);return i?this.build(i.type,i.identifierBase):""}generateQrCode(t,i,s=512,u="white",l="black",p="#23F7DD"){let f=this.build(t,i);return new zi.default({type:"svg",width:s,height:s,data:String(f),margin:16,qrOptions:{typeNumber:0,mode:"Byte",errorCorrectionLevel:"Q"},backgroundOptions:{color:u},dotsOptions:{type:"extra-rounded",color:l},cornersSquareOptions:{type:"extra-rounded",color:l},cornersDotOptions:{type:"square",color:l},imageOptions:{hideBackgroundDots:!0,imageSize:.4,margin:8},image:`data:image/svg+xml;utf8,<svg width="16" height="16" viewBox="0 0 100 100" fill="${encodeURIComponent(p)}" xmlns="http://www.w3.org/2000/svg"><path d="M54.8383 50.0242L95 28.8232L88.2456 16L51.4717 30.6974C50.5241 31.0764 49.4759 31.0764 48.5283 30.6974L11.7544 16L5 28.8232L45.1616 50.0242L5 71.2255L11.7544 84.0488L48.5283 69.351C49.4759 68.9724 50.5241 68.9724 51.4717 69.351L88.2456 84.0488L95 71.2255L54.8383 50.0242Z"/></svg>`})}extractIdentifierInfoFromUrl(t){let i=new URL(t),s=ce.SuperClientUrls.includes(i.origin),u=i.searchParams.get(q.IdentifierParamName),l=s&&!u?i.pathname.split("/")[1]:u;if(!l)return null;let p=decodeURIComponent(l);return ee.getInfoFromPrefixedIdentifier(p)}};var Cs="https://",ee=class{static getInfoFromPrefixedIdentifier(t){let i=decodeURIComponent(t),s=i.includes(q.IdentifierParamSeparator)?i:`${q.IdentifierType.Alias}${q.IdentifierParamSeparator}${i}`,[u,l]=s.split(q.IdentifierParamSeparator),p=l.split("?")[0];return{type:u,identifier:l,identifierBase:p}}static getNextInfo(t,i,s,u){let l=i.actions?.[s]?.next||i.next||null;if(!l)return null;if(l.startsWith(Cs))return[{identifier:null,url:l}];let[p,f]=l.split("?");if(!f)return[{identifier:p,url:this.buildNextUrl(p,t)}];let b=f.match(/{{([^}]+)\[\](\.[^}]+)?}}/g)||[];if(b.length===0){let y=Et(f,{...i.vars,...u}),m=y?`${p}?${y}`:p;return[{identifier:m,url:this.buildNextUrl(m,t)}]}let x=b[0];if(!x)return[];let S=x.match(/{{([^[]+)\[\]/),T=S?S[1]:null;if(!T||u[T]===void 0)return[];let N=Array.isArray(u[T])?u[T]:[u[T]];if(N.length===0)return[];let O=b.filter(y=>y.includes(`{{${T}[]`)).map(y=>{let m=y.match(/\[\](\.[^}]+)?}}/),d=m&&m[1]||"";return{placeholder:y,field:d?d.slice(1):"",regex:new RegExp(y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g")}});return N.map(y=>{let m=f;for(let{regex:g,field:_}of O){let a=_?this.getNestedValue(y,_):y;if(a==null)return null;m=m.replace(g,a)}if(m.includes("{{")||m.includes("}}"))return null;let d=m?`${p}?${m}`:p;return{identifier:d,url:this.buildNextUrl(d,t)}}).filter(y=>y!==null)}static buildNextUrl(t,i){let[s,u]=t.split("?"),l=this.getInfoFromPrefixedIdentifier(s)||{type:"alias",identifier:s,identifierBase:s},f=new Pt(i).build(l.type,l.identifierBase);if(!u)return f;let b=new URL(f);return new URLSearchParams(u).forEach((x,S)=>b.searchParams.set(S,x)),b.toString().replace(/\/\?/,"?")}static getNestedValue(t,i){return i.split(".").reduce((s,u)=>s?.[u],t)}static async getChainInfoForAction(t,i){if(!i.chain)return ue(t);let s=await new Ke(t).getChainInfo(i.chain,{ttl:_r.OneWeek});if(!s)throw new Error(`WarpActionExecutor: Chain info not found for ${i.chain}`);return s}static getChainEntrypoint(t,i){let s="warp-sdk",u="api";return i==="devnet"?new ct.DevnetEntrypoint(t.apiUrl,u,s):i==="testnet"?new ct.TestnetEntrypoint(t.apiUrl,u,s):new ct.MainnetEntrypoint(t.apiUrl,u,s)}};var Sr=class{constructor(t){this.pendingBrand={protocol:He("brand"),name:"",description:"",logo:""};this.config=t}createInscriptionTransaction(t){if(!this.config.user?.wallet)throw new Error("BrandBuilder: user address not set");let i=ue(this.config),s=new Qe.TransactionsFactoryConfig({chainID:i.chainId}),u=new Qe.TransferTransactionsFactory({config:s}),l=Qe.Address.newFromBech32(this.config.user.wallet),p=JSON.stringify(t);return u.createTransactionForNativeTokenTransfer(l,{receiver:Qe.Address.newFromBech32(this.config.user.wallet),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(p))})}async createFromRaw(t,i=!0){let s=JSON.parse(t);return i&&await this.ensureValidSchema(s),s}async createFromTransaction(t,i=!1){return await this.createFromRaw(t.data.toString(),i)}async createFromTransactionHash(t){let i=ue(this.config),u=ee.getChainEntrypoint(i,this.config.env).createNetworkProvider();try{let l=await u.getTransaction(t);return this.createFromTransaction(l)}catch(l){return console.error("BrandBuilder: Error creating from transaction hash",l),null}}setName(t){return this.pendingBrand.name=t,this}setDescription(t){return this.pendingBrand.description=t,this}setLogo(t){return this.pendingBrand.logo=t,this}setUrls(t){return this.pendingBrand.urls=t,this}setColors(t){return this.pendingBrand.colors=t,this}setCta(t){return this.pendingBrand.cta=t,this}async build(){return this.ensure(this.pendingBrand.name,"name is required"),this.ensure(this.pendingBrand.description,"description is required"),this.ensure(this.pendingBrand.logo,"logo is required"),await this.ensureValidSchema(this.pendingBrand),this.pendingBrand}ensure(t,i){if(!t)throw new Error(`Warp: ${i}`)}async ensureValidSchema(t){let i=this.config.schema?.brand||ce.LatestBrandSchemaUrl,u=await(await fetch(i)).json(),l=new Ki.default,p=l.compile(u);if(!p(t))throw new Error(`BrandBuilder: schema validation failed: ${l.errorsText(p.errors)}`)}};var D=require("@multiversx/sdk-core/out"),Ss=(c,t)=>c?D.OptionValue.newProvided(c):t?D.OptionValue.newMissingTyped(t):D.OptionValue.newMissing(),Es=(c,t)=>c?new D.OptionalValue(c.getType(),c):t?new D.OptionalValue(t):D.OptionalValue.newMissing(),As=c=>{if(c.length===0)throw new Error("Cannot create a list from an empty array");let t=c[0].getType();return new D.List(t,c)},Is=c=>D.VariadicValue.fromItems(...c),Ts=c=>{let t=c.map(i=>i.getType());return new D.CompositeValue(new D.CompositeType(...t),c)},ks=c=>D.StringValue.fromUTF8(c),Ps=c=>new D.U8Value(c),Rs=c=>new D.U16Value(c),Ns=c=>new D.U32Value(c),Vs=c=>new D.U64Value(c),Os=c=>new D.BigUIntValue(BigInt(c)),Ws=c=>new D.BooleanValue(c),Bs=c=>new D.AddressValue(D.Address.newFromBech32(c)),Fs=c=>new D.TokenIdentifierValue(c),Ls=c=>D.BytesValue.fromHex(c),Ms=c=>new D.Struct(new D.StructType("EsdtTokenPayment",[new D.FieldDefinition("token_identifier","",new D.TokenIdentifierType),new D.FieldDefinition("token_nonce","",new D.U64Type),new D.FieldDefinition("amount","",new D.BigUIntType)]),[new D.Field(new D.TokenIdentifierValue(c.token.identifier),"token_identifier"),new D.Field(new D.U64Value(BigInt(c.token.nonce)),"token_nonce"),new D.Field(new D.BigUIntValue(BigInt(c.amount)),"amount")]),Ds=c=>new D.CodeMetadataValue(D.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(c,"hex")))),Us=()=>new D.NothingValue;var lt=require("@multiversx/sdk-core");var Rt=class{constructor(t){this.cache=new We;this.config=t}createInscriptionTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpBuilder: user address not set");let i=ue(this.config),s=new lt.TransactionsFactoryConfig({chainID:i.chainId}),u=new lt.TransferTransactionsFactory({config:s}),l={protocol:He("abi"),content:t},p=lt.Address.newFromBech32(this.config.user.wallet),f=JSON.stringify(l),b=u.createTransactionForTransfer(p,{receiver:p,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(f))});return b.gasLimit=b.gasLimit+BigInt(2e6),b}async createFromRaw(t){return JSON.parse(t)}async createFromTransaction(t){let i=await this.createFromRaw(t.data.toString());return i.meta={hash:t.hash,creator:t.sender.bech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},i}async createFromTransactionHash(t,i){let s=Ce.WarpAbi(t);if(i){let f=this.cache.get(s);if(f)return me.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${t}`),f}let u=ue(this.config),p=ee.getChainEntrypoint(u,this.config.env).createNetworkProvider();try{let f=await p.getTransaction(t),b=await this.createFromTransaction(f);return i&&i.ttl&&b&&this.cache.set(s,b,i.ttl),b}catch(f){return console.error("WarpAbiBuilder: Error creating from transaction hash",f),null}}};var ne=require("@multiversx/sdk-core");var xt=require("@multiversx/sdk-core/out");var C=require("@multiversx/sdk-core/out");var Qi=new RegExp(`${q.ArgParamsSeparator}(.*)`),Je=class{nativeToString(t,i){return t==="esdt"&&i instanceof C.TokenTransfer?`esdt:${i.token.identifier}|${i.token.nonce.toString()}|${i.amount.toString()}`:`${t}:${i?.toString()??""}`}typedToString(t){if(t.hasClassOrSuperclass(C.OptionValue.ClassName))return t.isSet()?`option:${this.typedToString(t.getTypedValue())}`:"option:null";if(t.hasClassOrSuperclass(C.OptionalValue.ClassName))return t.isSet()?`optional:${this.typedToString(t.getTypedValue())}`:"optional:null";if(t.hasClassOrSuperclass(C.List.ClassName)){let i=t.getItems(),u=i.map(p=>this.typedToString(p).split(q.ArgParamsSeparator)[0])[0],l=i.map(p=>this.typedToString(p).split(q.ArgParamsSeparator)[1]);return`list:${u}:${l.join(",")}`}if(t.hasClassOrSuperclass(C.VariadicValue.ClassName)){let i=t.getItems(),u=i.map(p=>this.typedToString(p).split(q.ArgParamsSeparator)[0])[0],l=i.map(p=>this.typedToString(p).split(q.ArgParamsSeparator)[1]);return`variadic:${u}:${l.join(",")}`}if(t.hasClassOrSuperclass(C.CompositeValue.ClassName)){let i=t.getItems(),s=i.map(f=>this.typedToString(f).split(q.ArgParamsSeparator)[0]),u=i.map(f=>this.typedToString(f).split(q.ArgParamsSeparator)[1]),l=s.join(q.ArgCompositeSeparator),p=u.join(q.ArgCompositeSeparator);return`composite(${l}):${p}`}if(t.hasClassOrSuperclass(C.BigUIntValue.ClassName)||t.getType().getName()==="BigUint")return`biguint:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(C.U8Value.ClassName))return`uint8:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(C.U16Value.ClassName))return`uint16:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(C.U32Value.ClassName))return`uint32:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(C.U64Value.ClassName))return`uint64:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(C.StringValue.ClassName))return`string:${t.valueOf()}`;if(t.hasClassOrSuperclass(C.BooleanValue.ClassName))return`bool:${t.valueOf()}`;if(t.hasClassOrSuperclass(C.AddressValue.ClassName))return`address:${t.valueOf().bech32()}`;if(t.hasClassOrSuperclass(C.TokenIdentifierValue.ClassName))return`token:${t.valueOf()}`;if(t.hasClassOrSuperclass(C.BytesValue.ClassName))return`hex:${t.valueOf().toString("hex")}`;if(t.hasClassOrSuperclass(C.CodeMetadataValue.ClassName))return`codemeta:${t.valueOf().toBuffer().toString("hex")}`;if(t.getType().getName()==="EsdtTokenPayment"){let i=t.getFieldValue("token_identifier").valueOf(),s=t.getFieldValue("token_nonce").valueOf(),u=t.getFieldValue("amount").valueOf();return`esdt:${i}|${s}|${u}`}throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${t.getClassName()}`)}typedToNative(t){let i=this.typedToString(t);return this.stringToNative(i)}nativeToTyped(t,i){let s=this.nativeToString(t,i);return this.stringToTyped(s)}nativeToType(t){if(t.startsWith("composite")){let i=t.match(/\(([^)]+)\)/)?.[1];return new C.CompositeType(...i.split(q.ArgCompositeSeparator).map(s=>this.nativeToType(s)))}if(t==="string")return new C.StringType;if(t==="uint8")return new C.U8Type;if(t==="uint16")return new C.U16Type;if(t==="uint32")return new C.U32Type;if(t==="uint64")return new C.U64Type;if(t==="biguint")return new C.BigUIntType;if(t==="bool")return new C.BooleanType;if(t==="address")return new C.AddressType;if(t==="token")return new C.TokenIdentifierType;if(t==="hex")return new C.BytesType;if(t==="codemeta")return new C.CodeMetadataType;if(t==="esdt"||t==="nft")return new C.StructType("EsdtTokenPayment",[new C.FieldDefinition("token_identifier","",new C.TokenIdentifierType),new C.FieldDefinition("token_nonce","",new C.U64Type),new C.FieldDefinition("amount","",new C.BigUIntType)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${t}`)}stringToNative(t){let i=t.split(q.ArgParamsSeparator),s=i[0],u=i.slice(1).join(q.ArgParamsSeparator);if(s==="null")return[s,null];if(s==="option"){let[l,p]=u.split(q.ArgParamsSeparator);return[`option:${l}`,p||null]}else if(s==="optional"){let[l,p]=u.split(q.ArgParamsSeparator);return[`optional:${l}`,p||null]}else if(s==="list"){let l=u.split(q.ArgParamsSeparator),p=l.slice(0,-1).join(q.ArgParamsSeparator),f=l[l.length-1],x=(f?f.split(","):[]).map(S=>this.stringToNative(`${p}:${S}`)[1]);return[`list:${p}`,x]}else if(s==="variadic"){let l=u.split(q.ArgParamsSeparator),p=l.slice(0,-1).join(q.ArgParamsSeparator),f=l[l.length-1],x=(f?f.split(","):[]).map(S=>this.stringToNative(`${p}:${S}`)[1]);return[`variadic:${p}`,x]}else if(s.startsWith("composite")){let l=s.match(/\(([^)]+)\)/)?.[1]?.split(q.ArgCompositeSeparator),f=u.split(q.ArgCompositeSeparator).map((b,x)=>this.stringToNative(`${l[x]}:${b}`)[1]);return[s,f]}else{if(s==="string")return[s,u];if(s==="uint8"||s==="uint16"||s==="uint32")return[s,Number(u)];if(s==="uint64"||s==="biguint")return[s,BigInt(u||0)];if(s==="bool")return[s,u==="true"];if(s==="address")return[s,u];if(s==="token")return[s,u];if(s==="hex")return[s,u];if(s==="codemeta")return[s,u];if(s==="esdt"){let[l,p,f]=u.split(q.ArgCompositeSeparator);return[s,new C.TokenTransfer({token:new C.Token({identifier:l,nonce:BigInt(p)}),amount:BigInt(f)})]}}throw new Error(`WarpArgSerializer (stringToNative): Unsupported input type: ${s}`)}stringToTyped(t){let[i,s]=t.split(/:(.*)/,2);if(i==="null"||i===null)return new C.NothingValue;if(i==="option"){let u=this.stringToTyped(s);return u instanceof C.NothingValue?C.OptionValue.newMissingTyped(u.getType()):C.OptionValue.newProvided(u)}if(i==="optional"){let u=this.stringToTyped(s);return u instanceof C.NothingValue?C.OptionalValue.newMissing():new C.OptionalValue(u.getType(),u)}if(i==="list"){let[u,l]=s.split(Qi,2),f=l.split(",").map(b=>this.stringToTyped(`${u}:${b}`));return new C.List(this.nativeToType(u),f)}if(i==="variadic"){let[u,l]=s.split(Qi,2),f=l.split(",").map(b=>this.stringToTyped(`${u}:${b}`));return new C.VariadicValue(new C.VariadicType(this.nativeToType(u)),f)}if(i.startsWith("composite")){let u=i.match(/\(([^)]+)\)/)?.[1],l=s.split(q.ArgCompositeSeparator),p=u.split(q.ArgCompositeSeparator),f=l.map((x,S)=>this.stringToTyped(`${p[S]}:${x}`)),b=f.map(x=>x.getType());return new C.CompositeValue(new C.CompositeType(...b),f)}if(i==="string")return s?C.StringValue.fromUTF8(s):new C.NothingValue;if(i==="uint8")return s?new C.U8Value(Number(s)):new C.NothingValue;if(i==="uint16")return s?new C.U16Value(Number(s)):new C.NothingValue;if(i==="uint32")return s?new C.U32Value(Number(s)):new C.NothingValue;if(i==="uint64")return s?new C.U64Value(BigInt(s)):new C.NothingValue;if(i==="biguint")return s?new C.BigUIntValue(BigInt(s)):new C.NothingValue;if(i==="bool")return s?new C.BooleanValue(typeof s=="boolean"?s:s==="true"):new C.NothingValue;if(i==="address")return s?new C.AddressValue(C.Address.newFromBech32(s)):new C.NothingValue;if(i==="token")return s?new C.TokenIdentifierValue(s):new C.NothingValue;if(i==="hex")return s?C.BytesValue.fromHex(s):new C.NothingValue;if(i==="codemeta")return new C.CodeMetadataValue(C.CodeMetadata.newFromBytes(Uint8Array.from(Buffer.from(s,"hex"))));if(i==="esdt"){let u=s.split(q.ArgCompositeSeparator);return new C.Struct(this.nativeToType("esdt"),[new C.Field(new C.TokenIdentifierValue(u[0]),"token_identifier"),new C.Field(new C.U64Value(BigInt(u[1])),"token_nonce"),new C.Field(new C.BigUIntValue(BigInt(u[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${i}`)}typeToString(t){if(t instanceof C.OptionType)return"option:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof C.OptionalType)return"optional:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof C.ListType)return"list:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof C.VariadicType)return"variadic:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof C.StringType)return"string";if(t instanceof C.U8Type)return"uint8";if(t instanceof C.U16Type)return"uint16";if(t instanceof C.U32Type)return"uint32";if(t instanceof C.U64Type)return"uint64";if(t instanceof C.BigUIntType)return"biguint";if(t instanceof C.BooleanType)return"bool";if(t instanceof C.AddressType)return"address";if(t instanceof C.TokenIdentifierType)return"token";if(t instanceof C.BytesType)return"hex";if(t instanceof C.CodeMetadataType)return"codemeta";if(t instanceof C.StructType&&t.getClassName()==="EsdtTokenPayment")return"esdt";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${t.getClassName()}`)}};var ko=async(c,t)=>{if(typeof window>"u"){let i;try{i=On().VM}catch{throw new Error("The 'vm2' package is required for transform execution in Node.js environments. Please install it with 'npm install vm2', or use this library in a browser environment.")}let s=new i({timeout:1e3,sandbox:{input:t},eval:!1,wasm:!1});return c.trim().startsWith("(")&&c.includes("=>")?s.run(`(${c})(input)`):null}return new Promise((i,s)=>{try{let u=new Blob([`
|
|
3
26
|
self.onmessage = function(e) {
|
|
4
27
|
try {
|
|
5
28
|
const input = e.data;
|
|
6
|
-
const result = (${
|
|
29
|
+
const result = (${c})(input);
|
|
7
30
|
self.postMessage({ result });
|
|
8
31
|
} catch (error) {
|
|
9
32
|
self.postMessage({ error: error.toString() });
|
|
10
33
|
}
|
|
11
34
|
};
|
|
12
|
-
`],{type:"application/javascript"}),i=URL.createObjectURL(n),s=new Worker(i);s.onmessage=function(c){c.data.error?r(new Error(c.data.error)):e(c.data.result),s.terminate(),URL.revokeObjectURL(i)},s.onerror=function(c){r(new Error(`Error in transform: ${c.message}`)),s.terminate(),URL.revokeObjectURL(i)},s.postMessage(t)}catch(n){return r(n)}})},lt=a=>{if(a==="out")return 1;let t=a.match(/^out\[(\d+)\]/);return t?parseInt(t[1],10):(a.startsWith("out.")||a.startsWith("event."),null)},te=(a,t)=>t.reduce((e,r)=>e&&e[r]!==void 0?e[r]:null,a),ft=async(a,t)=>{if(!a.results)return t;let e={...t},r=Object.entries(a.results).filter(([,n])=>n.startsWith(f.Transform.Prefix)).map(([n,i])=>({key:n,code:i.substring(f.Transform.Prefix.length)}));for(let{key:n,code:i}of r)try{e[n]=await Zt(i,e)}catch(s){console.error(`Transform error for result '${n}':`,s),e[n]=null}return e},Wt=async(a,t,e,r,n=1)=>{let i=[],s={};if(!t.results||!e.abi||e.type!=="contract")return{values:i,results:s};let c=await a.getAbiForAction(e),u=new Q.TransactionEventsParser({abi:c}),d=new Q.SmartContractTransactionsOutcomeParser({abi:c}).parseExecute({transactionOnNetwork:r,function:e.func||void 0});for(let[g,T]of Object.entries(t.results)){if(T.startsWith(f.Transform.Prefix))continue;let W=lt(T);if(W!==null&&W!==n){s[g]=null;continue}let[B,h,w]=T.split(".");if(B==="event"){if(!h||isNaN(Number(w)))continue;let b=Number(w),A=(0,Q.findEventsByFirstTopic)(r,h),R=u.parseEvents({events:A})[0],E=Object.values(R)[b]||null;i.push(E),s[g]=E&&E.valueOf()}else if(B==="out"||B.startsWith("out[")){if(!h)continue;let b=Number(h),A=d.values[b-1]||null;i.push(A),s[g]=A&&A.valueOf()}}return{values:i,results:await ft(t,s)}},bt=async(a,t,e=1)=>{let r=new _,n=t.map(u=>r.typedToString(u)),i=t.map(u=>r.typedToNative(u)[1]),s={};if(!a.results)return{values:n,results:s};let c=u=>{let p=u.split(".").slice(1).map(g=>parseInt(g)-1);if(p.length===0)return;let d=i[p[0]];for(let g=1;g<p.length;g++){if(d==null)return;d=d[p[g]]}return d};for(let[u,p]of Object.entries(a.results)){if(p.startsWith(f.Transform.Prefix))continue;let d=lt(p);if(d!==null&&d!==e){s[u]=null;continue}(p.startsWith("out.")||p==="out"||p.startsWith("out["))&&(s[u]=c(p)||null)}return{values:n,results:await ft(a,s)}},It=async(a,t,e=1)=>{let r=[],n={};for(let[i,s]of Object.entries(a.results||{})){if(s.startsWith(f.Transform.Prefix))continue;let c=lt(s);if(c!==null&&c!==e){n[i]=null;continue}let[u,...p]=s.split(".");if(u!=="out"&&!u.startsWith("out["))continue;let d=p.length===0?t?.data||t:te(t,p);r.push(d),n[i]=d}return{values:r,results:await ft(a,n)}};var ee=[{id:"EGLD",name:"eGold",decimals:18},{id:"EGLD-000000",name:"eGold",decimals:18}],vt=a=>ee.find(t=>t.id===a)||null;var et=class{constructor(t){this.config=t}async getContract(t,e){try{let i=await y.getChainEntrypoint(e,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${t}`);return{address:t,owner:i.ownerAddress,verified:i.isVerified||!1}}catch(r){return console.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(t,e){try{let i=await y.getChainEntrypoint(e,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${t}/verification`);return{codeHash:i.codeHash,abi:i.source.abi}}catch(r){return console.error("WarpContractLoader: getVerificationInfo error",r),null}}};var dt=class{constructor(t){if(!t.currentUrl)throw new Error("WarpActionExecutor: currentUrl config not set");this.config=t,this.url=new URL(t.currentUrl),this.serializer=new _,this.contractLoader=new et(t)}async createTransactionForExecute(t,e,r){let n=M(t,e);if(!this.config.user?.wallet)throw new Error("WarpActionExecutor: user address not set");let i=C.Address.newFromBech32(this.config.user.wallet),s=await y.getChainInfoForAction(this.config,n),c=new C.TransactionsFactoryConfig({chainID:s.chainId}),{destination:u,args:p,value:d,transfers:g,data:T}=await this.getTxComponentsFromInputs(s,n,r,i),W=p.map(B=>this.serializer.stringToTyped(B));if(n.type==="transfer")return new C.TransferTransactionsFactory({config:c}).createTransactionForTransfer(i,{receiver:u,nativeAmount:d,tokenTransfers:g,data:T?new Uint8Array(T):void 0});if(n.type==="contract"&&u.isSmartContract())return new C.SmartContractTransactionsFactory({config:c}).createTransactionForExecute(i,{contract:u,function:"func"in n&&n.func||"",gasLimit:"gasLimit"in n?BigInt(n.gasLimit||0):0n,arguments:W,tokenTransfers:g,nativeTransferAmount:d});throw n.type==="query"?new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead"):n.type==="collect"?new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead"):new Error(`WarpActionExecutor: Invalid action type (${n.type})`)}async getTransactionExecutionResults(t,e,r){let n=M(t,e),i=await U.apply(this.config,t),{values:s,results:c}=await Wt(this,i,n,r,e),u=y.getNextInfo(this.config,i,e,c),p=this.getPreparedMessages(i,c);return{success:r.status.isSuccessful(),warp:i,action:e,user:this.config.user?.wallet||null,txHash:r.hash,next:u,values:s,results:c,messages:p}}async executeQuery(t,e,r){let n=M(t,e);if(!n)throw new Error("WarpActionExecutor: Action not found");if(!n.func)throw new Error("WarpActionExecutor: Function not found");let i=await y.getChainInfoForAction(this.config,n),s=await U.apply(this.config,t),c=await this.getAbiForAction(n),{args:u}=await this.getTxComponentsFromInputs(i,n,r),p=u.map(x=>this.serializer.stringToTyped(x)),d=y.getChainEntrypoint(i,this.config.env),g=C.Address.newFromBech32(n.address),T=d.createSmartContractController(c),W=T.createQuery({contract:g,function:n.func,arguments:p}),B=await T.runQuery(W),h=B.returnCode==="ok",w=new C.ArgSerializer,b=c.getEndpoint(B.function),A=B.returnDataParts.map(x=>Buffer.from(x)),R=w.buffersToValues(A,b.output),{values:E,results:q}=await bt(s,R,e),at=y.getNextInfo(this.config,s,e,q);return{success:h,warp:s,action:e,user:this.config.user?.wallet||null,txHash:null,next:at,values:E,results:q,messages:this.getPreparedMessages(s,q)}}async executeCollect(t,e,r,n){let i=M(t,e);if(!i)throw new Error("WarpActionExecutor: Action not found");let s=await y.getChainInfoForAction(this.config,i),c=await U.apply(this.config,t),u=await this.getResolvedInputs(s,i,r),p=this.getModifiedInputs(u),d=h=>{if(!h.value)return null;let w=this.serializer.stringToNative(h.value)[1];if(h.input.type==="biguint")return w.toString();if(h.input.type==="esdt"){let b=w;return{token:b.token.identifier,nonce:b.token.nonce.toString(),amount:b.amount.toString()}}else return w},g=new Headers;g.set("Content-Type","application/json"),g.set("Accept","application/json"),Object.entries(i.destination.headers||{}).forEach(([h,w])=>{g.set(h,w)});let T=Object.fromEntries(p.map(h=>[h.input.as||h.input.name,d(h)])),W=i.destination.method||"GET",B=W==="GET"?void 0:JSON.stringify({inputs:T,meta:n});try{let h=await fetch(i.destination.url,{method:W,headers:g,body:B}),w=await h.json(),{values:b,results:A}=await It(c,w,e),R=y.getNextInfo(this.config,c,e,A);return{success:h.ok,warp:c,action:e,user:this.config.user?.wallet||null,txHash:null,next:R,values:b,results:A,messages:this.getPreparedMessages(c,A)}}catch(h){return console.error(h),{success:!1,warp:c,action:e,user:this.config.user?.wallet||null,txHash:null,next:null,values:[],results:{},messages:{}}}}async getTxComponentsFromInputs(t,e,r,n){let i=await this.getResolvedInputs(t,e,r),s=this.getModifiedInputs(i),c=s.find(x=>x.input.position==="receiver")?.value,u="address"in e?e.address:null,p=c?.split(":")[1]||u||n?.toBech32();if(!p)throw new Error("WarpActionExecutor: Destination/Receiver not provided");let d=C.Address.newFromBech32(p),g=this.getPreparedArgs(e,s),T=s.find(x=>x.input.position==="value")?.value||null,W="value"in e?e.value:null,B=BigInt(T?.split(":")[1]||W||0),h=s.filter(x=>x.input.position==="transfer"&&x.value).map(x=>x.value),b=[...("transfers"in e?e.transfers:[])?.map(this.toTypedTransfer)||[],...h?.map(x=>this.serializer.stringToNative(x)[1])||[]],A=s.find(x=>x.input.position==="data")?.value,R="data"in e?e.data||"":null,E=A||R||null,q=E?this.serializer.stringToTyped(E).valueOf():null,at=q?Buffer.from(q):null;return{destination:d,args:g,value:B,transfers:b,data:at}}async getResolvedInputs(t,e,r){let n=e.inputs||[],i=await Promise.all(r.map(c=>this.preprocessInput(t,c))),s=(c,u)=>{if(c.source==="query"){let p=this.url.searchParams.get(c.name);return p?this.serializer.nativeToString(c.type,p):null}else return c.source===f.Source.UserWallet?this.config.user?.wallet?this.serializer.nativeToString("address",this.config.user.wallet):null:i[u]||null};return n.map((c,u)=>({input:c,value:s(c,u)}))}getModifiedInputs(t){return t.map((e,r)=>{if(e.input.modifier?.startsWith("scale:")){let[,n]=e.input.modifier.split(":");if(isNaN(Number(n))){let i=Number(t.find(u=>u.input.name===n)?.value?.split(":")[1]);if(!i)throw new Error(`WarpActionExecutor: Exponent value not found for input ${n}`);let s=e.value?.split(":")[1];if(!s)throw new Error("WarpActionExecutor: Scalable value not found");let c=G(s,+i);return{...e,value:`${e.input.type}:${c}`}}else{let i=e.value?.split(":")[1];if(!i)throw new Error("WarpActionExecutor: Scalable value not found");let s=G(i,+n);return{...e,value:`${e.input.type}:${s}`}}}else return e})}async preprocessInput(t,e){try{let[r,n]=e.split(f.ArgParamsSeparator,2);if(r==="esdt"){let[i,s,c,u]=n.split(f.ArgCompositeSeparator);if(u)return e;let p=new C.Token({identifier:i,nonce:BigInt(s)});if(!new C.TokenComputer().isFungible(p))return e;let T=vt(i)?.decimals;if(T||(T=(await(await fetch(`${t.apiUrl}/tokens/${i}`)).json()).decimals),!T)throw new Error(`WarpActionExecutor: Decimals not found for token ${i}`);let W=new C.TokenTransfer({token:p,amount:G(c,T)});return this.serializer.nativeToString(r,W)+f.ArgCompositeSeparator+T}return e}catch{return e}}async getAbiForAction(t){if(t.abi)return await this.fetchAbi(t);let e=I(this.config),r=await this.contractLoader.getVerificationInfo(t.address,e);if(!r)throw new Error("WarpActionExecutor: Verification info not found");return C.AbiRegistry.create(r.abi)}getPreparedArgs(t,e){let r="args"in t?t.args||[]:[];return e.forEach(({input:n,value:i})=>{if(!i||!n.position?.startsWith("arg:"))return;let s=Number(n.position.split(":")[1])-1;r.splice(s,0,i)}),r}getPreparedMessages(t,e){let r=Object.entries(t.messages||{}).map(([n,i])=>[n,z(i,e)]);return Object.fromEntries(r)}async fetchAbi(t){if(!t.abi)throw new Error("WarpActionExecutor: ABI not found");if(t.abi.startsWith(f.IdentifierType.Hash)){let e=new tt(this.config),r=t.abi.split(f.IdentifierParamSeparator)[1],n=await e.createFromTransactionHash(r);if(!n)throw new Error(`WarpActionExecutor: ABI not found for hash: ${t.abi}`);return C.AbiRegistry.create(n.content)}else{let r=await(await fetch(t.abi)).json();return C.AbiRegistry.create(r)}}toTypedTransfer(t){return new C.TokenTransfer({token:new C.Token({identifier:t.token,nonce:BigInt(t.nonce||0)}),amount:BigInt(t.amount||0)})}};var gt=class{constructor(t){this.config=t}async search(t,e,r){if(!this.config.index?.url)throw new Error("WarpIndex: Index URL is not set");try{let n=await fetch(this.config.index?.url,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.index?.apiKey}`,...r},body:JSON.stringify({[this.config.index?.searchParamName||"search"]:t,...e})});if(!n.ok)throw new Error(`WarpIndex: search failed with status ${n.status}`);return(await n.json()).hits}catch(n){throw console.error("WarpIndex: Error searching for warps: ",n),n}}};0&&(module.exports={BrandBuilder,CacheKey,CacheTtl,Config,WarpAbiBuilder,WarpActionExecutor,WarpArgSerializer,WarpBuilder,WarpCache,WarpConstants,WarpContractLoader,WarpIndex,WarpInterpolator,WarpLink,WarpProtocolVersions,WarpRegistry,WarpUtils,WarpValidator,address,biguint,boolean,codemeta,composite,esdt,getChainExplorerUrl,getLatestProtocolIdentifier,getMainChainInfo,getWarpActionByIndex,hex,list,nothing,option,optional,replacePlaceholders,shiftBigintBy,string,toPreviewText,toTypedChainInfo,token,u16,u32,u64,u8,variadic});
|
|
35
|
+
`],{type:"application/javascript"}),l=URL.createObjectURL(u),p=new Worker(l);p.onmessage=function(f){f.data.error?s(new Error(f.data.error)):i(f.data.result),p.terminate(),URL.revokeObjectURL(l)},p.onerror=function(f){s(new Error(`Error in transform: ${f.message}`)),p.terminate(),URL.revokeObjectURL(l)},p.postMessage(t)}catch(u){return s(u)}})},pi=c=>{if(c==="out")return 1;let t=c.match(/^out\[(\d+)\]/);return t?parseInt(t[1],10):(c.startsWith("out.")||c.startsWith("event."),null)},Po=(c,t)=>t.reduce((i,s)=>i&&i[s]!==void 0?i[s]:null,c),hi=async(c,t)=>{if(!c.results)return t;let i={...t},s=Object.entries(c.results).filter(([,u])=>u.startsWith(q.Transform.Prefix)).map(([u,l])=>({key:u,code:l.substring(q.Transform.Prefix.length)}));for(let{key:u,code:l}of s)try{i[u]=await ko(l,i)}catch(p){console.error(`Transform error for result '${u}':`,p),i[u]=null}return i},Wn=async(c,t,i,s,u=1)=>{let l=[],p={};if(!t.results||!i.abi||i.type!=="contract")return{values:l,results:p};let f=await c.getAbiForAction(i),b=new xt.TransactionEventsParser({abi:f}),S=new xt.SmartContractTransactionsOutcomeParser({abi:f}).parseExecute({transactionOnNetwork:s,function:i.func||void 0});for(let[T,N]of Object.entries(t.results)){if(N.startsWith(q.Transform.Prefix))continue;let O=pi(N);if(O!==null&&O!==u){p[T]=null;continue}let[W,y,m]=N.split(".");if(W==="event"){if(!y||isNaN(Number(m)))continue;let d=Number(m),g=(0,xt.findEventsByFirstTopic)(s,y),_=b.parseEvents({events:g})[0],a=Object.values(_)[d]||null;l.push(a),p[T]=a&&a.valueOf()}else if(W==="out"||W.startsWith("out[")){if(!y)continue;let d=Number(y),g=S.values[d-1]||null;m&&(g=g[m]||null),g&&typeof g=="object"&&(g="toFixed"in g?g.toFixed():g.valueOf()),l.push(g),p[T]=g&&g.valueOf()}}return{values:l,results:await hi(t,p)}},Bn=async(c,t,i=1)=>{let s=new Je,u=t.map(b=>s.typedToString(b)),l=t.map(b=>s.typedToNative(b)[1]),p={};if(!c.results)return{values:u,results:p};let f=b=>{let x=b.split(".").slice(1).map(T=>parseInt(T)-1);if(x.length===0)return;let S=l[x[0]];for(let T=1;T<x.length;T++){if(S==null)return;S=S[x[T]]}return S};for(let[b,x]of Object.entries(c.results)){if(x.startsWith(q.Transform.Prefix))continue;let S=pi(x);if(S!==null&&S!==i){p[b]=null;continue}(x.startsWith("out.")||x==="out"||x.startsWith("out["))&&(p[b]=f(x)||null)}return{values:u,results:await hi(c,p)}},Fn=async(c,t,i=1)=>{let s=[],u={};for(let[l,p]of Object.entries(c.results||{})){if(p.startsWith(q.Transform.Prefix))continue;let f=pi(p);if(f!==null&&f!==i){u[l]=null;continue}let[b,...x]=p.split(".");if(b!=="out"&&!b.startsWith("out["))continue;let S=x.length===0?t?.data||t:Po(t,x);s.push(S),u[l]=S}return{values:s,results:await hi(c,u)}};var Ro=[{id:"EGLD",name:"eGold",decimals:18},{id:"EGLD-000000",name:"eGold",decimals:18}],Ln=c=>Ro.find(t=>t.id===c)||null;var Bt=class{constructor(t){this.config=t}async getContract(t,i){try{let l=await ee.getChainEntrypoint(i,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${t}`);return{address:t,owner:l.ownerAddress,verified:l.isVerified||!1}}catch(s){return console.error("WarpContractLoader: getContract error",s),null}}async getVerificationInfo(t,i){try{let l=await ee.getChainEntrypoint(i,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${t}/verification`);return{codeHash:l.codeHash,abi:l.source.abi}}catch(s){return console.error("WarpContractLoader: getVerificationInfo error",s),null}}};var fi=class{constructor(t){if(!t.currentUrl)throw new Error("WarpActionExecutor: currentUrl config not set");this.config=t,this.url=new URL(t.currentUrl),this.serializer=new Je,this.contractLoader=new Bt(t)}async createTransactionForExecute(t,i,s){let u=ot(t,i);if(!this.config.user?.wallet)throw new Error("WarpActionExecutor: user address not set");let l=ne.Address.newFromBech32(this.config.user.wallet),p=await ee.getChainInfoForAction(this.config,u),f=new ne.TransactionsFactoryConfig({chainID:p.chainId}),{destination:b,args:x,value:S,transfers:T,data:N}=await this.getTxComponentsFromInputs(p,u,s,l),O=x.map(W=>this.serializer.stringToTyped(W));if(u.type==="transfer")return new ne.TransferTransactionsFactory({config:f}).createTransactionForTransfer(l,{receiver:b,nativeAmount:S,tokenTransfers:T,data:N?new Uint8Array(N):void 0});if(u.type==="contract"&&b.isSmartContract())return new ne.SmartContractTransactionsFactory({config:f}).createTransactionForExecute(l,{contract:b,function:"func"in u&&u.func||"",gasLimit:"gasLimit"in u?BigInt(u.gasLimit||0):0n,arguments:O,tokenTransfers:T,nativeTransferAmount:S});throw u.type==="query"?new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead"):u.type==="collect"?new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead"):new Error(`WarpActionExecutor: Invalid action type (${u.type})`)}async getTransactionExecutionResults(t,i,s){let u=ot(t,i),l=await Be.apply(this.config,t),{values:p,results:f}=await Wn(this,l,u,s,i),b=ee.getNextInfo(this.config,l,i,f),x=this.getPreparedMessages(l,f);return{success:s.status.isSuccessful(),warp:l,action:i,user:this.config.user?.wallet||null,txHash:s.hash,next:b,values:p,results:f,messages:x}}async executeQuery(t,i,s){let u=ot(t,i);if(!u)throw new Error("WarpActionExecutor: Action not found");if(!u.func)throw new Error("WarpActionExecutor: Function not found");let l=await ee.getChainInfoForAction(this.config,u),p=await Be.apply(this.config,t),f=await this.getAbiForAction(u),{args:b}=await this.getTxComponentsFromInputs(l,u,s),x=b.map(I=>this.serializer.stringToTyped(I)),S=ee.getChainEntrypoint(l,this.config.env),T=ne.Address.newFromBech32(u.address),N=S.createSmartContractController(f),O=N.createQuery({contract:T,function:u.func,arguments:x}),W=await N.runQuery(O),y=W.returnCode==="ok",m=new ne.ArgSerializer,d=f.getEndpoint(W.function),g=W.returnDataParts.map(I=>Buffer.from(I)),_=m.buffersToValues(g,d.output),{values:a,results:A}=await Bn(p,_,i),V=ee.getNextInfo(this.config,p,i,A);return{success:y,warp:p,action:i,user:this.config.user?.wallet||null,txHash:null,next:V,values:a,results:A,messages:this.getPreparedMessages(p,A)}}async executeCollect(t,i,s,u){let l=ot(t,i);if(!l)throw new Error("WarpActionExecutor: Action not found");let p=await ee.getChainInfoForAction(this.config,l),f=await Be.apply(this.config,t),b=await this.getResolvedInputs(p,l,s),x=this.getModifiedInputs(b),S=y=>{if(!y.value)return null;let m=this.serializer.stringToNative(y.value)[1];if(y.input.type==="biguint")return m.toString();if(y.input.type==="esdt"){let d=m;return{token:d.token.identifier,nonce:d.token.nonce.toString(),amount:d.amount.toString()}}else return m},T=new Headers;T.set("Content-Type","application/json"),T.set("Accept","application/json"),Object.entries(l.destination.headers||{}).forEach(([y,m])=>{T.set(y,m)});let N=Object.fromEntries(x.map(y=>[y.input.as||y.input.name,S(y)])),O=l.destination.method||"GET",W=O==="GET"?void 0:JSON.stringify({inputs:N,meta:u});try{let y=await fetch(l.destination.url,{method:O,headers:T,body:W}),m=await y.json(),{values:d,results:g}=await Fn(f,m,i),_=ee.getNextInfo(this.config,f,i,g);return{success:y.ok,warp:f,action:i,user:this.config.user?.wallet||null,txHash:null,next:_,values:d,results:g,messages:this.getPreparedMessages(f,g)}}catch(y){return console.error(y),{success:!1,warp:f,action:i,user:this.config.user?.wallet||null,txHash:null,next:null,values:[],results:{},messages:{}}}}async getTxComponentsFromInputs(t,i,s,u){let l=await this.getResolvedInputs(t,i,s),p=this.getModifiedInputs(l),f=p.find(I=>I.input.position==="receiver")?.value,b="address"in i?i.address:null,x=f?.split(":")[1]||b||u?.toBech32();if(!x)throw new Error("WarpActionExecutor: Destination/Receiver not provided");let S=ne.Address.newFromBech32(x),T=this.getPreparedArgs(i,p),N=p.find(I=>I.input.position==="value")?.value||null,O="value"in i?i.value:null,W=BigInt(N?.split(":")[1]||O||0),y=p.filter(I=>I.input.position==="transfer"&&I.value).map(I=>I.value),d=[...("transfers"in i?i.transfers:[])?.map(this.toTypedTransfer)||[],...y?.map(I=>this.serializer.stringToNative(I)[1])||[]],g=p.find(I=>I.input.position==="data")?.value,_="data"in i?i.data||"":null,a=g||_||null,A=a?this.serializer.stringToTyped(a).valueOf():null,V=A?Buffer.from(A):null;return{destination:S,args:T,value:W,transfers:d,data:V}}async getResolvedInputs(t,i,s){let u=i.inputs||[],l=await Promise.all(s.map(f=>this.preprocessInput(t,f))),p=(f,b)=>{if(f.source==="query"){let x=this.url.searchParams.get(f.name);return x?this.serializer.nativeToString(f.type,x):null}else return f.source===q.Source.UserWallet?this.config.user?.wallet?this.serializer.nativeToString("address",this.config.user.wallet):null:l[b]||null};return u.map((f,b)=>({input:f,value:p(f,b)}))}getModifiedInputs(t){return t.map((i,s)=>{if(i.input.modifier?.startsWith("scale:")){let[,u]=i.input.modifier.split(":");if(isNaN(Number(u))){let l=Number(t.find(b=>b.input.name===u)?.value?.split(":")[1]);if(!l)throw new Error(`WarpActionExecutor: Exponent value not found for input ${u}`);let p=i.value?.split(":")[1];if(!p)throw new Error("WarpActionExecutor: Scalable value not found");let f=St(p,+l);return{...i,value:`${i.input.type}:${f}`}}else{let l=i.value?.split(":")[1];if(!l)throw new Error("WarpActionExecutor: Scalable value not found");let p=St(l,+u);return{...i,value:`${i.input.type}:${p}`}}}else return i})}async preprocessInput(t,i){try{let[s,u]=i.split(q.ArgParamsSeparator,2);if(s==="esdt"){let[l,p,f,b]=u.split(q.ArgCompositeSeparator);if(b)return i;let x=new ne.Token({identifier:l,nonce:BigInt(p)});if(!new ne.TokenComputer().isFungible(x))return i;let N=Ln(l)?.decimals;if(N||(N=(await(await fetch(`${t.apiUrl}/tokens/${l}`)).json()).decimals),!N)throw new Error(`WarpActionExecutor: Decimals not found for token ${l}`);let O=new ne.TokenTransfer({token:x,amount:St(f,N)});return this.serializer.nativeToString(s,O)+q.ArgCompositeSeparator+N}return i}catch{return i}}async getAbiForAction(t){if(t.abi)return await this.fetchAbi(t);let i=ue(this.config),s=await this.contractLoader.getVerificationInfo(t.address,i);if(!s)throw new Error("WarpActionExecutor: Verification info not found");return ne.AbiRegistry.create(s.abi)}getPreparedArgs(t,i){let s="args"in t?t.args||[]:[];return i.forEach(({input:u,value:l})=>{if(!l||!u.position?.startsWith("arg:"))return;let p=Number(u.position.split(":")[1])-1;s.splice(p,0,l)}),s}getPreparedMessages(t,i){let s=Object.entries(t.messages||{}).map(([u,l])=>[u,Et(l,i)]);return Object.fromEntries(s)}async fetchAbi(t){if(!t.abi)throw new Error("WarpActionExecutor: ABI not found");if(t.abi.startsWith(q.IdentifierType.Hash)){let i=new Rt(this.config),s=t.abi.split(q.IdentifierParamSeparator)[1],u=await i.createFromTransactionHash(s);if(!u)throw new Error(`WarpActionExecutor: ABI not found for hash: ${t.abi}`);return ne.AbiRegistry.create(u.content)}else{let s=await(await fetch(t.abi)).json();return ne.AbiRegistry.create(s)}}toTypedTransfer(t){return new ne.TokenTransfer({token:new ne.Token({identifier:t.token,nonce:BigInt(t.nonce||0)}),amount:BigInt(t.amount||0)})}};var di=class{constructor(t){this.config=t}async search(t,i,s){if(!this.config.index?.url)throw new Error("WarpIndex: Index URL is not set");try{let u=await fetch(this.config.index?.url,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.index?.apiKey}`,...s},body:JSON.stringify({[this.config.index?.searchParamName||"search"]:t,...i})});if(!u.ok)throw new Error(`WarpIndex: search failed with status ${u.status}`);return(await u.json()).hits}catch(u){throw console.error("WarpIndex: Error searching for warps: ",u),u}}};0&&(module.exports={BrandBuilder,CacheKey,CacheTtl,Config,WarpAbiBuilder,WarpActionExecutor,WarpArgSerializer,WarpBuilder,WarpCache,WarpConstants,WarpContractLoader,WarpIndex,WarpInterpolator,WarpLink,WarpProtocolVersions,WarpRegistry,WarpUtils,WarpValidator,address,biguint,boolean,codemeta,composite,esdt,getChainExplorerUrl,getLatestProtocolIdentifier,getMainChainInfo,getWarpActionByIndex,hex,list,nothing,option,optional,replacePlaceholders,shiftBigintBy,string,toPreviewText,toTypedChainInfo,token,u16,u32,u64,u8,variadic});
|