@meshsdk/core 1.5.25 → 1.5.28
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/README.md +3 -30
- package/dist/index.d.mts +129 -0
- package/dist/index.d.ts +129 -11
- package/dist/index.js +149 -0
- package/dist/index.mjs +91 -0
- package/package.json +30 -60
- package/dist/common/constants.d.ts +0 -58
- package/dist/common/contracts/evaluator.d.ts +0 -4
- package/dist/common/contracts/fetcher.d.ts +0 -22
- package/dist/common/contracts/index.d.ts +0 -7
- package/dist/common/contracts/initiator.d.ts +0 -8
- package/dist/common/contracts/listener.d.ts +0 -3
- package/dist/common/contracts/signer.d.ts +0 -8
- package/dist/common/contracts/submitter.d.ts +0 -3
- package/dist/common/contracts/uploader.d.ts +0 -3
- package/dist/common/decorators.d.ts +0 -16
- package/dist/common/helpers/generateNonce.d.ts +0 -1
- package/dist/common/helpers/index.d.ts +0 -4
- package/dist/common/helpers/mergeSignatures.d.ts +0 -3
- package/dist/common/helpers/readPlutusData.d.ts +0 -2
- package/dist/common/helpers/readTransaction.d.ts +0 -2
- package/dist/common/types/Account.d.ts +0 -5
- package/dist/common/types/AccountInfo.d.ts +0 -7
- package/dist/common/types/Action.d.ts +0 -12
- package/dist/common/types/Asset.d.ts +0 -7
- package/dist/common/types/AssetExtended.d.ts +0 -8
- package/dist/common/types/AssetMetadata.d.ts +0 -24
- package/dist/common/types/BlockInfo.d.ts +0 -17
- package/dist/common/types/Data.d.ts +0 -4
- package/dist/common/types/DataSignature.d.ts +0 -4
- package/dist/common/types/Era.d.ts +0 -1
- package/dist/common/types/Mint.d.ts +0 -10
- package/dist/common/types/NativeScript.d.ts +0 -14
- package/dist/common/types/Network.d.ts +0 -4
- package/dist/common/types/PlutusScript.d.ts +0 -6
- package/dist/common/types/PoolParams.d.ts +0 -16
- package/dist/common/types/Protocol.d.ts +0 -22
- package/dist/common/types/Recipient.d.ts +0 -11
- package/dist/common/types/Relay.d.ts +0 -13
- package/dist/common/types/Token.d.ts +0 -2
- package/dist/common/types/TransactionInfo.d.ts +0 -11
- package/dist/common/types/UTxO.d.ts +0 -15
- package/dist/common/types/Wallet.d.ts +0 -5
- package/dist/common/types/index.d.ts +0 -22
- package/dist/common/utils/builder.d.ts +0 -18
- package/dist/common/utils/converter.d.ts +0 -27
- package/dist/common/utils/deserializer.d.ts +0 -19
- package/dist/common/utils/index.d.ts +0 -5
- package/dist/common/utils/parser.d.ts +0 -5
- package/dist/common/utils/resolver.d.ts +0 -19
- package/dist/core/CIP14.d.ts +0 -2
- package/dist/core/CIP1852.d.ts +0 -4
- package/dist/core/CIP1853.d.ts +0 -1
- package/dist/core/CIP1855.d.ts +0 -1
- package/dist/core/CIP2.d.ts +0 -4
- package/dist/core/CIP25.d.ts +0 -19
- package/dist/core/CIP27.d.ts +0 -4
- package/dist/core/CIP8.d.ts +0 -15
- package/dist/core/CPS-009.d.ts +0 -2
- package/dist/core/CSL.d.ts +0 -147
- package/dist/core/index.d.ts +0 -9
- package/dist/core.cjs +0 -8
- package/dist/core.js +0 -5995
- package/dist/providers/blockfrost.provider.d.ts +0 -46
- package/dist/providers/index.d.ts +0 -6
- package/dist/providers/infura.provider.d.ts +0 -12
- package/dist/providers/koios.provider.d.ts +0 -27
- package/dist/providers/maestro.provider.d.ts +0 -35
- package/dist/providers/ogmios.provider.d.ts +0 -12
- package/dist/providers/tango.provider.d.ts +0 -25
- package/dist/providers/yaci.provider.d.ts +0 -32
- package/dist/scripts/forge.script.d.ts +0 -8
- package/dist/scripts/index.d.ts +0 -1
- package/dist/transaction/index.d.ts +0 -2
- package/dist/transaction/meshTxBuilder/index.d.ts +0 -2
- package/dist/transaction/meshTxBuilder/meshTxBuilder.service.d.ts +0 -47
- package/dist/transaction/meshTxBuilder/meshTxBuilder.spec.d.ts +0 -1
- package/dist/transaction/meshTxBuilder/meshTxBuilderCore.d.ts +0 -321
- package/dist/transaction/meshTxBuilder/type.d.ts +0 -146
- package/dist/transaction/transaction.service.d.ts +0 -157
- package/dist/transaction/transaction.service.spec.d.ts +0 -1
- package/dist/wallet/app.service.d.ts +0 -45
- package/dist/wallet/app.service.spec.d.ts +0 -1
- package/dist/wallet/browser.service.d.ts +0 -218
- package/dist/wallet/browser.service.spec.d.ts +0 -1
- package/dist/wallet/embedded.service.d.ts +0 -21
- package/dist/wallet/embedded.service.spec.d.ts +0 -1
- package/dist/wallet/index.d.ts +0 -4
- package/dist/wallet/mesh.service.d.ts +0 -193
- package/dist/wallet/mina.service.d.ts +0 -11
- package/dist/wallet/mina.service.spec.d.ts +0 -1
package/dist/core/CSL.d.ts
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { csl } from '.';
|
|
2
|
-
export * as csl from '@emurgo/cardano-serialization-lib-nodejs';
|
|
3
|
-
export type Address = InstanceType<typeof csl.Address>;
|
|
4
|
-
export type AssetName = InstanceType<typeof csl.AssetName>;
|
|
5
|
-
export type AssetNames = InstanceType<typeof csl.AssetNames>;
|
|
6
|
-
export type Assets = InstanceType<typeof csl.Assets>;
|
|
7
|
-
export type AuxiliaryData = InstanceType<typeof csl.AuxiliaryData>;
|
|
8
|
-
export type AuxiliaryDataHash = InstanceType<typeof csl.AuxiliaryDataHash>;
|
|
9
|
-
export type AuxiliaryDataSet = InstanceType<typeof csl.AuxiliaryDataSet>;
|
|
10
|
-
export type BaseAddress = InstanceType<typeof csl.BaseAddress>;
|
|
11
|
-
export type BigInt = InstanceType<typeof csl.BigInt>;
|
|
12
|
-
export type BigNum = InstanceType<typeof csl.BigNum>;
|
|
13
|
-
export type Bip32PrivateKey = InstanceType<typeof csl.Bip32PrivateKey>;
|
|
14
|
-
export type Bip32PublicKey = InstanceType<typeof csl.Bip32PublicKey>;
|
|
15
|
-
export type Block = InstanceType<typeof csl.Block>;
|
|
16
|
-
export type BlockHash = InstanceType<typeof csl.BlockHash>;
|
|
17
|
-
export type BootstrapWitness = InstanceType<typeof csl.BootstrapWitness>;
|
|
18
|
-
export type BootstrapWitnesses = InstanceType<typeof csl.BootstrapWitnesses>;
|
|
19
|
-
export type ByronAddress = InstanceType<typeof csl.ByronAddress>;
|
|
20
|
-
export type Certificate = InstanceType<typeof csl.Certificate>;
|
|
21
|
-
export type Certificates = InstanceType<typeof csl.Certificates>;
|
|
22
|
-
export type ConstrPlutusData = InstanceType<typeof csl.ConstrPlutusData>;
|
|
23
|
-
export type CostModel = InstanceType<typeof csl.CostModel>;
|
|
24
|
-
export type Costmdls = InstanceType<typeof csl.Costmdls>;
|
|
25
|
-
export type DNSRecordAorAAAA = InstanceType<typeof csl.DNSRecordAorAAAA>;
|
|
26
|
-
export type DNSRecordSRV = InstanceType<typeof csl.DNSRecordSRV>;
|
|
27
|
-
export type DataCost = InstanceType<typeof csl.DataCost>;
|
|
28
|
-
export type DataHash = InstanceType<typeof csl.DataHash>;
|
|
29
|
-
export type DatumSource = InstanceType<typeof csl.DatumSource>;
|
|
30
|
-
export type Ed25519KeyHash = InstanceType<typeof csl.Ed25519KeyHash>;
|
|
31
|
-
export type Ed25519KeyHashes = InstanceType<typeof csl.Ed25519KeyHashes>;
|
|
32
|
-
export type Ed25519Signature = InstanceType<typeof csl.Ed25519Signature>;
|
|
33
|
-
export type EnterpriseAddress = InstanceType<typeof csl.EnterpriseAddress>;
|
|
34
|
-
export type ExUnitPrices = InstanceType<typeof csl.ExUnitPrices>;
|
|
35
|
-
export type ExUnits = InstanceType<typeof csl.ExUnits>;
|
|
36
|
-
export type GeneralTransactionMetadata = InstanceType<typeof csl.GeneralTransactionMetadata>;
|
|
37
|
-
export type GenesisDelegateHash = InstanceType<typeof csl.GenesisDelegateHash>;
|
|
38
|
-
export type GenesisHash = InstanceType<typeof csl.GenesisHash>;
|
|
39
|
-
export type GenesisHashes = InstanceType<typeof csl.GenesisHashes>;
|
|
40
|
-
export type GenesisKeyDelegation = InstanceType<typeof csl.GenesisKeyDelegation>;
|
|
41
|
-
export type Header = InstanceType<typeof csl.Header>;
|
|
42
|
-
export type HeaderBody = InstanceType<typeof csl.HeaderBody>;
|
|
43
|
-
export type Int = InstanceType<typeof csl.Int>;
|
|
44
|
-
export type Ipv4 = InstanceType<typeof csl.Ipv4>;
|
|
45
|
-
export type Ipv6 = InstanceType<typeof csl.Ipv6>;
|
|
46
|
-
export type KESSignature = InstanceType<typeof csl.KESSignature>;
|
|
47
|
-
export type KESVKey = InstanceType<typeof csl.KESVKey>;
|
|
48
|
-
export type Language = InstanceType<typeof csl.Language>;
|
|
49
|
-
export type Languages = InstanceType<typeof csl.Languages>;
|
|
50
|
-
export type LegacyDaedalusPrivateKey = InstanceType<typeof csl.LegacyDaedalusPrivateKey>;
|
|
51
|
-
export type LinearFee = InstanceType<typeof csl.LinearFee>;
|
|
52
|
-
export type MIRToStakeCredentials = InstanceType<typeof csl.MIRToStakeCredentials>;
|
|
53
|
-
export type MetadataList = InstanceType<typeof csl.MetadataList>;
|
|
54
|
-
export type MetadataMap = InstanceType<typeof csl.MetadataMap>;
|
|
55
|
-
export type Mint = InstanceType<typeof csl.Mint>;
|
|
56
|
-
export type MintAssets = InstanceType<typeof csl.MintAssets>;
|
|
57
|
-
export type MintBuilder = InstanceType<typeof csl.MintBuilder>;
|
|
58
|
-
export type MintWitness = InstanceType<typeof csl.MintWitness>;
|
|
59
|
-
export type MintsAssets = InstanceType<typeof csl.MintsAssets>;
|
|
60
|
-
export type MoveInstantaneousReward = InstanceType<typeof csl.MoveInstantaneousReward>;
|
|
61
|
-
export type MoveInstantaneousRewardsCert = InstanceType<typeof csl.MoveInstantaneousRewardsCert>;
|
|
62
|
-
export type MultiAsset = InstanceType<typeof csl.MultiAsset>;
|
|
63
|
-
export type MultiHostName = InstanceType<typeof csl.MultiHostName>;
|
|
64
|
-
export type NativeScript = InstanceType<typeof csl.NativeScript>;
|
|
65
|
-
export type NativeScripts = InstanceType<typeof csl.NativeScripts>;
|
|
66
|
-
export type NetworkId = InstanceType<typeof csl.NetworkId>;
|
|
67
|
-
export type NetworkInfo = InstanceType<typeof csl.NetworkInfo>;
|
|
68
|
-
export type Nonce = InstanceType<typeof csl.Nonce>;
|
|
69
|
-
export type OperationalCert = InstanceType<typeof csl.OperationalCert>;
|
|
70
|
-
export type PlutusData = InstanceType<typeof csl.PlutusData>;
|
|
71
|
-
export type PlutusList = InstanceType<typeof csl.PlutusList>;
|
|
72
|
-
export type PlutusMap = InstanceType<typeof csl.PlutusMap>;
|
|
73
|
-
export type PlutusScript = InstanceType<typeof csl.PlutusScript>;
|
|
74
|
-
export type PlutusScripts = InstanceType<typeof csl.PlutusScripts>;
|
|
75
|
-
export type PlutusScriptSource = InstanceType<typeof csl.PlutusScriptSource>;
|
|
76
|
-
export type PlutusWitness = InstanceType<typeof csl.PlutusWitness>;
|
|
77
|
-
export type PlutusWitnesses = InstanceType<typeof csl.PlutusWitnesses>;
|
|
78
|
-
export type Pointer = InstanceType<typeof csl.Pointer>;
|
|
79
|
-
export type PointerAddress = InstanceType<typeof csl.PointerAddress>;
|
|
80
|
-
export type PoolMetadata = InstanceType<typeof csl.PoolMetadata>;
|
|
81
|
-
export type PoolMetadataHash = InstanceType<typeof csl.PoolMetadataHash>;
|
|
82
|
-
export type PoolParams = InstanceType<typeof csl.PoolParams>;
|
|
83
|
-
export type PoolRegistration = InstanceType<typeof csl.PoolRegistration>;
|
|
84
|
-
export type PoolRetirement = InstanceType<typeof csl.PoolRetirement>;
|
|
85
|
-
export type PrivateKey = InstanceType<typeof csl.PrivateKey>;
|
|
86
|
-
export type ProposedProtocolParameterUpdates = InstanceType<typeof csl.ProposedProtocolParameterUpdates>;
|
|
87
|
-
export type ProtocolParamUpdate = InstanceType<typeof csl.ProtocolParamUpdate>;
|
|
88
|
-
export type ProtocolVersion = InstanceType<typeof csl.ProtocolVersion>;
|
|
89
|
-
export type PublicKey = InstanceType<typeof csl.PublicKey>;
|
|
90
|
-
export type PublicKeys = InstanceType<typeof csl.PublicKeys>;
|
|
91
|
-
export type Redeemer = InstanceType<typeof csl.Redeemer>;
|
|
92
|
-
export type RedeemerTag = InstanceType<typeof csl.RedeemerTag>;
|
|
93
|
-
export type Redeemers = InstanceType<typeof csl.Redeemers>;
|
|
94
|
-
export type Relay = InstanceType<typeof csl.Relay>;
|
|
95
|
-
export type Relays = InstanceType<typeof csl.Relays>;
|
|
96
|
-
export type RewardAddress = InstanceType<typeof csl.RewardAddress>;
|
|
97
|
-
export type RewardAddresses = InstanceType<typeof csl.RewardAddresses>;
|
|
98
|
-
export type ScriptAll = InstanceType<typeof csl.ScriptAll>;
|
|
99
|
-
export type ScriptAny = InstanceType<typeof csl.ScriptAny>;
|
|
100
|
-
export type ScriptDataHash = InstanceType<typeof csl.ScriptDataHash>;
|
|
101
|
-
export type ScriptHash = InstanceType<typeof csl.ScriptHash>;
|
|
102
|
-
export type ScriptHashes = InstanceType<typeof csl.ScriptHashes>;
|
|
103
|
-
export type ScriptNOfK = InstanceType<typeof csl.ScriptNOfK>;
|
|
104
|
-
export type ScriptPubkey = InstanceType<typeof csl.ScriptPubkey>;
|
|
105
|
-
export type ScriptRef = InstanceType<typeof csl.ScriptRef>;
|
|
106
|
-
export type SingleHostAddr = InstanceType<typeof csl.SingleHostAddr>;
|
|
107
|
-
export type SingleHostName = InstanceType<typeof csl.SingleHostName>;
|
|
108
|
-
export type StakeCredential = InstanceType<typeof csl.StakeCredential>;
|
|
109
|
-
export type StakeCredentials = InstanceType<typeof csl.StakeCredentials>;
|
|
110
|
-
export type StakeDelegation = InstanceType<typeof csl.StakeDelegation>;
|
|
111
|
-
export type StakeRegistration = InstanceType<typeof csl.StakeRegistration>;
|
|
112
|
-
export type Strings = InstanceType<typeof csl.Strings>;
|
|
113
|
-
export type TimelockExpiry = InstanceType<typeof csl.TimelockExpiry>;
|
|
114
|
-
export type TimelockStart = InstanceType<typeof csl.TimelockStart>;
|
|
115
|
-
export type Transaction = InstanceType<typeof csl.Transaction>;
|
|
116
|
-
export type TransactionBodies = InstanceType<typeof csl.TransactionBodies>;
|
|
117
|
-
export type TransactionBody = InstanceType<typeof csl.TransactionBody>;
|
|
118
|
-
export type TransactionBuilder = InstanceType<typeof csl.TransactionBuilder>;
|
|
119
|
-
export type TransactionBuilderConfig = InstanceType<typeof csl.TransactionBuilderConfig>;
|
|
120
|
-
export type TransactionBuilderConfigBuilder = InstanceType<typeof csl.TransactionBuilderConfigBuilder>;
|
|
121
|
-
export type TransactionHash = InstanceType<typeof csl.TransactionHash>;
|
|
122
|
-
export type TransactionInput = InstanceType<typeof csl.TransactionInput>;
|
|
123
|
-
export type TransactionInputs = InstanceType<typeof csl.TransactionInputs>;
|
|
124
|
-
export type TransactionMetadatum = InstanceType<typeof csl.TransactionMetadatum>;
|
|
125
|
-
export type TransactionMetadatumLabels = InstanceType<typeof csl.TransactionMetadatumLabels>;
|
|
126
|
-
export type TransactionOutput = InstanceType<typeof csl.TransactionOutput>;
|
|
127
|
-
export type TransactionOutputAmountBuilder = InstanceType<typeof csl.TransactionOutputAmountBuilder>;
|
|
128
|
-
export type TransactionOutputBuilder = InstanceType<typeof csl.TransactionOutputBuilder>;
|
|
129
|
-
export type TransactionOutputs = InstanceType<typeof csl.TransactionOutputs>;
|
|
130
|
-
export type TransactionUnspentOutput = InstanceType<typeof csl.TransactionUnspentOutput>;
|
|
131
|
-
export type TransactionUnspentOutputs = InstanceType<typeof csl.TransactionUnspentOutputs>;
|
|
132
|
-
export type TransactionWitnessSet = InstanceType<typeof csl.TransactionWitnessSet>;
|
|
133
|
-
export type TransactionWitnessSets = InstanceType<typeof csl.TransactionWitnessSets>;
|
|
134
|
-
export type TxBuilderConstants = InstanceType<typeof csl.TxBuilderConstants>;
|
|
135
|
-
export type TxInputsBuilder = InstanceType<typeof csl.TxInputsBuilder>;
|
|
136
|
-
export type URL = InstanceType<typeof csl.URL>;
|
|
137
|
-
export type UnitInterval = InstanceType<typeof csl.UnitInterval>;
|
|
138
|
-
export type Update = InstanceType<typeof csl.Update>;
|
|
139
|
-
export type VRFCert = InstanceType<typeof csl.VRFCert>;
|
|
140
|
-
export type VRFKeyHash = InstanceType<typeof csl.VRFKeyHash>;
|
|
141
|
-
export type VRFVKey = InstanceType<typeof csl.VRFVKey>;
|
|
142
|
-
export type Value = InstanceType<typeof csl.Value>;
|
|
143
|
-
export type Vkey = InstanceType<typeof csl.Vkey>;
|
|
144
|
-
export type Vkeys = InstanceType<typeof csl.Vkeys>;
|
|
145
|
-
export type Vkeywitness = InstanceType<typeof csl.Vkeywitness>;
|
|
146
|
-
export type Vkeywitnesses = InstanceType<typeof csl.Vkeywitnesses>;
|
|
147
|
-
export type Withdrawals = InstanceType<typeof csl.Withdrawals>;
|
package/dist/core/index.d.ts
DELETED
package/dist/core.cjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _r=require("nanoid"),Yr=require("@emurgo/cardano-serialization-lib-nodejs"),Mt=require("axios"),ke=require("bip39"),Y=require("@emurgo/cardano-message-signing-nodejs");function $r(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const a=$r(Yr),zr=s=>{const e=[];return s.forEach(t=>{const r=e.find(n=>n.unit===t.unit);r?r.quantity=(parseInt(r.quantity)+parseInt(t.quantity)).toString():e.push(t)}),e},Wr=["testnet","preview","preprod","mainnet"],yr=s=>Wr.includes(s),Yt={mem:7e6,steps:3e9},It={epoch:0,coinsPerUTxOSize:"4310",priceMem:.0577,priceStep:721e-7,minFeeA:44,minFeeB:155381,keyDeposit:"2000000",maxTxSize:16384,maxValSize:"5000",poolDeposit:"500000000",maxCollateralInputs:3,decentralisation:0,maxBlockSize:98304,collateralPercent:150,maxBlockHeaderSize:1100,minPoolCost:"340000000",maxTxExMem:"16000000",maxTxExSteps:"10000000000",maxBlockExMem:"80000000",maxBlockExSteps:"40000000000"},ve=2147483648,vt={V1:a.Language.new_plutus_v1(),V2:a.Language.new_plutus_v2()},dt=56,Jr={CERT:a.RedeemerTag.new_cert(),MINT:a.RedeemerTag.new_mint(),REWARD:a.RedeemerTag.new_reward(),SPEND:a.RedeemerTag.new_spend()},Ae={testnet:["74","1598400","1595967616","432000"],preview:["183","15811222","1682467200","86400"],preprod:["65","26438400","1682121600","432000"],mainnet:["208","4492800","1596059091","432000"]},Je={ALONZO:a.TxBuilderConstants.plutus_alonzo_cost_models(),BABBAGE:(()=>{const s=a.Costmdls.new(),e=a.CostModel.new();Object.values({"addInteger-cpu-arguments-intercept":205665,"addInteger-cpu-arguments-slope":812,"addInteger-memory-arguments-intercept":1,"addInteger-memory-arguments-slope":1,"appendByteString-cpu-arguments-intercept":1e3,"appendByteString-cpu-arguments-slope":571,"appendByteString-memory-arguments-intercept":0,"appendByteString-memory-arguments-slope":1,"appendString-cpu-arguments-intercept":1e3,"appendString-cpu-arguments-slope":24177,"appendString-memory-arguments-intercept":4,"appendString-memory-arguments-slope":1,"bData-cpu-arguments":1e3,"bData-memory-arguments":32,"blake2b_256-cpu-arguments-intercept":117366,"blake2b_256-cpu-arguments-slope":10475,"blake2b_256-memory-arguments":4,"cekApplyCost-exBudgetCPU":23e3,"cekApplyCost-exBudgetMemory":100,"cekBuiltinCost-exBudgetCPU":23e3,"cekBuiltinCost-exBudgetMemory":100,"cekConstCost-exBudgetCPU":23e3,"cekConstCost-exBudgetMemory":100,"cekDelayCost-exBudgetCPU":23e3,"cekDelayCost-exBudgetMemory":100,"cekForceCost-exBudgetCPU":23e3,"cekForceCost-exBudgetMemory":100,"cekLamCost-exBudgetCPU":23e3,"cekLamCost-exBudgetMemory":100,"cekStartupCost-exBudgetCPU":100,"cekStartupCost-exBudgetMemory":100,"cekVarCost-exBudgetCPU":23e3,"cekVarCost-exBudgetMemory":100,"chooseData-cpu-arguments":19537,"chooseData-memory-arguments":32,"chooseList-cpu-arguments":175354,"chooseList-memory-arguments":32,"chooseUnit-cpu-arguments":46417,"chooseUnit-memory-arguments":4,"consByteString-cpu-arguments-intercept":221973,"consByteString-cpu-arguments-slope":511,"consByteString-memory-arguments-intercept":0,"consByteString-memory-arguments-slope":1,"constrData-cpu-arguments":89141,"constrData-memory-arguments":32,"decodeUtf8-cpu-arguments-intercept":497525,"decodeUtf8-cpu-arguments-slope":14068,"decodeUtf8-memory-arguments-intercept":4,"decodeUtf8-memory-arguments-slope":2,"divideInteger-cpu-arguments-constant":196500,"divideInteger-cpu-arguments-model-arguments-intercept":453240,"divideInteger-cpu-arguments-model-arguments-slope":220,"divideInteger-memory-arguments-intercept":0,"divideInteger-memory-arguments-minimum":1,"divideInteger-memory-arguments-slope":1,"encodeUtf8-cpu-arguments-intercept":1e3,"encodeUtf8-cpu-arguments-slope":28662,"encodeUtf8-memory-arguments-intercept":4,"encodeUtf8-memory-arguments-slope":2,"equalsByteString-cpu-arguments-constant":245e3,"equalsByteString-cpu-arguments-intercept":216773,"equalsByteString-cpu-arguments-slope":62,"equalsByteString-memory-arguments":1,"equalsData-cpu-arguments-intercept":1060367,"equalsData-cpu-arguments-slope":12586,"equalsData-memory-arguments":1,"equalsInteger-cpu-arguments-intercept":208512,"equalsInteger-cpu-arguments-slope":421,"equalsInteger-memory-arguments":1,"equalsString-cpu-arguments-constant":187e3,"equalsString-cpu-arguments-intercept":1e3,"equalsString-cpu-arguments-slope":52998,"equalsString-memory-arguments":1,"fstPair-cpu-arguments":80436,"fstPair-memory-arguments":32,"headList-cpu-arguments":43249,"headList-memory-arguments":32,"iData-cpu-arguments":1e3,"iData-memory-arguments":32,"ifThenElse-cpu-arguments":80556,"ifThenElse-memory-arguments":1,"indexByteString-cpu-arguments":57667,"indexByteString-memory-arguments":4,"lengthOfByteString-cpu-arguments":1e3,"lengthOfByteString-memory-arguments":10,"lessThanByteString-cpu-arguments-intercept":197145,"lessThanByteString-cpu-arguments-slope":156,"lessThanByteString-memory-arguments":1,"lessThanEqualsByteString-cpu-arguments-intercept":197145,"lessThanEqualsByteString-cpu-arguments-slope":156,"lessThanEqualsByteString-memory-arguments":1,"lessThanEqualsInteger-cpu-arguments-intercept":204924,"lessThanEqualsInteger-cpu-arguments-slope":473,"lessThanEqualsInteger-memory-arguments":1,"lessThanInteger-cpu-arguments-intercept":208896,"lessThanInteger-cpu-arguments-slope":511,"lessThanInteger-memory-arguments":1,"listData-cpu-arguments":52467,"listData-memory-arguments":32,"mapData-cpu-arguments":64832,"mapData-memory-arguments":32,"mkCons-cpu-arguments":65493,"mkCons-memory-arguments":32,"mkNilData-cpu-arguments":22558,"mkNilData-memory-arguments":32,"mkNilPairData-cpu-arguments":16563,"mkNilPairData-memory-arguments":32,"mkPairData-cpu-arguments":76511,"mkPairData-memory-arguments":32,"modInteger-cpu-arguments-constant":196500,"modInteger-cpu-arguments-model-arguments-intercept":453240,"modInteger-cpu-arguments-model-arguments-slope":220,"modInteger-memory-arguments-intercept":0,"modInteger-memory-arguments-minimum":1,"modInteger-memory-arguments-slope":1,"multiplyInteger-cpu-arguments-intercept":69522,"multiplyInteger-cpu-arguments-slope":11687,"multiplyInteger-memory-arguments-intercept":0,"multiplyInteger-memory-arguments-slope":1,"nullList-cpu-arguments":60091,"nullList-memory-arguments":32,"quotientInteger-cpu-arguments-constant":196500,"quotientInteger-cpu-arguments-model-arguments-intercept":453240,"quotientInteger-cpu-arguments-model-arguments-slope":220,"quotientInteger-memory-arguments-intercept":0,"quotientInteger-memory-arguments-minimum":1,"quotientInteger-memory-arguments-slope":1,"remainderInteger-cpu-arguments-constant":196500,"remainderInteger-cpu-arguments-model-arguments-intercept":453240,"remainderInteger-cpu-arguments-model-arguments-slope":220,"remainderInteger-memory-arguments-intercept":0,"remainderInteger-memory-arguments-minimum":1,"remainderInteger-memory-arguments-slope":1,"sha2_256-cpu-arguments-intercept":806990,"sha2_256-cpu-arguments-slope":30482,"sha2_256-memory-arguments":4,"sha3_256-cpu-arguments-intercept":1927926,"sha3_256-cpu-arguments-slope":82523,"sha3_256-memory-arguments":4,"sliceByteString-cpu-arguments-intercept":265318,"sliceByteString-cpu-arguments-slope":0,"sliceByteString-memory-arguments-intercept":4,"sliceByteString-memory-arguments-slope":0,"sndPair-cpu-arguments":85931,"sndPair-memory-arguments":32,"subtractInteger-cpu-arguments-intercept":205665,"subtractInteger-cpu-arguments-slope":812,"subtractInteger-memory-arguments-intercept":1,"subtractInteger-memory-arguments-slope":1,"tailList-cpu-arguments":41182,"tailList-memory-arguments":32,"trace-cpu-arguments":212342,"trace-memory-arguments":32,"unBData-cpu-arguments":31220,"unBData-memory-arguments":32,"unConstrData-cpu-arguments":32696,"unConstrData-memory-arguments":32,"unIData-cpu-arguments":43357,"unIData-memory-arguments":32,"unListData-cpu-arguments":32247,"unListData-memory-arguments":32,"unMapData-cpu-arguments":38314,"unMapData-memory-arguments":32,"verifyEd25519Signature-cpu-arguments-intercept":57996947,"verifyEd25519Signature-cpu-arguments-slope":18975,"verifyEd25519Signature-memory-arguments":10}).forEach((r,n)=>e.set(n,a.Int.new_i32(r)));const t=a.CostModel.new();return Object.values({"addInteger-cpu-arguments-intercept":205665,"addInteger-cpu-arguments-slope":812,"addInteger-memory-arguments-intercept":1,"addInteger-memory-arguments-slope":1,"appendByteString-cpu-arguments-intercept":1e3,"appendByteString-cpu-arguments-slope":571,"appendByteString-memory-arguments-intercept":0,"appendByteString-memory-arguments-slope":1,"appendString-cpu-arguments-intercept":1e3,"appendString-cpu-arguments-slope":24177,"appendString-memory-arguments-intercept":4,"appendString-memory-arguments-slope":1,"bData-cpu-arguments":1e3,"bData-memory-arguments":32,"blake2b_256-cpu-arguments-intercept":117366,"blake2b_256-cpu-arguments-slope":10475,"blake2b_256-memory-arguments":4,"cekApplyCost-exBudgetCPU":23e3,"cekApplyCost-exBudgetMemory":100,"cekBuiltinCost-exBudgetCPU":23e3,"cekBuiltinCost-exBudgetMemory":100,"cekConstCost-exBudgetCPU":23e3,"cekConstCost-exBudgetMemory":100,"cekDelayCost-exBudgetCPU":23e3,"cekDelayCost-exBudgetMemory":100,"cekForceCost-exBudgetCPU":23e3,"cekForceCost-exBudgetMemory":100,"cekLamCost-exBudgetCPU":23e3,"cekLamCost-exBudgetMemory":100,"cekStartupCost-exBudgetCPU":100,"cekStartupCost-exBudgetMemory":100,"cekVarCost-exBudgetCPU":23e3,"cekVarCost-exBudgetMemory":100,"chooseData-cpu-arguments":19537,"chooseData-memory-arguments":32,"chooseList-cpu-arguments":175354,"chooseList-memory-arguments":32,"chooseUnit-cpu-arguments":46417,"chooseUnit-memory-arguments":4,"consByteString-cpu-arguments-intercept":221973,"consByteString-cpu-arguments-slope":511,"consByteString-memory-arguments-intercept":0,"consByteString-memory-arguments-slope":1,"constrData-cpu-arguments":89141,"constrData-memory-arguments":32,"decodeUtf8-cpu-arguments-intercept":497525,"decodeUtf8-cpu-arguments-slope":14068,"decodeUtf8-memory-arguments-intercept":4,"decodeUtf8-memory-arguments-slope":2,"divideInteger-cpu-arguments-constant":196500,"divideInteger-cpu-arguments-model-arguments-intercept":453240,"divideInteger-cpu-arguments-model-arguments-slope":220,"divideInteger-memory-arguments-intercept":0,"divideInteger-memory-arguments-minimum":1,"divideInteger-memory-arguments-slope":1,"encodeUtf8-cpu-arguments-intercept":1e3,"encodeUtf8-cpu-arguments-slope":28662,"encodeUtf8-memory-arguments-intercept":4,"encodeUtf8-memory-arguments-slope":2,"equalsByteString-cpu-arguments-constant":245e3,"equalsByteString-cpu-arguments-intercept":216773,"equalsByteString-cpu-arguments-slope":62,"equalsByteString-memory-arguments":1,"equalsData-cpu-arguments-intercept":1060367,"equalsData-cpu-arguments-slope":12586,"equalsData-memory-arguments":1,"equalsInteger-cpu-arguments-intercept":208512,"equalsInteger-cpu-arguments-slope":421,"equalsInteger-memory-arguments":1,"equalsString-cpu-arguments-constant":187e3,"equalsString-cpu-arguments-intercept":1e3,"equalsString-cpu-arguments-slope":52998,"equalsString-memory-arguments":1,"fstPair-cpu-arguments":80436,"fstPair-memory-arguments":32,"headList-cpu-arguments":43249,"headList-memory-arguments":32,"iData-cpu-arguments":1e3,"iData-memory-arguments":32,"ifThenElse-cpu-arguments":80556,"ifThenElse-memory-arguments":1,"indexByteString-cpu-arguments":57667,"indexByteString-memory-arguments":4,"lengthOfByteString-cpu-arguments":1e3,"lengthOfByteString-memory-arguments":10,"lessThanByteString-cpu-arguments-intercept":197145,"lessThanByteString-cpu-arguments-slope":156,"lessThanByteString-memory-arguments":1,"lessThanEqualsByteString-cpu-arguments-intercept":197145,"lessThanEqualsByteString-cpu-arguments-slope":156,"lessThanEqualsByteString-memory-arguments":1,"lessThanEqualsInteger-cpu-arguments-intercept":204924,"lessThanEqualsInteger-cpu-arguments-slope":473,"lessThanEqualsInteger-memory-arguments":1,"lessThanInteger-cpu-arguments-intercept":208896,"lessThanInteger-cpu-arguments-slope":511,"lessThanInteger-memory-arguments":1,"listData-cpu-arguments":52467,"listData-memory-arguments":32,"mapData-cpu-arguments":64832,"mapData-memory-arguments":32,"mkCons-cpu-arguments":65493,"mkCons-memory-arguments":32,"mkNilData-cpu-arguments":22558,"mkNilData-memory-arguments":32,"mkNilPairData-cpu-arguments":16563,"mkNilPairData-memory-arguments":32,"mkPairData-cpu-arguments":76511,"mkPairData-memory-arguments":32,"modInteger-cpu-arguments-constant":196500,"modInteger-cpu-arguments-model-arguments-intercept":453240,"modInteger-cpu-arguments-model-arguments-slope":220,"modInteger-memory-arguments-intercept":0,"modInteger-memory-arguments-minimum":1,"modInteger-memory-arguments-slope":1,"multiplyInteger-cpu-arguments-intercept":69522,"multiplyInteger-cpu-arguments-slope":11687,"multiplyInteger-memory-arguments-intercept":0,"multiplyInteger-memory-arguments-slope":1,"nullList-cpu-arguments":60091,"nullList-memory-arguments":32,"quotientInteger-cpu-arguments-constant":196500,"quotientInteger-cpu-arguments-model-arguments-intercept":453240,"quotientInteger-cpu-arguments-model-arguments-slope":220,"quotientInteger-memory-arguments-intercept":0,"quotientInteger-memory-arguments-minimum":1,"quotientInteger-memory-arguments-slope":1,"remainderInteger-cpu-arguments-constant":196500,"remainderInteger-cpu-arguments-model-arguments-intercept":453240,"remainderInteger-cpu-arguments-model-arguments-slope":220,"remainderInteger-memory-arguments-intercept":0,"remainderInteger-memory-arguments-minimum":1,"remainderInteger-memory-arguments-slope":1,"serialiseData-cpu-arguments-intercept":1159724,"serialiseData-cpu-arguments-slope":392670,"serialiseData-memory-arguments-intercept":0,"serialiseData-memory-arguments-slope":2,"sha2_256-cpu-arguments-intercept":806990,"sha2_256-cpu-arguments-slope":30482,"sha2_256-memory-arguments":4,"sha3_256-cpu-arguments-intercept":1927926,"sha3_256-cpu-arguments-slope":82523,"sha3_256-memory-arguments":4,"sliceByteString-cpu-arguments-intercept":265318,"sliceByteString-cpu-arguments-slope":0,"sliceByteString-memory-arguments-intercept":4,"sliceByteString-memory-arguments-slope":0,"sndPair-cpu-arguments":85931,"sndPair-memory-arguments":32,"subtractInteger-cpu-arguments-intercept":205665,"subtractInteger-cpu-arguments-slope":812,"subtractInteger-memory-arguments-intercept":1,"subtractInteger-memory-arguments-slope":1,"tailList-cpu-arguments":41182,"tailList-memory-arguments":32,"trace-cpu-arguments":212342,"trace-memory-arguments":32,"unBData-cpu-arguments":31220,"unBData-memory-arguments":32,"unConstrData-cpu-arguments":32696,"unConstrData-memory-arguments":32,"unIData-cpu-arguments":43357,"unIData-memory-arguments":32,"unListData-cpu-arguments":32247,"unListData-memory-arguments":32,"unMapData-cpu-arguments":38314,"unMapData-memory-arguments":32,"verifyEcdsaSecp256k1Signature-cpu-arguments":35892428,"verifyEcdsaSecp256k1Signature-memory-arguments":10,"verifyEd25519Signature-cpu-arguments-intercept":57996947,"verifyEd25519Signature-cpu-arguments-slope":18975,"verifyEd25519Signature-memory-arguments":10,"verifySchnorrSecp256k1Signature-cpu-arguments-intercept":38887044,"verifySchnorrSecp256k1Signature-cpu-arguments-slope":32947,"verifySchnorrSecp256k1Signature-memory-arguments":10}).forEach((r,n)=>t.set(n,a.Int.new_i32(r))),s.insert(a.Language.new_plutus_v1(),e),s.insert(a.Language.new_plutus_v2(),t),s})()},jr={ALONZO:{V1:"a141005901d59f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f704001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff"},BABBAGE:{V1:"a141005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff",V2:"a20198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c80041005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff"}},He={[a.NetworkInfo.testnet().network_id()]:"8d18d786e92776c824607fd8e193ec535c79dc61ea2405ddf3b09fe3",[a.NetworkInfo.mainnet().network_id()]:"f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a"},Xr={mainnet:"wss://ogmios-api.mainnet.dandelion.link",preprod:"wss://ogmios-api.iohk-preprod.dandelion.link",preview:"__TBD_SOON_TM__",testnet:"wss://ogmios-api.testnet.dandelion.link"},Zr={LQ:"da8c30857834c6ae7203935b89278c532b3995245295456f993e1d244c51",MIN:"29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e",NTX:"edfd7a1d77bcb8b884c474bdc92a16002d1fb720e454fa6e993444794e5458",iBTC:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069425443",iETH:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069455448",iUSD:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069555344",MILK:"8a1cfae21368b8bebbbed9800fec304e95cce39a2a57dc35e2e3ebaa4d494c4b",AGIX:"f43a62fdc3965df486de8a0d32fe800963589c41b38946602a0dc53541474958",MELD:"6ac8ef33b510ec004fe11585f7c5a9f0c07f0c23428ab4f29c1d7d104d454c44",INDY:"533bb94a8850ee3ccbe483106489399112b74c905342cb1792a797a0494e4459",CLAY:"38ad9dc3aec6a2f38e220142b9aa6ade63ebe71f65e7cc2b7d8a8535434c4159",MCOS:"6f46e1304b16d884c85c62fb0eef35028facdc41aaa0fd319a152ed64d434f53",DING:"ce5b9e0f8a88255b65f2e4d065c6e716e9fa9a8a86dfb86423dd1ac044494e47",GERO:"10a49b996e2402269af553a8a96fb8eb90d79e9eca79e2b4223057b64745524f",NMKR:"5dac8536653edc12f6f5e1045d8164b9f59998d3bdc300fc928434894e4d4b52",PAVIA:"884892bcdc360bcef87d6b3f806e7f9cd5ac30d999d49970e7a903ae5041564941",HOSKY:"a0028f350aaabe0545fdcb56b039bfb08e4bb4d8c4d7c3c7d481c235484f534b59",YUMMI:"078eafce5cd7edafdf63900edef2c1ea759e77f30ca81d6bbdeec92479756d6d69",C3:"8e51398904a5d3fc129fbf4f1589701de23c7824d5c90fdb9490e15a434841524c4933",GIMBAL:"2b0a04a7b60132b1805b296c7fcb3b217ff14413991bf76f72663c3067696d62616c",SUNDAE:"9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d7753554e444145",GREENS:"4623ab311b7d982d8d26fcbe1a9439ca56661aafcdcd8d8a0ef31fd6475245454e53",GENS:"dda5fdb1002f7389b33e036b6afee82a8189becb6cba852e8b79b4fb0014df1047454e53",SOCIETY:"25f0fc240e91bd95dcdaebd2ba7713fc5168ac77234a3d79449fc20c534f4349455459",DJED:"8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344",SHEN:"8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344",WMT:"1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e776f726c646d6f62696c65746f6b656e",COPI:"b6a7467ea1deb012808ef4e87b5ff371e85f7142d7b356a40d9b42a0436f726e75636f70696173205b76696120436861696e506f72742e696f5d"},je=["begin","eternl","flint","lace","nami","nufi","gerowallet","typhoncip30","vespr","yoroi"],xr=(s,e,t="5000000")=>{const r=a.BigNum.from_str(s.get("lovelace")??"0").checked_add(a.BigNum.from_str(t)),n=e.filter(l=>l.output.amount.filter(p=>p.unit!=="lovelace").some(p=>s.has(p.unit))),i=ss(n);return[...i.less_than(r)?ns(r.clamped_sub(i).to_str(),e.filter(l=>!n.some(p=>p.input.txHash===l.input.txHash&&p.input.outputIndex===l.input.outputIndex))):[],...n]},ts=(s,e,t=!1,{maxTxSize:r,minFeeA:n,minFeeB:i}=It)=>{const c=e.filter(E=>Cr(E)===!1).sort(Fe),l=a.BigNum.from_str(ze(r,n,i)),p=t?a.BigNum.from_str(s).checked_add(l).to_str():s;return re(c,new Map([["lovelace",p]]))},wr=(s,e,t=!1,r=It)=>{const n=e.filter(Cr).sort(Fe),i=rs(r),c=s.get("lovelace")??"0",l=t?a.BigNum.from_str(c).checked_add(i).to_str():c;return s.set("lovelace",l),re(n,s)},es=(s,e)=>Array.from(e,t=>({unit:t[0],quantity:a.BigNum.from_str(t[1])})).every(t=>s.filter(r=>r.output.amount.find(n=>n.unit===t.unit)!==void 0).reduce((r,n)=>{const i=n.output.amount.reduce((c,l)=>c.checked_add(a.BigNum.from_str(t.unit===l.unit?l.quantity:"0")),a.BigNum.from_str("0"));return r.checked_add(i)},a.BigNum.from_str("0")).less_than(t.quantity)===!1),Fe=(s,e)=>{var n,i;const t=a.BigNum.from_str(((n=s.output.amount.find(c=>c.unit==="lovelace"))==null?void 0:n.quantity)??"0");return a.BigNum.from_str(((i=e.output.amount.find(c=>c.unit==="lovelace"))==null?void 0:i.quantity)??"0").compare(t)},rs=s=>{const{maxTxSize:e,minFeeA:t,minFeeB:r}=s;return a.BigNum.from_str(ze(e,t,r))},Cr=s=>s.output.amount.length>1,ss=s=>s.reduce((e,t)=>{var n;const r=((n=t.output.amount.find(i=>i.unit==="lovelace"))==null?void 0:n.quantity)??"0";return e.checked_add(a.BigNum.from_str(r))},a.BigNum.from_str("0")),ns=(s,e)=>{const t=e.sort(Fe);return re(t,new Map([["lovelace",s]]))},re=(s,e,t=[])=>s.length===0||es(t,e)?t:is(s[0],e)?re(s.slice(1),e,[...t,s[0]]):re(s.slice(1),e,t),is=(s,e)=>Array.from(e.keys()).some(t=>s.output.amount.find(r=>r.unit===t)!==void 0),as=(s,e)=>{const t=us(e),r=ls(s,e);return{coseKey:ht(t.to_bytes()),coseSign1:ht(r.to_bytes())}},os=(s,e,{key:t,signature:r})=>{var c,l;const n=Y.COSEKey.from_bytes(G(t)),i=Y.COSESign1.from_bytes(G(r));if((s==null?void 0:s.length)>0){const p=ht(i.payload()??new Uint8Array);if(ft(s)!==p)return!1}if((e==null?void 0:e.length)>0){const y=(c=i.headers().protected().deserialized_headers().header(Y.Label.new_text("address")))==null?void 0:c.as_bytes();if(y===void 0)throw new Error("Couldn't find a signer address in signature");const C=(l=n.header(Y.Label.new_int(Y.Int.new_negative(Y.BigNum.from_str("2")))))==null?void 0:l.as_bytes();if(C===void 0)throw new Error("Couldn't find a signer key in signature");const E=Gt(ht(y)),w=Fs(ht(C));if(cs(e,E,w)===!1)throw new Error("Couldn't check signature because of address mismatch");const v=Hs(ht(i.signature())),P=i.signed_data().to_bytes();return w.verify(P,v)}return!1},cs=(s,e,t)=>{if(s!==e.to_bech32())return!1;try{return $t(s)===t.hash().to_hex()}catch{return!1}},us=s=>{const e=Y.COSEKey.new(Y.Label.from_key_type(Y.KeyType.OKP));return e.set_algorithm_id(Y.Label.from_algorithm_id(Y.AlgorithmId.EdDSA)),e.set_header(Y.Label.new_int(Y.Int.new_negative(Y.BigNum.from_str("1"))),Y.CBORValue.new_int(Y.Int.new_i32(6))),e.set_header(Y.Label.new_int(Y.Int.new_negative(Y.BigNum.from_str("2"))),Y.CBORValue.new_bytes(s.key.to_public().as_bytes())),e},ls=(s,e)=>{const t=Y.HeaderMap.new(),r=Y.HeaderMap.new();t.set_algorithm_id(Y.Label.from_algorithm_id(Y.AlgorithmId.EdDSA)),t.set_header(Y.Label.new_text("address"),Y.CBORValue.new_bytes(e.address.to_bytes()));const n=Y.Headers.new(Y.ProtectedHeaderMap.new(t),r),i=Y.COSESign1Builder.new(n,G(s.payload),!1);s.externalAAD!==void 0&&i.set_external_aad(G(s.externalAAD));const c=i.make_data_to_sign(),l=e.key.sign(c.to_bytes());return i.build(l.to_bytes())};var Te=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function hs(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Br={},ct={exports:{}};Dt.notEqual=fs;Dt.notOk=gs;Dt.equal=ds;Dt.ok=Dt;var Sr=Dt;function ds(s,e,t){Dt(s==e,t)}function fs(s,e,t){Dt(s!=e,t)}function gs(s,e){Dt(!s,e)}function Dt(s,e){if(!s)throw new Error(e||"AssertionError")}var Et={exports:{}};function ms(s){throw new Error('Could not dynamically require "'+s+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ps=Re;Re.supported=typeof WebAssembly<"u";function Re(s){if(!Re.supported)return null;var e=s&&s.imports,t=As("AGFzbQEAAAABEANgAn9/AGADf39/AGABfwADBQQAAQICBQUBAQroBwdNBQZtZW1vcnkCAAxibGFrZTJiX2luaXQAAA5ibGFrZTJiX3VwZGF0ZQABDWJsYWtlMmJfZmluYWwAAhBibGFrZTJiX2NvbXByZXNzAAMK00AElgMAIABCADcDACAAQQhqQgA3AwAgAEEQakIANwMAIABBGGpCADcDACAAQSBqQgA3AwAgAEEoakIANwMAIABBMGpCADcDACAAQThqQgA3AwAgAEHAAGpCADcDACAAQcgAakIANwMAIABB0ABqQgA3AwAgAEHYAGpCADcDACAAQeAAakIANwMAIABB6ABqQgA3AwAgAEHwAGpCADcDACAAQfgAakIANwMAIABBgAFqQoiS853/zPmE6gBBACkDAIU3AwAgAEGIAWpCu86qptjQ67O7f0EIKQMAhTcDACAAQZABakKr8NP0r+68tzxBECkDAIU3AwAgAEGYAWpC8e30+KWn/aelf0EYKQMAhTcDACAAQaABakLRhZrv+s+Uh9EAQSApAwCFNwMAIABBqAFqQp/Y+dnCkdqCm39BKCkDAIU3AwAgAEGwAWpC6/qG2r+19sEfQTApAwCFNwMAIABBuAFqQvnC+JuRo7Pw2wBBOCkDAIU3AwAgAEHAAWpCADcDACAAQcgBakIANwMAIABB0AFqQgA3AwALbQEDfyAAQcABaiEDIABByAFqIQQgBCkDAKchBQJAA0AgASACRg0BIAVBgAFGBEAgAyADKQMAIAWtfDcDAEEAIQUgABADCyAAIAVqIAEtAAA6AAAgBUEBaiEFIAFBAWohAQwACwsgBCAFrTcDAAtkAQN/IABBwAFqIQEgAEHIAWohAiABIAEpAwAgAikDAHw3AwAgAEHQAWpCfzcDACACKQMApyEDAkADQCADQYABRg0BIAAgA2pBADoAACADQQFqIQMMAAsLIAIgA603AwAgABADC+U7AiB+CX8gAEGAAWohISAAQYgBaiEiIABBkAFqISMgAEGYAWohJCAAQaABaiElIABBqAFqISYgAEGwAWohJyAAQbgBaiEoICEpAwAhASAiKQMAIQIgIykDACEDICQpAwAhBCAlKQMAIQUgJikDACEGICcpAwAhByAoKQMAIQhCiJLznf/M+YTqACEJQrvOqqbY0Ouzu38hCkKr8NP0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"),r=null,n={buffer:t,memory:null,exports:null,realloc:i,onload:c};return c(function(){}),n;function i(p){n.exports.memory.grow(Math.ceil(Math.abs(p-n.memory.length)/65536)),n.memory=new Uint8Array(n.exports.memory.buffer)}function c(p){if(n.exports)return p();if(r){r.then(p.bind(null,null)).catch(p);return}try{if(s&&s.async)throw new Error("async");l({instance:new WebAssembly.Instance(new WebAssembly.Module(t),e)})}catch{r=WebAssembly.instantiate(t,e).then(l)}c(p)}function l(p){n.exports=p.instance.exports,n.memory=n.exports.memory&&n.exports.memory.buffer&&new Uint8Array(n.exports.memory.buffer)}}function As(s){return typeof atob=="function"?new Uint8Array(atob(s).split("").map(Is)):new(ms("buffer")).Buffer(s,"base64")}function Is(s){return s.charCodeAt(0)}var Ct=Sr,J=ps(),Qt=64,de=[];Et.exports=_t;var Xe=Et.exports.BYTES_MIN=16,Ze=Et.exports.BYTES_MAX=64;Et.exports.BYTES=32;var tr=Et.exports.KEYBYTES_MIN=16,er=Et.exports.KEYBYTES_MAX=64;Et.exports.KEYBYTES=32;var rr=Et.exports.SALTBYTES=16,sr=Et.exports.PERSONALBYTES=16;function _t(s,e,t,r,n){if(!(this instanceof _t))return new _t(s,e,t,r,n);if(!(J&&J.exports))throw new Error("WASM not loaded. Wait for Blake2b.ready(cb)");s||(s=32),n!==!0&&(Ct(s>=Xe,"digestLength must be at least "+Xe+", was given "+s),Ct(s<=Ze,"digestLength must be at most "+Ze+", was given "+s),e!=null&&Ct(e.length>=tr,"key must be at least "+tr+", was given "+e.length),e!=null&&Ct(e.length<=er,"key must be at least "+er+", was given "+e.length),t!=null&&Ct(t.length===rr,"salt must be exactly "+rr+", was given "+t.length),r!=null&&Ct(r.length===sr,"personal must be exactly "+sr+", was given "+r.length)),de.length||(de.push(Qt),Qt+=216),this.digestLength=s,this.finalized=!1,this.pointer=de.pop(),J.memory.fill(0,0,64),J.memory[0]=this.digestLength,J.memory[1]=e?e.length:0,J.memory[2]=1,J.memory[3]=1,t&&J.memory.set(t,32),r&&J.memory.set(r,48),this.pointer+216>J.memory.length&&J.realloc(this.pointer+216),J.exports.blake2b_init(this.pointer,this.digestLength),e&&(this.update(e),J.memory.fill(0,Qt,Qt+e.length),J.memory[this.pointer+200]=128)}_t.prototype.update=function(s){return Ct(this.finalized===!1,"Hash instance finalized"),Ct(s,"input must be TypedArray or Buffer"),Qt+s.length>J.memory.length&&J.realloc(Qt+s.length),J.memory.set(s,Qt),J.exports.blake2b_update(this.pointer,Qt,Qt+s.length),this};_t.prototype.digest=function(s){if(Ct(this.finalized===!1,"Hash instance finalized"),this.finalized=!0,de.push(this.pointer),J.exports.blake2b_final(this.pointer),!s||s==="binary")return J.memory.slice(this.pointer+128,this.pointer+128+this.digestLength);if(s==="hex")return ys(J.memory,this.pointer+128,this.digestLength);Ct(s.length>=this.digestLength,"input must be TypedArray or Buffer");for(var e=0;e<this.digestLength;e++)s[e]=J.memory[this.pointer+128+e];return s};_t.prototype.final=_t.prototype.digest;_t.WASM=J&&J.buffer;_t.SUPPORTED=typeof WebAssembly<"u";_t.ready=function(s){if(s||(s=_s),!J)return s(new Error("WebAssembly not supported"));var e=new Promise(function(t,r){J.onload(function(n){n?r():t(),s(n)})});return e};_t.prototype.ready=_t.ready;function _s(){}function ys(s,e,t){for(var r="",n=0;n<t;n++)r+=xs(s[e+n]);return r}function xs(s){return s<16?"0"+s.toString(16):s.toString(16)}var ws=Et.exports,Ut=Sr,se=ws;function oe(s,e,t){var r=s[e]+s[t],n=s[e+1]+s[t+1];r>=4294967296&&n++,s[e]=r,s[e+1]=n}function nr(s,e,t,r){var n=s[e]+t;t<0&&(n+=4294967296);var i=s[e+1]+r;n>=4294967296&&i++,s[e]=n,s[e+1]=i}function Er(s,e){return s[e]^s[e+1]<<8^s[e+2]<<16^s[e+3]<<24}function Nt(s,e,t,r,n,i){var c=ee[n],l=ee[n+1],p=ee[i],y=ee[i+1];oe(H,s,e),nr(H,s,c,l);var C=H[r]^H[s],E=H[r+1]^H[s+1];H[r]=E,H[r+1]=C,oe(H,t,r),C=H[e]^H[t],E=H[e+1]^H[t+1],H[e]=C>>>24^E<<8,H[e+1]=E>>>24^C<<8,oe(H,s,e),nr(H,s,p,y),C=H[r]^H[s],E=H[r+1]^H[s+1],H[r]=C>>>16^E<<16,H[r+1]=E>>>16^C<<16,oe(H,t,r),C=H[e]^H[t],E=H[e+1]^H[t+1],H[e]=E>>>31^C<<1,H[e+1]=C>>>31^E<<1}var br=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Cs=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],at=new Uint8Array(Cs.map(function(s){return s*2})),H=new Uint32Array(32),ee=new Uint32Array(32);function vr(s,e){var t=0;for(t=0;t<16;t++)H[t]=s.h[t],H[t+16]=br[t];for(H[24]=H[24]^s.t,H[25]=H[25]^s.t/4294967296,e&&(H[28]=~H[28],H[29]=~H[29]),t=0;t<32;t++)ee[t]=Er(s.b,4*t);for(t=0;t<12;t++)Nt(0,8,16,24,at[t*16+0],at[t*16+1]),Nt(2,10,18,26,at[t*16+2],at[t*16+3]),Nt(4,12,20,28,at[t*16+4],at[t*16+5]),Nt(6,14,22,30,at[t*16+6],at[t*16+7]),Nt(0,10,20,30,at[t*16+8],at[t*16+9]),Nt(2,12,22,24,at[t*16+10],at[t*16+11]),Nt(4,14,16,26,at[t*16+12],at[t*16+13]),Nt(6,8,18,28,at[t*16+14],at[t*16+15]);for(t=0;t<16;t++)s.h[t]=s.h[t]^H[t]^H[t+16]}var Pt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function Wt(s,e,t,r){Pt.fill(0),this.b=new Uint8Array(128),this.h=new Uint32Array(16),this.t=0,this.c=0,this.outlen=s,Pt[0]=s,e&&(Pt[1]=e.length),Pt[2]=1,Pt[3]=1,t&&Pt.set(t,32),r&&Pt.set(r,48);for(var n=0;n<16;n++)this.h[n]=br[n]^Er(Pt,n*4);e&&(Qr(this,e),this.c=128)}Wt.prototype.update=function(s){return Ut(s!=null,"input must be Uint8Array or Buffer"),Qr(this,s),this};Wt.prototype.digest=function(s){var e=!s||s==="binary"||s==="hex"?new Uint8Array(this.outlen):s;return Ut(e.length>=this.outlen,"out must have at least outlen bytes of space"),Bs(this,e),s==="hex"?Ss(e):e};Wt.prototype.final=Wt.prototype.digest;Wt.ready=function(s){se.ready(function(){s()})};function Qr(s,e){for(var t=0;t<e.length;t++)s.c===128&&(s.t+=s.c,vr(s,!1),s.c=0),s.b[s.c++]=e[t]}function Bs(s,e){for(s.t+=s.c;s.c<128;)s.b[s.c++]=0;vr(s,!0);for(var t=0;t<s.outlen;t++)e[t]=s.h[t>>2]>>8*(t&3);return e}function Ss(s){for(var e="",t=0;t<s.length;t++)e+=Es(s[t]);return e}function Es(s){return s<16?"0"+s.toString(16):s.toString(16)}var Dr=Wt;ct.exports=function(e,t,r,n,i){return i!==!0&&(Ut(e>=ir,"outlen must be at least "+ir+", was given "+e),Ut(e<=ar,"outlen must be at most "+ar+", was given "+e),t!=null&&Ut(t.length>=or,"key must be at least "+or+", was given "+t.length),t!=null&&Ut(t.length<=cr,"key must be at most "+cr+", was given "+t.length),r!=null&&Ut(r.length===ur,"salt must be exactly "+ur+", was given "+r.length),n!=null&&Ut(n.length===lr,"personal must be exactly "+lr+", was given "+n.length)),new Dr(e,t,r,n)};ct.exports.ready=function(s){se.ready(function(){s()})};ct.exports.WASM_SUPPORTED=se.SUPPORTED;ct.exports.WASM_LOADED=!1;var ir=ct.exports.BYTES_MIN=16,ar=ct.exports.BYTES_MAX=64;ct.exports.BYTES=32;var or=ct.exports.KEYBYTES_MIN=16,cr=ct.exports.KEYBYTES_MAX=64;ct.exports.KEYBYTES=32;var ur=ct.exports.SALTBYTES=16,lr=ct.exports.PERSONALBYTES=16;se.ready(function(s){s||(ct.exports.WASM_LOADED=!0,Dr=se)});var bs=ct.exports,Jt={};Object.defineProperty(Jt,"__esModule",{value:!0});Jt.bech32m=Jt.bech32=void 0;const Ie="qpzry9x8gf2tvdw0s3jn54khce6mua7l",kr={};for(let s=0;s<Ie.length;s++){const e=Ie.charAt(s);kr[e]=s}function zt(s){const e=s>>25;return(s&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function hr(s){let e=1;for(let t=0;t<s.length;++t){const r=s.charCodeAt(t);if(r<33||r>126)return"Invalid prefix ("+s+")";e=zt(e)^r>>5}e=zt(e);for(let t=0;t<s.length;++t){const r=s.charCodeAt(t);e=zt(e)^r&31}return e}function qe(s,e,t,r){let n=0,i=0;const c=(1<<t)-1,l=[];for(let p=0;p<s.length;++p)for(n=n<<e|s[p],i+=e;i>=t;)i-=t,l.push(n>>i&c);if(r)i>0&&l.push(n<<t-i&c);else{if(i>=e)return"Excess padding";if(n<<t-i&c)return"Non-zero padding"}return l}function vs(s){return qe(s,8,5,!0)}function Qs(s){const e=qe(s,5,8,!1);if(Array.isArray(e))return e}function Ds(s){const e=qe(s,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function Tr(s){let e;s==="bech32"?e=1:e=734539939;function t(c,l,p){if(p=p||90,c.length+7+l.length>p)throw new TypeError("Exceeds length limit");c=c.toLowerCase();let y=hr(c);if(typeof y=="string")throw new Error(y);let C=c+"1";for(let E=0;E<l.length;++E){const w=l[E];if(w>>5)throw new Error("Non 5-bit word");y=zt(y)^w,C+=Ie.charAt(w)}for(let E=0;E<6;++E)y=zt(y);y^=e;for(let E=0;E<6;++E){const w=y>>(5-E)*5&31;C+=Ie.charAt(w)}return C}function r(c,l){if(l=l||90,c.length<8)return c+" too short";if(c.length>l)return"Exceeds length limit";const p=c.toLowerCase(),y=c.toUpperCase();if(c!==p&&c!==y)return"Mixed-case string "+c;c=p;const C=c.lastIndexOf("1");if(C===-1)return"No separator character for "+c;if(C===0)return"Missing prefix for "+c;const E=c.slice(0,C),w=c.slice(C+1);if(w.length<6)return"Data too short";let v=hr(E);if(typeof v=="string")return v;const P=[];for(let k=0;k<w.length;++k){const N=w.charAt(k),T=kr[N];if(T===void 0)return"Unknown character "+N;v=zt(v)^T,!(k+6>=w.length)&&P.push(T)}return v!==e?"Invalid checksum for "+c:{prefix:E,words:P}}function n(c,l){const p=r(c,l);if(typeof p=="object")return p}function i(c,l){const p=r(c,l);if(typeof p=="object")return p;throw new Error(p)}return{decodeUnsafe:n,decode:i,encode:t,toWords:vs,fromWordsUnsafe:Qs,fromWords:Ds}}Jt.bech32=Tr("bech32");Jt.bech32m=Tr("bech32m");var ks=Te&&Te.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Br,"__esModule",{value:!0});const Ts=ks(bs),ce=Jt,Qe="asset";let Ns=class fe{constructor(e){this.hashBuf=e}static fromHash(e){return new fe(e)}static fromParts(e,t){const r=(0,Ts.default)(20).update(new Uint8Array([...e,...t])).digest("binary");return fe.fromHash(r)}static fromBech32(e){const{prefix:t,words:r}=ce.bech32.decode(e);if(t!==Qe)throw new Error("Invalid asset fingerprint");const n=Buffer.from(ce.bech32.fromWords(r));return fe.fromHash(n)}fingerprint(){const e=ce.bech32.toWords(this.hashBuf);return ce.bech32.encode(Qe,e)}hash(){return Buffer.from(this.hashBuf).toString("hex")}prefix(){return Qe}checksum(){return this.fingerprint().slice(-6)}};var Ps=Br.default=Ns;const Us=Ps,Os=(s,e,t=0)=>{const r=Ms(s),n=r.derive(ve+1852).derive(ve+1815).derive(ve+e),i=n.derive(0).derive(t).to_raw_key(),c=n.derive(2).derive(0).to_raw_key();return n.free(),r.free(),{paymentKey:i,stakeKey:c}},Gt=s=>a.Address.from_bytes(G(s)),Ms=s=>a.Bip32PrivateKey.from_bytes(G(s)),Ks=s=>a.DataHash.from_bytes(G(s)),Bt=s=>a.Ed25519KeyHash.from_bytes(G(s)),Hs=s=>a.Ed25519Signature.from_bytes(G(s)),Ve=s=>a.NativeScript.from_bytes(G(s)),Fs=s=>a.PublicKey.from_bytes(G(s)),Nr=s=>a.PlutusData.from_bytes(G(s)),jt=(s,e)=>a.PlutusScript.from_bytes_with_version(G(s),vt[e]),Rs=s=>a.ScriptRef.from_bytes(G(s)),qs=s=>a.ScriptHash.from_bytes(G(s)),At=s=>a.Transaction.from_bytes(G(s)),Ne=s=>a.TransactionHash.from_bytes(G(s)),dr=s=>a.TransactionUnspentOutput.from_bytes(G(s)),fr=s=>a.TransactionWitnessSet.from_bytes(G(s)),Vs=s=>a.Value.from_bytes(G(s)),xt=s=>a.Address.from_bech32(s),Le=s=>a.BaseAddress.from_address(xt(s)),Pr=s=>a.EnterpriseAddress.from_address(xt(s)),Ur=s=>a.RewardAddress.from_address(xt(s)),ht=s=>Buffer.from(s).toString("hex"),G=s=>s.length%2===0&&/^[0-9A-F]*$/i.test(s)?Buffer.from(s,"hex"):Buffer.from(s,"utf-8"),Ge=s=>{const e=t=>{const r=new Array;for(let n=0;n<t.len();n+=1)r.push(Ge(t.get(n)));return r};switch(s.kind()){case a.NativeScriptKind.ScriptAll:{const t=s.as_script_all();return{type:"all",scripts:e(t.native_scripts())}}case a.NativeScriptKind.ScriptAny:{const t=s.as_script_any();return{type:"any",scripts:e(t.native_scripts())}}case a.NativeScriptKind.ScriptNOfK:{const t=s.as_script_n_of_k();return{type:"atLeast",required:t.n(),scripts:e(t.native_scripts())}}case a.NativeScriptKind.TimelockStart:return{type:"after",slot:s.as_timelock_start().slot_bignum().to_str()};case a.NativeScriptKind.TimelockExpiry:return{type:"before",slot:s.as_timelock_expiry().slot_bignum().to_str()};case a.NativeScriptKind.ScriptPubkey:return{type:"sig",keyHash:s.as_script_pubkey().addr_keyhash().to_hex()};default:throw new Error(`Script Kind: ${s.kind()}, is not supported`)}},Vt=s=>{const e=t=>{const r=a.NativeScripts.new();return t.forEach(n=>{r.add(Vt(n))}),r};switch(s.type){case"all":return a.NativeScript.new_script_all(a.ScriptAll.new(e(s.scripts)));case"any":return a.NativeScript.new_script_any(a.ScriptAny.new(e(s.scripts)));case"atLeast":return a.NativeScript.new_script_n_of_k(a.ScriptNOfK.new(s.required,e(s.scripts)));case"after":return a.NativeScript.new_timelock_start(a.TimelockStart.new_timelockstart(a.BigNum.from_str(s.slot)));case"before":return a.NativeScript.new_timelock_expiry(a.TimelockExpiry.new_timelockexpiry(a.BigNum.from_str(s.slot)));case"sig":return a.NativeScript.new_script_pubkey(a.ScriptPubkey.new(Bt(s.keyHash)))}},ge=s=>{var r,n,i;const e=c=>{const l=[];for(let p=0;p<c.len();p+=1)l.push(ge(c.get(p)));return l},t=c=>{const l=new Map;for(let p=0;p<c.len();p+=1){const y=c.keys().get(p),C=c.get(y)??a.PlutusData.from_hex(ft("NO_ITEM_FOUND_INSIDE_GOLD_ROOM"));l.set(ge(y),ge(C))}return l};switch(s.kind()){case a.PlutusDataKind.Bytes:return ht(s.as_bytes()??new Uint8Array);case a.PlutusDataKind.Integer:return parseInt(((r=s.as_integer())==null?void 0:r.to_str())??"0",10);case a.PlutusDataKind.List:return e(s.as_list()??a.PlutusList.new());case a.PlutusDataKind.Map:return t(s.as_map()??a.PlutusMap.new());case a.PlutusDataKind.ConstrPlutusData:return{alternative:parseInt(((n=s.as_constr_plutus_data())==null?void 0:n.alternative().to_str())??"0",10),fields:e(((i=s.as_constr_plutus_data())==null?void 0:i.data())??a.PlutusList.new())};default:throw new Error(`PlutusData Kind: ${s.kind()}, is not supported`)}},Ot=s=>{const e=t=>{const r=a.PlutusList.new();return t.forEach(n=>{r.add(Ot(n))}),r};switch(typeof s){case"string":return a.PlutusData.new_bytes(G(s));case"number":return a.PlutusData.new_integer(a.BigInt.from_str(s.toString()));case"bigint":return a.PlutusData.new_integer(a.BigInt.from_str(s.toString()));case"object":if(s instanceof Array){const t=e(s);return a.PlutusData.new_list(t)}else if(s instanceof Map){const t=a.PlutusMap.new();return s.forEach((r,n)=>{t.insert(Ot(n),Ot(r))}),a.PlutusData.new_map(t)}else return a.PlutusData.new_constr_plutus_data(a.ConstrPlutusData.new(a.BigNum.from_str(s.alternative.toString()),e(s.fields)))}},Ls=s=>{const e=a.Relays.new();throw s.relays.forEach(t=>{e.add(Or(t))}),new Error("toPoolParams not implemented.")},Pe=s=>{const e=t=>Jr[t];return a.Redeemer.new(e(s.tag),a.BigNum.from_str(s.index.toString()),Ot(s.data),a.ExUnits.new(a.BigNum.from_str(s.budget.mem.toString()),a.BigNum.from_str(s.budget.steps.toString())))},Or=s=>{switch(s.type){case"SingleHostAddr":{const e=s.IPV4?a.Ipv4.new(new Uint8Array(s.IPV4.split(".").map(r=>parseInt(r)))):void 0,t=s.IPV6?a.Ipv6.new(G(s.IPV6.replaceAll(":",""))):void 0;return a.Relay.new_single_host_addr(a.SingleHostAddr.new(s.port,e,t))}case"SingleHostName":return a.Relay.new_single_host_name(a.SingleHostName.new(s.port,a.DNSRecordAorAAAA.new(s.domainName)));case"MultiHostName":return a.Relay.new_multi_host_name(a.MultiHostName.new(a.DNSRecordSRV.new(s.domainName)))}},Mr=s=>{if(s.is_plutus_script()){const t=s.plutus_script();return{code:t.to_hex(),version:Object.keys(vt).find(r=>vt[r].to_hex()===t.language_version().to_hex())}}const e=s.native_script();return Ge(e)},Xt=s=>{if("code"in s){const e=jt(s.code,s.version);return a.ScriptRef.new_plutus_script(e)}return a.ScriptRef.new_native_script(Vt(s))},ne=s=>{var n,i,c;const e=s.output().has_data_hash()?(n=s.output().data_hash())==null?void 0:n.to_hex():void 0,t=s.output().has_plutus_data()?(i=s.output().plutus_data())==null?void 0:i.to_hex():void 0,r=s.output().has_script_ref()?(c=s.output().script_ref())==null?void 0:c.to_hex():void 0;return{input:{outputIndex:s.input().index(),txHash:s.input().transaction_id().to_hex()},output:{address:s.output().address().to_bech32(),amount:Kr(s.output().amount()),dataHash:e,plutusData:t,scriptRef:r}}},pt=s=>{const e=a.TransactionInput.new(Ne(s.input.txHash),s.input.outputIndex),t=a.TransactionOutput.new(xt(s.output.address),St(s.output.amount));return s.output.dataHash!==void 0&&t.set_data_hash(Ks(s.output.dataHash)),s.output.plutusData!==void 0&&t.set_plutus_data(Nr(s.output.plutusData)),s.output.scriptRef!==void 0&&t.set_script_ref(Rs(s.output.scriptRef)),a.TransactionUnspentOutput.new(e,t)},gr=s=>{const e=s.split(".")[1]??"0",t=`${parseInt(e,10)}`,r="1"+"0".repeat(e.length);return a.UnitInterval.new(a.BigNum.from_str(t),a.BigNum.from_str(r))},ft=s=>s.length%2===0&&/^[0-9A-F]*$/i.test(s)?s:ht(Buffer.from(s,"utf-8")),Ye=s=>Buffer.from(s,"hex").toString("utf-8"),Kr=s=>{const e=[{unit:"lovelace",quantity:s.coin().to_str()}],t=s.multiasset();if(t!==void 0){const r=t.keys();for(let n=0;n<r.len();n+=1){const i=r.get(n),c=t.get(i);if(c!==void 0){const l=c.keys();for(let p=0;p<l.len();p+=1){const y=l.get(p),C=c.get(y)??a.BigNum.from_str("0"),E=i.to_hex()+ht(y.name());e.push({unit:E,quantity:C.to_str()})}}}}return e},St=s=>{const e=s.find(i=>i.unit==="lovelace"),t=Array.from(new Set(s.filter(i=>i.unit!=="lovelace").map(i=>i.unit.slice(0,dt)))),r=a.MultiAsset.new();t.forEach(i=>{const c=a.Assets.new();s.filter(l=>l.unit.slice(0,dt)===i).forEach(l=>{c.insert(a.AssetName.new(G(l.unit.slice(dt))),a.BigNum.from_str(l.quantity))}),r.insert(qs(i),c)});const n=a.Value.new(a.BigNum.from_str(e?e.quantity:"0"));return(s.length>1||!e)&&n.set_multiasset(r),n},mr=(s,e,t)=>a.BaseAddress.new(s,a.StakeCredential.from_keyhash(e),a.StakeCredential.from_keyhash(t)),Hr=(s,e="")=>a.Bip32PrivateKey.from_bip39_entropy(G(s),G(ft(e))),Ue=s=>a.DataCost.new_coins_per_byte(a.BigNum.from_str(s)),Gs=s=>{if(typeof s!="object"||!("input"in s))return a.DatumSource.new(Ot(s));const e=pt(s);if(e.output().has_plutus_data())return a.DatumSource.new_ref_input(e.input());throw new Error(`No inline datum found in UTxO: ${e.input().transaction_id().to_hex()}`)},pr=(s,e)=>a.EnterpriseAddress.new(s,a.StakeCredential.from_keyhash(e)),Ar=(s,e)=>{if(typeof s=="string")return a.MintWitness.new_native_script(Ve(s));if(e===void 0)throw new Error("Minting with plutus requires a redeemer to be defined");if(e.tag!=="MINT")throw new Error("Minting redeemer's tag must be defined as 'MINT'");return a.MintWitness.new_plutus_script(Me(s),Pe({tag:"MINT",index:0,budget:Yt,data:{alternative:0,fields:[]},...e}))},Oe=(s,e)=>a.RewardAddress.new(s,a.StakeCredential.from_keyhash(e)),Me=s=>{if("code"in s)return a.PlutusScriptSource.new(jt(s.code,s.version));const e=pt(s);if(e.output().has_script_ref()){const t=e.output().script_ref();if(t.is_plutus_script()){const r=Mr(t),n=jt(r.code,r.version).hash();return a.PlutusScriptSource.new_ref_input_with_lang_ver(n,e.input(),vt[r.version])}}throw new Error(`No plutus script reference found in UTxO: ${e.input().transaction_id().to_hex()}`)},ue=s=>{const e=a.ScriptPubkey.new(s);return a.NativeScript.new_script_pubkey(e)},me=(s=It)=>{const e=a.TransactionBuilderConfigBuilder.new().coins_per_utxo_byte(a.BigNum.from_str(s.coinsPerUTxOSize)).ex_unit_prices(a.ExUnitPrices.new(gr(s.priceMem.toString()),gr(s.priceStep.toString()))).fee_algo(a.LinearFee.new(a.BigNum.from_str(s.minFeeA.toString()),a.BigNum.from_str(s.minFeeB.toString()))).key_deposit(a.BigNum.from_str(s.keyDeposit)).max_tx_size(s.maxTxSize).max_value_size(parseInt(s.maxValSize,10)).pool_deposit(a.BigNum.from_str(s.poolDeposit)).build();return a.TransactionBuilder.new(e)},Ir=s=>{const e=a.TxInputsBuilder.new();return s.map(t=>t instanceof a.TransactionUnspentOutput?t:pt(t)).forEach(t=>{e.add_input(t.output().address(),t.input(),t.output().amount())}),e},le=s=>{if(typeof s=="string")return a.TransactionOutputBuilder.new().with_address(xt(s));let e=a.TransactionOutputBuilder.new().with_address(xt(s.address));if(s.datum){const{value:t,inline:r}=s.datum,n=Ot(t);e=e.with_data_hash(a.hash_plutus_data(n)),r&&(e=e.with_plutus_data(n))}if(s.script){const t=Xt(s.script);e=e.with_script_ref(t)}return e},kt=s=>{const e=s.slice(0,dt),t=s.includes(".")?ft(s.split(".")[1]):s.slice(dt);return{policyId:e,assetName:t}},S=s=>Mt.isAxiosError(s)?s.response?JSON.stringify({data:s.response.data,headers:s.response.headers,status:s.response.status}):s.request?JSON.stringify(s.request):s.message:JSON.stringify(s),Ys=s=>{const e=Ot(s);return a.hash_plutus_data(e).to_hex()},$s=(s,e=Date.now())=>{if(Ae[s]){const[t,r,n,i]=Ae[s];return parseInt(a.BigNum.from_str(e.toString()).div_floor(a.BigNum.from_str("1000")).checked_sub(a.BigNum.from_str(n)).div_floor(a.BigNum.from_str(i)).checked_add(a.BigNum.from_str(t)).to_str(),10)}throw new Error(`Couldn't resolve EpochNo for network: ${s}`)},$e=(s,e)=>Us.fromParts(G(s),G(e)).fingerprint(),zs=(s,e)=>jr[s][e],Ws=(s,e=0)=>{const t=Vt(s);return a.EnterpriseAddress.new(e,a.StakeCredential.from_scripthash(t.hash())).to_address().to_bech32()},Js=s=>Vt(s).hash().to_hex(),js=s=>Vt(s).to_hex(),qt=s=>{var e,t;try{const r=[(e=Le(s))==null?void 0:e.payment_cred().to_keyhash(),(t=Pr(s))==null?void 0:t.payment_cred().to_keyhash()].find(n=>n!==void 0);if(r!==void 0)return r.to_hex();throw new Error(`Couldn't resolve payment key hash from address: ${s}`)}catch(r){throw new Error(`An error occurred during resolvePaymentKeyHash: ${r}.`)}},Xs=(s,e=0)=>{const t=jt(s.code,s.version);return a.EnterpriseAddress.new(e,a.StakeCredential.from_scripthash(t.hash())).to_address().to_bech32()},Zs=s=>{try{const e=Pr(s),t=e==null?void 0:e.payment_cred().to_scripthash();if(t!==void 0)return t.to_hex();throw new Error(`Couldn't resolve script hash from address: ${s}`)}catch(e){throw new Error(`An error occurred during resolveScriptHash: ${e}.`)}},tn=s=>a.Ed25519KeyHash.from_hex(s).to_bech32("pool1"),Fr=s=>{const e=ke.mnemonicToEntropy(s.join(" ")),t=Hr(e),r=t.to_bech32();return t.free(),r},en=s=>Xt(s).to_hex(),rn=(s,e=Date.now())=>{if(Ae[s]){const[t,r,n]=Ae[s];return a.BigNum.from_str(e.toString()).div_floor(a.BigNum.from_str("1000")).checked_sub(a.BigNum.from_str(n)).checked_add(a.BigNum.from_str(r)).to_str()}throw new Error(`Couldn't resolve SlotNo for network: ${s}`)},ie=s=>{try{const e=xt(s),t=Le(s),r=t==null?void 0:t.stake_cred().to_keyhash();if(r!==void 0)return Oe(e.network_id(),r).to_address().to_bech32();throw new Error(`Couldn't resolve reward address from address: ${s}`)}catch(e){throw new Error(`An error occurred during resolveRewardAddress: ${e}.`)}},$t=s=>{var e,t;try{const r=[(e=Le(s))==null?void 0:e.stake_cred().to_keyhash(),(t=Ur(s))==null?void 0:t.payment_cred().to_keyhash()].find(n=>n!==void 0);if(r!==void 0)return r.to_hex();throw new Error(`Couldn't resolve stake key hash from address: ${s}`)}catch(r){throw new Error(`An error occurred during resolveStakeKeyHash: ${r}.`)}},ze=(s,e=It.minFeeA,t=It.minFeeB)=>(BigInt(e)*BigInt(s)+BigInt(t)).toString(),Ke=s=>{const e=At(s).body();return a.hash_transaction(e).to_hex()},sn=(s="",e=32)=>{if(e<=0||e>2048)throw new Error("Length must be bewteen 1 and 2048");const r=_r.customAlphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")(e);return ft(`${s}${r}`)},_e=(s,e)=>{const t=s.vkeys();if(t!==void 0){const r=new Set;for(let i=0;i<t.len();i+=1)r.add(t.get(i).to_hex());for(let i=0;i<e.len();i+=1)r.add(e.get(i).to_hex());const n=a.Vkeywitnesses.new();return r.forEach(i=>{n.add(a.Vkeywitness.from_hex(i))}),n}return e},nn=s=>ge(Nr(s)),an=s=>At(s).to_js_value();class on{_axiosInstance;constructor(...e){if(typeof e[0]=="string"&&e[0].startsWith("http"))this._axiosInstance=Mt.create({baseURL:e[0]});else{const t=e[0],r=t.slice(0,7);this._axiosInstance=Mt.create({baseURL:`https://cardano-${r}.blockfrost.io/api/v${e[1]??0}`,headers:{project_id:t}})}}async fetchAccountInfo(e){const t=e.startsWith("addr")?ie(e):e;try{const{data:r,status:n}=await this._axiosInstance.get(`accounts/${t}`);if(n===200)return{poolId:r.pool_id,active:r.active||r.active_epoch!==null,balance:r.controlled_amount,rewards:r.withdrawable_amount,withdrawals:r.withdrawals_sum};throw S(r)}catch(r){throw S(r)}}resolveScriptRef=async e=>{if(e){const{data:t,status:r}=await this._axiosInstance.get(`scripts/${e}`);if(r===200){const n=t.type.startsWith("plutus")?{code:await this.fetchPlutusScriptCBOR(e),version:t.type.replace("plutus","")}:await this.fetchNativeScriptJSON(e);return Xt(n).to_hex()}throw S(t)}};toUTxO=async(e,t)=>({input:{outputIndex:e.output_index,txHash:t},output:{address:e.address,amount:e.amount,dataHash:e.data_hash??void 0,plutusData:e.inline_datum??void 0,scriptRef:await this.resolveScriptRef(e.reference_script_hash),scriptHash:e.reference_script_hash}});async fetchAddressUTxOs(e,t){const r=t!==void 0?`/${t}`:"",n=`addresses/${e}/utxos`+r,i=async(c=1,l=[])=>{const{data:p,status:y}=await this._axiosInstance.get(`${n}?page=${c}`);if(y===200)return p.length>0?i(c+1,[...l,...await Promise.all(p.map(C=>this.toUTxO(C,C.tx_hash)))]):l;throw S(p)};try{return await i()}catch{return[]}}async fetchAssetAddresses(e){const t=async(r=1,n=[])=>{const{policyId:i,assetName:c}=kt(e),{data:l,status:p}=await this._axiosInstance.get(`assets/${i}${c}/addresses?page=${r}`);if(p===200)return l.length>0?t(r+1,[...n,...l]):n;throw S(l)};try{return await t()}catch{return[]}}async fetchAssetMetadata(e){try{const{policyId:t,assetName:r}=kt(e),{data:n,status:i}=await this._axiosInstance.get(`assets/${t}${r}`);if(i===200)return{...n.onchain_metadata};throw S(n)}catch(t){throw S(t)}}async fetchBlockInfo(e){try{const{data:t,status:r}=await this._axiosInstance.get(`blocks/${e}`);if(r===200)return{confirmations:t.confirmations,epoch:t.epoch,epochSlot:t.epoch_slot.toString(),fees:t.fees,hash:t.hash,nextBlock:t.next_block??"",operationalCertificate:t.op_cert,output:t.output??"0",previousBlock:t.previous_block,size:t.size,slot:t.slot.toString(),slotLeader:t.slot_leader??"",time:t.time,txCount:t.tx_count,VRFKey:t.block_vrf};throw S(t)}catch(t){throw S(t)}}async fetchCollectionAssets(e,t=1){try{const{data:r,status:n}=await this._axiosInstance.get(`assets/policy/${e}?page=${t}`);if(n===200)return{assets:r.map(i=>({unit:i.asset,quantity:i.quantity})),next:r.length===100?t+1:null};throw S(r)}catch{return{assets:[],next:null}}}async fetchHandleAddress(e){try{const t=ft(e.replace("$","")),{data:r,status:n}=await this._axiosInstance.get(`assets/${He[1]}${t}/addresses`);if(n===200)return r[0].address;throw S(r)}catch(t){throw S(t)}}async fetchProtocolParameters(e=Number.NaN){try{const{data:t,status:r}=await this._axiosInstance.get(`epochs/${isNaN(e)?"latest":e}/parameters`);if(r===200)return{coinsPerUTxOSize:t.coins_per_utxo_word,collateralPercent:t.collateral_percent,decentralisation:t.decentralisation_param,epoch:t.epoch,keyDeposit:t.key_deposit,maxBlockExMem:t.max_block_ex_mem,maxBlockExSteps:t.max_block_ex_steps,maxBlockHeaderSize:t.max_block_header_size,maxBlockSize:t.max_block_size,maxCollateralInputs:t.max_collateral_inputs,maxTxExMem:t.max_tx_ex_mem,maxTxExSteps:t.max_tx_ex_steps,maxTxSize:t.max_tx_size,maxValSize:t.max_val_size,minFeeA:t.min_fee_a,minFeeB:t.min_fee_b,minPoolCost:t.min_pool_cost,poolDeposit:t.pool_deposit,priceMem:t.price_mem,priceStep:t.price_step};throw S(t)}catch(t){throw S(t)}}async fetchTxInfo(e){try{const{data:t,status:r}=await this._axiosInstance.get(`txs/${e}`);if(r===200)return{block:t.block,deposit:t.deposit,fees:t.fees,hash:t.hash,index:t.index,invalidAfter:t.invalid_hereafter??"",invalidBefore:t.invalid_before??"",slot:t.slot.toString(),size:t.size};throw S(t)}catch(t){throw S(t)}}async fetchUTxOs(e){try{const{data:t,status:r}=await this._axiosInstance.get(`txs/${e}/utxos`);if(r===200){const n=t.outputs,i=[];return n.forEach(l=>{i.push(this.toUTxO(l,e))}),await Promise.all(i)}throw S(t)}catch(t){throw S(t)}}onTxConfirmed(e,t,r=100){let n=0;const i=setInterval(()=>{n>=r&&clearInterval(i),this.fetchTxInfo(e).then(c=>{this.fetchBlockInfo(c.block).then(l=>{(l==null?void 0:l.confirmations)>0&&(clearInterval(i),t())}).catch(()=>{n+=1})}).catch(()=>{n+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/cbor"},{data:r,status:n}=await this._axiosInstance.post("tx/submit",G(e),{headers:t});if(n===200)return r;throw S(r)}catch(t){throw S(t)}}async fetchPlutusScriptCBOR(e){const{data:t,status:r}=await this._axiosInstance.get(`scripts/${e}/cbor`);if(r===200)return t.cbor;throw S(t)}async fetchNativeScriptJSON(e){const{data:t,status:r}=await this._axiosInstance.get(`scripts/${e}/json`);if(r===200)return t.json;throw S(t)}}class cn{_axiosInstance;constructor(e,t,r){const n=r.host??"ipfs.infura.io",i=r.port??5001,c=r.version??0;this._axiosInstance=Mt.create({baseURL:`https://${n}:${i}/api/v${c}`,auth:{username:e,password:t}})}async uploadContent(e,t=!1){try{const r={"Content-Type":"multipart/form-data"},{data:n,status:i}=await this._axiosInstance.post(`add?recursive=${t}`,e,{headers:r});if(i===200)return n;throw S(n)}catch(r){throw S(r)}}}class un{_axiosInstance;constructor(...e){if(typeof e[0]=="string"&&e[0].startsWith("http"))this._axiosInstance=Mt.create({baseURL:e[0],headers:{Authorization:`Bearer ${e[1]}`}});else{let t=1;typeof e[2]=="number"&&(t=e[2]);const r={baseURL:`https://${e[0]}.koios.rest/api/v${t}`};typeof e[1]=="string"&&(r.headers={Authorization:`Bearer ${e[1]}`}),this._axiosInstance=Mt.create(r)}}async fetchAccountInfo(e){try{const t=e.startsWith("addr")?ie(e):e,{data:r,status:n}=await this._axiosInstance.post("account_info",{_stake_addresses:[t]});if(n===200)return{poolId:r[0].delegated_pool,active:r[0].status==="registered",balance:r[0].total_balance.toString(),rewards:r[0].rewards_available,withdrawals:r[0].withdrawals};throw S(r)}catch(t){throw S(t)}}async fetchAddressUTxOs(e,t){try{const{data:r,status:n}=await this._axiosInstance.post("address_info",{_addresses:[e]});if(n===200){const i=r.flatMap(c=>c.utxo_set).map(c=>this.toUTxO(c,e));return t!==void 0?i.filter(c=>c.output.amount.find(l=>l.unit===t)!==void 0):i}throw S(r)}catch{return[]}}async fetchAssetAddresses(e){try{const{policyId:t,assetName:r}=kt(e),{data:n,status:i}=await this._axiosInstance.get(`asset_address_list?_asset_policy=${t}&_asset_name=${r}`);if(i===200)return n.map(c=>({address:c.payment_address,quantity:c.quantity}));throw S(n)}catch(t){throw S(t)}}async fetchAssetMetadata(e){try{const{policyId:t,assetName:r}=kt(e),{data:n,status:i}=await this._axiosInstance.get(`asset_info?_asset_policy=${t}&_asset_name=${r}`);if(i===200)return{...n[0].minting_tx_metadata[721][t][Ye(r)]};throw S(n)}catch(t){throw S(t)}}async fetchBlockInfo(e){try{const{data:t,status:r}=await this._axiosInstance.post("block_info",{_block_hashes:[e]});if(r===200)return{confirmations:t[0].num_confirmations,epoch:t[0].epoch_no,epochSlot:t[0].epoch_slot.toString(),fees:t[0].total_fees??"",hash:t[0].hash,nextBlock:t[0].child_hash??"",operationalCertificate:t[0].op_cert,output:t[0].total_output??"0",previousBlock:t[0].parent_hash,size:t[0].block_size,slot:t[0].abs_slot.toString(),slotLeader:t[0].pool??"",time:t[0].block_time,txCount:t[0].tx_count,VRFKey:t[0].vrf_key};throw S(t)}catch(t){throw S(t)}}async fetchCollectionAssets(e,t=0){try{const{data:r,status:n}=await this._axiosInstance.get(`asset_policy_info?_asset_policy=${e}&limit=100&offset=${t}`);if(n===200)return{assets:r.map(i=>({unit:`${e}${i.asset_name}`,quantity:i.total_supply})),next:r.length===100?t+100:null};throw S(r)}catch(r){throw S(r)}}async fetchHandleAddress(e){try{const t=ft(e.replace("$","")),{data:r,status:n}=await this._axiosInstance.get(`asset_address_list?_asset_policy=${He[1]}&_asset_name=${t}`);if(n===200)return r[0].payment_address;throw S(r)}catch(t){throw S(t)}}async fetchProtocolParameters(e){try{const{data:t,status:r}=await this._axiosInstance.get(`epoch_params?_epoch_no=${e}`);if(r===200)return{coinsPerUTxOSize:t[0].coins_per_utxo_size,collateralPercent:t[0].collateral_percent,decentralisation:t[0].decentralisation,epoch:t[0].epoch_no,keyDeposit:t[0].key_deposit,maxBlockExMem:t[0].max_block_ex_mem.toString(),maxBlockExSteps:t[0].max_block_ex_steps.toString(),maxBlockHeaderSize:t[0].max_bh_size,maxBlockSize:t[0].max_block_size,maxCollateralInputs:t[0].max_collateral_inputs,maxTxExMem:t[0].max_tx_ex_mem.toString(),maxTxExSteps:t[0].max_tx_ex_steps.toString(),maxTxSize:t[0].max_tx_size,maxValSize:t[0].max_val_size.toString(),minFeeA:t[0].min_fee_a,minFeeB:t[0].min_fee_b,minPoolCost:t[0].min_pool_cost,poolDeposit:t[0].pool_deposit,priceMem:t[0].price_mem,priceStep:t[0].price_step};throw S(t)}catch(t){throw S(t)}}async fetchTxInfo(e){var t,r;try{const{data:n,status:i}=await this._axiosInstance.post("tx_info",{_tx_hashes:[e]});if(i===200)return{block:n[0].block_hash,deposit:n[0].deposit,fees:n[0].fee,hash:n[0].tx_hash,index:n[0].tx_block_index,invalidAfter:((t=n[0].invalid_after)==null?void 0:t.toString())??"",invalidBefore:((r=n[0].invalid_before)==null?void 0:r.toString())??"",slot:n[0].absolute_slot.toString(),size:n[0].tx_size};throw S(n)}catch(n){throw S(n)}}async fetchUTxOs(e){try{const{data:t,status:r}=await this._axiosInstance.post("tx_info",{_tx_hashes:[e]});if(r===200)return t[0].outputs.map(i=>this.toUTxO(i,i.payment_addr.bech32));throw S(t)}catch(t){throw S(t)}}onTxConfirmed(e,t,r=100){let n=0;const i=setInterval(()=>{n>=r&&clearInterval(i),this.fetchTxInfo(e).then(c=>{this.fetchBlockInfo(c.block).then(l=>{(l==null?void 0:l.confirmations)>0&&(clearInterval(i),t())}).catch(()=>{n+=1})}).catch(()=>{n+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/cbor"},{data:r,status:n}=await this._axiosInstance.post("submittx",G(e),{headers:t});if(n===202)return r;throw S(r)}catch(t){throw S(t)}}toUTxO(e,t){var r,n;return{input:{outputIndex:e.tx_index,txHash:e.tx_hash},output:{address:t,amount:[{unit:"lovelace",quantity:e.value},...e.asset_list.map(i=>({unit:`${i.policy_id}${i.asset_name}`,quantity:`${i.quantity}`}))],dataHash:e.datum_hash??void 0,plutusData:((r=e.inline_datum)==null?void 0:r.bytes)??void 0,scriptRef:this.resolveScriptRef(e.reference_script),scriptHash:((n=e.reference_script)==null?void 0:n.hash)??void 0}}}resolveScriptRef=e=>{if(e){const t=e.type.startsWith("plutus")?{code:e.bytes,version:e.type.replace("plutus","")}:Ge(Ve(e.bytes));return Xt(t).to_hex()}}}class ln{_baseUrl;constructor(...e){this._baseUrl=yr(e[0])?Xr[e[0]]:e[0]}async evaluateTx(e){const t=await this.open();return this.send(t,"EvaluateTx",{evaluate:e}),new Promise((r,n)=>{t.addEventListener("message",i=>{try{const{result:c}=JSON.parse(i.data);c.EvaluationResult?r(Object.keys(c.EvaluationResult).map(l=>({index:parseInt(l.split(":")[1],10),tag:l.split(":")[0].toUpperCase(),budget:{mem:c.EvaluationResult[l].memory,steps:c.EvaluationResult[l].steps}}))):n(c.EvaluationFailure),t.close()}catch(c){n(c)}},{once:!0})})}async onNextTx(e){const t=await this.open();return this.send(t,"AwaitAcquire",{}),t.addEventListener("message",r=>{const{result:n}=JSON.parse(r.data);if(n===null)return this.send(t,"AwaitAcquire",{});n.AwaitAcquired===void 0&&e(n),this.send(t,"NextTx",{})}),()=>t.close()}async submitTx(e){const t=await this.open();return this.send(t,"SubmitTx",{submit:e}),new Promise((r,n)=>{t.addEventListener("message",i=>{try{const{result:c}=JSON.parse(i.data);c.SubmitSuccess?r(c.SubmitSuccess.txId):n(c.SubmitFail),t.close()}catch(c){n(c)}},{once:!0})})}async open(){const e=new WebSocket(this._baseUrl);return await new Promise(t=>{e.addEventListener("open",()=>t(!0),{once:!0})}),e}send(e,t,r){e.send(JSON.stringify({version:"1.0",type:"jsonwsp/request",servicename:"ogmios",methodname:t,args:r}))}}class hn{_axiosInstance;_amountsAsStrings={headers:{"amounts-as-strings":"true"}};submitUrl;constructor({network:e,apiKey:t,turboSubmit:r=!1}){this._axiosInstance=Mt.create({baseURL:`https://${e}.gomaestro-api.org/v1`,headers:{"api-key":t}}),this.submitUrl=r?"txmanager/turbosubmit":"txmanager"}async evaluateTx(e){try{const{data:t,status:r}=await this._axiosInstance.post("transactions/evaluate",{cbor:e});if(r===200){const n={spend:"SPEND",mint:"MINT",cert:"CERT",wdrl:"REWARD"};return t.map(c=>{const l=c.ex_units,p=c.redeemer_index,y=n[c.redeemer_tag];return{budget:l,index:p,tag:y}})}throw S(t)}catch(t){throw S(t)}}async fetchAccountInfo(e){const t=e.startsWith("addr")?ie(e):e;try{const{data:r,status:n}=await this._axiosInstance.get(`accounts/${t}`,this._amountsAsStrings);if(n===200){const i=r.data;return{poolId:i.delegated_pool,active:i.registered,balance:i.total_balance,rewards:i.rewards_available,withdrawals:i.total_withdrawn}}throw S(r)}catch(r){throw S(r)}}async fetchAddressUTxOs(e,t){const r=e.startsWith("addr_vkh")||e.startsWith("addr_shared_vkh")?`addresses/cred/${e}`:`addresses/${e}`,n=t?`&asset=${t}`:"",i=async(c=null,l=[])=>{const p=c===null?"":`&cursor=${c}`,{data:y,status:C}=await this._axiosInstance.get(`${r}/utxos?count=100${n}${p}`,this._amountsAsStrings);if(C===200){const w=y.data.map(this.toUTxO),v=[...l,...w],P=y.next_cursor;return P==null?v:i(P,v)}throw S(y)};try{return await i()}catch{return[]}}async fetchAssetAddresses(e){const{policyId:t,assetName:r}=kt(e),n=async(i=null,c=[])=>{const l=i===null?"":`&cursor=${i}`,{data:p,status:y}=await this._axiosInstance.get(`assets/${t}${r}/addresses?count=100${l}`,this._amountsAsStrings);if(y===200){const E=p.data.map(P=>({address:P.address,quantity:P.amount})),w=p.next_cursor,v=[...c,...E];return w==null?v:n(w,v)}throw S(p)};try{return await n()}catch{return[]}}async fetchAssetMetadata(e){try{const{policyId:t,assetName:r}=kt(e),{data:n,status:i}=await this._axiosInstance.get(`assets/${t}${r}`);if(i===200){const c=n.data;return{...c.asset_standards.cip25_metadata,...c.asset_standards.cip68_metadata}}throw S(n)}catch(t){throw S(t)}}async fetchBlockInfo(e){var t;try{const{data:r,status:n}=await this._axiosInstance.get(`blocks/${e}`,this._amountsAsStrings);if(n===200){const i=r.data;return{confirmations:i.confirmations,epoch:i.epoch,epochSlot:i.epoch_slot.toString(),fees:i.total_fees,hash:i.hash,nextBlock:i.next_block??"",operationalCertificate:(t=i.operational_certificate)==null?void 0:t.hot_vkey,output:i.total_output_lovelace??"0",previousBlock:i.previous_block,size:i.size,slot:i.absolute_slot.toString(),slotLeader:i.block_producer??"",time:Date.parse(i.timestamp)/1e3,txCount:i.tx_hashes.length,VRFKey:a.VRFVKey.from_hex(i.vrf_key).to_bech32("vrf_vk")}}throw S(r)}catch(r){throw S(r)}}async fetchCollectionAssets(e,t){try{const{data:r,status:n}=await this._axiosInstance.get(`policy/${e}/assets?count=100${t?`&cursor=${t}`:""}`);if(n===200)return{assets:r.data.map(c=>({unit:e+c.asset_name,quantity:c.total_supply})),next:r.next_cursor};throw S(r)}catch{return{assets:[],next:null}}}async fetchHandleAddress(e){try{const t=e.charAt(0)==="$"?e.substring(1):e,{data:r,status:n}=await this._axiosInstance.get(`ecosystem/adahandle/${t}`);if(n===200)return r.data;throw S(r)}catch(t){throw S(t)}}async fetchProtocolParameters(e=Number.NaN){if(!isNaN(e))throw new Error("Maestro only supports fetching Protocol parameters of the latest completed epoch.");const t=r=>{const n=r.indexOf("/");return parseInt(r.slice(0,n))/parseInt(r.slice(n+1))};try{const{data:r,status:n}=await this._axiosInstance.get("protocol-params");if(n===200){const i=r.data;try{const{data:c,status:l}=await this._axiosInstance.get("epochs/current");if(l===200){const p=c.data;return{coinsPerUTxOSize:i.coins_per_utxo_byte.toString(),collateralPercent:parseInt(i.collateral_percentage),decentralisation:0,epoch:parseInt(p.epoch_no),keyDeposit:i.stake_key_deposit.toString(),maxBlockExMem:i.max_execution_units_per_block.memory.toString(),maxBlockExSteps:i.max_execution_units_per_block.steps.toString(),maxBlockHeaderSize:parseInt(i.max_block_header_size),maxBlockSize:parseInt(i.max_block_body_size),maxCollateralInputs:parseInt(i.max_collateral_inputs),maxTxExMem:i.max_execution_units_per_transaction.memory.toString(),maxTxExSteps:i.max_execution_units_per_transaction.steps.toString(),maxTxSize:parseInt(i.max_tx_size),maxValSize:i.max_value_size.toString(),minFeeA:i.min_fee_coefficient,minFeeB:i.min_fee_constant,minPoolCost:i.min_pool_cost.toString(),poolDeposit:i.pool_deposit.toString(),priceMem:t(i.prices.memory),priceStep:t(i.prices.steps)}}throw S(c)}catch(c){throw S(c)}}throw S(r)}catch(r){throw S(r)}}async fetchTxInfo(e){try{const{data:t,status:r}=await this._axiosInstance.get(`transactions/${e}`);if(r===200){const n=t.data;return{block:n.block_hash,deposit:n.deposit.toString(),fees:n.fee.toString(),hash:n.tx_hash,index:n.block_tx_index,invalidAfter:n.invalid_hereafter??"",invalidBefore:n.invalid_before??"",slot:n.block_absolute_slot.toString(),size:n.size-1}}throw S(t)}catch(t){throw S(t)}}async fetchUTxOs(e){try{const{data:t,status:r}=await this._axiosInstance.get(`transactions/${e}`,this._amountsAsStrings);if(r===200)return t.data.outputs.map(this.toUTxO);throw S(t)}catch(t){throw S(t)}}onTxConfirmed(e,t,r=100){let n=0;const i=setInterval(()=>{n>=r&&clearInterval(i),this.fetchTxInfo(e).then(c=>{this.fetchBlockInfo(c.block).then(l=>{(l==null?void 0:l.confirmations)>0&&(clearInterval(i),t())}).catch(()=>{n+=1})}).catch(()=>{n+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/cbor"},{data:r,status:n}=await this._axiosInstance.post(this.submitUrl,G(e),{headers:t});if(n===202)return r;throw S(r)}catch(t){throw S(t)}}toUTxO=e=>{var t,r,n;return{input:{outputIndex:e.index,txHash:e.tx_hash},output:{address:e.address,amount:e.assets.map(i=>({unit:i.unit,quantity:i.amount})),dataHash:(t=e.datum)==null?void 0:t.hash,plutusData:(r=e.datum)==null?void 0:r.bytes,scriptRef:this.resolveScript(e),scriptHash:(n=e.reference_script)==null?void 0:n.hash}}};resolveScript=e=>{if(e.reference_script){const t=e.reference_script.type==="native"?e.reference_script.json:{code:e.reference_script.bytes,version:e.reference_script.type.replace("plutusv","V")};return Xt(t).to_hex()}else return}}class dn{_axiosInstance;constructor(e="http://localhost:8080/api/v1"){this._axiosInstance=Mt.create({baseURL:e})}async fetchAccountInfo(e){const t=e.startsWith("addr")?ie(e):e;try{const{data:r,status:n}=await this._axiosInstance.get(`accounts/${t}`);if(n===200)return{poolId:r.pool_id,active:r.active||r.active_epoch!==null,balance:r.controlled_amount,rewards:r.withdrawable_amount,withdrawals:r.withdrawals_sum};throw S(r)}catch(r){throw S(r)}}resolveScriptRef=async e=>{if(e){const{data:t,status:r}=await this._axiosInstance.get(`scripts/${e}`);if(r===200){const n=t.type.startsWith("plutus")?{code:await this.fetchPlutusScriptCBOR(e),version:t.type.replace("plutus","")}:await this.fetchNativeScriptJSON(e);return Xt(n).to_hex()}throw S(t)}};toUTxO=async(e,t)=>({input:{outputIndex:e.output_index,txHash:t},output:{address:e.address,amount:e.amount.map(r=>({...r,quantity:r.quantity.toString()})),dataHash:e.data_hash??void 0,plutusData:e.inline_datum??void 0,scriptRef:await this.resolveScriptRef(e.reference_script_hash),scriptHash:e.reference_script_hash}});async fetchAddressUTxOs(e,t){const r=t!==void 0?`/${t}`:"",n=`addresses/${e}/utxos`+r,i=async(c=1,l=[])=>{const{data:p,status:y}=await this._axiosInstance.get(`${n}?page=${c}`);if(y===200)return p.length>0?i(c+1,[...l,...await Promise.all(p.map(C=>this.toUTxO(C,C.tx_hash)))]):l;throw S(p)};try{return await i()}catch{return[]}}async fetchAssetAddresses(e){const t=async(r=1,n=[])=>{const{policyId:i,assetName:c}=kt(e),{data:l,status:p}=await this._axiosInstance.get(`assets/${i}${c}/addresses?page=${r}`);if(p===200)return l.length>0?t(r+1,[...n,...l]):n;throw S(l)};try{return await t()}catch{return[]}}async fetchAssetMetadata(e){try{const{policyId:t,assetName:r}=kt(e),{data:n,status:i}=await this._axiosInstance.get(`assets/${t}${r}`);if(i===200)return{...n.onchain_metadata};throw S(n)}catch(t){throw S(t)}}async fetchBlockInfo(e){try{const{data:t,status:r}=await this._axiosInstance.get(`blocks/${e}`);if(r===200)return{confirmations:t.confirmations,epoch:t.epoch,epochSlot:t.epoch_slot.toString(),fees:t.fees,hash:t.hash,nextBlock:t.next_block??"",operationalCertificate:t.op_cert,output:t.output??"0",previousBlock:t.previous_block,size:t.size,slot:t.slot.toString(),slotLeader:t.slot_leader??"",time:t.time,txCount:t.tx_count,VRFKey:t.block_vrf};throw S(t)}catch(t){throw S(t)}}async fetchCollectionAssets(e,t=1){try{const{data:r,status:n}=await this._axiosInstance.get(`assets/policy/${e}?page=${t}`);if(n===200)return{assets:r.map(i=>({unit:i.asset,quantity:i.quantity})),next:r.length===100?t+1:null};throw S(r)}catch{return{assets:[],next:null}}}async fetchHandleAddress(e){try{const t=ft(e.replace("$","")),{data:r,status:n}=await this._axiosInstance.get(`assets/${He[1]}${t}/addresses`);if(n===200)return r[0].address;throw S(r)}catch(t){throw S(t)}}async fetchProtocolParameters(e=Number.NaN){try{const{data:t,status:r}=await this._axiosInstance.get(`epochs/${isNaN(e)?"latest":e}/parameters`);if(r===200)return{coinsPerUTxOSize:t.coins_per_utxo_word,collateralPercent:t.collateral_percent,decentralisation:t.decentralisation_param,epoch:t.epoch,keyDeposit:t.key_deposit,maxBlockExMem:t.max_block_ex_mem,maxBlockExSteps:t.max_block_ex_steps,maxBlockHeaderSize:t.max_block_header_size,maxBlockSize:t.max_block_size,maxCollateralInputs:t.max_collateral_inputs,maxTxExMem:t.max_tx_ex_mem,maxTxExSteps:t.max_tx_ex_steps,maxTxSize:t.max_tx_size,maxValSize:t.max_val_size,minFeeA:t.min_fee_a,minFeeB:t.min_fee_b,minPoolCost:t.min_pool_cost,poolDeposit:t.pool_deposit,priceMem:t.price_mem,priceStep:t.price_step};throw S(t)}catch(t){throw S(t)}}async fetchTxInfo(e){try{const{data:t,status:r}=await this._axiosInstance.get(`txs/${e}`);if(r===200)return{block:t.block,deposit:t.deposit,fees:t.fees,hash:t.hash,index:t.index,invalidAfter:t.invalid_hereafter??"",invalidBefore:t.invalid_before??"",slot:t.slot.toString(),size:t.size};throw S(t)}catch(t){throw S(t)}}async fetchUTxOs(e){try{const{data:t,status:r}=await this._axiosInstance.get(`txs/${e}/utxos`);if(r===200){const n=t.outputs,i=[];return n.forEach(l=>{i.push(this.toUTxO(l,e))}),await Promise.all(i)}throw S(t)}catch(t){throw S(t)}}onTxConfirmed(e,t,r=100){let n=0;const i=setInterval(()=>{n>=r&&clearInterval(i),this.fetchTxInfo(e).then(c=>{this.fetchBlockInfo(c.block).then(l=>{(l==null?void 0:l.confirmations)>0&&(clearInterval(i),t())}).catch(()=>{n+=1})}).catch(()=>{n+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"text/plain"},{status:r,data:n}=await this._axiosInstance.post("/tx/submit",e,{headers:t});if(r===202)return n;throw S(n)}catch(t){throw console.log("error",t),S(t)}}async fetchPlutusScriptCBOR(e){const{data:t,status:r}=await this._axiosInstance.get(`scripts/${e}/cbor`);if(r===200)return t.cbor;throw S(t)}async fetchNativeScriptJSON(e){const{data:t,status:r}=await this._axiosInstance.get(`scripts/${e}/json`);if(r===200)return t.json;throw S(t)}}class fn{static withOneSignature(e){const t=Bt(qt(e));return ue(t).to_hex()}static withAtLeastNSignatures(e,t){const r=a.NativeScripts.new();e.forEach(i=>{const c=Bt(qt(i));r.add(ue(c))});const n=a.ScriptNOfK.new(t,r);return a.NativeScript.new_script_any(n).to_hex()}static withAnySignature(e){const t=a.NativeScripts.new();e.forEach(n=>{const i=Bt(qt(n));t.add(ue(i))});const r=a.ScriptAny.new(t);return a.NativeScript.new_script_any(r).to_hex()}static withAllSignatures(e){const t=a.NativeScripts.new();e.forEach(n=>{const i=Bt(qt(n));t.add(ue(i))});const r=a.ScriptAll.new(t);return a.NativeScript.new_script_any(r).to_hex()}static fromNativeScript(e){return Vt(e).to_hex()}}function Kt(s,e,t,r){var n=arguments.length,i=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,e,t,r);else for(var l=s.length-1;l>=0;l--)(c=s[l])&&(i=(n<3?c(i):n>3?c(e,t,i):c(e,t))||i);return n>3&&i&&Object.defineProperty(e,t,i),i}const gn=s=>class extends s{__visits=[]},Lt=()=>function(s,e,t){const r=t.value;t.value=function(...n){const i=r.call(this,...n);return this.__visits&&this.__visits.push(e),i}};exports.Transaction=class{_changeAddress;_txOutputs=new Map;_recipients=new Map;_totalBurns=new Map;_totalMints=new Map;_era;_initiator;_mintBuilder;_protocolParameters;_txBuilder;_txCertificates;_txInputsBuilder;_txWithdrawals;constructor(e={}){this._era=e.era,this._initiator=e.initiator,this._mintBuilder=a.MintBuilder.new(),this._protocolParameters=e.parameters??It,this._txBuilder=me(e.parameters),this._txCertificates=a.Certificates.new(),this._txInputsBuilder=a.TxInputsBuilder.new(),this._txWithdrawals=a.Withdrawals.new()}static attachMetadata(e,t,r="BABBAGE"){var c;const n=At(e),i=n.auxiliary_data()??a.AuxiliaryData.new();if(i.set_metadata(a.GeneralTransactionMetadata.from_hex(t)),i.set_prefer_alonzo_format(r==="ALONZO"),a.hash_auxiliary_data(i).to_hex()!==((c=n.body().auxiliary_data_hash())==null?void 0:c.to_hex()))throw new Error("[Transaction] attachMetadata: The metadata hash does not match the auxiliary data hash.");return a.Transaction.new(n.body(),n.witness_set(),i).to_hex()}static deattachMetadata(e){const t=At(e);return a.Transaction.new(t.body(),t.witness_set(),void 0).to_hex()}static maskMetadata(e,t="BABBAGE"){var i;const r=At(e),n=(i=r.auxiliary_data())==null?void 0:i.metadata();if(n!==void 0){const c=a.GeneralTransactionMetadata.new();for(let p=0;p<n.len();p+=1){const y=n.keys().get(p),C=n.get(y);c.insert(y,a.TransactionMetadatum.from_hex("0".repeat(((C==null?void 0:C.to_hex())??"").length)))}const l=r.auxiliary_data();return l!==void 0&&(l.set_metadata(c),l.set_prefer_alonzo_format(t==="ALONZO")),a.Transaction.new(r.body(),r.witness_set(),l).to_hex()}return e}static readMetadata(e){var r,n;return((n=(r=At(e).auxiliary_data())==null?void 0:r.metadata())==null?void 0:n.to_hex())??""}static writeMetadata(e,t,r="BABBAGE"){const n=At(e),i=n.auxiliary_data()??a.AuxiliaryData.new();return i.set_metadata(a.GeneralTransactionMetadata.from_hex(t)),i.set_prefer_alonzo_format(r==="ALONZO"),a.Transaction.new(n.body(),n.witness_set(),i).to_hex()}get size(){return this._txBuilder.full_size()}async build(){try{return(this._mintBuilder.has_plutus_scripts()||this.notVisited("redeemValue")===!1)&&(await this.addRequiredSignersIfNeeded(),await this.addCollateralIfNeeded()),await this.forgeAssetsIfNeeded(),await this.addTxInputsAsNeeded(),await this.addChangeAddress(),this._txBuilder.build_tx().to_hex()}catch(e){throw new Error(`[Transaction] An error occurred during build: ${e}.`)}}burnAsset(e,t,r){const n=this._totalBurns.has(t.unit)?a.BigNum.from_str(this._totalBurns.get(t.unit)??"0").checked_add(a.BigNum.from_str(t.quantity)).to_str():t.quantity;return this._mintBuilder.add_asset(Ar(e,r),a.AssetName.new(G(t.unit.slice(dt))),a.Int.new_negative(a.BigNum.from_str(t.quantity))),this._totalBurns.set(t.unit,n),this}delegateStake(e,t){const r=a.Certificate.new_stake_delegation(a.StakeDelegation.new(a.StakeCredential.from_keyhash(Bt($t(e))),a.Ed25519KeyHash.from_bech32(t)));return this._txCertificates.add(r),this}deregisterStake(e){const t=a.Certificate.new_stake_deregistration(a.StakeDeregistration.new(a.StakeCredential.from_keyhash(Bt($t(e)))));return this._txCertificates.add(t),this}mintAsset(e,t,r){var y,C;const n=(E,w)=>{const v=typeof E=="string"?Ve(E).hash().to_hex():i(E).hash().to_hex(),P=ft(w.assetName);return{unit:`${v}${P}`,quantity:w.assetQuantity}},i=E=>{if("code"in E)return jt(E.code,E.version);const w=pt(E);if(w.output().has_script_ref()){const v=w.output().script_ref();if(v.is_plutus_script()){const P=Mr(v);return jt(P.code,P.version)}}throw new Error(`[Transaction] No plutus script reference found in UTxO: ${w.input().transaction_id().to_hex()}`)},c=n(e,t),p=a.BigNum.from_str(((y=this._totalMints.get(c.unit))==null?void 0:y.assetQuantity)??"0").checked_add(a.BigNum.from_str(c.quantity));return this._mintBuilder.add_asset(Ar(e,r),a.AssetName.new(G(ft(t.assetName))),a.Int.new(a.BigNum.from_str(c.quantity))),this._recipients.has(t.recipient)?(C=this._recipients.get(t.recipient))==null||C.push(c):this._recipients.set(t.recipient,[c]),this._totalMints.set(c.unit,{...t,assetQuantity:p.to_str()}),this}redeemValue(e){const t={tag:"SPEND",budget:Yt,index:this._txInputsBuilder.inputs().len(),data:{alternative:0,fields:[]},...e.redeemer},r=pt(e.value),n=e.datum?a.PlutusWitness.new_with_ref(Me(e.script),Gs(e.datum),Pe(t)):a.PlutusWitness.new_with_ref_without_datum(Me(e.script),Pe(t));return this._txInputsBuilder.add_plutus_script_input(n,r.input(),r.output().amount()),this}registerStake(e){const t=a.Certificate.new_stake_registration(a.StakeRegistration.new(a.StakeCredential.from_keyhash(Bt($t(e)))));return this._txCertificates.add(t),this}registerPool(e){const t=a.Certificate.new_pool_registration(a.PoolRegistration.new(Ls(e)));return this._txCertificates.add(t),this}retirePool(e,t){const r=a.Certificate.new_pool_retirement(a.PoolRetirement.new(a.Ed25519KeyHash.from_bech32(e),t));return this._txCertificates.add(r),this}sendAssets(e,t){const r=St(t),n=r.multiasset();if(r.is_zero()||n===void 0)return this;const i=le(e).next(),c=r.coin().is_zero()?i.with_asset_and_min_required_coin_by_utxo_cost(n,Ue(this._protocolParameters.coinsPerUTxOSize)).build():i.with_coin_and_asset(r.coin(),n).build();return t.forEach(l=>{this.setTxOutput(l)}),this._txBuilder.add_output(c),this}sendLovelace(e,t){const n=le(e).next().with_coin(a.BigNum.from_str(t)).build();return this.setTxOutput({unit:"lovelace",quantity:t}),this._txBuilder.add_output(n),this}sendToken(e,t,r){return this.sendAssets(e,[{quantity:r,unit:Zr[t]}]),this}sendValue(e,t){const r=St(t.output.amount),i=le(e).next().with_value(r).build();return t.output.amount.forEach(c=>{this.setTxOutput(c)}),this._txBuilder.add_output(i),this}setChangeAddress(e){return this._changeAddress=xt(e),this}setCollateral(e){const t=Ir(e);return this._txBuilder.set_collateral(t),this}setMetadata(e,t){return this._txBuilder.add_json_metadatum_with_schema(a.BigNum.from_str(e.toString()),JSON.stringify(t),a.MetadataJsonSchema.NoConversions),this}setRequiredSigners(e){return Array.from(new Set(e.map(r=>r.startsWith("addr")?qt(r):$t(r)).map(r=>Bt(r)))).forEach(r=>{this._txBuilder.add_required_signer(r)}),this}setNativeScriptInput(e,t){const r=pt(t);return this._txBuilder.add_native_script_input(Vt(e),r.input(),r.output().amount()),this}setTimeToStart(e){return this._txBuilder.set_validity_start_interval_bignum(a.BigNum.from_str(e)),this}setTimeToExpire(e){return this._txBuilder.set_ttl_bignum(a.BigNum.from_str(e)),this}setTxInputs(e){return e.map(t=>pt(t)).forEach(t=>{this._txInputsBuilder.add_input(t.output().address(),t.input(),t.output().amount())}),this}setTxRefInputs(e){return e.map(t=>pt(t)).forEach(t=>{this._txBuilder.add_reference_input(t.input())}),this}withdrawRewards(e,t){const r=Ur(e);return r!==void 0&&this._txWithdrawals.insert(r,a.BigNum.from_str(t)),this}async addBurnInputsIfNeeded(){if(this._initiator&&this._totalBurns.size>0&&this.notVisited("setTxInputs")){const e=await this._initiator.getUsedUTxOs();wr(this._totalBurns,e.map(r=>ne(r))).map(r=>pt(r)).forEach(r=>{this._txInputsBuilder.add_input(r.output().address(),r.input(),r.output().amount())})}}async addChangeAddress(){if(this._initiator&&this._changeAddress===void 0){const e=await this._initiator.getUsedAddress();this._txBuilder.add_change_if_needed(e)}else this._changeAddress!==void 0&&this._txBuilder.add_change_if_needed(this._changeAddress)}async addCollateralIfNeeded(){if(this._initiator&&this.notVisited("setCollateral")){const e=await this._initiator.getUsedCollateral();this._txBuilder.set_collateral(Ir(e))}}async addRequiredSignersIfNeeded(){if(this._initiator&&this.notVisited("setRequiredSigners")){const e=await this._initiator.getUsedAddress(),t=qt(e.to_bech32());this._txBuilder.add_required_signer(Bt(t))}}async addTxInputsAsNeeded(){if(this.notVisited("setTxInputs")){const e=await this.filterAvailableUTxOs();xr(this._txOutputs,e.map(r=>ne(r))).map(r=>pt(r)).forEach(r=>{this._txInputsBuilder.add_input(r.output().address(),r.input(),r.output().amount())})}if(this._txBuilder.set_inputs(this._txInputsBuilder),(this._mintBuilder.has_native_scripts()||this._mintBuilder.has_plutus_scripts())&&this._txBuilder.set_mint_builder(this._mintBuilder),this._txCertificates.len()>0&&this._txBuilder.set_certs(this._txCertificates),this._txWithdrawals.len()>0&&this._txBuilder.set_withdrawals(this._txWithdrawals),this._txBuilder.get_mint_builder()||this.notVisited("redeemValue")===!1){const e=this._era!==void 0?Je[this._era]:Je.BABBAGE;this._txBuilder.calc_script_data_hash(e)}}async forgeAssetsIfNeeded(){const e=(t,r)=>{const n=t.data.assetName,i=t.data.metadata,c=t.unit.slice(0,dt);if(t.data.label==="777")return i;if(r&&r[c]){const{[c]:l,...p}=r,y={[n]:i,...l};return{[c]:{...y},...p}}return r!==void 0?{[c]:{[n]:i},...r}:{[c]:{[n]:i}}};await this.addBurnInputsIfNeeded(),Array.from(this._totalMints,t=>({unit:t[0],data:t[1]})).reduce((t,r)=>t.set(r.data.label,e(r,t.get(r.data.label))),new Map).forEach((t,r)=>{this._txBuilder.add_json_metadatum(a.BigNum.from_str(r),JSON.stringify(t))}),this.addMintOutputs()}async filterAvailableUTxOs(e=[]){return this._initiator===void 0?[]:(await this._initiator.getUsedUTxOs()).filter(r=>e.find(n=>n.input.txHash===r.input().transaction_id().to_hex())===void 0)}addMintOutputs(){this._recipients.forEach((e,t)=>{const n=St(e).multiasset();if(n!==void 0){const c=le(t).next().with_asset_and_min_required_coin_by_utxo_cost(n,Ue(this._protocolParameters.coinsPerUTxOSize)).build();this._txBuilder.add_output(c)}})}notVisited(e){return this.__visits.includes(e)===!1}setTxOutput(e){const r=a.BigNum.from_str(this._txOutputs.get(e.unit)??"0").checked_add(a.BigNum.from_str(e.quantity)).to_str();this._txOutputs.set(e.unit,r)}};Kt([Lt()],exports.Transaction.prototype,"mintAsset",null);Kt([Lt()],exports.Transaction.prototype,"redeemValue",null);Kt([Lt()],exports.Transaction.prototype,"sendAssets",null);Kt([Lt()],exports.Transaction.prototype,"sendValue",null);Kt([Lt()],exports.Transaction.prototype,"setCollateral",null);Kt([Lt()],exports.Transaction.prototype,"setRequiredSigners",null);Kt([Lt()],exports.Transaction.prototype,"setTxInputs",null);exports.Transaction=Kt([gn],exports.Transaction);const mn=(s,e,t)=>{const r=new Map(e);r.set("lovelace",String(Number(r.get("lovelace"))+Number(t)));const n=new Map;for(let w=0;w<s.length;w++)n.set(w,s[w]);const i=new Set,c=new Set,l=new Set,p=new Set,y=new Set;for(let w=0;w<s.length;w++)switch(s[w].output.amount.length){case 1:{c.add(w);break}case 2:{l.add(w);break}case 3:{p.add(w);break}default:{y.add(w);break}}const C=(w,v,P)=>{const k=n.get(w);if(!k)return;const N=pn(k,v);if(Number(N)>0){i.add(w),P.delete(w);for(const T of k.output.amount)r.set(T.unit,String(Number(r.get(T.unit))-Number(T.quantity)))}};for(const w of r.keys())if(w!="lovelace"){for(const v of l){const P=r.get(w);if(!P||Number(P)<=0)break;C(v,w,l)}for(const v of p){const P=r.get(w);if(!P||Number(P)<=0)break;C(v,w,p)}for(const v of y){const P=r.get(w);if(!P||Number(P)<=0)break;C(v,w,y)}}for(const w of c){const v=r.get("lovelace");if(!v||Number(v)<=0)break;C(w,"lovelace",c)}for(const w of l){const v=r.get("lovelace");if(!v||Number(v)<=0)break;C(w,"lovelace",l)}for(const w of p){const v=r.get("lovelace");if(!v||Number(v)<=0)break;C(w,"lovelace",p)}for(const w of y){const v=r.get("lovelace");if(!v||Number(v)<=0)break;C(w,"lovelace",y)}for(const w of r.keys())if(Number(r.get(w))>0)return[];const E=[];for(const w of i){const v=n.get(w);v&&E.push(v)}return E},pn=(s,e)=>{for(const t of s.output.amount)if(t.unit==e)return t.quantity;return"0"};var xe={exports:{}},Rr={exports:{}},qr={exports:{}};(function(s){(function(e){var t,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,c="[BigNumber Error] ",l=c+"Number primitive has more than 15 significant digits: ",p=1e14,y=14,C=9007199254740991,E=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],w=1e7,v=1e9;function P(O){var M,W,Z,D=b.prototype={constructor:b,toString:null,valueOf:null},F=new b(1),q=20,j=4,nt=-7,ut=21,Ht=-1e7,yt=1e7,Ft=!1,Zt=1,Tt=0,we={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},Rt="0123456789abcdefghijklmnopqrstuvwxyz",Ce=!0;function b(o,u){var h,I,f,m,x,d,g,_,A=this;if(!(A instanceof b))return new b(o,u);if(u==null){if(o&&o._isBigNumber===!0){A.s=o.s,!o.c||o.e>yt?A.c=A.e=null:o.e<Ht?A.c=[A.e=0]:(A.e=o.e,A.c=o.c.slice());return}if((d=typeof o=="number")&&o*0==0){if(A.s=1/o<0?(o=-o,-1):1,o===~~o){for(m=0,x=o;x>=10;x/=10,m++);m>yt?A.c=A.e=null:(A.e=m,A.c=[o]);return}_=String(o)}else{if(!r.test(_=String(o)))return Z(A,_,d);A.s=_.charCodeAt(0)==45?(_=_.slice(1),-1):1}(m=_.indexOf("."))>-1&&(_=_.replace(".","")),(x=_.search(/e/i))>0?(m<0&&(m=x),m+=+_.slice(x+1),_=_.substring(0,x)):m<0&&(m=_.length)}else{if(Q(u,2,Rt.length,"Base"),u==10&&Ce)return A=new b(o),gt(A,q+A.e+1,j);if(_=String(o),d=typeof o=="number"){if(o*0!=0)return Z(A,_,d,u);if(A.s=1/o<0?(_=_.slice(1),-1):1,b.DEBUG&&_.replace(/^0\.0*|\./,"").length>15)throw Error(l+o)}else A.s=_.charCodeAt(0)===45?(_=_.slice(1),-1):1;for(h=Rt.slice(0,u),m=x=0,g=_.length;x<g;x++)if(h.indexOf(I=_.charAt(x))<0){if(I=="."){if(x>m){m=g;continue}}else if(!f&&(_==_.toUpperCase()&&(_=_.toLowerCase())||_==_.toLowerCase()&&(_=_.toUpperCase()))){f=!0,x=-1,m=0;continue}return Z(A,String(o),d,u)}d=!1,_=W(_,u,10,A.s),(m=_.indexOf("."))>-1?_=_.replace(".",""):m=_.length}for(x=0;_.charCodeAt(x)===48;x++);for(g=_.length;_.charCodeAt(--g)===48;);if(_=_.slice(x,++g)){if(g-=x,d&&b.DEBUG&&g>15&&(o>C||o!==i(o)))throw Error(l+A.s*o);if((m=m-x-1)>yt)A.c=A.e=null;else if(m<Ht)A.c=[A.e=0];else{if(A.e=m,A.c=[],x=(m+1)%y,m<0&&(x+=y),x<g){for(x&&A.c.push(+_.slice(0,x)),g-=y;x<g;)A.c.push(+_.slice(x,x+=y));x=y-(_=_.slice(x)).length}else x-=g;for(;x--;_+="0");A.c.push(+_)}}else A.c=[A.e=0]}b.clone=P,b.ROUND_UP=0,b.ROUND_DOWN=1,b.ROUND_CEIL=2,b.ROUND_FLOOR=3,b.ROUND_HALF_UP=4,b.ROUND_HALF_DOWN=5,b.ROUND_HALF_EVEN=6,b.ROUND_HALF_CEIL=7,b.ROUND_HALF_FLOOR=8,b.EUCLID=9,b.config=b.set=function(o){var u,h;if(o!=null)if(typeof o=="object"){if(o.hasOwnProperty(u="DECIMAL_PLACES")&&(h=o[u],Q(h,0,v,u),q=h),o.hasOwnProperty(u="ROUNDING_MODE")&&(h=o[u],Q(h,0,8,u),j=h),o.hasOwnProperty(u="EXPONENTIAL_AT")&&(h=o[u],h&&h.pop?(Q(h[0],-v,0,u),Q(h[1],0,v,u),nt=h[0],ut=h[1]):(Q(h,-v,v,u),nt=-(ut=h<0?-h:h))),o.hasOwnProperty(u="RANGE"))if(h=o[u],h&&h.pop)Q(h[0],-v,-1,u),Q(h[1],1,v,u),Ht=h[0],yt=h[1];else if(Q(h,-v,v,u),h)Ht=-(yt=h<0?-h:h);else throw Error(c+u+" cannot be zero: "+h);if(o.hasOwnProperty(u="CRYPTO"))if(h=o[u],h===!!h)if(h)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))Ft=h;else throw Ft=!h,Error(c+"crypto unavailable");else Ft=h;else throw Error(c+u+" not true or false: "+h);if(o.hasOwnProperty(u="MODULO_MODE")&&(h=o[u],Q(h,0,9,u),Zt=h),o.hasOwnProperty(u="POW_PRECISION")&&(h=o[u],Q(h,0,v,u),Tt=h),o.hasOwnProperty(u="FORMAT"))if(h=o[u],typeof h=="object")we=h;else throw Error(c+u+" not an object: "+h);if(o.hasOwnProperty(u="ALPHABET"))if(h=o[u],typeof h=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(h))Ce=h.slice(0,10)=="0123456789",Rt=h;else throw Error(c+u+" invalid: "+h)}else throw Error(c+"Object expected: "+o);return{DECIMAL_PLACES:q,ROUNDING_MODE:j,EXPONENTIAL_AT:[nt,ut],RANGE:[Ht,yt],CRYPTO:Ft,MODULO_MODE:Zt,POW_PRECISION:Tt,FORMAT:we,ALPHABET:Rt}},b.isBigNumber=function(o){if(!o||o._isBigNumber!==!0)return!1;if(!b.DEBUG)return!0;var u,h,I=o.c,f=o.e,m=o.s;t:if({}.toString.call(I)=="[object Array]"){if((m===1||m===-1)&&f>=-v&&f<=v&&f===i(f)){if(I[0]===0){if(f===0&&I.length===1)return!0;break t}if(u=(f+1)%y,u<1&&(u+=y),String(I[0]).length==u){for(u=0;u<I.length;u++)if(h=I[u],h<0||h>=p||h!==i(h))break t;if(h!==0)return!0}}}else if(I===null&&f===null&&(m===null||m===1||m===-1))return!0;throw Error(c+"Invalid BigNumber: "+o)},b.maximum=b.max=function(){return We(arguments,-1)},b.minimum=b.min=function(){return We(arguments,1)},b.random=function(){var o=9007199254740992,u=Math.random()*o&2097151?function(){return i(Math.random()*o)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(h){var I,f,m,x,d,g=0,_=[],A=new b(F);if(h==null?h=q:Q(h,0,v),x=n(h/y),Ft)if(crypto.getRandomValues){for(I=crypto.getRandomValues(new Uint32Array(x*=2));g<x;)d=I[g]*131072+(I[g+1]>>>11),d>=9e15?(f=crypto.getRandomValues(new Uint32Array(2)),I[g]=f[0],I[g+1]=f[1]):(_.push(d%1e14),g+=2);g=x/2}else if(crypto.randomBytes){for(I=crypto.randomBytes(x*=7);g<x;)d=(I[g]&31)*281474976710656+I[g+1]*1099511627776+I[g+2]*4294967296+I[g+3]*16777216+(I[g+4]<<16)+(I[g+5]<<8)+I[g+6],d>=9e15?crypto.randomBytes(7).copy(I,g):(_.push(d%1e14),g+=7);g=x/7}else throw Ft=!1,Error(c+"crypto unavailable");if(!Ft)for(;g<x;)d=u(),d<9e15&&(_[g++]=d%1e14);for(x=_[--g],h%=y,x&&h&&(d=E[y-h],_[g]=i(x/d)*d);_[g]===0;_.pop(),g--);if(g<0)_=[m=0];else{for(m=-1;_[0]===0;_.splice(0,1),m-=y);for(g=1,d=_[0];d>=10;d/=10,g++);g<y&&(m-=y-g)}return A.e=m,A.c=_,A}}(),b.sum=function(){for(var o=1,u=arguments,h=new b(u[0]);o<u.length;)h=h.plus(u[o++]);return h},W=function(){var o="0123456789";function u(h,I,f,m){for(var x,d=[0],g,_=0,A=h.length;_<A;){for(g=d.length;g--;d[g]*=I);for(d[0]+=m.indexOf(h.charAt(_++)),x=0;x<d.length;x++)d[x]>f-1&&(d[x+1]==null&&(d[x+1]=0),d[x+1]+=d[x]/f|0,d[x]%=f)}return d.reverse()}return function(h,I,f,m,x){var d,g,_,A,B,U,K,L,tt=h.indexOf("."),st=q,V=j;for(tt>=0&&(A=Tt,Tt=0,h=h.replace(".",""),L=new b(I),U=L.pow(h.length-tt),Tt=A,L.c=u($(N(U.c),U.e,"0"),10,f,o),L.e=L.c.length),K=u(h,I,f,x?(d=Rt,o):(d=o,Rt)),_=A=K.length;K[--A]==0;K.pop());if(!K[0])return d.charAt(0);if(tt<0?--_:(U.c=K,U.e=_,U.s=m,U=M(U,L,st,V,f),K=U.c,B=U.r,_=U.e),g=_+st+1,tt=K[g],A=f/2,B=B||g<0||K[g+1]!=null,B=V<4?(tt!=null||B)&&(V==0||V==(U.s<0?3:2)):tt>A||tt==A&&(V==4||B||V==6&&K[g-1]&1||V==(U.s<0?8:7)),g<1||!K[0])h=B?$(d.charAt(1),-st,d.charAt(0)):d.charAt(0);else{if(K.length=g,B)for(--f;++K[--g]>f;)K[g]=0,g||(++_,K=[1].concat(K));for(A=K.length;!K[--A];);for(tt=0,h="";tt<=A;h+=d.charAt(K[tt++]));h=$(h,_,d.charAt(0))}return h}}(),M=function(){function o(I,f,m){var x,d,g,_,A=0,B=I.length,U=f%w,K=f/w|0;for(I=I.slice();B--;)g=I[B]%w,_=I[B]/w|0,x=K*g+_*U,d=U*g+x%w*w+A,A=(d/m|0)+(x/w|0)+K*_,I[B]=d%m;return A&&(I=[A].concat(I)),I}function u(I,f,m,x){var d,g;if(m!=x)g=m>x?1:-1;else for(d=g=0;d<m;d++)if(I[d]!=f[d]){g=I[d]>f[d]?1:-1;break}return g}function h(I,f,m,x){for(var d=0;m--;)I[m]-=d,d=I[m]<f[m]?1:0,I[m]=d*x+I[m]-f[m];for(;!I[0]&&I.length>1;I.splice(0,1));}return function(I,f,m,x,d){var g,_,A,B,U,K,L,tt,st,V,z,it,ae,Ee,be,wt,te,mt=I.s==f.s?1:-1,ot=I.c,et=f.c;if(!ot||!ot[0]||!et||!et[0])return new b(!I.s||!f.s||(ot?et&&ot[0]==et[0]:!et)?NaN:ot&&ot[0]==0||!et?mt*0:mt/0);for(tt=new b(mt),st=tt.c=[],_=I.e-f.e,mt=m+_+1,d||(d=p,_=k(I.e/y)-k(f.e/y),mt=mt/y|0),A=0;et[A]==(ot[A]||0);A++);if(et[A]>(ot[A]||0)&&_--,mt<0)st.push(1),B=!0;else{for(Ee=ot.length,wt=et.length,A=0,mt+=2,U=i(d/(et[0]+1)),U>1&&(et=o(et,U,d),ot=o(ot,U,d),wt=et.length,Ee=ot.length),ae=wt,V=ot.slice(0,wt),z=V.length;z<wt;V[z++]=0);te=et.slice(),te=[0].concat(te),be=et[0],et[1]>=d/2&&be++;do{if(U=0,g=u(et,V,wt,z),g<0){if(it=V[0],wt!=z&&(it=it*d+(V[1]||0)),U=i(it/be),U>1)for(U>=d&&(U=d-1),K=o(et,U,d),L=K.length,z=V.length;u(K,V,L,z)==1;)U--,h(K,wt<L?te:et,L,d),L=K.length,g=1;else U==0&&(g=U=1),K=et.slice(),L=K.length;if(L<z&&(K=[0].concat(K)),h(V,K,z,d),z=V.length,g==-1)for(;u(et,V,wt,z)<1;)U++,h(V,wt<z?te:et,z,d),z=V.length}else g===0&&(U++,V=[0]);st[A++]=U,V[0]?V[z++]=ot[ae]||0:(V=[ot[ae]],z=1)}while((ae++<Ee||V[0]!=null)&&mt--);B=V[0]!=null,st[0]||st.splice(0,1)}if(d==p){for(A=1,mt=st[0];mt>=10;mt/=10,A++);gt(tt,m+(tt.e=A+_*y-1)+1,x,B)}else tt.e=_,tt.r=+B;return tt}}();function Be(o,u,h,I){var f,m,x,d,g;if(h==null?h=j:Q(h,0,8),!o.c)return o.toString();if(f=o.c[0],x=o.e,u==null)g=N(o.c),g=I==1||I==2&&(x<=nt||x>=ut)?X(g,x):$(g,x,"0");else if(o=gt(new b(o),u,h),m=o.e,g=N(o.c),d=g.length,I==1||I==2&&(u<=m||m<=nt)){for(;d<u;g+="0",d++);g=X(g,m)}else if(u-=x,g=$(g,m,"0"),m+1>d){if(--u>0)for(g+=".";u--;g+="0");}else if(u+=m-d,u>0)for(m+1==d&&(g+=".");u--;g+="0");return o.s<0&&f?"-"+g:g}function We(o,u){for(var h,I,f=1,m=new b(o[0]);f<o.length;f++)I=new b(o[f]),(!I.s||(h=T(m,I))===u||h===0&&m.s===u)&&(m=I);return m}function Se(o,u,h){for(var I=1,f=u.length;!u[--f];u.pop());for(f=u[0];f>=10;f/=10,I++);return(h=I+h*y-1)>yt?o.c=o.e=null:h<Ht?o.c=[o.e=0]:(o.e=h,o.c=u),o}Z=function(){var o=/^(-?)0([xbo])(?=\w[\w.]*$)/i,u=/^([^.]+)\.$/,h=/^\.([^.]+)$/,I=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(m,x,d,g){var _,A=d?x:x.replace(f,"");if(I.test(A))m.s=isNaN(A)?null:A<0?-1:1;else{if(!d&&(A=A.replace(o,function(B,U,K){return _=(K=K.toLowerCase())=="x"?16:K=="b"?2:8,!g||g==_?U:B}),g&&(_=g,A=A.replace(u,"$1").replace(h,"0.$1")),x!=A))return new b(A,_);if(b.DEBUG)throw Error(c+"Not a"+(g?" base "+g:"")+" number: "+x);m.s=null}m.c=m.e=null}}();function gt(o,u,h,I){var f,m,x,d,g,_,A,B=o.c,U=E;if(B){t:{for(f=1,d=B[0];d>=10;d/=10,f++);if(m=u-f,m<0)m+=y,x=u,g=B[_=0],A=i(g/U[f-x-1]%10);else if(_=n((m+1)/y),_>=B.length)if(I){for(;B.length<=_;B.push(0));g=A=0,f=1,m%=y,x=m-y+1}else break t;else{for(g=d=B[_],f=1;d>=10;d/=10,f++);m%=y,x=m-y+f,A=x<0?0:i(g/U[f-x-1]%10)}if(I=I||u<0||B[_+1]!=null||(x<0?g:g%U[f-x-1]),I=h<4?(A||I)&&(h==0||h==(o.s<0?3:2)):A>5||A==5&&(h==4||I||h==6&&(m>0?x>0?g/U[f-x]:0:B[_-1])%10&1||h==(o.s<0?8:7)),u<1||!B[0])return B.length=0,I?(u-=o.e+1,B[0]=U[(y-u%y)%y],o.e=-u||0):B[0]=o.e=0,o;if(m==0?(B.length=_,d=1,_--):(B.length=_+1,d=U[y-m],B[_]=x>0?i(g/U[f-x]%U[x])*d:0),I)for(;;)if(_==0){for(m=1,x=B[0];x>=10;x/=10,m++);for(x=B[0]+=d,d=1;x>=10;x/=10,d++);m!=d&&(o.e++,B[0]==p&&(B[0]=1));break}else{if(B[_]+=d,B[_]!=p)break;B[_--]=0,d=1}for(m=B.length;B[--m]===0;B.pop());}o.e>yt?o.c=o.e=null:o.e<Ht&&(o.c=[o.e=0])}return o}function bt(o){var u,h=o.e;return h===null?o.toString():(u=N(o.c),u=h<=nt||h>=ut?X(u,h):$(u,h,"0"),o.s<0?"-"+u:u)}return D.absoluteValue=D.abs=function(){var o=new b(this);return o.s<0&&(o.s=1),o},D.comparedTo=function(o,u){return T(this,new b(o,u))},D.decimalPlaces=D.dp=function(o,u){var h,I,f,m=this;if(o!=null)return Q(o,0,v),u==null?u=j:Q(u,0,8),gt(new b(m),o+m.e+1,u);if(!(h=m.c))return null;if(I=((f=h.length-1)-k(this.e/y))*y,f=h[f])for(;f%10==0;f/=10,I--);return I<0&&(I=0),I},D.dividedBy=D.div=function(o,u){return M(this,new b(o,u),q,j)},D.dividedToIntegerBy=D.idiv=function(o,u){return M(this,new b(o,u),0,1)},D.exponentiatedBy=D.pow=function(o,u){var h,I,f,m,x,d,g,_,A,B=this;if(o=new b(o),o.c&&!o.isInteger())throw Error(c+"Exponent not an integer: "+bt(o));if(u!=null&&(u=new b(u)),d=o.e>14,!B.c||!B.c[0]||B.c[0]==1&&!B.e&&B.c.length==1||!o.c||!o.c[0])return A=new b(Math.pow(+bt(B),d?o.s*(2-R(o)):+bt(o))),u?A.mod(u):A;if(g=o.s<0,u){if(u.c?!u.c[0]:!u.s)return new b(NaN);I=!g&&B.isInteger()&&u.isInteger(),I&&(B=B.mod(u))}else{if(o.e>9&&(B.e>0||B.e<-1||(B.e==0?B.c[0]>1||d&&B.c[1]>=24e7:B.c[0]<8e13||d&&B.c[0]<=9999975e7)))return m=B.s<0&&R(o)?-0:0,B.e>-1&&(m=1/m),new b(g?1/m:m);Tt&&(m=n(Tt/y+2))}for(d?(h=new b(.5),g&&(o.s=1),_=R(o)):(f=Math.abs(+bt(o)),_=f%2),A=new b(F);;){if(_){if(A=A.times(B),!A.c)break;m?A.c.length>m&&(A.c.length=m):I&&(A=A.mod(u))}if(f){if(f=i(f/2),f===0)break;_=f%2}else if(o=o.times(h),gt(o,o.e+1,1),o.e>14)_=R(o);else{if(f=+bt(o),f===0)break;_=f%2}B=B.times(B),m?B.c&&B.c.length>m&&(B.c.length=m):I&&(B=B.mod(u))}return I?A:(g&&(A=F.div(A)),u?A.mod(u):m?gt(A,Tt,j,x):A)},D.integerValue=function(o){var u=new b(this);return o==null?o=j:Q(o,0,8),gt(u,u.e+1,o)},D.isEqualTo=D.eq=function(o,u){return T(this,new b(o,u))===0},D.isFinite=function(){return!!this.c},D.isGreaterThan=D.gt=function(o,u){return T(this,new b(o,u))>0},D.isGreaterThanOrEqualTo=D.gte=function(o,u){return(u=T(this,new b(o,u)))===1||u===0},D.isInteger=function(){return!!this.c&&k(this.e/y)>this.c.length-2},D.isLessThan=D.lt=function(o,u){return T(this,new b(o,u))<0},D.isLessThanOrEqualTo=D.lte=function(o,u){return(u=T(this,new b(o,u)))===-1||u===0},D.isNaN=function(){return!this.s},D.isNegative=function(){return this.s<0},D.isPositive=function(){return this.s>0},D.isZero=function(){return!!this.c&&this.c[0]==0},D.minus=function(o,u){var h,I,f,m,x=this,d=x.s;if(o=new b(o,u),u=o.s,!d||!u)return new b(NaN);if(d!=u)return o.s=-u,x.plus(o);var g=x.e/y,_=o.e/y,A=x.c,B=o.c;if(!g||!_){if(!A||!B)return A?(o.s=-u,o):new b(B?x:NaN);if(!A[0]||!B[0])return B[0]?(o.s=-u,o):new b(A[0]?x:j==3?-0:0)}if(g=k(g),_=k(_),A=A.slice(),d=g-_){for((m=d<0)?(d=-d,f=A):(_=g,f=B),f.reverse(),u=d;u--;f.push(0));f.reverse()}else for(I=(m=(d=A.length)<(u=B.length))?d:u,d=u=0;u<I;u++)if(A[u]!=B[u]){m=A[u]<B[u];break}if(m&&(f=A,A=B,B=f,o.s=-o.s),u=(I=B.length)-(h=A.length),u>0)for(;u--;A[h++]=0);for(u=p-1;I>d;){if(A[--I]<B[I]){for(h=I;h&&!A[--h];A[h]=u);--A[h],A[I]+=p}A[I]-=B[I]}for(;A[0]==0;A.splice(0,1),--_);return A[0]?Se(o,A,_):(o.s=j==3?-1:1,o.c=[o.e=0],o)},D.modulo=D.mod=function(o,u){var h,I,f=this;return o=new b(o,u),!f.c||!o.s||o.c&&!o.c[0]?new b(NaN):!o.c||f.c&&!f.c[0]?new b(f):(Zt==9?(I=o.s,o.s=1,h=M(f,o,0,3),o.s=I,h.s*=I):h=M(f,o,0,Zt),o=f.minus(h.times(o)),!o.c[0]&&Zt==1&&(o.s=f.s),o)},D.multipliedBy=D.times=function(o,u){var h,I,f,m,x,d,g,_,A,B,U,K,L,tt,st,V=this,z=V.c,it=(o=new b(o,u)).c;if(!z||!it||!z[0]||!it[0])return!V.s||!o.s||z&&!z[0]&&!it||it&&!it[0]&&!z?o.c=o.e=o.s=null:(o.s*=V.s,!z||!it?o.c=o.e=null:(o.c=[0],o.e=0)),o;for(I=k(V.e/y)+k(o.e/y),o.s*=V.s,g=z.length,B=it.length,g<B&&(L=z,z=it,it=L,f=g,g=B,B=f),f=g+B,L=[];f--;L.push(0));for(tt=p,st=w,f=B;--f>=0;){for(h=0,U=it[f]%st,K=it[f]/st|0,x=g,m=f+x;m>f;)_=z[--x]%st,A=z[x]/st|0,d=K*_+A*U,_=U*_+d%st*st+L[m]+h,h=(_/tt|0)+(d/st|0)+K*A,L[m--]=_%tt;L[m]=h}return h?++I:L.splice(0,1),Se(o,L,I)},D.negated=function(){var o=new b(this);return o.s=-o.s||null,o},D.plus=function(o,u){var h,I=this,f=I.s;if(o=new b(o,u),u=o.s,!f||!u)return new b(NaN);if(f!=u)return o.s=-u,I.minus(o);var m=I.e/y,x=o.e/y,d=I.c,g=o.c;if(!m||!x){if(!d||!g)return new b(f/0);if(!d[0]||!g[0])return g[0]?o:new b(d[0]?I:f*0)}if(m=k(m),x=k(x),d=d.slice(),f=m-x){for(f>0?(x=m,h=g):(f=-f,h=d),h.reverse();f--;h.push(0));h.reverse()}for(f=d.length,u=g.length,f-u<0&&(h=g,g=d,d=h,u=f),f=0;u;)f=(d[--u]=d[u]+g[u]+f)/p|0,d[u]=p===d[u]?0:d[u]%p;return f&&(d=[f].concat(d),++x),Se(o,d,x)},D.precision=D.sd=function(o,u){var h,I,f,m=this;if(o!=null&&o!==!!o)return Q(o,1,v),u==null?u=j:Q(u,0,8),gt(new b(m),o,u);if(!(h=m.c))return null;if(f=h.length-1,I=f*y+1,f=h[f]){for(;f%10==0;f/=10,I--);for(f=h[0];f>=10;f/=10,I++);}return o&&m.e+1>I&&(I=m.e+1),I},D.shiftedBy=function(o){return Q(o,-C,C),this.times("1e"+o)},D.squareRoot=D.sqrt=function(){var o,u,h,I,f,m=this,x=m.c,d=m.s,g=m.e,_=q+4,A=new b("0.5");if(d!==1||!x||!x[0])return new b(!d||d<0&&(!x||x[0])?NaN:x?m:1/0);if(d=Math.sqrt(+bt(m)),d==0||d==1/0?(u=N(x),(u.length+g)%2==0&&(u+="0"),d=Math.sqrt(+u),g=k((g+1)/2)-(g<0||g%2),d==1/0?u="5e"+g:(u=d.toExponential(),u=u.slice(0,u.indexOf("e")+1)+g),h=new b(u)):h=new b(d+""),h.c[0]){for(g=h.e,d=g+_,d<3&&(d=0);;)if(f=h,h=A.times(f.plus(M(m,f,_,1))),N(f.c).slice(0,d)===(u=N(h.c)).slice(0,d))if(h.e<g&&--d,u=u.slice(d-3,d+1),u=="9999"||!I&&u=="4999"){if(!I&&(gt(f,f.e+q+2,0),f.times(f).eq(m))){h=f;break}_+=4,d+=4,I=1}else{(!+u||!+u.slice(1)&&u.charAt(0)=="5")&&(gt(h,h.e+q+2,1),o=!h.times(h).eq(m));break}}return gt(h,h.e+q+1,j,o)},D.toExponential=function(o,u){return o!=null&&(Q(o,0,v),o++),Be(this,o,u,1)},D.toFixed=function(o,u){return o!=null&&(Q(o,0,v),o=o+this.e+1),Be(this,o,u)},D.toFormat=function(o,u,h){var I,f=this;if(h==null)o!=null&&u&&typeof u=="object"?(h=u,u=null):o&&typeof o=="object"?(h=o,o=u=null):h=we;else if(typeof h!="object")throw Error(c+"Argument not an object: "+h);if(I=f.toFixed(o,u),f.c){var m,x=I.split("."),d=+h.groupSize,g=+h.secondaryGroupSize,_=h.groupSeparator||"",A=x[0],B=x[1],U=f.s<0,K=U?A.slice(1):A,L=K.length;if(g&&(m=d,d=g,g=m,L-=m),d>0&&L>0){for(m=L%d||d,A=K.substr(0,m);m<L;m+=d)A+=_+K.substr(m,d);g>0&&(A+=_+K.slice(m)),U&&(A="-"+A)}I=B?A+(h.decimalSeparator||"")+((g=+h.fractionGroupSize)?B.replace(new RegExp("\\d{"+g+"}\\B","g"),"$&"+(h.fractionGroupSeparator||"")):B):A}return(h.prefix||"")+I+(h.suffix||"")},D.toFraction=function(o){var u,h,I,f,m,x,d,g,_,A,B,U,K=this,L=K.c;if(o!=null&&(d=new b(o),!d.isInteger()&&(d.c||d.s!==1)||d.lt(F)))throw Error(c+"Argument "+(d.isInteger()?"out of range: ":"not an integer: ")+bt(d));if(!L)return new b(K);for(u=new b(F),_=h=new b(F),I=g=new b(F),U=N(L),m=u.e=U.length-K.e-1,u.c[0]=E[(x=m%y)<0?y+x:x],o=!o||d.comparedTo(u)>0?m>0?u:_:d,x=yt,yt=1/0,d=new b(U),g.c[0]=0;A=M(d,u,0,1),f=h.plus(A.times(I)),f.comparedTo(o)!=1;)h=I,I=f,_=g.plus(A.times(f=_)),g=f,u=d.minus(A.times(f=u)),d=f;return f=M(o.minus(h),I,0,1),g=g.plus(f.times(_)),h=h.plus(f.times(I)),g.s=_.s=K.s,m=m*2,B=M(_,I,m,j).minus(K).abs().comparedTo(M(g,h,m,j).minus(K).abs())<1?[_,I]:[g,h],yt=x,B},D.toNumber=function(){return+bt(this)},D.toPrecision=function(o,u){return o!=null&&Q(o,1,v),Be(this,o,u,2)},D.toString=function(o){var u,h=this,I=h.s,f=h.e;return f===null?I?(u="Infinity",I<0&&(u="-"+u)):u="NaN":(o==null?u=f<=nt||f>=ut?X(N(h.c),f):$(N(h.c),f,"0"):o===10&&Ce?(h=gt(new b(h),q+f+1,j),u=$(N(h.c),h.e,"0")):(Q(o,2,Rt.length,"Base"),u=W($(N(h.c),f,"0"),10,o,I,!0)),I<0&&h.c[0]&&(u="-"+u)),u},D.valueOf=D.toJSON=function(){return bt(this)},D._isBigNumber=!0,O!=null&&b.set(O),b}function k(O){var M=O|0;return O>0||O===M?M:M-1}function N(O){for(var M,W,Z=1,D=O.length,F=O[0]+"";Z<D;){for(M=O[Z++]+"",W=y-M.length;W--;M="0"+M);F+=M}for(D=F.length;F.charCodeAt(--D)===48;);return F.slice(0,D+1||1)}function T(O,M){var W,Z,D=O.c,F=M.c,q=O.s,j=M.s,nt=O.e,ut=M.e;if(!q||!j)return null;if(W=D&&!D[0],Z=F&&!F[0],W||Z)return W?Z?0:-j:q;if(q!=j)return q;if(W=q<0,Z=nt==ut,!D||!F)return Z?0:!D^W?1:-1;if(!Z)return nt>ut^W?1:-1;for(j=(nt=D.length)<(ut=F.length)?nt:ut,q=0;q<j;q++)if(D[q]!=F[q])return D[q]>F[q]^W?1:-1;return nt==ut?0:nt>ut^W?1:-1}function Q(O,M,W,Z){if(O<M||O>W||O!==i(O))throw Error(c+(Z||"Argument")+(typeof O=="number"?O<M||O>W?" out of range: ":" not an integer: ":" not a primitive number: ")+String(O))}function R(O){var M=O.c.length-1;return k(O.e/y)==M&&O.c[M]%2!=0}function X(O,M){return(O.length>1?O.charAt(0)+"."+O.slice(1):O)+(M<0?"e":"e+")+M}function $(O,M,W){var Z,D;if(M<0){for(D=W+".";++M;D+=W);O=D+O}else if(Z=O.length,++M>Z){for(D=W,M-=Z;--M;D+=W);O+=D}else M<Z&&(O=O.slice(0,M)+"."+O.slice(M));return O}t=P(),t.default=t.BigNumber=t,s.exports?s.exports=t:(e||(e=typeof self<"u"&&self?self:window),e.BigNumber=t)})(Te)})(qr);var Vr=qr.exports;(function(s){var e=Vr,t=s.exports;(function(){var r=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,n,i,c={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},l;function p(C){return r.lastIndex=0,r.test(C)?'"'+C.replace(r,function(E){var w=c[E];return typeof w=="string"?w:"\\u"+("0000"+E.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+C+'"'}function y(C,E){var w,v,P,k,N=n,T,Q=E[C],R=Q!=null&&(Q instanceof e||e.isBigNumber(Q));switch(Q&&typeof Q=="object"&&typeof Q.toJSON=="function"&&(Q=Q.toJSON(C)),typeof l=="function"&&(Q=l.call(E,C,Q)),typeof Q){case"string":return R?Q:p(Q);case"number":return isFinite(Q)?String(Q):"null";case"boolean":case"null":case"bigint":return String(Q);case"object":if(!Q)return"null";if(n+=i,T=[],Object.prototype.toString.apply(Q)==="[object Array]"){for(k=Q.length,w=0;w<k;w+=1)T[w]=y(w,Q)||"null";return P=T.length===0?"[]":n?`[
|
|
2
|
-
`+n+T.join(`,
|
|
3
|
-
`+n)+`
|
|
4
|
-
`+N+"]":"["+T.join(",")+"]",n=N,P}if(l&&typeof l=="object")for(k=l.length,w=0;w<k;w+=1)typeof l[w]=="string"&&(v=l[w],P=y(v,Q),P&&T.push(p(v)+(n?": ":":")+P));else Object.keys(Q).forEach(function(X){var $=y(X,Q);$&&T.push(p(X)+(n?": ":":")+$)});return P=T.length===0?"{}":n?`{
|
|
5
|
-
`+n+T.join(`,
|
|
6
|
-
`+n)+`
|
|
7
|
-
`+N+"}":"{"+T.join(",")+"}",n=N,P}}typeof t.stringify!="function"&&(t.stringify=function(C,E,w){var v;if(n="",i="",typeof w=="number")for(v=0;v<w;v+=1)i+=" ";else typeof w=="string"&&(i=w);if(l=E,E&&typeof E!="function"&&(typeof E!="object"||typeof E.length!="number"))throw new Error("JSON.stringify");return y("",{"":C})})})()})(Rr);var An=Rr.exports,he=null;const In=/(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/,_n=/(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/;var yn=function(s){var e={strict:!1,storeAsString:!1,alwaysParseAsBig:!1,useNativeBigInt:!1,protoAction:"error",constructorAction:"error"};if(s!=null){if(s.strict===!0&&(e.strict=!0),s.storeAsString===!0&&(e.storeAsString=!0),e.alwaysParseAsBig=s.alwaysParseAsBig===!0?s.alwaysParseAsBig:!1,e.useNativeBigInt=s.useNativeBigInt===!0?s.useNativeBigInt:!1,typeof s.constructorAction<"u")if(s.constructorAction==="error"||s.constructorAction==="ignore"||s.constructorAction==="preserve")e.constructorAction=s.constructorAction;else throw new Error(`Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${s.constructorAction}`);if(typeof s.protoAction<"u")if(s.protoAction==="error"||s.protoAction==="ignore"||s.protoAction==="preserve")e.protoAction=s.protoAction;else throw new Error(`Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${s.protoAction}`)}var t,r,n={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
8
|
-
`,r:"\r",t:" "},i,c=function(k){throw{name:"SyntaxError",message:k,at:t,text:i}},l=function(k){return k&&k!==r&&c("Expected '"+k+"' instead of '"+r+"'"),r=i.charAt(t),t+=1,r},p=function(){var k,N="";for(r==="-"&&(N="-",l("-"));r>="0"&&r<="9";)N+=r,l();if(r===".")for(N+=".";l()&&r>="0"&&r<="9";)N+=r;if(r==="e"||r==="E")for(N+=r,l(),(r==="-"||r==="+")&&(N+=r,l());r>="0"&&r<="9";)N+=r,l();if(k=+N,!isFinite(k))c("Bad number");else return he==null&&(he=Vr),N.length>15?e.storeAsString?N:e.useNativeBigInt?BigInt(N):new he(N):e.alwaysParseAsBig?e.useNativeBigInt?BigInt(k):new he(k):k},y=function(){var k,N,T="",Q;if(r==='"')for(var R=t;l();){if(r==='"')return t-1>R&&(T+=i.substring(R,t-1)),l(),T;if(r==="\\"){if(t-1>R&&(T+=i.substring(R,t-1)),l(),r==="u"){for(Q=0,N=0;N<4&&(k=parseInt(l(),16),!!isFinite(k));N+=1)Q=Q*16+k;T+=String.fromCharCode(Q)}else if(typeof n[r]=="string")T+=n[r];else break;R=t}}c("Bad string")},C=function(){for(;r&&r<=" ";)l()},E=function(){switch(r){case"t":return l("t"),l("r"),l("u"),l("e"),!0;case"f":return l("f"),l("a"),l("l"),l("s"),l("e"),!1;case"n":return l("n"),l("u"),l("l"),l("l"),null}c("Unexpected '"+r+"'")},w,v=function(){var k=[];if(r==="["){if(l("["),C(),r==="]")return l("]"),k;for(;r;){if(k.push(w()),C(),r==="]")return l("]"),k;l(","),C()}}c("Bad array")},P=function(){var k,N=Object.create(null);if(r==="{"){if(l("{"),C(),r==="}")return l("}"),N;for(;r;){if(k=y(),C(),l(":"),e.strict===!0&&Object.hasOwnProperty.call(N,k)&&c('Duplicate key "'+k+'"'),In.test(k)===!0?e.protoAction==="error"?c("Object contains forbidden prototype property"):e.protoAction==="ignore"?w():N[k]=w():_n.test(k)===!0?e.constructorAction==="error"?c("Object contains forbidden constructor property"):e.constructorAction==="ignore"?w():N[k]=w():N[k]=w(),C(),r==="}")return l("}"),N;l(","),C()}}c("Bad object")};return w=function(){switch(C(),r){case"{":return P();case"[":return v();case'"':return y();case"-":return p();default:return r>="0"&&r<="9"?p():E()}},function(k,N){var T;return i=k+"",t=0,r=" ",T=w(),C(),r&&c("Syntax error"),typeof N=="function"?function Q(R,X){var $,O=R[X];return O&&typeof O=="object"&&Object.keys(O).forEach(function(M){$=Q(O,M),$!==void 0?O[M]=$:delete O[M]}),N.call(R,X,O)}({"":T},""):T}},xn=yn,Lr=An.stringify,Gr=xn;xe.exports=function(s){return{parse:Gr(s),stringify:Lr}};xe.exports.parse=Gr();xe.exports.stringify=Lr;var wn=xe.exports;const De=hs(wn);class Cn{txHex="";txBuilder=me();txEvaluationMultiplier=1.1;_protocolParams=It;txOutput;addingScriptInput=!1;addingPlutusMint=!1;isHydra=!1;meshTxBuilderBody;mintItem;txInQueueItem;collateralQueueItem;refScriptTxInQueueItem;reset=()=>(this.txHex="",this.txBuilder=me(),this.txEvaluationMultiplier=1.1,this._protocolParams=It,this.txOutput=void 0,this.addingScriptInput=!1,this.addingPlutusMint=!1,this.mintItem=void 0,this.txInQueueItem=void 0,this.collateralQueueItem=void 0,this.refScriptTxInQueueItem=void 0,this.meshTxBuilderBody=this.emptyTxBuilderBody(),this);emptyTxBuilderBody=()=>({inputs:[],outputs:[],extraInputs:[],selectionThreshold:0,collaterals:[],requiredSignatures:[],referenceInputs:[],mints:[],changeAddress:"",metadata:[],validityRange:{},certificates:[],signingKey:[]});constructor(){this.meshTxBuilderBody=this.emptyTxBuilderBody()}completeSync=e=>(e?this.meshTxBuilderBody=e:this.queueAllLastItem(),this.serializeTxBody(this.meshTxBuilderBody));completeSigning=()=>{const{signingKey:e}=this.meshTxBuilderBody;return e.length>0&&this.addAllSigningKeys(e),this.txHex};serializeTxBody=e=>{const{inputs:t,outputs:r,extraInputs:n,selectionThreshold:i,collaterals:c,referenceInputs:l,mints:p,changeAddress:y,certificates:C,validityRange:E,requiredSignatures:w,metadata:v}=e;if(this.isHydra?this.protocolParams({minFeeA:0,minFeeB:0,priceMem:0,priceStep:0,collateralPercent:0,coinsPerUTxOSize:"0"}):this.protocolParams({}),n.length>0&&this.addUtxosFrom(n,String(i)),this.removeDuplicateInputs(),this.meshTxBuilderBody.mints.sort((P,k)=>P.policyId.localeCompare(k.policyId)),this.meshTxBuilderBody.inputs.sort((P,k)=>P.txIn.txHash===k.txIn.txHash?P.txIn.txIndex-k.txIn.txIndex:P.txIn.txHash.localeCompare(k.txIn.txHash)),this.addAllInputs(t),this.addAllOutputs(r),this.addAllCollaterals(c),this.addAllReferenceInputs(l),this.addAllMints(p),this.addAllCertificates(C),this.addValidityRange(E),this.addAllRequiredSignatures(w),this.addAllMetadata(v),this.addCostModels(),y){const P=this.meshTxBuilderBody.collaterals.map(T=>{var Q,R;return((R=(Q=T.txIn.amount)==null?void 0:Q.find(X=>X.unit==="lovelace"))==null?void 0:R.quantity)||"0"}).reduce((T,Q)=>T+parseInt(Q),0),k=Math.ceil(this._protocolParams.collateralPercent*Number(Number(this.txBuilder.min_fee().checked_add(a.BigNum.from_str("10000")).to_js_value()))/100);let N=!1;if(P-k>0){const T=a.TransactionOutput.new(a.Address.from_bech32(y),a.Value.new(a.BigNum.from_str(String(k))));P-k>Number(a.min_ada_for_output(T,a.DataCost.new_coins_per_byte(a.BigNum.from_str(this._protocolParams.coinsPerUTxOSize))).to_js_value())&&(this.txBuilder.set_collateral_return(a.TransactionOutput.new(a.Address.from_bech32(y),a.Value.new(a.BigNum.from_str(String(P))))),this.txBuilder.set_total_collateral(a.BigNum.from_str(String(P))),N=!0)}this.addChange(y),N&&this.addCollateralReturn(y)}return this.buildTx(),this};txIn=(e,t,r,n)=>(this.txInQueueItem&&this.queueInput(),this.addingScriptInput?this.txInQueueItem={type:"Script",txIn:{txHash:e,txIndex:t,amount:r,address:n},scriptTxIn:{}}:this.txInQueueItem={type:"PubKey",txIn:{txHash:e,txIndex:t,amount:r,address:n}},this.addingScriptInput=!1,this);txInScript=(e,t)=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="PubKey"&&(this.txInQueueItem={type:"SimpleScript",txIn:this.txInQueueItem.txIn,simpleScriptTxIn:{scriptSource:{type:"Provided",script:e}}}),this.txInQueueItem.type==="Script"){const r=t||"V2";this.txInQueueItem.scriptTxIn.scriptSource={type:"Provided",script:{code:e,version:r}}}return this};txInDatumValue=(e,t="Mesh")=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="PubKey")throw Error("Datum value attempted to be called a non script input");if(this.txInQueueItem.type==="SimpleScript")throw Error("Datum value attempted to be called on a simple script input");let r=e;return t==="JSON"&&(r=this.castRawDataToJsonString(e)),t==="Mesh"?(this.txInQueueItem.scriptTxIn.datumSource={type:"Provided",data:{type:t,content:e}},this):(this.txInQueueItem.scriptTxIn.datumSource={type:"Provided",data:{type:t,content:r}},this)};txInInlineDatumPresent=()=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="PubKey")throw Error("Inline datum present attempted to be called a non script input");if(this.txInQueueItem.type==="SimpleScript")throw Error("Inline datum present attempted to be called on a simple script input");const{txHash:e,txIndex:t}=this.txInQueueItem.txIn;return e&&t.toString()&&(this.txInQueueItem.scriptTxIn.datumSource={type:"Inline",txHash:e,txIndex:t}),this};txInRedeemerValue=(e,t={...Yt},r="Mesh")=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="PubKey")throw Error("Spending tx in reference redeemer attempted to be called a non script input");if(this.txInQueueItem.type==="SimpleScript")throw Error("Spending tx in reference redeemer attempted to be called on a simple script input");let n=e;return r==="Mesh"?(this.txInQueueItem.scriptTxIn.redeemer={data:{type:r,content:e},exUnits:t},this):(r==="JSON"&&(n=this.castRawDataToJsonString(e)),this.txInQueueItem.scriptTxIn.redeemer={data:{type:r,content:n},exUnits:t},this)};txOut=(e,t)=>(this.txOutput&&(this.meshTxBuilderBody.outputs.push(this.txOutput),this.txOutput=void 0),this.txOutput={address:e,amount:t},this);txOutDatumHashValue=(e,t="Mesh")=>{let r=e;if(this.txOutput){if(t==="Mesh")return this.txOutput.datum={type:"Hash",data:{type:t,content:r}},this;t==="JSON"&&(r=this.castRawDataToJsonString(e)),this.txOutput.datum={type:"Hash",data:{type:t,content:r}}}return this};txOutInlineDatumValue=(e,t="Mesh")=>{let r=e;if(this.txOutput){if(t==="Mesh")return this.txOutput.datum={type:"Inline",data:{type:t,content:r}},this;t==="JSON"&&(r=this.castRawDataToJsonString(e)),this.txOutput.datum={type:"Inline",data:{type:t,content:r}}}return this};txOutReferenceScript=(e,t="V2")=>(this.txOutput&&(this.txOutput.referenceScript={code:e,version:t}),this);spendingPlutusScriptV2=()=>(this.addingScriptInput=!0,this);spendingTxInReference=(e,t,r,n="V2")=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="PubKey")throw Error("Spending tx in reference attempted to be called a non script input");if(this.txInQueueItem.type==="SimpleScript")throw Error("Spending tx in reference attempted to be called on a simple script input");return this.txInQueueItem.scriptTxIn.scriptSource={type:"Inline",txInInfo:{txHash:e,txIndex:t,spendingScriptHash:r,version:n}},this};spendingReferenceTxInInlineDatumPresent=()=>(this.txInInlineDatumPresent(),this);spendingReferenceTxInRedeemerValue=(e,t={...Yt},r="Mesh")=>(this.txInRedeemerValue(e,t,r),this);readOnlyTxInReference=(e,t)=>(this.meshTxBuilderBody.referenceInputs.push({txHash:e,txIndex:t}),this);mintPlutusScriptV2=()=>(this.addingPlutusMint=!0,this);mint=(e,t,r)=>(this.mintItem&&this.queueMint(),this.mintItem={type:this.addingPlutusMint?"Plutus":"Native",policyId:t,assetName:r,amount:e},this.addingPlutusMint=!1,this);mintingScript=(e,t="V2")=>{if(!this.mintItem)throw Error("Undefined mint");if(!this.mintItem.type)throw Error("Mint information missing");return this.mintItem.scriptSource={type:"Provided",script:{code:e,version:t}},this};mintTxInReference=(e,t,r="V2")=>{if(!this.mintItem)throw Error("Undefined mint");if(!this.mintItem.type)throw Error("Mint information missing");if(this.mintItem.type=="Native")throw Error("Mint tx in reference can only be used on plutus script tokens");if(!this.mintItem.policyId)throw Error("PolicyId information missing from mint asset");return this.mintItem.scriptSource={type:"Reference Script",txHash:e,txIndex:t,version:r},this};mintReferenceTxInRedeemerValue=(e,t={...Yt},r="Mesh")=>{if(!this.mintItem)throw Error("Undefined mint");if(this.mintItem.type=="Native")throw Error("Mint tx in reference can only be used on plutus script tokens");if(this.mintItem.type=="Plutus"){if(!this.mintItem.policyId)throw Error("PolicyId information missing from mint asset");let n=e;if(r==="Mesh")return this.mintItem.redeemer={data:{type:r,content:n},exUnits:t},this;r==="JSON"&&(n=this.castRawDataToJsonString(e)),this.mintItem.redeemer={data:{type:r,content:n},exUnits:t}}return this};mintRedeemerValue=(e,t={...Yt},r="Mesh")=>(this.mintReferenceTxInRedeemerValue(e,t,r),this);requiredSignerHash=e=>(this.meshTxBuilderBody.requiredSignatures.push(e),this);txInCollateral=(e,t,r,n)=>(this.collateralQueueItem&&this.meshTxBuilderBody.collaterals.push(this.collateralQueueItem),this.collateralQueueItem={type:"PubKey",txIn:{txHash:e,txIndex:t,amount:r,address:n}},this);registerPoolCertificate=e=>(this.meshTxBuilderBody.certificates.push({type:"RegisterPool",poolParams:e}),this);registerStakeCertificate=e=>(this.meshTxBuilderBody.certificates.push({type:"RegisterStake",stakeKeyHash:e}),this);delegateStakeCertificate=(e,t)=>(this.meshTxBuilderBody.certificates.push({type:"DelegateStake",stakeKeyHash:e,poolId:t}),this);deregisterStakeCertificate=e=>(this.meshTxBuilderBody.certificates.push({type:"DeregisterStake",stakeKeyHash:e}),this);retirePoolCertificate=(e,t)=>(this.meshTxBuilderBody.certificates.push({type:"RetirePool",poolId:e,epoch:t}),this);changeAddress=e=>(this.meshTxBuilderBody.changeAddress=e,this);invalidBefore=e=>(this.meshTxBuilderBody.validityRange.invalidBefore=e,this);invalidHereafter=e=>(this.meshTxBuilderBody.validityRange.invalidHereafter=e,this);metadataValue=(e,t)=>(this.meshTxBuilderBody.metadata.push({tag:e,metadata:t}),this);protocolParams=e=>{const t={...It,...e};return this._protocolParams=t,this.txBuilder=me(t),this};signingKey=e=>(this.meshTxBuilderBody.signingKey.push(e),this);selectUtxosFrom=(e,t=5e6)=>(this.meshTxBuilderBody.extraInputs=e,this.meshTxBuilderBody.selectionThreshold=t,this);addUtxosFrom=(e,t)=>{const r=this.meshTxBuilderBody.outputs.reduce((i,c)=>(c.amount.forEach(p=>{const{unit:y,quantity:C}=p,E=Number(i.get(y))||0;i.set(y,String(E+Number(C)))}),i),new Map);this.meshTxBuilderBody.inputs.reduce((i,c)=>{const l=c.txIn.amount;return l==null||l.forEach(p=>{const{unit:y,quantity:C}=p,E=Number(i.get(y))||0;i.set(y,String(E-Number(C)))}),i},r),this.meshTxBuilderBody.mints.reduce((i,c)=>{const l={unit:c.policyId+c.assetName,quantity:String(c.amount)},p=Number(i.get(l.unit))||0;return i.set(l.unit,String(p-Number(l.quantity))),i},r),mn(e,r,t).forEach(i=>{const c={type:"PubKey",txIn:{txHash:i.input.txHash,txIndex:i.input.outputIndex,amount:i.output.amount,address:i.output.address}};this.meshTxBuilderBody.inputs.push(c),this.addTxIn(c)})};addAllSigningKeys=e=>{if(e.length>0){const t=a.Vkeywitnesses.new(),r=a.Transaction.from_hex(this.txHex),n=r.body();e.forEach(l=>{const p=l.slice(0,4)==="5820"?l.slice(4):l,y=a.PrivateKey.from_hex(p),C=a.make_vkey_witness(a.hash_transaction(n),y);t.add(C)});const i=r.witness_set();i.set_vkeys(t);const c=a.Transaction.new(n,i,r.auxiliary_data());this.txHex=c.to_hex()}};buildTx=()=>{const e=this.txBuilder.build_tx();this.txHex=e.to_hex()};queueInput=()=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="Script")if(this.txInQueueItem.scriptTxIn){if(!this.txInQueueItem.scriptTxIn.datumSource)throw Error("Script input does not contain datum information");if(!this.txInQueueItem.scriptTxIn.redeemer)throw Error("Script input does not contain redeemer information");if(!this.txInQueueItem.scriptTxIn.scriptSource)throw Error("Script input does not contain script information")}else throw Error("Script input does not contain script, datum, or redeemer information");this.meshTxBuilderBody.inputs.push(this.txInQueueItem),this.txInQueueItem=void 0};queueMint=()=>{if(!this.mintItem)throw Error("Undefined mint");if(!this.mintItem.scriptSource)throw Error("Missing mint script information");this.meshTxBuilderBody.mints.push(this.mintItem),this.mintItem=void 0};makePlutusScriptSource=e=>{const t=a.ScriptHash.from_hex(e.spendingScriptHash),r=a.TransactionInput.new(a.TransactionHash.from_hex(e.txHash),e.txIndex);return a.PlutusScriptSource.new_ref_input_with_lang_ver(t,r,vt[e.version])};removeDuplicateInputs=()=>{const e=this.meshTxBuilderBody.inputs,t=n=>`${n.txHash}#${n.txIndex}`,r=[];for(let n=0;n<e.length;n++){const i=t(e[n].txIn);r.includes(i)?(e.splice(n,1),n--):r.push(i)}};addAllInputs=e=>{for(let t=0;t<e.length;t++){const r=e[t];switch(r.type){case"PubKey":this.addTxIn(r);break;case"SimpleScript":this.addNativeScriptTxIn(r);break;case"Script":this.addScriptTxIn(r);break}}};addTxIn=e=>{this.txBuilder.add_input(a.Address.from_bech32(e.txIn.address),a.TransactionInput.new(a.TransactionHash.from_hex(e.txIn.txHash),e.txIn.txIndex),St(e.txIn.amount))};addNativeScriptTxIn=({txIn:e,simpleScriptTxIn:t})=>{t.scriptSource.type==="Provided"&&this.txBuilder.add_native_script_input(a.NativeScript.from_hex(t.scriptSource.script),a.TransactionInput.new(a.TransactionHash.from_hex(e.txHash),e.txIndex),St(e.amount))};addScriptTxIn=({scriptTxIn:e,txIn:t})=>{let r;const{datumSource:n,scriptSource:i,redeemer:c}=e;if(n.type==="Provided")r=a.DatumSource.new(this.castDataToPlutusData(n.data));else{const y=a.TransactionInput.new(a.TransactionHash.from_hex(n.txHash),n.txIndex);r=a.DatumSource.new_ref_input(y)}let l;i.type=="Inline"?l=this.makePlutusScriptSource(i.txInInfo):l=a.PlutusScriptSource.new(a.PlutusScript.from_hex_with_version(i.script.code,vt[i.script.version]));const p=a.Redeemer.new(a.RedeemerTag.new_spend(),a.BigNum.from_str("0"),this.castDataToPlutusData(c.data),a.ExUnits.new(a.BigNum.from_str(String(c.exUnits.mem)),a.BigNum.from_str(String(c.exUnits.steps))));this.txBuilder.add_plutus_script_input(a.PlutusWitness.new_with_ref(l,r,p),a.TransactionInput.new(a.TransactionHash.from_hex(t.txHash),t.txIndex),St(t.amount))};addAllOutputs=e=>{for(let t=0;t<e.length;t++){const r=e[t];this.addOutput(r)}};addOutput=({amount:e,address:t,datum:r,referenceScript:n})=>{const i=St(e),c=i.multiasset();if(i.is_zero()&&c===void 0)throw Error("Invalid output amount");let l=a.TransactionOutputBuilder.new().with_address(xt(t));r&&r.type==="Hash"&&(l=l.with_data_hash(a.hash_plutus_data(this.castDataToPlutusData(r.data)))),r&&r.type==="Inline"&&(l=l.with_plutus_data(this.castDataToPlutusData(r.data))),n&&(l=l.with_script_ref(a.ScriptRef.new_plutus_script(a.PlutusScript.from_hex_with_version(n.code,vt[n.version]))));const p=l.next();if(c){const y=i.coin().is_zero()?p.with_asset_and_min_required_coin_by_utxo_cost(c,Ue(this._protocolParams.coinsPerUTxOSize)).build():p.with_coin_and_asset(i.coin(),c).build();this.txBuilder.add_output(y)}else{const y=p.with_coin(i.coin()).build();this.txBuilder.add_output(y)}};addAllCollaterals=e=>{const t=a.TxInputsBuilder.new();for(let r=0;r<e.length;r++){const n=e[r];this.addCollateral(t,n)}this.txBuilder.set_collateral(t)};addCollateral=(e,t)=>{e.add_input(a.Address.from_bech32(t.txIn.address),a.TransactionInput.new(a.TransactionHash.from_hex(t.txIn.txHash),t.txIn.txIndex),St(t.txIn.amount))};addCollateralReturn=e=>{var r;const t=(r=this.txBuilder.get_fee_if_set())==null?void 0:r.to_js_value();if(t){const n=Math.ceil(this._protocolParams.collateralPercent*Number(t)/100);this.txBuilder.set_total_collateral_and_return(a.BigNum.from_str(String(n)),a.Address.from_bech32(e))}};addAllReferenceInputs=e=>{e.forEach(t=>{this.addReferenceInput(t)})};addReferenceInput=({txHash:e,txIndex:t})=>{const r=a.TransactionInput.new(a.TransactionHash.from_hex(e),t);this.txBuilder.add_reference_input(r)};addAllMints=e=>{const t=a.MintBuilder.new();let r=0;for(let n=0;n<e.length;n++){const i=e[n];if(!i.scriptSource)throw Error("Mint script is expected to be provided");if(i.type==="Plutus"){if(!i.redeemer)throw Error("Missing mint redeemer information");this.addPlutusMint(t,i,r),r++}else i.type==="Native"&&this.addNativeMint(t,i)}this.txBuilder.set_mint_builder(t)};addPlutusMint=(e,{redeemer:t,policyId:r,scriptSource:n,assetName:i,amount:c},l)=>{const p=a.Redeemer.new(a.RedeemerTag.new_mint(),a.BigNum.from_str(String(l)),this.castDataToPlutusData(t.data),a.ExUnits.new(a.BigNum.from_str(String(t.exUnits.mem)),a.BigNum.from_str(String(t.exUnits.steps)))),y=n.type==="Reference Script"?a.PlutusScriptSource.new_ref_input_with_lang_ver(a.ScriptHash.from_hex(r),a.TransactionInput.new(a.TransactionHash.from_hex(n.txHash),n.txIndex),vt[n.version]):a.PlutusScriptSource.new(a.PlutusScript.from_hex_with_version(n.script.code,vt[n.script.version]));e.add_asset(a.MintWitness.new_plutus_script(y,p),a.AssetName.new(Buffer.from(i,"hex")),a.Int.from_str(c))};addNativeMint=(e,{scriptSource:t,assetName:r,amount:n})=>{if(t.type==="Reference Script")throw Error("Native mint cannot have reference script");e.add_asset(a.MintWitness.new_native_script(a.NativeScript.from_hex(t.script.code)),a.AssetName.new(Buffer.from(r,"hex")),a.Int.from_str(n))};decimalToFraction(e){const t=10**e.toString().split(".")[1].length;return[e*t,t]}toPoolParams=e=>{const t=this.decimalToFraction(e.margin),r=a.Relays.new();e.relays.forEach(c=>{r.add(Or(c))});const n=a.RewardAddress.from_address(a.Address.from_bech32(e.rewardAddress));if(n===void 0)throw new Error("Reward address is invalid");const i=a.Ed25519KeyHashes.new();return e.owners.forEach(c=>{i.add(a.Ed25519KeyHash.from_hex(c))}),a.PoolParams.new(a.Ed25519KeyHash.from_hex(e.operator),a.VRFKeyHash.from_hex(e.VRFKeyHash),a.BigNum.from_str(e.pledge),a.BigNum.from_str(e.cost),a.UnitInterval.new(a.BigNum.from_str(t[0].toString()),a.BigNum.from_str(t[1].toString())),n,i,r,e.metadata?a.PoolMetadata.from_json(De.stringify(e.metadata)):void 0)};addCertificate=(e,t)=>{switch(t.type){case"RegisterPool":e.add(a.Certificate.new_pool_registration(a.PoolRegistration.new(this.toPoolParams(t.poolParams))));break;case"RegisterStake":e.add(a.Certificate.new_stake_registration(a.StakeRegistration.new(a.StakeCredential.from_keyhash(a.Ed25519KeyHash.from_hex(t.stakeKeyHash)))));break;case"DelegateStake":e.add(a.Certificate.new_stake_delegation(a.StakeDelegation.new(a.StakeCredential.from_keyhash(a.Ed25519KeyHash.from_hex(t.stakeKeyHash)),t.poolId.startsWith("pool")?a.Ed25519KeyHash.from_bech32(t.poolId):a.Ed25519KeyHash.from_hex(t.poolId))));break;case"DeregisterStake":e.add(a.Certificate.new_stake_deregistration(a.StakeDeregistration.new(a.StakeCredential.from_keyhash(a.Ed25519KeyHash.from_hex(t.stakeKeyHash)))));break;case"RetirePool":e.add(a.Certificate.new_pool_retirement(a.PoolRetirement.new(t.poolId.startsWith("pool")?a.Ed25519KeyHash.from_bech32(t.poolId):a.Ed25519KeyHash.from_hex(t.poolId),t.epoch)))}};queueAllLastItem=()=>{this.txOutput&&(this.meshTxBuilderBody.outputs.push(this.txOutput),this.txOutput=void 0),this.txInQueueItem&&this.queueInput(),this.collateralQueueItem&&(this.meshTxBuilderBody.collaterals.push(this.collateralQueueItem),this.collateralQueueItem=void 0),this.mintItem&&this.queueMint()};addAllCertificates=e=>{const t=a.Certificates.new();e.forEach(r=>{this.addCertificate(t,r)}),this.txBuilder.set_certs(t)};addCostModels=()=>{this.txBuilder.calc_script_data_hash(a.TxBuilderConstants.plutus_vasil_cost_models())};addChange=e=>{this.txBuilder.add_change_if_needed(a.Address.from_bech32(e))};addValidityRange=({invalidBefore:e,invalidHereafter:t})=>{e&&this.txBuilder.set_validity_start_interval_bignum(a.BigNum.from_str(e.toString())),t&&this.txBuilder.set_ttl_bignum(a.BigNum.from_str(t.toString()))};addAllRequiredSignatures=e=>{e.forEach(t=>{this.txBuilder.add_required_signer(a.Ed25519KeyHash.from_hex(t))})};addAllMetadata=e=>{e.forEach(({tag:t,metadata:r})=>{this.txBuilder.add_json_metadatum(a.BigNum.from_str(t),De.stringify(r))})};updateRedeemer=(e,t)=>{t.forEach(r=>{switch(r.tag){case"SPEND":{const n=e.inputs[r.index];n.type=="Script"&&n.scriptTxIn.redeemer&&(n.scriptTxIn.redeemer.exUnits.mem=Math.floor(r.budget.mem*this.txEvaluationMultiplier),n.scriptTxIn.redeemer.exUnits.steps=Math.floor(r.budget.steps*this.txEvaluationMultiplier));break}case"MINT":{const n=e.mints[r.index];n.type=="Plutus"&&n.redeemer&&(n.redeemer.exUnits.mem=Math.floor(r.budget.mem*this.txEvaluationMultiplier),n.redeemer.exUnits.steps=Math.floor(r.budget.steps*this.txEvaluationMultiplier));break}}})};castRawDataToJsonString=e=>typeof e=="object"?De.stringify(e):e;castDataToPlutusData=({type:e,content:t})=>e==="Mesh"?Ot(t):e==="CBOR"?a.PlutusData.from_hex(t):a.PlutusData.from_json(t,a.PlutusDatumSchema.DetailedSchema)}class Bn extends Cn{_fetcher;_submitter;_evaluator;queriedTxHashes=new Set;queriedUTxOs={};constructor({fetcher:e,submitter:t,evaluator:r,isHydra:n=!1}){super(),e&&(this._fetcher=e),t&&(this._submitter=t),r&&(this._evaluator=r),n&&(this.isHydra=!0)}complete=async e=>{e?this.meshTxBuilderBody=e:this.queueAllLastItem();const{inputs:t,collaterals:r}=this.meshTxBuilderBody,n=[...t,...r].filter(i=>!this.isInputComplete(i));if(await this.queryAllTxInfo(n),n.forEach(i=>{this.completeTxInformation(i)}),this.completeSync(e),this._evaluator){const i=await this._evaluator.evaluateTx(this.txHex);this.updateRedeemer(this.meshTxBuilderBody,i),this.completeSync(e)}return this};submitTx=async e=>{var r;return await((r=this._submitter)==null?void 0:r.submitTx(e))};getUTxOInfo=async e=>{var r;let t=[];this.queriedTxHashes.has(e)||(this.queriedTxHashes.add(e),t=await((r=this._fetcher)==null?void 0:r.fetchUTxOs(e))||[],this.queriedUTxOs[e]=t)};queryAllTxInfo=e=>{var r;const t=[];if(e.length>0&&!this._fetcher)throw Error("Transaction information is incomplete while no fetcher instance is provided");for(let n=0;n<e.length;n++){const i=e[n];this.isInputInfoComplete(i)||t.push(this.getUTxOInfo(i.txIn.txHash)),i.type==="Script"&&((r=i.scriptTxIn.scriptSource)==null?void 0:r.type)==="Inline"&&!this.isRefScriptInfoComplete(i)&&t.push(this.getUTxOInfo(i.scriptTxIn.scriptSource.txInInfo.txHash))}return Promise.all(t)};completeTxInformation=e=>{var t;if(!this.isInputInfoComplete(e)){const r=this.queriedUTxOs[e.txIn.txHash],n=r==null?void 0:r.find(l=>l.input.outputIndex===e.txIn.txIndex),i=n==null?void 0:n.output.amount,c=n==null?void 0:n.output.address;if(!i||i.length===0)throw Error(`Couldn't find value information for ${e.txIn.txHash}#${e.txIn.txIndex}`);if(e.txIn.amount=i,e.type==="PubKey"){if(!c||c==="")throw Error(`Couldn't find address information for ${e.txIn.txHash}#${e.txIn.txIndex}`);e.txIn.address=c}}if(e.type==="Script"&&((t=e.scriptTxIn.scriptSource)==null?void 0:t.type)=="Inline"&&!this.isRefScriptInfoComplete(e)){const r=e.scriptTxIn.scriptSource.txInInfo,i=this.queriedUTxOs[r.txHash].find(c=>c.input.outputIndex===r.txIndex);if(!i)throw Error(`Couldn't find script reference utxo for ${r.txHash}#${r.txIndex}`);r.spendingScriptHash=i==null?void 0:i.output.scriptHash}};isInputComplete=e=>e.type==="PubKey"?this.isInputInfoComplete(e):e.type==="Script"?this.isInputInfoComplete(e)&&this.isRefScriptInfoComplete(e):!0;isInputInfoComplete=e=>{const{amount:t,address:r}=e.txIn;return!(e.type==="PubKey"&&(!t||!r)||e.type==="Script"&&!t)};isRefScriptInfoComplete=e=>{var r;const{scriptSource:t}=e.scriptTxIn;return!((t==null?void 0:t.type)==="Inline"&&!((r=t.txInInfo)!=null&&r.spendingScriptHash))}}class rt{_networkId;_encryptedSecret;constructor(e,t){this._networkId=e,this._encryptedSecret=t}getAccount(e,t,r=0){return this.accountContext(e,r,t,(n,i)=>{const c=mr(this._networkId,n.to_public().hash(),i.to_public().hash()).to_address().to_bech32(),l=pr(this._networkId,n.to_public().hash()).to_address().to_bech32(),p=Oe(this._networkId,i.to_public().hash()).to_address().to_bech32();return{baseAddress:c,enterpriseAddress:l,rewardAddress:p}})}signData(e,t,r,n,i=0){try{return this.accountContext(e,i,t,(c,l)=>{const p={payload:n},y={address:rt.resolveAddress(this._networkId,r,c,l),key:r.startsWith("stake")?l:c},{coseSign1:C,coseKey:E}=as(p,y);return{signature:C,key:E}})}catch(c){throw new Error(`An error occurred during signData: ${c}.`)}}signTx(e,t,r,n,i,c=0){try{const l=Ne(Ke(n));return this.accountContext(e,c,t,(p,y)=>{const C=a.Vkeywitnesses.new();return rt.resolveSigners(n,r,p.to_public().hash().to_hex()).forEach(w=>{if(w===p.to_public().hash().to_hex())C.add(a.make_vkey_witness(l,p));else if(w===y.to_public().hash().to_hex())C.add(a.make_vkey_witness(l,y));else if(i===!1)throw new Error(`Missing key witness for: ${w}`)}),C})}catch(l){throw new Error(`An error occurred during signTx: ${l}.`)}}addPaymentKey(e,t,r,n,i=0){const c=Ne(Ke(r));return this.accountContext(e,i,t,(l,p)=>{n.add(a.make_vkey_witness(c,l))}),n}static encryptMnemonic(e,t){const r=ke.mnemonicToEntropy(e.join(" ")),n=Hr(r),i=ht(n.as_bytes());return n.free(),rt.encrypt(i,t)}static encryptPrivateKey(e,t){const r=a.Bip32PrivateKey.from_bech32(e),n=ht(r.as_bytes());return r.free(),rt.encrypt(n,t)}static encryptSigningKeys(e,t,r){const n=rt.encrypt(e.slice(4),r),i=rt.encrypt(t.slice(4),r);return[n,i]}static generateMnemonic(e=256){return ke.generateMnemonic(e).split(" ")}accountContext(e,t,r,n){const{paymentKey:i,stakeKey:c}=rt.resolveKeys(e,t,r,this._encryptedSecret),l=n(i,c);return i.free(),c.free(),l}static decrypt(e,t){try{return a.decrypt_with_password(ft(t),e)}catch{throw new Error("The password is incorrect.")}}static encrypt(e,t){const r=_r.customAlphabet("0123456789abcdef"),n=r(64),i=r(24);return a.encrypt_with_password(ft(t),n,i,e)}static resolveAddress(e,t,r,n){const i=[mr(e,r.to_public().hash(),n.to_public().hash()),pr(e,r.to_public().hash()),Oe(e,n.to_public().hash())].find(c=>c.to_address().to_bech32()===t);if(i!==void 0)return i.to_address();throw new Error(`Address: ${t} doesn't belong to this account.`)}static resolveKeys(e,t,r,n){if(typeof n=="string"){const l=rt.decrypt(n,r);return Os(l,e,t)}const i=rt.decrypt(n[0],r),c=rt.decrypt(n[1],r);return{paymentKey:a.PrivateKey.from_hex(i),stakeKey:a.PrivateKey.from_hex(c)}}static resolveSigners(e,t,r){const n=l=>{const p=(T,Q=[],R=0)=>{var O,M,W,Z,D;if(T===void 0||R>=T.len())return Q;const X=T.get(R),$=new Array;switch(X.kind()){case a.CertificateKind.StakeDeregistration:{const F=(O=X.as_stake_deregistration())==null?void 0:O.stake_credential(),q=(F==null?void 0:F.kind())===a.StakeCredKind.Key?F.to_keyhash():void 0;q&&$.push(q.to_hex());break}case a.CertificateKind.StakeDelegation:{const F=(M=X.as_stake_delegation())==null?void 0:M.stake_credential(),q=(F==null?void 0:F.kind())===a.StakeCredKind.Key?F.to_keyhash():void 0;q&&$.push(q.to_hex());break}case a.CertificateKind.PoolRegistration:{const F=(W=X.as_pool_registration())==null?void 0:W.pool_params().pool_owners();$.push(...C(F));break}case a.CertificateKind.PoolRetirement:{const F=(Z=X.as_pool_retirement())==null?void 0:Z.pool_keyhash();F&&$.push(F.to_hex());break}case a.CertificateKind.MoveInstantaneousRewardsCert:{const F=(D=X.as_move_instantaneous_rewards_cert())==null?void 0:D.move_instantaneous_reward().as_to_stake_creds();if(F)for(let q=0;q<F.len();q+=1){const j=F.keys().get(q),nt=j.kind()===a.StakeCredKind.Key?j.to_keyhash():void 0;nt&&$.push(nt.to_hex())}break}}return p(T,[...Q,...$],R+1)},y=(T,Q=[],R=0)=>{if(T===void 0||R>=T.len())return Q;const X=T.get(R).index(),$=T.get(R).transaction_id(),O=t.find(M=>M.input.outputIndex===X&&M.input.txHash===$.to_hex())!==void 0?r:"OUR_PRINCESS_IS_IN_ANOTHER_CASTLE";return y(T,[...Q,O],R+1)},C=(T,Q=[],R=0)=>T===void 0||R>=T.len()?Q:C(T,[...Q,T.get(R).to_hex()],R+1),E=(T,Q=[],R=0)=>{if(T===void 0||R>=T.len())return Q;const X=T.keys().get(R).payment_cred(),$=X.kind()===a.StakeCredKind.Key?X.to_keyhash():void 0;return E(T,$?[...Q,$.to_hex()]:Q,R+1)},w=l.certs(),v=l.collateral(),P=l.inputs(),k=l.required_signers(),N=l.withdrawals();return[...p(w),...y(v),...y(P),...C(k),...E(N)]},i=l=>{const p=(C,E=[])=>{var w,v,P,k;if(C)for(let N=0;N<C.len();N+=1){const T=C.get(N);switch(T.kind()){case a.NativeScriptKind.ScriptPubkey:{const Q=(w=T.as_script_pubkey())==null?void 0:w.addr_keyhash().to_hex();return Q?[...E,Q]:E}case a.NativeScriptKind.ScriptAll:return p((v=T.as_script_all())==null?void 0:v.native_scripts(),E);case a.NativeScriptKind.ScriptAny:return p((P=T.as_script_any())==null?void 0:P.native_scripts(),E);case a.NativeScriptKind.ScriptNOfK:return p((k=T.as_script_n_of_k())==null?void 0:k.native_scripts(),E)}}return E},y=l.native_scripts();return[...p(y)]},c=At(e);return new Set([...n(c.body()),...i(c.witness_set())])}}const lt="MARI0TIME";class pe{_fetcher;_submitter;_wallet;constructor(e){switch(this._fetcher=e.fetcher,this._submitter=e.submitter,e.key.type){case"mnemonic":this._wallet=new rt(e.networkId,rt.encryptMnemonic(e.key.words,lt));break;case"root":this._wallet=new rt(e.networkId,rt.encryptPrivateKey(e.key.bech32,lt));break;case"cli":this._wallet=new rt(e.networkId,rt.encryptSigningKeys(e.key.payment,e.key.stake??"f0".repeat(34),lt))}}getBaseAddress(e=0,t=0){return this._wallet.getAccount(e,lt,t).baseAddress}getPaymentAddress(e=0,t=0){return this._wallet.getAccount(e,lt,t).enterpriseAddress}getRewardAddress(e=0,t=0){return this._wallet.getAccount(e,lt,t).rewardAddress}getUsedAddress(e=0,t=0){const r=this._wallet.getAccount(e,lt,t);return xt(r.enterpriseAddress)}getUsedCollateral(e=It.maxCollateralInputs){throw new Error("getUsedCollateral not implemented.")}async getUsedUTxOs(e=0,t="base"){if(!this._fetcher)throw new Error("[AppWallet] Fetcher is required to fetch UTxOs. Please provide a fetcher.");const r=this._wallet.getAccount(e,lt);return(await this._fetcher.fetchAddressUTxOs(t=="enterprise"?r.enterpriseAddress:r.baseAddress)).map(i=>pt(i))}signData(e,t,r=0,n=0){try{return this._wallet.signData(r,lt,e,t,n)}catch(i){throw new Error(`[AppWallet] An error occurred during signData: ${i}.`)}}async signTx(e,t=!1,r=0,n=0,i="base"){try{if(!this._fetcher)throw new Error("[AppWallet] Fetcher is required to fetch UTxOs. Please provide a fetcher.");const c=this._wallet.getAccount(r,lt),l=await this._fetcher.fetchAddressUTxOs(i=="enterprise"?c.enterpriseAddress:c.baseAddress),p=this._wallet.signTx(r,lt,l,e,t,n),y=At(e),C=y.witness_set(),E=_e(C,p);return C.set_vkeys(E),a.Transaction.new(y.body(),C,y.auxiliary_data()).to_hex()}catch(c){throw new Error(`[AppWallet] An error occurred during signTx: ${c}.`)}}signTxSync(e,t=!1,r=0,n=0){try{const i=this._wallet.signTx(r,lt,[],e,t,n);this._wallet.addPaymentKey(r,lt,e,i,n);const c=At(e),l=c.witness_set(),p=_e(l,i);return l.set_vkeys(p),a.Transaction.new(c.body(),l,c.auxiliary_data()).to_hex()}catch(i){throw new Error(`[AppWallet] An error occurred during signTx: ${i}.`)}}async signTxs(e,t){return console.log("unimplemented",e,t),[]}submitTx(e){if(!this._submitter)throw new Error("[AppWallet] Submitter is required to submit transactions. Please provide a submitter.");return this._submitter.submitTx(e)}static brew(e=256){return rt.generateMnemonic(e)}async getUtxos(){return await this.getUsedUTxOs()}async getCollateral(){return(await this.getUsedUTxOs())[0]}async getUsedAddresses(){return console.log(1,await this.getPaymentAddress()),[await this.getPaymentAddress()]}}class ye{_walletInstance;_walletName;walletInstance;constructor(e,t){this._walletInstance=e,this._walletName=t,this.walletInstance={...e}}static getInstalledWallets(){return window.cardano===void 0?[]:je.filter(e=>window.cardano[e]!==void 0).map(e=>({name:window.cardano[e].name,icon:window.cardano[e].icon,version:window.cardano[e].apiVersion}))}static async enable(e){try{const t=await ye.resolveInstance(e);if(t!==void 0)return new ye(t,e);throw new Error(`Couldn't create an instance of wallet: ${e}`)}catch(t){throw new Error(`[BrowserWallet] An error occurred during enable: ${JSON.stringify(t)}.`)}}async getBalance(){const e=await this._walletInstance.getBalance();return Kr(Vs(e))}async getChangeAddress(){const e=await this._walletInstance.getChangeAddress();return Gt(e).to_bech32()}async getCollateral(e=It.maxCollateralInputs){return(await this.getUsedCollateral(e)).map(r=>ne(r))}getNetworkId(){return this._walletInstance.getNetworkId()}async getRewardAddresses(){return(await this._walletInstance.getRewardAddresses()).map(t=>Gt(t).to_bech32())}async getUnusedAddresses(){return(await this._walletInstance.getUnusedAddresses()).map(t=>Gt(t).to_bech32())}async getUsedAddresses(){return(await this._walletInstance.getUsedAddresses()).map(t=>Gt(t).to_bech32())}async getUtxos(e=void 0){return(await this.getUsedUTxOs(e)).map(r=>ne(r))}signData(e,t){const r=xt(e).to_hex();return this._walletInstance.signData(r,ft(t))}async signTx(e,t=!1){try{const r=At(e),n=r.witness_set(),i=await this._walletInstance.signTx(e,t),c=fr(i).vkeys()??a.Vkeywitnesses.new(),l=_e(n,c);return n.set_vkeys(l),ht(a.Transaction.new(r.body(),n,r.auxiliary_data()).to_bytes())}catch(r){throw new Error(`[BrowserWallet] An error occurred during signTx: ${JSON.stringify(r)}.`)}}async signTxs(e,t=!1){let r;switch(this._walletName){case"Typhon Wallet":this._walletInstance.signTxs&&(r=await this._walletInstance.signTxs(e,t));break;default:this._walletInstance.signTxs?r=await this._walletInstance.signTxs(e.map(i=>({cbor:i,partialSign:t}))):this._walletInstance.experimental.signTxs&&(r=await this._walletInstance.experimental.signTxs(e.map(i=>({cbor:i,partialSign:t}))));break}if(!r)throw new Error("Wallet does not support signTxs");const n=[];for(let i=0;i<r.length;i++)if(!r[i])n.push(e[i]);else{const c=At(e[i]),l=c.witness_set(),p=fr(r[i]).vkeys()??a.Vkeywitnesses.new(),y=_e(l,p);l.set_vkeys(y);const C=ht(a.Transaction.new(c.body(),l,c.auxiliary_data()).to_bytes());n.push(C)}return n}submitTx(e){return this._walletInstance.submitTx(e)}async getUsedAddress(){const e=await this._walletInstance.getUsedAddresses();return Gt(e[0])}async getUsedCollateral(e=It.maxCollateralInputs){return(await this._walletInstance.experimental.getCollateral()??[]).map(r=>dr(r)).slice(0,e)}async getUsedUTxOs(e=void 0){const t=e?St(e).to_hex():void 0;return(await this._walletInstance.getUtxos(t)??[]).map(n=>dr(n))}async getAssets(){return(await this.getBalance()).filter(t=>t.unit!=="lovelace").map(t=>{const r=t.unit.slice(0,dt),n=t.unit.slice(dt),i=$e(r,n);return{unit:t.unit,policyId:r,assetName:Ye(n),fingerprint:i,quantity:t.quantity}})}async getLovelace(){const t=(await this.getBalance()).find(r=>r.unit==="lovelace");return t!==void 0?t.quantity:"0"}async getPolicyIdAssets(e){return(await this.getAssets()).filter(r=>r.policyId===e)}async getPolicyIds(){const e=await this.getBalance();return Array.from(new Set(e.map(t=>t.unit.slice(0,dt)))).filter(t=>t!=="lovelace")}static resolveInstance(e){if(window.cardano===void 0)return;const t=je.map(r=>window.cardano[r]).filter(r=>r!==void 0).find(r=>r.name.toLowerCase()===e.toLowerCase());return t==null?void 0:t.enable()}}class Sn{_wallet;_network;constructor(e){switch(this._network=e.networkId,e.key.type){case"root":this._wallet=new pe({networkId:e.networkId,fetcher:e.fetcher,submitter:e.submitter,key:{type:"root",bech32:e.key.bech32}});break;case"cli":this._wallet=new pe({networkId:e.networkId,fetcher:e.fetcher,submitter:e.submitter,key:{type:"cli",payment:e.key.payment}});break;case"mnemonic":this._wallet=new pe({networkId:e.networkId,fetcher:e.fetcher,submitter:e.submitter,key:{type:"mnemonic",words:e.key.words}});break}}async getBalance(){const e=await this.getUtxos(),t=new Map;return e.map(n=>{n.output.amount.map(i=>{const c=i.unit,l=Number(i.quantity);if(t.has(c)){const p=t.get(c);t.set(c,p+l)}else t.set(c,l)})}),Array.from(t,([n,i])=>({unit:n,quantity:i.toString()}))}getChangeAddress(e="base"){return e==="base"?this._wallet.getBaseAddress():this._wallet.getPaymentAddress()}async getCollateral(){const t=(await this.getUtxos()).filter(r=>r.output.amount.length===1&&r.output.amount[0].unit==="lovelace");t.sort((r,n)=>Number(r.output.amount[0].quantity)-Number(n.output.amount[0].quantity));for(const r of t)if(Number(r.output.amount[0].quantity)>=5e6)return[r];return[]}getNetworkId(){return this._network}async getRewardAddresses(){return[await this._wallet.getRewardAddress()]}getUnusedAddresses(e="base"){return e==="base"?[this._wallet.getBaseAddress()]:[this._wallet.getPaymentAddress()]}async getUsedAddresses(e="base"){return e==="base"?[this._wallet.getBaseAddress()]:[this._wallet.getPaymentAddress()]}async getUtxos(e="base"){return(await this.getUsedUTxOs(e)).map(r=>ne(r))}signData(e){return this._wallet.signData(this.getChangeAddress(),e)}async signTx(e,t=!1){return await this._wallet.signTx(e,t)}async signTxs(e,t=!1){const r=[];for(const n of e){const i=await this.signTx(n,t);r.push(i)}return r}async submitTx(e){return await this._wallet.submitTx(e)}getUsedAddress(){return this._wallet.getUsedAddress()}async getUsedCollateral(){return(await this.getCollateral()).map(r=>pt(r))}async getUsedUTxOs(e="base"){return await this._wallet.getUsedUTxOs(0,e)}async getAssets(){return(await this.getBalance()).filter(t=>t.unit!=="lovelace").map(t=>{const r=t.unit.slice(0,dt),n=t.unit.slice(dt),i=$e(r,n);return{unit:t.unit,policyId:r,assetName:Ye(n),fingerprint:i,quantity:t.quantity}})}async getLovelace(){const t=(await this.getBalance()).find(r=>r.unit==="lovelace");return t!==void 0?t.quantity:"0"}async getPolicyIdAssets(e){return(await this.getAssets()).filter(r=>r.policyId===e)}async getPolicyIds(){const e=await this.getBalance();return Array.from(new Set(e.map(t=>t.unit.slice(0,dt)))).filter(t=>t!=="lovelace")}async createCollateral(){const t=await new exports.Transaction({initiator:this._wallet}).sendLovelace(this.getChangeAddress(),"5000000").build(),r=await this.signTx(t);return await this.submitTx(r)}static brew(e=!1,t=256){const r=rt.generateMnemonic(t);return e?Fr(r):r}}exports.AppWallet=pe;exports.BlockfrostProvider=on;exports.BrowserWallet=ye;exports.EmbeddedWallet=rt;exports.ForgeScript=fn;exports.InfuraProvider=cn;exports.KoiosProvider=un;exports.MaestroProvider=hn;exports.MeshTxBuilder=Bn;exports.MeshWallet=Sn;exports.OgmiosProvider=ln;exports.YaciProvider=dn;exports.checkSignature=os;exports.generateNonce=sn;exports.isNetwork=yr;exports.keepRelevant=xr;exports.largestFirst=ts;exports.largestFirstMultiAsset=wr;exports.mergeAssets=zr;exports.parseAssetUnit=kt;exports.parseHttpError=S;exports.readPlutusData=nn;exports.readTransaction=an;exports.resolveDataHash=Ys;exports.resolveEpochNo=$s;exports.resolveFingerprint=$e;exports.resolveLanguageView=zs;exports.resolveNativeScriptAddress=Ws;exports.resolveNativeScriptHash=Js;exports.resolveNativeScriptHex=js;exports.resolvePaymentKeyHash=qt;exports.resolvePlutusScriptAddress=Xs;exports.resolvePlutusScriptHash=Zs;exports.resolvePoolId=tn;exports.resolvePrivateKey=Fr;exports.resolveRewardAddress=ie;exports.resolveScriptRef=en;exports.resolveSlotNo=rn;exports.resolveStakeKeyHash=$t;exports.resolveTxFees=ze;exports.resolveTxHash=Ke;
|