/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@meshsdk/common@1.9.0-beta.102/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
var DEFAULT_PROTOCOL_PARAMETERS={epoch:0,coinsPerUtxoSize:4310,priceMem:.0577,priceStep:721e-7,minFeeA:44,minFeeB:155381,keyDeposit:2e6,maxTxSize:16384,maxValSize:5e3,poolDeposit:5e8,maxCollateralInputs:3,decentralisation:0,maxBlockSize:98304,collateralPercent:150,maxBlockHeaderSize:1100,minPoolCost:"340000000",maxTxExMem:"16000000",maxTxExSteps:"10000000000",maxBlockExMem:"80000000",maxBlockExSteps:"40000000000",minFeeRefScriptCostPerByte:15},DREP_DEPOSIT="500000000",VOTING_PROPOSAL_DEPOSIT="100000000000",resolveTxFees=(e,t=DEFAULT_PROTOCOL_PARAMETERS.minFeeA,a=DEFAULT_PROTOCOL_PARAMETERS.minFeeB)=>(BigInt(t)*BigInt(e)+BigInt(a)).toString(),SUPPORTED_WALLETS=["begin","eternl","flint","lace","nami","nufi","gerowallet","typhoncip30","vespr","yoroi"],DEFAULT_V1_COST_MODEL_LIST=[100788,420,1,1,1e3,173,0,1,1e3,59957,4,1,11183,32,201305,8356,4,16e3,100,16e3,100,16e3,100,16e3,100,16e3,100,16e3,100,100,100,16e3,100,94375,32,132994,32,61462,4,72010,178,0,1,22151,32,91189,769,4,2,85848,228465,122,0,1,1,1e3,42921,4,2,24548,29498,38,1,898148,27279,1,51775,558,1,39184,1e3,60594,1,141895,32,83150,32,15299,32,76049,1,13169,4,22100,10,28999,74,1,28999,74,1,43285,552,1,44749,541,1,33852,32,68246,32,72362,32,7243,32,7391,32,11546,32,85848,228465,122,0,1,1,90434,519,0,1,74433,32,85848,228465,122,0,1,1,85848,228465,122,0,1,1,270652,22588,4,1457325,64566,4,20467,1,4,0,141992,32,100788,420,1,1,81663,32,59498,32,20142,32,24588,32,20744,32,25933,32,24623,32,53384111,14333,10],DEFAULT_V2_COST_MODEL_LIST=[100788,420,1,1,1e3,173,0,1,1e3,59957,4,1,11183,32,201305,8356,4,16e3,100,16e3,100,16e3,100,16e3,100,16e3,100,16e3,100,100,100,16e3,100,94375,32,132994,32,61462,4,72010,178,0,1,22151,32,91189,769,4,2,85848,228465,122,0,1,1,1e3,42921,4,2,24548,29498,38,1,898148,27279,1,51775,558,1,39184,1e3,60594,1,141895,32,83150,32,15299,32,76049,1,13169,4,22100,10,28999,74,1,28999,74,1,43285,552,1,44749,541,1,33852,32,68246,32,72362,32,7243,32,7391,32,11546,32,85848,228465,122,0,1,1,90434,519,0,1,74433,32,85848,228465,122,0,1,1,85848,228465,122,0,1,1,955506,213312,0,2,270652,22588,4,1457325,64566,4,20467,1,4,0,141992,32,100788,420,1,1,81663,32,59498,32,20142,32,24588,32,20744,32,25933,32,24623,32,43053543,10,53384111,14333,10,43574283,26308,10],DEFAULT_V3_COST_MODEL_LIST=[100788,420,1,1,1e3,173,0,1,1e3,59957,4,1,11183,32,201305,8356,4,16e3,100,16e3,100,16e3,100,16e3,100,16e3,100,16e3,100,100,100,16e3,100,94375,32,132994,32,61462,4,72010,178,0,1,22151,32,91189,769,4,2,85848,123203,7305,-900,1716,549,57,85848,0,1,1,1e3,42921,4,2,24548,29498,38,1,898148,27279,1,51775,558,1,39184,1e3,60594,1,141895,32,83150,32,15299,32,76049,1,13169,4,22100,10,28999,74,1,28999,74,1,43285,552,1,44749,541,1,33852,32,68246,32,72362,32,7243,32,7391,32,11546,32,85848,123203,7305,-900,1716,549,57,85848,0,1,90434,519,0,1,74433,32,85848,123203,7305,-900,1716,549,57,85848,0,1,1,85848,123203,7305,-900,1716,549,57,85848,0,1,955506,213312,0,2,270652,22588,4,1457325,64566,4,20467,1,4,0,141992,32,100788,420,1,1,81663,32,59498,32,20142,32,24588,32,20744,32,25933,32,24623,32,43053543,10,53384111,14333,10,43574283,26308,10,16e3,100,16e3,100,962335,18,2780678,6,442008,1,52538055,3756,18,267929,18,76433006,8868,18,52948122,18,1995836,36,3227919,12,901022,1,166917843,4307,36,284546,36,158221314,26549,36,74698472,36,333849714,1,254006273,72,2174038,72,2261318,64571,4,207616,8310,4,1293828,28716,63,0,1,1006041,43623,251,0,1,100181,726,719,0,1,100181,726,719,0,1,100181,726,719,0,1,107878,680,0,1,95336,1,281145,18848,0,1,180194,159,1,1,158519,8942,0,1,159378,8813,0,1,107490,3298,1,106057,655,1,1964219,24520,3],SUPPORTED_LANGUAGE_VIEWS={ALONZO:{V1:"a141005901d59f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f704001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff"},BABBAGE:{V1:"a141005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff",V2:"a20198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c80041005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff"}},resolveLanguageView=(e,t)=>SUPPORTED_LANGUAGE_VIEWS[e][t],DEFAULT_REDEEMER_BUDGET={mem:7e6,steps:3e9},POLICY_ID_LENGTH=56,LANGUAGE_VERSIONS={V1:"V1",V2:"V2",V3:"V3"},HARDENED_KEY_START=2147483648,SUPPORTED_CLOCKS={testnet:["74","1598400","1595967616","432000"],preview:["183","15811222","1682467200","86400"],preprod:["65","26438400","1682121600","432000"],mainnet:["208","4492800","1596059091","432000"]},SUPPORTED_HANDLES={0:"8d18d786e92776c824607fd8e193ec535c79dc61ea2405ddf3b09fe3",1:"f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a"},SUPPORTED_OGMIOS_LINKS={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"},SUPPORTED_TOKENS={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"},CIP68_100=e=>`000643b0${e}`,CIP68_222=e=>`000de140${e}`,DEFAULT_FETCHER_OPTIONS={maxPage:20,order:"desc"},mergeAssets=e=>{const t=[];return e.forEach((e=>{const a=t.find((t=>t.unit===e.unit));a?a.quantity=(BigInt(a.quantity)+BigInt(e.quantity)).toString():t.push(e)})),t},royaltiesStandardKeys=["rate","address"],metadataStandardKeys=["name","image","mediaType","description","instagram","twitter","discord","website"],fungibleAssetKeys=["ticker","decimals"],metadataToCip68=e=>{if("object"==typeof e){if(e instanceof Array)return e.map((e=>metadataToCip68(e)));const t=new Map;return Object.keys(e).forEach((a=>{t.set(a,metadataToCip68(e[a]))})),{alternative:0,fields:[t,1]}}return e},ALL_NETWORKS=["testnet","preview","preprod","mainnet"],isNetwork=e=>ALL_NETWORKS.includes(e),castProtocol=e=>{const t={};for(const a in DEFAULT_PROTOCOL_PARAMETERS){const n=a,i=DEFAULT_PROTOCOL_PARAMETERS[n],s=e[n];"number"==typeof i?t[n]=s||0===s?Number(s):i:"string"==typeof i&&(t[n]=s||""===s?s.toString():i)}return t},txInToUtxo=e=>({input:{txHash:e.txHash,outputIndex:e.txIndex},output:{address:e.address||"",amount:e.amount||[]}}),emptyTxBuilderBody=()=>({inputs:[],outputs:[],fee:"0",extraInputs:[],collaterals:[],requiredSignatures:[],referenceInputs:[],mints:[],changeAddress:"",metadata:new Map,scriptMetadata:[],validityRange:{},certificates:[],withdrawals:[],votes:[],proposals:[],signingKey:[],chainedTxs:[],inputsForEvaluation:{},network:"mainnet",expectedNumberKeyWitnesses:0,expectedByronAddressWitnesses:[]});function cloneTxBuilderBody(e){const{extraInputs:t,...a}=e,n=structuredClone(a);return n.extraInputs=t,n}var validityRangeToObj=e=>({invalidBefore:e.invalidBefore??null,invalidHereafter:e.invalidHereafter??null}),validityRangeFromObj=e=>{const t={};return null!==e.invalidBefore&&void 0!==e.invalidBefore&&(t.invalidBefore=Number(e.invalidBefore)),null!==e.invalidHereafter&&void 0!==e.invalidHereafter&&(t.invalidHereafter=Number(e.invalidHereafter)),t},GovernanceActionKind=(e=>(e.ParameterChangeAction="ParameterChangeAction",e.HardForkInitiationAction="HardForkInitiationAction",e.TreasuryWithdrawalsAction="TreasuryWithdrawalsAction",e.NoConfidenceAction="NoConfidenceAction",e.UpdateCommitteeAction="UpdateCommitteeAction",e.NewConstitutionAction="NewConstitutionAction",e.InfoAction="InfoAction",e))(GovernanceActionKind||{}),mConStr=(e,t)=>({alternative:e,fields:t}),mConStr0=e=>({alternative:0,fields:e}),mConStr1=e=>({alternative:1,fields:e}),mConStr2=e=>({alternative:2,fields:e}),mConStr3=e=>({alternative:3,fields:e}),mAssetClass=(e,t)=>{if(56!==e.length&&""!==e)throw new Error(`Invalid policy id for [${e}] - should be ${POLICY_ID_LENGTH} bytes long or empty string for lovelace`);if(t.length>64)throw new Error(`Invalid asset name for [${t}] - should be less than 32 bytes (64 hex length) long`);return mConStr0([e,t])},mOutputReference=(e,t)=>{if(64!==e.length)throw new Error("Invalid transaction hash - should be 32 bytes long");return mConStr0([e,t])},mTxOutRef=(e,t)=>{if(64!==e.length)throw new Error("Invalid transaction hash - should be 32 bytes long");return mConStr0([mConStr0([e]),t])},mTuple=(...e)=>e,mOption=e=>e?mSome(e):mNone(),mSome=e=>mConStr0([e]),mNone=()=>mConStr1([]),mVerificationKey=e=>mConStr0([e]),mScript=e=>mConStr1([e]),mMaybeStakingHash=(e,t=!1)=>""===e?mConStr1([]):mConStr0(t?[mConStr0([mScript(e)])]:[mConStr0([mVerificationKey(e)])]),mPubKeyAddress=(e,t,a=!1)=>mConStr0([{alternative:0,fields:[e]},mMaybeStakingHash(t||"",a)]),mScriptAddress=(e,t,a=!1)=>mConStr0([{alternative:1,fields:[e]},mMaybeStakingHash(t||"",a)]),mCredential=(e,t=!1)=>t?mScript(e):mVerificationKey(e),mBool=e=>e?mConStr1([]):mConStr0([]),mStringToPlutusBSArray=e=>{const t=[];for(let a=0;a<e.length;a+=64){const n=e.substring(a,a+64);t.push(n)}return t},mPlutusBSArrayToString=e=>e.join(""),conStr=(e,t)=>{if(!Array.isArray(t))throw new Error("fields of a constructor must be an array");return{constructor:e,fields:t}},conStr0=e=>conStr(0,e),conStr1=e=>conStr(1,e),conStr2=e=>conStr(2,e),conStr3=e=>conStr(3,e),bool=e=>e?conStr1([]):conStr0([]),builtinByteString=e=>byteString(e),byteString=e=>{if(e.length%2!=0)throw new Error("Invalid hex string - odd length: "+e);if(!/^[0-9a-fA-F]*$/.test(e))throw new Error("Invalid hex string - non-hex string character: "+e);return{bytes:e}},integer=e=>({int:e}),list=(e,t=!0)=>(t&&e.forEach((e=>{if("object"!=typeof e)throw new Error("List item of JSON Cardano data type must be an object - "+e)})),{list:e}),stringToBSArray=e=>list((e=>{const t=[];for(let a=0;a<e.length;a+=64){const n=e.substring(a,a+64);t.push(n)}return t})(e).map(builtinByteString)),plutusBSArrayToString=e=>e.list.map((e=>e.bytes)).join(""),assocMap=(e,t=!0)=>({map:e.map((([e,a])=>{if(t&&("object"!=typeof e||"object"!=typeof a))throw new Error(`Map item of JSON Cardano data type must be an object - ${e}, ${a}`);return{k:e,v:a}}))}),pairs=(e,t=!0)=>({map:e.map((([e,a])=>{if(t&&("object"!=typeof e||"object"!=typeof a))throw new Error(`Map item of JSON Cardano data type must be an object - ${e}, ${a}`);return{k:e,v:a}}))}),hashByteString=e=>{if(56!==e.length)throw new Error(`Invalid hash for [${e}] - should be 28 bytes (56 hex length) long`);return byteString(e)},scriptHash=e=>hashByteString(e),pubKeyHash=e=>hashByteString(e),policyId=e=>{if(e.length!==POLICY_ID_LENGTH&&""!==e)throw new Error(`Invalid policy id for [${e}] - should be ${POLICY_ID_LENGTH/2} bytes (${POLICY_ID_LENGTH} hex length) long or empty string for lovelace`);return byteString(e)},currencySymbol=e=>policyId(e),assetName=e=>{if(e.length>64)throw new Error(`Invalid asset name for [${e}] - should be less than 32 bytes (64 hex length) long`);return byteString(e)},tokenName=e=>assetName(e),assetClass=(e,t)=>conStr0([currencySymbol(e),tokenName(t)]),outputReference=(e,t)=>{if(64!==e.length)throw new Error("Invalid transaction hash - should be 32 bytes long");return conStr0([byteString(e),integer(t)])},txOutRef=(e,t)=>{if(64!==e.length)throw new Error("Invalid transaction hash - should be 32 bytes long");return conStr0([conStr0([byteString(e)]),integer(t)])},posixTime=e=>({int:e}),dict=e=>({map:e.map((([e,t])=>({k:e,v:t})))}),tuple=(...e)=>({list:e}),option=e=>e?some(e):none(),some=e=>conStr0([e]),none=()=>conStr1([]),verificationKey=e=>conStr0([pubKeyHash(e)]),script=e=>conStr1([scriptHash(e)]),maybeStakingHash=(e,t=!1)=>""===e?conStr1([]):conStr0(t?[conStr0([script(e)])]:[conStr0([verificationKey(e)])]),pubKeyAddress=(e,t,a=!1)=>conStr0([conStr0([pubKeyHash(e)]),maybeStakingHash(t||"",a)]),scriptAddress=(e,t,a=!1)=>conStr0([script(e),maybeStakingHash(t||"",a)]),credential=(e,t=!1)=>t?script(e):verificationKey(e),jsonProofToPlutusData=e=>{const t=[];return e.forEach((e=>{const a=integer(e.skip);switch(e.type){case"branch":t.push(conStr0([a,byteString(e.neighbors.toString("hex"))]));break;case"fork":const{prefix:n,nibble:i,root:s}=e.neighbor,r=conStr0([integer(i),byteString(n.toString("hex")),byteString(s.toString("hex"))]);t.push(conStr1([a,r]));break;case"leaf":const{key:o,value:c}=e.neighbor;t.push(conStr2([a,byteString(o),byteString(c)]))}})),t},bytesToHex=e=>Buffer.from(e).toString("hex"),hexToBytes=e=>Buffer.from(e,"hex"),stringToHex=e=>Buffer.from(e,"utf8").toString("hex"),isHexString=e=>/^[0-9A-F]*$/i.test(e),hexToString=e=>Buffer.from(e,"hex").toString("utf8"),toBytes=e=>e.length%2==0&&/^[0-9A-F]*$/i.test(e)?Buffer.from(e,"hex"):Buffer.from(e,"utf-8"),fromUTF8=e=>e.length%2==0&&/^[0-9A-F]*$/i.test(e)?e:bytesToHex(Buffer.from(e,"utf-8")),toUTF8=e=>Buffer.from(e,"hex").toString("utf-8"),parseAssetUnit=e=>({policyId:e.slice(0,POLICY_ID_LENGTH),assetName:e.includes(".")?fromUTF8(e.split(".")[1]):e.slice(POLICY_ID_LENGTH)}),SLOT_CONFIG_NETWORK={mainnet:{zeroTime:1596059091e3,zeroSlot:4492800,slotLength:1e3,startEpoch:208,epochLength:432e3},preview:{zeroTime:1666656e6,zeroSlot:0,slotLength:1e3,startEpoch:0,epochLength:86400},preprod:{zeroTime:16557696e5,zeroSlot:86400,slotLength:1e3,startEpoch:4,epochLength:432e3},testnet:{zeroTime:0,zeroSlot:0,slotLength:0,startEpoch:0,epochLength:0}},slotToBeginUnixTime=(e,t)=>{const a=(e-t.zeroSlot)*t.slotLength;return t.zeroTime+a},unixTimeToEnclosingSlot=(e,t)=>{const a=e-t.zeroTime;return Math.floor(a/t.slotLength)+t.zeroSlot},resolveSlotNo=(e,t=Date.now())=>unixTimeToEnclosingSlot(t,SLOT_CONFIG_NETWORK[e]).toString(),resolveEpochNo=(e,t=Date.now())=>{const a=SLOT_CONFIG_NETWORK[e],n=(BigInt(t)-BigInt(a.zeroTime))/1000n/BigInt(a.epochLength)+BigInt(a.startEpoch);return Number(n)};import{bech32}from"bech32";import blake2b from"blake2b";var resolveFingerprint=(e,t)=>AssetFingerprint.fromParts(toBytes(e),toBytes(t)).fingerprint(),DATA="asset",AssetFingerprint=class e{hashBuf;constructor(e){this.hashBuf=e}static fromHash(t){return new e(t)}static fromParts(t,a){const n=blake2b(20).update(new Uint8Array([...t,...a])).digest("binary");return e.fromHash(n)}static fromBech32(t){const{prefix:a,words:n}=bech32.decode(t);if(a!==DATA)throw new Error("Invalid asset fingerprint");const i=Buffer.from(bech32.fromWords(n));return e.fromHash(i)}fingerprint(){const e=bech32.toWords(this.hashBuf);return bech32.encode(DATA,e)}hash(){return Buffer.from(this.hashBuf).toString("hex")}prefix(){return DATA}checksum(){return this.fingerprint().slice(-6)}},BigNum=class e{value;constructor(e){this.value=e?BigInt(e):BigInt(0)}static new(t){return new e(t||0)}divFloor(e){return this.value=this.value/e.value,this}checkedMul(e){return this.value*=e.value,this}checkedAdd(e){return this.value+=e.value,this}checkedSub(e){return this.value-=e.value,this}clampedSub(e){const t=this.value-e.value;return this.value=t<0n?0n:t,this}lessThan(e){return this.value<e.value}compare(e){return this.value===e.value?0:this.value<e.value?-1:1}toString(){return this.value.toString()}};import{blake2b as blake2b2}from"blakejs";var hashDrepAnchor=e=>{const t=blake2b2(JSON.stringify(e,null,2),void 0,32);return Buffer.from(t).toString("hex")};function getFile(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText}var compareByteOrder=(e,t)=>e<t?-1:e>t?1:0,value=e=>MeshValue.fromAssets(e).toJSON(),mValue=e=>MeshValue.fromAssets(e).toData(),MeshValue=class e{value;constructor(e={}){this.value=e}static sortValue=e=>({map:[...e.map].sort(((e,t)=>compareByteOrder(e.k.bytes,t.k.bytes))).map((e=>{const t=[...e.v.map].sort(((e,t)=>compareByteOrder(e.k.bytes,t.k.bytes)));return{k:e.k,v:{map:t}}}))});static fromAssets=t=>{const a=new e;return a.addAssets(t),a};static fromValue=t=>{const a=[];return t.map.forEach((e=>{const t=e.k.bytes;e.v.map.forEach((e=>{const n=e.k.bytes,i=e.v.int.toString(),s=t+n,r=""===s?"lovelace":s;a.push({unit:r,quantity:i})}))})),e.fromAssets(a)};addAsset=e=>{const t=BigInt(e.quantity),{unit:a}=e;return this.value[a]?this.value[a]+=t:this.value[a]=t,this};addAssets=e=>(e.forEach((e=>{this.addAsset(e)})),this);negateAsset=e=>{const{unit:t,quantity:a}=e,n=BigNum.new(this.value[t]);return n.clampedSub(BigNum.new(a)),n.value===BigInt(0)?delete this.value[t]:this.value[t]=n.value,this};negateAssets=e=>(e.forEach((e=>{this.negateAsset(e)})),this);get=e=>this.value[e]?BigInt(this.value[e]):BigInt(0);getPolicyAssets=e=>{const t=[];return Object.entries(this.value).forEach((([a,n])=>{a.startsWith(e)&&t.push({unit:a,quantity:n.toString()})})),t};units=()=>Object.keys(this.value);geq=e=>Object.keys(e.value).every((t=>this.geqUnit(t,e)));geqUnit=(e,t)=>void 0!==this.value[e]&&void 0!==t.value[e]&&BigInt(this.value[e])>=BigInt(t.value[e]);leq=e=>Object.keys(this.value).every((t=>this.leqUnit(t,e)));leqUnit=(e,t)=>void 0!==this.value[e]&&void 0!==t.value[e]&&BigInt(this.value[e])<=BigInt(t.value[e]);eq=e=>Object.keys(this.value).every((t=>this.eqUnit(t,e)));eqUnit=(e,t)=>void 0!==this.value[e]&&void 0!==t.value[e]&&BigInt(this.value[e])===BigInt(t.value[e]);isEmpty=()=>0===Object.keys(this.value).length;merge=e=>((Array.isArray(e)?e:[e]).forEach((e=>{Object.entries(e.value).forEach((([e,t])=>{this.value[e]=(void 0!==this.value[e]?BigInt(this.value[e]):BigInt(0))+BigInt(t)}))})),this);toAssets=()=>{const e=[];return Object.entries(this.value).forEach((([t,a])=>{e.push({unit:t,quantity:a.toString()})})),e};toData=()=>{const e=new Map;this.toAssets().forEach((t=>{const a=t.unit.replace("lovelace",""),n=a.slice(0,56)||"",i=a.slice(56)||"";e.has(n)||e.set(n,new Map);const s=e.get(n),r=s?.get(i);r?s.set(i,r+BigInt(t.quantity)):s.set(i,BigInt(t.quantity))}));const t=Array.from(e.keys()).sort(compareByteOrder),a=new Map;return t.forEach((t=>{const n=e.get(t),i=Array.from(n.keys()).sort(compareByteOrder),s=new Map;i.forEach((e=>{s.set(e,n.get(e))})),a.set(t,s)})),a};toJSON=()=>{const e=[],t={};this.toAssets().forEach((e=>{const a=e.unit.replace("lovelace",""),n=a.slice(0,56)||"",i=a.slice(56)||"";t[n]||(t[n]={}),t[n][i]?t[n][i]+=Number(e.quantity):t[n][i]=Number(e.quantity)}));return Object.keys(t).sort(compareByteOrder).forEach((a=>{const n=currencySymbol(a),i=Object.keys(t[a]).sort(compareByteOrder).map((e=>[tokenName(e),integer(t[a][e])])),s=assocMap(i);e.push([n,s])})),assocMap(e)}},experimentalSelectUtxos=(e,t,a)=>{const n=new Map(e);n.set("lovelace",String(Number(n.get("lovelace")||0)+Number(a)));const i=new Map;for(let e=0;e<t.length;e++)i.set(e,t[e]);const s=new Set,r=new Set,o=new Set,c=new Set,u=new Set,d=new Set;for(let e=0;e<t.length;e++)switch(t[e].output.amount.length){case 1:{const a=t[e].output.amount[0]?.quantity;if("5000000"==a||"10000000"==a){d.add(e);break}r.add(e);break}case 2:o.add(e);break;case 3:c.add(e);break;default:u.add(e)}const l=(e,t,a)=>{const r=i.get(e);if(!r)return;const o=getAssetAmount(r,t);if(Number(o)>0){s.add(e),a.delete(e);for(const e of r.output.amount)n.set(e.unit,String(Number(n.get(e.unit))-Number(e.quantity)))}};for(const e of n.keys())if("lovelace"!=e){for(const t of o){const a=n.get(e);if(!a||Number(a)<=0)break;l(t,e,o)}for(const t of c){const a=n.get(e);if(!a||Number(a)<=0)break;l(t,e,c)}for(const t of u){const a=n.get(e);if(!a||Number(a)<=0)break;l(t,e,u)}}for(const e of r){const t=n.get("lovelace");if(!t||Number(t)<=0)break;l(e,"lovelace",r)}for(const e of o){const t=n.get("lovelace");if(!t||Number(t)<=0)break;l(e,"lovelace",o)}for(const e of c){const t=n.get("lovelace");if(!t||Number(t)<=0)break;l(e,"lovelace",c)}for(const e of u){const t=n.get("lovelace");if(!t||Number(t)<=0)break;l(e,"lovelace",u)}for(const e of d){const t=n.get("lovelace");if(!t||Number(t)<=0)break;l(e,"lovelace",d)}for(const e of n.keys())if(Number(n.get(e))>0)return console.warn("Insufficient funds for",e),console.warn("Remaining quantity",Number(n.get(e))),[];const f=[];for(const e of s){const t=i.get(e);t&&f.push(t)}return f},getAssetAmount=(e,t)=>{for(const a of e.output.amount)if(a.unit==t)return a.quantity;return"0"},enoughValueHasBeenSelected=(e,t)=>Array.from(t,(e=>({unit:e[0],quantity:BigNum.new(e[1])}))).every((t=>!1===e.filter((e=>void 0!==e.output.amount.find((e=>e.unit===t.unit)))).reduce(((e,a)=>{const n=a.output.amount.reduce(((e,a)=>e.checkedAdd(BigNum.new(t.unit===a.unit?a.quantity:"0"))),BigNum.new("0"));return e.checkedAdd(n)}),BigNum.new("0")).lessThan(t.quantity))),largestLovelaceQuantity=(e,t)=>{const a=BigNum.new(e.output.amount.find((e=>"lovelace"===e.unit))?.quantity??"0");return BigNum.new(t.output.amount.find((e=>"lovelace"===e.unit))?.quantity??"0").compare(a)},maxTxFees=e=>{const{maxTxSize:t,minFeeA:a,minFeeB:n}=e;return BigNum.new(resolveTxFees(t,a,n))},multiAssetUTxO=e=>e.output.amount.length>1,selectedLovelaceQuantity=e=>e.reduce(((e,t)=>{const a=t.output.amount.find((e=>"lovelace"===e.unit))?.quantity??"0";return e.checkedAdd(BigNum.new(a))}),BigNum.new("0")),remainingLovelace=(e,t)=>{const a=t.sort(largestLovelaceQuantity);return selectValue(a,new Map([["lovelace",e]]))},selectValue=(e,t,a=[])=>0===e.length||enoughValueHasBeenSelected(a,t)?a:valueCanBeSelected(e[0],t)?selectValue(e.slice(1),t,[...a,e[0]]):selectValue(e.slice(1),t,a),valueCanBeSelected=(e,t)=>Array.from(t.keys()).some((t=>void 0!==e.output.amount.find((e=>e.unit===t)))),keepRelevant=(e,t,a="5000000")=>{const n=BigNum.new(e.get("lovelace")??"0").checkedAdd(BigNum.new(a)),i=t.filter((t=>t.output.amount.filter((e=>"lovelace"!==e.unit)).some((t=>e.has(t.unit))))),s=selectedLovelaceQuantity(i);return[...s.lessThan(n)?remainingLovelace(n.clampedSub(s).toString(),t.filter((e=>!i.some((t=>t.input.txHash===e.input.txHash&&t.input.outputIndex===e.input.outputIndex))))):[],...i]},largestFirst=(e,t,a=!1,{maxTxSize:n,minFeeA:i,minFeeB:s}=DEFAULT_PROTOCOL_PARAMETERS)=>{const r=t.filter((e=>!1===multiAssetUTxO(e))).sort(largestLovelaceQuantity),o=BigNum.new(resolveTxFees(n,i,s)),c=a?BigNum.new(e).checkedAdd(o).toString():e;return selectValue(r,new Map([["lovelace",c]]))},largestFirstMultiAsset=(e,t,a=!1,n=DEFAULT_PROTOCOL_PARAMETERS)=>{const i=t.filter(multiAssetUTxO).sort(largestLovelaceQuantity),s=maxTxFees(n),r=e.get("lovelace")??"0",o=a?BigNum.new(r).checkedAdd(s).toString():r;e.set("lovelace",o);return selectValue(i,e)},UtxoSelection=class{threshold;includeTxFees;constructor(e="5000000",t=!0){this.threshold=e,this.includeTxFees=t}largestFirst(e,t){const a=e.get("lovelace")??"0",n=BigInt(a)+BigInt(this.threshold);return largestFirst(n.toString(),t,this.includeTxFees)}keepRelevant(e,t){return keepRelevant(e,t,this.threshold)}largestFirstMultiAsset(e,t){const a=e.get("lovelace")??"0";return e.set("lovelace",(BigInt(a)+BigInt(this.threshold)).toString()),largestFirstMultiAsset(e,t,this.includeTxFees)}experimental(e,t){return experimentalSelectUtxos(e,t,this.threshold)}},TxTester=class{txBody;inputsEvaluating;outputsEvaluating;traces;constructor(e){this.txBody={...e},this.inputsEvaluating=[],this.outputsEvaluating=[],this.traces=[]}addTrace(e,t){const a=`[Error - ${e}]: ${t}`;this.traces.push(a)}success(){return 0===this.traces.length}errors(){return this.traces.length>0?`${this.traces}`:"No errors"}validAfter=e=>{const t=this.txBody.validityRange?.invalidHereafter?this.txBody.validityRange.invalidHereafter:9999999999999;return!this.txBody.validityRange?.invalidBefore||this.txBody.validityRange.invalidBefore<e||this.addTrace("validAfter",`tx invalid before ${t}, with requiredTimestamp ${e}`),this};validBefore=e=>{const t=this.txBody.validityRange?.invalidBefore?this.txBody.validityRange.invalidBefore:0;return!this.txBody.validityRange?.invalidHereafter||this.txBody.validityRange.invalidHereafter>e||this.addTrace("validBefore",`tx invalid after ${t}, with requiredTimestamp ${e}`),this};keySigned=e=>(keySignedLogic(this.txBody.requiredSignatures,e)||this.addTrace("keySigned",`tx does not have key ${e} signed`),this);oneOfKeysSigned=e=>(e.some((e=>keySignedLogic(this.txBody.requiredSignatures,e)))||this.addTrace("oneOfKeysSigned",`tx does not have any of the keys signed: ${e.join(", ")}`),this);allKeysSigned=e=>{const t=[];return e.every((e=>{const a=keySignedLogic(this.txBody.requiredSignatures,e);return a||t.push(e),a}))||this.addTrace("allKeysSigned",`tx does not have all keys signed: ${t.join(", ")}`),this};tokenMinted=(e,t,a)=>(tokenMintedLogic(this.txBody.mints,e,t,a)||this.addTrace("tokenMinted",`Token with policy_id: ${e}, asset_name: ${t}, quantity: ${a} not found in mints.`),this);onlyTokenMinted=(e,t,a)=>{const n=tokenMintedLogic(this.txBody.mints,e,t,a),i=1===this.txBody.mints?.length;return n||this.addTrace("onlyTokenMinted",`Token with policy_id: ${e}, asset_name: ${t}, quantity: ${a} not found in mints`),i||this.addTrace("onlyTokenMinted",`Expected only one mint, but found ${this.txBody.mints?.length||0} mints.`),this};policyOnlyMintedToken=(e,t,a)=>{const n=this.txBody.mints?.filter((t=>t.policyId===e))||[],i=tokenMintedLogic(this.txBody.mints,e,t,a);return 1===n.length||this.addTrace("policyOnlyMintedToken",`Expected only one mint for policy_id: ${e}, but found ${n.length} mints.`),i||this.addTrace("policyOnlyMintedToken",`Token with policy_id: ${e}, asset_name: ${t}, quantity: ${a} not found in mints.`),this};checkPolicyOnlyBurn=e=>0===(this.txBody.mints?.filter((t=>t.policyId===e&&t.mintValue.findIndex((e=>BigInt(e.amount)>0))>=0))||[]).length;allInputs=()=>(this.inputsEvaluating=this.txBody.inputs?.slice()||[],this);inputsAt=e=>(this.inputsEvaluating=this.txBody.inputs?.filter((t=>txInToUtxo(t.txIn).output.address===e))||[],this);inputsWith=e=>(this.inputsEvaluating=this.txBody.inputs?.filter((t=>MeshValue.fromAssets(txInToUtxo(t.txIn).output.amount).get(e)>0))||[],this);inputsWithPolicy=e=>(this.inputsEvaluating=this.txBody.inputs?.filter((t=>MeshValue.fromAssets(txInToUtxo(t.txIn).output.amount).getPolicyAssets(e).length>0))||[],this);inputsAtWithPolicy=(e,t)=>(this.inputsEvaluating=this.txBody.inputs?.filter((a=>{const n=txInToUtxo(a.txIn),i=MeshValue.fromAssets(n.output.amount).getPolicyAssets(t);return n.output.address===e&&i.length>0}))||[],this);inputsAtWith=(e,t)=>(this.inputsEvaluating=this.txBody.inputs?.filter((a=>{const n=txInToUtxo(a.txIn),i=MeshValue.fromAssets(n.output.amount).get(t);return n.output.address===e&&i>0}))||[],this);inputsValue=e=>{let t=new MeshValue;this.inputsEvaluating.forEach((e=>{const a=txInToUtxo(e.txIn);t.addAssets(a.output.amount)}));return t.eq(e)||this.addTrace("inputsValue",`inputs ${JSON.stringify(this.inputsEvaluating)} have value ${JSON.stringify(t)}, expect ${JSON.stringify(e)}`),this};allOutputs=()=>(this.outputsEvaluating=this.txBody.outputs?.slice()||[],this);outputsAt=e=>(this.outputsEvaluating=this.txBody.outputs?.filter((t=>t.address===e))||[],this);outputsWith=e=>(this.outputsEvaluating=this.txBody.outputs?.filter((t=>MeshValue.fromAssets(t.amount).get(e)>0))||[],this);outputsWithPolicy=e=>(this.outputsEvaluating=this.txBody.outputs?.filter((t=>MeshValue.fromAssets(t.amount).getPolicyAssets(e).length>0))||[],this);outputsAtWithPolicy=(e,t)=>(this.outputsEvaluating=this.txBody.outputs?.filter((a=>{const n=MeshValue.fromAssets(a.amount).getPolicyAssets(t);return a.address===e&&n.length>0}))||[],this);outputsAtWith=(e,t)=>(this.outputsEvaluating=this.txBody.outputs?.filter((a=>{const n=MeshValue.fromAssets(a.amount).get(t);return a.address===e&&n>0}))||[],this);outputsValue=e=>{let t=new MeshValue;this.outputsEvaluating.forEach((e=>{t.addAssets(e.amount)}));return t.eq(e)||this.addTrace("outputsValue",`tx outputs ${JSON.stringify(this.outputsEvaluating)} have value ${JSON.stringify(t)}, expected ${JSON.stringify(e)}`),this};outputsInlineDatumExist=e=>(0===this.outputsEvaluating.filter((t=>!(!t.datum||"Inline"!==t.datum.type)&&t.datum.data.content===e)).length&&this.addTrace("outputs_inline_datum_exist",`No outputs with inline datum matching: ${e}`),this)};function keySignedLogic(e,t){return e?.some((e=>e===t))||!1}function tokenMintedLogic(e,t,a,n){return e?.some((e=>e.policyId===t&&e.mintValue.findIndex((e=>e.assetName===a&&BigInt(e.amount)===BigInt(n)))>=0))||!1}import{generateMnemonic,mnemonicToEntropy}from"bip39";export{AssetFingerprint,BigNum,CIP68_100,CIP68_222,DEFAULT_FETCHER_OPTIONS,DEFAULT_PROTOCOL_PARAMETERS,DEFAULT_REDEEMER_BUDGET,DEFAULT_V1_COST_MODEL_LIST,DEFAULT_V2_COST_MODEL_LIST,DEFAULT_V3_COST_MODEL_LIST,DREP_DEPOSIT,GovernanceActionKind,HARDENED_KEY_START,LANGUAGE_VERSIONS,MeshValue,POLICY_ID_LENGTH,SLOT_CONFIG_NETWORK,SUPPORTED_CLOCKS,SUPPORTED_HANDLES,SUPPORTED_LANGUAGE_VIEWS,SUPPORTED_OGMIOS_LINKS,SUPPORTED_TOKENS,SUPPORTED_WALLETS,TxTester,UtxoSelection,VOTING_PROPOSAL_DEPOSIT,assetClass,assetName,assocMap,bool,builtinByteString,byteString,bytesToHex,castProtocol,cloneTxBuilderBody,conStr,conStr0,conStr1,conStr2,conStr3,credential,currencySymbol,dict,emptyTxBuilderBody,experimentalSelectUtxos,fromUTF8,fungibleAssetKeys,generateMnemonic,getFile,hashByteString,hashDrepAnchor,hexToBytes,hexToString,integer,isHexString,isNetwork,jsonProofToPlutusData,keepRelevant,keySignedLogic,largestFirst,largestFirstMultiAsset,list,mAssetClass,mBool,mConStr,mConStr0,mConStr1,mConStr2,mConStr3,mCredential,mMaybeStakingHash,mNone,mOption,mOutputReference,mPlutusBSArrayToString,mPubKeyAddress,mScript,mScriptAddress,mSome,mStringToPlutusBSArray,mTuple,mTxOutRef,mValue,mVerificationKey,maybeStakingHash,mergeAssets,metadataStandardKeys,metadataToCip68,mnemonicToEntropy,none,option,outputReference,pairs,parseAssetUnit,plutusBSArrayToString,policyId,posixTime,pubKeyAddress,pubKeyHash,resolveEpochNo,resolveFingerprint,resolveLanguageView,resolveSlotNo,resolveTxFees,royaltiesStandardKeys,script,scriptAddress,scriptHash,slotToBeginUnixTime,some,stringToBSArray,stringToHex,toBytes,toUTF8,tokenMintedLogic,tokenName,tuple,txInToUtxo,txOutRef,unixTimeToEnclosingSlot,validityRangeFromObj,validityRangeToObj,value,verificationKey};
//# sourceMappingURL=/sm/904a4aadb25fe41187c8942996390ea79ec2fdf4441454d2670392a3466c0e8f.map