@meshsdk/core 1.5.7-beta.1 → 1.5.7

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.
@@ -1,4 +1,4 @@
1
1
  export declare const deriveAccountKeys: (rootKey: string, accountIndex: number) => {
2
- paymentKey: import("@emurgo/cardano-serialization-lib-asmjs").PrivateKey;
3
- stakeKey: import("@emurgo/cardano-serialization-lib-asmjs").PrivateKey;
2
+ paymentKey: import("@emurgo/cardano-serialization-lib-nodejs").PrivateKey;
3
+ stakeKey: import("@emurgo/cardano-serialization-lib-nodejs").PrivateKey;
4
4
  };
@@ -1 +1 @@
1
- export declare const deriveStakePoolColdKey: (rootKey: string, coldIndex: number) => import("@emurgo/cardano-serialization-lib-asmjs").PrivateKey;
1
+ export declare const deriveStakePoolColdKey: (rootKey: string, coldIndex: number) => import("@emurgo/cardano-serialization-lib-nodejs").PrivateKey;
@@ -1 +1 @@
1
- export declare const deriveForgingPolicyKey: (rootKey: string, policyIndex: number) => import("@emurgo/cardano-serialization-lib-asmjs").PrivateKey;
1
+ export declare const deriveForgingPolicyKey: (rootKey: string, policyIndex: number) => import("@emurgo/cardano-serialization-lib-nodejs").PrivateKey;
@@ -1,5 +1,5 @@
1
1
  import { csl } from '.';
2
- export * as csl from '@emurgo/cardano-serialization-lib-asmjs';
2
+ export * as csl from '@emurgo/cardano-serialization-lib-nodejs';
3
3
  export declare type Address = InstanceType<typeof csl.Address>;
4
4
  export declare type AssetName = InstanceType<typeof csl.AssetName>;
5
5
  export declare type AssetNames = InstanceType<typeof csl.AssetNames>;
package/dist/core.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ge=require("@emurgo/cardano-serialization-lib-asmjs"),J=require("axios"),Kt=require("bip39"),f=require("@emurgo/cardano-message-signing-asmjs");function Re(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 n=Re(Ge),$e=["testnet","preview","preprod","mainnet"],pe=s=>$e.includes(s);let ze=s=>crypto.getRandomValues(new Uint8Array(s)),We=(s,e,t)=>{let r=(2<<Math.log(s.length-1)/Math.LN2)-1,a=-~(1.6*r*e/s.length);return(i=e)=>{let o="";for(;;){let c=t(a),u=a;for(;u--;)if(o+=s[c[u]&r]||"",o.length===i)return o}}},fe=(s,e=21)=>We(s,e,ze);const _e={mem:7e6,steps:3e9},q={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"},kt=2147483648,wt={V1:n.Language.new_plutus_v1(),V2:n.Language.new_plutus_v2()},T=56,Je={CERT:n.RedeemerTag.new_cert(),MINT:n.RedeemerTag.new_mint(),REWARD:n.RedeemerTag.new_reward(),SPEND:n.RedeemerTag.new_spend()},Bt={testnet:["74","1598400","1595967616","432000"],preview:["183","15811222","1682467200","86400"],preprod:["65","26438400","1682121600","432000"],mainnet:["208","4492800","1596059091","432000"]},$t={ALONZO:n.TxBuilderConstants.plutus_alonzo_cost_models(),BABBAGE:(()=>{const s=n.Costmdls.new(),e=n.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,a)=>e.set(a,n.Int.new_i32(r)));const t=n.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,a)=>t.set(a,n.Int.new_i32(r))),s.insert(n.Language.new_plutus_v1(),e),s.insert(n.Language.new_plutus_v2(),t),s})()},je={ALONZO:{V1:"a141005901d59f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f704001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff"},BABBAGE:{V1:"a141005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff",V2:"a20198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c80041005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff"}},Pt={[n.NetworkInfo.testnet().network_id()]:"8d18d786e92776c824607fd8e193ec535c79dc61ea2405ddf3b09fe3",[n.NetworkInfo.mainnet().network_id()]:"f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a"},Xe={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"},Ze={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"},zt=["begin","eternl","flint","lace","nami","nufi","gerowallet","typhoncip30","vespr"],ye=(s,e,t="5000000")=>{const r=n.BigNum.from_str(s.get("lovelace")??"0").checked_add(n.BigNum.from_str(t)),a=e.filter(c=>c.output.amount.filter(u=>u.unit!=="lovelace").some(u=>s.has(u.unit))),i=rs(a);return[...i.less_than(r)?as(r.clamped_sub(i).to_str(),e.filter(c=>!a.some(u=>u.input.txHash===c.input.txHash&&u.input.outputIndex===c.input.outputIndex))):[],...a]},ts=(s,e,t=!1,{maxTxSize:r,minFeeA:a,minFeeB:i}=q)=>{const o=e.filter(g=>we(g)===!1).sort(Ft),c=n.BigNum.from_str(Vt(r,a,i)),u=t?n.BigNum.from_str(s).checked_add(c).to_str():s;return At(o,new Map([["lovelace",u]]))},Ce=(s,e,t=!1,r=q)=>{const a=e.filter(we).sort(Ft),i=ss(r),o=s.get("lovelace")??"0",c=t?n.BigNum.from_str(o).checked_add(i).to_str():o;return s.set("lovelace",c),At(a,s)},es=(s,e)=>Array.from(e,t=>({unit:t[0],quantity:n.BigNum.from_str(t[1])})).every(t=>s.filter(r=>r.output.amount.find(a=>a.unit===t.unit)!==void 0).reduce((r,a)=>{const i=a.output.amount.reduce((o,c)=>o.checked_add(n.BigNum.from_str(t.unit===c.unit?c.quantity:"0")),n.BigNum.from_str("0"));return r.checked_add(i)},n.BigNum.from_str("0")).less_than(t.quantity)===!1),Ft=(s,e)=>{var a,i;const t=n.BigNum.from_str(((a=s.output.amount.find(o=>o.unit==="lovelace"))==null?void 0:a.quantity)??"0");return n.BigNum.from_str(((i=e.output.amount.find(o=>o.unit==="lovelace"))==null?void 0:i.quantity)??"0").compare(t)},ss=s=>{const{maxTxSize:e,minFeeA:t,minFeeB:r}=s;return n.BigNum.from_str(Vt(e,t,r))},we=s=>s.output.amount.length>1,rs=s=>s.reduce((e,t)=>{var a;const r=((a=t.output.amount.find(i=>i.unit==="lovelace"))==null?void 0:a.quantity)??"0";return e.checked_add(n.BigNum.from_str(r))},n.BigNum.from_str("0")),as=(s,e)=>{const t=e.sort(Ft);return At(t,new Map([["lovelace",s]]))},At=(s,e,t=[])=>s.length===0||es(t,e)?t:ns(s[0],e)?At(s.slice(1),e,[...t,s[0]]):At(s.slice(1),e,t),ns=(s,e)=>Array.from(e.keys()).some(t=>s.output.amount.find(r=>r.unit===t)!==void 0),is=(s,e)=>{const t=us(e),r=As(s,e);return{coseKey:v(t.to_bytes()),coseSign1:v(r.to_bytes())}},os=(s,e,{key:t,signature:r})=>{var o,c;const a=f.COSEKey.from_bytes(m(t)),i=f.COSESign1.from_bytes(m(r));if((s==null?void 0:s.length)>0){const u=v(i.payload()??new Uint8Array);if(Q(s)!==u)return!1}if((e==null?void 0:e.length)>0){const A=(o=i.headers().protected().deserialized_headers().header(f.Label.new_text("address")))==null?void 0:o.as_bytes();if(A===void 0)throw new Error("Couldn't find a signer address in signature");const d=(c=a.header(f.Label.new_int(f.Int.new_negative(f.BigNum.from_str("2")))))==null?void 0:c.as_bytes();if(d===void 0)throw new Error("Couldn't find a signer key in signature");const g=st(v(A)),I=Hs(v(d));if(cs(e,g,I)===!1)throw new Error("Couldn't check signature because of address mismatch");const y=Ms(v(i.signature())),S=i.signed_data().to_bytes();return I.verify(S,y)}return!1},cs=(s,e,t)=>{if(s!==e.to_bech32())return!1;try{return rt(s)===t.hash().to_hex()}catch{return!1}},us=s=>{const e=f.COSEKey.new(f.Label.from_key_type(f.KeyType.OKP));return e.set_algorithm_id(f.Label.from_algorithm_id(f.AlgorithmId.EdDSA)),e.set_header(f.Label.new_int(f.Int.new_negative(f.BigNum.from_str("1"))),f.CBORValue.new_int(f.Int.new_i32(6))),e.set_header(f.Label.new_int(f.Int.new_negative(f.BigNum.from_str("2"))),f.CBORValue.new_bytes(s.key.to_public().as_bytes())),e},As=(s,e)=>{const t=f.HeaderMap.new(),r=f.HeaderMap.new();t.set_algorithm_id(f.Label.from_algorithm_id(f.AlgorithmId.EdDSA)),t.set_header(f.Label.new_text("address"),f.CBORValue.new_bytes(e.address.to_bytes()));const a=f.Headers.new(f.ProtectedHeaderMap.new(t),r),i=f.COSESign1Builder.new(a,m(s.payload),!1);s.externalAAD!==void 0&&i.set_external_aad(m(s.externalAAD));const o=i.make_data_to_sign(),c=e.key.sign(o.to_bytes());return i.build(c.to_bytes())};var Wt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Be={},b={exports:{}};G.notEqual=ds;G.notOk=ls;G.equal=gs;G.ok=G;var Ee=G;function gs(s,e,t){G(s==e,t)}function ds(s,e,t){G(s!=e,t)}function ls(s,e){G(!s,e)}function G(s,e){if(!s)throw new Error(e||"AssertionError")}var H={exports:{}};function hs(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 Is=Tt;Tt.supported=typeof WebAssembly<"u";function Tt(s){if(!Tt.supported)return null;var e=s&&s.imports,t=ms("AGFzbQEAAAABEANgAn9/AGADf39/AGABfwADBQQAAQICBQUBAQroBwdNBQZtZW1vcnkCAAxibGFrZTJiX2luaXQAAA5ibGFrZTJiX3VwZGF0ZQABDWJsYWtlMmJfZmluYWwAAhBibGFrZTJiX2NvbXByZXNzAAMK00AElgMAIABCADcDACAAQQhqQgA3AwAgAEEQakIANwMAIABBGGpCADcDACAAQSBqQgA3AwAgAEEoakIANwMAIABBMGpCADcDACAAQThqQgA3AwAgAEHAAGpCADcDACAAQcgAakIANwMAIABB0ABqQgA3AwAgAEHYAGpCADcDACAAQeAAakIANwMAIABB6ABqQgA3AwAgAEHwAGpCADcDACAAQfgAakIANwMAIABBgAFqQoiS853/zPmE6gBBACkDAIU3AwAgAEGIAWpCu86qptjQ67O7f0EIKQMAhTcDACAAQZABakKr8NP0r+68tzxBECkDAIU3AwAgAEGYAWpC8e30+KWn/aelf0EYKQMAhTcDACAAQaABakLRhZrv+s+Uh9EAQSApAwCFNwMAIABBqAFqQp/Y+dnCkdqCm39BKCkDAIU3AwAgAEGwAWpC6/qG2r+19sEfQTApAwCFNwMAIABBuAFqQvnC+JuRo7Pw2wBBOCkDAIU3AwAgAEHAAWpCADcDACAAQcgBakIANwMAIABB0AFqQgA3AwALbQEDfyAAQcABaiEDIABByAFqIQQgBCkDAKchBQJAA0AgASACRg0BIAVBgAFGBEAgAyADKQMAIAWtfDcDAEEAIQUgABADCyAAIAVqIAEtAAA6AAAgBUEBaiEFIAFBAWohAQwACwsgBCAFrTcDAAtkAQN/IABBwAFqIQEgAEHIAWohAiABIAEpAwAgAikDAHw3AwAgAEHQAWpCfzcDACACKQMApyEDAkADQCADQYABRg0BIAAgA2pBADoAACADQQFqIQMMAAsLIAIgA603AwAgABADC+U7AiB+CX8gAEGAAWohISAAQYgBaiEiIABBkAFqISMgAEGYAWohJCAAQaABaiElIABBqAFqISYgAEGwAWohJyAAQbgBaiEoICEpAwAhASAiKQMAIQIgIykDACEDICQpAwAhBCAlKQMAIQUgJikDACEGICcpAwAhByAoKQMAIQhCiJLznf/M+YTqACEJQrvOqqbY0Ouzu38hCkKr8NP0r+68tzwhC0Lx7fT4paf9p6V/IQxC0YWa7/rPlIfRACENQp/Y+dnCkdqCm38hDkLr+obav7X2wR8hD0L5wvibkaOz8NsAIRAgACkDACERIABBCGopAwAhEiAAQRBqKQMAIRMgAEEYaikDACEUIABBIGopAwAhFSAAQShqKQMAIRYgAEEwaikDACEXIABBOGopAwAhGCAAQcAAaikDACEZIABByABqKQMAIRogAEHQAGopAwAhGyAAQdgAaikDACEcIABB4ABqKQMAIR0gAEHoAGopAwAhHiAAQfAAaikDACEfIABB+ABqKQMAISAgDSAAQcABaikDAIUhDSAPIABB0AFqKQMAhSEPIAEgBSARfHwhASANIAGFQiCKIQ0gCSANfCEJIAUgCYVCGIohBSABIAUgEnx8IQEgDSABhUIQiiENIAkgDXwhCSAFIAmFQj+KIQUgAiAGIBN8fCECIA4gAoVCIIohDiAKIA58IQogBiAKhUIYiiEGIAIgBiAUfHwhAiAOIAKFQ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/iiEGIAMgByAafHwhAyAPIAOFQiCKIQ8gCyAPfCELIAcgC4VCGIohByADIAcgIHx8IQMgDyADhUIQiiEPIAsgD3whCyAHIAuFQj+KIQcgBCAIIB58fCEEIBAgBIVCIIohECAMIBB8IQwgCCAMhUIYiiEIIAQgCCAXfHwhBCAQIASFQhCKIRAgDCAQfCEMIAggDIVCP4ohCCABIAYgEnx8IQEgECABhUIgiiEQIAsgEHwhCyAGIAuFQhiKIQYgASAGIB18fCEBIBAgAYVCEIohECALIBB8IQsgBiALhUI/iiEGIAIgByARfHwhAiANIAKFQiCKIQ0gDCANfCEMIAcgDIVCGIohByACIAcgE3x8IQIgDSAChUIQiiENIAwgDXwhDCAHIAyFQj+KIQcgAyAIIBx8fCEDIA4gA4VCIIohDiAJIA58IQkgCCAJhUIYiiEIIAMgCCAYfHwhAyAOIAOFQhCKIQ4gCSAOfCEJIAggCYVCP4ohCCAEIAUgFnx8IQQgDyAEhUIgiiEPIAogD3whCiAFIAqFQhiKIQUgBCAFIBR8fCEEIA8gBIVCEIohDyAKIA98IQogBSAKhUI/iiEFICEgISkDACABIAmFhTcDACAiICIpAwAgAiAKhYU3AwAgIyAjKQMAIAMgC4WFNwMAICQgJCkDACAEIAyFhTcDACAlICUpAwAgBSANhYU3AwAgJiAmKQMAIAYgDoWFNwMAICcgJykDACAHIA+FhTcDACAoICgpAwAgCCAQhYU3AwAL"),r=null,a={buffer:t,memory:null,exports:null,realloc:i,onload:o};return o(function(){}),a;function i(u){a.exports.memory.grow(Math.ceil(Math.abs(u-a.memory.length)/65536)),a.memory=new Uint8Array(a.exports.memory.buffer)}function o(u){if(a.exports)return u();if(r){r.then(u.bind(null,null)).catch(u);return}try{if(s&&s.async)throw new Error("async");c({instance:new WebAssembly.Instance(new WebAssembly.Module(t),e)})}catch{r=WebAssembly.instantiate(t,e).then(c)}o(u)}function c(u){a.exports=u.instance.exports,a.memory=a.exports.memory&&a.exports.memory.buffer&&new Uint8Array(a.exports.memory.buffer)}}function ms(s){return typeof atob=="function"?new Uint8Array(atob(s).split("").map(ps)):new(hs("buffer")).Buffer(s,"base64")}function ps(s){return s.charCodeAt(0)}var N=Ee,_=Is(),Y=64,ft=[];H.exports=D;var Jt=H.exports.BYTES_MIN=16,jt=H.exports.BYTES_MAX=64;H.exports.BYTES=32;var Xt=H.exports.KEYBYTES_MIN=16,Zt=H.exports.KEYBYTES_MAX=64;H.exports.KEYBYTES=32;var te=H.exports.SALTBYTES=16,ee=H.exports.PERSONALBYTES=16;function D(s,e,t,r,a){if(!(this instanceof D))return new D(s,e,t,r,a);if(!(_&&_.exports))throw new Error("WASM not loaded. Wait for Blake2b.ready(cb)");s||(s=32),a!==!0&&(N(s>=Jt,"digestLength must be at least "+Jt+", was given "+s),N(s<=jt,"digestLength must be at most "+jt+", was given "+s),e!=null&&N(e.length>=Xt,"key must be at least "+Xt+", was given "+e.length),e!=null&&N(e.length<=Zt,"key must be at least "+Zt+", was given "+e.length),t!=null&&N(t.length===te,"salt must be exactly "+te+", was given "+t.length),r!=null&&N(r.length===ee,"personal must be exactly "+ee+", was given "+r.length)),ft.length||(ft.push(Y),Y+=216),this.digestLength=s,this.finalized=!1,this.pointer=ft.pop(),_.memory.fill(0,0,64),_.memory[0]=this.digestLength,_.memory[1]=e?e.length:0,_.memory[2]=1,_.memory[3]=1,t&&_.memory.set(t,32),r&&_.memory.set(r,48),this.pointer+216>_.memory.length&&_.realloc(this.pointer+216),_.exports.blake2b_init(this.pointer,this.digestLength),e&&(this.update(e),_.memory.fill(0,Y,Y+e.length),_.memory[this.pointer+200]=128)}D.prototype.update=function(s){return N(this.finalized===!1,"Hash instance finalized"),N(s,"input must be TypedArray or Buffer"),Y+s.length>_.memory.length&&_.realloc(Y+s.length),_.memory.set(s,Y),_.exports.blake2b_update(this.pointer,Y,Y+s.length),this};D.prototype.digest=function(s){if(N(this.finalized===!1,"Hash instance finalized"),this.finalized=!0,ft.push(this.pointer),_.exports.blake2b_final(this.pointer),!s||s==="binary")return _.memory.slice(this.pointer+128,this.pointer+128+this.digestLength);if(s==="hex")return _s(_.memory,this.pointer+128,this.digestLength);N(s.length>=this.digestLength,"input must be TypedArray or Buffer");for(var e=0;e<this.digestLength;e++)s[e]=_.memory[this.pointer+128+e];return s};D.prototype.final=D.prototype.digest;D.WASM=_&&_.buffer;D.SUPPORTED=typeof WebAssembly<"u";D.ready=function(s){if(s||(s=fs),!_)return s(new Error("WebAssembly not supported"));var e=new Promise(function(t,r){_.onload(function(a){a?r():t(),s(a)})});return e};D.prototype.ready=D.ready;function fs(){}function _s(s,e,t){for(var r="",a=0;a<t;a++)r+=ys(s[e+a]);return r}function ys(s){return s<16?"0"+s.toString(16):s.toString(16)}var Cs=H.exports,W=Ee,gt=Cs;function ht(s,e,t){var r=s[e]+s[t],a=s[e+1]+s[t+1];r>=4294967296&&a++,s[e]=r,s[e+1]=a}function se(s,e,t,r){var a=s[e]+t;t<0&&(a+=4294967296);var i=s[e+1]+r;a>=4294967296&&i++,s[e]=a,s[e+1]=i}function xe(s,e){return s[e]^s[e+1]<<8^s[e+2]<<16^s[e+3]<<24}function $(s,e,t,r,a,i){var o=ut[a],c=ut[a+1],u=ut[i],A=ut[i+1];ht(h,s,e),se(h,s,o,c);var d=h[r]^h[s],g=h[r+1]^h[s+1];h[r]=g,h[r+1]=d,ht(h,t,r),d=h[e]^h[t],g=h[e+1]^h[t+1],h[e]=d>>>24^g<<8,h[e+1]=g>>>24^d<<8,ht(h,s,e),se(h,s,u,A),d=h[r]^h[s],g=h[r+1]^h[s+1],h[r]=d>>>16^g<<16,h[r+1]=g>>>16^d<<16,ht(h,t,r),d=h[e]^h[t],g=h[e+1]^h[t+1],h[e]=g>>>31^d<<1,h[e+1]=d>>>31^g<<1}var Se=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),ws=[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],E=new Uint8Array(ws.map(function(s){return s*2})),h=new Uint32Array(32),ut=new Uint32Array(32);function Qe(s,e){var t=0;for(t=0;t<16;t++)h[t]=s.h[t],h[t+16]=Se[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++)ut[t]=xe(s.b,4*t);for(t=0;t<12;t++)$(0,8,16,24,E[t*16+0],E[t*16+1]),$(2,10,18,26,E[t*16+2],E[t*16+3]),$(4,12,20,28,E[t*16+4],E[t*16+5]),$(6,14,22,30,E[t*16+6],E[t*16+7]),$(0,10,20,30,E[t*16+8],E[t*16+9]),$(2,12,22,24,E[t*16+10],E[t*16+11]),$(4,14,16,26,E[t*16+12],E[t*16+13]),$(6,8,18,28,E[t*16+14],E[t*16+15]);for(t=0;t<16;t++)s.h[t]=s.h[t]^h[t]^h[t+16]}var z=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 nt(s,e,t,r){z.fill(0),this.b=new Uint8Array(128),this.h=new Uint32Array(16),this.t=0,this.c=0,this.outlen=s,z[0]=s,e&&(z[1]=e.length),z[2]=1,z[3]=1,t&&z.set(t,32),r&&z.set(r,48);for(var a=0;a<16;a++)this.h[a]=Se[a]^xe(z,a*4);e&&(be(this,e),this.c=128)}nt.prototype.update=function(s){return W(s!=null,"input must be Uint8Array or Buffer"),be(this,s),this};nt.prototype.digest=function(s){var e=!s||s==="binary"||s==="hex"?new Uint8Array(this.outlen):s;return W(e.length>=this.outlen,"out must have at least outlen bytes of space"),Bs(this,e),s==="hex"?Es(e):e};nt.prototype.final=nt.prototype.digest;nt.ready=function(s){gt.ready(function(){s()})};function be(s,e){for(var t=0;t<e.length;t++)s.c===128&&(s.t+=s.c,Qe(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;Qe(s,!0);for(var t=0;t<s.outlen;t++)e[t]=s.h[t>>2]>>8*(t&3);return e}function Es(s){for(var e="",t=0;t<s.length;t++)e+=xs(s[t]);return e}function xs(s){return s<16?"0"+s.toString(16):s.toString(16)}var ve=nt;b.exports=function(e,t,r,a,i){return i!==!0&&(W(e>=re,"outlen must be at least "+re+", was given "+e),W(e<=ae,"outlen must be at most "+ae+", was given "+e),t!=null&&W(t.length>=ne,"key must be at least "+ne+", was given "+t.length),t!=null&&W(t.length<=ie,"key must be at most "+ie+", was given "+t.length),r!=null&&W(r.length===oe,"salt must be exactly "+oe+", was given "+r.length),a!=null&&W(a.length===ce,"personal must be exactly "+ce+", was given "+a.length)),new ve(e,t,r,a)};b.exports.ready=function(s){gt.ready(function(){s()})};b.exports.WASM_SUPPORTED=gt.SUPPORTED;b.exports.WASM_LOADED=!1;var re=b.exports.BYTES_MIN=16,ae=b.exports.BYTES_MAX=64;b.exports.BYTES=32;var ne=b.exports.KEYBYTES_MIN=16,ie=b.exports.KEYBYTES_MAX=64;b.exports.KEYBYTES=32;var oe=b.exports.SALTBYTES=16,ce=b.exports.PERSONALBYTES=16;gt.ready(function(s){s||(b.exports.WASM_LOADED=!0,ve=gt)});var Ss=b.exports,it={};Object.defineProperty(it,"__esModule",{value:!0});it.bech32m=it.bech32=void 0;const Et="qpzry9x8gf2tvdw0s3jn54khce6mua7l",De={};for(let s=0;s<Et.length;s++){const e=Et.charAt(s);De[e]=s}function at(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 ue(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=at(e)^r>>5}e=at(e);for(let t=0;t<s.length;++t){const r=s.charCodeAt(t);e=at(e)^r&31}return e}function Mt(s,e,t,r){let a=0,i=0;const o=(1<<t)-1,c=[];for(let u=0;u<s.length;++u)for(a=a<<e|s[u],i+=e;i>=t;)i-=t,c.push(a>>i&o);if(r)i>0&&c.push(a<<t-i&o);else{if(i>=e)return"Excess padding";if(a<<t-i&o)return"Non-zero padding"}return c}function Qs(s){return Mt(s,8,5,!0)}function bs(s){const e=Mt(s,5,8,!1);if(Array.isArray(e))return e}function vs(s){const e=Mt(s,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function ke(s){let e;s==="bech32"?e=1:e=734539939;function t(o,c,u){if(u=u||90,o.length+7+c.length>u)throw new TypeError("Exceeds length limit");o=o.toLowerCase();let A=ue(o);if(typeof A=="string")throw new Error(A);let d=o+"1";for(let g=0;g<c.length;++g){const I=c[g];if(I>>5)throw new Error("Non 5-bit word");A=at(A)^I,d+=Et.charAt(I)}for(let g=0;g<6;++g)A=at(A);A^=e;for(let g=0;g<6;++g){const I=A>>(5-g)*5&31;d+=Et.charAt(I)}return d}function r(o,c){if(c=c||90,o.length<8)return o+" too short";if(o.length>c)return"Exceeds length limit";const u=o.toLowerCase(),A=o.toUpperCase();if(o!==u&&o!==A)return"Mixed-case string "+o;o=u;const d=o.lastIndexOf("1");if(d===-1)return"No separator character for "+o;if(d===0)return"Missing prefix for "+o;const g=o.slice(0,d),I=o.slice(d+1);if(I.length<6)return"Data too short";let y=ue(g);if(typeof y=="string")return y;const S=[];for(let O=0;O<I.length;++O){const R=I.charAt(O),p=De[R];if(p===void 0)return"Unknown character "+R;y=at(y)^p,!(O+6>=I.length)&&S.push(p)}return y!==e?"Invalid checksum for "+o:{prefix:g,words:S}}function a(o,c){const u=r(o,c);if(typeof u=="object")return u}function i(o,c){const u=r(o,c);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:a,decode:i,encode:t,toWords:Qs,fromWordsUnsafe:bs,fromWords:vs}}it.bech32=ke("bech32");it.bech32m=ke("bech32m");var Ds=Wt&&Wt.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Be,"__esModule",{value:!0});const ks=Ds(Ss),It=it,Ut="asset";let Us=class _t{constructor(e){this.hashBuf=e}static fromHash(e){return new _t(e)}static fromParts(e,t){const r=(0,ks.default)(20).update(new Uint8Array([...e,...t])).digest("binary");return _t.fromHash(r)}static fromBech32(e){const{prefix:t,words:r}=It.bech32.decode(e);if(t!==Ut)throw new Error("Invalid asset fingerprint");const a=Buffer.from(It.bech32.fromWords(r));return _t.fromHash(a)}fingerprint(){const e=It.bech32.toWords(this.hashBuf);return It.bech32.encode(Ut,e)}hash(){return Buffer.from(this.hashBuf).toString("hex")}prefix(){return Ut}checksum(){return this.fingerprint().slice(-6)}};var Ks=Be.default=Us;const Ns=Ks,Ps=(s,e)=>{const t=Fs(s),r=t.derive(kt+1852).derive(kt+1815).derive(kt+e),a=r.derive(0).derive(0).to_raw_key(),i=r.derive(2).derive(0).to_raw_key();return r.free(),t.free(),{paymentKey:a,stakeKey:i}},st=s=>n.Address.from_bytes(m(s)),Fs=s=>n.Bip32PrivateKey.from_bytes(m(s)),Ts=s=>n.DataHash.from_bytes(m(s)),F=s=>n.Ed25519KeyHash.from_bytes(m(s)),Ms=s=>n.Ed25519Signature.from_bytes(m(s)),Qt=s=>n.NativeScript.from_bytes(m(s)),Hs=s=>n.PublicKey.from_bytes(m(s)),Ue=s=>n.PlutusData.from_bytes(m(s)),ot=(s,e)=>n.PlutusScript.from_bytes_with_version(m(s),wt[e]),Os=s=>n.ScriptRef.from_bytes(m(s)),Vs=s=>n.ScriptHash.from_bytes(m(s)),L=s=>n.Transaction.from_bytes(m(s)),Ke=s=>n.TransactionHash.from_bytes(m(s)),Ae=s=>n.TransactionUnspentOutput.from_bytes(m(s)),Ys=s=>n.TransactionWitnessSet.from_bytes(m(s)),Ls=s=>n.Value.from_bytes(m(s)),M=s=>n.Address.from_bech32(s),Ht=s=>n.BaseAddress.from_address(M(s)),Ne=s=>n.EnterpriseAddress.from_address(M(s)),Pe=s=>n.RewardAddress.from_address(M(s)),v=s=>Buffer.from(s).toString("hex"),m=s=>s.length%2===0&&/^[0-9A-F]*$/i.test(s)?Buffer.from(s,"hex"):Buffer.from(s,"utf-8"),bt=s=>{const e=t=>{const r=new Array;for(let a=0;a<t.len();a+=1)r.push(bt(t.get(a)));return r};switch(s.kind()){case n.NativeScriptKind.ScriptAll:{const t=s.as_script_all();return{type:"all",scripts:e(t.native_scripts())}}case n.NativeScriptKind.ScriptAny:{const t=s.as_script_any();return{type:"any",scripts:e(t.native_scripts())}}case n.NativeScriptKind.ScriptNOfK:{const t=s.as_script_n_of_k();return{type:"atLeast",required:t.n(),scripts:e(t.native_scripts())}}case n.NativeScriptKind.TimelockStart:return{type:"after",slot:s.as_timelock_start().slot_bignum().to_str()};case n.NativeScriptKind.TimelockExpiry:return{type:"before",slot:s.as_timelock_expiry().slot_bignum().to_str()};case n.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=n.NativeScripts.new();return t.forEach(a=>{r.add(vt(a))}),r};switch(s.type){case"all":return n.NativeScript.new_script_all(n.ScriptAll.new(e(s.scripts)));case"any":return n.NativeScript.new_script_any(n.ScriptAny.new(e(s.scripts)));case"atLeast":return n.NativeScript.new_script_n_of_k(n.ScriptNOfK.new(s.required,e(s.scripts)));case"after":return n.NativeScript.new_timelock_start(n.TimelockStart.new_timelockstart(n.BigNum.from_str(s.slot)));case"before":return n.NativeScript.new_timelock_expiry(n.TimelockExpiry.new_timelockexpiry(n.BigNum.from_str(s.slot)));case"sig":return n.NativeScript.new_script_pubkey(n.ScriptPubkey.new(F(s.keyHash)))}},yt=s=>{var r,a,i;const e=o=>{const c=[];for(let u=0;u<o.len();u+=1)c.push(yt(o.get(u)));return c},t=o=>{const c=new Map;for(let u=0;u<o.len();u+=1){const A=o.keys().get(u),d=o.get(A)??n.PlutusData.from_hex(Q("NO_ITEM_FOUND_INSIDE_GOLD_ROOM"));c.set(yt(A),yt(d))}return c};switch(s.kind()){case n.PlutusDataKind.Bytes:return v(s.as_bytes()??new Uint8Array);case n.PlutusDataKind.Integer:return parseInt(((r=s.as_integer())==null?void 0:r.to_str())??"0",10);case n.PlutusDataKind.List:return e(s.as_list()??n.PlutusList.new());case n.PlutusDataKind.Map:return t(s.as_map()??n.PlutusMap.new());case n.PlutusDataKind.ConstrPlutusData:return{alternative:parseInt(((a=s.as_constr_plutus_data())==null?void 0:a.alternative().to_str())??"0",10),fields:e(((i=s.as_constr_plutus_data())==null?void 0:i.data())??n.PlutusList.new())};default:throw new Error(`PlutusData Kind: ${s.kind()}, is not supported`)}},Z=s=>{const e=t=>{const r=n.PlutusList.new();return t.forEach(a=>{r.add(Z(a))}),r};switch(typeof s){case"string":return n.PlutusData.new_bytes(m(s));case"number":return n.PlutusData.new_integer(n.BigInt.from_str(s.toString()));case"object":if(s instanceof Array){const t=e(s);return n.PlutusData.new_list(t)}else if(s instanceof Map){const t=n.PlutusMap.new();return s.forEach((r,a)=>{t.insert(Z(a),Z(r))}),n.PlutusData.new_map(t)}else return n.PlutusData.new_constr_plutus_data(n.ConstrPlutusData.new(n.BigNum.from_str(s.alternative.toString()),e(s.fields)))}},qs=s=>{const e=n.Relays.new();throw s.relays.forEach(t=>{e.add(Gs(t))}),new Error("toPoolParams not implemented.")},Fe=s=>{const e=t=>Je[t];return n.Redeemer.new(e(s.tag),n.BigNum.from_str(s.index.toString()),Z(s.data),n.ExUnits.new(n.BigNum.from_str(s.budget.mem.toString()),n.BigNum.from_str(s.budget.steps.toString())))},Gs=s=>{switch(s.type){case"SingleHostAddr":{const e=s.IPV4?n.Ipv4.new(new Uint8Array(s.IPV4.split(".").map(r=>parseInt(r)))):void 0,t=s.IPV6?n.Ipv6.new(m(s.IPV6.replaceAll(":",""))):void 0;return n.Relay.new_single_host_addr(n.SingleHostAddr.new(s.port,e,t))}case"SingleHostName":return n.Relay.new_single_host_name(n.SingleHostName.new(s.port,n.DNSRecordAorAAAA.new(s.domainName)));case"MultiHostName":return n.Relay.new_multi_host_name(n.MultiHostName.new(n.DNSRecordSRV.new(s.domainName)))}},Te=s=>{if(s.is_plutus_script()){const t=s.plutus_script();return{code:t.to_hex(),version:Object.keys(wt).find(r=>wt[r].to_hex()===t.language_version().to_hex())}}const e=s.native_script();return bt(e)},dt=s=>{if("code"in s){const e=ot(s.code,s.version);return n.ScriptRef.new_plutus_script(e)}return n.ScriptRef.new_native_script(vt(s))},xt=s=>{var a,i,o;const e=s.output().has_data_hash()?(a=s.output().data_hash())==null?void 0:a.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()?(o=s.output().script_ref())==null?void 0:o.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:Me(s.output().amount()),dataHash:e,plutusData:t,scriptRef:r}}},P=s=>{const e=n.TransactionInput.new(Ke(s.input.txHash),s.input.outputIndex),t=n.TransactionOutput.new(M(s.output.address),Ct(s.output.amount));return s.output.dataHash!==void 0&&t.set_data_hash(Ts(s.output.dataHash)),s.output.plutusData!==void 0&&t.set_plutus_data(Ue(s.output.plutusData)),s.output.scriptRef!==void 0&&t.set_script_ref(Os(s.output.scriptRef)),n.TransactionUnspentOutput.new(e,t)},ge=s=>{const e=s.split(".")[1]??"0",t=`${parseInt(e,10)}`,r="1"+"0".repeat(e.length);return n.UnitInterval.new(n.BigNum.from_str(t),n.BigNum.from_str(r))},Q=s=>s.length%2===0&&/^[0-9A-F]*$/i.test(s)?s:v(Buffer.from(s,"utf-8")),Ot=s=>Buffer.from(s,"hex").toString("utf-8"),Me=s=>{const e=[{unit:"lovelace",quantity:s.coin().to_str()}],t=s.multiasset();if(t!==void 0){const r=t.keys();for(let a=0;a<r.len();a+=1){const i=r.get(a),o=t.get(i);if(o!==void 0){const c=o.keys();for(let u=0;u<c.len();u+=1){const A=c.get(u),d=o.get(A)??n.BigNum.from_str("0"),g=i.to_hex()+v(A.name());e.push({unit:g,quantity:d.to_str()})}}}}return e},Ct=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,T)))),r=n.MultiAsset.new();t.forEach(i=>{const o=n.Assets.new();s.filter(c=>c.unit.slice(0,T)===i).forEach(c=>{o.insert(n.AssetName.new(m(c.unit.slice(T))),n.BigNum.from_str(c.quantity))}),r.insert(Vs(i),o)});const a=n.Value.new(n.BigNum.from_str(e?e.quantity:"0"));return(s.length>1||!e)&&a.set_multiasset(r),a},de=(s,e,t)=>n.BaseAddress.new(s,n.StakeCredential.from_keyhash(e),n.StakeCredential.from_keyhash(t)),He=(s,e="")=>n.Bip32PrivateKey.from_bip39_entropy(m(s),m(Q(e))),le=s=>n.DataCost.new_coins_per_byte(n.BigNum.from_str(s)),Rs=s=>{if(typeof s!="object"||!("input"in s))return n.DatumSource.new(Z(s));const e=P(s);if(e.output().has_plutus_data())return n.DatumSource.new_ref_input(e.input());throw new Error(`No inline datum found in UTxO: ${e.input().transaction_id().to_hex()}`)},he=(s,e)=>n.EnterpriseAddress.new(s,n.StakeCredential.from_keyhash(e)),Ie=(s,e)=>{if(typeof s=="string")return n.MintWitness.new_native_script(Qt(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 n.MintWitness.new_plutus_script(Oe(s),Fe({tag:"MINT",index:0,budget:_e,data:{alternative:0,fields:[]},...e}))},Nt=(s,e)=>n.RewardAddress.new(s,n.StakeCredential.from_keyhash(e)),Oe=s=>{if("code"in s)return n.PlutusScriptSource.new(ot(s.code,s.version));const e=P(s);if(e.output().has_script_ref()){const t=e.output().script_ref();if(t.is_plutus_script()){const r=Te(t),a=ot(r.code,r.version).hash();return n.PlutusScriptSource.new_ref_input_with_lang_ver(a,e.input(),wt[r.version])}}throw new Error(`No plutus script reference found in UTxO: ${e.input().transaction_id().to_hex()}`)},mt=s=>{const e=n.ScriptPubkey.new(s);return n.NativeScript.new_script_pubkey(e)},$s=(s=q)=>{const e=n.TransactionBuilderConfigBuilder.new().coins_per_utxo_byte(n.BigNum.from_str(s.coinsPerUTxOSize)).ex_unit_prices(n.ExUnitPrices.new(ge(s.priceMem.toString()),ge(s.priceStep.toString()))).fee_algo(n.LinearFee.new(n.BigNum.from_str(s.minFeeA.toString()),n.BigNum.from_str(s.minFeeB.toString()))).key_deposit(n.BigNum.from_str(s.keyDeposit)).max_tx_size(s.maxTxSize).max_value_size(parseInt(s.maxValSize,10)).pool_deposit(n.BigNum.from_str(s.poolDeposit)).build();return n.TransactionBuilder.new(e)},me=s=>{const e=n.TxInputsBuilder.new();return s.map(t=>t instanceof n.TransactionUnspentOutput?t:P(t)).forEach(t=>{e.add_input(t.output().address(),t.input(),t.output().amount())}),e},pt=s=>{if(typeof s=="string")return n.TransactionOutputBuilder.new().with_address(M(s));let e=n.TransactionOutputBuilder.new().with_address(M(s.address));if(s.datum){const{value:t,inline:r}=s.datum,a=Z(t);e=e.with_data_hash(n.hash_plutus_data(a)),r&&(e=e.with_plutus_data(a))}if(s.script){const t=dt(s.script);e=e.with_script_ref(t)}return e},tt=s=>{const e=s.slice(0,T),t=s.includes(".")?Q(s.split(".")[1]):s.slice(T);return{policyId:e,assetName:t}},l=s=>J.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),zs=s=>{const e=Z(s);return n.hash_plutus_data(e).to_hex()},Ws=(s,e=Date.now())=>{if(Bt[s]){const[t,r,a,i]=Bt[s];return parseInt(n.BigNum.from_str(e.toString()).div_floor(n.BigNum.from_str("1000")).checked_sub(n.BigNum.from_str(a)).div_floor(n.BigNum.from_str(i)).checked_add(n.BigNum.from_str(t)).to_str(),10)}throw new Error(`Couldn't resolve EpochNo for network: ${s}`)},Ve=(s,e)=>Ns.fromParts(m(s),m(e)).fingerprint(),Js=(s,e)=>je[s][e],js=s=>vt(s).hash().to_hex(),X=s=>{var e,t;try{const r=[(e=Ht(s))==null?void 0:e.payment_cred().to_keyhash(),(t=Ne(s))==null?void 0:t.payment_cred().to_keyhash()].find(a=>a!==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=ot(s.code,s.version);return n.EnterpriseAddress.new(e,n.StakeCredential.from_scripthash(t.hash())).to_address().to_bech32()},Zs=s=>{try{const e=Ne(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}.`)}},tr=s=>n.Ed25519KeyHash.from_hex(s).to_bech32("pool1"),er=s=>{const e=Kt.mnemonicToEntropy(s.join(" ")),t=He(e),r=t.to_bech32();return t.free(),r},sr=s=>dt(s).to_hex(),rr=(s,e=Date.now())=>{if(Bt[s]){const[t,r,a]=Bt[s];return n.BigNum.from_str(e.toString()).div_floor(n.BigNum.from_str("1000")).checked_sub(n.BigNum.from_str(a)).checked_add(n.BigNum.from_str(r)).to_str()}throw new Error(`Couldn't resolve SlotNo for network: ${s}`)},Dt=s=>{try{const e=M(s),t=Ht(s),r=t==null?void 0:t.stake_cred().to_keyhash();if(r!==void 0)return Nt(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}.`)}},rt=s=>{var e,t;try{const r=[(e=Ht(s))==null?void 0:e.stake_cred().to_keyhash(),(t=Pe(s))==null?void 0:t.payment_cred().to_keyhash()].find(a=>a!==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}.`)}},Vt=(s,e=q.minFeeA,t=q.minFeeB)=>(BigInt(e)*BigInt(s)+BigInt(t)).toString(),Ye=s=>{const e=L(s).body();return n.hash_transaction(e).to_hex()},ar=(s="",e=32)=>{if(e<=0||e>2048)throw new Error("Length must be bewteen 1 and 2048");const r=fe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")(e);return Q(`${s}${r}`)},Le=(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 a=n.Vkeywitnesses.new();return r.forEach(i=>{a.add(n.Vkeywitness.from_hex(i))}),a}return e},nr=s=>yt(Ue(s)),ir=s=>L(s).to_js_value();class or{_axiosInstance;constructor(...e){if(typeof e[0]=="string"&&e[0].startsWith("http"))this._axiosInstance=J.create({baseURL:e[0]});else{const t=e[0],r=t.slice(0,7);this._axiosInstance=J.create({baseURL:`https://cardano-${r}.blockfrost.io/api/v${e[1]??0}`,headers:{project_id:t}})}}async fetchAccountInfo(e){const t=e.startsWith("addr")?Dt(e):e;try{const{data:r,status:a}=await this._axiosInstance.get(`accounts/${t}`);if(a===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 l(r)}catch(r){throw l(r)}}async fetchAddressUTxOs(e,t){const r=t!==void 0?`/${t}`:"",a=`addresses/${e}/utxos`+r,i=async(u=1,A=[])=>{const{data:d,status:g}=await this._axiosInstance.get(`${a}?page=${u}`);if(g===200)return d.length>0?i(u+1,[...A,...await Promise.all(d.map(c))]):A;throw l(d)},o=async u=>{if(u){const{data:A,status:d}=await this._axiosInstance.get(`scripts/${u}`);if(d===200){const g=A.type.startsWith("plutus")?{code:await this.fetchPlutusScriptCBOR(u),version:A.type.replace("plutus","")}:await this.fetchNativeScriptJSON(u);return dt(g).to_hex()}throw l(A)}},c=async u=>({input:{outputIndex:u.output_index,txHash:u.tx_hash},output:{address:e,amount:u.amount,dataHash:u.data_hash??void 0,plutusData:u.inline_datum??void 0,scriptRef:await o(u.reference_script_hash)}});try{return await i()}catch{return[]}}async fetchAssetAddresses(e){const t=async(r=1,a=[])=>{const{policyId:i,assetName:o}=tt(e),{data:c,status:u}=await this._axiosInstance.get(`assets/${i}${o}/addresses?page=${r}`);if(u===200)return c.length>0?t(r+1,[...a,...c]):a;throw l(c)};try{return await t()}catch{return[]}}async fetchAssetMetadata(e){try{const{policyId:t,assetName:r}=tt(e),{data:a,status:i}=await this._axiosInstance.get(`assets/${t}${r}`);if(i===200)return{...a.onchain_metadata};throw l(a)}catch(t){throw l(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 l(t)}catch(t){throw l(t)}}async fetchCollectionAssets(e,t=1){try{const{data:r,status:a}=await this._axiosInstance.get(`assets/policy/${e}?page=${t}`);if(a===200)return{assets:r.map(i=>({unit:i.asset,quantity:i.quantity})),next:r.length===100?t+1:null};throw l(r)}catch{return{assets:[],next:null}}}async fetchHandleAddress(e){try{const t=Q(e.replace("$","")),{data:r,status:a}=await this._axiosInstance.get(`assets/${Pt[1]}${t}/addresses`);if(a===200)return r[0].address;throw l(r)}catch(t){throw l(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 l(t)}catch(t){throw l(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 l(t)}catch(t){throw l(t)}}onTxConfirmed(e,t,r=100){let a=0;const i=setInterval(()=>{a>=r&&clearInterval(i),this.fetchTxInfo(e).then(o=>{this.fetchBlockInfo(o.block).then(c=>{(c==null?void 0:c.confirmations)>0&&(clearInterval(i),t())}).catch(()=>{a+=1})}).catch(()=>{a+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/cbor"},{data:r,status:a}=await this._axiosInstance.post("tx/submit",m(e),{headers:t});if(a===200)return r;throw l(r)}catch(t){throw l(t)}}async fetchPlutusScriptCBOR(e){const{data:t,status:r}=await this._axiosInstance.get(`scripts/${e}/cbor`);if(r===200)return t.cbor;throw l(t)}async fetchNativeScriptJSON(e){const{data:t,status:r}=await this._axiosInstance.get(`scripts/${e}/json`);if(r===200)return t.json;throw l(t)}}class cr{_axiosInstance;constructor(e,t,r){const a=r.host??"ipfs.infura.io",i=r.port??5001,o=r.version??0;this._axiosInstance=J.create({baseURL:`https://${a}:${i}/api/v${o}`,auth:{username:e,password:t}})}async uploadContent(e,t=!1){try{const r={"Content-Type":"multipart/form-data"},{data:a,status:i}=await this._axiosInstance.post(`add?recursive=${t}`,e,{headers:r});if(i===200)return a;throw l(a)}catch(r){throw l(r)}}}class ur{_axiosInstance;constructor(...e){typeof e[0]=="string"&&e[0].startsWith("http")?this._axiosInstance=J.create({baseURL:e[0]}):this._axiosInstance=J.create({baseURL:`https://${e[0]}.koios.rest/api/v${e[1]??0}`})}async fetchAccountInfo(e){try{const t=e.startsWith("addr")?Dt(e):e,{data:r,status:a}=await this._axiosInstance.post("account_info",{_stake_addresses:[t]});if(a===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 l(r)}catch(t){throw l(t)}}async fetchAddressUTxOs(e,t){const r=a=>{if(a){const i=a.type.startsWith("plutus")?{code:a.bytes,version:a.type.replace("plutus","")}:bt(Qt(a.bytes));return dt(i).to_hex()}};try{const{data:a,status:i}=await this._axiosInstance.post("address_info",{_addresses:[e]});if(i===200){const o=a.flatMap(c=>c.utxo_set).map(c=>{var u;return{input:{outputIndex:c.tx_index,txHash:c.tx_hash},output:{address:e,amount:[{unit:"lovelace",quantity:c.value},...c.asset_list.map(A=>({unit:`${A.policy_id}${A.asset_name}`,quantity:`${A.quantity}`}))],dataHash:c.datum_hash??void 0,plutusData:((u=c.inline_datum)==null?void 0:u.bytes)??void 0,scriptRef:r(c.reference_script)}}});return t!==void 0?o.filter(c=>c.output.amount.find(u=>u.unit===t)!==void 0):o}throw l(a)}catch{return[]}}async fetchAssetAddresses(e){try{const{policyId:t,assetName:r}=tt(e),{data:a,status:i}=await this._axiosInstance.get(`asset_address_list?_asset_policy=${t}&_asset_name=${r}`);if(i===200)return a.map(o=>({address:o.payment_address,quantity:o.quantity}));throw l(a)}catch(t){throw l(t)}}async fetchAssetMetadata(e){try{const{policyId:t,assetName:r}=tt(e),{data:a,status:i}=await this._axiosInstance.get(`asset_info?_asset_policy=${t}&_asset_name=${r}`);if(i===200)return{...a[0].minting_tx_metadata[721][t][Ot(r)]};throw l(a)}catch(t){throw l(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 l(t)}catch(t){throw l(t)}}async fetchCollectionAssets(e,t=0){try{const{data:r,status:a}=await this._axiosInstance.get(`asset_policy_info?_asset_policy=${e}&limit=100&offset=${t}`);if(a===200)return{assets:r.map(i=>({unit:`${e}${i.asset_name}`,quantity:i.total_supply})),next:r.length===100?t+100:null};throw l(r)}catch(r){throw l(r)}}async fetchHandleAddress(e){try{const t=Q(e.replace("$","")),{data:r,status:a}=await this._axiosInstance.get(`asset_address_list?_asset_policy=${Pt[1]}&_asset_name=${t}`);if(a===200)return r[0].payment_address;throw l(r)}catch(t){throw l(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 l(t)}catch(t){throw l(t)}}async fetchTxInfo(e){var t,r;try{const{data:a,status:i}=await this._axiosInstance.post("tx_info",{_tx_hashes:[e]});if(i===200)return{block:a[0].block_hash,deposit:a[0].deposit,fees:a[0].fee,hash:a[0].tx_hash,index:a[0].tx_block_index,invalidAfter:((t=a[0].invalid_after)==null?void 0:t.toString())??"",invalidBefore:((r=a[0].invalid_before)==null?void 0:r.toString())??"",slot:a[0].absolute_slot.toString(),size:a[0].tx_size};throw l(a)}catch(a){throw l(a)}}onTxConfirmed(e,t,r=100){let a=0;const i=setInterval(()=>{a>=r&&clearInterval(i),this.fetchTxInfo(e).then(o=>{this.fetchBlockInfo(o.block).then(c=>{(c==null?void 0:c.confirmations)>0&&(clearInterval(i),t())}).catch(()=>{a+=1})}).catch(()=>{a+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/cbor"},{data:r,status:a}=await this._axiosInstance.post("submittx",m(e),{headers:t});if(a===202)return r;throw l(r)}catch(t){throw l(t)}}}class Ar{_baseUrl;constructor(...e){this._baseUrl=pe(e[0])?Xe[e[0]]:e[0]}async evaluateTx(e){const t=await this.open();return this.send(t,"EvaluateTx",{evaluate:e}),new Promise((r,a)=>{t.addEventListener("message",i=>{try{const{result:o}=JSON.parse(i.data);o.EvaluationResult?r(Object.keys(o.EvaluationResult).map(c=>({index:parseInt(c.split(":")[1],10),tag:c.split(":")[0].toUpperCase(),budget:{mem:o.EvaluationResult[c].memory,steps:o.EvaluationResult[c].steps}}))):a(o.EvaluationFailure),t.close()}catch(o){a(o)}},{once:!0})})}async onNextTx(e){const t=await this.open();return this.send(t,"AwaitAcquire",{}),t.addEventListener("message",r=>{const{result:a}=JSON.parse(r.data);if(a===null)return this.send(t,"AwaitAcquire",{});a.AwaitAcquired===void 0&&e(a),this.send(t,"NextTx",{})}),()=>t.close()}async submitTx(e){const t=await this.open();return this.send(t,"SubmitTx",{submit:e}),new Promise((r,a)=>{t.addEventListener("message",i=>{try{const{result:o}=JSON.parse(i.data);o.SubmitSuccess?r(o.SubmitSuccess.txId):a(o.SubmitFail),t.close()}catch(o){a(o)}},{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 gr{_axiosInstance;constructor(e,t,r,a=1){this._axiosInstance=J.create({baseURL:`https://cardano-${e}.tangocrypto.com/${t}/v${a}`,headers:{"x-api-key":r}})}async evaluateTx(e){try{const{data:t,status:r}=await this._axiosInstance.post("transactions/evaluate",{tx:e,utxos:[]});if(r===200)return t.redeemers.map(a=>({index:a.index,tag:a.purpose.toUpperCase(),budget:{mem:a.unit_mem,steps:a.unit_steps}}));throw l(t)}catch(t){throw l(t)}}async fetchAccountInfo(e){try{const t=e.startsWith("addr")?Dt(e):e,{data:r,status:a}=await this._axiosInstance.get(`wallets/${t}`);if(a===200)return{poolId:r.pool_id,active:r.active,balance:r.controlled_total_stake,rewards:r.rewards_sum,withdrawals:r.withdrawals_sum};throw l(r)}catch(t){throw l(t)}}async fetchAddressUTxOs(e,t){const r=t!==void 0?`/assets/${t}`:"",a=`addresses/${e}${r}/utxos?size=50`,i=async(A="",d=[])=>{var y;const{data:g,status:I}=await this._axiosInstance.get(`${a}&cursor=${A}`);if(I===200)return g.cursor!==null&&((y=g.cursor)==null?void 0:y.length)>0?i(g.cursor,[...d,...g.data.map(u)]):g.data.map(u);throw l(g)},o=(A,d)=>{const g=[{unit:"lovelace",quantity:A.toString()}];return d.forEach(I=>{const y=Q(I.asset_name);g.push({unit:`${I.policy_id}${y}`,quantity:I.quantity.toString()})}),g},c=A=>{if(A){const d=A.type.startsWith("plutus")?{code:A.code,version:A.type.replace("plutus","")}:bt(Qt(A.json));return dt(d).to_hex()}},u=A=>{var d;return{input:{outputIndex:A.index,txHash:A.hash},output:{address:e,amount:o(A.value,A.assets),dataHash:void 0,plutusData:((d=A.inline_datum)==null?void 0:d.value_raw)??void 0,scriptRef:c(A.reference_script)}}};try{return await i()}catch{return[]}}async fetchAssetAddresses(e){const t=a=>({address:a.address,quantity:a.quantity.toString()}),r=async(a="",i=[])=>{var d;const{policyId:o,assetName:c}=tt(e),{data:u,status:A}=await this._axiosInstance.get(`assets/${o}${c}/addresses?size=100&cursor=${a}`);if(A===200)return u.cursor!==null&&((d=u.cursor)==null?void 0:d.length)>0?r(u.cursor,[...i,...u.data.map(t)]):u.data.map(t);throw l(u)};try{return await r()}catch{return[]}}async fetchAssetMetadata(e){var t;try{const{policyId:r,assetName:a}=tt(e),{data:i,status:o}=await this._axiosInstance.get(`assets/${r}${a}`);if(o===200)return{...(t=i.metadata.find(c=>c.label===721))==null?void 0:t.json[r][Ot(a)]};throw l(i)}catch(r){throw l(r)}}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_no,epochSlot:t.epoch_slot_no.toString(),fees:t.fees.toString(),hash:t.hash,nextBlock:t.next_block.toString()??"",operationalCertificate:t.op_cert,output:t.out_sum.toString()??"0",previousBlock:t.previous_block.toString(),size:t.size,slot:t.slot_no.toString(),slotLeader:t.slot_leader??"",time:Date.parse(t.time),txCount:t.tx_count,VRFKey:t.vrf_key};throw l(t)}catch(t){throw l(t)}}async fetchCollectionAssets(e,t=""){try{const{data:r,status:a}=await this._axiosInstance.get(`policies/${e}/assets?size=100&cursor=${t}`);if(a===200)return{assets:r.data.map(i=>({unit:`${i.policy_id}${i.asset_name}`,quantity:i.quantity})),next:r.cursor};throw l(r)}catch{return{assets:[],next:null}}}async fetchHandleAddress(e){try{const t=Q(e.replace("$","")),{data:r,status:a}=await this._axiosInstance.get(`assets/${Pt[1]}${t}/addresses`);if(a===200)return r.data[0].address;throw l(r)}catch(t){throw l(t)}}async fetchProtocolParameters(e){try{const{data:t,status:r}=await this._axiosInstance.get(`epochs/${e}/parameters`);if(r===200)return{coinsPerUTxOSize:t.coins_per_utxo_size.toString(),collateralPercent:t.collateral_percent,decentralisation:t.decentralisation,epoch:t.epoch_no,keyDeposit:t.key_deposit.toString(),maxBlockExMem:t.max_block_ex_mem.toString(),maxBlockExSteps:t.max_block_ex_steps.toString(),maxBlockHeaderSize:t.max_block_header_size,maxBlockSize:t.max_block_size,maxCollateralInputs:t.max_collateral_inputs,maxTxExMem:t.max_tx_ex_mem.toString(),maxTxExSteps:t.max_tx_ex_steps.toString(),maxTxSize:t.max_tx_size,maxValSize:t.max_val_size.toString(),minFeeA:t.min_fee_a,minFeeB:t.min_fee_b,minPoolCost:t.min_pool_cost.toString(),poolDeposit:t.pool_deposit.toString(),priceMem:t.price_mem,priceStep:t.price_step};throw l(t)}catch(t){throw l(t)}}async fetchTxInfo(e){try{const{data:t,status:r}=await this._axiosInstance.get(`transactions/${e}`);if(r===200)return{block:t.block.hash,deposit:t.deposit,fees:t.fee,hash:t.hash,index:t.block_index,invalidAfter:t.invalid_hereafter??"",invalidBefore:t.invalid_before??"",slot:t.block.slot_no.toString(),size:t.size};throw l(t)}catch(t){throw l(t)}}onTxConfirmed(e,t,r=100){let a=0;const i=setInterval(()=>{a>=r&&clearInterval(i),this.fetchTxInfo(e).then(o=>{this.fetchBlockInfo(o.block).then(c=>{(c==null?void 0:c.confirmations)>0&&(clearInterval(i),t())}).catch(()=>{a+=1})}).catch(()=>{a+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/json"},{data:r,status:a}=await this._axiosInstance.post("transactions/submit",{tx:e},{headers:t});if(a===200)return r.tx_id;throw l(r)}catch(t){throw l(t)}}}class dr{static withOneSignature(e){const t=F(X(e));return mt(t).to_hex()}static withAtLeastNSignatures(e,t){const r=n.NativeScripts.new();e.forEach(i=>{const o=F(X(i));r.add(mt(o))});const a=n.ScriptNOfK.new(t,r);return n.NativeScript.new_script_any(a).to_hex()}static withAnySignature(e){const t=n.NativeScripts.new();e.forEach(a=>{const i=F(X(a));t.add(mt(i))});const r=n.ScriptAny.new(t);return n.NativeScript.new_script_any(r).to_hex()}static withAllSignatures(e){const t=n.NativeScripts.new();e.forEach(a=>{const i=F(X(a));t.add(mt(i))});const r=n.ScriptAll.new(t);return n.NativeScript.new_script_any(r).to_hex()}static fromNativeScript(e){return vt(e).to_hex()}}function j(s,e,t,r){var a=arguments.length,i=a<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,e,t,r);else for(var c=s.length-1;c>=0;c--)(o=s[c])&&(i=(a<3?o(i):a>3?o(e,t,i):o(e,t))||i);return a>3&&i&&Object.defineProperty(e,t,i),i}const lr=s=>class extends s{__visits=[]},et=()=>function(s,e,t){const r=t.value;t.value=function(...a){const i=r.call(this,...a);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=n.MintBuilder.new(),this._protocolParameters=e.parameters??q,this._txBuilder=$s(e.parameters),this._txCertificates=n.Certificates.new(),this._txInputsBuilder=n.TxInputsBuilder.new(),this._txWithdrawals=n.Withdrawals.new()}static maskMetadata(e,t="BABBAGE"){var i;const r=L(e),a=(i=r.auxiliary_data())==null?void 0:i.metadata();if(a!==void 0){const o=n.GeneralTransactionMetadata.new();for(let u=0;u<a.len();u+=1){const A=a.keys().get(u),d=a.get(A);o.insert(A,n.TransactionMetadatum.from_hex("0".repeat(((d==null?void 0:d.to_hex())??"").length)))}const c=r.auxiliary_data();return c!==void 0&&(c.set_metadata(o),c.set_prefer_alonzo_format(t==="ALONZO")),n.Transaction.new(r.body(),r.witness_set(),c).to_hex()}return e}static readMetadata(e){var r,a;return((a=(r=L(e).auxiliary_data())==null?void 0:r.metadata())==null?void 0:a.to_hex())??""}static writeMetadata(e,t,r="BABBAGE"){const a=L(e),i=a.auxiliary_data()??n.AuxiliaryData.new();return i.set_metadata(n.GeneralTransactionMetadata.from_hex(t)),i.set_prefer_alonzo_format(r==="ALONZO"),n.Transaction.new(a.body(),a.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 a=this._totalBurns.has(t.unit)?n.BigNum.from_str(this._totalBurns.get(t.unit)??"0").checked_add(n.BigNum.from_str(t.quantity)).to_str():t.quantity;return this._mintBuilder.add_asset(Ie(e,r),n.AssetName.new(m(t.unit.slice(T))),n.Int.new_negative(n.BigNum.from_str(t.quantity))),this._totalBurns.set(t.unit,a),this}delegateStake(e,t){const r=n.Certificate.new_stake_delegation(n.StakeDelegation.new(n.StakeCredential.from_keyhash(F(rt(e))),n.Ed25519KeyHash.from_bech32(t)));return this._txCertificates.add(r),this}deregisterStake(e){const t=n.Certificate.new_stake_deregistration(n.StakeDeregistration.new(n.StakeCredential.from_keyhash(F(rt(e)))));return this._txCertificates.add(t),this}mintAsset(e,t,r){var A,d;const a=(g,I)=>{const y=typeof g=="string"?Qt(g).hash().to_hex():i(g).hash().to_hex(),S=Q(I.assetName);return{unit:`${y}${S}`,quantity:I.assetQuantity}},i=g=>{if("code"in g)return ot(g.code,g.version);const I=P(g);if(I.output().has_script_ref()){const y=I.output().script_ref();if(y.is_plutus_script()){const S=Te(y);return ot(S.code,S.version)}}throw new Error(`No plutus script reference found in UTxO: ${I.input().transaction_id().to_hex()}`)},o=a(e,t),u=n.BigNum.from_str(((A=this._totalMints.get(o.unit))==null?void 0:A.assetQuantity)??"0").checked_add(n.BigNum.from_str(o.quantity));return this._mintBuilder.add_asset(Ie(e,r),n.AssetName.new(m(Q(t.assetName))),n.Int.new(n.BigNum.from_str(o.quantity))),this._recipients.has(t.recipient)?(d=this._recipients.get(t.recipient))==null||d.push(o):this._recipients.set(t.recipient,[o]),this._totalMints.set(o.unit,{...t,assetQuantity:u.to_str()}),this}redeemValue(e){const t={tag:"SPEND",budget:_e,index:this._txInputsBuilder.inputs().len(),data:{alternative:0,fields:[]},...e.redeemer},r=P(e.value),a=n.PlutusWitness.new_with_ref(Oe(e.script),Rs(e.datum),Fe(t));return this._txInputsBuilder.add_plutus_script_input(a,r.input(),r.output().amount()),this}registerStake(e){const t=n.Certificate.new_stake_registration(n.StakeRegistration.new(n.StakeCredential.from_keyhash(F(rt(e)))));return this._txCertificates.add(t),this}registerPool(e){const t=n.Certificate.new_pool_registration(n.PoolRegistration.new(qs(e)));return this._txCertificates.add(t),this}retirePool(e,t){const r=n.Certificate.new_pool_retirement(n.PoolRetirement.new(n.Ed25519KeyHash.from_bech32(e),t));return this._txCertificates.add(r),this}sendAssets(e,t){const r=Ct(t),a=r.multiasset();if(r.is_zero()||a===void 0)return this;const i=pt(e).next(),o=r.coin().is_zero()?i.with_asset_and_min_required_coin_by_utxo_cost(a,le(this._protocolParameters.coinsPerUTxOSize)).build():i.with_coin_and_asset(r.coin(),a).build();return t.forEach(c=>{this.setTxOutput(c)}),this._txBuilder.add_output(o),this}sendLovelace(e,t){const a=pt(e).next().with_coin(n.BigNum.from_str(t)).build();return this.setTxOutput({unit:"lovelace",quantity:t}),this._txBuilder.add_output(a),this}sendToken(e,t,r){return this.sendAssets(e,[{quantity:r,unit:Ze[t]}]),this}sendValue(e,t){const r=Ct(t.output.amount),i=pt(e).next().with_value(r).build();return t.output.amount.forEach(o=>{this.setTxOutput(o)}),this._txBuilder.add_output(i),this}setChangeAddress(e){return this._changeAddress=M(e),this}setCollateral(e){const t=me(e);return this._txBuilder.set_collateral(t),this}setMetadata(e,t){return this._txBuilder.add_json_metadatum_with_schema(n.BigNum.from_str(e.toString()),JSON.stringify(t),n.MetadataJsonSchema.NoConversions),this}setRequiredSigners(e){return Array.from(new Set(e.map(r=>r.startsWith("addr")?X(r):rt(r)).map(r=>F(r)))).forEach(r=>{this._txBuilder.add_required_signer(r)}),this}setTimeToStart(e){return this._txBuilder.set_validity_start_interval_bignum(n.BigNum.from_str(e)),this}setTimeToExpire(e){return this._txBuilder.set_ttl_bignum(n.BigNum.from_str(e)),this}setTxInputs(e){return e.map(t=>P(t)).forEach(t=>{this._txInputsBuilder.add_input(t.output().address(),t.input(),t.output().amount())}),this}setTxRefInputs(e){return e.map(t=>P(t)).forEach(t=>{this._txBuilder.add_reference_input(t.input())}),this}withdrawRewards(e,t){const r=Pe(e);return r!==void 0&&this._txWithdrawals.insert(r,n.BigNum.from_str(t)),this}async addBurnInputsIfNeeded(){if(this._initiator&&this._totalBurns.size>0&&this.notVisited("setTxInputs")){const e=await this._initiator.getUsedUTxOs();Ce(this._totalBurns,e.map(r=>xt(r))).map(r=>P(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(me(e))}}async addRequiredSignersIfNeeded(){if(this._initiator&&this.notVisited("setRequiredSigners")){const e=await this._initiator.getUsedAddress(),t=X(e.to_bech32());this._txBuilder.add_required_signer(F(t))}}async addTxInputsAsNeeded(){if(this.notVisited("setTxInputs")){const e=await this.filterAvailableUTxOs();ye(this._txOutputs,e.map(r=>xt(r))).map(r=>P(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?$t[this._era]:$t.BABBAGE;this._txBuilder.calc_script_data_hash(e)}}async forgeAssetsIfNeeded(){const e=(t,r)=>{const a=t.data.assetName,i=t.data.metadata,o=t.unit.slice(0,T);if(r&&r[o]){const{[o]:c,...u}=r,A={[a]:i,...c};return{[o]:{...A},...u}}return r!==void 0?{[o]:{[a]:i},...r}:{[o]:{[a]: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(n.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(a=>a.input.txHash===r.input().transaction_id().to_hex())===void 0)}addMintOutputs(){this._recipients.forEach((e,t)=>{const a=Ct(e).multiasset();if(a!==void 0){const o=pt(t).next().with_asset_and_min_required_coin_by_utxo_cost(a,le(this._protocolParameters.coinsPerUTxOSize)).build();this._txBuilder.add_output(o)}})}notVisited(e){return this.__visits.includes(e)===!1}setTxOutput(e){const r=n.BigNum.from_str(this._txOutputs.get(e.unit)??"0").checked_add(n.BigNum.from_str(e.quantity)).to_str();this._txOutputs.set(e.unit,r)}};j([et()],exports.Transaction.prototype,"mintAsset",null);j([et()],exports.Transaction.prototype,"redeemValue",null);j([et()],exports.Transaction.prototype,"sendAssets",null);j([et()],exports.Transaction.prototype,"sendValue",null);j([et()],exports.Transaction.prototype,"setCollateral",null);j([et()],exports.Transaction.prototype,"setRequiredSigners",null);j([et()],exports.Transaction.prototype,"setTxInputs",null);exports.Transaction=j([lr],exports.Transaction);class C{_networkId;_encryptedSecret;constructor(e,t){this._networkId=e,this._encryptedSecret=t}getAccount(e,t){return this.accountContext(e,t,(r,a)=>{const i=de(this._networkId,r.to_public().hash(),a.to_public().hash()).to_address().to_bech32(),o=he(this._networkId,r.to_public().hash()).to_address().to_bech32(),c=Nt(this._networkId,a.to_public().hash()).to_address().to_bech32();return{baseAddress:i,enterpriseAddress:o,rewardAddress:c}})}signData(e,t,r,a){try{return this.accountContext(e,t,(i,o)=>{const c={payload:a},u={address:C.resolveAddress(this._networkId,r,i,o),key:r.startsWith("stake")?o:i},{coseSign1:A,coseKey:d}=is(c,u);return{signature:A,key:d}})}catch(i){throw new Error(`An error occurred during signData: ${i}.`)}}signTx(e,t,r,a,i){try{const o=Ke(Ye(a));return this.accountContext(e,t,(c,u)=>{const A=n.Vkeywitnesses.new();return C.resolveSigners(a,r,c.to_public().hash().to_hex()).forEach(g=>{if(g===c.to_public().hash().to_hex())A.add(n.make_vkey_witness(o,c));else if(g===u.to_public().hash().to_hex())A.add(n.make_vkey_witness(o,u));else if(i===!1)throw new Error(`Missing key witness for: ${g}`)}),A})}catch(o){throw new Error(`An error occurred during signTx: ${o}.`)}}static encryptMnemonic(e,t){const r=Kt.mnemonicToEntropy(e.join(" ")),a=He(r),i=v(a.as_bytes());return a.free(),C.encrypt(i,t)}static encryptPrivateKey(e,t){const r=n.Bip32PrivateKey.from_bech32(e),a=v(r.as_bytes());return r.free(),C.encrypt(a,t)}static encryptSigningKeys(e,t,r){const a=C.encrypt(e.slice(4),r),i=C.encrypt(t.slice(4),r);return[a,i]}static generateMnemonic(e=256){return Kt.generateMnemonic(e).split(" ")}accountContext(e,t,r){const{paymentKey:a,stakeKey:i}=C.resolveKeys(e,t,this._encryptedSecret),o=r(a,i);return a.free(),i.free(),o}static decrypt(e,t){try{return n.decrypt_with_password(Q(t),e)}catch{throw new Error("The password is incorrect.")}}static encrypt(e,t){const r=fe("0123456789abcdef"),a=r(64),i=r(24);return n.encrypt_with_password(Q(t),a,i,e)}static resolveAddress(e,t,r,a){const i=[de(e,r.to_public().hash(),a.to_public().hash()),he(e,r.to_public().hash()),Nt(e,a.to_public().hash())].find(o=>o.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){if(typeof r=="string"){const o=C.decrypt(r,t);return Ps(o,e)}const a=C.decrypt(r[0],t),i=C.decrypt(r[1],t);return{paymentKey:n.PrivateKey.from_hex(a),stakeKey:n.PrivateKey.from_hex(i)}}static resolveSigners(e,t,r){const a=c=>{const u=(p,x=[],B=0)=>{var lt,ct,Yt,Lt,qt;if(p===void 0||B>=p.len())return x;const k=p.get(B),U=new Array;switch(k.kind()){case n.CertificateKind.StakeDeregistration:{const w=(lt=k.as_stake_deregistration())==null?void 0:lt.stake_credential(),V=(w==null?void 0:w.kind())===n.StakeCredKind.Key?w.to_keyhash():void 0;V&&U.push(V.to_hex());break}case n.CertificateKind.StakeDelegation:{const w=(ct=k.as_stake_delegation())==null?void 0:ct.stake_credential(),V=(w==null?void 0:w.kind())===n.StakeCredKind.Key?w.to_keyhash():void 0;V&&U.push(V.to_hex());break}case n.CertificateKind.PoolRegistration:{const w=(Yt=k.as_pool_registration())==null?void 0:Yt.pool_params().pool_owners();U.push(...d(w));break}case n.CertificateKind.PoolRetirement:{const w=(Lt=k.as_pool_retirement())==null?void 0:Lt.pool_keyhash();w&&U.push(w.to_hex());break}case n.CertificateKind.MoveInstantaneousRewardsCert:{const w=(qt=k.as_move_instantaneous_rewards_cert())==null?void 0:qt.move_instantaneous_reward().as_to_stake_creds();if(w)for(let V=0;V<w.len();V+=1){const Gt=w.keys().get(V),Rt=Gt.kind()===n.StakeCredKind.Key?Gt.to_keyhash():void 0;Rt&&U.push(Rt.to_hex())}break}}return u(p,[...x,...U],B+1)},A=(p,x=[],B=0)=>{if(p===void 0||B>=p.len())return x;const k=p.get(B).index(),U=p.get(B).transaction_id(),lt=t.find(ct=>ct.input.outputIndex===k&&ct.input.txHash===U.to_hex())!==void 0?r:"OUR_PRINCESS_IS_IN_ANOTHER_CASTLE";return A(p,[...x,lt],B+1)},d=(p,x=[],B=0)=>p===void 0||B>=p.len()?x:d(p,[...x,p.get(B).to_hex()],B+1),g=(p,x=[],B=0)=>{if(p===void 0||B>=p.len())return x;const k=p.keys().get(B).payment_cred(),U=k.kind()===n.StakeCredKind.Key?k.to_keyhash():void 0;return g(p,U?[...x,U.to_hex()]:x,B+1)},I=c.certs(),y=c.collateral(),S=c.inputs(),O=c.required_signers(),R=c.withdrawals();return[...u(I),...A(y),...A(S),...d(O),...g(R)]},i=c=>{const u=(d,g=[])=>{var I,y,S,O;if(d)for(let R=0;R<d.len();R+=1){const p=d.get(R);switch(p.kind()){case n.NativeScriptKind.ScriptPubkey:{const x=(I=p.as_script_pubkey())==null?void 0:I.addr_keyhash().to_hex();return x?[...g,x]:g}case n.NativeScriptKind.ScriptAll:return u((y=p.as_script_all())==null?void 0:y.native_scripts(),g);case n.NativeScriptKind.ScriptAny:return u((S=p.as_script_any())==null?void 0:S.native_scripts(),g);case n.NativeScriptKind.ScriptNOfK:return u((O=p.as_script_n_of_k())==null?void 0:O.native_scripts(),g)}}return g},A=c.native_scripts();return[...u(A)]},o=L(e);return new Set([...a(o.body()),...i(o.witness_set())])}}const K="MARI0TIME";class hr{_fetcher;_submitter;_wallet;constructor(e){switch(this._fetcher=e.fetcher,this._submitter=e.submitter,e.key.type){case"mnemonic":this._wallet=new C(e.networkId,C.encryptMnemonic(e.key.words,K));break;case"root":this._wallet=new C(e.networkId,C.encryptPrivateKey(e.key.bech32,K));break;case"cli":this._wallet=new C(e.networkId,C.encryptSigningKeys(e.key.payment,e.key.stake??"f0".repeat(34),K))}}getBaseAddress(e=0){return this._wallet.getAccount(e,K).baseAddress}getPaymentAddress(e=0){return this._wallet.getAccount(e,K).enterpriseAddress}getRewardAddress(e=0){return this._wallet.getAccount(e,K).rewardAddress}getUsedAddress(e=0){const t=this._wallet.getAccount(e,K);return M(t.enterpriseAddress)}getUsedCollateral(e=q.maxCollateralInputs){throw new Error("getUsedCollateral not implemented.")}async getUsedUTxOs(e=0){const t=this._wallet.getAccount(e,K);return(await this._fetcher.fetchAddressUTxOs(t.enterpriseAddress)).map(a=>P(a))}signData(e,t,r=0){try{return this._wallet.signData(r,K,e,t)}catch(a){throw new Error(`[AppWallet] An error occurred during signData: ${a}.`)}}async signTx(e,t=!1,r=0){try{const a=this._wallet.getAccount(r,K),i=await this._fetcher.fetchAddressUTxOs(a.enterpriseAddress),o=this._wallet.signTx(r,K,i,e,t),c=L(e),u=c.witness_set(),A=Le(u,o);return u.set_vkeys(A),n.Transaction.new(c.body(),u,c.auxiliary_data()).to_hex()}catch(a){throw new Error(`[AppWallet] An error occurred during signTx: ${a}.`)}}submitTx(e){return this._submitter.submitTx(e)}static brew(e=256){return C.generateMnemonic(e)}}class St{_walletInstance;constructor(e){this._walletInstance=e}static getInstalledWallets(){return window.cardano===void 0?[]:zt.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 St.resolveInstance(e);if(t!==void 0)return new St(t);throw new Error(`Couldn't create an instance of wallet: ${e}`)}catch(t){throw new Error(`[BrowserWallet] An error occurred during enable: ${t}.`)}}async getBalance(){const e=await this._walletInstance.getBalance();return Me(Ls(e))}async getChangeAddress(){const e=await this._walletInstance.getChangeAddress();return st(e).to_bech32()}async getCollateral(e=q.maxCollateralInputs){return(await this.getUsedCollateral(e)).map(r=>xt(r))}getNetworkId(){return this._walletInstance.getNetworkId()}async getRewardAddresses(){return(await this._walletInstance.getRewardAddresses()).map(t=>st(t).to_bech32())}async getUnusedAddresses(){return(await this._walletInstance.getUnusedAddresses()).map(t=>st(t).to_bech32())}async getUsedAddresses(){return(await this._walletInstance.getUsedAddresses()).map(t=>st(t).to_bech32())}async getUtxos(){return(await this.getUsedUTxOs()).map(t=>xt(t))}signData(e,t){const r=M(e).to_hex();return this._walletInstance.signData(r,Q(t))}async signTx(e,t=!1){try{const r=L(e),a=r.witness_set(),i=await this._walletInstance.signTx(e,t),o=Ys(i).vkeys()??n.Vkeywitnesses.new(),c=Le(a,o);return a.set_vkeys(c),v(n.Transaction.new(r.body(),a,r.auxiliary_data()).to_bytes())}catch(r){throw new Error(`[BrowserWallet] An error occurred during signTx: ${JSON.stringify(r)}.`)}}submitTx(e){return this._walletInstance.submitTx(e)}async getUsedAddress(){const e=await this._walletInstance.getUsedAddresses();return st(e[0])}async getUsedCollateral(e=q.maxCollateralInputs){return(await this._walletInstance.experimental.getCollateral()??[]).map(r=>Ae(r)).slice(0,e)}async getUsedUTxOs(){return(await this._walletInstance.getUtxos()??[]).map(t=>Ae(t))}async getAssets(){return(await this.getBalance()).filter(t=>t.unit!=="lovelace").map(t=>{const r=t.unit.slice(0,T),a=t.unit.slice(T),i=Ve(r,a);return{unit:t.unit,policyId:r,assetName:Ot(a),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,T)))).filter(t=>t!=="lovelace")}static resolveInstance(e){if(window.cardano===void 0)return;const t=zt.map(r=>window.cardano[r]).filter(r=>r!==void 0).find(r=>r.name.toLowerCase()===e.toLowerCase());return t==null?void 0:t.enable()}}const qe="http://localhost:4000/",Ir="http://localhost:5000/",mr=`${qe}access`,pr=`${qe}transaction/signtx`;class fr{static getAxiosInstance(){return J.create({baseURL:Ir,withCredentials:!0})}static getAppId(){return window.location.hostname}static async openMinaFrontend(e){const t=this.getAppId();e.includes("?")?e=`${e}&appId=${t}`:e=`${e}?appId=${t}`;const r="left=100,top=100,width=540,height=540",a=window.open(e,"meshWindow",r);return a||console.error("the window did not open",a),await(async()=>new Promise(i=>{window.addEventListener("message",async o=>{o.data.target=="minaWallet"&&i(o.data)})}))()}static async get(e,t={}){const r=this.getAppId();t={...t,appId:r};try{return(await this.getAxiosInstance().get(e,{params:t})).data}catch{console.error("Not logged in");return}}static async enable(){return await this.get("wallet/getuserwalletsmeta")===void 0?await this.openMinaFrontend(mr):!0}static async getChangeAddress(e=void 0,t=void 0){return await this.get("wallet/getchangeaddress",{walletId:e,accountIndex:t})}static async getUtxos(e=void 0,t=void 0){return await this.get("wallet/getutxo",{walletId:e,accountIndex:t})}static async signTx(e,t=!1){const r=await this.get("wallet/getuserwalletsmeta");if(console.log("userWalletsMeta",r),r){const a=await this.openMinaFrontend(`${pr}?unsignedTx=${e}&partialSign=${t}`);if(a instanceof n.Vkeywitnesses){const i=L(e),o=i.witness_set();o.set_vkeys(a);const c=n.Transaction.new(i.body(),o,i.auxiliary_data()).to_hex();return console.log("signedTx",c),c}}else return}}exports.AppWallet=hr;exports.BlockfrostProvider=or;exports.BrowserWallet=St;exports.EmbeddedWallet=C;exports.ForgeScript=dr;exports.InfuraProvider=cr;exports.KoiosProvider=ur;exports.MinaWallet=fr;exports.OgmiosProvider=Ar;exports.TangoProvider=gr;exports.checkSignature=os;exports.generateNonce=ar;exports.isNetwork=pe;exports.keepRelevant=ye;exports.largestFirst=ts;exports.largestFirstMultiAsset=Ce;exports.parseAssetUnit=tt;exports.parseHttpError=l;exports.readPlutusData=nr;exports.readTransaction=ir;exports.resolveDataHash=zs;exports.resolveEpochNo=Ws;exports.resolveFingerprint=Ve;exports.resolveLanguageView=Js;exports.resolveNativeScriptHash=js;exports.resolvePaymentKeyHash=X;exports.resolvePlutusScriptAddress=Xs;exports.resolvePlutusScriptHash=Zs;exports.resolvePoolId=tr;exports.resolvePrivateKey=er;exports.resolveRewardAddress=Dt;exports.resolveScriptRef=sr;exports.resolveSlotNo=rr;exports.resolveStakeKeyHash=rt;exports.resolveTxFees=Vt;exports.resolveTxHash=Ye;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const pe=require("nanoid"),Ge=require("@emurgo/cardano-serialization-lib-nodejs"),Re=require("axios"),Kt=require("bip39"),f=require("@emurgo/cardano-message-signing-nodejs"),$e=s=>s&&typeof s=="object"&&"default"in s?s:{default:s};function ze(s){if(s&&s.__esModule)return 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 i=ze(Ge),G=$e(Re),We=["testnet","preview","preprod","mainnet"],fe=s=>We.includes(s),_e={mem:7e6,steps:3e9},R={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"},kt=2147483648,Bt={V1:i.Language.new_plutus_v1(),V2:i.Language.new_plutus_v2()},H=56,Je={CERT:i.RedeemerTag.new_cert(),MINT:i.RedeemerTag.new_mint(),REWARD:i.RedeemerTag.new_reward(),SPEND:i.RedeemerTag.new_spend()},xt={testnet:["74","1598400","1595967616","432000"],preview:["183","15811222","1682467200","86400"],preprod:["65","26438400","1682121600","432000"],mainnet:["208","4492800","1596059091","432000"]},$t={ALONZO:i.TxBuilderConstants.plutus_alonzo_cost_models(),BABBAGE:(()=>{const s=i.Costmdls.new(),e=i.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,a)=>e.set(a,i.Int.new_i32(r)));const t=i.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,a)=>t.set(a,i.Int.new_i32(r))),s.insert(i.Language.new_plutus_v1(),e),s.insert(i.Language.new_plutus_v2(),t),s})()},je={ALONZO:{V1:"a141005901d59f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f704001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff"},BABBAGE:{V1:"a141005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff",V2:"a20198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c80041005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff"}},Pt={[i.NetworkInfo.testnet().network_id()]:"8d18d786e92776c824607fd8e193ec535c79dc61ea2405ddf3b09fe3",[i.NetworkInfo.mainnet().network_id()]:"f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a"},Xe={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"},Ze={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"},zt=["begin","eternl","flint","lace","nami","nufi","gerowallet","typhoncip30","vespr"],ye=(s,e,t="5000000")=>{const r=i.BigNum.from_str(s.get("lovelace")??"0").checked_add(i.BigNum.from_str(t)),a=e.filter(c=>c.output.amount.filter(u=>u.unit!=="lovelace").some(u=>s.has(u.unit))),n=rs(a);return[...n.less_than(r)?as(r.clamped_sub(n).to_str(),e.filter(c=>!a.some(u=>u.input.txHash===c.input.txHash&&u.input.outputIndex===c.input.outputIndex))):[],...a]},ts=(s,e,t=!1,{maxTxSize:r,minFeeA:a,minFeeB:n}=R)=>{const o=e.filter(l=>we(l)===!1).sort(Tt),c=i.BigNum.from_str(Vt(r,a,n)),u=t?i.BigNum.from_str(s).checked_add(c).to_str():s;return lt(o,new Map([["lovelace",u]]))},Ce=(s,e,t=!1,r=R)=>{const a=e.filter(we).sort(Tt),n=ss(r),o=s.get("lovelace")??"0",c=t?i.BigNum.from_str(o).checked_add(n).to_str():o;return s.set("lovelace",c),lt(a,s)},es=(s,e)=>Array.from(e,t=>({unit:t[0],quantity:i.BigNum.from_str(t[1])})).every(t=>s.filter(r=>r.output.amount.find(a=>a.unit===t.unit)!==void 0).reduce((r,a)=>{const n=a.output.amount.reduce((o,c)=>o.checked_add(i.BigNum.from_str(t.unit===c.unit?c.quantity:"0")),i.BigNum.from_str("0"));return r.checked_add(n)},i.BigNum.from_str("0")).less_than(t.quantity)===!1),Tt=(s,e)=>{var a,n;const t=i.BigNum.from_str(((a=s.output.amount.find(o=>o.unit==="lovelace"))==null?void 0:a.quantity)??"0");return i.BigNum.from_str(((n=e.output.amount.find(o=>o.unit==="lovelace"))==null?void 0:n.quantity)??"0").compare(t)},ss=s=>{const{maxTxSize:e,minFeeA:t,minFeeB:r}=s;return i.BigNum.from_str(Vt(e,t,r))},we=s=>s.output.amount.length>1,rs=s=>s.reduce((e,t)=>{var a;const r=((a=t.output.amount.find(n=>n.unit==="lovelace"))==null?void 0:a.quantity)??"0";return e.checked_add(i.BigNum.from_str(r))},i.BigNum.from_str("0")),as=(s,e)=>{const t=e.sort(Tt);return lt(t,new Map([["lovelace",s]]))},lt=(s,e,t=[])=>s.length===0||es(t,e)?t:ns(s[0],e)?lt(s.slice(1),e,[...t,s[0]]):lt(s.slice(1),e,t),ns=(s,e)=>Array.from(e.keys()).some(t=>s.output.amount.find(r=>r.unit===t)!==void 0),is=(s,e)=>{const t=us(e),r=As(s,e);return{coseKey:D(t.to_bytes()),coseSign1:D(r.to_bytes())}},os=(s,e,{key:t,signature:r})=>{var o,c;const a=f.COSEKey.from_bytes(m(t)),n=f.COSESign1.from_bytes(m(r));if((s==null?void 0:s.length)>0){const u=D(n.payload()??new Uint8Array);if(Q(s)!==u)return!1}if((e==null?void 0:e.length)>0){const A=(o=n.headers().protected().deserialized_headers().header(f.Label.new_text("address")))==null?void 0:o.as_bytes();if(A===void 0)throw new Error("Couldn't find a signer address in signature");const g=(c=a.header(f.Label.new_int(f.Int.new_negative(f.BigNum.from_str("2")))))==null?void 0:c.as_bytes();if(g===void 0)throw new Error("Couldn't find a signer key in signature");const l=st(D(A)),I=Ts(D(g));if(cs(e,l,I)===!1)throw new Error("Couldn't check signature because of address mismatch");const _=Ps(D(n.signature())),C=n.signed_data().to_bytes();return I.verify(C,_)}return!1},cs=(s,e,t)=>{if(s!==e.to_bech32())return!1;try{return rt(s)===t.hash().to_hex()}catch{return!1}},us=s=>{const e=f.COSEKey.new(f.Label.from_key_type(f.KeyType.OKP));return e.set_algorithm_id(f.Label.from_algorithm_id(f.AlgorithmId.EdDSA)),e.set_header(f.Label.new_int(f.Int.new_negative(f.BigNum.from_str("1"))),f.CBORValue.new_int(f.Int.new_i32(6))),e.set_header(f.Label.new_int(f.Int.new_negative(f.BigNum.from_str("2"))),f.CBORValue.new_bytes(s.key.to_public().as_bytes())),e},As=(s,e)=>{const t=f.HeaderMap.new(),r=f.HeaderMap.new();t.set_algorithm_id(f.Label.from_algorithm_id(f.AlgorithmId.EdDSA)),t.set_header(f.Label.new_text("address"),f.CBORValue.new_bytes(e.address.to_bytes()));const a=f.Headers.new(f.ProtectedHeaderMap.new(t),r),n=f.COSESign1Builder.new(a,m(s.payload),!1);s.externalAAD!==void 0&&n.set_external_aad(m(s.externalAAD));const o=n.make_data_to_sign(),c=e.key.sign(o.to_bytes());return n.build(c.to_bytes())};var Wt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Be={},b={exports:{}};$.notEqual=ls;$.notOk=gs;$.equal=ds;$.ok=$;var xe=$;function ds(s,e,t){$(s==e,t)}function ls(s,e,t){$(s!=e,t)}function gs(s,e){$(!s,e)}function $(s,e){if(!s)throw new Error(e||"AssertionError")}var V={exports:{}};function hs(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 Is=Ft;Ft.supported=typeof WebAssembly<"u";function Ft(s){if(!Ft.supported)return null;var e=s&&s.imports,t=ms("AGFzbQEAAAABEANgAn9/AGADf39/AGABfwADBQQAAQICBQUBAQroBwdNBQZtZW1vcnkCAAxibGFrZTJiX2luaXQAAA5ibGFrZTJiX3VwZGF0ZQABDWJsYWtlMmJfZmluYWwAAhBibGFrZTJiX2NvbXByZXNzAAMK00AElgMAIABCADcDACAAQQhqQgA3AwAgAEEQakIANwMAIABBGGpCADcDACAAQSBqQgA3AwAgAEEoakIANwMAIABBMGpCADcDACAAQThqQgA3AwAgAEHAAGpCADcDACAAQcgAakIANwMAIABB0ABqQgA3AwAgAEHYAGpCADcDACAAQeAAakIANwMAIABB6ABqQgA3AwAgAEHwAGpCADcDACAAQfgAakIANwMAIABBgAFqQoiS853/zPmE6gBBACkDAIU3AwAgAEGIAWpCu86qptjQ67O7f0EIKQMAhTcDACAAQZABakKr8NP0r+68tzxBECkDAIU3AwAgAEGYAWpC8e30+KWn/aelf0EYKQMAhTcDACAAQaABakLRhZrv+s+Uh9EAQSApAwCFNwMAIABBqAFqQp/Y+dnCkdqCm39BKCkDAIU3AwAgAEGwAWpC6/qG2r+19sEfQTApAwCFNwMAIABBuAFqQvnC+JuRo7Pw2wBBOCkDAIU3AwAgAEHAAWpCADcDACAAQcgBakIANwMAIABB0AFqQgA3AwALbQEDfyAAQcABaiEDIABByAFqIQQgBCkDAKchBQJAA0AgASACRg0BIAVBgAFGBEAgAyADKQMAIAWtfDcDAEEAIQUgABADCyAAIAVqIAEtAAA6AAAgBUEBaiEFIAFBAWohAQwACwsgBCAFrTcDAAtkAQN/IABBwAFqIQEgAEHIAWohAiABIAEpAwAgAikDAHw3AwAgAEHQAWpCfzcDACACKQMApyEDAkADQCADQYABRg0BIAAgA2pBADoAACADQQFqIQMMAAsLIAIgA603AwAgABADC+U7AiB+CX8gAEGAAWohISAAQYgBaiEiIABBkAFqISMgAEGYAWohJCAAQaABaiElIABBqAFqISYgAEGwAWohJyAAQbgBaiEoICEpAwAhASAiKQMAIQIgIykDACEDICQpAwAhBCAlKQMAIQUgJikDACEGICcpAwAhByAoKQMAIQhCiJLznf/M+Y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8fCEEIA8gBIVCEIohDyAKIA98IQogBSAKhUI/iiEFICEgISkDACABIAmFhTcDACAiICIpAwAgAiAKhYU3AwAgIyAjKQMAIAMgC4WFNwMAICQgJCkDACAEIAyFhTcDACAlICUpAwAgBSANhYU3AwAgJiAmKQMAIAYgDoWFNwMAICcgJykDACAHIA+FhTcDACAoICgpAwAgCCAQhYU3AwAL"),r=null,a={buffer:t,memory:null,exports:null,realloc:n,onload:o};return o(function(){}),a;function n(u){a.exports.memory.grow(Math.ceil(Math.abs(u-a.memory.length)/65536)),a.memory=new Uint8Array(a.exports.memory.buffer)}function o(u){if(a.exports)return u();if(r){r.then(u.bind(null,null)).catch(u);return}try{if(s&&s.async)throw new Error("async");c({instance:new WebAssembly.Instance(new WebAssembly.Module(t),e)})}catch{r=WebAssembly.instantiate(t,e).then(c)}o(u)}function c(u){a.exports=u.instance.exports,a.memory=a.exports.memory&&a.exports.memory.buffer&&new Uint8Array(a.exports.memory.buffer)}}function ms(s){return typeof atob=="function"?new Uint8Array(atob(s).split("").map(ps)):new(hs("buffer")).Buffer(s,"base64")}function ps(s){return s.charCodeAt(0)}var T=xe,y=Is(),q=64,yt=[];V.exports=k;var Jt=V.exports.BYTES_MIN=16,jt=V.exports.BYTES_MAX=64;V.exports.BYTES=32;var Xt=V.exports.KEYBYTES_MIN=16,Zt=V.exports.KEYBYTES_MAX=64;V.exports.KEYBYTES=32;var te=V.exports.SALTBYTES=16,ee=V.exports.PERSONALBYTES=16;function k(s,e,t,r,a){if(!(this instanceof k))return new k(s,e,t,r,a);if(!(y&&y.exports))throw new Error("WASM not loaded. Wait for Blake2b.ready(cb)");s||(s=32),a!==!0&&(T(s>=Jt,"digestLength must be at least "+Jt+", was given "+s),T(s<=jt,"digestLength must be at most "+jt+", was given "+s),e!=null&&T(e.length>=Xt,"key must be at least "+Xt+", was given "+e.length),e!=null&&T(e.length<=Zt,"key must be at least "+Zt+", was given "+e.length),t!=null&&T(t.length===te,"salt must be exactly "+te+", was given "+t.length),r!=null&&T(r.length===ee,"personal must be exactly "+ee+", was given "+r.length)),yt.length||(yt.push(q),q+=216),this.digestLength=s,this.finalized=!1,this.pointer=yt.pop(),y.memory.fill(0,0,64),y.memory[0]=this.digestLength,y.memory[1]=e?e.length:0,y.memory[2]=1,y.memory[3]=1,t&&y.memory.set(t,32),r&&y.memory.set(r,48),this.pointer+216>y.memory.length&&y.realloc(this.pointer+216),y.exports.blake2b_init(this.pointer,this.digestLength),e&&(this.update(e),y.memory.fill(0,q,q+e.length),y.memory[this.pointer+200]=128)}k.prototype.update=function(s){return T(this.finalized===!1,"Hash instance finalized"),T(s,"input must be TypedArray or Buffer"),q+s.length>y.memory.length&&y.realloc(q+s.length),y.memory.set(s,q),y.exports.blake2b_update(this.pointer,q,q+s.length),this};k.prototype.digest=function(s){if(T(this.finalized===!1,"Hash instance finalized"),this.finalized=!0,yt.push(this.pointer),y.exports.blake2b_final(this.pointer),!s||s==="binary")return y.memory.slice(this.pointer+128,this.pointer+128+this.digestLength);if(s==="hex")return _s(y.memory,this.pointer+128,this.digestLength);T(s.length>=this.digestLength,"input must be TypedArray or Buffer");for(var e=0;e<this.digestLength;e++)s[e]=y.memory[this.pointer+128+e];return s};k.prototype.final=k.prototype.digest;k.WASM=y&&y.buffer;k.SUPPORTED=typeof WebAssembly<"u";k.ready=function(s){if(s||(s=fs),!y)return s(new Error("WebAssembly not supported"));var e=new Promise(function(t,r){y.onload(function(a){a?r():t(),s(a)})});return e};k.prototype.ready=k.ready;function fs(){}function _s(s,e,t){for(var r="",a=0;a<t;a++)r+=ys(s[e+a]);return r}function ys(s){return s<16?"0"+s.toString(16):s.toString(16)}var j=xe,gt=V.exports;function mt(s,e,t){var r=s[e]+s[t],a=s[e+1]+s[t+1];r>=4294967296&&a++,s[e]=r,s[e+1]=a}function se(s,e,t,r){var a=s[e]+t;t<0&&(a+=4294967296);var n=s[e+1]+r;a>=4294967296&&n++,s[e]=a,s[e+1]=n}function Ee(s,e){return s[e]^s[e+1]<<8^s[e+2]<<16^s[e+3]<<24}function W(s,e,t,r,a,n){var o=At[a],c=At[a+1],u=At[n],A=At[n+1];mt(h,s,e),se(h,s,o,c);var g=h[r]^h[s],l=h[r+1]^h[s+1];h[r]=l,h[r+1]=g,mt(h,t,r),g=h[e]^h[t],l=h[e+1]^h[t+1],h[e]=g>>>24^l<<8,h[e+1]=l>>>24^g<<8,mt(h,s,e),se(h,s,u,A),g=h[r]^h[s],l=h[r+1]^h[s+1],h[r]=g>>>16^l<<16,h[r+1]=l>>>16^g<<16,mt(h,t,r),g=h[e]^h[t],l=h[e+1]^h[t+1],h[e]=l>>>31^g<<1,h[e+1]=g>>>31^l<<1}var Se=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],E=new Uint8Array(Cs.map(function(s){return s*2})),h=new Uint32Array(32),At=new Uint32Array(32);function Qe(s,e){var t=0;for(t=0;t<16;t++)h[t]=s.h[t],h[t+16]=Se[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++)At[t]=Ee(s.b,4*t);for(t=0;t<12;t++)W(0,8,16,24,E[t*16+0],E[t*16+1]),W(2,10,18,26,E[t*16+2],E[t*16+3]),W(4,12,20,28,E[t*16+4],E[t*16+5]),W(6,14,22,30,E[t*16+6],E[t*16+7]),W(0,10,20,30,E[t*16+8],E[t*16+9]),W(2,12,22,24,E[t*16+10],E[t*16+11]),W(4,14,16,26,E[t*16+12],E[t*16+13]),W(6,8,18,28,E[t*16+14],E[t*16+15]);for(t=0;t<16;t++)s.h[t]=s.h[t]^h[t]^h[t+16]}var J=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 nt(s,e,t,r){J.fill(0),this.b=new Uint8Array(128),this.h=new Uint32Array(16),this.t=0,this.c=0,this.outlen=s,J[0]=s,e&&(J[1]=e.length),J[2]=1,J[3]=1,t&&J.set(t,32),r&&J.set(r,48);for(var a=0;a<16;a++)this.h[a]=Se[a]^Ee(J,a*4);e&&(be(this,e),this.c=128)}nt.prototype.update=function(s){return j(s!=null,"input must be Uint8Array or Buffer"),be(this,s),this};nt.prototype.digest=function(s){var e=!s||s==="binary"||s==="hex"?new Uint8Array(this.outlen):s;return j(e.length>=this.outlen,"out must have at least outlen bytes of space"),ws(this,e),s==="hex"?Bs(e):e};nt.prototype.final=nt.prototype.digest;nt.ready=function(s){gt.ready(function(){s()})};function be(s,e){for(var t=0;t<e.length;t++)s.c===128&&(s.t+=s.c,Qe(s,!1),s.c=0),s.b[s.c++]=e[t]}function ws(s,e){for(s.t+=s.c;s.c<128;)s.b[s.c++]=0;Qe(s,!0);for(var t=0;t<s.outlen;t++)e[t]=s.h[t>>2]>>8*(t&3);return e}function Bs(s){for(var e="",t=0;t<s.length;t++)e+=xs(s[t]);return e}function xs(s){return s<16?"0"+s.toString(16):s.toString(16)}var ve=nt;b.exports=function(e,t,r,a,n){return n!==!0&&(j(e>=re,"outlen must be at least "+re+", was given "+e),j(e<=ae,"outlen must be at most "+ae+", was given "+e),t!=null&&j(t.length>=ne,"key must be at least "+ne+", was given "+t.length),t!=null&&j(t.length<=ie,"key must be at most "+ie+", was given "+t.length),r!=null&&j(r.length===oe,"salt must be exactly "+oe+", was given "+r.length),a!=null&&j(a.length===ce,"personal must be exactly "+ce+", was given "+a.length)),new ve(e,t,r,a)};b.exports.ready=function(s){gt.ready(function(){s()})};b.exports.WASM_SUPPORTED=gt.SUPPORTED;b.exports.WASM_LOADED=!1;var re=b.exports.BYTES_MIN=16,ae=b.exports.BYTES_MAX=64;b.exports.BYTES=32;var ne=b.exports.KEYBYTES_MIN=16,ie=b.exports.KEYBYTES_MAX=64;b.exports.KEYBYTES=32;var oe=b.exports.SALTBYTES=16,ce=b.exports.PERSONALBYTES=16;gt.ready(function(s){s||(b.exports.WASM_LOADED=!0,ve=gt)});var it={};Object.defineProperty(it,"__esModule",{value:!0});it.bech32m=it.bech32=void 0;const Et="qpzry9x8gf2tvdw0s3jn54khce6mua7l",De={};for(let s=0;s<Et.length;s++){const e=Et.charAt(s);De[e]=s}function at(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 ue(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=at(e)^r>>5}e=at(e);for(let t=0;t<s.length;++t){const r=s.charCodeAt(t);e=at(e)^r&31}return e}function Mt(s,e,t,r){let a=0,n=0;const o=(1<<t)-1,c=[];for(let u=0;u<s.length;++u)for(a=a<<e|s[u],n+=e;n>=t;)n-=t,c.push(a>>n&o);if(r)n>0&&c.push(a<<t-n&o);else{if(n>=e)return"Excess padding";if(a<<t-n&o)return"Non-zero padding"}return c}function Es(s){return Mt(s,8,5,!0)}function Ss(s){const e=Mt(s,5,8,!1);if(Array.isArray(e))return e}function Qs(s){const e=Mt(s,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function ke(s){let e;s==="bech32"?e=1:e=734539939;function t(o,c,u){if(u=u||90,o.length+7+c.length>u)throw new TypeError("Exceeds length limit");o=o.toLowerCase();let A=ue(o);if(typeof A=="string")throw new Error(A);let g=o+"1";for(let l=0;l<c.length;++l){const I=c[l];if(I>>5!==0)throw new Error("Non 5-bit word");A=at(A)^I,g+=Et.charAt(I)}for(let l=0;l<6;++l)A=at(A);A^=e;for(let l=0;l<6;++l){const I=A>>(5-l)*5&31;g+=Et.charAt(I)}return g}function r(o,c){if(c=c||90,o.length<8)return o+" too short";if(o.length>c)return"Exceeds length limit";const u=o.toLowerCase(),A=o.toUpperCase();if(o!==u&&o!==A)return"Mixed-case string "+o;o=u;const g=o.lastIndexOf("1");if(g===-1)return"No separator character for "+o;if(g===0)return"Missing prefix for "+o;const l=o.slice(0,g),I=o.slice(g+1);if(I.length<6)return"Data too short";let _=ue(l);if(typeof _=="string")return _;const C=[];for(let v=0;v<I.length;++v){const U=I.charAt(v),p=De[U];if(p===void 0)return"Unknown character "+U;_=at(_)^p,!(v+6>=I.length)&&C.push(p)}return _!==e?"Invalid checksum for "+o:{prefix:l,words:C}}function a(o,c){const u=r(o,c);if(typeof u=="object")return u}function n(o,c){const u=r(o,c);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:a,decode:n,encode:t,toWords:Es,fromWordsUnsafe:Ss,fromWords:Qs}}it.bech32=ke("bech32");it.bech32m=ke("bech32m");var bs=Wt&&Wt.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Be,"__esModule",{value:!0});const vs=bs(b.exports),pt=it,Ut="asset";class dt{constructor(e){this.hashBuf=e}static fromHash(e){return new dt(e)}static fromParts(e,t){const r=(0,vs.default)(20).update(new Uint8Array([...e,...t])).digest("binary");return dt.fromHash(r)}static fromBech32(e){const{prefix:t,words:r}=pt.bech32.decode(e);if(t!==Ut)throw new Error("Invalid asset fingerprint");const a=Buffer.from(pt.bech32.fromWords(r));return dt.fromHash(a)}fingerprint(){const e=pt.bech32.toWords(this.hashBuf);return pt.bech32.encode(Ut,e)}hash(){return Buffer.from(this.hashBuf).toString("hex")}prefix(){return Ut}checksum(){return this.fingerprint().slice(-6)}}var Ds=Be.default=dt;const ks=Ds,Us=(s,e)=>{const t=Ks(s),r=t.derive(kt+1852).derive(kt+1815).derive(kt+e),a=r.derive(0).derive(0).to_raw_key(),n=r.derive(2).derive(0).to_raw_key();return r.free(),t.free(),{paymentKey:a,stakeKey:n}},st=s=>i.Address.from_bytes(m(s)),Ks=s=>i.Bip32PrivateKey.from_bytes(m(s)),Ns=s=>i.DataHash.from_bytes(m(s)),M=s=>i.Ed25519KeyHash.from_bytes(m(s)),Ps=s=>i.Ed25519Signature.from_bytes(m(s)),bt=s=>i.NativeScript.from_bytes(m(s)),Ts=s=>i.PublicKey.from_bytes(m(s)),Ue=s=>i.PlutusData.from_bytes(m(s)),ot=(s,e)=>i.PlutusScript.from_bytes_with_version(m(s),Bt[e]),Fs=s=>i.ScriptRef.from_bytes(m(s)),Ms=s=>i.ScriptHash.from_bytes(m(s)),L=s=>i.Transaction.from_bytes(m(s)),Ke=s=>i.TransactionHash.from_bytes(m(s)),Ae=s=>i.TransactionUnspentOutput.from_bytes(m(s)),Hs=s=>i.TransactionWitnessSet.from_bytes(m(s)),Os=s=>i.Value.from_bytes(m(s)),O=s=>i.Address.from_bech32(s),Ht=s=>i.BaseAddress.from_address(O(s)),Ne=s=>i.EnterpriseAddress.from_address(O(s)),Pe=s=>i.RewardAddress.from_address(O(s)),D=s=>Buffer.from(s).toString("hex"),m=s=>s.length%2===0&&/^[0-9A-F]*$/i.test(s)?Buffer.from(s,"hex"):Buffer.from(s,"utf-8"),vt=s=>{const e=t=>{const r=new Array;for(let a=0;a<t.len();a+=1)r.push(vt(t.get(a)));return r};switch(s.kind()){case i.NativeScriptKind.ScriptAll:{const t=s.as_script_all();return{type:"all",scripts:e(t.native_scripts())}}case i.NativeScriptKind.ScriptAny:{const t=s.as_script_any();return{type:"any",scripts:e(t.native_scripts())}}case i.NativeScriptKind.ScriptNOfK:{const t=s.as_script_n_of_k();return{type:"atLeast",required:t.n(),scripts:e(t.native_scripts())}}case i.NativeScriptKind.TimelockStart:{const t=s.as_timelock_start();return{type:"after",slot:t.slot_bignum().to_str()}}case i.NativeScriptKind.TimelockExpiry:{const t=s.as_timelock_expiry();return{type:"before",slot:t.slot_bignum().to_str()}}case i.NativeScriptKind.ScriptPubkey:{const t=s.as_script_pubkey();return{type:"sig",keyHash:t.addr_keyhash().to_hex()}}default:throw new Error(`Script Kind: ${s.kind()}, is not supported`)}},Dt=s=>{const e=t=>{const r=i.NativeScripts.new();return t.forEach(a=>{r.add(Dt(a))}),r};switch(s.type){case"all":return i.NativeScript.new_script_all(i.ScriptAll.new(e(s.scripts)));case"any":return i.NativeScript.new_script_any(i.ScriptAny.new(e(s.scripts)));case"atLeast":return i.NativeScript.new_script_n_of_k(i.ScriptNOfK.new(s.required,e(s.scripts)));case"after":return i.NativeScript.new_timelock_start(i.TimelockStart.new_timelockstart(i.BigNum.from_str(s.slot)));case"before":return i.NativeScript.new_timelock_expiry(i.TimelockExpiry.new_timelockexpiry(i.BigNum.from_str(s.slot)));case"sig":return i.NativeScript.new_script_pubkey(i.ScriptPubkey.new(M(s.keyHash)))}},Ct=s=>{var r,a,n;const e=o=>{const c=[];for(let u=0;u<o.len();u+=1)c.push(Ct(o.get(u)));return c},t=o=>{const c=new Map;for(let u=0;u<o.len();u+=1){const A=o.keys().get(u),g=o.get(A)??i.PlutusData.from_hex(Q("NO_ITEM_FOUND_INSIDE_GOLD_ROOM"));c.set(Ct(A),Ct(g))}return c};switch(s.kind()){case i.PlutusDataKind.Bytes:return D(s.as_bytes()??new Uint8Array);case i.PlutusDataKind.Integer:return parseInt(((r=s.as_integer())==null?void 0:r.to_str())??"0",10);case i.PlutusDataKind.List:return e(s.as_list()??i.PlutusList.new());case i.PlutusDataKind.Map:return t(s.as_map()??i.PlutusMap.new());case i.PlutusDataKind.ConstrPlutusData:return{alternative:parseInt(((a=s.as_constr_plutus_data())==null?void 0:a.alternative().to_str())??"0",10),fields:e(((n=s.as_constr_plutus_data())==null?void 0:n.data())??i.PlutusList.new())};default:throw new Error(`PlutusData Kind: ${s.kind()}, is not supported`)}},tt=s=>{const e=t=>{const r=i.PlutusList.new();return t.forEach(a=>{r.add(tt(a))}),r};switch(typeof s){case"string":return i.PlutusData.new_bytes(m(s));case"number":return i.PlutusData.new_integer(i.BigInt.from_str(s.toString()));case"object":if(s instanceof Array){const t=e(s);return i.PlutusData.new_list(t)}else if(s instanceof Map){const t=i.PlutusMap.new();return s.forEach((r,a)=>{t.insert(tt(a),tt(r))}),i.PlutusData.new_map(t)}else return i.PlutusData.new_constr_plutus_data(i.ConstrPlutusData.new(i.BigNum.from_str(s.alternative.toString()),e(s.fields)))}},Vs=s=>{const e=i.Relays.new();throw s.relays.forEach(t=>{e.add(Ys(t))}),new Error("toPoolParams not implemented.")},Te=s=>{const e=t=>Je[t];return i.Redeemer.new(e(s.tag),i.BigNum.from_str(s.index.toString()),tt(s.data),i.ExUnits.new(i.BigNum.from_str(s.budget.mem.toString()),i.BigNum.from_str(s.budget.steps.toString())))},Ys=s=>{switch(s.type){case"SingleHostAddr":{const e=s.IPV4?i.Ipv4.new(new Uint8Array(s.IPV4.split(".").map(r=>parseInt(r)))):void 0,t=s.IPV6?i.Ipv6.new(m(s.IPV6.replaceAll(":",""))):void 0;return i.Relay.new_single_host_addr(i.SingleHostAddr.new(s.port,e,t))}case"SingleHostName":return i.Relay.new_single_host_name(i.SingleHostName.new(s.port,i.DNSRecordAorAAAA.new(s.domainName)));case"MultiHostName":return i.Relay.new_multi_host_name(i.MultiHostName.new(i.DNSRecordSRV.new(s.domainName)))}},Fe=s=>{if(s.is_plutus_script()){const t=s.plutus_script();return{code:t.to_hex(),version:Object.keys(Bt).find(r=>Bt[r].to_hex()===t.language_version().to_hex())}}const e=s.native_script();return vt(e)},ct=s=>{if("code"in s){const e=ot(s.code,s.version);return i.ScriptRef.new_plutus_script(e)}return i.ScriptRef.new_native_script(Dt(s))},St=s=>{var a,n,o;const e=s.output().has_data_hash()?(a=s.output().data_hash())==null?void 0:a.to_hex():void 0,t=s.output().has_plutus_data()?(n=s.output().plutus_data())==null?void 0:n.to_hex():void 0,r=s.output().has_script_ref()?(o=s.output().script_ref())==null?void 0:o.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:Me(s.output().amount()),dataHash:e,plutusData:t,scriptRef:r}}},F=s=>{const e=i.TransactionInput.new(Ke(s.input.txHash),s.input.outputIndex),t=i.TransactionOutput.new(O(s.output.address),wt(s.output.amount));return s.output.dataHash!==void 0&&t.set_data_hash(Ns(s.output.dataHash)),s.output.plutusData!==void 0&&t.set_plutus_data(Ue(s.output.plutusData)),s.output.scriptRef!==void 0&&t.set_script_ref(Fs(s.output.scriptRef)),i.TransactionUnspentOutput.new(e,t)},de=s=>{const e=s.split(".")[1]??"0",t=`${parseInt(e,10)}`,r="1"+"0".repeat(e.length);return i.UnitInterval.new(i.BigNum.from_str(t),i.BigNum.from_str(r))},Q=s=>s.length%2===0&&/^[0-9A-F]*$/i.test(s)?s:D(Buffer.from(s,"utf-8")),Ot=s=>Buffer.from(s,"hex").toString("utf-8"),Me=s=>{const e=[{unit:"lovelace",quantity:s.coin().to_str()}],t=s.multiasset();if(t!==void 0){const r=t.keys();for(let a=0;a<r.len();a+=1){const n=r.get(a),o=t.get(n);if(o!==void 0){const c=o.keys();for(let u=0;u<c.len();u+=1){const A=c.get(u),g=o.get(A)??i.BigNum.from_str("0"),l=n.to_hex()+D(A.name());e.push({unit:l,quantity:g.to_str()})}}}}return e},wt=s=>{const e=s.find(n=>n.unit==="lovelace"),t=Array.from(new Set(s.filter(n=>n.unit!=="lovelace").map(n=>n.unit.slice(0,H)))),r=i.MultiAsset.new();t.forEach(n=>{const o=i.Assets.new();s.filter(c=>c.unit.slice(0,H)===n).forEach(c=>{o.insert(i.AssetName.new(m(c.unit.slice(H))),i.BigNum.from_str(c.quantity))}),r.insert(Ms(n),o)});const a=i.Value.new(i.BigNum.from_str(e?e.quantity:"0"));return(s.length>1||!e)&&a.set_multiasset(r),a},le=(s,e,t)=>i.BaseAddress.new(s,i.StakeCredential.from_keyhash(e),i.StakeCredential.from_keyhash(t)),He=(s,e="")=>i.Bip32PrivateKey.from_bip39_entropy(m(s),m(Q(e))),ge=s=>i.DataCost.new_coins_per_byte(i.BigNum.from_str(s)),qs=s=>{if(typeof s!="object"||!("input"in s))return i.DatumSource.new(tt(s));const e=F(s);if(e.output().has_plutus_data())return i.DatumSource.new_ref_input(e.input());throw new Error(`No inline datum found in UTxO: ${e.input().transaction_id().to_hex()}`)},he=(s,e)=>i.EnterpriseAddress.new(s,i.StakeCredential.from_keyhash(e)),Ie=(s,e)=>{if(typeof s=="string")return i.MintWitness.new_native_script(bt(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 i.MintWitness.new_plutus_script(Oe(s),Te({tag:"MINT",index:0,budget:_e,data:{alternative:0,fields:[]},...e}))},Nt=(s,e)=>i.RewardAddress.new(s,i.StakeCredential.from_keyhash(e)),Oe=s=>{if("code"in s)return i.PlutusScriptSource.new(ot(s.code,s.version));const e=F(s);if(e.output().has_script_ref()){const t=e.output().script_ref();if(t.is_plutus_script()){const r=Fe(t),a=ot(r.code,r.version).hash();return i.PlutusScriptSource.new_ref_input_with_lang_ver(a,e.input(),Bt[r.version])}}throw new Error(`No plutus script reference found in UTxO: ${e.input().transaction_id().to_hex()}`)},ft=s=>{const e=i.ScriptPubkey.new(s);return i.NativeScript.new_script_pubkey(e)},Ls=(s=R)=>{const e=i.TransactionBuilderConfigBuilder.new().coins_per_utxo_byte(i.BigNum.from_str(s.coinsPerUTxOSize)).ex_unit_prices(i.ExUnitPrices.new(de(s.priceMem.toString()),de(s.priceStep.toString()))).fee_algo(i.LinearFee.new(i.BigNum.from_str(s.minFeeA.toString()),i.BigNum.from_str(s.minFeeB.toString()))).key_deposit(i.BigNum.from_str(s.keyDeposit)).max_tx_size(s.maxTxSize).max_value_size(parseInt(s.maxValSize,10)).pool_deposit(i.BigNum.from_str(s.poolDeposit)).build();return i.TransactionBuilder.new(e)},me=s=>{const e=i.TxInputsBuilder.new();return s.map(t=>t instanceof i.TransactionUnspentOutput?t:F(t)).forEach(t=>{e.add_input(t.output().address(),t.input(),t.output().amount())}),e},_t=s=>{if(typeof s=="string")return i.TransactionOutputBuilder.new().with_address(O(s));let e=i.TransactionOutputBuilder.new().with_address(O(s.address));if(s.datum){const{value:t,inline:r}=s.datum,a=tt(t);e=e.with_data_hash(i.hash_plutus_data(a)),r&&(e=e.with_plutus_data(a))}if(s.script){const t=ct(s.script);e=e.with_script_ref(t)}return e},z=s=>{const e=s.slice(0,H),t=s.includes(".")?Q(s.split(".")[1]):s.slice(H);return{policyId:e,assetName:t}},d=s=>G.default.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),Gs=s=>{const e=tt(s);return i.hash_plutus_data(e).to_hex()},Rs=(s,e=Date.now())=>{if(xt[s]){const[t,r,a,n]=xt[s];return parseInt(i.BigNum.from_str(e.toString()).div_floor(i.BigNum.from_str("1000")).checked_sub(i.BigNum.from_str(a)).div_floor(i.BigNum.from_str(n)).checked_add(i.BigNum.from_str(t)).to_str(),10)}throw new Error(`Couldn't resolve EpochNo for network: ${s}`)},Ve=(s,e)=>ks.fromParts(m(s),m(e)).fingerprint(),$s=(s,e)=>je[s][e],zs=s=>Dt(s).hash().to_hex(),Z=s=>{var e,t;try{const r=[(e=Ht(s))==null?void 0:e.payment_cred().to_keyhash(),(t=Ne(s))==null?void 0:t.payment_cred().to_keyhash()].find(a=>a!==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}.`)}},Ws=(s,e=0)=>{const t=ot(s.code,s.version);return i.EnterpriseAddress.new(e,i.StakeCredential.from_scripthash(t.hash())).to_address().to_bech32()},Js=s=>{try{const e=Ne(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}.`)}},js=s=>i.Ed25519KeyHash.from_hex(s).to_bech32("pool1"),Xs=s=>{const e=Kt.mnemonicToEntropy(s.join(" ")),t=He(e),r=t.to_bech32();return t.free(),r},Zs=s=>ct(s).to_hex(),tr=(s,e=Date.now())=>{if(xt[s]){const[t,r,a]=xt[s];return i.BigNum.from_str(e.toString()).div_floor(i.BigNum.from_str("1000")).checked_sub(i.BigNum.from_str(a)).checked_add(i.BigNum.from_str(r)).to_str()}throw new Error(`Couldn't resolve SlotNo for network: ${s}`)},ht=s=>{try{const e=O(s),t=Ht(s),r=t==null?void 0:t.stake_cred().to_keyhash();if(r!==void 0)return Nt(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}.`)}},rt=s=>{var e,t;try{const r=[(e=Ht(s))==null?void 0:e.stake_cred().to_keyhash(),(t=Pe(s))==null?void 0:t.payment_cred().to_keyhash()].find(a=>a!==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}.`)}},Vt=(s,e=R.minFeeA,t=R.minFeeB)=>(BigInt(e)*BigInt(s)+BigInt(t)).toString(),Ye=s=>{const e=L(s).body();return i.hash_transaction(e).to_hex()},er=(s="",e=32)=>{if(e<=0||e>2048)throw new Error("Length must be bewteen 1 and 2048");const r=pe.customAlphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")(e);return Q(`${s}${r}`)},qe=(s,e)=>{const t=s.vkeys();if(t!==void 0){const r=new Set;for(let n=0;n<t.len();n+=1)r.add(t.get(n).to_hex());for(let n=0;n<e.len();n+=1)r.add(e.get(n).to_hex());const a=i.Vkeywitnesses.new();return r.forEach(n=>{a.add(i.Vkeywitness.from_hex(n))}),a}return e},sr=s=>Ct(Ue(s)),rr=s=>L(s).to_js_value();class ar{_axiosInstance;constructor(...e){if(typeof e[0]=="string"&&e[0].startsWith("http"))this._axiosInstance=G.default.create({baseURL:e[0]});else{const t=e[0],r=t.slice(0,7);this._axiosInstance=G.default.create({baseURL:`https://cardano-${r}.blockfrost.io/api/v${e[1]??0}`,headers:{project_id:t}})}}async fetchAccountInfo(e){const t=e.startsWith("addr")?ht(e):e;try{const{data:r,status:a}=await this._axiosInstance.get(`accounts/${t}`);if(a===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 d(r)}catch(r){throw d(r)}}async fetchAddressUTxOs(e,t){const r=t!==void 0?`/${t}`:"",a=`addresses/${e}/utxos`+r,n=async(u=1,A=[])=>{const{data:g,status:l}=await this._axiosInstance.get(`${a}?page=${u}`);if(l===200)return g.length>0?n(u+1,[...A,...await Promise.all(g.map(c))]):A;throw d(g)},o=async u=>{if(u){const{data:A,status:g}=await this._axiosInstance.get(`scripts/${u}`);if(g===200){const l=A.type.startsWith("plutus")?{code:await this.fetchPlutusScriptCBOR(u),version:A.type.replace("plutus","")}:await this.fetchNativeScriptJSON(u);return ct(l).to_hex()}throw d(A)}},c=async u=>({input:{outputIndex:u.output_index,txHash:u.tx_hash},output:{address:e,amount:u.amount,dataHash:u.data_hash??void 0,plutusData:u.inline_datum??void 0,scriptRef:await o(u.reference_script_hash)}});try{return await n()}catch{return[]}}async fetchAssetAddresses(e){const t=async(r=1,a=[])=>{const{policyId:n,assetName:o}=z(e),{data:c,status:u}=await this._axiosInstance.get(`assets/${n}${o}/addresses?page=${r}`);if(u===200)return c.length>0?t(r+1,[...a,...c]):a;throw d(c)};try{return await t()}catch{return[]}}async fetchAssetMetadata(e){try{const{policyId:t,assetName:r}=z(e),{data:a,status:n}=await this._axiosInstance.get(`assets/${t}${r}`);if(n===200)return{...a.onchain_metadata};throw d(a)}catch(t){throw d(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 d(t)}catch(t){throw d(t)}}async fetchCollectionAssets(e,t=1){try{const{data:r,status:a}=await this._axiosInstance.get(`assets/policy/${e}?page=${t}`);if(a===200)return{assets:r.map(n=>({unit:n.asset,quantity:n.quantity})),next:r.length===100?t+1:null};throw d(r)}catch{return{assets:[],next:null}}}async fetchHandleAddress(e){try{const t=Q(e.replace("$","")),{data:r,status:a}=await this._axiosInstance.get(`assets/${Pt[1]}${t}/addresses`);if(a===200)return r[0].address;throw d(r)}catch(t){throw d(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 d(t)}catch(t){throw d(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 d(t)}catch(t){throw d(t)}}onTxConfirmed(e,t,r=100){let a=0;const n=setInterval(()=>{a>=r&&clearInterval(n),this.fetchTxInfo(e).then(o=>{this.fetchBlockInfo(o.block).then(c=>{(c==null?void 0:c.confirmations)>0&&(clearInterval(n),t())}).catch(()=>{a+=1})}).catch(()=>{a+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/cbor"},{data:r,status:a}=await this._axiosInstance.post("tx/submit",m(e),{headers:t});if(a===200)return r;throw d(r)}catch(t){throw d(t)}}async fetchPlutusScriptCBOR(e){const{data:t,status:r}=await this._axiosInstance.get(`scripts/${e}/cbor`);if(r===200)return t.cbor;throw d(t)}async fetchNativeScriptJSON(e){const{data:t,status:r}=await this._axiosInstance.get(`scripts/${e}/json`);if(r===200)return t.json;throw d(t)}}class nr{_axiosInstance;constructor(e,t,r){const a=r.host??"ipfs.infura.io",n=r.port??5001,o=r.version??0;this._axiosInstance=G.default.create({baseURL:`https://${a}:${n}/api/v${o}`,auth:{username:e,password:t}})}async uploadContent(e,t=!1){try{const r={"Content-Type":"multipart/form-data"},{data:a,status:n}=await this._axiosInstance.post(`add?recursive=${t}`,e,{headers:r});if(n===200)return a;throw d(a)}catch(r){throw d(r)}}}class ir{_axiosInstance;constructor(...e){typeof e[0]=="string"&&e[0].startsWith("http")?this._axiosInstance=G.default.create({baseURL:e[0]}):this._axiosInstance=G.default.create({baseURL:`https://${e[0]}.koios.rest/api/v${e[1]??0}`})}async fetchAccountInfo(e){try{const t=e.startsWith("addr")?ht(e):e,{data:r,status:a}=await this._axiosInstance.post("account_info",{_stake_addresses:[t]});if(a===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 d(r)}catch(t){throw d(t)}}async fetchAddressUTxOs(e,t){const r=a=>{if(a){const n=a.type.startsWith("plutus")?{code:a.bytes,version:a.type.replace("plutus","")}:vt(bt(a.bytes));return ct(n).to_hex()}};try{const{data:a,status:n}=await this._axiosInstance.post("address_info",{_addresses:[e]});if(n===200){const o=a.flatMap(c=>c.utxo_set).map(c=>{var u;return{input:{outputIndex:c.tx_index,txHash:c.tx_hash},output:{address:e,amount:[{unit:"lovelace",quantity:c.value},...c.asset_list.map(A=>({unit:`${A.policy_id}${A.asset_name}`,quantity:`${A.quantity}`}))],dataHash:c.datum_hash??void 0,plutusData:((u=c.inline_datum)==null?void 0:u.bytes)??void 0,scriptRef:r(c.reference_script)}}});return t!==void 0?o.filter(c=>c.output.amount.find(u=>u.unit===t)!==void 0):o}throw d(a)}catch{return[]}}async fetchAssetAddresses(e){try{const{policyId:t,assetName:r}=z(e),{data:a,status:n}=await this._axiosInstance.get(`asset_address_list?_asset_policy=${t}&_asset_name=${r}`);if(n===200)return a.map(o=>({address:o.payment_address,quantity:o.quantity}));throw d(a)}catch(t){throw d(t)}}async fetchAssetMetadata(e){try{const{policyId:t,assetName:r}=z(e),{data:a,status:n}=await this._axiosInstance.get(`asset_info?_asset_policy=${t}&_asset_name=${r}`);if(n===200)return{...a[0].minting_tx_metadata[721][t][Ot(r)]};throw d(a)}catch(t){throw d(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 d(t)}catch(t){throw d(t)}}async fetchCollectionAssets(e,t=0){try{const{data:r,status:a}=await this._axiosInstance.get(`asset_policy_info?_asset_policy=${e}&limit=100&offset=${t}`);if(a===200)return{assets:r.map(n=>({unit:`${e}${n.asset_name}`,quantity:n.total_supply})),next:r.length===100?t+100:null};throw d(r)}catch(r){throw d(r)}}async fetchHandleAddress(e){try{const t=Q(e.replace("$","")),{data:r,status:a}=await this._axiosInstance.get(`asset_address_list?_asset_policy=${Pt[1]}&_asset_name=${t}`);if(a===200)return r[0].payment_address;throw d(r)}catch(t){throw d(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 d(t)}catch(t){throw d(t)}}async fetchTxInfo(e){var t,r;try{const{data:a,status:n}=await this._axiosInstance.post("tx_info",{_tx_hashes:[e]});if(n===200)return{block:a[0].block_hash,deposit:a[0].deposit,fees:a[0].fee,hash:a[0].tx_hash,index:a[0].tx_block_index,invalidAfter:((t=a[0].invalid_after)==null?void 0:t.toString())??"",invalidBefore:((r=a[0].invalid_before)==null?void 0:r.toString())??"",slot:a[0].absolute_slot.toString(),size:a[0].tx_size};throw d(a)}catch(a){throw d(a)}}onTxConfirmed(e,t,r=100){let a=0;const n=setInterval(()=>{a>=r&&clearInterval(n),this.fetchTxInfo(e).then(o=>{this.fetchBlockInfo(o.block).then(c=>{(c==null?void 0:c.confirmations)>0&&(clearInterval(n),t())}).catch(()=>{a+=1})}).catch(()=>{a+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/cbor"},{data:r,status:a}=await this._axiosInstance.post("submittx",m(e),{headers:t});if(a===202)return r;throw d(r)}catch(t){throw d(t)}}}class or{_baseUrl;constructor(...e){this._baseUrl=fe(e[0])?Xe[e[0]]:e[0]}async evaluateTx(e){const t=await this.open();return this.send(t,"EvaluateTx",{evaluate:e}),new Promise((r,a)=>{t.addEventListener("message",n=>{try{const{result:o}=JSON.parse(n.data);o.EvaluationResult?r(Object.keys(o.EvaluationResult).map(c=>({index:parseInt(c.split(":")[1],10),tag:c.split(":")[0].toUpperCase(),budget:{mem:o.EvaluationResult[c].memory,steps:o.EvaluationResult[c].steps}}))):a(o.EvaluationFailure),t.close()}catch(o){a(o)}},{once:!0})})}async onNextTx(e){const t=await this.open();return this.send(t,"AwaitAcquire",{}),t.addEventListener("message",r=>{const{result:a}=JSON.parse(r.data);if(a===null)return this.send(t,"AwaitAcquire",{});a.AwaitAcquired===void 0&&e(a),this.send(t,"NextTx",{})}),()=>t.close()}async submitTx(e){const t=await this.open();return this.send(t,"SubmitTx",{submit:e}),new Promise((r,a)=>{t.addEventListener("message",n=>{try{const{result:o}=JSON.parse(n.data);o.SubmitSuccess?r(o.SubmitSuccess.txId):a(o.SubmitFail),t.close()}catch(o){a(o)}},{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 cr{_axiosInstance;constructor(e,t,r,a=1){this._axiosInstance=G.default.create({baseURL:`https://cardano-${e}.tangocrypto.com/${t}/v${a}`,headers:{"x-api-key":r}})}async evaluateTx(e){try{const{data:t,status:r}=await this._axiosInstance.post("transactions/evaluate",{tx:e,utxos:[]});if(r===200)return t.redeemers.map(a=>({index:a.index,tag:a.purpose.toUpperCase(),budget:{mem:a.unit_mem,steps:a.unit_steps}}));throw d(t)}catch(t){throw d(t)}}async fetchAccountInfo(e){try{const t=e.startsWith("addr")?ht(e):e,{data:r,status:a}=await this._axiosInstance.get(`wallets/${t}`);if(a===200)return{poolId:r.pool_id,active:r.active,balance:r.controlled_total_stake,rewards:r.rewards_sum,withdrawals:r.withdrawals_sum};throw d(r)}catch(t){throw d(t)}}async fetchAddressUTxOs(e,t){const r=t!==void 0?`/assets/${t}`:"",a=`addresses/${e}${r}/utxos?size=50`,n=async(A="",g=[])=>{var _;const{data:l,status:I}=await this._axiosInstance.get(`${a}&cursor=${A}`);if(I===200)return l.cursor!==null&&((_=l.cursor)==null?void 0:_.length)>0?n(l.cursor,[...g,...l.data.map(u)]):l.data.map(u);throw d(l)},o=(A,g)=>{const l=[{unit:"lovelace",quantity:A.toString()}];return g.forEach(I=>{const _=Q(I.asset_name);l.push({unit:`${I.policy_id}${_}`,quantity:I.quantity.toString()})}),l},c=A=>{if(A){const g=A.type.startsWith("plutus")?{code:A.code,version:A.type.replace("plutus","")}:vt(bt(A.json));return ct(g).to_hex()}},u=A=>{var g;return{input:{outputIndex:A.index,txHash:A.hash},output:{address:e,amount:o(A.value,A.assets),dataHash:void 0,plutusData:((g=A.inline_datum)==null?void 0:g.value_raw)??void 0,scriptRef:c(A.reference_script)}}};try{return await n()}catch{return[]}}async fetchAssetAddresses(e){const t=a=>({address:a.address,quantity:a.quantity.toString()}),r=async(a="",n=[])=>{var g;const{policyId:o,assetName:c}=z(e),{data:u,status:A}=await this._axiosInstance.get(`assets/${o}${c}/addresses?size=100&cursor=${a}`);if(A===200)return u.cursor!==null&&((g=u.cursor)==null?void 0:g.length)>0?r(u.cursor,[...n,...u.data.map(t)]):u.data.map(t);throw d(u)};try{return await r()}catch{return[]}}async fetchAssetMetadata(e){var t;try{const{policyId:r,assetName:a}=z(e),{data:n,status:o}=await this._axiosInstance.get(`assets/${r}${a}`);if(o===200)return{...(t=n.metadata.find(c=>c.label===721))==null?void 0:t.json[r][Ot(a)]};throw d(n)}catch(r){throw d(r)}}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_no,epochSlot:t.epoch_slot_no.toString(),fees:t.fees.toString(),hash:t.hash,nextBlock:t.next_block.toString()??"",operationalCertificate:t.op_cert,output:t.out_sum.toString()??"0",previousBlock:t.previous_block.toString(),size:t.size,slot:t.slot_no.toString(),slotLeader:t.slot_leader??"",time:Date.parse(t.time),txCount:t.tx_count,VRFKey:t.vrf_key};throw d(t)}catch(t){throw d(t)}}async fetchCollectionAssets(e,t=""){try{const{data:r,status:a}=await this._axiosInstance.get(`policies/${e}/assets?size=100&cursor=${t}`);if(a===200)return{assets:r.data.map(n=>({unit:`${n.policy_id}${n.asset_name}`,quantity:n.quantity})),next:r.cursor};throw d(r)}catch{return{assets:[],next:null}}}async fetchHandleAddress(e){try{const t=Q(e.replace("$","")),{data:r,status:a}=await this._axiosInstance.get(`assets/${Pt[1]}${t}/addresses`);if(a===200)return r.data[0].address;throw d(r)}catch(t){throw d(t)}}async fetchProtocolParameters(e){try{const{data:t,status:r}=await this._axiosInstance.get(`epochs/${e}/parameters`);if(r===200)return{coinsPerUTxOSize:t.coins_per_utxo_size.toString(),collateralPercent:t.collateral_percent,decentralisation:t.decentralisation,epoch:t.epoch_no,keyDeposit:t.key_deposit.toString(),maxBlockExMem:t.max_block_ex_mem.toString(),maxBlockExSteps:t.max_block_ex_steps.toString(),maxBlockHeaderSize:t.max_block_header_size,maxBlockSize:t.max_block_size,maxCollateralInputs:t.max_collateral_inputs,maxTxExMem:t.max_tx_ex_mem.toString(),maxTxExSteps:t.max_tx_ex_steps.toString(),maxTxSize:t.max_tx_size,maxValSize:t.max_val_size.toString(),minFeeA:t.min_fee_a,minFeeB:t.min_fee_b,minPoolCost:t.min_pool_cost.toString(),poolDeposit:t.pool_deposit.toString(),priceMem:t.price_mem,priceStep:t.price_step};throw d(t)}catch(t){throw d(t)}}async fetchTxInfo(e){try{const{data:t,status:r}=await this._axiosInstance.get(`transactions/${e}`);if(r===200)return{block:t.block.hash,deposit:t.deposit,fees:t.fee,hash:t.hash,index:t.block_index,invalidAfter:t.invalid_hereafter??"",invalidBefore:t.invalid_before??"",slot:t.block.slot_no.toString(),size:t.size};throw d(t)}catch(t){throw d(t)}}onTxConfirmed(e,t,r=100){let a=0;const n=setInterval(()=>{a>=r&&clearInterval(n),this.fetchTxInfo(e).then(o=>{this.fetchBlockInfo(o.block).then(c=>{(c==null?void 0:c.confirmations)>0&&(clearInterval(n),t())}).catch(()=>{a+=1})}).catch(()=>{a+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/json"},{data:r,status:a}=await this._axiosInstance.post("transactions/submit",{tx:e},{headers:t});if(a===200)return r.tx_id;throw d(r)}catch(t){throw d(t)}}}class ur{_axiosInstance;submitUrl;constructor({network:e,apiKey:t,turboSubmit:r=!1}){this._axiosInstance=G.default.create({baseURL:`https://${e}.gomaestro-api.org/v1`,headers:{"api-key":t}}),this.submitUrl=r?"txmanager":"txmanager/turbosubmit"}async fetchAccountInfo(e){const t=e.startsWith("addr")?ht(e):e;try{const{data:r,status:a}=await this._axiosInstance.get(`accounts/${t}`);if(a===200){const n=r.data;return{poolId:n.delegated_pool,active:n.registered,balance:n.total_balance.toString(),rewards:n.rewards_available.toString(),withdrawals:n.total_withdrawn.toString()}}throw d(r)}catch(r){throw d(r)}}async fetchAddressUTxOs(e,t){const r=(()=>e.startsWith("addr_vkh")||e.startsWith("addr_shared_vkh")?`addresses/cred/${e}`:`addresses/${e}`)(),a=t?`&asset=${t}`:"",n=u=>{if(u.reference_script){const A=u.reference_script.type==="native"?u.reference_script.json:{code:u.reference_script.bytes,version:u.reference_script.type.replace("plutusv","V")};return ct(A).to_hex()}else return},o=async(u=null,A=[])=>{const g=u===null?"":`&cursor=${u}`,{data:l,status:I}=await this._axiosInstance.get(`${r}/utxos?count=100${a}${g}`);if(I===200){const C=l.data.map(c),v=[...A,...C],U=l.next_cursor;return U==null?v:o(U,v)}throw d(l)},c=u=>{var A,g;return{input:{outputIndex:u.index,txHash:u.tx_hash},output:{address:e,amount:u.assets.map(l=>({unit:l.unit,quantity:l.amount.toString()})),dataHash:(A=u.datum)==null?void 0:A.hash,plutusData:(g=u.datum)==null?void 0:g.bytes,scriptRef:n(u)}}};try{return await o()}catch{return[]}}async fetchAssetAddresses(e){const{policyId:t,assetName:r}=z(e),a=async(n=null,o=[])=>{const c=n===null?"":`&cursor=${n}`,{data:u,status:A}=await this._axiosInstance.get(`assets/${t}${r}/addresses?count=100${c}`);if(A===200){const l=u.data.map(C=>({address:C.address,quantity:C.amount.toString()})),I=u.next_cursor,_=[...o,...l];return I==null?_:a(I,_)}throw d(u)};try{return await a()}catch{return[]}}async fetchAssetMetadata(e){try{const{policyId:t,assetName:r}=z(e),{data:a,status:n}=await this._axiosInstance.get(`assets/${t}${r}`);if(n===200){const o=a.data;return{...o.asset_standards.cip25_metadata,...o.asset_standards.cip68_metadata}}throw d(a)}catch(t){throw d(t)}}async fetchBlockInfo(e){var t;try{const{data:r,status:a}=await this._axiosInstance.get(`blocks/${e}`);if(a===200){const n=r.data;return{confirmations:n.confirmations,epoch:n.epoch,epochSlot:n.epoch_slot.toString(),fees:n.total_fees.toString(),hash:n.hash,nextBlock:n.next_block??"",operationalCertificate:(t=n.operational_certificate)==null?void 0:t.hot_vkey,output:n.total_output_lovelace??"0",previousBlock:n.previous_block,size:n.size,slot:n.absolute_slot.toString(),slotLeader:n.block_producer??"",time:Date.parse(n.timestamp)/1e3,txCount:n.tx_hashes.length,VRFKey:i.VRFVKey.from_hex(n.vrf_key).to_bech32("vrf_vk")}}throw d(r)}catch(r){throw d(r)}}async fetchCollectionAssets(e,t){try{const{data:r,status:a}=await this._axiosInstance.get(`assets/policy/${e}?count=100${t?`&cursor=${t}`:""}`);if(console.log(r),a===200)return{assets:r.data.map(o=>({unit:e+o.asset_name,quantity:o.total_supply.toString()})),next:r.next_cursor};throw d(r)}catch{return{assets:[],next:null}}}async fetchHandleAddress(e){try{const t=e.charAt(0)==="$"?e.substring(1):e,{data:r,status:a}=await this._axiosInstance.get(`ecosystem/adahandle/${t}`);if(a===200)return r.data;throw d(r)}catch(t){throw d(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 a=r.indexOf("/");return parseInt(r.slice(0,a))/parseInt(r.slice(a+1))};try{const{data:r,status:a}=await this._axiosInstance.get("protocol-params");if(a===200){const n=r.data;try{const{data:o,status:c}=await this._axiosInstance.get("epochs/current");if(c===200){const u=o.data;return{coinsPerUTxOSize:n.coins_per_utxo_byte.toString(),collateralPercent:parseInt(n.collateral_percentage),decentralisation:0,epoch:parseInt(u.epoch_no),keyDeposit:n.stake_key_deposit.toString(),maxBlockExMem:n.max_execution_units_per_block.memory.toString(),maxBlockExSteps:n.max_execution_units_per_block.steps.toString(),maxBlockHeaderSize:parseInt(n.max_block_header_size),maxBlockSize:parseInt(n.max_block_body_size),maxCollateralInputs:parseInt(n.max_collateral_inputs),maxTxExMem:n.max_execution_units_per_transaction.memory.toString(),maxTxExSteps:n.max_execution_units_per_transaction.steps.toString(),maxTxSize:parseInt(n.max_tx_size),maxValSize:n.max_value_size.toString(),minFeeA:n.min_fee_coefficient,minFeeB:n.min_fee_constant,minPoolCost:n.min_pool_cost.toString(),poolDeposit:n.pool_deposit.toString(),priceMem:t(n.prices.memory),priceStep:t(n.prices.steps)}}throw d(o)}catch(o){throw d(o)}}throw d(r)}catch(r){throw d(r)}}async fetchTxInfo(e){try{const{data:t,status:r}=await this._axiosInstance.get(`transactions/${e}`);if(r===200){const a=t.data;return{block:a.block_hash,deposit:a.deposit.toString(),fees:a.fee.toString(),hash:a.tx_hash,index:a.block_tx_index,invalidAfter:a.invalid_hereafter??"",invalidBefore:a.invalid_before??"",slot:a.block_absolute_slot.toString(),size:a.size-1}}throw d(t)}catch(t){throw d(t)}}onTxConfirmed(e,t,r=100){let a=0;const n=setInterval(()=>{a>=r&&clearInterval(n),this.fetchTxInfo(e).then(o=>{this.fetchBlockInfo(o.block).then(c=>{(c==null?void 0:c.confirmations)>0&&(clearInterval(n),t())}).catch(()=>{a+=1})}).catch(()=>{a+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/cbor"},{data:r,status:a}=await this._axiosInstance.post(this.submitUrl,m(e),{headers:t});if(a===202)return r;throw d(r)}catch(t){throw d(t)}}}class Ar{static withOneSignature(e){const t=M(Z(e));return ft(t).to_hex()}static withAtLeastNSignatures(e,t){const r=i.NativeScripts.new();e.forEach(n=>{const o=M(Z(n));r.add(ft(o))});const a=i.ScriptNOfK.new(t,r);return i.NativeScript.new_script_any(a).to_hex()}static withAnySignature(e){const t=i.NativeScripts.new();e.forEach(a=>{const n=M(Z(a));t.add(ft(n))});const r=i.ScriptAny.new(t);return i.NativeScript.new_script_any(r).to_hex()}static withAllSignatures(e){const t=i.NativeScripts.new();e.forEach(a=>{const n=M(Z(a));t.add(ft(n))});const r=i.ScriptAll.new(t);return i.NativeScript.new_script_any(r).to_hex()}static fromNativeScript(e){return Dt(e).to_hex()}}function X(s,e,t,r){var a=arguments.length,n=a<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(s,e,t,r);else for(var c=s.length-1;c>=0;c--)(o=s[c])&&(n=(a<3?o(n):a>3?o(e,t,n):o(e,t))||n);return a>3&&n&&Object.defineProperty(e,t,n),n}const dr=s=>class extends s{__visits=[]},et=()=>function(s,e,t){const r=t.value;t.value=function(...a){const n=r.call(this,...a);return this.__visits&&this.__visits.push(e),n}};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=i.MintBuilder.new(),this._protocolParameters=e.parameters??R,this._txBuilder=Ls(e.parameters),this._txCertificates=i.Certificates.new(),this._txInputsBuilder=i.TxInputsBuilder.new(),this._txWithdrawals=i.Withdrawals.new()}static maskMetadata(e,t="BABBAGE"){var n;const r=L(e),a=(n=r.auxiliary_data())==null?void 0:n.metadata();if(a!==void 0){const o=i.GeneralTransactionMetadata.new();for(let u=0;u<a.len();u+=1){const A=a.keys().get(u),g=a.get(A);o.insert(A,i.TransactionMetadatum.from_hex("0".repeat(((g==null?void 0:g.to_hex())??"").length)))}const c=r.auxiliary_data();return c!==void 0&&(c.set_metadata(o),c.set_prefer_alonzo_format(t==="ALONZO")),i.Transaction.new(r.body(),r.witness_set(),c).to_hex()}return e}static readMetadata(e){var r,a;return((a=(r=L(e).auxiliary_data())==null?void 0:r.metadata())==null?void 0:a.to_hex())??""}static writeMetadata(e,t,r="BABBAGE"){const a=L(e),n=a.auxiliary_data()??i.AuxiliaryData.new();return n.set_metadata(i.GeneralTransactionMetadata.from_hex(t)),n.set_prefer_alonzo_format(r==="ALONZO"),i.Transaction.new(a.body(),a.witness_set(),n).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 a=this._totalBurns.has(t.unit)?i.BigNum.from_str(this._totalBurns.get(t.unit)??"0").checked_add(i.BigNum.from_str(t.quantity)).to_str():t.quantity;return this._mintBuilder.add_asset(Ie(e,r),i.AssetName.new(m(t.unit.slice(H))),i.Int.new_negative(i.BigNum.from_str(t.quantity))),this._totalBurns.set(t.unit,a),this}delegateStake(e,t){const r=i.Certificate.new_stake_delegation(i.StakeDelegation.new(i.StakeCredential.from_keyhash(M(rt(e))),i.Ed25519KeyHash.from_bech32(t)));return this._txCertificates.add(r),this}deregisterStake(e){const t=i.Certificate.new_stake_deregistration(i.StakeDeregistration.new(i.StakeCredential.from_keyhash(M(rt(e)))));return this._txCertificates.add(t),this}mintAsset(e,t,r){var A,g;const a=(l,I)=>{const _=typeof l=="string"?bt(l).hash().to_hex():n(l).hash().to_hex(),C=Q(I.assetName);return{unit:`${_}${C}`,quantity:I.assetQuantity}},n=l=>{if("code"in l)return ot(l.code,l.version);const I=F(l);if(I.output().has_script_ref()){const _=I.output().script_ref();if(_.is_plutus_script()){const C=Fe(_);return ot(C.code,C.version)}}throw new Error(`No plutus script reference found in UTxO: ${I.input().transaction_id().to_hex()}`)},o=a(e,t),u=i.BigNum.from_str(((A=this._totalMints.get(o.unit))==null?void 0:A.assetQuantity)??"0").checked_add(i.BigNum.from_str(o.quantity));return this._mintBuilder.add_asset(Ie(e,r),i.AssetName.new(m(Q(t.assetName))),i.Int.new(i.BigNum.from_str(o.quantity))),this._recipients.has(t.recipient)?(g=this._recipients.get(t.recipient))==null||g.push(o):this._recipients.set(t.recipient,[o]),this._totalMints.set(o.unit,{...t,assetQuantity:u.to_str()}),this}redeemValue(e){const t={tag:"SPEND",budget:_e,index:this._txInputsBuilder.inputs().len(),data:{alternative:0,fields:[]},...e.redeemer},r=F(e.value),a=i.PlutusWitness.new_with_ref(Oe(e.script),qs(e.datum),Te(t));return this._txInputsBuilder.add_plutus_script_input(a,r.input(),r.output().amount()),this}registerStake(e){const t=i.Certificate.new_stake_registration(i.StakeRegistration.new(i.StakeCredential.from_keyhash(M(rt(e)))));return this._txCertificates.add(t),this}registerPool(e){const t=i.Certificate.new_pool_registration(i.PoolRegistration.new(Vs(e)));return this._txCertificates.add(t),this}retirePool(e,t){const r=i.Certificate.new_pool_retirement(i.PoolRetirement.new(i.Ed25519KeyHash.from_bech32(e),t));return this._txCertificates.add(r),this}sendAssets(e,t){const r=wt(t),a=r.multiasset();if(r.is_zero()||a===void 0)return this;const n=_t(e).next(),o=r.coin().is_zero()?n.with_asset_and_min_required_coin_by_utxo_cost(a,ge(this._protocolParameters.coinsPerUTxOSize)).build():n.with_coin_and_asset(r.coin(),a).build();return t.forEach(c=>{this.setTxOutput(c)}),this._txBuilder.add_output(o),this}sendLovelace(e,t){const a=_t(e).next().with_coin(i.BigNum.from_str(t)).build();return this.setTxOutput({unit:"lovelace",quantity:t}),this._txBuilder.add_output(a),this}sendToken(e,t,r){return this.sendAssets(e,[{quantity:r,unit:Ze[t]}]),this}sendValue(e,t){const r=wt(t.output.amount),n=_t(e).next().with_value(r).build();return t.output.amount.forEach(o=>{this.setTxOutput(o)}),this._txBuilder.add_output(n),this}setChangeAddress(e){return this._changeAddress=O(e),this}setCollateral(e){const t=me(e);return this._txBuilder.set_collateral(t),this}setMetadata(e,t){return this._txBuilder.add_json_metadatum_with_schema(i.BigNum.from_str(e.toString()),JSON.stringify(t),i.MetadataJsonSchema.NoConversions),this}setRequiredSigners(e){return Array.from(new Set(e.map(r=>r.startsWith("addr")?Z(r):rt(r)).map(r=>M(r)))).forEach(r=>{this._txBuilder.add_required_signer(r)}),this}setTimeToStart(e){return this._txBuilder.set_validity_start_interval_bignum(i.BigNum.from_str(e)),this}setTimeToExpire(e){return this._txBuilder.set_ttl_bignum(i.BigNum.from_str(e)),this}setTxInputs(e){return e.map(t=>F(t)).forEach(t=>{this._txInputsBuilder.add_input(t.output().address(),t.input(),t.output().amount())}),this}setTxRefInputs(e){return e.map(t=>F(t)).forEach(t=>{this._txBuilder.add_reference_input(t.input())}),this}withdrawRewards(e,t){const r=Pe(e);return r!==void 0&&this._txWithdrawals.insert(r,i.BigNum.from_str(t)),this}async addBurnInputsIfNeeded(){if(this._initiator&&this._totalBurns.size>0&&this.notVisited("setTxInputs")){const e=await this._initiator.getUsedUTxOs();Ce(this._totalBurns,e.map(r=>St(r))).map(r=>F(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(me(e))}}async addRequiredSignersIfNeeded(){if(this._initiator&&this.notVisited("setRequiredSigners")){const e=await this._initiator.getUsedAddress(),t=Z(e.to_bech32());this._txBuilder.add_required_signer(M(t))}}async addTxInputsAsNeeded(){if(this.notVisited("setTxInputs")){const e=await this.filterAvailableUTxOs();ye(this._txOutputs,e.map(r=>St(r))).map(r=>F(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?$t[this._era]:$t.BABBAGE;this._txBuilder.calc_script_data_hash(e)}}async forgeAssetsIfNeeded(){const e=(t,r)=>{const a=t.data.assetName,n=t.data.metadata,o=t.unit.slice(0,H);if(t.data.label==="777")return n;if(r&&r[o]){const{[o]:c,...u}=r,A={[a]:n,...c};return{[o]:{...A},...u}}return r!==void 0?{[o]:{[a]:n},...r}:{[o]:{[a]:n}}};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(i.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(a=>a.input.txHash===r.input().transaction_id().to_hex())===void 0)}addMintOutputs(){this._recipients.forEach((e,t)=>{const a=wt(e).multiasset();if(a!==void 0){const o=_t(t).next().with_asset_and_min_required_coin_by_utxo_cost(a,ge(this._protocolParameters.coinsPerUTxOSize)).build();this._txBuilder.add_output(o)}})}notVisited(e){return this.__visits.includes(e)===!1}setTxOutput(e){const r=i.BigNum.from_str(this._txOutputs.get(e.unit)??"0").checked_add(i.BigNum.from_str(e.quantity)).to_str();this._txOutputs.set(e.unit,r)}};X([et()],exports.Transaction.prototype,"mintAsset",null);X([et()],exports.Transaction.prototype,"redeemValue",null);X([et()],exports.Transaction.prototype,"sendAssets",null);X([et()],exports.Transaction.prototype,"sendValue",null);X([et()],exports.Transaction.prototype,"setCollateral",null);X([et()],exports.Transaction.prototype,"setRequiredSigners",null);X([et()],exports.Transaction.prototype,"setTxInputs",null);exports.Transaction=X([dr],exports.Transaction);class w{_networkId;_encryptedSecret;constructor(e,t){this._networkId=e,this._encryptedSecret=t}getAccount(e,t){return this.accountContext(e,t,(r,a)=>{const n=le(this._networkId,r.to_public().hash(),a.to_public().hash()).to_address().to_bech32(),o=he(this._networkId,r.to_public().hash()).to_address().to_bech32(),c=Nt(this._networkId,a.to_public().hash()).to_address().to_bech32();return{baseAddress:n,enterpriseAddress:o,rewardAddress:c}})}signData(e,t,r,a){try{return this.accountContext(e,t,(n,o)=>{const c={payload:a},u={address:w.resolveAddress(this._networkId,r,n,o),key:r.startsWith("stake")?o:n},{coseSign1:A,coseKey:g}=is(c,u);return{signature:A,key:g}})}catch(n){throw new Error(`An error occurred during signData: ${n}.`)}}signTx(e,t,r,a,n){try{const o=Ke(Ye(a));return this.accountContext(e,t,(c,u)=>{const A=i.Vkeywitnesses.new();return w.resolveSigners(a,r,c.to_public().hash().to_hex()).forEach(l=>{if(l===c.to_public().hash().to_hex())A.add(i.make_vkey_witness(o,c));else if(l===u.to_public().hash().to_hex())A.add(i.make_vkey_witness(o,u));else if(n===!1)throw new Error(`Missing key witness for: ${l}`)}),A})}catch(o){throw new Error(`An error occurred during signTx: ${o}.`)}}static encryptMnemonic(e,t){const r=Kt.mnemonicToEntropy(e.join(" ")),a=He(r),n=D(a.as_bytes());return a.free(),w.encrypt(n,t)}static encryptPrivateKey(e,t){const r=i.Bip32PrivateKey.from_bech32(e),a=D(r.as_bytes());return r.free(),w.encrypt(a,t)}static encryptSigningKeys(e,t,r){const a=w.encrypt(e.slice(4),r),n=w.encrypt(t.slice(4),r);return[a,n]}static generateMnemonic(e=256){return Kt.generateMnemonic(e).split(" ")}accountContext(e,t,r){const{paymentKey:a,stakeKey:n}=w.resolveKeys(e,t,this._encryptedSecret),o=r(a,n);return a.free(),n.free(),o}static decrypt(e,t){try{return i.decrypt_with_password(Q(t),e)}catch{throw new Error("The password is incorrect.")}}static encrypt(e,t){const r=pe.customAlphabet("0123456789abcdef"),a=r(64),n=r(24);return i.encrypt_with_password(Q(t),a,n,e)}static resolveAddress(e,t,r,a){const n=[le(e,r.to_public().hash(),a.to_public().hash()),he(e,r.to_public().hash()),Nt(e,a.to_public().hash())].find(o=>o.to_address().to_bech32()===t);if(n!==void 0)return n.to_address();throw new Error(`Address: ${t} doesn't belong to this account.`)}static resolveKeys(e,t,r){if(typeof r=="string"){const o=w.decrypt(r,t);return Us(o,e)}const a=w.decrypt(r[0],t),n=w.decrypt(r[1],t);return{paymentKey:i.PrivateKey.from_hex(a),stakeKey:i.PrivateKey.from_hex(n)}}static resolveSigners(e,t,r){const a=c=>{const u=(p,S=[],x=0)=>{var It,ut,Yt,qt,Lt;if(p===void 0||x>=p.len())return S;const K=p.get(x),N=new Array;switch(K.kind()){case i.CertificateKind.StakeDeregistration:{const B=(It=K.as_stake_deregistration())==null?void 0:It.stake_credential(),Y=(B==null?void 0:B.kind())===i.StakeCredKind.Key?B.to_keyhash():void 0;Y&&N.push(Y.to_hex());break}case i.CertificateKind.StakeDelegation:{const B=(ut=K.as_stake_delegation())==null?void 0:ut.stake_credential(),Y=(B==null?void 0:B.kind())===i.StakeCredKind.Key?B.to_keyhash():void 0;Y&&N.push(Y.to_hex());break}case i.CertificateKind.PoolRegistration:{const B=(Yt=K.as_pool_registration())==null?void 0:Yt.pool_params().pool_owners();N.push(...g(B));break}case i.CertificateKind.PoolRetirement:{const B=(qt=K.as_pool_retirement())==null?void 0:qt.pool_keyhash();B&&N.push(B.to_hex());break}case i.CertificateKind.MoveInstantaneousRewardsCert:{const B=(Lt=K.as_move_instantaneous_rewards_cert())==null?void 0:Lt.move_instantaneous_reward().as_to_stake_creds();if(B)for(let Y=0;Y<B.len();Y+=1){const Gt=B.keys().get(Y),Rt=Gt.kind()===i.StakeCredKind.Key?Gt.to_keyhash():void 0;Rt&&N.push(Rt.to_hex())}break}}return u(p,[...S,...N],x+1)},A=(p,S=[],x=0)=>{if(p===void 0||x>=p.len())return S;const K=p.get(x).index(),N=p.get(x).transaction_id(),It=t.find(ut=>ut.input.outputIndex===K&&ut.input.txHash===N.to_hex())!==void 0?r:"OUR_PRINCESS_IS_IN_ANOTHER_CASTLE";return A(p,[...S,It],x+1)},g=(p,S=[],x=0)=>p===void 0||x>=p.len()?S:g(p,[...S,p.get(x).to_hex()],x+1),l=(p,S=[],x=0)=>{if(p===void 0||x>=p.len())return S;const K=p.keys().get(x).payment_cred(),N=K.kind()===i.StakeCredKind.Key?K.to_keyhash():void 0;return l(p,N?[...S,N.to_hex()]:S,x+1)},I=c.certs(),_=c.collateral(),C=c.inputs(),v=c.required_signers(),U=c.withdrawals();return[...u(I),...A(_),...A(C),...g(v),...l(U)]},n=c=>{const u=(g,l=[])=>{var I,_,C,v;if(g)for(let U=0;U<g.len();U+=1){const p=g.get(U);switch(p.kind()){case i.NativeScriptKind.ScriptPubkey:{const S=(I=p.as_script_pubkey())==null?void 0:I.addr_keyhash().to_hex();return S?[...l,S]:l}case i.NativeScriptKind.ScriptAll:return u((_=p.as_script_all())==null?void 0:_.native_scripts(),l);case i.NativeScriptKind.ScriptAny:return u((C=p.as_script_any())==null?void 0:C.native_scripts(),l);case i.NativeScriptKind.ScriptNOfK:return u((v=p.as_script_n_of_k())==null?void 0:v.native_scripts(),l)}}return l},A=c.native_scripts();return[...u(A)]},o=L(e);return new Set([...a(o.body()),...n(o.witness_set())])}}const P="MARI0TIME";class lr{_fetcher;_submitter;_wallet;constructor(e){switch(this._fetcher=e.fetcher,this._submitter=e.submitter,e.key.type){case"mnemonic":this._wallet=new w(e.networkId,w.encryptMnemonic(e.key.words,P));break;case"root":this._wallet=new w(e.networkId,w.encryptPrivateKey(e.key.bech32,P));break;case"cli":this._wallet=new w(e.networkId,w.encryptSigningKeys(e.key.payment,e.key.stake??"f0".repeat(34),P))}}getBaseAddress(e=0){return this._wallet.getAccount(e,P).baseAddress}getPaymentAddress(e=0){return this._wallet.getAccount(e,P).enterpriseAddress}getRewardAddress(e=0){return this._wallet.getAccount(e,P).rewardAddress}getUsedAddress(e=0){const t=this._wallet.getAccount(e,P);return O(t.enterpriseAddress)}getUsedCollateral(e=R.maxCollateralInputs){throw new Error("getUsedCollateral not implemented.")}async getUsedUTxOs(e=0){const t=this._wallet.getAccount(e,P);return(await this._fetcher.fetchAddressUTxOs(t.enterpriseAddress)).map(a=>F(a))}signData(e,t,r=0){try{return this._wallet.signData(r,P,e,t)}catch(a){throw new Error(`[AppWallet] An error occurred during signData: ${a}.`)}}async signTx(e,t=!1,r=0){try{const a=this._wallet.getAccount(r,P),n=await this._fetcher.fetchAddressUTxOs(a.enterpriseAddress),o=this._wallet.signTx(r,P,n,e,t),c=L(e),u=c.witness_set(),A=qe(u,o);return u.set_vkeys(A),i.Transaction.new(c.body(),u,c.auxiliary_data()).to_hex()}catch(a){throw new Error(`[AppWallet] An error occurred during signTx: ${a}.`)}}submitTx(e){return this._submitter.submitTx(e)}static brew(e=256){return w.generateMnemonic(e)}}class Qt{_walletInstance;constructor(e){this._walletInstance=e}static getInstalledWallets(){return window.cardano===void 0?[]:zt.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 Qt.resolveInstance(e);if(t!==void 0)return new Qt(t);throw new Error(`Couldn't create an instance of wallet: ${e}`)}catch(t){throw new Error(`[BrowserWallet] An error occurred during enable: ${t}.`)}}async getBalance(){const e=await this._walletInstance.getBalance();return Me(Os(e))}async getChangeAddress(){const e=await this._walletInstance.getChangeAddress();return st(e).to_bech32()}async getCollateral(e=R.maxCollateralInputs){return(await this.getUsedCollateral(e)).map(r=>St(r))}getNetworkId(){return this._walletInstance.getNetworkId()}async getRewardAddresses(){return(await this._walletInstance.getRewardAddresses()).map(t=>st(t).to_bech32())}async getUnusedAddresses(){return(await this._walletInstance.getUnusedAddresses()).map(t=>st(t).to_bech32())}async getUsedAddresses(){return(await this._walletInstance.getUsedAddresses()).map(t=>st(t).to_bech32())}async getUtxos(){return(await this.getUsedUTxOs()).map(t=>St(t))}signData(e,t){const r=O(e).to_hex();return this._walletInstance.signData(r,Q(t))}async signTx(e,t=!1){try{const r=L(e),a=r.witness_set(),n=await this._walletInstance.signTx(e,t),o=Hs(n).vkeys()??i.Vkeywitnesses.new(),c=qe(a,o);return a.set_vkeys(c),D(i.Transaction.new(r.body(),a,r.auxiliary_data()).to_bytes())}catch(r){throw new Error(`[BrowserWallet] An error occurred during signTx: ${JSON.stringify(r)}.`)}}submitTx(e){return this._walletInstance.submitTx(e)}async getUsedAddress(){const e=await this._walletInstance.getUsedAddresses();return st(e[0])}async getUsedCollateral(e=R.maxCollateralInputs){return(await this._walletInstance.experimental.getCollateral()??[]).map(r=>Ae(r)).slice(0,e)}async getUsedUTxOs(){return(await this._walletInstance.getUtxos()??[]).map(t=>Ae(t))}async getAssets(){return(await this.getBalance()).filter(t=>t.unit!=="lovelace").map(t=>{const r=t.unit.slice(0,H),a=t.unit.slice(H),n=Ve(r,a);return{unit:t.unit,policyId:r,assetName:Ot(a),fingerprint:n,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,H)))).filter(t=>t!=="lovelace")}static resolveInstance(e){if(window.cardano===void 0)return;const t=zt.map(r=>window.cardano[r]).filter(r=>r!==void 0).find(r=>r.name.toLowerCase()===e.toLowerCase());return t==null?void 0:t.enable()}}const Le="http://localhost:4000/",gr="http://localhost:5000/",hr=`${Le}access`,Ir=`${Le}transaction/signtx`;class mr{static getAxiosInstance(){return G.default.create({baseURL:gr,withCredentials:!0})}static getAppId(){return window.location.hostname}static async openMinaFrontend(e){const t=this.getAppId();e.includes("?")?e=`${e}&appId=${t}`:e=`${e}?appId=${t}`;const r="left=100,top=100,width=540,height=540",a=window.open(e,"meshWindow",r);return a||console.error("the window did not open",a),await(async()=>new Promise(n=>{window.addEventListener("message",async o=>{o.data.target=="minaWallet"&&n(o.data)})}))()}static async get(e,t={}){const r=this.getAppId();t={...t,appId:r};try{return(await this.getAxiosInstance().get(e,{params:t})).data}catch{console.error("Not logged in");return}}static async enable(){return await this.get("wallet/getuserwalletsmeta")===void 0?await this.openMinaFrontend(hr):!0}static async getChangeAddress(e=void 0,t=void 0){return await this.get("wallet/getchangeaddress",{walletId:e,accountIndex:t})}static async getUtxos(e=void 0,t=void 0){return await this.get("wallet/getutxo",{walletId:e,accountIndex:t})}static async signTx(e,t=!1){const r=await this.get("wallet/getuserwalletsmeta");if(console.log("userWalletsMeta",r),r){const a=await this.openMinaFrontend(`${Ir}?unsignedTx=${e}&partialSign=${t}`);if(a instanceof i.Vkeywitnesses){const n=L(e),o=n.witness_set();o.set_vkeys(a);const c=i.Transaction.new(n.body(),o,n.auxiliary_data()).to_hex();return console.log("signedTx",c),c}}else return}}exports.AppWallet=lr;exports.BlockfrostProvider=ar;exports.BrowserWallet=Qt;exports.EmbeddedWallet=w;exports.ForgeScript=Ar;exports.InfuraProvider=nr;exports.KoiosProvider=ir;exports.MaestroProvider=ur;exports.MinaWallet=mr;exports.OgmiosProvider=or;exports.TangoProvider=cr;exports.checkSignature=os;exports.generateNonce=er;exports.isNetwork=fe;exports.keepRelevant=ye;exports.largestFirst=ts;exports.largestFirstMultiAsset=Ce;exports.parseAssetUnit=z;exports.parseHttpError=d;exports.readPlutusData=sr;exports.readTransaction=rr;exports.resolveDataHash=Gs;exports.resolveEpochNo=Rs;exports.resolveFingerprint=Ve;exports.resolveLanguageView=$s;exports.resolveNativeScriptHash=zs;exports.resolvePaymentKeyHash=Z;exports.resolvePlutusScriptAddress=Ws;exports.resolvePlutusScriptHash=Js;exports.resolvePoolId=js;exports.resolvePrivateKey=Xs;exports.resolveRewardAddress=ht;exports.resolveScriptRef=Zs;exports.resolveSlotNo=tr;exports.resolveStakeKeyHash=rt;exports.resolveTxFees=Vt;exports.resolveTxHash=Ye;